diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..032f867f2728a55718e59efa6e8a56e71264345d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text +node_modules/@cloudflare/workerd-linux-64/bin/workerd filter=lfs diff=lfs merge=lfs -text +node_modules/workerd/bin/workerd filter=lfs diff=lfs merge=lfs -text diff --git a/index.js b/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c29e2f8a423c206f5c84d56598e5bdb322d261a2 --- /dev/null +++ b/index.js @@ -0,0 +1,27 @@ +const TelegramBot = require('node-telegram-bot-api'); +const axios = require('axios'); + +const telegramToken = '6610438736:AAFNPlGGY_SfuINu3dXThuyMFSOkoy1BpAg'; +const cloudflareToken = 'NB-sxyNA3JSyhezy2fUnTnXc3Pf7i8X17BJfBwLx'; + +const bot = new TelegramBot(telegramToken, {polling: true}); + +console.log('Loaded success..') + +bot.on('message', (msg) => { + const chatId = msg.chat.id; + const userMessage = msg.text; + + axios.post('https://api.cloudflare.com/client/v4/accounts/d888e02cee618e93b19cd9e7717da715/ai/run/@cf/meta/llama-2-7b-chat-int8', { + prompt: userMessage + }, { + headers: { + 'Authorization': `Bearer ${cloudflareToken}` + } + }).then(response => { + const aiResponse = response.data.result.response; + bot.sendMessage(chatId, aiResponse); + }).catch(error => { + console.error(error); + }); +}); \ No newline at end of file diff --git a/node_modules/@cloudflare/kv-asset-handler/LICENSE_APACHE b/node_modules/@cloudflare/kv-asset-handler/LICENSE_APACHE new file mode 100644 index 0000000000000000000000000000000000000000..a7e77cb28d386ec6eddeaabf441f91473ddefa1e --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/LICENSE_APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/node_modules/@cloudflare/kv-asset-handler/LICENSE_MIT b/node_modules/@cloudflare/kv-asset-handler/LICENSE_MIT new file mode 100644 index 0000000000000000000000000000000000000000..abf2bc736ee4e8d7c7465ddc911ab739f46c413f --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/LICENSE_MIT @@ -0,0 +1,25 @@ +Copyright (c) 2018 Ashley Williams + +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. \ No newline at end of file diff --git a/node_modules/@cloudflare/kv-asset-handler/README.md b/node_modules/@cloudflare/kv-asset-handler/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d5baa0a289345223863b5c224c77f2b6c5be6302 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/README.md @@ -0,0 +1,329 @@ +# @cloudflare/kv-asset-handler + +[![npm](https://img.shields.io/npm/v/@cloudflare/kv-asset-handler.svg)](https://www.npmjs.com/package/@cloudflare/kv-asset-handler)   +[![Run npm tests](https://github.com/cloudflare/kv-asset-handler/actions/workflows/test.yml/badge.svg)](https://github.com/cloudflare/kv-asset-handler/actions/workflows/test.yml)   +[![Lint Markdown](https://github.com/cloudflare/kv-asset-handler/actions/workflows/lint.yml/badge.svg)](https://github.com/cloudflare/kv-asset-handler/actions/workflows/lint.yml)   + +`kv-asset-handler` is an open-source library for managing the retrieval of static assets from [Workers KV](https://developers.cloudflare.com/workers/runtime-apis/kv) inside of a [Cloudflare Workers](https://workers.dev) function. `kv-asset-handler` is designed for use with [Workers Sites](https://developers.cloudflare.com/workers/platform/sites), a feature included in [Wrangler](https://github.com/cloudflare/wrangler), our command-line tool for deploying Workers projects. + +`kv-asset-handler` runs as part of a Cloudflare Workers function, so it allows you to customize _how_ and _when_ your static assets are loaded, as well as customize how those assets behave before they're sent to the client. + +Most users and sites will not need these customizations, and just want to serve their statically built applications. For that simple use-case, you can check out [Cloudflare Pages](https://pages.cloudflare.com), our batteries-included approach to deploying static sites on Cloudflare's edge network. Workers Sites was designed as a precursor to Cloudflare Pages, so check out Pages if you just want to deploy your static site without any special customizations! + +For users who _do_ want to customize their assets, and want to build complex experiences on top of their static assets, `kv-asset-handler` (and the default [Workers Sites template](https://github.com/cloudflare/worker-sites-template), which is provided for use with Wrangler + Workers Sites) allows you to customize caching behavior, headers, and anything else about how your Workers function loads the static assets for your site stored in Workers KV. + +The Cloudflare Workers Discord server is an active place where Workers users get help, share feedback, and collaborate on making our platform better. The `#workers-sites` channel in particular is a great place to chat about `kv-asset-handler`, and building cool experiences for your users using these tools! If you have questions, want to share what you're working on, or give feedback, [join us in Discord and say hello](https://discord.gg/cloudflaredev)! + +- [Installation](#installation) +- [Usage](#usage) +- [`getAssetFromKV`](#-getassetfromkv) + - [Example](#example) + * [Return](#return) + * [Optional Arguments](#optional-arguments) + - [`mapRequestToAsset`](#-maprequesttoasset) + - [Example](#example-1) + - [`cacheControl`](#-cachecontrol) + - [`browserTTL`](#browserttl) + - [`edgeTTL`](#edgettl) + - [`bypassCache`](#bypasscache) + - [`ASSET_NAMESPACE` (required for ES Modules)](#asset_namespace-required-for-es-modules) + - [`ASSET_MANIFEST` (required for ES Modules)](#asset_manifest-required-for-es-modules) + +* [Helper functions](#helper-functions) + - [`mapRequestToAsset`](#maprequesttoasset-1) + - [`serveSinglePageApp`](#servesinglepageapp) +* [Cache revalidation and etags](#cache-revalidation-and-etags) + +## Installation + +Add this package to your `package.json` by running this in the root of your +project's directory: + +``` +npm i @cloudflare/kv-asset-handler +``` + +## Usage + +This package was designed to work with [Worker Sites](https://workers.cloudflare.com/sites). + +## `getAssetFromKV` + +getAssetFromKV(Evt) => Promise + +`getAssetFromKV` is an async function that takes an `Evt` object (containing a `Request` and a [`waitUntil`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#waituntil)) and returns a `Response` object if the request matches an asset in KV, otherwise it will throw a `KVError`. + +#### Example + +This example checks for the existence of a value in KV, and returns it if it's there, and returns a 404 if it is not. It also serves index.html from `/`. + +### Return + +`getAssetFromKV` returns a `Promise` with `Response` being the body of the asset requested. + +Known errors to be thrown are: + +- MethodNotAllowedError +- NotFoundError +- InternalError + +#### ES Modules + +```js +import { getAssetFromKV, NotFoundError, MethodNotAllowedError } from '@cloudflare/kv-asset-handler' +import manifestJSON from '__STATIC_CONTENT_MANIFEST' +const assetManifest = JSON.parse(manifestJSON) + +export default { + async fetch(request, env, ctx) { + if (request.url.includes('/docs')) { + try { + return await getAssetFromKV( + { + request, + waitUntil(promise) { + return ctx.waitUntil(promise) + }, + }, + { + ASSET_NAMESPACE: env.__STATIC_CONTENT, + ASSET_MANIFEST: assetManifest, + }, + ) + } catch (e) { + if (e instanceof NotFoundError) { + // ... + } else if (e instanceof MethodNotAllowedError) { + // ... + } else { + return new Response('An unexpected error occurred', { status: 500 }) + } + } + } else return fetch(request) + }, +} +``` + +#### Service Worker + +```js +import { getAssetFromKV, NotFoundError, MethodNotAllowedError } from '@cloudflare/kv-asset-handler' + +addEventListener('fetch', (event) => { + event.respondWith(handleEvent(event)) +}) + +async function handleEvent(event) { + if (event.request.url.includes('/docs')) { + try { + return await getAssetFromKV(event) + } catch (e) { + if (e instanceof NotFoundError) { + // ... + } else if (e instanceof MethodNotAllowedError) { + // ... + } else { + return new Response('An unexpected error occurred', { status: 500 }) + } + } + } else return fetch(event.request) +} +``` + +### Optional Arguments + +You can customize the behavior of `getAssetFromKV` by passing the following properties as an object into the second argument. + +``` +getAssetFromKV(event, { mapRequestToAsset: ... }) +``` + +#### `mapRequestToAsset` + +mapRequestToAsset(Request) => Request + +Maps the incoming request to the value that will be looked up in Cloudflare's KV + +By default, mapRequestToAsset is set to the exported function [`mapRequestToAsset`](#maprequesttoasset-1). This works for most static site generators, but you can customize this behavior by passing your own function as `mapRequestToAsset`. The function should take a `Request` object as its only argument, and return a new `Request` object with an updated path to be looked up in the asset manifest/KV. + +For SPA mapping pass in the [`serveSinglePageApp`](#servesinglepageapp) function + +#### Example + +Strip `/docs` from any incoming request before looking up an asset in Cloudflare's KV. + +```js +import { getAssetFromKV, mapRequestToAsset } from '@cloudflare/kv-asset-handler' +... +const customKeyModifier = request => { + let url = request.url + //custom key mapping optional + url = url.replace('/docs', '').replace(/^\/+/, '') + return mapRequestToAsset(new Request(url, request)) +} +let asset = await getAssetFromKV(event, { mapRequestToAsset: customKeyModifier }) +``` + +#### `cacheControl` + +type: object + +`cacheControl` allows you to configure options for both the Cloudflare Cache accessed by your Worker, and the browser cache headers sent along with your Workers' responses. The default values are as follows: + +```javascript +let cacheControl = { + browserTTL: null, // do not set cache control ttl on responses + edgeTTL: 2 * 60 * 60 * 24, // 2 days + bypassCache: false, // do not bypass Cloudflare's cache +} +``` + +##### `browserTTL` + +type: number | null +nullable: true + +Sets the `Cache-Control: max-age` header on the response returned from the Worker. By default set to `null` which will not add the header at all. + +##### `edgeTTL` + +type: number | null +nullable: true + +Sets the `Cache-Control: max-age` header on the response used as the edge cache key. By default set to 2 days (`2 * 60 * 60 * 24`). When null will not cache on the edge at all. + +##### `bypassCache` + +type: boolean + +Determines whether to cache requests on Cloudflare's edge cache. By default set to `false` (recommended for production builds). Useful for development when you need to eliminate the cache's effect on testing. + +#### `ASSET_NAMESPACE` (required for ES Modules) + +type: KV Namespace Binding + +The binding name to the KV Namespace populated with key/value entries of files for the Worker to serve. By default, Workers Sites uses a [binding to a Workers KV Namespace](https://developers.cloudflare.com/workers/reference/storage/api/#namespaces) named `__STATIC_CONTENT`. + +It is further assumed that this namespace consists of static assets such as HTML, CSS, JavaScript, or image files, keyed off of a relative path that roughly matches the assumed URL pathname of the incoming request. + +In ES Modules format, this argument is required, and can be gotten from `env`. + +##### ES Module + +```js +return getAssetFromKV( + { + request, + waitUntil(promise) { + return ctx.waitUntil(promise) + }, + }, + { + ASSET_NAMESPACE: env.__STATIC_CONTENT, + }, +) +``` + +##### Service Worker + +``` +return getAssetFromKV(event, { ASSET_NAMESPACE: MY_NAMESPACE }) +``` + +#### `ASSET_MANIFEST` (required for ES Modules) + +type: text blob (JSON formatted) or object + +The mapping of requested file path to the key stored on Cloudflare. + +Workers Sites with Wrangler bundles up a text blob that maps request paths to content-hashed keys that are generated by Wrangler as a cache-busting measure. If this option/binding is not present, the function will fallback to using the raw pathname to look up your asset in KV. If, for whatever reason, you have rolled your own implementation of this, you can include your own by passing a stringified JSON object where the keys are expected paths, and the values are the expected keys in your KV namespace. + +In ES Modules format, this argument is required, and can be imported. + +##### ES Module + +```js +import manifestJSON from '__STATIC_CONTENT_MANIFEST' +let manifest = JSON.parse(manifestJSON) +manifest['index.html'] = 'index.special.html' + +return getAssetFromKV( + { + request, + waitUntil(promise) { + return ctx.waitUntil(promise) + }, + }, + { + ASSET_MANIFEST: manifest, + // ... + }, +) +``` + +##### Service Worker + +``` +let assetManifest = { "index.html": "index.special.html" } +return getAssetFromKV(event, { ASSET_MANIFEST: assetManifest }) +``` + +#### `defaultMimeType` (optional) + +type: string + +This is the mime type that will be used for files with unrecognized or missing extensions. The default value is `'text/plain'`. + +If you are serving a static site and would like to use extensionless HTML files instead of index.html files, set this to `'text/html'`. + +#### `defaultDocument` (optional) + +type: string + +This is the default document that will be concatenated for requests ends in `'/'` or without a valid mime type like `'/about'` or `'/about.me'`. The default value is `'index.html'`. + +# Helper functions + +## `mapRequestToAsset` + +mapRequestToAsset(Request) => Request + +The default function for mapping incoming requests to keys in Cloudflare's KV. + +Takes any path that ends in `/` or evaluates to an HTML file and appends `index.html` or `/index.html` for lookup in your Workers KV namespace. + +## `serveSinglePageApp` + +serveSinglePageApp(Request) => Request + +A custom handler for mapping requests to a single root: `index.html`. The most common use case is single-page applications - frameworks with in-app routing - such as React Router, VueJS, etc. It takes zero arguments. + +```js +import { getAssetFromKV, serveSinglePageApp } from '@cloudflare/kv-asset-handler' +... +let asset = await getAssetFromKV(event, { mapRequestToAsset: serveSinglePageApp }) +``` + +# Cache revalidation and etags + +All responses served from cache (including those with `cf-cache-status: MISS`) include an `etag` response header that identifies the version of the resource. The `etag` value is identical to the path key used in the `ASSET_MANIFEST`. It is updated each time an asset changes and looks like this: `etag: ..` (ex. `etag: index.54321.html`). + +Resources served with an `etag` allow browsers to use the `if-none-match` request header to make conditional requests for that resource in the future. This has two major benefits: + +- When a request's `if-none-match` value matches the `etag` of the resource in Cloudflare cache, Cloudflare will send a `304 Not Modified` response without a body, saving bandwidth. +- Changes to a file on the server are immediately reflected in the browser - even when the cache control directive `max-age` is unexpired. + +#### Disable the `etag` + +To turn `etags` **off**, you must bypass cache: + +```js +/* Turn etags off */ +let cacheControl = { + bypassCache: true, +} +``` + +#### Syntax and comparison context + +`kv-asset-handler` sets and evaluates etags as [strong validators](https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests#Strong_validation). To preserve `etag` integrity, the format of the value deviates from the [RFC2616 recommendation to enclose the `etag` with quotation marks](https://tools.ietf.org/html/rfc2616#section-3.11). This is intentional. Cloudflare cache applies the `W/` prefix to all `etags` that use quoted-strings -- a process that converts the `etag` to a "weak validator" when served to a client. diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/index.d.ts b/node_modules/@cloudflare/kv-asset-handler/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7820e622f73c7cc63bb95f68c98bda63dea6cea3 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/index.d.ts @@ -0,0 +1,36 @@ +import { Options, CacheControl, MethodNotAllowedError, NotFoundError, InternalError } from './types'; +declare global { + var __STATIC_CONTENT: any, __STATIC_CONTENT_MANIFEST: string; +} +/** + * maps the path of incoming request to the request pathKey to look up + * in bucket and in cache + * e.g. for a path '/' returns '/index.html' which serves + * the content of bucket/index.html + * @param {Request} request incoming request + */ +declare const mapRequestToAsset: (request: Request, options?: Partial) => Request; +/** + * maps the path of incoming request to /index.html if it evaluates to + * any HTML file. + * @param {Request} request incoming request + */ +declare function serveSinglePageApp(request: Request, options?: Partial): Request; +/** + * takes the path of the incoming request, gathers the appropriate content from KV, and returns + * the response + * + * @param {FetchEvent} event the fetch event of the triggered request + * @param {{mapRequestToAsset: (string: Request) => Request, cacheControl: {bypassCache:boolean, edgeTTL: number, browserTTL:number}, ASSET_NAMESPACE: any, ASSET_MANIFEST:any}} [options] configurable options + * @param {CacheControl} [options.cacheControl] determine how to cache on Cloudflare and the browser + * @param {typeof(options.mapRequestToAsset)} [options.mapRequestToAsset] maps the path of incoming request to the request pathKey to look up + * @param {Object | string} [options.ASSET_NAMESPACE] the binding to the namespace that script references + * @param {any} [options.ASSET_MANIFEST] the map of the key to cache and store in KV + * */ +declare type Evt = { + request: Request; + waitUntil: (promise: Promise) => void; +}; +declare const getAssetFromKV: (event: Evt, options?: Partial) => Promise; +export { getAssetFromKV, mapRequestToAsset, serveSinglePageApp }; +export { Options, CacheControl, MethodNotAllowedError, NotFoundError, InternalError }; diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/index.js b/node_modules/@cloudflare/kv-asset-handler/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5f80b5eb2942a77db613ba5cd9bc63bd75cd9b34 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/index.js @@ -0,0 +1,267 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InternalError = exports.NotFoundError = exports.MethodNotAllowedError = exports.serveSinglePageApp = exports.mapRequestToAsset = exports.getAssetFromKV = void 0; +const mime = require("mime"); +const types_1 = require("./types"); +Object.defineProperty(exports, "MethodNotAllowedError", { enumerable: true, get: function () { return types_1.MethodNotAllowedError; } }); +Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return types_1.NotFoundError; } }); +Object.defineProperty(exports, "InternalError", { enumerable: true, get: function () { return types_1.InternalError; } }); +const defaultCacheControl = { + browserTTL: null, + edgeTTL: 2 * 60 * 60 * 24, + bypassCache: false, // do not bypass Cloudflare's cache +}; +const parseStringAsObject = (maybeString) => typeof maybeString === 'string' ? JSON.parse(maybeString) : maybeString; +const getAssetFromKVDefaultOptions = { + ASSET_NAMESPACE: typeof __STATIC_CONTENT !== 'undefined' ? __STATIC_CONTENT : undefined, + ASSET_MANIFEST: typeof __STATIC_CONTENT_MANIFEST !== 'undefined' + ? parseStringAsObject(__STATIC_CONTENT_MANIFEST) + : {}, + cacheControl: defaultCacheControl, + defaultMimeType: 'text/plain', + defaultDocument: 'index.html', + pathIsEncoded: false, +}; +function assignOptions(options) { + // Assign any missing options passed in to the default + // options.mapRequestToAsset is handled manually later + return Object.assign({}, getAssetFromKVDefaultOptions, options); +} +/** + * maps the path of incoming request to the request pathKey to look up + * in bucket and in cache + * e.g. for a path '/' returns '/index.html' which serves + * the content of bucket/index.html + * @param {Request} request incoming request + */ +const mapRequestToAsset = (request, options) => { + options = assignOptions(options); + const parsedUrl = new URL(request.url); + let pathname = parsedUrl.pathname; + if (pathname.endsWith('/')) { + // If path looks like a directory append options.defaultDocument + // e.g. If path is /about/ -> /about/index.html + pathname = pathname.concat(options.defaultDocument); + } + else if (!mime.getType(pathname)) { + // If path doesn't look like valid content + // e.g. /about.me -> /about.me/index.html + pathname = pathname.concat('/' + options.defaultDocument); + } + parsedUrl.pathname = pathname; + return new Request(parsedUrl.toString(), request); +}; +exports.mapRequestToAsset = mapRequestToAsset; +/** + * maps the path of incoming request to /index.html if it evaluates to + * any HTML file. + * @param {Request} request incoming request + */ +function serveSinglePageApp(request, options) { + options = assignOptions(options); + // First apply the default handler, which already has logic to detect + // paths that should map to HTML files. + request = mapRequestToAsset(request, options); + const parsedUrl = new URL(request.url); + // Detect if the default handler decided to map to + // a HTML file in some specific directory. + if (parsedUrl.pathname.endsWith('.html')) { + // If expected HTML file was missing, just return the root index.html (or options.defaultDocument) + return new Request(`${parsedUrl.origin}/${options.defaultDocument}`, request); + } + else { + // The default handler decided this is not an HTML page. It's probably + // an image, CSS, or JS file. Leave it as-is. + return request; + } +} +exports.serveSinglePageApp = serveSinglePageApp; +const getAssetFromKV = async (event, options) => { + options = assignOptions(options); + const request = event.request; + const ASSET_NAMESPACE = options.ASSET_NAMESPACE; + const ASSET_MANIFEST = parseStringAsObject(options.ASSET_MANIFEST); + if (typeof ASSET_NAMESPACE === 'undefined') { + throw new types_1.InternalError(`there is no KV namespace bound to the script`); + } + const rawPathKey = new URL(request.url).pathname.replace(/^\/+/, ''); // strip any preceding /'s + let pathIsEncoded = options.pathIsEncoded; + let requestKey; + // if options.mapRequestToAsset is explicitly passed in, always use it and assume user has own intentions + // otherwise handle request as normal, with default mapRequestToAsset below + if (options.mapRequestToAsset) { + requestKey = options.mapRequestToAsset(request); + } + else if (ASSET_MANIFEST[rawPathKey]) { + requestKey = request; + } + else if (ASSET_MANIFEST[decodeURIComponent(rawPathKey)]) { + pathIsEncoded = true; + requestKey = request; + } + else { + const mappedRequest = mapRequestToAsset(request); + const mappedRawPathKey = new URL(mappedRequest.url).pathname.replace(/^\/+/, ''); + if (ASSET_MANIFEST[decodeURIComponent(mappedRawPathKey)]) { + pathIsEncoded = true; + requestKey = mappedRequest; + } + else { + // use default mapRequestToAsset + requestKey = mapRequestToAsset(request, options); + } + } + const SUPPORTED_METHODS = ['GET', 'HEAD']; + if (!SUPPORTED_METHODS.includes(requestKey.method)) { + throw new types_1.MethodNotAllowedError(`${requestKey.method} is not a valid request method`); + } + const parsedUrl = new URL(requestKey.url); + const pathname = pathIsEncoded ? decodeURIComponent(parsedUrl.pathname) : parsedUrl.pathname; // decode percentage encoded path only when necessary + // pathKey is the file path to look up in the manifest + let pathKey = pathname.replace(/^\/+/, ''); // remove prepended / + // @ts-ignore + const cache = caches.default; + let mimeType = mime.getType(pathKey) || options.defaultMimeType; + if (mimeType.startsWith('text') || mimeType === 'application/javascript') { + mimeType += '; charset=utf-8'; + } + let shouldEdgeCache = false; // false if storing in KV by raw file path i.e. no hash + // check manifest for map from file path to hash + if (typeof ASSET_MANIFEST !== 'undefined') { + if (ASSET_MANIFEST[pathKey]) { + pathKey = ASSET_MANIFEST[pathKey]; + // if path key is in asset manifest, we can assume it contains a content hash and can be cached + shouldEdgeCache = true; + } + } + // TODO this excludes search params from cache, investigate ideal behavior + let cacheKey = new Request(`${parsedUrl.origin}/${pathKey}`, request); + // if argument passed in for cacheControl is a function then + // evaluate that function. otherwise return the Object passed in + // or default Object + const evalCacheOpts = (() => { + switch (typeof options.cacheControl) { + case 'function': + return options.cacheControl(request); + case 'object': + return options.cacheControl; + default: + return defaultCacheControl; + } + })(); + // formats the etag depending on the response context. if the entityId + // is invalid, returns an empty string (instead of null) to prevent the + // the potentially disastrous scenario where the value of the Etag resp + // header is "null". Could be modified in future to base64 encode etc + const formatETag = (entityId = pathKey, validatorType = 'strong') => { + if (!entityId) { + return ''; + } + switch (validatorType) { + case 'weak': + if (!entityId.startsWith('W/')) { + return `W/${entityId}`; + } + return entityId; + case 'strong': + if (entityId.startsWith(`W/"`)) { + entityId = entityId.replace('W/', ''); + } + if (!entityId.endsWith(`"`)) { + entityId = `"${entityId}"`; + } + return entityId; + default: + return ''; + } + }; + options.cacheControl = Object.assign({}, defaultCacheControl, evalCacheOpts); + // override shouldEdgeCache if options say to bypassCache + if (options.cacheControl.bypassCache || + options.cacheControl.edgeTTL === null || + request.method == 'HEAD') { + shouldEdgeCache = false; + } + // only set max-age if explicitly passed in a number as an arg + const shouldSetBrowserCache = typeof options.cacheControl.browserTTL === 'number'; + let response = null; + if (shouldEdgeCache) { + response = await cache.match(cacheKey); + } + if (response) { + if (response.status > 300 && response.status < 400) { + if (response.body && 'cancel' in Object.getPrototypeOf(response.body)) { + // Body exists and environment supports readable streams + response.body.cancel(); + } + else { + // Environment doesnt support readable streams, or null repsonse body. Nothing to do + } + response = new Response(null, response); + } + else { + // fixes #165 + let opts = { + headers: new Headers(response.headers), + status: 0, + statusText: '', + }; + opts.headers.set('cf-cache-status', 'HIT'); + if (response.status) { + opts.status = response.status; + opts.statusText = response.statusText; + } + else if (opts.headers.has('Content-Range')) { + opts.status = 206; + opts.statusText = 'Partial Content'; + } + else { + opts.status = 200; + opts.statusText = 'OK'; + } + response = new Response(response.body, opts); + } + } + else { + const body = await ASSET_NAMESPACE.get(pathKey, 'arrayBuffer'); + if (body === null) { + throw new types_1.NotFoundError(`could not find ${pathKey} in your content namespace`); + } + response = new Response(body); + if (shouldEdgeCache) { + response.headers.set('Accept-Ranges', 'bytes'); + response.headers.set('Content-Length', body.length); + // set etag before cache insertion + if (!response.headers.has('etag')) { + response.headers.set('etag', formatETag(pathKey, 'strong')); + } + // determine Cloudflare cache behavior + response.headers.set('Cache-Control', `max-age=${options.cacheControl.edgeTTL}`); + event.waitUntil(cache.put(cacheKey, response.clone())); + response.headers.set('CF-Cache-Status', 'MISS'); + } + } + response.headers.set('Content-Type', mimeType); + if (response.status === 304) { + let etag = formatETag(response.headers.get('etag'), 'strong'); + let ifNoneMatch = cacheKey.headers.get('if-none-match'); + let proxyCacheStatus = response.headers.get('CF-Cache-Status'); + if (etag) { + if (ifNoneMatch && ifNoneMatch === etag && proxyCacheStatus === 'MISS') { + response.headers.set('CF-Cache-Status', 'EXPIRED'); + } + else { + response.headers.set('CF-Cache-Status', 'REVALIDATED'); + } + response.headers.set('etag', formatETag(etag, 'weak')); + } + } + if (shouldSetBrowserCache) { + response.headers.set('Cache-Control', `max-age=${options.cacheControl.browserTTL}`); + } + else { + response.headers.delete('Cache-Control'); + } + return response; +}; +exports.getAssetFromKV = getAssetFromKV; diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/mocks.d.ts b/node_modules/@cloudflare/kv-asset-handler/dist/mocks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8293350279f7f586a66f6df7a66f51d0e58c423 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/mocks.d.ts @@ -0,0 +1,14 @@ +export declare const getEvent: (request: Request) => any; +export declare const mockKV: (store: any) => { + get: (path: string) => any; +}; +export declare const mockManifest: () => string; +export declare const mockCaches: () => { + default: { + match(key: any): Promise; + put(key: any, val: Response): Promise; + }; +}; +export declare function mockRequestScope(): void; +export declare function mockGlobalScope(): void; +export declare const sleep: (milliseconds: number) => Promise; diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/mocks.js b/node_modules/@cloudflare/kv-asset-handler/dist/mocks.js new file mode 100644 index 0000000000000000000000000000000000000000..0f7a338a9cf556680d9d23c2ac2e8bd30d064237 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/mocks.js @@ -0,0 +1,146 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.sleep = exports.mockGlobalScope = exports.mockRequestScope = exports.mockCaches = exports.mockManifest = exports.mockKV = exports.getEvent = void 0; +const makeServiceWorkerEnv = require('service-worker-mock'); +const HASH = '123HASHBROWN'; +const getEvent = (request) => { + const waitUntil = async (callback) => { + await callback; + }; + return { + request, + waitUntil, + }; +}; +exports.getEvent = getEvent; +const store = { + 'key1.123HASHBROWN.txt': 'val1', + 'key1.123HASHBROWN.png': 'val1', + 'index.123HASHBROWN.html': 'index.html', + 'cache.123HASHBROWN.html': 'cache me if you can', + '测试.123HASHBROWN.html': 'My filename is non-ascii', + '%not-really-percent-encoded.123HASHBROWN.html': 'browser percent encoded', + '%2F.123HASHBROWN.html': 'user percent encoded', + '你好.123HASHBROWN.html': 'I shouldnt be served', + '%E4%BD%A0%E5%A5%BD.123HASHBROWN.html': 'Im important', + 'nohash.txt': 'no hash but still got some result', + 'sub/blah.123HASHBROWN.png': 'picturedis', + 'sub/index.123HASHBROWN.html': 'picturedis', + 'client.123HASHBROWN': 'important file', + 'client.123HASHBROWN/index.html': 'Im here but serve my big bro above', + 'image.123HASHBROWN.png': 'imagepng', + 'image.123HASHBROWN.webp': 'imagewebp', + '你好/index.123HASHBROWN.html': 'My path is non-ascii', +}; +const mockKV = (store) => { + return { + get: (path) => store[path] || null, + }; +}; +exports.mockKV = mockKV; +const mockManifest = () => { + return JSON.stringify({ + 'key1.txt': `key1.${HASH}.txt`, + 'key1.png': `key1.${HASH}.png`, + 'cache.html': `cache.${HASH}.html`, + '测试.html': `测试.${HASH}.html`, + '你好.html': `你好.${HASH}.html`, + '%not-really-percent-encoded.html': `%not-really-percent-encoded.${HASH}.html`, + '%2F.html': `%2F.${HASH}.html`, + '%E4%BD%A0%E5%A5%BD.html': `%E4%BD%A0%E5%A5%BD.${HASH}.html`, + 'index.html': `index.${HASH}.html`, + 'sub/blah.png': `sub/blah.${HASH}.png`, + 'sub/index.html': `sub/index.${HASH}.html`, + client: `client.${HASH}`, + 'client/index.html': `client.${HASH}`, + 'image.png': `image.${HASH}.png`, + 'image.webp': `image.${HASH}.webp`, + '你好/index.html': `你好/index.${HASH}.html`, + }); +}; +exports.mockManifest = mockManifest; +let cacheStore = new Map(); +const mockCaches = () => { + return { + default: { + async match(key) { + let cacheKey = { + url: key.url, + headers: {}, + }; + let response; + if (key.headers.has('if-none-match')) { + let makeStrongEtag = key.headers.get('if-none-match').replace('W/', ''); + Reflect.set(cacheKey.headers, 'etag', makeStrongEtag); + response = cacheStore.get(JSON.stringify(cacheKey)); + } + else { + // if client doesn't send if-none-match, we need to iterate through these keys + // and just test the URL + const activeCacheKeys = Array.from(cacheStore.keys()); + for (const cacheStoreKey of activeCacheKeys) { + if (JSON.parse(cacheStoreKey).url === key.url) { + response = cacheStore.get(cacheStoreKey); + } + } + } + // TODO: write test to accomodate for rare scenarios with where range requests accomodate etags + if (response && !key.headers.has('if-none-match')) { + // this appears overly verbose, but is necessary to document edge cache behavior + // The Range request header triggers the response header Content-Range ... + const range = key.headers.get('range'); + if (range) { + response.headers.set('content-range', `bytes ${range.split('=').pop()}/${response.headers.get('content-length')}`); + } + // ... which we are using in this repository to set status 206 + if (response.headers.has('content-range')) { + response.status = 206; + } + else { + response.status = 200; + } + let etag = response.headers.get('etag'); + if (etag && !etag.includes('W/')) { + response.headers.set('etag', `W/${etag}`); + } + } + return response; + }, + async put(key, val) { + let headers = new Headers(val.headers); + let url = new URL(key.url); + let resWithBody = new Response(val.body, { headers, status: 200 }); + let resNoBody = new Response(null, { headers, status: 304 }); + let cacheKey = { + url: key.url, + headers: { + etag: `"${url.pathname.replace('/', '')}"`, + }, + }; + cacheStore.set(JSON.stringify(cacheKey), resNoBody); + cacheKey.headers = {}; + cacheStore.set(JSON.stringify(cacheKey), resWithBody); + return; + }, + }, + }; +}; +exports.mockCaches = mockCaches; +// mocks functionality used inside worker request +function mockRequestScope() { + Object.assign(global, makeServiceWorkerEnv()); + Object.assign(global, { __STATIC_CONTENT_MANIFEST: (0, exports.mockManifest)() }); + Object.assign(global, { __STATIC_CONTENT: (0, exports.mockKV)(store) }); + Object.assign(global, { caches: (0, exports.mockCaches)() }); +} +exports.mockRequestScope = mockRequestScope; +// mocks functionality used on global isolate scope. such as the KV namespace bind +function mockGlobalScope() { + Object.assign(global, { __STATIC_CONTENT_MANIFEST: (0, exports.mockManifest)() }); + Object.assign(global, { __STATIC_CONTENT: (0, exports.mockKV)(store) }); +} +exports.mockGlobalScope = mockGlobalScope; +const sleep = (milliseconds) => { + return new Promise((resolve) => setTimeout(resolve, milliseconds)); +}; +exports.sleep = sleep; diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV-optional.d.ts b/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV-optional.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV-optional.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV-optional.js b/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV-optional.js new file mode 100644 index 0000000000000000000000000000000000000000..83838ad3c46813577f769ddec4b054a9dcaf63eb --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV-optional.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const ava_1 = require("ava"); +const mocks_1 = require("../mocks"); +(0, mocks_1.mockGlobalScope)(); +// manually reset manifest global, to test optional behaviour +Object.assign(global, { __STATIC_CONTENT_MANIFEST: undefined }); +const index_1 = require("../index"); +(0, ava_1.default)('getAssetFromKV return correct val from KV without manifest', async (t) => { + (0, mocks_1.mockRequestScope)(); + // manually reset manifest global, to test optional behaviour + Object.assign(global, { __STATIC_CONTENT_MANIFEST: undefined }); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/key1.123HASHBROWN.txt')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'val1'); + t.true(res.headers.get('content-type').includes('text')); + } + else { + t.fail('Response was undefined'); + } +}); diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts b/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js b/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js new file mode 100644 index 0000000000000000000000000000000000000000..724c1d11957d31ed711a93aec846dc316d1d78bd --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js @@ -0,0 +1,446 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const ava_1 = require("ava"); +const mocks_1 = require("../mocks"); +(0, mocks_1.mockGlobalScope)(); +const index_1 = require("../index"); +(0, ava_1.default)('getAssetFromKV return correct val from KV and default caching', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/key1.txt')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(res.headers.get('cache-control'), null); + t.is(res.headers.get('cf-cache-status'), 'MISS'); + t.is(await res.text(), 'val1'); + t.true(res.headers.get('content-type').includes('text')); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV evaluated the file matching the extensionless path first /client/ -> client', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request(`https://foo.com/client/`)); + const res = await (0, index_1.getAssetFromKV)(event); + t.is(await res.text(), 'important file'); + t.true(res.headers.get('content-type').includes('text')); +}); +(0, ava_1.default)('getAssetFromKV evaluated the file matching the extensionless path first /client -> client', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request(`https://foo.com/client`)); + const res = await (0, index_1.getAssetFromKV)(event); + t.is(await res.text(), 'important file'); + t.true(res.headers.get('content-type').includes('text')); +}); +(0, ava_1.default)('getAssetFromKV if not in asset manifest still returns nohash.txt', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/nohash.txt')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'no hash but still got some result'); + t.true(res.headers.get('content-type').includes('text')); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV if no asset manifest /client -> client fails', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request(`https://foo.com/client`)); + const error = await t.throwsAsync((0, index_1.getAssetFromKV)(event, { ASSET_MANIFEST: {} })); + t.is(error.status, 404); +}); +(0, ava_1.default)('getAssetFromKV if sub/ -> sub/index.html served', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request(`https://foo.com/sub`)); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'picturedis'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV gets index.html by default for / requests', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'index.html'); + t.true(res.headers.get('content-type').includes('html')); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV non ASCII path support', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/测试.html')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'My filename is non-ascii'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV supports browser percent encoded URLs', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://example.com/%not-really-percent-encoded.html')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'browser percent encoded'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV supports user percent encoded URLs', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/%2F.html')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'user percent encoded'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV only decode URL when necessary', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event1 = (0, mocks_1.getEvent)(new Request('https://blah.com/%E4%BD%A0%E5%A5%BD.html')); + const event2 = (0, mocks_1.getEvent)(new Request('https://blah.com/你好.html')); + const res1 = await (0, index_1.getAssetFromKV)(event1); + const res2 = await (0, index_1.getAssetFromKV)(event2); + if (res1 && res2) { + t.is(await res1.text(), 'Im important'); + t.is(await res2.text(), 'Im important'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV Support for user decode url path', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event1 = (0, mocks_1.getEvent)(new Request('https://blah.com/%E4%BD%A0%E5%A5%BD/')); + const event2 = (0, mocks_1.getEvent)(new Request('https://blah.com/你好/')); + const res1 = await (0, index_1.getAssetFromKV)(event1); + const res2 = await (0, index_1.getAssetFromKV)(event2); + if (res1 && res2) { + t.is(await res1.text(), 'My path is non-ascii'); + t.is(await res2.text(), 'My path is non-ascii'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV custom key modifier', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/docs/sub/blah.png')); + const customRequestMapper = (request) => { + let defaultModifiedRequest = (0, index_1.mapRequestToAsset)(request); + let url = new URL(defaultModifiedRequest.url); + url.pathname = url.pathname.replace('/docs', ''); + return new Request(url.toString(), request); + }; + const res = await (0, index_1.getAssetFromKV)(event, { mapRequestToAsset: customRequestMapper }); + if (res) { + t.is(await res.text(), 'picturedis'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV request override with existing manifest file', async (t) => { + // see https://github.com/cloudflare/kv-asset-handler/pull/159 for more info + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/image.png')); // real file in manifest + const customRequestMapper = (request) => { + let defaultModifiedRequest = (0, index_1.mapRequestToAsset)(request); + let url = new URL(defaultModifiedRequest.url); + url.pathname = '/image.webp'; // other different file in manifest + return new Request(url.toString(), request); + }; + const res = await (0, index_1.getAssetFromKV)(event, { mapRequestToAsset: customRequestMapper }); + if (res) { + t.is(await res.text(), 'imagewebp'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV when setting browser caching', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/')); + const res = await (0, index_1.getAssetFromKV)(event, { cacheControl: { browserTTL: 22 } }); + if (res) { + t.is(res.headers.get('cache-control'), 'max-age=22'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV when setting custom cache setting', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event1 = (0, mocks_1.getEvent)(new Request('https://blah.com/')); + const event2 = (0, mocks_1.getEvent)(new Request('https://blah.com/key1.png?blah=34')); + const cacheOnlyPngs = (req) => { + if (new URL(req.url).pathname.endsWith('.png')) + return { + browserTTL: 720, + edgeTTL: 720, + }; + else + return { + bypassCache: true, + }; + }; + const res1 = await (0, index_1.getAssetFromKV)(event1, { cacheControl: cacheOnlyPngs }); + const res2 = await (0, index_1.getAssetFromKV)(event2, { cacheControl: cacheOnlyPngs }); + if (res1 && res2) { + t.is(res1.headers.get('cache-control'), null); + t.true(res2.headers.get('content-type').includes('png')); + t.is(res2.headers.get('cache-control'), 'max-age=720'); + t.is(res2.headers.get('cf-cache-status'), 'MISS'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV caches on two sequential requests', async (t) => { + (0, mocks_1.mockRequestScope)(); + const resourceKey = 'cache.html'; + const resourceVersion = JSON.parse((0, mocks_1.mockManifest)())[resourceKey]; + const event1 = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`)); + const event2 = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}"`, + }, + })); + const res1 = await (0, index_1.getAssetFromKV)(event1, { cacheControl: { edgeTTL: 720, browserTTL: 720 } }); + await (0, mocks_1.sleep)(1); + const res2 = await (0, index_1.getAssetFromKV)(event2); + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS'); + t.is(res1.headers.get('cache-control'), 'max-age=720'); + t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV does not store max-age on two sequential requests', async (t) => { + (0, mocks_1.mockRequestScope)(); + const resourceKey = 'cache.html'; + const resourceVersion = JSON.parse((0, mocks_1.mockManifest)())[resourceKey]; + const event1 = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`)); + const event2 = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}"`, + }, + })); + const res1 = await (0, index_1.getAssetFromKV)(event1, { cacheControl: { edgeTTL: 720 } }); + await (0, mocks_1.sleep)(100); + const res2 = await (0, index_1.getAssetFromKV)(event2); + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS'); + t.is(res1.headers.get('cache-control'), null); + t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED'); + t.is(res2.headers.get('cache-control'), null); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV does not cache on Cloudflare when bypass cache set', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/')); + const res = await (0, index_1.getAssetFromKV)(event, { cacheControl: { bypassCache: true } }); + if (res) { + t.is(res.headers.get('cache-control'), null); + t.is(res.headers.get('cf-cache-status'), null); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV with no trailing slash on root', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'index.html'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV with no trailing slash on a subdirectory', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/sub/blah.png')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'picturedis'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV no result throws an error', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/random')); + const error = await t.throwsAsync((0, index_1.getAssetFromKV)(event)); + t.is(error.status, 404); +}); +(0, ava_1.default)('getAssetFromKV TTls set to null should not cache on browser or edge', async (t) => { + (0, mocks_1.mockRequestScope)(); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/')); + const res1 = await (0, index_1.getAssetFromKV)(event, { cacheControl: { browserTTL: null, edgeTTL: null } }); + await (0, mocks_1.sleep)(100); + const res2 = await (0, index_1.getAssetFromKV)(event, { cacheControl: { browserTTL: null, edgeTTL: null } }); + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), null); + t.is(res1.headers.get('cache-control'), null); + t.is(res2.headers.get('cf-cache-status'), null); + t.is(res2.headers.get('cache-control'), null); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV passing in a custom NAMESPACE serves correct asset', async (t) => { + (0, mocks_1.mockRequestScope)(); + let CUSTOM_NAMESPACE = (0, mocks_1.mockKV)({ + 'key1.123HASHBROWN.txt': 'val1', + }); + Object.assign(global, { CUSTOM_NAMESPACE }); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/')); + const res = await (0, index_1.getAssetFromKV)(event); + if (res) { + t.is(await res.text(), 'index.html'); + t.true(res.headers.get('content-type').includes('html')); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV when custom namespace without the asset should fail', async (t) => { + (0, mocks_1.mockRequestScope)(); + let CUSTOM_NAMESPACE = (0, mocks_1.mockKV)({ + 'key5.123HASHBROWN.txt': 'customvalu', + }); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com')); + const error = await t.throwsAsync((0, index_1.getAssetFromKV)(event, { ASSET_NAMESPACE: CUSTOM_NAMESPACE })); + t.is(error.status, 404); +}); +(0, ava_1.default)('getAssetFromKV when namespace not bound fails', async (t) => { + (0, mocks_1.mockRequestScope)(); + var MY_CUSTOM_NAMESPACE = undefined; + Object.assign(global, { MY_CUSTOM_NAMESPACE }); + const event = (0, mocks_1.getEvent)(new Request('https://blah.com/')); + const error = await t.throwsAsync((0, index_1.getAssetFromKV)(event, { ASSET_NAMESPACE: MY_CUSTOM_NAMESPACE })); + t.is(error.status, 500); +}); +(0, ava_1.default)('getAssetFromKV when if-none-match === active resource version, should revalidate', async (t) => { + (0, mocks_1.mockRequestScope)(); + const resourceKey = 'key1.png'; + const resourceVersion = JSON.parse((0, mocks_1.mockManifest)())[resourceKey]; + const event1 = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`)); + const event2 = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `W/"${resourceVersion}"`, + }, + })); + const res1 = await (0, index_1.getAssetFromKV)(event1, { cacheControl: { edgeTTL: 720 } }); + await (0, mocks_1.sleep)(100); + const res2 = await (0, index_1.getAssetFromKV)(event2); + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS'); + t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV when if-none-match equals etag of stale resource then should bypass cache', async (t) => { + (0, mocks_1.mockRequestScope)(); + const resourceKey = 'key1.png'; + const resourceVersion = JSON.parse((0, mocks_1.mockManifest)())[resourceKey]; + const req1 = new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}"`, + }, + }); + const req2 = new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}-another-version"`, + }, + }); + const event = (0, mocks_1.getEvent)(req1); + const event2 = (0, mocks_1.getEvent)(req2); + const res1 = await (0, index_1.getAssetFromKV)(event, { cacheControl: { edgeTTL: 720 } }); + const res2 = await (0, index_1.getAssetFromKV)(event); + const res3 = await (0, index_1.getAssetFromKV)(event2); + if (res1 && res2 && res3) { + t.is(res1.headers.get('cf-cache-status'), 'MISS'); + t.is(res2.headers.get('etag'), `W/${req1.headers.get('if-none-match')}`); + t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED'); + t.not(res3.headers.get('etag'), req2.headers.get('if-none-match')); + t.is(res3.headers.get('cf-cache-status'), 'MISS'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV when resource in cache, etag should be weakened before returned to eyeball', async (t) => { + (0, mocks_1.mockRequestScope)(); + const resourceKey = 'key1.png'; + const resourceVersion = JSON.parse((0, mocks_1.mockManifest)())[resourceKey]; + const req1 = new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}"`, + }, + }); + const event = (0, mocks_1.getEvent)(req1); + const res1 = await (0, index_1.getAssetFromKV)(event, { cacheControl: { edgeTTL: 720 } }); + const res2 = await (0, index_1.getAssetFromKV)(event); + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS'); + t.is(res2.headers.get('etag'), `W/${req1.headers.get('if-none-match')}`); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV if-none-match not sent but resource in cache, should return cache hit 200 OK', async (t) => { + const resourceKey = 'cache.html'; + const event = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`)); + const res1 = await (0, index_1.getAssetFromKV)(event, { cacheControl: { edgeTTL: 720 } }); + await (0, mocks_1.sleep)(1); + const res2 = await (0, index_1.getAssetFromKV)(event); + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS'); + t.is(res1.headers.get('cache-control'), null); + t.is(res2.status, 200); + t.is(res2.headers.get('cf-cache-status'), 'HIT'); + } + else { + t.fail('Response was undefined'); + } +}); +(0, ava_1.default)('getAssetFromKV if range request submitted and resource in cache, request fulfilled', async (t) => { + const resourceKey = 'cache.html'; + const event1 = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`)); + const event2 = (0, mocks_1.getEvent)(new Request(`https://blah.com/${resourceKey}`, { headers: { range: 'bytes=0-10' } })); + const res1 = (0, index_1.getAssetFromKV)(event1, { cacheControl: { edgeTTL: 720 } }); + await res1; + await (0, mocks_1.sleep)(2); + const res2 = await (0, index_1.getAssetFromKV)(event2); + if (res2.headers.has('content-range')) { + t.is(res2.status, 206); + } + else { + t.fail('Response was undefined'); + } +}); +ava_1.default.todo('getAssetFromKV when body not empty, should invoke .cancel()'); diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts b/node_modules/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js b/node_modules/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js new file mode 100644 index 0000000000000000000000000000000000000000..11be9121ba5f889f59a50311a8556aeb25ee7a8f --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const ava_1 = require("ava"); +const mocks_1 = require("../mocks"); +(0, mocks_1.mockGlobalScope)(); +const index_1 = require("../index"); +(0, ava_1.default)('mapRequestToAsset() correctly changes /about -> /about/index.html', async (t) => { + (0, mocks_1.mockRequestScope)(); + let path = '/about'; + let request = new Request(`https://foo.com${path}`); + let newRequest = (0, index_1.mapRequestToAsset)(request); + t.is(newRequest.url, request.url + '/index.html'); +}); +(0, ava_1.default)('mapRequestToAsset() correctly changes /about/ -> /about/index.html', async (t) => { + (0, mocks_1.mockRequestScope)(); + let path = '/about/'; + let request = new Request(`https://foo.com${path}`); + let newRequest = (0, index_1.mapRequestToAsset)(request); + t.is(newRequest.url, request.url + 'index.html'); +}); +(0, ava_1.default)('mapRequestToAsset() correctly changes /about.me/ -> /about.me/index.html', async (t) => { + (0, mocks_1.mockRequestScope)(); + let path = '/about.me/'; + let request = new Request(`https://foo.com${path}`); + let newRequest = (0, index_1.mapRequestToAsset)(request); + t.is(newRequest.url, request.url + 'index.html'); +}); +(0, ava_1.default)('mapRequestToAsset() correctly changes /about -> /about/default.html', async (t) => { + (0, mocks_1.mockRequestScope)(); + let path = '/about'; + let request = new Request(`https://foo.com${path}`); + let newRequest = (0, index_1.mapRequestToAsset)(request, { defaultDocument: 'default.html' }); + t.is(newRequest.url, request.url + '/default.html'); +}); diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts b/node_modules/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js b/node_modules/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js new file mode 100644 index 0000000000000000000000000000000000000000..8ee0bfbe83a8a607933527ba0bdde77ff23a4d1c --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const ava_1 = require("ava"); +const mocks_1 = require("../mocks"); +(0, mocks_1.mockGlobalScope)(); +const index_1 = require("../index"); +function testRequest(path) { + (0, mocks_1.mockRequestScope)(); + let url = new URL('https://example.com'); + url.pathname = path; + let request = new Request(url.toString()); + return request; +} +(0, ava_1.default)('serveSinglePageApp returns root asset path when request path ends in .html', async (t) => { + let path = '/foo/thing.html'; + let request = testRequest(path); + let expected_request = testRequest('/index.html'); + let actual_request = (0, index_1.serveSinglePageApp)(request); + t.deepEqual(expected_request, actual_request); +}); +(0, ava_1.default)('serveSinglePageApp returns root asset path when request path does not have extension', async (t) => { + let path = '/foo/thing'; + let request = testRequest(path); + let expected_request = testRequest('/index.html'); + let actual_request = (0, index_1.serveSinglePageApp)(request); + t.deepEqual(expected_request, actual_request); +}); +(0, ava_1.default)('serveSinglePageApp returns requested asset when request path has non-html extension', async (t) => { + let path = '/foo/thing.js'; + let request = testRequest(path); + let expected_request = request; + let actual_request = (0, index_1.serveSinglePageApp)(request); + t.deepEqual(expected_request, actual_request); +}); diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/types.d.ts b/node_modules/@cloudflare/kv-asset-handler/dist/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..eef1bff2f19fa30929fb04fd51929c1dd03cc837 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/types.d.ts @@ -0,0 +1,28 @@ +export declare type CacheControl = { + browserTTL: number; + edgeTTL: number; + bypassCache: boolean; +}; +export declare type AssetManifestType = Record; +export declare type Options = { + cacheControl: ((req: Request) => Partial) | Partial; + ASSET_NAMESPACE: any; + ASSET_MANIFEST: AssetManifestType | string; + mapRequestToAsset?: (req: Request, options?: Partial) => Request; + defaultMimeType: string; + defaultDocument: string; + pathIsEncoded: boolean; +}; +export declare class KVError extends Error { + constructor(message?: string, status?: number); + status: number; +} +export declare class MethodNotAllowedError extends KVError { + constructor(message?: string, status?: number); +} +export declare class NotFoundError extends KVError { + constructor(message?: string, status?: number); +} +export declare class InternalError extends KVError { + constructor(message?: string, status?: number); +} diff --git a/node_modules/@cloudflare/kv-asset-handler/dist/types.js b/node_modules/@cloudflare/kv-asset-handler/dist/types.js new file mode 100644 index 0000000000000000000000000000000000000000..ba08c1babad312716ba86e756b4a8596f51d1a5c --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/dist/types.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InternalError = exports.NotFoundError = exports.MethodNotAllowedError = exports.KVError = void 0; +class KVError extends Error { + constructor(message, status = 500) { + super(message); + // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html + Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain + this.name = KVError.name; // stack traces display correctly now + this.status = status; + } +} +exports.KVError = KVError; +class MethodNotAllowedError extends KVError { + constructor(message = `Not a valid request method`, status = 405) { + super(message, status); + } +} +exports.MethodNotAllowedError = MethodNotAllowedError; +class NotFoundError extends KVError { + constructor(message = `Not Found`, status = 404) { + super(message, status); + } +} +exports.NotFoundError = NotFoundError; +class InternalError extends KVError { + constructor(message = `Internal Error in KV Asset Handler`, status = 500) { + super(message, status); + } +} +exports.InternalError = InternalError; diff --git a/node_modules/@cloudflare/kv-asset-handler/package.json b/node_modules/@cloudflare/kv-asset-handler/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec9c423326fe8554c7d03f7cf36cd98a5d9ed12 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/package.json @@ -0,0 +1,52 @@ +{ + "name": "@cloudflare/kv-asset-handler", + "version": "0.2.0", + "description": "Routes requests to KV assets", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "prepack": "npm run build", + "build": "tsc -d", + "format": "prettier --write \"**/*.{js,ts,json,md}\"", + "pretest": "npm run build", + "lint:code": "prettier --check \"**/*.{js,ts,json,md}\"", + "lint:markdown": "markdownlint \"**/*.md\" --ignore node_modules", + "test": "ava dist/test/*.js --verbose" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/cloudflare/kv-asset-handler.git" + }, + "keywords": [ + "kv", + "cloudflare", + "workers", + "wrangler", + "assets" + ], + "files": [ + "src", + "dist", + "LICENSE_APACHE", + "LICENSE_MIT" + ], + "author": "wrangler@cloudflare.com", + "license": "MIT OR Apache-2.0", + "bugs": { + "url": "https://github.com/cloudflare/kv-asset-handler/issues" + }, + "homepage": "https://github.com/cloudflare/kv-asset-handler#readme", + "dependencies": { + "mime": "^3.0.0" + }, + "devDependencies": { + "@ava/typescript": "^3.0.0", + "@cloudflare/workers-types": "^3.0.0", + "@types/mime": "^2.0.3", + "@types/node": "^15.14.9", + "ava": "^3.15.0", + "prettier": "^2.4.1", + "service-worker-mock": "^2.0.5", + "typescript": "^4.4.4" + } +} diff --git a/node_modules/@cloudflare/kv-asset-handler/src/index.ts b/node_modules/@cloudflare/kv-asset-handler/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a91b68ea2610e113b8e4bd7d04c691c9a865dcf --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/src/index.ts @@ -0,0 +1,312 @@ +import * as mime from 'mime' +import { + Options, + CacheControl, + MethodNotAllowedError, + NotFoundError, + InternalError, + AssetManifestType, +} from './types' + +declare global { + var __STATIC_CONTENT: any, __STATIC_CONTENT_MANIFEST: string +} + +const defaultCacheControl: CacheControl = { + browserTTL: null, + edgeTTL: 2 * 60 * 60 * 24, // 2 days + bypassCache: false, // do not bypass Cloudflare's cache +} + +const parseStringAsObject = (maybeString: string | T): T => + typeof maybeString === 'string' ? (JSON.parse(maybeString) as T) : maybeString + +const getAssetFromKVDefaultOptions: Partial = { + ASSET_NAMESPACE: typeof __STATIC_CONTENT !== 'undefined' ? __STATIC_CONTENT : undefined, + ASSET_MANIFEST: + typeof __STATIC_CONTENT_MANIFEST !== 'undefined' + ? parseStringAsObject(__STATIC_CONTENT_MANIFEST) + : {}, + cacheControl: defaultCacheControl, + defaultMimeType: 'text/plain', + defaultDocument: 'index.html', + pathIsEncoded: false, +} + +function assignOptions(options?: Partial): Options { + // Assign any missing options passed in to the default + // options.mapRequestToAsset is handled manually later + return Object.assign({}, getAssetFromKVDefaultOptions, options) +} + +/** + * maps the path of incoming request to the request pathKey to look up + * in bucket and in cache + * e.g. for a path '/' returns '/index.html' which serves + * the content of bucket/index.html + * @param {Request} request incoming request + */ +const mapRequestToAsset = (request: Request, options?: Partial) => { + options = assignOptions(options) + + const parsedUrl = new URL(request.url) + let pathname = parsedUrl.pathname + + if (pathname.endsWith('/')) { + // If path looks like a directory append options.defaultDocument + // e.g. If path is /about/ -> /about/index.html + pathname = pathname.concat(options.defaultDocument) + } else if (!mime.getType(pathname)) { + // If path doesn't look like valid content + // e.g. /about.me -> /about.me/index.html + pathname = pathname.concat('/' + options.defaultDocument) + } + + parsedUrl.pathname = pathname + return new Request(parsedUrl.toString(), request) +} + +/** + * maps the path of incoming request to /index.html if it evaluates to + * any HTML file. + * @param {Request} request incoming request + */ +function serveSinglePageApp(request: Request, options?: Partial): Request { + options = assignOptions(options) + + // First apply the default handler, which already has logic to detect + // paths that should map to HTML files. + request = mapRequestToAsset(request, options) + + const parsedUrl = new URL(request.url) + + // Detect if the default handler decided to map to + // a HTML file in some specific directory. + if (parsedUrl.pathname.endsWith('.html')) { + // If expected HTML file was missing, just return the root index.html (or options.defaultDocument) + return new Request(`${parsedUrl.origin}/${options.defaultDocument}`, request) + } else { + // The default handler decided this is not an HTML page. It's probably + // an image, CSS, or JS file. Leave it as-is. + return request + } +} + +/** + * takes the path of the incoming request, gathers the appropriate content from KV, and returns + * the response + * + * @param {FetchEvent} event the fetch event of the triggered request + * @param {{mapRequestToAsset: (string: Request) => Request, cacheControl: {bypassCache:boolean, edgeTTL: number, browserTTL:number}, ASSET_NAMESPACE: any, ASSET_MANIFEST:any}} [options] configurable options + * @param {CacheControl} [options.cacheControl] determine how to cache on Cloudflare and the browser + * @param {typeof(options.mapRequestToAsset)} [options.mapRequestToAsset] maps the path of incoming request to the request pathKey to look up + * @param {Object | string} [options.ASSET_NAMESPACE] the binding to the namespace that script references + * @param {any} [options.ASSET_MANIFEST] the map of the key to cache and store in KV + * */ + +type Evt = { + request: Request + waitUntil: (promise: Promise) => void +} + +const getAssetFromKV = async (event: Evt, options?: Partial): Promise => { + options = assignOptions(options) + + const request = event.request + const ASSET_NAMESPACE = options.ASSET_NAMESPACE + const ASSET_MANIFEST = parseStringAsObject(options.ASSET_MANIFEST) + + if (typeof ASSET_NAMESPACE === 'undefined') { + throw new InternalError(`there is no KV namespace bound to the script`) + } + + const rawPathKey = new URL(request.url).pathname.replace(/^\/+/, '') // strip any preceding /'s + let pathIsEncoded = options.pathIsEncoded + let requestKey + // if options.mapRequestToAsset is explicitly passed in, always use it and assume user has own intentions + // otherwise handle request as normal, with default mapRequestToAsset below + if (options.mapRequestToAsset) { + requestKey = options.mapRequestToAsset(request) + } else if (ASSET_MANIFEST[rawPathKey]) { + requestKey = request + } else if (ASSET_MANIFEST[decodeURIComponent(rawPathKey)]) { + pathIsEncoded = true + requestKey = request + } else { + const mappedRequest = mapRequestToAsset(request) + const mappedRawPathKey = new URL(mappedRequest.url).pathname.replace(/^\/+/, '') + if (ASSET_MANIFEST[decodeURIComponent(mappedRawPathKey)]) { + pathIsEncoded = true + requestKey = mappedRequest + } else { + // use default mapRequestToAsset + requestKey = mapRequestToAsset(request, options) + } + } + + const SUPPORTED_METHODS = ['GET', 'HEAD'] + if (!SUPPORTED_METHODS.includes(requestKey.method)) { + throw new MethodNotAllowedError(`${requestKey.method} is not a valid request method`) + } + + const parsedUrl = new URL(requestKey.url) + const pathname = pathIsEncoded ? decodeURIComponent(parsedUrl.pathname) : parsedUrl.pathname // decode percentage encoded path only when necessary + + // pathKey is the file path to look up in the manifest + let pathKey = pathname.replace(/^\/+/, '') // remove prepended / + + // @ts-ignore + const cache = caches.default + let mimeType = mime.getType(pathKey) || options.defaultMimeType + if (mimeType.startsWith('text') || mimeType === 'application/javascript') { + mimeType += '; charset=utf-8' + } + + let shouldEdgeCache = false // false if storing in KV by raw file path i.e. no hash + // check manifest for map from file path to hash + if (typeof ASSET_MANIFEST !== 'undefined') { + if (ASSET_MANIFEST[pathKey]) { + pathKey = ASSET_MANIFEST[pathKey] + // if path key is in asset manifest, we can assume it contains a content hash and can be cached + shouldEdgeCache = true + } + } + + // TODO this excludes search params from cache, investigate ideal behavior + let cacheKey = new Request(`${parsedUrl.origin}/${pathKey}`, request) + + // if argument passed in for cacheControl is a function then + // evaluate that function. otherwise return the Object passed in + // or default Object + const evalCacheOpts = (() => { + switch (typeof options.cacheControl) { + case 'function': + return options.cacheControl(request) + case 'object': + return options.cacheControl + default: + return defaultCacheControl + } + })() + + // formats the etag depending on the response context. if the entityId + // is invalid, returns an empty string (instead of null) to prevent the + // the potentially disastrous scenario where the value of the Etag resp + // header is "null". Could be modified in future to base64 encode etc + const formatETag = (entityId: any = pathKey, validatorType: string = 'strong') => { + if (!entityId) { + return '' + } + switch (validatorType) { + case 'weak': + if (!entityId.startsWith('W/')) { + return `W/${entityId}` + } + return entityId + case 'strong': + if (entityId.startsWith(`W/"`)) { + entityId = entityId.replace('W/', '') + } + if (!entityId.endsWith(`"`)) { + entityId = `"${entityId}"` + } + return entityId + default: + return '' + } + } + + options.cacheControl = Object.assign({}, defaultCacheControl, evalCacheOpts) + + // override shouldEdgeCache if options say to bypassCache + if ( + options.cacheControl.bypassCache || + options.cacheControl.edgeTTL === null || + request.method == 'HEAD' + ) { + shouldEdgeCache = false + } + // only set max-age if explicitly passed in a number as an arg + const shouldSetBrowserCache = typeof options.cacheControl.browserTTL === 'number' + + let response = null + if (shouldEdgeCache) { + response = await cache.match(cacheKey) + } + + if (response) { + if (response.status > 300 && response.status < 400) { + if (response.body && 'cancel' in Object.getPrototypeOf(response.body)) { + // Body exists and environment supports readable streams + response.body.cancel() + } else { + // Environment doesnt support readable streams, or null repsonse body. Nothing to do + } + response = new Response(null, response) + } else { + // fixes #165 + let opts = { + headers: new Headers(response.headers), + status: 0, + statusText: '', + } + + opts.headers.set('cf-cache-status', 'HIT') + + if (response.status) { + opts.status = response.status + opts.statusText = response.statusText + } else if (opts.headers.has('Content-Range')) { + opts.status = 206 + opts.statusText = 'Partial Content' + } else { + opts.status = 200 + opts.statusText = 'OK' + } + response = new Response(response.body, opts) + } + } else { + const body = await ASSET_NAMESPACE.get(pathKey, 'arrayBuffer') + if (body === null) { + throw new NotFoundError(`could not find ${pathKey} in your content namespace`) + } + response = new Response(body) + + if (shouldEdgeCache) { + response.headers.set('Accept-Ranges', 'bytes') + response.headers.set('Content-Length', body.length) + // set etag before cache insertion + if (!response.headers.has('etag')) { + response.headers.set('etag', formatETag(pathKey, 'strong')) + } + // determine Cloudflare cache behavior + response.headers.set('Cache-Control', `max-age=${options.cacheControl.edgeTTL}`) + event.waitUntil(cache.put(cacheKey, response.clone())) + response.headers.set('CF-Cache-Status', 'MISS') + } + } + response.headers.set('Content-Type', mimeType) + + if (response.status === 304) { + let etag = formatETag(response.headers.get('etag'), 'strong') + let ifNoneMatch = cacheKey.headers.get('if-none-match') + let proxyCacheStatus = response.headers.get('CF-Cache-Status') + if (etag) { + if (ifNoneMatch && ifNoneMatch === etag && proxyCacheStatus === 'MISS') { + response.headers.set('CF-Cache-Status', 'EXPIRED') + } else { + response.headers.set('CF-Cache-Status', 'REVALIDATED') + } + response.headers.set('etag', formatETag(etag, 'weak')) + } + } + if (shouldSetBrowserCache) { + response.headers.set('Cache-Control', `max-age=${options.cacheControl.browserTTL}`) + } else { + response.headers.delete('Cache-Control') + } + return response +} + +export { getAssetFromKV, mapRequestToAsset, serveSinglePageApp } +export { Options, CacheControl, MethodNotAllowedError, NotFoundError, InternalError } diff --git a/node_modules/@cloudflare/kv-asset-handler/src/mocks.ts b/node_modules/@cloudflare/kv-asset-handler/src/mocks.ts new file mode 100644 index 0000000000000000000000000000000000000000..b42fb7452a517912ce131246f0f13caaceaf1b61 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/src/mocks.ts @@ -0,0 +1,148 @@ +const makeServiceWorkerEnv = require('service-worker-mock') + +const HASH = '123HASHBROWN' + +export const getEvent = (request: Request): any => { + const waitUntil = async (callback: any) => { + await callback + } + return { + request, + waitUntil, + } +} +const store: any = { + 'key1.123HASHBROWN.txt': 'val1', + 'key1.123HASHBROWN.png': 'val1', + 'index.123HASHBROWN.html': 'index.html', + 'cache.123HASHBROWN.html': 'cache me if you can', + '测试.123HASHBROWN.html': 'My filename is non-ascii', + '%not-really-percent-encoded.123HASHBROWN.html': 'browser percent encoded', + '%2F.123HASHBROWN.html': 'user percent encoded', + '你好.123HASHBROWN.html': 'I shouldnt be served', + '%E4%BD%A0%E5%A5%BD.123HASHBROWN.html': 'Im important', + 'nohash.txt': 'no hash but still got some result', + 'sub/blah.123HASHBROWN.png': 'picturedis', + 'sub/index.123HASHBROWN.html': 'picturedis', + 'client.123HASHBROWN': 'important file', + 'client.123HASHBROWN/index.html': 'Im here but serve my big bro above', + 'image.123HASHBROWN.png': 'imagepng', + 'image.123HASHBROWN.webp': 'imagewebp', + '你好/index.123HASHBROWN.html': 'My path is non-ascii', +} +export const mockKV = (store: any) => { + return { + get: (path: string) => store[path] || null, + } +} + +export const mockManifest = () => { + return JSON.stringify({ + 'key1.txt': `key1.${HASH}.txt`, + 'key1.png': `key1.${HASH}.png`, + 'cache.html': `cache.${HASH}.html`, + '测试.html': `测试.${HASH}.html`, + '你好.html': `你好.${HASH}.html`, + '%not-really-percent-encoded.html': `%not-really-percent-encoded.${HASH}.html`, + '%2F.html': `%2F.${HASH}.html`, + '%E4%BD%A0%E5%A5%BD.html': `%E4%BD%A0%E5%A5%BD.${HASH}.html`, + 'index.html': `index.${HASH}.html`, + 'sub/blah.png': `sub/blah.${HASH}.png`, + 'sub/index.html': `sub/index.${HASH}.html`, + client: `client.${HASH}`, + 'client/index.html': `client.${HASH}`, + 'image.png': `image.${HASH}.png`, + 'image.webp': `image.${HASH}.webp`, + '你好/index.html': `你好/index.${HASH}.html`, + }) +} + +let cacheStore: any = new Map() +interface CacheKey { + url: object + headers: object +} +export const mockCaches = () => { + return { + default: { + async match(key: any) { + let cacheKey: CacheKey = { + url: key.url, + headers: {}, + } + let response + if (key.headers.has('if-none-match')) { + let makeStrongEtag = key.headers.get('if-none-match').replace('W/', '') + Reflect.set(cacheKey.headers, 'etag', makeStrongEtag) + response = cacheStore.get(JSON.stringify(cacheKey)) + } else { + // if client doesn't send if-none-match, we need to iterate through these keys + // and just test the URL + const activeCacheKeys: Array = Array.from(cacheStore.keys()) + for (const cacheStoreKey of activeCacheKeys) { + if (JSON.parse(cacheStoreKey).url === key.url) { + response = cacheStore.get(cacheStoreKey) + } + } + } + // TODO: write test to accomodate for rare scenarios with where range requests accomodate etags + if (response && !key.headers.has('if-none-match')) { + // this appears overly verbose, but is necessary to document edge cache behavior + // The Range request header triggers the response header Content-Range ... + const range = key.headers.get('range') + if (range) { + response.headers.set( + 'content-range', + `bytes ${range.split('=').pop()}/${response.headers.get('content-length')}`, + ) + } + // ... which we are using in this repository to set status 206 + if (response.headers.has('content-range')) { + response.status = 206 + } else { + response.status = 200 + } + let etag = response.headers.get('etag') + if (etag && !etag.includes('W/')) { + response.headers.set('etag', `W/${etag}`) + } + } + return response + }, + async put(key: any, val: Response) { + let headers = new Headers(val.headers) + let url = new URL(key.url) + let resWithBody = new Response(val.body, { headers, status: 200 }) + let resNoBody = new Response(null, { headers, status: 304 }) + let cacheKey: CacheKey = { + url: key.url, + headers: { + etag: `"${url.pathname.replace('/', '')}"`, + }, + } + cacheStore.set(JSON.stringify(cacheKey), resNoBody) + cacheKey.headers = {} + cacheStore.set(JSON.stringify(cacheKey), resWithBody) + return + }, + }, + } +} + +// mocks functionality used inside worker request +export function mockRequestScope() { + Object.assign(global, makeServiceWorkerEnv()) + Object.assign(global, { __STATIC_CONTENT_MANIFEST: mockManifest() }) + Object.assign(global, { __STATIC_CONTENT: mockKV(store) }) + Object.assign(global, { caches: mockCaches() }) +} + +// mocks functionality used on global isolate scope. such as the KV namespace bind +export function mockGlobalScope() { + Object.assign(global, { __STATIC_CONTENT_MANIFEST: mockManifest() }) + Object.assign(global, { __STATIC_CONTENT: mockKV(store) }) +} + +export const sleep = (milliseconds: number) => { + return new Promise((resolve) => setTimeout(resolve, milliseconds)) +} diff --git a/node_modules/@cloudflare/kv-asset-handler/src/test/getAssetFromKV-optional.ts b/node_modules/@cloudflare/kv-asset-handler/src/test/getAssetFromKV-optional.ts new file mode 100644 index 0000000000000000000000000000000000000000..9740b7d648d46edf7302799929410ceb58dccc2b --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/src/test/getAssetFromKV-optional.ts @@ -0,0 +1,24 @@ +import test from 'ava' +import { mockRequestScope, mockGlobalScope, getEvent, sleep, mockKV, mockManifest } from '../mocks' +mockGlobalScope() + +// manually reset manifest global, to test optional behaviour +Object.assign(global, { __STATIC_CONTENT_MANIFEST: undefined }) + +import { getAssetFromKV, mapRequestToAsset } from '../index' + +test('getAssetFromKV return correct val from KV without manifest', async (t) => { + mockRequestScope() + // manually reset manifest global, to test optional behaviour + Object.assign(global, { __STATIC_CONTENT_MANIFEST: undefined }) + + const event = getEvent(new Request('https://blah.com/key1.123HASHBROWN.txt')) + const res = await getAssetFromKV(event) + + if (res) { + t.is(await res.text(), 'val1') + t.true(res.headers.get('content-type').includes('text')) + } else { + t.fail('Response was undefined') + } +}) diff --git a/node_modules/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts b/node_modules/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts new file mode 100644 index 0000000000000000000000000000000000000000..425d622e2dbd82123ac22a5a9e5201ec75f4ac0e --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts @@ -0,0 +1,488 @@ +import test from 'ava' +import { mockRequestScope, mockGlobalScope, getEvent, sleep, mockKV, mockManifest } from '../mocks' +mockGlobalScope() + +import { getAssetFromKV, mapRequestToAsset } from '../index' +import { KVError } from '../types' + +test('getAssetFromKV return correct val from KV and default caching', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/key1.txt')) + const res = await getAssetFromKV(event) + + if (res) { + t.is(res.headers.get('cache-control'), null) + t.is(res.headers.get('cf-cache-status'), 'MISS') + t.is(await res.text(), 'val1') + t.true(res.headers.get('content-type').includes('text')) + } else { + t.fail('Response was undefined') + } +}) +test('getAssetFromKV evaluated the file matching the extensionless path first /client/ -> client', async (t) => { + mockRequestScope() + const event = getEvent(new Request(`https://foo.com/client/`)) + const res = await getAssetFromKV(event) + t.is(await res.text(), 'important file') + t.true(res.headers.get('content-type').includes('text')) +}) +test('getAssetFromKV evaluated the file matching the extensionless path first /client -> client', async (t) => { + mockRequestScope() + const event = getEvent(new Request(`https://foo.com/client`)) + const res = await getAssetFromKV(event) + t.is(await res.text(), 'important file') + t.true(res.headers.get('content-type').includes('text')) +}) + +test('getAssetFromKV if not in asset manifest still returns nohash.txt', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/nohash.txt')) + const res = await getAssetFromKV(event) + + if (res) { + t.is(await res.text(), 'no hash but still got some result') + t.true(res.headers.get('content-type').includes('text')) + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV if no asset manifest /client -> client fails', async (t) => { + mockRequestScope() + const event = getEvent(new Request(`https://foo.com/client`)) + const error: KVError = await t.throwsAsync(getAssetFromKV(event, { ASSET_MANIFEST: {} })) + t.is(error.status, 404) +}) + +test('getAssetFromKV if sub/ -> sub/index.html served', async (t) => { + mockRequestScope() + const event = getEvent(new Request(`https://foo.com/sub`)) + const res = await getAssetFromKV(event) + if (res) { + t.is(await res.text(), 'picturedis') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV gets index.html by default for / requests', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/')) + const res = await getAssetFromKV(event) + + if (res) { + t.is(await res.text(), 'index.html') + t.true(res.headers.get('content-type').includes('html')) + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV non ASCII path support', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/测试.html')) + const res = await getAssetFromKV(event) + + if (res) { + t.is(await res.text(), 'My filename is non-ascii') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV supports browser percent encoded URLs', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://example.com/%not-really-percent-encoded.html')) + const res = await getAssetFromKV(event) + + if (res) { + t.is(await res.text(), 'browser percent encoded') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV supports user percent encoded URLs', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/%2F.html')) + const res = await getAssetFromKV(event) + + if (res) { + t.is(await res.text(), 'user percent encoded') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV only decode URL when necessary', async (t) => { + mockRequestScope() + const event1 = getEvent(new Request('https://blah.com/%E4%BD%A0%E5%A5%BD.html')) + const event2 = getEvent(new Request('https://blah.com/你好.html')) + const res1 = await getAssetFromKV(event1) + const res2 = await getAssetFromKV(event2) + + if (res1 && res2) { + t.is(await res1.text(), 'Im important') + t.is(await res2.text(), 'Im important') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV Support for user decode url path', async (t) => { + mockRequestScope() + const event1 = getEvent(new Request('https://blah.com/%E4%BD%A0%E5%A5%BD/')) + const event2 = getEvent(new Request('https://blah.com/你好/')) + const res1 = await getAssetFromKV(event1) + const res2 = await getAssetFromKV(event2) + + if (res1 && res2) { + t.is(await res1.text(), 'My path is non-ascii') + t.is(await res2.text(), 'My path is non-ascii') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV custom key modifier', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/docs/sub/blah.png')) + + const customRequestMapper = (request: Request) => { + let defaultModifiedRequest = mapRequestToAsset(request) + + let url = new URL(defaultModifiedRequest.url) + url.pathname = url.pathname.replace('/docs', '') + return new Request(url.toString(), request) + } + + const res = await getAssetFromKV(event, { mapRequestToAsset: customRequestMapper }) + + if (res) { + t.is(await res.text(), 'picturedis') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV request override with existing manifest file', async (t) => { + // see https://github.com/cloudflare/kv-asset-handler/pull/159 for more info + mockRequestScope() + const event = getEvent(new Request('https://blah.com/image.png')) // real file in manifest + + const customRequestMapper = (request: Request) => { + let defaultModifiedRequest = mapRequestToAsset(request) + + let url = new URL(defaultModifiedRequest.url) + url.pathname = '/image.webp' // other different file in manifest + return new Request(url.toString(), request) + } + + const res = await getAssetFromKV(event, { mapRequestToAsset: customRequestMapper }) + + if (res) { + t.is(await res.text(), 'imagewebp') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV when setting browser caching', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/')) + + const res = await getAssetFromKV(event, { cacheControl: { browserTTL: 22 } }) + + if (res) { + t.is(res.headers.get('cache-control'), 'max-age=22') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV when setting custom cache setting', async (t) => { + mockRequestScope() + const event1 = getEvent(new Request('https://blah.com/')) + const event2 = getEvent(new Request('https://blah.com/key1.png?blah=34')) + const cacheOnlyPngs = (req: Request) => { + if (new URL(req.url).pathname.endsWith('.png')) + return { + browserTTL: 720, + edgeTTL: 720, + } + else + return { + bypassCache: true, + } + } + + const res1 = await getAssetFromKV(event1, { cacheControl: cacheOnlyPngs }) + const res2 = await getAssetFromKV(event2, { cacheControl: cacheOnlyPngs }) + + if (res1 && res2) { + t.is(res1.headers.get('cache-control'), null) + t.true(res2.headers.get('content-type').includes('png')) + t.is(res2.headers.get('cache-control'), 'max-age=720') + t.is(res2.headers.get('cf-cache-status'), 'MISS') + } else { + t.fail('Response was undefined') + } +}) +test('getAssetFromKV caches on two sequential requests', async (t) => { + mockRequestScope() + const resourceKey = 'cache.html' + const resourceVersion = JSON.parse(mockManifest())[resourceKey] + const event1 = getEvent(new Request(`https://blah.com/${resourceKey}`)) + const event2 = getEvent( + new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}"`, + }, + }), + ) + + const res1 = await getAssetFromKV(event1, { cacheControl: { edgeTTL: 720, browserTTL: 720 } }) + await sleep(1) + const res2 = await getAssetFromKV(event2) + + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS') + t.is(res1.headers.get('cache-control'), 'max-age=720') + t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED') + } else { + t.fail('Response was undefined') + } +}) +test('getAssetFromKV does not store max-age on two sequential requests', async (t) => { + mockRequestScope() + const resourceKey = 'cache.html' + const resourceVersion = JSON.parse(mockManifest())[resourceKey] + const event1 = getEvent(new Request(`https://blah.com/${resourceKey}`)) + const event2 = getEvent( + new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}"`, + }, + }), + ) + + const res1 = await getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }) + await sleep(100) + const res2 = await getAssetFromKV(event2) + + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS') + t.is(res1.headers.get('cache-control'), null) + t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED') + t.is(res2.headers.get('cache-control'), null) + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV does not cache on Cloudflare when bypass cache set', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/')) + + const res = await getAssetFromKV(event, { cacheControl: { bypassCache: true } }) + + if (res) { + t.is(res.headers.get('cache-control'), null) + t.is(res.headers.get('cf-cache-status'), null) + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV with no trailing slash on root', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com')) + const res = await getAssetFromKV(event) + if (res) { + t.is(await res.text(), 'index.html') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV with no trailing slash on a subdirectory', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/sub/blah.png')) + const res = await getAssetFromKV(event) + if (res) { + t.is(await res.text(), 'picturedis') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV no result throws an error', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/random')) + const error: KVError = await t.throwsAsync(getAssetFromKV(event)) + t.is(error.status, 404) +}) +test('getAssetFromKV TTls set to null should not cache on browser or edge', async (t) => { + mockRequestScope() + const event = getEvent(new Request('https://blah.com/')) + + const res1 = await getAssetFromKV(event, { cacheControl: { browserTTL: null, edgeTTL: null } }) + await sleep(100) + const res2 = await getAssetFromKV(event, { cacheControl: { browserTTL: null, edgeTTL: null } }) + + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), null) + t.is(res1.headers.get('cache-control'), null) + t.is(res2.headers.get('cf-cache-status'), null) + t.is(res2.headers.get('cache-control'), null) + } else { + t.fail('Response was undefined') + } +}) +test('getAssetFromKV passing in a custom NAMESPACE serves correct asset', async (t) => { + mockRequestScope() + let CUSTOM_NAMESPACE = mockKV({ + 'key1.123HASHBROWN.txt': 'val1', + }) + Object.assign(global, { CUSTOM_NAMESPACE }) + const event = getEvent(new Request('https://blah.com/')) + const res = await getAssetFromKV(event) + if (res) { + t.is(await res.text(), 'index.html') + t.true(res.headers.get('content-type').includes('html')) + } else { + t.fail('Response was undefined') + } +}) +test('getAssetFromKV when custom namespace without the asset should fail', async (t) => { + mockRequestScope() + let CUSTOM_NAMESPACE = mockKV({ + 'key5.123HASHBROWN.txt': 'customvalu', + }) + + const event = getEvent(new Request('https://blah.com')) + const error: KVError = await t.throwsAsync( + getAssetFromKV(event, { ASSET_NAMESPACE: CUSTOM_NAMESPACE }), + ) + t.is(error.status, 404) +}) +test('getAssetFromKV when namespace not bound fails', async (t) => { + mockRequestScope() + var MY_CUSTOM_NAMESPACE = undefined + Object.assign(global, { MY_CUSTOM_NAMESPACE }) + + const event = getEvent(new Request('https://blah.com/')) + const error: KVError = await t.throwsAsync( + getAssetFromKV(event, { ASSET_NAMESPACE: MY_CUSTOM_NAMESPACE }), + ) + t.is(error.status, 500) +}) + +test('getAssetFromKV when if-none-match === active resource version, should revalidate', async (t) => { + mockRequestScope() + const resourceKey = 'key1.png' + const resourceVersion = JSON.parse(mockManifest())[resourceKey] + const event1 = getEvent(new Request(`https://blah.com/${resourceKey}`)) + const event2 = getEvent( + new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `W/"${resourceVersion}"`, + }, + }), + ) + + const res1 = await getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }) + await sleep(100) + const res2 = await getAssetFromKV(event2) + + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS') + t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV when if-none-match equals etag of stale resource then should bypass cache', async (t) => { + mockRequestScope() + const resourceKey = 'key1.png' + const resourceVersion = JSON.parse(mockManifest())[resourceKey] + const req1 = new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}"`, + }, + }) + const req2 = new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}-another-version"`, + }, + }) + const event = getEvent(req1) + const event2 = getEvent(req2) + const res1 = await getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }) + const res2 = await getAssetFromKV(event) + const res3 = await getAssetFromKV(event2) + if (res1 && res2 && res3) { + t.is(res1.headers.get('cf-cache-status'), 'MISS') + t.is(res2.headers.get('etag'), `W/${req1.headers.get('if-none-match')}`) + t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED') + t.not(res3.headers.get('etag'), req2.headers.get('if-none-match')) + t.is(res3.headers.get('cf-cache-status'), 'MISS') + } else { + t.fail('Response was undefined') + } +}) +test('getAssetFromKV when resource in cache, etag should be weakened before returned to eyeball', async (t) => { + mockRequestScope() + const resourceKey = 'key1.png' + const resourceVersion = JSON.parse(mockManifest())[resourceKey] + const req1 = new Request(`https://blah.com/${resourceKey}`, { + headers: { + 'if-none-match': `"${resourceVersion}"`, + }, + }) + const event = getEvent(req1) + const res1 = await getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }) + const res2 = await getAssetFromKV(event) + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS') + t.is(res2.headers.get('etag'), `W/${req1.headers.get('if-none-match')}`) + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV if-none-match not sent but resource in cache, should return cache hit 200 OK', async (t) => { + const resourceKey = 'cache.html' + const event = getEvent(new Request(`https://blah.com/${resourceKey}`)) + const res1 = await getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }) + await sleep(1) + const res2 = await getAssetFromKV(event) + if (res1 && res2) { + t.is(res1.headers.get('cf-cache-status'), 'MISS') + t.is(res1.headers.get('cache-control'), null) + t.is(res2.status, 200) + t.is(res2.headers.get('cf-cache-status'), 'HIT') + } else { + t.fail('Response was undefined') + } +}) + +test('getAssetFromKV if range request submitted and resource in cache, request fulfilled', async (t) => { + const resourceKey = 'cache.html' + const event1 = getEvent(new Request(`https://blah.com/${resourceKey}`)) + const event2 = getEvent( + new Request(`https://blah.com/${resourceKey}`, { headers: { range: 'bytes=0-10' } }), + ) + const res1 = getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }) + await res1 + await sleep(2) + const res2 = await getAssetFromKV(event2) + if (res2.headers.has('content-range')) { + t.is(res2.status, 206) + } else { + t.fail('Response was undefined') + } +}) + +test.todo('getAssetFromKV when body not empty, should invoke .cancel()') diff --git a/node_modules/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts b/node_modules/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts new file mode 100644 index 0000000000000000000000000000000000000000..422165e37ede66d06de21db71c5e133bb3412581 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts @@ -0,0 +1,37 @@ +import test from 'ava' +import { mockRequestScope, mockGlobalScope } from '../mocks' +mockGlobalScope() + +import { mapRequestToAsset } from '../index' + +test('mapRequestToAsset() correctly changes /about -> /about/index.html', async (t) => { + mockRequestScope() + let path = '/about' + let request = new Request(`https://foo.com${path}`) + let newRequest = mapRequestToAsset(request) + t.is(newRequest.url, request.url + '/index.html') +}) + +test('mapRequestToAsset() correctly changes /about/ -> /about/index.html', async (t) => { + mockRequestScope() + let path = '/about/' + let request = new Request(`https://foo.com${path}`) + let newRequest = mapRequestToAsset(request) + t.is(newRequest.url, request.url + 'index.html') +}) + +test('mapRequestToAsset() correctly changes /about.me/ -> /about.me/index.html', async (t) => { + mockRequestScope() + let path = '/about.me/' + let request = new Request(`https://foo.com${path}`) + let newRequest = mapRequestToAsset(request) + t.is(newRequest.url, request.url + 'index.html') +}) + +test('mapRequestToAsset() correctly changes /about -> /about/default.html', async (t) => { + mockRequestScope() + let path = '/about' + let request = new Request(`https://foo.com${path}`) + let newRequest = mapRequestToAsset(request, { defaultDocument: 'default.html' }) + t.is(newRequest.url, request.url + '/default.html') +}) diff --git a/node_modules/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts b/node_modules/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c634c85526190dfa1aae54b6da3c7e33175f282 --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts @@ -0,0 +1,44 @@ +import test from 'ava' +import { mockRequestScope, mockGlobalScope } from '../mocks' +mockGlobalScope() + +import { serveSinglePageApp } from '../index' + +function testRequest(path: string) { + mockRequestScope() + let url = new URL('https://example.com') + url.pathname = path + let request = new Request(url.toString()) + + return request +} + +test('serveSinglePageApp returns root asset path when request path ends in .html', async (t) => { + let path = '/foo/thing.html' + let request = testRequest(path) + + let expected_request = testRequest('/index.html') + let actual_request = serveSinglePageApp(request) + + t.deepEqual(expected_request, actual_request) +}) + +test('serveSinglePageApp returns root asset path when request path does not have extension', async (t) => { + let path = '/foo/thing' + let request = testRequest(path) + + let expected_request = testRequest('/index.html') + let actual_request = serveSinglePageApp(request) + + t.deepEqual(expected_request, actual_request) +}) + +test('serveSinglePageApp returns requested asset when request path has non-html extension', async (t) => { + let path = '/foo/thing.js' + let request = testRequest(path) + + let expected_request = request + let actual_request = serveSinglePageApp(request) + + t.deepEqual(expected_request, actual_request) +}) diff --git a/node_modules/@cloudflare/kv-asset-handler/src/types.ts b/node_modules/@cloudflare/kv-asset-handler/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8060767dac6dda082dd25dbe36e567ceaa71bdc --- /dev/null +++ b/node_modules/@cloudflare/kv-asset-handler/src/types.ts @@ -0,0 +1,43 @@ +export type CacheControl = { + browserTTL: number + edgeTTL: number + bypassCache: boolean +} + +export type AssetManifestType = Record + +export type Options = { + cacheControl: ((req: Request) => Partial) | Partial + ASSET_NAMESPACE: any + ASSET_MANIFEST: AssetManifestType | string + mapRequestToAsset?: (req: Request, options?: Partial) => Request + defaultMimeType: string + defaultDocument: string + pathIsEncoded: boolean +} + +export class KVError extends Error { + constructor(message?: string, status: number = 500) { + super(message) + // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html + Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain + this.name = KVError.name // stack traces display correctly now + this.status = status + } + status: number +} +export class MethodNotAllowedError extends KVError { + constructor(message: string = `Not a valid request method`, status: number = 405) { + super(message, status) + } +} +export class NotFoundError extends KVError { + constructor(message: string = `Not Found`, status: number = 404) { + super(message, status) + } +} +export class InternalError extends KVError { + constructor(message: string = `Internal Error in KV Asset Handler`, status: number = 500) { + super(message, status) + } +} diff --git a/node_modules/@cloudflare/workerd-linux-64/README.md b/node_modules/@cloudflare/workerd-linux-64/README.md new file mode 100644 index 0000000000000000000000000000000000000000..edbebe807f72b1227358e864f7558011e61054b8 --- /dev/null +++ b/node_modules/@cloudflare/workerd-linux-64/README.md @@ -0,0 +1,6 @@ +# 👷 `workerd` for Linux 64-bit, Cloudflare's JavaScript/Wasm Runtime + +`workerd` is a JavaScript / Wasm server runtime based on the same code that powers +[Cloudflare Workers](https://workers.dev). + +See https://github.com/cloudflare/workerd for details. diff --git a/node_modules/@cloudflare/workerd-linux-64/bin/workerd b/node_modules/@cloudflare/workerd-linux-64/bin/workerd new file mode 100644 index 0000000000000000000000000000000000000000..643f01ae033f718faaa533290eb631fe685d3394 --- /dev/null +++ b/node_modules/@cloudflare/workerd-linux-64/bin/workerd @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38e89c01a468df1cd48bfdc6eb9ac9eacb4c07d106fb5fa88ac13a1fdce6910e +size 88115856 diff --git a/node_modules/@cloudflare/workerd-linux-64/package.json b/node_modules/@cloudflare/workerd-linux-64/package.json new file mode 100644 index 0000000000000000000000000000000000000000..378b934cdcb792ecb7018693208199b225c0fb5d --- /dev/null +++ b/node_modules/@cloudflare/workerd-linux-64/package.json @@ -0,0 +1,17 @@ +{ + "name": "@cloudflare/workerd-linux-64", + "description": "👷 workerd for Linux 64-bit, Cloudflare's JavaScript/Wasm Runtime", + "repository": "https://github.com/cloudflare/workerd", + "license": "Apache-2.0", + "preferUnplugged": false, + "engines": { + "node": ">=16" + }, + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "version": "1.20231030.0" +} diff --git a/node_modules/@cypress/request-promise/.circleci/config.yml b/node_modules/@cypress/request-promise/.circleci/config.yml new file mode 100644 index 0000000000000000000000000000000000000000..1fc027a7f511cec6e19f45b93a0044d5d8ba85e9 --- /dev/null +++ b/node_modules/@cypress/request-promise/.circleci/config.yml @@ -0,0 +1,46 @@ +version: 2.1 +jobs: + test: + docker: + - image: circleci/node:11.5.0 + working_directory: ~/repo + steps: + - checkout + + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + - v1-dependencies- + - run: yarn install + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + - run: yarn test + + release: + docker: + - image: cimg/node:18.12.1 + steps: + - checkout + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + - v1-dependencies- + - run: yarn install + - run: npx semantic-release + +workflows: + version: 2.1 + test_and_release: + jobs: + - test + - release: + context: + - test-runner:npm-release + requires: + - test + filters: + branches: + only: + - master \ No newline at end of file diff --git a/node_modules/@cypress/request-promise/LICENSE b/node_modules/@cypress/request-promise/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d6b60c3930d9204ebc74c5095881ba15eb9cf892 --- /dev/null +++ b/node_modules/@cypress/request-promise/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2019, Nicolai Kamenzky, Ty Abonil, and contributors + +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. \ No newline at end of file diff --git a/node_modules/@cypress/request-promise/README.md b/node_modules/@cypress/request-promise/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8e8e9574f48faa9c0c2d0bf9c9f9fd4185510b97 --- /dev/null +++ b/node_modules/@cypress/request-promise/README.md @@ -0,0 +1,760 @@ + + Promises/A+ logo + + +# Request-Promise + +[![Gitter](https://img.shields.io/badge/gitter-join_chat-blue.svg?style=flat-square&maxAge=2592000)](https://gitter.im/request/request-promise?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://img.shields.io/travis/request/request-promise/master.svg?style=flat-square&maxAge=2592000)](https://travis-ci.org/request/request-promise) +[![Coverage Status](https://img.shields.io/coveralls/request/request-promise.svg?style=flat-square&maxAge=2592000)](https://coveralls.io/r/request/request-promise) +[![Dependency Status](https://img.shields.io/david/request/request-promise.svg?style=flat-square&maxAge=2592000)](https://david-dm.org/request/request-promise) +[![Known Vulnerabilities](https://snyk.io/test/npm/request-promise/badge.svg?style=flat-square&maxAge=2592000)](https://snyk.io/test/npm/request-promise) + +# Deprecated! + +As of Feb 11th 2020, [`request`](https://github.com/request/request) is fully deprecated. No new changes are expected to land. In fact, none have landed for some time. This package is also deprecated because it depends on `request`. + +Fyi, here is the [reasoning of `request`'s deprecation](https://github.com/request/request/issues/3142) and a [list of alternative libraries](https://github.com/request/request/issues/3143). + +--- + +The simplified HTTP request client 'request' with Promise support. Powered by Bluebird. + +[Request](https://github.com/request/request) and [Bluebird](https://github.com/petkaantonov/bluebird) are pretty awesome, but I found myself using the same design pattern. Request-Promise adds a Bluebird-powered `.then(...)` method to Request call objects. By default, http response codes other than 2xx will cause the promise to be rejected. This can be overwritten by setting `options.simple = false`. + +Also check out the new libraries that are **very similar to `request-promise` v4**: +- [`request-promise-native`](https://github.com/request/request-promise-native) v1 – Does not depend on Bluebird and uses native ES6 promises instead. +- [`request-promise-any`](https://github.com/request/request-promise-any) v1 – Allows you to register any Promise library supported by [`any-promise`](https://www.npmjs.com/package/any-promise). + +--- + +## Migration from v3 to v4 + +1. `request` became a peer dependency. Thus make sure that `request` is installed into your project as a direct dependency. (`npm install --save request`) +2. Continuation Local Storage is no longer supported. However, you [can get back the support](https://github.com/request/request-promise/wiki/Getting-Back-Support-for-Continuation-Local-Storage) by using `request-promise-any`. +3. When you migrated your `transform` function to v3 and had to add `if (!(/^2/.test('' + response.statusCode))) { return resolveWithFullResponse ? response : body; }` you may now set the option `transform2xxOnly = true` instead. + +## Migration from v2 to v3 + +1. The handling of the `transform` function got overhauled. This has two effects: + - `StatusCodeError.response` is the transformed instead of the original response now. This error is thrown for non-2xx responses when `options.simple` is `true` (default). Please update your `transform` functions to also cover the transformation of non-2xx responses. To get the old behavior you may add `if (!(/^2/.test('' + response.statusCode))) { return resolveWithFullResponse ? response : body; }` to the first line of your `transform` functions that are used for requests with `options.simple === true`. However, you may prefer updating your `transform` functions to being able to transform 2xx as well as non-2xx responses because this decouples their implementation from the use of the `simple` option when doing requests. + - If a transform operation throws an error, the request will be rejected with a `TransformError`. Its `cause` attribute contains the error thrown by the transform operation. Previously, the request was rejected directly with the error thrown by the transform operation. Wrapping it into a `TransformError` makes the error handling easier. + +2. Bluebird got updated from v2 to v3. This won't make a difference for most use cases. However, if you use advanced Promise chains starting with the Promise returned by Request-Promise, please check [Bluebird's new features and changes](http://bluebirdjs.com/docs/new-in-bluebird-3.html). + +--- + +## Installation + +This module is installed via npm: + +``` +npm install --save request +npm install --save request-promise +``` + +`request` is defined as a peer-dependency and thus has to be installed separately. + +## Cheat Sheet + +``` js +var rp = require('request-promise'); +``` + +Since `request-promise` wraps around `request` everything that works with `request` also works with `request-promise`. Also check out the [`request` docs](https://github.com/request/request) for more examples. + +### Crawl a webpage + +``` js +rp('http://www.google.com') + .then(function (htmlString) { + // Process html... + }) + .catch(function (err) { + // Crawling failed... + }); +``` + +### Crawl a webpage better + +``` js +var cheerio = require('cheerio'); // Basically jQuery for node.js + +var options = { + uri: 'http://www.google.com', + transform: function (body) { + return cheerio.load(body); + } +}; + +rp(options) + .then(function ($) { + // Process html like you would with jQuery... + }) + .catch(function (err) { + // Crawling failed or Cheerio choked... + }); +``` + +### GET something from a JSON REST API + +``` js +var options = { + uri: 'https://api.github.com/user/repos', + qs: { + access_token: 'xxxxx xxxxx' // -> uri + '?access_token=xxxxx%20xxxxx' + }, + headers: { + 'User-Agent': 'Request-Promise' + }, + json: true // Automatically parses the JSON string in the response +}; + +rp(options) + .then(function (repos) { + console.log('User has %d repos', repos.length); + }) + .catch(function (err) { + // API call failed... + }); +``` + +### POST data to a JSON REST API + +Set `option.body` to your data and `json: true` to encode the body as JSON. See below for HTML forms. + +``` js +var options = { + method: 'POST', + uri: 'http://api.posttestserver.com/post', + body: { + some: 'payload' + }, + json: true // Automatically stringifies the body to JSON +}; + +rp(options) + .then(function (parsedBody) { + // POST succeeded... + }) + .catch(function (err) { + // POST failed... + }); +``` + +### POST like HTML forms do + +Pass your data to `options.form` to encode the body the same way as HTML forms do: + +``` js +var options = { + method: 'POST', + uri: 'http://posttestserver.com/post.php', + form: { + // Like + name: 'Josh' + }, + headers: { + /* 'content-type': 'application/x-www-form-urlencoded' */ // Is set automatically + } +}; + +rp(options) + .then(function (body) { + // POST succeeded... + }) + .catch(function (err) { + // POST failed... + }); +``` + +If you want to include a file upload then use `options.formData`: + +``` js +var options = { + method: 'POST', + uri: 'http://posttestserver.com/post.php', + formData: { + // Like + name: 'Jenn', + // Like + file: { + value: fs.createReadStream('test/test.jpg'), + options: { + filename: 'test.jpg', + contentType: 'image/jpg' + } + } + }, + headers: { + /* 'content-type': 'multipart/form-data' */ // Is set automatically + } +}; + +rp(options) + .then(function (body) { + // POST succeeded... + }) + .catch(function (err) { + // POST failed... + }); +``` + +### Include a cookie + +``` js +var tough = require('tough-cookie'); + +// Easy creation of the cookie - see tough-cookie docs for details +let cookie = new tough.Cookie({ + key: "some_key", + value: "some_value", + domain: 'api.mydomain.com', + httpOnly: true, + maxAge: 31536000 +}); + +// Put cookie in an jar which can be used across multiple requests +var cookiejar = rp.jar(); +cookiejar.setCookie(cookie, 'https://api.mydomain.com'); +// ...all requests to https://api.mydomain.com will include the cookie + +var options = { + uri: 'https://api.mydomain.com/...', + jar: cookiejar // Tells rp to include cookies in jar that match uri +}; + +rp(options) + .then(function (body) { + // Request succeeded... + }) + .catch(function (err) { + // Request failed... + }); +``` + +### Get the full response instead of just the body + +``` js +var options = { + method: 'DELETE', + uri: 'http://my-server/path/to/resource/1234', + resolveWithFullResponse: true // <--- <--- <--- <--- +}; + +rp(options) + .then(function (response) { + console.log("DELETE succeeded with status %d", response.statusCode); + }) + .catch(function (err) { + // Delete failed... + }); +``` + +### Get a rejection only if the request failed for technical reasons + +``` js +var options = { + uri: 'http://www.google.com/this-page-does-not-exist.html', + simple: false // <--- <--- <--- <--- +}; + +rp(options) + .then(function (body) { + // Request succeeded but might as well be a 404 + // Usually combined with resolveWithFullResponse = true to check response.statusCode + }) + .catch(function (err) { + // Request failed due to technical reasons... + }); +``` + +--- + +**For more options checkout the [Request docs](https://github.com/request/request#requestoptions-callback).** + +--- + +## API in Detail + +Consider Request-Promise being: + +- A Request object + - With an [identical API](https://github.com/request/request): `require('request-promise') == require('request')` so to say + - However, **STREAMING THE RESPONSE** (e.g. `.pipe(...)`) is **DISCOURAGED** because Request-Promise would grow the memory footprint for large requests unnecessarily high. Use the original Request library for that. You can use both libraries in the same project. +- Plus some methods on a request call object: + - `rp(...).then(...)` or e.g. `rp.post(...).then(...)` which turn `rp(...)` and `rp.post(...)` into promises + - `rp(...).catch(...)` or e.g. `rp.del(...).catch(...)` which is the same method as provided by Bluebird promises + - Errors that the `request` library would pass to the callback are wrapped by `request-promise` and then passed to the catch handler. See [code example](https://github.com/request/request-promise#thenonfulfilled-onrejected) below. + - `rp(...).finally(...)` or e.g. `rp.put(...).finally(...)` which is the same method as provided by Bluebird promises + - `rp(...).cancel()` or e.g. `rp.get(...).cancel()` which cancels the request + - `rp(...).promise()` or e.g. `rp.head(...).promise()` which returns the underlying promise so you can access the full [Bluebird API](https://github.com/petkaantonov/bluebird/blob/master/API.md) +- Plus some additional options: + - `simple = true` which is a boolean to set whether status codes other than 2xx should also reject the promise + - `resolveWithFullResponse = false` which is a boolean to set whether the promise should be resolved with the full response or just the response body + - `transform` which takes a function to transform the response into a custom value with which the promise is resolved + - `transform2xxOnly = false` which is a boolean to set whether the transform function is applied to all responses or only to those with a 2xx status code + +The objects returned by request calls like `rp(...)` or e.g. `rp.post(...)` are regular Promises/A+ compliant promises and can be assimilated by any compatible promise library. + +The methods `.then(...)`, `.catch(...)`, and `.finally(...)` - which you can call on the request call objects - return a full-fledged Bluebird promise. That means you have the full [Bluebird API](https://github.com/petkaantonov/bluebird/blob/master/API.md) available for further chaining. E.g.: `rp(...).then(...).spread(...)` If, however, you need a method other than `.then(...)`, `.catch(...)`, or `.finally(...)` to be **FIRST** in the chain, use `.promise()`: `rp(...).promise().bind(...).then(...)` + +### .then(onFulfilled, onRejected) + +``` js +// As a Request user you would write: +var request = require('request'); + +request('http://google.com', function (err, response, body) { + if (err) { + handleError({ error: err, response: response, ... }); + } else if (!(/^2/.test('' + response.statusCode))) { // Status Codes other than 2xx + handleError({ error: body, response: response, ... }); + } else { + process(body); + } +}); + +// As a Request-Promise user you can now write the equivalent code: +var rp = require('request-promise'); + +rp('http://google.com') + .then(process, handleError); +``` + +``` js +// The same is available for all http method shortcuts: +request.post('http://example.com/api', function (err, response, body) { ... }); +rp.post('http://example.com/api').then(...); +``` + +### .catch(onRejected) + +``` js +rp('http://google.com') + .catch(handleError); + +// ... is syntactical sugar for: + +rp('http://google.com') + .then(null, handleError); + + +// However, this: +rp('http://google.com') + .then(process) + .catch(handleError); + +// ... is safer than: +rp('http://google.com') + .then(process, handleError); +``` + +For more info on `.then(process).catch(handleError)` versus `.then(process, handleError)`, see Bluebird docs on [promise anti-patterns](http://bluebirdjs.com/docs/anti-patterns.html#the-.then). + +### .finally(onFinished) + +``` js +rp('http://google.com') + .finally(function () { + // This is called after the request finishes either successful or not successful. + }); +``` + +### .cancel() + +This method cancels the request using [Bluebird's cancellation feature](http://bluebirdjs.com/docs/api/cancellation.html). + +When `.cancel()` is called: + +- the promise will neither be resolved nor rejected and +- the request is [aborted](https://nodejs.org/dist/latest-v6.x/docs/api/http.html#http_request_abort). + +### .promise() - For advanced use cases + +In order to not pollute the Request call objects with the methods of the underlying Bluebird promise, only `.then(...)`, `.catch(...)`, and `.finally(...)` were exposed to cover most use cases. The effect is that any methods of a Bluebird promise other than `.then(...)`, `.catch(...)`, or `.finally(...)` cannot be used as the **FIRST** method in the promise chain: + +``` js +// This works: +rp('http://google.com').then(function () { ... }); +rp('http://google.com').catch(function () { ... }); + +// This works as well since additional methods are only used AFTER the FIRST call in the chain: +rp('http://google.com').then(function () { ... }).spread(function () { ... }); +rp('http://google.com').catch(function () { ... }).error(function () { ... }); + +// Using additional methods as the FIRST call in the chain does not work: +// rp('http://google.com').bind(this).then(function () { ... }); + +// Use .promise() in these cases: +rp('http://google.com').promise().bind(this).then(function () { ... }); +``` + +### Fulfilled promises and the `resolveWithFullResponse` option + +``` js +// Per default the body is passed to the fulfillment handler: +rp('http://google.com') + .then(function (body) { + // Process the html of the Google web page... + }); + +// The resolveWithFullResponse options allows to pass the full response: +rp({ uri: 'http://google.com', resolveWithFullResponse: true }) + .then(function (response) { + // Access response.statusCode, response.body etc. + }); + +``` + +### Rejected promises and the `simple` option + +``` js +// The rejection handler is called with a reason object... +rp('http://google.com') + .catch(function (reason) { + // Handle failed request... + }); + +// ... and would be equivalent to this Request-only implementation: +var options = { uri: 'http://google.com' }; + +request(options, function (err, response, body) { + var reason; + if (err) { + reason = { + cause: err, + error: err, + options: options, + response: response + }; + } else if (!(/^2/.test('' + response.statusCode))) { // Status Codes other than 2xx + reason = { + statusCode: response.statusCode, + error: body, + options: options, + response: response + }; + } + + if (reason) { + // Handle failed request... + } +}); + + +// If you pass the simple option as false... +rp({ uri: 'http://google.com', simple: false }) + .catch(function (reason) { + // Handle failed request... + }); + +// ... the equivalent Request-only code would be: +request(options, function (err, response, body) { + if (err) { + var reason = { + cause: err, + error: err, + options: options, + response: response + }; + // Handle failed request... + } +}); +// E.g. a 404 would now fulfill the promise. +// Combine it with resolveWithFullResponse = true to check the status code in the fulfillment handler. +``` + +With version 0.4 the reason objects became Error objects with identical properties to ensure backwards compatibility. These new Error types allow targeted catch blocks: + +``` js +var errors = require('request-promise/errors'); + +rp('http://google.com') + .catch(errors.StatusCodeError, function (reason) { + // The server responded with a status codes other than 2xx. + // Check reason.statusCode + }) + .catch(errors.RequestError, function (reason) { + // The request failed due to technical reasons. + // reason.cause is the Error object Request would pass into a callback. + }); +``` + +### The `transform` function + +You can pass a function to `options.transform` to generate a custom fulfillment value when the promise gets resolved. + +``` js +// Just for fun you could reverse the response body: +var options = { + uri: 'http://google.com', + transform: function (body, response, resolveWithFullResponse) { + return body.split('').reverse().join(''); + } +}; + +rp(options) + .then(function (reversedBody) { + // ;D + }); + + +// However, you could also do something useful: +var $ = require('cheerio'); // Basically jQuery for node.js + +function autoParse(body, response, resolveWithFullResponse) { + // FIXME: The content type string could contain additional values like the charset. + // Consider using the `content-type` library for a robust comparison. + if (response.headers['content-type'] === 'application/json') { + return JSON.parse(body); + } else if (response.headers['content-type'] === 'text/html') { + return $.load(body); + } else { + return body; + } +} + +options.transform = autoParse; + +rp(options) + .then(function (autoParsedBody) { + // :) + }); + + +// You can go one step further and set the transform as the default: +var rpap = rp.defaults({ transform: autoParse }); + +rpap('http://google.com') + .then(function (autoParsedBody) { + // :) + }); + +rpap('http://echojs.com') + .then(function (autoParsedBody) { + // =) + }); +``` + +The third `resolveWithFullResponse` parameter of the transform function is equivalent to the option passed with the request. This allows to distinguish whether just the transformed body or the whole response shall be returned by the transform function: + +``` js +function reverseBody(body, response, resolveWithFullResponse) { + response.body = response.body.split('').reverse().join(''); + return resolveWithFullResponse ? response : response.body; +} +``` + +As of Request-Promise v3 the transform function is ALWAYS executed for non-2xx responses. When `options.simple` is set to `true` (default) then non-2xx responses are rejected with a `StatusCodeError`. In this case the error contains the transformed response: + +``` js +var options = { + uri: 'http://the-server.com/will-return/404', + simple: true, + transform: function (body, response, resolveWithFullResponse) { /* ... */ } +}; + +rp(options) + .catch(errors.StatusCodeError, function (reason) { + // reason.response is the transformed response + }); +``` + +You may set `options.transform2xxOnly = true` to only execute the transform function for responses with a 2xx status code. For other status codes – independent of any other settings, e.g. `options.simple` – the transform function is not executed. + +#### Error handling + +If the transform operation fails (throws an error) the request will be rejected with a `TransformError`: + +``` js +var errors = require('request-promise/errors'); + +var options = { + uri: 'http://google.com', + transform: function (body, response, resolveWithFullResponse) { + throw new Error('Transform failed!'); + } +}; + +rp(options) + .catch(errors.TransformError, function (reason) { + console.log(reason.cause.message); // => Transform failed! + // reason.response is the original response for which the transform operation failed + }); +``` + +## Experimental Support for Continuation Local Storage + +Continuation Local Storage is no longer supported. However, you [can get back the support](https://github.com/request/request-promise/wiki/Getting-Back-Support-for-Continuation-Local-Storage) by using `request-promise-any`. + +## Debugging + +The ways to debug the operation of Request-Promise are the same [as described](https://github.com/request/request#debugging) for Request. These are: + +1. Launch the node process like `NODE_DEBUG=request node script.js` (`lib,request,otherlib` works too). +2. Set `require('request-promise').debug = true` at any time (this does the same thing as #1). +3. Use the [request-debug module](https://github.com/nylen/request-debug) to view request and response headers and bodies. Instrument Request-Promise with `require('request-debug')(rp);`. + +## Mocking Request-Promise + +Usually you want to mock the whole request function which is returned by `require('request-promise')`. This is not possible by using a mocking library like [sinon.js](http://sinonjs.org) alone. What you need is a library that ties into the module loader and makes sure that your mock is returned whenever the tested code is calling `require('request-promise')`. [Mockery](https://github.com/mfncooper/mockery) is one of such libraries. + +@florianschmidt1994 kindly shared his solution: +```javascript +before(function (done) { + + var filename = "fileForResponse"; + mockery.enable({ + warnOnReplace: false, + warnOnUnregistered: false, + useCleanCache: true + }); + + mockery.registerMock('request-promise', function () { + var response = fs.readFileSync(__dirname + '/data/' + filename, 'utf8'); + return Bluebird.resolve(response.trim()); + }); + + done(); +}); + +after(function (done) { + mockery.disable(); + mockery.deregisterAll(); + done(); +}); + +describe('custom test case', function () { + // Test some function/module/... which uses request-promise + // and it will always receive the predefined "fileForResponse" as data, e.g.: + var rp = require('request-promise'); + rp(...).then(function(data) { + // ➞ data is what is in fileForResponse + }); +}); +``` + +Based on that you may now build a more sophisticated mock. [Sinon.js](http://sinonjs.org) may be of help as well. + +## Contributing + +To set up your development environment: + +1. clone the repo to your desktop, +2. in the shell `cd` to the main folder, +3. hit `npm install`, +4. hit `npm install gulp -g` if you haven't installed gulp globally yet, and +5. run `gulp dev`. (Or run `node ./node_modules/.bin/gulp dev` if you don't want to install gulp globally.) + +`gulp dev` watches all source files and if you save some changes it will lint the code and execute all tests. The test coverage report can be viewed from `./coverage/lcov-report/index.html`. + +If you want to debug a test you should use `gulp test-without-coverage` to run all tests without obscuring the code by the test coverage instrumentation. + +## Change History + +- v4.2.5 (2019-11-03) + - Security fix: bumped `request-promise-core` which bumps `lodash` to `^4.17.15`. See [vulnerabilty reports](https://snyk.io/vuln/search?q=lodash&type=npm). + *(Thanks to @rishabh-chowdhary for reporting this in pull request [#326](https://github.com/request/request-promise/pull/326).)* +- v4.2.4 (2019-02-14) + - Corrected mistakenly set `tough-cookie` version, now `^2.3.3` + *(Thanks to @evocateur for pointing this out.)* + - If you installed `request-promise@4.2.3` please make sure after the upgrade that `request` and `request-promise` use the same physical copy of `tough-cookie`. +- v4.2.3 (2019-02-14) + - Using stricter `tough-cookie@~2.3.3` to avoid installing `tough-cookie@3` which introduces breaking changes + *(Thanks to @aomdoa for pull request [#299](https://github.com/request/request-promise/pull/299))* + - Security fix: bumped `lodash` to `^4.17.11`, see [vulnerabilty reports](https://snyk.io/vuln/search?q=lodash&type=npm) +- v4.2.2 (2017-09-22) + - Upgraded `tough-cookie` to a version without regex DoS vulnerability + *(Thanks to @rouanw for [pull request #226](https://github.com/request/request-promise/pull/226))* +- v4.2.1 (2017-05-07) + - Fix that allows to use `tough-cookie` for cookie creation + *(Thanks to @ScottyMJacobson for reporting [issue #183](https://github.com/request/request-promise/issues/183))* + - Added [cookie handling example](https://github.com/request/request-promise#include-a-cookie) to the cheat sheet + *(Thanks to @chovy and @ProfessorTom for [asking for it](https://github.com/request/request-promise/issues/79))* +- v4.2.0 (2017-03-16) + - Updated `bluebird` to v3.5 + *(Thanks to @acinader for [pull request #181](https://github.com/request/request-promise/pull/181))* +- v4.1.1 (2016-08-08) + - Renamed internally used package `@request/promise-core` to `request-promise-core` because there where [too](https://github.com/request/request-promise/issues/137) [many](https://github.com/request/request-promise/issues/141) issues with the scoped package name + *(Thanks to @cabrinoob, @crazy4groovy, @dsandor, @KpjComp, @lorenwest, @Reisyukaku, @tehChromic, @todd for providing helpful information.)* +- v4.1.0 (2016-07-30) + - Added cancellation support + *(Thanks to @not-an-aardvark for [pull request #123](https://github.com/request/request-promise/pull/123))* +- v4.0.2 (2016-07-18) + - Fix for using with module bundlers like Webpack and Browserify +- v4.0.1 (2016-07-17) + - Fixed `@request/promise-core` version for safer versioning +- v4.0.0 (2016-07-15) + - **Breaking Change**: `request` is declared as a peer dependency which has to be installed separately by the user now + - **Breaking Change**: Dropped support for Continuation Local Storage since [`request-promise-any`](https://github.com/request/request-promise-any) can be [used](https://github.com/request/request-promise/wiki/Getting-Back-Support-for-Continuation-Local-Storage) for that now + - Introduced the `transform2xxOnly` option to ease the breaking change regarding the new `transform` handling in v3.0.0 + *(Thanks to @stevage for pointing out the effect of the breaking change in [issue #131](https://github.com/request/request-promise/issues/131))* + - Resolved issues [#65](https://github.com/request/request-promise/issues/65) and [#71](https://github.com/request/request-promise/issues/71) by publishing nearly identical libraries to support other Promise implementations: [`request-promise-native`](https://github.com/request/request-promise-native) and [`request-promise-any`](https://github.com/request/request-promise-any) + *(Thanks to @benjamingr, @eilgin, @gillesdemey, @hildjj, @iggycoloma, @jonathanong, @knpwrs, @MarkHerhold, @massimocode, @mikeal, @niftylettuce, @raitucarp, @sherdeadlock, @tonylukasavage, and @vgoloviznin for the valuable discussions!)* + - Relicensed this library with the ISC license +- v3.0.0 (2016-04-16) + - **Breaking Change**: Overhauled the handling of the `transform` function + *(Thanks to @Limess for explaining the need in [issue #86](https://github.com/request/request-promise/issues/86))* + - **Breaking Change**: Updated `bluebird` to v3 + *(Thanks to @BrandonSmith for [pull request #103](https://github.com/request/request-promise/pull/103))* + - Improved `StatusCodeError.message` + - Updated `lodash` to v4.6 + - Improved README in regard to `.catch(...)` best practice + *(Thanks to @RebootJeff for [pull request #98](https://github.com/request/request-promise/pull/98))* +- v2.0.1 (2016-02-17) + - Updated `lodash` to v4 + *(Thanks to @ratson for [pull request #94](https://github.com/request/request-promise/pull/94))* +- v2.0.0 (2016-01-12) + - **Breaking Change**: Removed explicit `cls-bluebird` dependency which has to be installed by the user now + *(Thanks to @hildjj for his [pull request #75](https://github.com/request/request-promise/pull/75))* + - `npm shrinkwrap` now works for `npm@3` users who don't use `continuation-local-storage` + *(Thanks to @toboid and @rstacruz for reporting the issue in [issue #70](https://github.com/request/request-promise/issues/70) and [issue #82](https://github.com/request/request-promise/issues/82))* +- v1.0.2 (2015-10-22) + - Removed `continuation-local-storage` from peer dependencies as it was unnecessary + *(Thanks to @mrhyde for working on a better solution discussed in [issue #70](https://github.com/request/request-promise/issues/70))* +- v1.0.1 (2015-10-14) + - Fixed a npm warning by marking `continuation-local-storage` as a peer dependency +- v1.0.0 (2015-10-11) + - **Breaking Change**: Some errors that were previously thrown synchronously - e.g. for wrong input parameters - are now passed to the rejected promise instead + *(Thanks to @josnidhin for suggesting that in [issue #43](https://github.com/request/request-promise/issues/43))* + - **Breaking Change**: Request-Promise does not load its own Bluebird prototype anymore. If you use Bluebird in your project and altered the prototype then Request-Promise may use your altered Bluebird prototype internally. + - For HEAD requests the headers instead of an empty body is returned (unless `resolveWithFullResponse = true` is used) + *(Thanks to @zcei for proposing the change in [issue #58](https://github.com/request/request-promise/issues/58))* + - Extended `transform` function by a third `resolveWithFullResponse` parameter + - Added experimental support for continuation local storage + *(Thanks to @silverbp preparing this in [issue #64](https://github.com/request/request-promise/issues/64))* + - Added node.js 4 to the Travis CI build + - Updated the README + *(Thanks to many people for their feedback in issues [#55](https://github.com/request/request-promise/issues/55) and [#59](https://github.com/request/request-promise/issues/59))* +- v0.4.3 (2015-07-27) + - Reduced overhead by just requiring used lodash functions instead of the whole lodash library + *(Thanks to @luanmuniz for [pull request #54](https://github.com/request/request-promise/pull/54))* + - Updated dependencies +- v0.4.2 (2015-04-12) + - Updated dependencies +- v0.4.1 (2015-03-20) + - Improved Error types to work in browsers without v8 engine + *(Thanks to @nodiis for [pull request #40](https://github.com/request/request-promise/pull/40))* +- v0.4.0 (2015-02-08) + - Introduced Error types used for the reject reasons (See last part [this section](#rejected-promises-and-the-simple-option)) + *(Thanks to @jakecraige for starting the discussion in [issue #38](https://github.com/request/request-promise/issues/38))* + - **Minor Breaking Change:** The reject reason objects became actual Error objects. However, `typeof reason === 'object'` still holds true and the error objects have the same properties as the previous reason objects. If the reject handler only accesses the properties on the reason object - which is usually the case - no migration is required. + - Added io.js and node.js 0.12 to the Travis CI build +- v0.3.3 (2015-01-19) + - Fixed handling possibly unhandled rejections to work with the latest version of Bluebird + *(Thanks to @slang800 for reporting this in [issue #36](https://github.com/request/request-promise/issues/36))* +- v0.3.2 (2014-11-17) + - Exposed `.finally(...)` to allow using it as the first method in the promise chain + *(Thanks to @hjpbarcelos for his [pull request #28](https://github.com/request/request-promise/pull/28))* +- v0.3.1 (2014-11-11) + - Added the `.promise()` method for advanced Bluebird API usage + *(Thanks to @devo-tox for his feedback in [issue #27](https://github.com/request/request-promise/issues/27))* +- v0.3.0 (2014-11-10) + - Carefully rewritten from scratch to make Request-Promise a drop-in replacement for Request + +## License (ISC) + +In case you never heard about the [ISC license](http://en.wikipedia.org/wiki/ISC_license) it is functionally equivalent to the MIT license. + +See the [LICENSE file](LICENSE) for details. diff --git a/node_modules/@cypress/request-promise/errors.js b/node_modules/@cypress/request-promise/errors.js new file mode 100644 index 0000000000000000000000000000000000000000..e1021bce2485575c2ca0796425de46a4a5deae12 --- /dev/null +++ b/node_modules/@cypress/request-promise/errors.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('request-promise-core/errors'); diff --git a/node_modules/@cypress/request-promise/lib/rp.js b/node_modules/@cypress/request-promise/lib/rp.js new file mode 100644 index 0000000000000000000000000000000000000000..a2f68056d46cc709f48c34dfc54052c4a9fc942c --- /dev/null +++ b/node_modules/@cypress/request-promise/lib/rp.js @@ -0,0 +1,52 @@ +'use strict'; + +var Bluebird = require('bluebird').getNewLibraryCopy(), + configure = require('request-promise-core/configure/request2'), + stealthyRequire = require('stealthy-require'); + +try { + + // Load Request freshly - so that users can require an unaltered request instance! + var request = stealthyRequire(require.cache, function () { + return require('@cypress/request'); + }, + function () { + require('tough-cookie'); + }, module); + +} catch (err) { + /* istanbul ignore next */ + var EOL = require('os').EOL; + /* istanbul ignore next */ + console.error(EOL + '###' + EOL + '### The "request" library is not installed automatically anymore.' + EOL + '### But is a dependency of "request-promise".' + EOL + '### Please install it with:' + EOL + '### npm install request --save' + EOL + '###' + EOL); + /* istanbul ignore next */ + throw err; +} + +Bluebird.config({cancellation: true}); + +configure({ + request: request, + PromiseImpl: Bluebird, + expose: [ + 'then', + 'catch', + 'finally', + 'cancel', + 'promise' + // Would you like to expose more Bluebird methods? Try e.g. `rp(...).promise().tap(...)` first. `.promise()` returns the full-fledged Bluebird promise. + ], + constructorMixin: function (resolve, reject, onCancel) { + var self = this; + onCancel(function () { + self.abort(); + }); + } +}); + +request.bindCLS = function RP$bindCLS() { + throw new Error('CLS support was dropped. To get it back read: https://github.com/request/request-promise/wiki/Getting-Back-Support-for-Continuation-Local-Storage'); +}; + + +module.exports = request; diff --git a/node_modules/@cypress/request-promise/package.json b/node_modules/@cypress/request-promise/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b5b1d8935265bb6fbe187989025ca1cf0a2e6b9a --- /dev/null +++ b/node_modules/@cypress/request-promise/package.json @@ -0,0 +1,61 @@ +{ + "name": "@cypress/request-promise", + "version": "5.0.0", + "description": "Cypress's fork of the simplified HTTP request client 'request' with Promise support. Powered by Bluebird.", + "keywords": [ + "xhr", + "http", + "https", + "promise", + "request", + "then", + "thenable", + "bluebird" + ], + "main": "./lib/rp.js", + "scripts": { + "test": "./node_modules/.bin/gulp ci", + "test-publish": "./node_modules/.bin/gulp ci-no-cov", + "publish-please": "publish-please" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/cypress-io/request-promise.git" + }, + "author": "Nicolai Kamenzky (https://github.com/analog-nico)", + "license": "ISC", + "bugs": { + "url": "https://github.com/cypress-io/request-promise/issues" + }, + "homepage": "https://github.com/cypress-io/request-promise#readme", + "engines": { + "node": ">=0.10.0" + }, + "dependencies": { + "request-promise-core": "1.1.3", + "bluebird": "^3.5.0", + "stealthy-require": "^1.1.1", + "tough-cookie": "^4.1.3" + }, + "peerDependencies": { + "@cypress/request": "^3.0.0" + }, + "devDependencies": { + "body-parser": "~1.15.2", + "chai": "~3.5.0", + "chalk": "~1.1.3", + "gulp": "~3.9.1", + "gulp-coveralls": "~0.1.4", + "gulp-eslint": "~2.1.0", + "gulp-istanbul": "~1.0.0", + "gulp-mocha": "~2.2.0", + "lodash": "~4.13.1", + "publish-please": "~2.1.4", + "@cypress/request": "^3.0.0", + "rimraf": "~2.5.3", + "run-sequence": "~1.2.2" + }, + "resolutions": { + "chalk": "~1.1.3" + } +} diff --git a/node_modules/@cypress/request/LICENSE b/node_modules/@cypress/request/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..a4a9aee0c2fa14a2007895d018bfa06f0592fd34 --- /dev/null +++ b/node_modules/@cypress/request/LICENSE @@ -0,0 +1,55 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/node_modules/@cypress/request/README.md b/node_modules/@cypress/request/README.md new file mode 100644 index 0000000000000000000000000000000000000000..47bc4da721f2e210a32ffa7dcef9452dd7cdbe80 --- /dev/null +++ b/node_modules/@cypress/request/README.md @@ -0,0 +1,1032 @@ + +# @cypress/request - Simplified HTTP client + +[![npm package](https://nodei.co/npm/@cypress/request.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/@cypress/request/) + +**This is a fork of [`request`](https://github.com/request/request) for use in [Cypress](https://github.com/cypress-io/cypress).** + +## Super simple to use + +Request is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default. + +```js +const request = require('@cypress/request'); +request('http://www.google.com', function (error, response, body) { + console.error('error:', error); // Print the error if one occurred + console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received + console.log('body:', body); // Print the HTML for the Google homepage. +}); +``` + + +## Table of contents + +- [Streaming](#streaming) +- [Promises & Async/Await](#promises--asyncawait) +- [Forms](#forms) +- [HTTP Authentication](#http-authentication) +- [Custom HTTP Headers](#custom-http-headers) +- [Proxies](#proxies) +- [Unix Domain Sockets](#unix-domain-sockets) +- [TLS/SSL Protocol](#tlsssl-protocol) +- [Support for HAR 1.2](#support-for-har-12) +- [**All Available Options**](#requestoptions-callback) + +Request also offers [convenience methods](#convenience-methods) like +`request.defaults` and `request.post`, and there are +lots of [usage examples](#examples) and several +[debugging techniques](#debugging). + + +--- + + +## Streaming + +You can stream any response to a file stream. + +```js +request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')) +``` + +You can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types (in this case `application/json`) and use the proper `content-type` in the PUT request (if the headers don’t already provide one). + +```js +fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json')) +``` + +Request can also `pipe` to itself. When doing so, `content-type` and `content-length` are preserved in the PUT headers. + +```js +request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')) +``` + +Request emits a "response" event when a response is received. The `response` argument will be an instance of [http.IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage). + +```js +request + .get('http://google.com/img.png') + .on('response', function(response) { + console.log(response.statusCode) // 200 + console.log(response.headers['content-type']) // 'image/png' + }) + .pipe(request.put('http://mysite.com/img.png')) +``` + +To easily handle errors when streaming requests, listen to the `error` event before piping: + +```js +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.error(err) + }) + .pipe(fs.createWriteStream('doodle.png')) +``` + +Now let’s get fancy. + +```js +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + if (req.method === 'PUT') { + req.pipe(request.put('http://mysite.com/doodle.png')) + } else if (req.method === 'GET' || req.method === 'HEAD') { + request.get('http://mysite.com/doodle.png').pipe(resp) + } + } +}) +``` + +You can also `pipe()` from `http.ServerRequest` instances, as well as to `http.ServerResponse` instances. The HTTP method, headers, and entity-body data will be sent. Which means that, if you don't really care about security, you can do: + +```js +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + const x = request('http://mysite.com/doodle.png') + req.pipe(x) + x.pipe(resp) + } +}) +``` + +And since `pipe()` returns the destination stream in ≥ Node 0.5.x you can do one line proxying. :) + +```js +req.pipe(request('http://mysite.com/doodle.png')).pipe(resp) +``` + +Also, none of this new functionality conflicts with requests previous features, it just expands them. + +```js +const r = request.defaults({'proxy':'http://localproxy.com'}) + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + r.get('http://google.com/doodle.png').pipe(resp) + } +}) +``` + +You can still use intermediate proxies, the requests will still follow HTTP forwards, etc. + +[back to top](#table-of-contents) + + +--- + + +## Promises & Async/Await + +`request` supports both streaming and callback interfaces natively. If you'd like `request` to return a Promise instead, you can use an alternative interface wrapper for `request`. These wrappers can be useful if you prefer to work with Promises, or if you'd like to use `async`/`await` in ES2017. + +Several alternative interfaces are provided by the request team, including: +- [`request-promise`](https://github.com/cypress-io/request-promise) (uses [Bluebird](https://github.com/petkaantonov/bluebird) Promises) +- [`request-promise-native`](https://github.com/cypress-io/request-promise-native) (uses native Promises) +- [`request-promise-any`](https://github.com/cypress-io/request-promise-any) (uses [any-promise](https://www.npmjs.com/package/any-promise) Promises) + +Also, [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original), which is available from Node.js v8.0 can be used to convert a regular function that takes a callback to return a promise instead. + + +[back to top](#table-of-contents) + + +--- + + +## Forms + +`request` supports `application/x-www-form-urlencoded` and `multipart/form-data` form uploads. For `multipart/related` refer to the `multipart` API. + + +#### application/x-www-form-urlencoded (URL-Encoded Forms) + +URL-encoded forms are simple. + +```js +request.post('http://service.com/upload', {form:{key:'value'}}) +// or +request.post('http://service.com/upload').form({key:'value'}) +// or +request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }) +``` + + +#### multipart/form-data (Multipart Form Uploads) + +For `multipart/form-data` we use the [form-data](https://github.com/form-data/form-data) library by [@felixge](https://github.com/felixge). For the most cases, you can pass your upload form data via the `formData` option. + + +```js +const formData = { + // Pass a simple key-value pair + my_field: 'my_value', + // Pass data via Buffers + my_buffer: Buffer.from([1, 2, 3]), + // Pass data via Streams + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + // Pass multiple values /w an Array + attachments: [ + fs.createReadStream(__dirname + '/attachment1.jpg'), + fs.createReadStream(__dirname + '/attachment2.jpg') + ], + // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} + // Use case: for some types of streams, you'll need to provide "file"-related information manually. + // See the `form-data` README for more information about options: https://github.com/form-data/form-data + custom_file: { + value: fs.createReadStream('/dev/urandom'), + options: { + filename: 'topsecret.jpg', + contentType: 'image/jpeg' + } + } +}; +request.post({url:'http://service.com/upload', formData: formData}, function optionalCallback(err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); +}); +``` + +For advanced cases, you can access the form-data object itself via `r.form()`. This can be modified until the request is fired on the next cycle of the event-loop. (Note that this calling `form()` will clear the currently set form data for that request.) + +```js +// NOTE: Advanced use-case, for normal use see 'formData' usage above +const r = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {...}) +const form = r.form(); +form.append('my_field', 'my_value'); +form.append('my_buffer', Buffer.from([1, 2, 3])); +form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'}); +``` +See the [form-data README](https://github.com/form-data/form-data) for more information & examples. + + +#### multipart/related + +Some variations in different HTTP implementations require a newline/CRLF before, after, or both before and after the boundary of a `multipart/related` request (using the multipart option). This has been observed in the .NET WebAPI version 4.0. You can turn on a boundary preambleCRLF or postamble by passing them as `true` to your request options. + +```js + request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' }, + { body: fs.createReadStream('image.png') } + ], + // alternatively pass an object containing additional options + multipart: { + chunked: false, + data: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' } + ] + } + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }) +``` + +[back to top](#table-of-contents) + + +--- + + +## HTTP Authentication + +```js +request.get('http://some.server.com/').auth('username', 'password', false); +// or +request.get('http://some.server.com/', { + 'auth': { + 'user': 'username', + 'pass': 'password', + 'sendImmediately': false + } +}); +// or +request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); +// or +request.get('http://some.server.com/', { + 'auth': { + 'bearer': 'bearerToken' + } +}); +``` + +If passed as an option, `auth` should be a hash containing values: + +- `user` || `username` +- `pass` || `password` +- `sendImmediately` (optional) +- `bearer` (optional) + +The method form takes parameters +`auth(username, password, sendImmediately, bearer)`. + +`sendImmediately` defaults to `true`, which causes a basic or bearer +authentication header to be sent. If `sendImmediately` is `false`, then +`request` will retry with a proper authentication header after receiving a +`401` response from the server (which must contain a `WWW-Authenticate` header +indicating the required authentication method). + +Note that you can also specify basic authentication using the URL itself, as +detailed in [RFC 1738](http://www.ietf.org/rfc/rfc1738.txt). Simply pass the +`user:password` before the host with an `@` sign: + +```js +const username = 'username', + password = 'password', + url = 'http://' + username + ':' + password + '@some.server.com'; + +request({url}, function (error, response, body) { + // Do more stuff with 'body' here +}); +``` + +Digest authentication is supported, but it only works with `sendImmediately` +set to `false`; otherwise `request` will send basic authentication on the +initial request, which will probably cause the request to fail. + +Bearer authentication is supported, and is activated when the `bearer` value is +available. The value may be either a `String` or a `Function` returning a +`String`. Using a function to supply the bearer token is particularly useful if +used in conjunction with `defaults` to allow a single function to supply the +last known token at the time of sending a request, or to compute one on the fly. + +[back to top](#table-of-contents) + + +--- + + +## Custom HTTP Headers + +HTTP Headers, such as `User-Agent`, can be set in the `options` object. +In the example below, we call the github API to find out the number +of stars and forks for the request repository. This requires a +custom `User-Agent` header as well as https. + +```js +const request = require('request'); + +const options = { + url: 'https://api.github.com/repos/cypress-io/request', + headers: { + 'User-Agent': 'request' + } +}; + +function callback(error, response, body) { + if (!error && response.statusCode == 200) { + const info = JSON.parse(body); + console.log(info.stargazers_count + " Stars"); + console.log(info.forks_count + " Forks"); + } +} + +request(options, callback); +``` + +[back to top](#table-of-contents) + + +--- + +## Proxies + +If you specify a `proxy` option, then the request (and any subsequent +redirects) will be sent via a connection to the proxy server. + +If your endpoint is an `https` url, and you are using a proxy, then +request will send a `CONNECT` request to the proxy server *first*, and +then use the supplied connection to connect to the endpoint. + +That is, first it will make a request like: + +``` +HTTP/1.1 CONNECT endpoint-server.com:80 +Host: proxy-server.com +User-Agent: whatever user agent you specify +``` + +and then the proxy server make a TCP connection to `endpoint-server` +on port `80`, and return a response that looks like: + +``` +HTTP/1.1 200 OK +``` + +At this point, the connection is left open, and the client is +communicating directly with the `endpoint-server.com` machine. + +See [the wikipedia page on HTTP Tunneling](https://en.wikipedia.org/wiki/HTTP_tunnel) +for more information. + +By default, when proxying `http` traffic, request will simply make a +standard proxied `http` request. This is done by making the `url` +section of the initial line of the request a fully qualified url to +the endpoint. + +For example, it will make a single request that looks like: + +``` +HTTP/1.1 GET http://endpoint-server.com/some-url +Host: proxy-server.com +Other-Headers: all go here + +request body or whatever +``` + +Because a pure "http over http" tunnel offers no additional security +or other features, it is generally simpler to go with a +straightforward HTTP proxy in this case. However, if you would like +to force a tunneling proxy, you may set the `tunnel` option to `true`. + +You can also make a standard proxied `http` request by explicitly setting +`tunnel : false`, but **note that this will allow the proxy to see the traffic +to/from the destination server**. + +If you are using a tunneling proxy, you may set the +`proxyHeaderWhiteList` to share certain headers with the proxy. + +You can also set the `proxyHeaderExclusiveList` to share certain +headers only with the proxy and not with destination host. + +By default, this set is: + +``` +accept +accept-charset +accept-encoding +accept-language +accept-ranges +cache-control +content-encoding +content-language +content-length +content-location +content-md5 +content-range +content-type +connection +date +expect +max-forwards +pragma +proxy-authorization +referer +te +transfer-encoding +user-agent +via +``` + +Note that, when using a tunneling proxy, the `proxy-authorization` +header and any headers from custom `proxyHeaderExclusiveList` are +*never* sent to the endpoint server, but only to the proxy server. + + +### Controlling proxy behaviour using environment variables + +The following environment variables are respected by `request`: + + * `HTTP_PROXY` / `http_proxy` + * `HTTPS_PROXY` / `https_proxy` + * `NO_PROXY` / `no_proxy` + +When `HTTP_PROXY` / `http_proxy` are set, they will be used to proxy non-SSL requests that do not have an explicit `proxy` configuration option present. Similarly, `HTTPS_PROXY` / `https_proxy` will be respected for SSL requests that do not have an explicit `proxy` configuration option. It is valid to define a proxy in one of the environment variables, but then override it for a specific request, using the `proxy` configuration option. Furthermore, the `proxy` configuration option can be explicitly set to false / null to opt out of proxying altogether for that request. + +`request` is also aware of the `NO_PROXY`/`no_proxy` environment variables. These variables provide a granular way to opt out of proxying, on a per-host basis. It should contain a comma separated list of hosts to opt out of proxying. It is also possible to opt of proxying when a particular destination port is used. Finally, the variable may be set to `*` to opt out of the implicit proxy configuration of the other environment variables. + +Here's some examples of valid `no_proxy` values: + + * `google.com` - don't proxy HTTP/HTTPS requests to Google. + * `google.com:443` - don't proxy HTTPS requests to Google, but *do* proxy HTTP requests to Google. + * `google.com:443, yahoo.com:80` - don't proxy HTTPS requests to Google, and don't proxy HTTP requests to Yahoo! + * `*` - ignore `https_proxy`/`http_proxy` environment variables altogether. + +[back to top](#table-of-contents) + + +--- + + +## UNIX Domain Sockets + +`request` supports making requests to [UNIX Domain Sockets](https://en.wikipedia.org/wiki/Unix_domain_socket). To make one, use the following URL scheme: + +```js +/* Pattern */ 'http://unix:SOCKET:PATH' +/* Example */ request.get('http://unix:/absolute/path/to/unix.socket:/request/path') +``` + +Note: The `SOCKET` path is assumed to be absolute to the root of the host file system. + +[back to top](#table-of-contents) + + +--- + + +## TLS/SSL Protocol + +TLS/SSL Protocol options, such as `cert`, `key` and `passphrase`, can be +set directly in `options` object, in the `agentOptions` property of the `options` object, or even in `https.globalAgent.options`. Keep in mind that, although `agentOptions` allows for a slightly wider range of configurations, the recommended way is via `options` object directly, as using `agentOptions` or `https.globalAgent.options` would not be applied in the same way in proxied environments (as data travels through a TLS connection instead of an http/https agent). + +```js +const fs = require('fs') + , path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , caFile = path.resolve(__dirname, 'ssl/ca.cert.pem') + , request = require('request'); + +const options = { + url: 'https://api.some-server.com/', + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + passphrase: 'password', + ca: fs.readFileSync(caFile) +}; + +request.get(options); +``` + +### Using `options.agentOptions` + +In the example below, we call an API that requires client side SSL certificate +(in PEM format) with passphrase protected private key (in PEM format) and disable the SSLv3 protocol: + +```js +const fs = require('fs') + , path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , request = require('request'); + +const options = { + url: 'https://api.some-server.com/', + agentOptions: { + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: + // pfx: fs.readFileSync(pfxFilePath), + passphrase: 'password', + securityOptions: 'SSL_OP_NO_SSLv3' + } +}; + +request.get(options); +``` + +It is able to force using SSLv3 only by specifying `secureProtocol`: + +```js +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + secureProtocol: 'SSLv3_method' + } +}); +``` + +It is possible to accept other certificates than those signed by generally allowed Certificate Authorities (CAs). +This can be useful, for example, when using self-signed certificates. +To require a different root certificate, you can specify the signing CA by adding the contents of the CA's certificate file to the `agentOptions`. +The certificate the domain presents must be signed by the root certificate specified: + +```js +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: fs.readFileSync('ca.cert.pem') + } +}); +``` + +The `ca` value can be an array of certificates, in the event you have a private or internal corporate public-key infrastructure hierarchy. For example, if you want to connect to https://api.some-server.com which presents a key chain consisting of: +1. its own public key, which is signed by: +2. an intermediate "Corp Issuing Server", that is in turn signed by: +3. a root CA "Corp Root CA"; + +you can configure your request as follows: + +```js +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: [ + fs.readFileSync('Corp Issuing Server.pem'), + fs.readFileSync('Corp Root CA.pem') + ] + } +}); +``` + +[back to top](#table-of-contents) + + +--- + +## Support for HAR 1.2 + +The `options.har` property will override the values: `url`, `method`, `qs`, `headers`, `form`, `formData`, `body`, `json`, as well as construct multipart data and read files from disk when `request.postData.params[].fileName` is present without a matching `value`. + +A validation step will check if the HAR Request format matches the latest spec (v1.2) and will skip parsing if not matching. + +```js + const request = require('request') + request({ + // will be ignored + method: 'GET', + uri: 'http://www.google.com', + + // HTTP Archive Request Object + har: { + url: 'http://www.mockbin.com/har', + method: 'POST', + headers: [ + { + name: 'content-type', + value: 'application/x-www-form-urlencoded' + } + ], + postData: { + mimeType: 'application/x-www-form-urlencoded', + params: [ + { + name: 'foo', + value: 'bar' + }, + { + name: 'hello', + value: 'world' + } + ] + } + } + }) + + // a POST request will be sent to http://www.mockbin.com + // with body an application/x-www-form-urlencoded body: + // foo=bar&hello=world +``` + +[back to top](#table-of-contents) + + +--- + +## request(options, callback) + +The first argument can be either a `url` or an `options` object. The only required option is `uri`; all others are optional. + +- `uri` || `url` - fully qualified uri or a parsed url object from `url.parse()` +- `baseUrl` - fully qualified uri string used as the base url. Most useful with `request.defaults`, for example when you want to do many requests to the same domain. If `baseUrl` is `https://example.com/api/`, then requesting `/end/point?test=true` will fetch `https://example.com/api/end/point?test=true`. When `baseUrl` is given, `uri` must also be a string. +- `method` - http method (default: `"GET"`) +- `headers` - http headers (default: `{}`) + +--- + +- `qs` - object containing querystring values to be appended to the `uri` +- `qsParseOptions` - object containing options to pass to the [qs.parse](https://github.com/hapijs/qs#parsing-objects) method. Alternatively pass options to the [querystring.parse](https://nodejs.org/docs/v0.12.0/api/querystring.html#querystring_querystring_parse_str_sep_eq_options) method using this format `{sep:';', eq:':', options:{}}` +- `qsStringifyOptions` - object containing options to pass to the [qs.stringify](https://github.com/hapijs/qs#stringifying) method. Alternatively pass options to the [querystring.stringify](https://nodejs.org/docs/v0.12.0/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options) method using this format `{sep:';', eq:':', options:{}}`. For example, to change the way arrays are converted to query strings using the `qs` module pass the `arrayFormat` option with one of `indices|brackets|repeat` +- `useQuerystring` - if true, use `querystring` to stringify and parse + querystrings, otherwise use `qs` (default: `false`). Set this option to + `true` if you need arrays to be serialized as `foo=bar&foo=baz` instead of the + default `foo[0]=bar&foo[1]=baz`. + +--- + +- `body` - entity body for PATCH, POST and PUT requests. Must be a `Buffer`, `String` or `ReadStream`. If `json` is `true`, then `body` must be a JSON-serializable object. +- `form` - when passed an object or a querystring, this sets `body` to a querystring representation of value, and adds `Content-type: application/x-www-form-urlencoded` header. When passed no options, a `FormData` instance is returned (and is piped to request). See "Forms" section above. +- `formData` - data to pass for a `multipart/form-data` request. See + [Forms](#forms) section above. +- `multipart` - array of objects which contain their own headers and `body` + attributes. Sends a `multipart/related` request. See [Forms](#forms) section + above. + - Alternatively you can pass in an object `{chunked: false, data: []}` where + `chunked` is used to specify whether the request is sent in + [chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding) + In non-chunked requests, data items with body streams are not allowed. +- `preambleCRLF` - append a newline/CRLF before the boundary of your `multipart/form-data` request. +- `postambleCRLF` - append a newline/CRLF at the end of the boundary of your `multipart/form-data` request. +- `json` - sets `body` to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as JSON. +- `jsonReviver` - a [reviver function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) that will be passed to `JSON.parse()` when parsing a JSON response body. +- `jsonReplacer` - a [replacer function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) that will be passed to `JSON.stringify()` when stringifying a JSON request body. + +--- + +- `auth` - a hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). See documentation above. +- `hawk` - options for [Hawk signing](https://github.com/hueniverse/hawk). The `credentials` key must contain the necessary signing info, [see hawk docs for details](https://github.com/hueniverse/hawk#usage-example). +- `aws` - `object` containing AWS signing information. Should have the properties `key`, `secret`, and optionally `session` (note that this only works for services that require session as part of the canonical string). Also requires the property `bucket`, unless you’re specifying your `bucket` as part of the path, or the request doesn’t use a bucket (i.e. GET Services). If you want to use AWS sign version 4 use the parameter `sign_version` with value `4` otherwise the default is version 2. If you are using SigV4, you can also include a `service` property that specifies the service name. **Note:** you need to `npm install aws4` first. +- `httpSignature` - options for the [HTTP Signature Scheme](https://github.com/joyent/node-http-signature/blob/master/http_signing.md) using [Joyent's library](https://github.com/joyent/node-http-signature). The `keyId` and `key` properties must be specified. See the docs for other options. + +--- + +- `followRedirect` - follow HTTP 3xx responses as redirects (default: `true`). This property can also be implemented as function which gets `response` object as the first argument. + - *(synchronous usage)* It should return `true` if redirects should continue or `false` otherwise. If it returns a url string, the destination of the redirect will be overridden. + - *(async callback usage)* If the function has two arguments, it will be treated as an asynchronous function and will be passed a callback as the second argument. Invoke the callback with an error (`null` if no error) and the boolean/url result as the second. + - *(async promise usage)* Return a promise that resolves to the boolean/url result. +- `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects (default: `false`) +- `followOriginalHttpMethod` - by default we redirect to HTTP method GET. you can enable this property to redirect to the original HTTP method (default: `false`) +- `maxRedirects` - the maximum number of redirects to follow (default: `10`) +- `removeRefererHeader` - removes the referer header when a redirect happens (default: `false`). **Note:** if true, referer header set in the initial request is preserved during redirect chain. +- `allowInsecureRedirect` - allows cross-protocol redirects (HTTP to HTTPS and vice versa). **Warning:** may lead to bypassing anti SSRF filters (default: `false`) + +--- + +- `encoding` - encoding to be used on `setEncoding` of response data. If `null`, the `body` is returned as a `Buffer`. Anything else **(including the default value of `undefined`)** will be passed as the [encoding](http://nodejs.org/api/buffer.html#buffer_buffer) parameter to `toString()` (meaning this is effectively `utf8` by default). (**Note:** if you expect binary data, you should set `encoding: null`.) +- `gzip` - if `true`, add an `Accept-Encoding` header to request compressed content encodings from the server (if not already present) and decode supported content encodings in the response. **Note:** Automatic decoding of the response content is performed on the body data returned through `request` (both through the `request` stream and passed to the callback function) but is not performed on the `response` stream (available from the `response` event) which is the unmodified `http.IncomingMessage` object which may contain compressed data. See example below. +- `jar` - if `true`, remember cookies for future use (or define your custom cookie jar; see examples section) + +--- + +- `agent` - `http(s).Agent` instance to use +- `agentClass` - alternatively specify your agent's class name +- `agentOptions` - and pass its options. **Note:** for HTTPS see [tls API doc for TLS/SSL options](http://nodejs.org/api/tls.html#tls_tls_connect_options_callback) and the [documentation above](#using-optionsagentoptions). +- `forever` - set to `true` to use the [forever-agent](https://github.com/request/forever-agent) **Note:** Defaults to `http(s).Agent({keepAlive:true})` in node 0.12+ +- `pool` - an object describing which agents to use for the request. If this option is omitted the request will use the global agent (as long as your options allow for it). Otherwise, request will search the pool for your custom agent. If no custom agent is found, a new agent will be created and added to the pool. **Note:** `pool` is used only when the `agent` option is not specified. + - A `maxSockets` property can also be provided on the `pool` object to set the max number of sockets for all agents created (ex: `pool: {maxSockets: Infinity}`). + - Note that if you are sending multiple requests in a loop and creating + multiple new `pool` objects, `maxSockets` will not work as intended. To + work around this, either use [`request.defaults`](#requestdefaultsoptions) + with your pool options or create the pool object with the `maxSockets` + property outside of the loop. +- `timeout` - integer containing number of milliseconds, controls two timeouts. + - **Read timeout**: Time to wait for a server to send response headers (and start the response body) before aborting the request. + - **Connection timeout**: Sets the socket to timeout after `timeout` milliseconds of inactivity. Note that increasing the timeout beyond the OS-wide TCP connection timeout will not have any effect ([the default in Linux can be anywhere from 20-120 seconds][linux-timeout]) + +[linux-timeout]: http://www.sekuda.com/overriding_the_default_linux_kernel_20_second_tcp_socket_connect_timeout + +--- + +- `localAddress` - local interface to bind for network connections. +- `proxy` - an HTTP proxy to be used. Supports proxy Auth with Basic Auth, identical to support for the `url` parameter (by embedding the auth info in the `uri`) +- `strictSSL` - if `true`, requires SSL certificates be valid. **Note:** to use your own certificate authority, you need to specify an agent that was created with that CA as an option. +- `tunnel` - controls the behavior of + [HTTP `CONNECT` tunneling](https://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_tunneling) + as follows: + - `undefined` (default) - `true` if the destination is `https`, `false` otherwise + - `true` - always tunnel to the destination by making a `CONNECT` request to + the proxy + - `false` - request the destination as a `GET` request. +- `proxyHeaderWhiteList` - a whitelist of headers to send to a + tunneling proxy. +- `proxyHeaderExclusiveList` - a whitelist of headers to send + exclusively to a tunneling proxy and not to destination. + +--- + +- `time` - if `true`, the request-response cycle (including all redirects) is timed at millisecond resolution. When set, the following properties are added to the response object: + - `elapsedTime` Duration of the entire request/response in milliseconds (*deprecated*). + - `responseStartTime` Timestamp when the response began (in Unix Epoch milliseconds) (*deprecated*). + - `timingStart` Timestamp of the start of the request (in Unix Epoch milliseconds). + - `timings` Contains event timestamps in millisecond resolution relative to `timingStart`. If there were redirects, the properties reflect the timings of the final request in the redirect chain: + - `socket` Relative timestamp when the [`http`](https://nodejs.org/api/http.html#http_event_socket) module's `socket` event fires. This happens when the socket is assigned to the request. + - `lookup` Relative timestamp when the [`net`](https://nodejs.org/api/net.html#net_event_lookup) module's `lookup` event fires. This happens when the DNS has been resolved. + - `connect`: Relative timestamp when the [`net`](https://nodejs.org/api/net.html#net_event_connect) module's `connect` event fires. This happens when the server acknowledges the TCP connection. + - `response`: Relative timestamp when the [`http`](https://nodejs.org/api/http.html#http_event_response) module's `response` event fires. This happens when the first bytes are received from the server. + - `end`: Relative timestamp when the last bytes of the response are received. + - `timingPhases` Contains the durations of each request phase. If there were redirects, the properties reflect the timings of the final request in the redirect chain: + - `wait`: Duration of socket initialization (`timings.socket`) + - `dns`: Duration of DNS lookup (`timings.lookup` - `timings.socket`) + - `tcp`: Duration of TCP connection (`timings.connect` - `timings.socket`) + - `firstByte`: Duration of HTTP server response (`timings.response` - `timings.connect`) + - `download`: Duration of HTTP download (`timings.end` - `timings.response`) + - `total`: Duration entire HTTP round-trip (`timings.end`) + +- `har` - a [HAR 1.2 Request Object](http://www.softwareishard.com/blog/har-12-spec/#request), will be processed from HAR format into options overwriting matching values *(see the [HAR 1.2 section](#support-for-har-12) for details)* +- `callback` - alternatively pass the request's callback in the options object + +The callback argument gets 3 arguments: + +1. An `error` when applicable (usually from [`http.ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest) object) +2. An [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) object (Response object) +3. The third is the `response` body (`String` or `Buffer`, or JSON object if the `json` option is supplied) + +[back to top](#table-of-contents) + + +--- + +## Convenience methods + +There are also shorthand methods for different HTTP METHODs and some other conveniences. + + +### request.defaults(options) + +This method **returns a wrapper** around the normal request API that defaults +to whatever options you pass to it. + +**Note:** `request.defaults()` **does not** modify the global request API; +instead, it **returns a wrapper** that has your default settings applied to it. + +**Note:** You can call `.defaults()` on the wrapper that is returned from +`request.defaults` to add/override defaults that were previously defaulted. + +For example: +```js +//requests using baseRequest() will set the 'x-token' header +const baseRequest = request.defaults({ + headers: {'x-token': 'my-token'} +}) + +//requests using specialRequest() will include the 'x-token' header set in +//baseRequest and will also include the 'special' header +const specialRequest = baseRequest.defaults({ + headers: {special: 'special value'} +}) +``` + +### request.METHOD() + +These HTTP method convenience functions act just like `request()` but with a default method already set for you: + +- *request.get()*: Defaults to `method: "GET"`. +- *request.post()*: Defaults to `method: "POST"`. +- *request.put()*: Defaults to `method: "PUT"`. +- *request.patch()*: Defaults to `method: "PATCH"`. +- *request.del() / request.delete()*: Defaults to `method: "DELETE"`. +- *request.head()*: Defaults to `method: "HEAD"`. +- *request.options()*: Defaults to `method: "OPTIONS"`. + +### request.cookie() + +Function that creates a new cookie. + +```js +request.cookie('key1=value1') +``` +### request.jar() + +Function that creates a new cookie jar. + +```js +request.jar() +``` + +### response.caseless.get('header-name') + +Function that returns the specified response header field using a [case-insensitive match](https://tools.ietf.org/html/rfc7230#section-3.2) + +```js +request('http://www.google.com', function (error, response, body) { + // print the Content-Type header even if the server returned it as 'content-type' (lowercase) + console.log('Content-Type is:', response.caseless.get('Content-Type')); +}); +``` + +[back to top](#table-of-contents) + + +--- + + +## Debugging + +There are at least three ways to debug the operation of `request`: + +1. Launch the node process like `NODE_DEBUG=request node script.js` + (`lib,request,otherlib` works too). + +2. Set `require('request').debug = true` at any time (this does the same thing + as #1). + +3. Use the [request-debug module](https://github.com/cypress-io/request-debug) to + view request and response headers and bodies. + +[back to top](#table-of-contents) + + +--- + +## Timeouts + +Most requests to external servers should have a timeout attached, in case the +server is not responding in a timely manner. Without a timeout, your code may +have a socket open/consume resources for minutes or more. + +There are two main types of timeouts: **connection timeouts** and **read +timeouts**. A connect timeout occurs if the timeout is hit while your client is +attempting to establish a connection to a remote machine (corresponding to the +[connect() call][connect] on the socket). A read timeout occurs any time the +server is too slow to send back a part of the response. + +These two situations have widely different implications for what went wrong +with the request, so it's useful to be able to distinguish them. You can detect +timeout errors by checking `err.code` for an 'ETIMEDOUT' value. Further, you +can detect whether the timeout was a connection timeout by checking if the +`err.connect` property is set to `true`. + +```js +request.get('http://10.255.255.1', {timeout: 1500}, function(err) { + console.log(err.code === 'ETIMEDOUT'); + // Set to `true` if the timeout was a connection timeout, `false` or + // `undefined` otherwise. + console.log(err.connect === true); + process.exit(0); +}); +``` + +[connect]: http://linux.die.net/man/2/connect + +## Examples: + +```js + const request = require('request') + , rand = Math.floor(Math.random()*100000000).toString() + ; + request( + { method: 'PUT' + , uri: 'http://mikeal.iriscouch.com/testjs/' + rand + , multipart: + [ { 'content-type': 'application/json' + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + } + , { body: 'I am an attachment' } + ] + } + , function (error, response, body) { + if(response.statusCode == 201){ + console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + } else { + console.log('error: '+ response.statusCode) + console.log(body) + } + } + ) +``` + +For backwards-compatibility, response compression is not supported by default. +To accept gzip-compressed responses, set the `gzip` option to `true`. Note +that the body data passed through `request` is automatically decompressed +while the response object is unmodified and will contain compressed data if +the server sent a compressed response. + +```js + const request = require('request') + request( + { method: 'GET' + , uri: 'http://www.google.com' + , gzip: true + } + , function (error, response, body) { + // body is the decompressed response body + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) + console.log('the decoded data is: ' + body) + } + ) + .on('data', function(data) { + // decompressed data as it is received + console.log('decoded chunk: ' + data) + }) + .on('response', function(response) { + // unmodified http.IncomingMessage object + response.on('data', function(data) { + // compressed data as it is received + console.log('received ' + data.length + ' bytes of compressed data') + }) + }) +``` + +Cookies are disabled by default (else, they would be used in subsequent requests). To enable cookies, set `jar` to `true` (either in `defaults` or `options`). + +```js +const request = request.defaults({jar: true}) +request('http://www.google.com', function () { + request('http://images.google.com') +}) +``` + +To use a custom cookie jar (instead of `request`’s global cookie jar), set `jar` to an instance of `request.jar()` (either in `defaults` or `options`) + +```js +const j = request.jar() +const request = request.defaults({jar:j}) +request('http://www.google.com', function () { + request('http://images.google.com') +}) +``` + +OR + +```js +const j = request.jar(); +const cookie = request.cookie('key1=value1'); +const url = 'http://www.google.com'; +j.setCookie(cookie, url); +request({url: url, jar: j}, function () { + request('http://images.google.com') +}) +``` + +To use a custom cookie store (such as a +[`FileCookieStore`](https://github.com/mitsuru/tough-cookie-filestore) +which supports saving to and restoring from JSON files), pass it as a parameter +to `request.jar()`: + +```js +const FileCookieStore = require('tough-cookie-filestore'); +// NOTE - currently the 'cookies.json' file must already exist! +const j = request.jar(new FileCookieStore('cookies.json')); +request = request.defaults({ jar : j }) +request('http://www.google.com', function() { + request('http://images.google.com') +}) +``` + +The cookie store must be a +[`tough-cookie`](https://github.com/SalesforceEng/tough-cookie) +store and it must support synchronous operations; see the +[`CookieStore` API docs](https://github.com/SalesforceEng/tough-cookie#api) +for details. + +To inspect your cookie jar after a request: + +```js +const j = request.jar() +request({url: 'http://www.google.com', jar: j}, function () { + const cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." + const cookies = j.getCookies(url); + // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] +}) +``` + +[back to top](#table-of-contents) diff --git a/node_modules/@cypress/request/index.js b/node_modules/@cypress/request/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d50f9917b5f014f7be651fd88405b975f17a290b --- /dev/null +++ b/node_modules/@cypress/request/index.js @@ -0,0 +1,155 @@ +// Copyright 2010-2012 Mikeal Rogers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict' + +var extend = require('extend') +var cookies = require('./lib/cookies') +var helpers = require('./lib/helpers') + +var paramsHaveRequestBody = helpers.paramsHaveRequestBody + +// organize params for patch, post, put, head, del +function initParams (uri, options, callback) { + if (typeof options === 'function') { + callback = options + } + + var params = {} + if (options !== null && typeof options === 'object') { + extend(params, options, {uri: uri}) + } else if (typeof uri === 'string') { + extend(params, {uri: uri}) + } else { + extend(params, uri) + } + + params.callback = callback || params.callback + return params +} + +function request (uri, options, callback) { + if (typeof uri === 'undefined') { + throw new Error('undefined is not a valid uri or options object.') + } + + var params = initParams(uri, options, callback) + + if (params.method === 'HEAD' && paramsHaveRequestBody(params)) { + throw new Error('HTTP HEAD requests MUST NOT include a request body.') + } + + return new request.Request(params) +} + +function verbFunc (verb) { + var method = verb.toUpperCase() + return function (uri, options, callback) { + var params = initParams(uri, options, callback) + params.method = method + return request(params, params.callback) + } +} + +// define like this to please codeintel/intellisense IDEs +request.get = verbFunc('get') +request.head = verbFunc('head') +request.options = verbFunc('options') +request.post = verbFunc('post') +request.put = verbFunc('put') +request.patch = verbFunc('patch') +request.del = verbFunc('delete') +request['delete'] = verbFunc('delete') + +request.jar = function (store) { + return cookies.jar(store) +} + +request.cookie = function (str) { + return cookies.parse(str) +} + +function wrapRequestMethod (method, options, requester, verb) { + return function (uri, opts, callback) { + var params = initParams(uri, opts, callback) + + var target = {} + extend(true, target, options, params) + + target.pool = params.pool || options.pool + + if (verb) { + target.method = verb.toUpperCase() + } + + if (typeof requester === 'function') { + method = requester + } + + return method(target, target.callback) + } +} + +request.defaults = function (options, requester) { + var self = this + + options = options || {} + + if (typeof options === 'function') { + requester = options + options = {} + } + + var defaults = wrapRequestMethod(self, options, requester) + + var verbs = ['get', 'head', 'post', 'put', 'patch', 'del', 'delete'] + verbs.forEach(function (verb) { + defaults[verb] = wrapRequestMethod(self[verb], options, requester, verb) + }) + + defaults.cookie = wrapRequestMethod(self.cookie, options, requester) + defaults.jar = self.jar + defaults.defaults = self.defaults + return defaults +} + +request.forever = function (agentOptions, optionsArg) { + var options = {} + if (optionsArg) { + extend(options, optionsArg) + } + if (agentOptions) { + options.agentOptions = agentOptions + } + + options.forever = true + return request.defaults(options) +} + +// Exports + +module.exports = request +request.Request = require('./request') +request.initParams = initParams + +// Backwards compatibility for request.debug +Object.defineProperty(request, 'debug', { + enumerable: true, + get: function () { + return request.Request.debug + }, + set: function (debug) { + request.Request.debug = debug + } +}) diff --git a/node_modules/@cypress/request/lib/auth.js b/node_modules/@cypress/request/lib/auth.js new file mode 100644 index 0000000000000000000000000000000000000000..6f094d683baa75243d1c48d1e29973087781879a --- /dev/null +++ b/node_modules/@cypress/request/lib/auth.js @@ -0,0 +1,167 @@ +'use strict' + +var caseless = require('caseless') +var { v4: uuid } = require('uuid') +var helpers = require('./helpers') + +var md5 = helpers.md5 +var toBase64 = helpers.toBase64 + +function Auth (request) { + // define all public properties here + this.request = request + this.hasAuth = false + this.sentAuth = false + this.bearerToken = null + this.user = null + this.pass = null +} + +Auth.prototype.basic = function (user, pass, sendImmediately) { + var self = this + if (typeof user !== 'string' || (pass !== undefined && typeof pass !== 'string')) { + self.request.emit('error', new Error('auth() received invalid user or password')) + } + self.user = user + self.pass = pass + self.hasAuth = true + var header = user + ':' + (pass || '') + if (sendImmediately || typeof sendImmediately === 'undefined') { + var authHeader = 'Basic ' + toBase64(header) + self.sentAuth = true + return authHeader + } +} + +Auth.prototype.bearer = function (bearer, sendImmediately) { + var self = this + self.bearerToken = bearer + self.hasAuth = true + if (sendImmediately || typeof sendImmediately === 'undefined') { + if (typeof bearer === 'function') { + bearer = bearer() + } + var authHeader = 'Bearer ' + (bearer || '') + self.sentAuth = true + return authHeader + } +} + +Auth.prototype.digest = function (method, path, authHeader) { + // TODO: More complete implementation of RFC 2617. + // - handle challenge.domain + // - support qop="auth-int" only + // - handle Authentication-Info (not necessarily?) + // - check challenge.stale (not necessarily?) + // - increase nc (not necessarily?) + // For reference: + // http://tools.ietf.org/html/rfc2617#section-3 + // https://github.com/bagder/curl/blob/master/lib/http_digest.c + + var self = this + + var challenge = {} + var re = /([a-z0-9_-]+)=(?:"([^"]+)"|([a-z0-9_-]+))/gi + while (true) { + var match = re.exec(authHeader) + if (!match) { + break + } + challenge[match[1]] = match[2] || match[3] + } + + /** + * RFC 2617: handle both MD5 and MD5-sess algorithms. + * + * If the algorithm directive's value is "MD5" or unspecified, then HA1 is + * HA1=MD5(username:realm:password) + * If the algorithm directive's value is "MD5-sess", then HA1 is + * HA1=MD5(MD5(username:realm:password):nonce:cnonce) + */ + var ha1Compute = function (algorithm, user, realm, pass, nonce, cnonce) { + var ha1 = md5(user + ':' + realm + ':' + pass) + if (algorithm && algorithm.toLowerCase() === 'md5-sess') { + return md5(ha1 + ':' + nonce + ':' + cnonce) + } else { + return ha1 + } + } + + var qop = /(^|,)\s*auth\s*($|,)/.test(challenge.qop) && 'auth' + var nc = qop && '00000001' + var cnonce = qop && uuid().replace(/-/g, '') + var ha1 = ha1Compute(challenge.algorithm, self.user, challenge.realm, self.pass, challenge.nonce, cnonce) + var ha2 = md5(method + ':' + path) + var digestResponse = qop + ? md5(ha1 + ':' + challenge.nonce + ':' + nc + ':' + cnonce + ':' + qop + ':' + ha2) + : md5(ha1 + ':' + challenge.nonce + ':' + ha2) + var authValues = { + username: self.user, + realm: challenge.realm, + nonce: challenge.nonce, + uri: path, + qop: qop, + response: digestResponse, + nc: nc, + cnonce: cnonce, + algorithm: challenge.algorithm, + opaque: challenge.opaque + } + + authHeader = [] + for (var k in authValues) { + if (authValues[k]) { + if (k === 'qop' || k === 'nc' || k === 'algorithm') { + authHeader.push(k + '=' + authValues[k]) + } else { + authHeader.push(k + '="' + authValues[k] + '"') + } + } + } + authHeader = 'Digest ' + authHeader.join(', ') + self.sentAuth = true + return authHeader +} + +Auth.prototype.onRequest = function (user, pass, sendImmediately, bearer) { + var self = this + var request = self.request + + var authHeader + if (bearer === undefined && user === undefined) { + self.request.emit('error', new Error('no auth mechanism defined')) + } else if (bearer !== undefined) { + authHeader = self.bearer(bearer, sendImmediately) + } else { + authHeader = self.basic(user, pass, sendImmediately) + } + if (authHeader) { + request.setHeader('authorization', authHeader) + } +} + +Auth.prototype.onResponse = function (response) { + var self = this + var request = self.request + + if (!self.hasAuth || self.sentAuth) { return null } + + var c = caseless(response.headers) + + var authHeader = c.get('www-authenticate') + var authVerb = authHeader && authHeader.split(' ')[0].toLowerCase() + request.debug('reauth', authVerb) + + switch (authVerb) { + case 'basic': + return self.basic(self.user, self.pass, true) + + case 'bearer': + return self.bearer(self.bearerToken, true) + + case 'digest': + return self.digest(request.method, request.path, authHeader) + } +} + +exports.Auth = Auth diff --git a/node_modules/@cypress/request/lib/cookies.js b/node_modules/@cypress/request/lib/cookies.js new file mode 100644 index 0000000000000000000000000000000000000000..bd5d46bead94b1e14e5fb90d7ce44311a7b07603 --- /dev/null +++ b/node_modules/@cypress/request/lib/cookies.js @@ -0,0 +1,38 @@ +'use strict' + +var tough = require('tough-cookie') + +var Cookie = tough.Cookie +var CookieJar = tough.CookieJar + +exports.parse = function (str) { + if (str && str.uri) { + str = str.uri + } + if (typeof str !== 'string') { + throw new Error('The cookie function only accepts STRING as param') + } + return Cookie.parse(str, {loose: true}) +} + +// Adapt the sometimes-Async api of tough.CookieJar to our requirements +function RequestJar (store) { + var self = this + self._jar = new CookieJar(store, {looseMode: true}) +} +RequestJar.prototype.setCookie = function (cookieOrStr, uri, options) { + var self = this + return self._jar.setCookieSync(cookieOrStr, uri, options || {}) +} +RequestJar.prototype.getCookieString = function (uri) { + var self = this + return self._jar.getCookieStringSync(uri) +} +RequestJar.prototype.getCookies = function (uri) { + var self = this + return self._jar.getCookiesSync(uri) +} + +exports.jar = function (store) { + return new RequestJar(store) +} diff --git a/node_modules/@cypress/request/lib/getProxyFromURI.js b/node_modules/@cypress/request/lib/getProxyFromURI.js new file mode 100644 index 0000000000000000000000000000000000000000..0b9b18e5acfe1364dcd55189ecdfb987e03866ab --- /dev/null +++ b/node_modules/@cypress/request/lib/getProxyFromURI.js @@ -0,0 +1,79 @@ +'use strict' + +function formatHostname (hostname) { + // canonicalize the hostname, so that 'oogle.com' won't match 'google.com' + return hostname.replace(/^\.*/, '.').toLowerCase() +} + +function parseNoProxyZone (zone) { + zone = zone.trim().toLowerCase() + + var zoneParts = zone.split(':', 2) + var zoneHost = formatHostname(zoneParts[0]) + var zonePort = zoneParts[1] + var hasPort = zone.indexOf(':') > -1 + + return {hostname: zoneHost, port: zonePort, hasPort: hasPort} +} + +function uriInNoProxy (uri, noProxy) { + var port = uri.port || (uri.protocol === 'https:' ? '443' : '80') + var hostname = formatHostname(uri.hostname) + var noProxyList = noProxy.split(',') + + // iterate through the noProxyList until it finds a match. + return noProxyList.map(parseNoProxyZone).some(function (noProxyZone) { + var isMatchedAt = hostname.indexOf(noProxyZone.hostname) + var hostnameMatched = ( + isMatchedAt > -1 && + (isMatchedAt === hostname.length - noProxyZone.hostname.length) + ) + + if (noProxyZone.hasPort) { + return (port === noProxyZone.port) && hostnameMatched + } + + return hostnameMatched + }) +} + +function getProxyFromURI (uri) { + // Decide the proper request proxy to use based on the request URI object and the + // environmental variables (NO_PROXY, HTTP_PROXY, etc.) + // respect NO_PROXY environment variables (see: https://lynx.invisible-island.net/lynx2.8.7/breakout/lynx_help/keystrokes/environments.html) + + var noProxy = process.env.NO_PROXY || process.env.no_proxy || '' + + // if the noProxy is a wildcard then return null + + if (noProxy === '*') { + return null + } + + // if the noProxy is not empty and the uri is found return null + + if (noProxy !== '' && uriInNoProxy(uri, noProxy)) { + return null + } + + // Check for HTTP or HTTPS Proxy in environment Else default to null + + if (uri.protocol === 'http:') { + return process.env.HTTP_PROXY || + process.env.http_proxy || null + } + + if (uri.protocol === 'https:') { + return process.env.HTTPS_PROXY || + process.env.https_proxy || + process.env.HTTP_PROXY || + process.env.http_proxy || null + } + + // if none of that works, return null + // (What uri protocol are you using then?) + + return null +} + +module.exports = getProxyFromURI diff --git a/node_modules/@cypress/request/lib/har.js b/node_modules/@cypress/request/lib/har.js new file mode 100644 index 0000000000000000000000000000000000000000..03f660dc7c0a95b857f4ae739f466518d9c68dc5 --- /dev/null +++ b/node_modules/@cypress/request/lib/har.js @@ -0,0 +1,200 @@ +'use strict' + +var fs = require('fs') +var qs = require('querystring') +var extend = require('extend') + +function Har (request) { + this.request = request +} + +Har.prototype.reducer = function (obj, pair) { + // new property ? + if (obj[pair.name] === undefined) { + obj[pair.name] = pair.value + return obj + } + + // existing? convert to array + var arr = [ + obj[pair.name], + pair.value + ] + + obj[pair.name] = arr + + return obj +} + +Har.prototype.prep = function (data) { + // construct utility properties + data.queryObj = {} + data.headersObj = {} + data.postData.jsonObj = false + data.postData.paramsObj = false + + // construct query objects + if (data.queryString && data.queryString.length) { + data.queryObj = data.queryString.reduce(this.reducer, {}) + } + + // construct headers objects + if (data.headers && data.headers.length) { + // loweCase header keys + data.headersObj = data.headers.reduceRight(function (headers, header) { + headers[header.name] = header.value + return headers + }, {}) + } + + // construct Cookie header + if (data.cookies && data.cookies.length) { + var cookies = data.cookies.map(function (cookie) { + return cookie.name + '=' + cookie.value + }) + + if (cookies.length) { + data.headersObj.cookie = cookies.join('; ') + } + } + + // prep body + function some (arr) { + return arr.some(function (type) { + return data.postData.mimeType.indexOf(type) === 0 + }) + } + + if (some([ + 'multipart/mixed', + 'multipart/related', + 'multipart/form-data', + 'multipart/alternative'])) { + // reset values + data.postData.mimeType = 'multipart/form-data' + } else if (some([ + 'application/x-www-form-urlencoded'])) { + if (!data.postData.params) { + data.postData.text = '' + } else { + data.postData.paramsObj = data.postData.params.reduce(this.reducer, {}) + + // always overwrite + data.postData.text = qs.stringify(data.postData.paramsObj) + } + } else if (some([ + 'text/json', + 'text/x-json', + 'application/json', + 'application/x-json'])) { + data.postData.mimeType = 'application/json' + + if (data.postData.text) { + try { + data.postData.jsonObj = JSON.parse(data.postData.text) + } catch (e) { + this.request.debug(e) + + // force back to text/plain + data.postData.mimeType = 'text/plain' + } + } + } + + return data +} + +Har.prototype.options = function (options) { + // skip if no har property defined + if (!options.har) { + return options + } + + var har = {} + extend(har, options.har) + + // only process the first entry + if (har.log && har.log.entries) { + har = har.log.entries[0] + } + + // add optional properties to make validation successful + har.url = har.url || options.url || options.uri || options.baseUrl || '/' + har.httpVersion = har.httpVersion || 'HTTP/1.1' + har.queryString = har.queryString || [] + har.headers = har.headers || [] + har.cookies = har.cookies || [] + har.postData = har.postData || {} + har.postData.mimeType = har.postData.mimeType || 'application/octet-stream' + + har.bodySize = 0 + har.headersSize = 0 + har.postData.size = 0 + + // clean up and get some utility properties + var req = this.prep(har) + + // construct new options + if (req.url) { + options.url = req.url + } + + if (req.method) { + options.method = req.method + } + + if (Object.keys(req.queryObj).length) { + options.qs = req.queryObj + } + + if (Object.keys(req.headersObj).length) { + options.headers = req.headersObj + } + + function test (type) { + return req.postData.mimeType.indexOf(type) === 0 + } + if (test('application/x-www-form-urlencoded')) { + options.form = req.postData.paramsObj + } else if (test('application/json')) { + if (req.postData.jsonObj) { + options.body = req.postData.jsonObj + options.json = true + } + } else if (test('multipart/form-data')) { + options.formData = {} + + req.postData.params.forEach(function (param) { + var attachment = {} + + if (!param.fileName && !param.contentType) { + options.formData[param.name] = param.value + return + } + + // attempt to read from disk! + if (param.fileName && !param.value) { + attachment.value = fs.createReadStream(param.fileName) + } else if (param.value) { + attachment.value = param.value + } + + if (param.fileName) { + attachment.options = { + filename: param.fileName, + contentType: param.contentType ? param.contentType : null + } + } + + options.formData[param.name] = attachment + }) + } else { + if (req.postData.text) { + options.body = req.postData.text + } + } + + return options +} + +exports.Har = Har diff --git a/node_modules/@cypress/request/lib/hawk.js b/node_modules/@cypress/request/lib/hawk.js new file mode 100644 index 0000000000000000000000000000000000000000..de48a98519c77a73605ae4162c1496121761ba85 --- /dev/null +++ b/node_modules/@cypress/request/lib/hawk.js @@ -0,0 +1,89 @@ +'use strict' + +var crypto = require('crypto') + +function randomString (size) { + var bits = (size + 1) * 6 + var buffer = crypto.randomBytes(Math.ceil(bits / 8)) + var string = buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '') + return string.slice(0, size) +} + +function calculatePayloadHash (payload, algorithm, contentType) { + var hash = crypto.createHash(algorithm) + hash.update('hawk.1.payload\n') + hash.update((contentType ? contentType.split(';')[0].trim().toLowerCase() : '') + '\n') + hash.update(payload || '') + hash.update('\n') + return hash.digest('base64') +} + +exports.calculateMac = function (credentials, opts) { + var normalized = 'hawk.1.header\n' + + opts.ts + '\n' + + opts.nonce + '\n' + + (opts.method || '').toUpperCase() + '\n' + + opts.resource + '\n' + + opts.host.toLowerCase() + '\n' + + opts.port + '\n' + + (opts.hash || '') + '\n' + + if (opts.ext) { + normalized = normalized + opts.ext.replace('\\', '\\\\').replace('\n', '\\n') + } + + normalized = normalized + '\n' + + if (opts.app) { + normalized = normalized + opts.app + '\n' + (opts.dlg || '') + '\n' + } + + var hmac = crypto.createHmac(credentials.algorithm, credentials.key).update(normalized) + var digest = hmac.digest('base64') + return digest +} + +exports.header = function (uri, method, opts) { + var timestamp = opts.timestamp || Math.floor((Date.now() + (opts.localtimeOffsetMsec || 0)) / 1000) + var credentials = opts.credentials + if (!credentials || !credentials.id || !credentials.key || !credentials.algorithm) { + return '' + } + + if (['sha1', 'sha256'].indexOf(credentials.algorithm) === -1) { + return '' + } + + var artifacts = { + ts: timestamp, + nonce: opts.nonce || randomString(6), + method: method, + resource: uri.pathname + (uri.search || ''), + host: uri.hostname, + port: uri.port || (uri.protocol === 'http:' ? 80 : 443), + hash: opts.hash, + ext: opts.ext, + app: opts.app, + dlg: opts.dlg + } + + if (!artifacts.hash && (opts.payload || opts.payload === '')) { + artifacts.hash = calculatePayloadHash(opts.payload, credentials.algorithm, opts.contentType) + } + + var mac = exports.calculateMac(credentials, artifacts) + + var hasExt = artifacts.ext !== null && artifacts.ext !== undefined && artifacts.ext !== '' + var header = 'Hawk id="' + credentials.id + + '", ts="' + artifacts.ts + + '", nonce="' + artifacts.nonce + + (artifacts.hash ? '", hash="' + artifacts.hash : '') + + (hasExt ? '", ext="' + artifacts.ext.replace(/\\/g, '\\\\').replace(/"/g, '\\"') : '') + + '", mac="' + mac + '"' + + if (artifacts.app) { + header = header + ', app="' + artifacts.app + (artifacts.dlg ? '", dlg="' + artifacts.dlg : '') + '"' + } + + return header +} diff --git a/node_modules/@cypress/request/lib/helpers.js b/node_modules/@cypress/request/lib/helpers.js new file mode 100644 index 0000000000000000000000000000000000000000..8b2a7e6ebf3d1491749353b0aae25b6ce9756dc6 --- /dev/null +++ b/node_modules/@cypress/request/lib/helpers.js @@ -0,0 +1,66 @@ +'use strict' + +var jsonSafeStringify = require('json-stringify-safe') +var crypto = require('crypto') +var Buffer = require('safe-buffer').Buffer + +var defer = typeof setImmediate === 'undefined' + ? process.nextTick + : setImmediate + +function paramsHaveRequestBody (params) { + return ( + params.body || + params.requestBodyStream || + (params.json && typeof params.json !== 'boolean') || + params.multipart + ) +} + +function safeStringify (obj, replacer) { + var ret + try { + ret = JSON.stringify(obj, replacer) + } catch (e) { + ret = jsonSafeStringify(obj, replacer) + } + return ret +} + +function md5 (str) { + return crypto.createHash('md5').update(str).digest('hex') +} + +function isReadStream (rs) { + return rs.readable && rs.path && rs.mode +} + +function toBase64 (str) { + return Buffer.from(str || '', 'utf8').toString('base64') +} + +function copy (obj) { + var o = {} + Object.keys(obj).forEach(function (i) { + o[i] = obj[i] + }) + return o +} + +function version () { + var numbers = process.version.replace('v', '').split('.') + return { + major: parseInt(numbers[0], 10), + minor: parseInt(numbers[1], 10), + patch: parseInt(numbers[2], 10) + } +} + +exports.paramsHaveRequestBody = paramsHaveRequestBody +exports.safeStringify = safeStringify +exports.md5 = md5 +exports.isReadStream = isReadStream +exports.toBase64 = toBase64 +exports.copy = copy +exports.version = version +exports.defer = defer diff --git a/node_modules/@cypress/request/lib/multipart.js b/node_modules/@cypress/request/lib/multipart.js new file mode 100644 index 0000000000000000000000000000000000000000..b6f2dcb619204ab8b7c446637d159d22ca5f10af --- /dev/null +++ b/node_modules/@cypress/request/lib/multipart.js @@ -0,0 +1,112 @@ +'use strict' + +var { v4: uuid } = require('uuid') +var CombinedStream = require('combined-stream') +var isstream = require('isstream') +var Buffer = require('safe-buffer').Buffer + +function Multipart (request) { + this.request = request + this.boundary = uuid() + this.chunked = false + this.body = null +} + +Multipart.prototype.isChunked = function (options) { + var self = this + var chunked = false + var parts = options.data || options + + if (!parts.forEach) { + self.request.emit('error', new Error('Argument error, options.multipart.')) + } + + if (options.chunked !== undefined) { + chunked = options.chunked + } + + if (self.request.getHeader('transfer-encoding') === 'chunked') { + chunked = true + } + + if (!chunked) { + parts.forEach(function (part) { + if (typeof part.body === 'undefined') { + self.request.emit('error', new Error('Body attribute missing in multipart.')) + } + if (isstream(part.body)) { + chunked = true + } + }) + } + + return chunked +} + +Multipart.prototype.setHeaders = function (chunked) { + var self = this + + if (chunked && !self.request.hasHeader('transfer-encoding')) { + self.request.setHeader('transfer-encoding', 'chunked') + } + + var header = self.request.getHeader('content-type') + + if (!header || header.indexOf('multipart') === -1) { + self.request.setHeader('content-type', 'multipart/related; boundary=' + self.boundary) + } else { + if (header.indexOf('boundary') !== -1) { + self.boundary = header.replace(/.*boundary=([^\s;]+).*/, '$1') + } else { + self.request.setHeader('content-type', header + '; boundary=' + self.boundary) + } + } +} + +Multipart.prototype.build = function (parts, chunked) { + var self = this + var body = chunked ? new CombinedStream() : [] + + function add (part) { + if (typeof part === 'number') { + part = part.toString() + } + return chunked ? body.append(part) : body.push(Buffer.from(part)) + } + + if (self.request.preambleCRLF) { + add('\r\n') + } + + parts.forEach(function (part) { + var preamble = '--' + self.boundary + '\r\n' + Object.keys(part).forEach(function (key) { + if (key === 'body') { return } + preamble += key + ': ' + part[key] + '\r\n' + }) + preamble += '\r\n' + add(preamble) + add(part.body) + add('\r\n') + }) + add('--' + self.boundary + '--') + + if (self.request.postambleCRLF) { + add('\r\n') + } + + return body +} + +Multipart.prototype.onRequest = function (options) { + var self = this + + var chunked = self.isChunked(options) + var parts = options.data || options + + self.setHeaders(chunked) + self.chunked = chunked + self.body = self.build(parts, chunked) +} + +exports.Multipart = Multipart diff --git a/node_modules/@cypress/request/lib/querystring.js b/node_modules/@cypress/request/lib/querystring.js new file mode 100644 index 0000000000000000000000000000000000000000..4a32cd1491a8cb87e1505b0b03b24d077cae12dd --- /dev/null +++ b/node_modules/@cypress/request/lib/querystring.js @@ -0,0 +1,50 @@ +'use strict' + +var qs = require('qs') +var querystring = require('querystring') + +function Querystring (request) { + this.request = request + this.lib = null + this.useQuerystring = null + this.parseOptions = null + this.stringifyOptions = null +} + +Querystring.prototype.init = function (options) { + if (this.lib) { return } + + this.useQuerystring = options.useQuerystring + this.lib = (this.useQuerystring ? querystring : qs) + + this.parseOptions = options.qsParseOptions || {} + this.stringifyOptions = options.qsStringifyOptions || {} +} + +Querystring.prototype.stringify = function (obj) { + return (this.useQuerystring) + ? this.rfc3986(this.lib.stringify(obj, + this.stringifyOptions.sep || null, + this.stringifyOptions.eq || null, + this.stringifyOptions)) + : this.lib.stringify(obj, this.stringifyOptions) +} + +Querystring.prototype.parse = function (str) { + return (this.useQuerystring) + ? this.lib.parse(str, + this.parseOptions.sep || null, + this.parseOptions.eq || null, + this.parseOptions) + : this.lib.parse(str, this.parseOptions) +} + +Querystring.prototype.rfc3986 = function (str) { + return str.replace(/[!'()*]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16).toUpperCase() + }) +} + +Querystring.prototype.unescape = querystring.unescape + +exports.Querystring = Querystring diff --git a/node_modules/@cypress/request/lib/redirect.js b/node_modules/@cypress/request/lib/redirect.js new file mode 100644 index 0000000000000000000000000000000000000000..4634a6390ed94ffbaf45be5db6a1c21baa57e146 --- /dev/null +++ b/node_modules/@cypress/request/lib/redirect.js @@ -0,0 +1,179 @@ +'use strict' + +var url = require('url') +var isUrl = /^https?:/ + +function Redirect (request) { + this.request = request + this.followRedirect = true + this.followRedirects = true + this.followAllRedirects = false + this.followOriginalHttpMethod = false + this.allowRedirect = function () { return true } + this.maxRedirects = 10 + this.redirects = [] + this.redirectsFollowed = 0 + this.removeRefererHeader = false + this.allowInsecureRedirect = false +} + +Redirect.prototype.onRequest = function (options) { + var self = this + + if (options.maxRedirects !== undefined) { + self.maxRedirects = options.maxRedirects + } + if (typeof options.followRedirect === 'function') { + self.allowRedirect = options.followRedirect + } + if (options.followRedirect !== undefined) { + self.followRedirects = !!options.followRedirect + } + if (options.followAllRedirects !== undefined) { + self.followAllRedirects = options.followAllRedirects + } + if (self.followRedirects || self.followAllRedirects) { + self.redirects = self.redirects || [] + } + if (options.removeRefererHeader !== undefined) { + self.removeRefererHeader = options.removeRefererHeader + } + if (options.followOriginalHttpMethod !== undefined) { + self.followOriginalHttpMethod = options.followOriginalHttpMethod + } + if (options.allowInsecureRedirect !== undefined) { + self.allowInsecureRedirect = options.allowInsecureRedirect + } +} + +Redirect.prototype.redirectTo = function (response) { + var self = this + var request = self.request + + var redirectTo = null + if (response.statusCode >= 300 && response.statusCode < 400 && response.caseless.has('location')) { + var location = response.caseless.get('location') + request.debug('redirect', location) + + if (self.followAllRedirects) { + redirectTo = location + } else if (self.followRedirects) { + switch (request.method) { + case 'PATCH': + case 'PUT': + case 'POST': + case 'DELETE': + // Do not follow redirects + break + default: + redirectTo = location + break + } + } + } else if (response.statusCode === 401) { + var authHeader = request._auth.onResponse(response) + if (authHeader) { + request.setHeader('authorization', authHeader) + redirectTo = request.uri + } + } + return redirectTo +} + +Redirect.prototype.onResponse = function (response, callback) { + var self = this + var request = self.request + + var redirectTo = self.redirectTo(response) + if (!redirectTo) return callback(null, false) + + function processRedirect (shouldRedirect) { + if (!shouldRedirect) return callback(null, false) + if (typeof shouldRedirect === 'string') { + // overridden redirect url + request.debug('redirect overridden', redirectTo) + redirectTo = shouldRedirect + } + + request.debug('redirect to', redirectTo) + + // ignore any potential response body. it cannot possibly be useful + // to us at this point. + // response.resume should be defined, but check anyway before calling. Workaround for browserify. + if (response.resume) { + response.resume() + } + + if (self.redirectsFollowed >= self.maxRedirects) { + return callback(new Error('Exceeded maxRedirects. Probably stuck in a redirect loop ' + request.uri.href)) + } + self.redirectsFollowed += 1 + + if (!isUrl.test(redirectTo)) { + redirectTo = url.resolve(request.uri.href, redirectTo) + } + + var uriPrev = request.uri + request.uri = url.parse(redirectTo) + + // handle the case where we change protocol from https to http or vice versa + if (request.uri.protocol !== uriPrev.protocol && self.allowInsecureRedirect) { + delete request.agent + } + + self.redirects.push({ statusCode: response.statusCode, redirectUri: redirectTo }) + + if (self.followAllRedirects && request.method !== 'HEAD' && + response.statusCode !== 401 && response.statusCode !== 307) { + request.method = self.followOriginalHttpMethod ? request.method : 'GET' + } + // request.method = 'GET' // Force all redirects to use GET || commented out fixes #215 + delete request.src + delete request.req + delete request._started + if (response.statusCode !== 401 && response.statusCode !== 307) { + // Remove parameters from the previous response, unless this is the second request + // for a server that requires digest authentication. + delete request.body + delete request._form + if (request.headers) { + request.removeHeader('host') + request.removeHeader('content-type') + request.removeHeader('content-length') + if (request.uri.hostname !== request.originalHost.split(':')[0]) { + // Remove authorization if changing hostnames (but not if just + // changing ports or protocols). This matches the behavior of curl: + // https://github.com/bagder/curl/blob/6beb0eee/lib/http.c#L710 + request.removeHeader('authorization') + } + } + } + + if (!self.removeRefererHeader) { + request.setHeader('referer', uriPrev.href) + } + + request.emit('redirect') + request.init() + callback(null, true) + } + + // test allowRedirect arity; if has more than one argument, + // assume it's asynchronous via a callback + if (self.allowRedirect.length > 1) { + return self.allowRedirect.call(request, response, function (err, result) { + if (err) return callback(err) + processRedirect(result) + }) + } + + var allowsRedirect = self.allowRedirect.call(request, response) + if (allowsRedirect && allowsRedirect.then) { + return allowsRedirect.then(processRedirect, callback) + } + + // treat as a regular boolean + processRedirect(allowsRedirect) +} + +exports.Redirect = Redirect diff --git a/node_modules/@cypress/request/lib/tunnel.js b/node_modules/@cypress/request/lib/tunnel.js new file mode 100644 index 0000000000000000000000000000000000000000..4479003f694234f9970f9f75719d599b31f00ab0 --- /dev/null +++ b/node_modules/@cypress/request/lib/tunnel.js @@ -0,0 +1,175 @@ +'use strict' + +var url = require('url') +var tunnel = require('tunnel-agent') + +var defaultProxyHeaderWhiteList = [ + 'accept', + 'accept-charset', + 'accept-encoding', + 'accept-language', + 'accept-ranges', + 'cache-control', + 'content-encoding', + 'content-language', + 'content-location', + 'content-md5', + 'content-range', + 'content-type', + 'connection', + 'date', + 'expect', + 'max-forwards', + 'pragma', + 'referer', + 'te', + 'user-agent', + 'via' +] + +var defaultProxyHeaderExclusiveList = [ + 'proxy-authorization' +] + +function constructProxyHost (uriObject) { + var port = uriObject.port + var protocol = uriObject.protocol + var proxyHost = uriObject.hostname + ':' + + if (port) { + proxyHost += port + } else if (protocol === 'https:') { + proxyHost += '443' + } else { + proxyHost += '80' + } + + return proxyHost +} + +function constructProxyHeaderWhiteList (headers, proxyHeaderWhiteList) { + var whiteList = proxyHeaderWhiteList + .reduce(function (set, header) { + set[header.toLowerCase()] = true + return set + }, {}) + + return Object.keys(headers) + .filter(function (header) { + return whiteList[header.toLowerCase()] + }) + .reduce(function (set, header) { + set[header] = headers[header] + return set + }, {}) +} + +function constructTunnelOptions (request, proxyHeaders) { + var proxy = request.proxy + + var tunnelOptions = { + proxy: { + host: proxy.hostname, + port: +proxy.port, + proxyAuth: proxy.auth, + headers: proxyHeaders + }, + headers: request.headers, + ca: request.ca, + cert: request.cert, + key: request.key, + passphrase: request.passphrase, + pfx: request.pfx, + ciphers: request.ciphers, + rejectUnauthorized: request.rejectUnauthorized, + secureOptions: request.secureOptions, + secureProtocol: request.secureProtocol + } + + return tunnelOptions +} + +function constructTunnelFnName (uri, proxy) { + var uriProtocol = (uri.protocol === 'https:' ? 'https' : 'http') + var proxyProtocol = (proxy.protocol === 'https:' ? 'Https' : 'Http') + return [uriProtocol, proxyProtocol].join('Over') +} + +function getTunnelFn (request) { + var uri = request.uri + var proxy = request.proxy + var tunnelFnName = constructTunnelFnName(uri, proxy) + return tunnel[tunnelFnName] +} + +function Tunnel (request) { + this.request = request + this.proxyHeaderWhiteList = defaultProxyHeaderWhiteList + this.proxyHeaderExclusiveList = [] + if (typeof request.tunnel !== 'undefined') { + this.tunnelOverride = request.tunnel + } +} + +Tunnel.prototype.isEnabled = function () { + var self = this + var request = self.request + // Tunnel HTTPS by default. Allow the user to override this setting. + + // If self.tunnelOverride is set (the user specified a value), use it. + if (typeof self.tunnelOverride !== 'undefined') { + return self.tunnelOverride + } + + // If the destination is HTTPS, tunnel. + if (request.uri.protocol === 'https:') { + return true + } + + // Otherwise, do not use tunnel. + return false +} + +Tunnel.prototype.setup = function (options) { + var self = this + var request = self.request + + options = options || {} + + if (typeof request.proxy === 'string') { + request.proxy = url.parse(request.proxy) + } + + if (!request.proxy || !request.tunnel) { + return false + } + + // Setup Proxy Header Exclusive List and White List + if (options.proxyHeaderWhiteList) { + self.proxyHeaderWhiteList = options.proxyHeaderWhiteList + } + if (options.proxyHeaderExclusiveList) { + self.proxyHeaderExclusiveList = options.proxyHeaderExclusiveList + } + + var proxyHeaderExclusiveList = self.proxyHeaderExclusiveList.concat(defaultProxyHeaderExclusiveList) + var proxyHeaderWhiteList = self.proxyHeaderWhiteList.concat(proxyHeaderExclusiveList) + + // Setup Proxy Headers and Proxy Headers Host + // Only send the Proxy White Listed Header names + var proxyHeaders = constructProxyHeaderWhiteList(request.headers, proxyHeaderWhiteList) + proxyHeaders.host = constructProxyHost(request.uri) + + proxyHeaderExclusiveList.forEach(request.removeHeader, request) + + // Set Agent from Tunnel Data + var tunnelFn = getTunnelFn(request) + var tunnelOptions = constructTunnelOptions(request, proxyHeaders) + request.agent = tunnelFn(tunnelOptions) + + return true +} + +Tunnel.defaultProxyHeaderWhiteList = defaultProxyHeaderWhiteList +Tunnel.defaultProxyHeaderExclusiveList = defaultProxyHeaderExclusiveList +exports.Tunnel = Tunnel diff --git a/node_modules/@cypress/request/package.json b/node_modules/@cypress/request/package.json new file mode 100644 index 0000000000000000000000000000000000000000..eea31fc06152a3616e06692745f46eba3c93805d --- /dev/null +++ b/node_modules/@cypress/request/package.json @@ -0,0 +1,84 @@ +{ + "name": "@cypress/request", + "description": "Cypress's fork of a simplified HTTP request client.", + "keywords": [ + "http", + "simple", + "util", + "utility" + ], + "version": "3.0.1", + "author": "Mikeal Rogers ", + "repository": { + "type": "git", + "url": "https://github.com/cypress-io/request.git" + }, + "bugs": { + "url": "http://github.com/cypress-io/request/issues" + }, + "license": "Apache-2.0", + "engines": { + "node": ">= 6" + }, + "main": "index.js", + "files": [ + "lib/", + "index.js", + "request.js" + ], + "dependencies": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "http-signature": "~1.3.6", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "performance-now": "^2.1.0", + "qs": "6.10.4", + "safe-buffer": "^5.1.2", + "tough-cookie": "^4.1.3", + "tunnel-agent": "^0.6.0", + "uuid": "^8.3.2" + }, + "scripts": { + "test": "npm run lint && npm run test-ci && npm run test-browser", + "test-ci": "tap --no-check-coverage tests/test-*.js", + "test-cov": "nyc --reporter=lcov tape tests/test-*.js", + "test-browser": "echo 'Skipping browser tests.' || node tests/browser/start.js", + "lint": "standard" + }, + "devDependencies": { + "bluebird": "^3.2.1", + "browserify": "^13.0.1", + "browserify-istanbul": "^2.0.0", + "buffer-equal": "^1.0.0", + "codecov": "^3.0.4", + "coveralls": "^3.0.2", + "function-bind": "^1.0.2", + "karma": "^3.0.0", + "karma-browserify": "^5.0.1", + "karma-cli": "^2.0.0", + "karma-coverage": "^2.0.3", + "karma-phantomjs-launcher": "^1.0.0", + "karma-tap": "^4.2.0", + "nyc": "^15.1.0", + "phantomjs-prebuilt": "^2.1.3", + "rimraf": "^2.2.8", + "server-destroy": "^1.0.1", + "standard": "^9.0.0", + "tap": "^15.1.5", + "tape": "^4.6.0" + }, + "greenkeeper": { + "ignore": [ + "hawk", + "har-validator" + ] + } +} diff --git a/node_modules/@cypress/request/request.js b/node_modules/@cypress/request/request.js new file mode 100644 index 0000000000000000000000000000000000000000..e6bf22388edde7615d88e884eb247c3ede5dc12a --- /dev/null +++ b/node_modules/@cypress/request/request.js @@ -0,0 +1,1548 @@ +'use strict' + +var http = require('http') +var https = require('https') +var url = require('url') +var util = require('util') +var stream = require('stream') +var zlib = require('zlib') +var aws2 = require('aws-sign2') +var aws4 = require('aws4') +var httpSignature = require('http-signature') +var mime = require('mime-types') +var caseless = require('caseless') +var ForeverAgent = require('forever-agent') +var FormData = require('form-data') +var extend = require('extend') +var isstream = require('isstream') +var isTypedArray = require('is-typedarray').strict +var helpers = require('./lib/helpers') +var cookies = require('./lib/cookies') +var getProxyFromURI = require('./lib/getProxyFromURI') +var Querystring = require('./lib/querystring').Querystring +var Har = require('./lib/har').Har +var Auth = require('./lib/auth').Auth +var hawk = require('./lib/hawk') +var Multipart = require('./lib/multipart').Multipart +var Redirect = require('./lib/redirect').Redirect +var Tunnel = require('./lib/tunnel').Tunnel +var now = require('performance-now') +var Buffer = require('safe-buffer').Buffer + +var safeStringify = helpers.safeStringify +var isReadStream = helpers.isReadStream +var toBase64 = helpers.toBase64 +var defer = helpers.defer +var copy = helpers.copy +var version = helpers.version +var globalCookieJar = cookies.jar() + +var globalPool = {} + +function filterForNonReserved (reserved, options) { + // Filter out properties that are not reserved. + // Reserved values are passed in at call site. + + var object = {} + for (var i in options) { + var notReserved = (reserved.indexOf(i) === -1) + if (notReserved) { + object[i] = options[i] + } + } + return object +} + +function filterOutReservedFunctions (reserved, options) { + // Filter out properties that are functions and are reserved. + // Reserved values are passed in at call site. + + var object = {} + for (var i in options) { + var isReserved = !(reserved.indexOf(i) === -1) + var isFunction = (typeof options[i] === 'function') + if (!(isReserved && isFunction)) { + object[i] = options[i] + } + } + return object +} + +// Return a simpler request object to allow serialization +function requestToJSON () { + var self = this + return { + uri: self.uri, + method: self.method, + headers: self.headers + } +} + +// Return a simpler response object to allow serialization +function responseToJSON () { + var self = this + return { + statusCode: self.statusCode, + body: self.body, + headers: self.headers, + request: requestToJSON.call(self.request) + } +} + +function Request (options) { + // if given the method property in options, set property explicitMethod to true + + // extend the Request instance with any non-reserved properties + // remove any reserved functions from the options object + // set Request instance to be readable and writable + // call init + + var self = this + + // start with HAR, then override with additional options + if (options.har) { + self._har = new Har(self) + options = self._har.options(options) + } + + stream.Stream.call(self) + var reserved = Object.keys(Request.prototype) + var nonReserved = filterForNonReserved(reserved, options) + + extend(self, nonReserved) + options = filterOutReservedFunctions(reserved, options) + + self.readable = true + self.writable = true + if (options.method) { + self.explicitMethod = true + } + self._qs = new Querystring(self) + self._auth = new Auth(self) + self._multipart = new Multipart(self) + self._redirect = new Redirect(self) + self._tunnel = new Tunnel(self) + self.init(options) +} + +util.inherits(Request, stream.Stream) + +// Debugging +Request.debug = process.env.NODE_DEBUG && /\brequest\b/.test(process.env.NODE_DEBUG) +function debug () { + if (Request.debug) { + console.error('REQUEST %s', util.format.apply(util, arguments)) + } +} +Request.prototype.debug = debug + +Request.prototype.init = function (options) { + // init() contains all the code to setup the request object. + // the actual outgoing request is not started until start() is called + // this function is called from both the constructor and on redirect. + var self = this + if (!options) { + options = {} + } + self.headers = self.headers ? copy(self.headers) : {} + + // Delete headers with value undefined since they break + // ClientRequest.OutgoingMessage.setHeader in node 0.12 + for (var headerName in self.headers) { + if (typeof self.headers[headerName] === 'undefined') { + delete self.headers[headerName] + } + } + + caseless.httpify(self, self.headers) + + if (!self.method) { + self.method = options.method || 'GET' + } + if (!self.localAddress) { + self.localAddress = options.localAddress + } + + self._qs.init(options) + + debug(options) + if (!self.pool && self.pool !== false) { + self.pool = globalPool + } + self.dests = self.dests || [] + self.__isRequestRequest = true + + // Protect against double callback + if (!self._callback && self.callback) { + self._callback = self.callback + self.callback = function () { + if (self._callbackCalled) { + return // Print a warning maybe? + } + self._callbackCalled = true + self._callback.apply(self, arguments) + } + self.on('error', self.callback.bind()) + self.on('complete', self.callback.bind(self, null)) + } + + // People use this property instead all the time, so support it + if (!self.uri && self.url) { + self.uri = self.url + delete self.url + } + + // If there's a baseUrl, then use it as the base URL (i.e. uri must be + // specified as a relative path and is appended to baseUrl). + if (self.baseUrl) { + if (typeof self.baseUrl !== 'string') { + return self.emit('error', new Error('options.baseUrl must be a string')) + } + + if (typeof self.uri !== 'string') { + return self.emit('error', new Error('options.uri must be a string when using options.baseUrl')) + } + + if (self.uri.indexOf('//') === 0 || self.uri.indexOf('://') !== -1) { + return self.emit('error', new Error('options.uri must be a path when using options.baseUrl')) + } + + // Handle all cases to make sure that there's only one slash between + // baseUrl and uri. + var baseUrlEndsWithSlash = self.baseUrl.lastIndexOf('/') === self.baseUrl.length - 1 + var uriStartsWithSlash = self.uri.indexOf('/') === 0 + + if (baseUrlEndsWithSlash && uriStartsWithSlash) { + self.uri = self.baseUrl + self.uri.slice(1) + } else if (baseUrlEndsWithSlash || uriStartsWithSlash) { + self.uri = self.baseUrl + self.uri + } else if (self.uri === '') { + self.uri = self.baseUrl + } else { + self.uri = self.baseUrl + '/' + self.uri + } + delete self.baseUrl + } + + // A URI is needed by this point, emit error if we haven't been able to get one + if (!self.uri) { + return self.emit('error', new Error('options.uri is a required argument')) + } + + // If a string URI/URL was given, parse it into a URL object + if (typeof self.uri === 'string') { + self.uri = url.parse(self.uri) + } + + // Some URL objects are not from a URL parsed string and need href added + if (!self.uri.href) { + self.uri.href = url.format(self.uri) + } + + // DEPRECATED: Warning for users of the old Unix Sockets URL Scheme + if (self.uri.protocol === 'unix:') { + return self.emit('error', new Error('`unix://` URL scheme is no longer supported. Please use the format `http://unix:SOCKET:PATH`')) + } + + // Support Unix Sockets + if (self.uri.host === 'unix') { + self.enableUnixSocket() + } + + if (self.strictSSL === false) { + self.rejectUnauthorized = false + } + + if (!self.uri.pathname) { self.uri.pathname = '/' } + + if (!(self.uri.host || (self.uri.hostname && self.uri.port)) && !self.uri.isUnix) { + // Invalid URI: it may generate lot of bad errors, like 'TypeError: Cannot call method `indexOf` of undefined' in CookieJar + // Detect and reject it as soon as possible + var faultyUri = url.format(self.uri) + var message = 'Invalid URI "' + faultyUri + '"' + if (Object.keys(options).length === 0) { + // No option ? This can be the sign of a redirect + // As this is a case where the user cannot do anything (they didn't call request directly with this URL) + // they should be warned that it can be caused by a redirection (can save some hair) + message += '. This can be caused by a crappy redirection.' + } + // This error was fatal + self.abort() + return self.emit('error', new Error(message)) + } + + if (!self.hasOwnProperty('proxy')) { + self.proxy = getProxyFromURI(self.uri) + } + + self.tunnel = self._tunnel.isEnabled() + if (self.proxy) { + self._tunnel.setup(options) + } + + self._redirect.onRequest(options) + + self.setHost = false + if (!self.hasHeader('host')) { + var hostHeaderName = self.originalHostHeaderName || 'host' + self.setHeader(hostHeaderName, self.uri.host) + // Drop :port suffix from Host header if known protocol. + if (self.uri.port) { + if ((self.uri.port === '80' && self.uri.protocol === 'http:') || + (self.uri.port === '443' && self.uri.protocol === 'https:')) { + self.setHeader(hostHeaderName, self.uri.hostname) + } + } + self.setHost = true + } + + self.jar(self._jar || options.jar) + + if (!self.uri.port) { + if (self.uri.protocol === 'http:') { self.uri.port = 80 } else if (self.uri.protocol === 'https:') { self.uri.port = 443 } + } + + if (self.proxy && !self.tunnel) { + self.port = self.proxy.port + self.host = self.proxy.hostname + } else { + self.port = self.uri.port + self.host = self.uri.hostname + } + + if (options.form) { + self.form(options.form) + } + + if (options.formData) { + var formData = options.formData + var requestForm = self.form() + var appendFormValue = function (key, value) { + if (value && value.hasOwnProperty('value') && value.hasOwnProperty('options')) { + requestForm.append(key, value.value, value.options) + } else { + requestForm.append(key, value) + } + } + for (var formKey in formData) { + if (formData.hasOwnProperty(formKey)) { + var formValue = formData[formKey] + if (formValue instanceof Array) { + for (var j = 0; j < formValue.length; j++) { + appendFormValue(formKey, formValue[j]) + } + } else { + appendFormValue(formKey, formValue) + } + } + } + } + + if (options.qs) { + self.qs(options.qs) + } + + if (self.uri.path) { + self.path = self.uri.path + } else { + self.path = self.uri.pathname + (self.uri.search || '') + } + + if (self.path.length === 0) { + self.path = '/' + } + + // Auth must happen last in case signing is dependent on other headers + if (options.aws) { + self.aws(options.aws) + } + + if (options.hawk) { + self.hawk(options.hawk) + } + + if (options.httpSignature) { + self.httpSignature(options.httpSignature) + } + + if (options.auth) { + if (Object.prototype.hasOwnProperty.call(options.auth, 'username')) { + options.auth.user = options.auth.username + } + if (Object.prototype.hasOwnProperty.call(options.auth, 'password')) { + options.auth.pass = options.auth.password + } + + self.auth( + options.auth.user, + options.auth.pass, + options.auth.sendImmediately, + options.auth.bearer + ) + } + + if (self.gzip && !self.hasHeader('accept-encoding')) { + self.setHeader('accept-encoding', 'gzip, deflate') + } + + if (self.uri.auth && !self.hasHeader('authorization')) { + var uriAuthPieces = self.uri.auth.split(':').map(function (item) { return self._qs.unescape(item) }) + self.auth(uriAuthPieces[0], uriAuthPieces.slice(1).join(':'), true) + } + + if (!self.tunnel && self.proxy && self.proxy.auth && !self.hasHeader('proxy-authorization')) { + var proxyAuthPieces = self.proxy.auth.split(':').map(function (item) { return self._qs.unescape(item) }) + var authHeader = 'Basic ' + toBase64(proxyAuthPieces.join(':')) + self.setHeader('proxy-authorization', authHeader) + } + + if (self.proxy && !self.tunnel) { + self.path = (self.uri.protocol + '//' + self.uri.host + self.path) + } + + if (options.json) { + self.json(options.json) + } + if (options.multipart) { + self.multipart(options.multipart) + } + + if (options.time) { + self.timing = true + + // NOTE: elapsedTime is deprecated in favor of .timings + self.elapsedTime = self.elapsedTime || 0 + } + + function setContentLength () { + if (isTypedArray(self.body)) { + self.body = Buffer.from(self.body) + } + + if (!self.hasHeader('content-length')) { + var length + if (typeof self.body === 'string') { + length = Buffer.byteLength(self.body) + } else if (Array.isArray(self.body)) { + length = self.body.reduce(function (a, b) { return a + b.length }, 0) + } else { + length = self.body.length + } + + if (length) { + self.setHeader('content-length', length) + } else { + self.emit('error', new Error('Argument error, options.body.')) + } + } + } + if (self.body && !isstream(self.body)) { + setContentLength() + } + + var protocol = self.proxy && !self.tunnel ? self.proxy.protocol : self.uri.protocol + var defaultModules = {'http:': http, 'https:': https} + var httpModules = self.httpModules || {} + + self.httpModule = httpModules[protocol] || defaultModules[protocol] + + if (!self.httpModule) { + return self.emit('error', new Error('Invalid protocol: ' + protocol)) + } + + if (options.ca) { + self.ca = options.ca + } + + if (!self.agent) { + if (options.agentOptions) { + self.agentOptions = options.agentOptions + } + + if (options.agentClass) { + self.agentClass = options.agentClass + } else if (options.forever) { + var v = version() + // use ForeverAgent in node 0.10- only + if (v.major === 0 && v.minor <= 10) { + self.agentClass = protocol === 'http:' ? ForeverAgent : ForeverAgent.SSL + } else { + self.agentClass = self.httpModule.Agent + self.agentOptions = self.agentOptions || {} + self.agentOptions.keepAlive = true + } + } else { + self.agentClass = self.httpModule.Agent + } + } + + if (self.pool === false) { + self.agent = false + } else { + self.agent = self.agent || self.getNewAgent() + } + + self.on('pipe', function (src) { + if (self.ntick && self._started) { + self.emit('error', new Error('You cannot pipe to this stream after the outbound request has started.')) + } + self.src = src + if (isReadStream(src)) { + if (!self.hasHeader('content-type')) { + self.setHeader('content-type', mime.lookup(src.path)) + } + } else { + if (src.headers) { + for (var i in src.headers) { + if (!self.hasHeader(i)) { + self.setHeader(i, src.headers[i]) + } + } + } + if (self._json && !self.hasHeader('content-type')) { + self.setHeader('content-type', 'application/json') + } + if (src.method && !self.explicitMethod) { + self.method = src.method + } + } + + // self.on('pipe', function () { + // console.error('You have already piped to this stream. Pipeing twice is likely to break the request.') + // }) + }) + + defer(function () { + if (self._aborted) { + return + } + + var end = function () { + if (self._form) { + if (!self._auth.hasAuth) { + self._form.pipe(self) + } else if (self._auth.hasAuth && self._auth.sentAuth) { + self._form.pipe(self) + } + } + if (self._multipart && self._multipart.chunked) { + self._multipart.body.pipe(self) + } + if (self.body) { + if (isstream(self.body)) { + self.body.pipe(self) + } else { + setContentLength() + if (Array.isArray(self.body)) { + self.body.forEach(function (part) { + self.write(part) + }) + } else { + self.write(self.body) + } + self.end() + } + } else if (self.requestBodyStream) { + console.warn('options.requestBodyStream is deprecated, please pass the request object to stream.pipe.') + self.requestBodyStream.pipe(self) + } else if (!self.src) { + if (self._auth.hasAuth && !self._auth.sentAuth) { + self.end() + return + } + if (self.method !== 'GET' && typeof self.method !== 'undefined') { + self.setHeader('content-length', 0) + } + self.end() + } + } + + if (self._form && !self.hasHeader('content-length')) { + // Before ending the request, we had to compute the length of the whole form, asyncly + self.setHeader(self._form.getHeaders(), true) + self._form.getLength(function (err, length) { + if (!err && !isNaN(length)) { + self.setHeader('content-length', length) + } + end() + }) + } else { + end() + } + + self.ntick = true + }) +} + +Request.prototype.getNewAgent = function () { + var self = this + var Agent = self.agentClass + var options = {} + if (self.agentOptions) { + for (var i in self.agentOptions) { + options[i] = self.agentOptions[i] + } + } + if (self.ca) { + options.ca = self.ca + } + if (self.ciphers) { + options.ciphers = self.ciphers + } + if (self.secureProtocol) { + options.secureProtocol = self.secureProtocol + } + if (self.secureOptions) { + options.secureOptions = self.secureOptions + } + if (typeof self.rejectUnauthorized !== 'undefined') { + options.rejectUnauthorized = self.rejectUnauthorized + } + + if (self.cert && self.key) { + options.key = self.key + options.cert = self.cert + } + + if (self.pfx) { + options.pfx = self.pfx + } + + if (self.passphrase) { + options.passphrase = self.passphrase + } + + var poolKey = '' + + // different types of agents are in different pools + if (Agent !== self.httpModule.Agent) { + poolKey += Agent.name + } + + // ca option is only relevant if proxy or destination are https + var proxy = self.proxy + if (typeof proxy === 'string') { + proxy = url.parse(proxy) + } + var isHttps = (proxy && proxy.protocol === 'https:') || this.uri.protocol === 'https:' + + if (isHttps) { + if (options.ca) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.ca + } + + if (typeof options.rejectUnauthorized !== 'undefined') { + if (poolKey) { + poolKey += ':' + } + poolKey += options.rejectUnauthorized + } + + if (options.cert) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.cert.toString('ascii') + options.key.toString('ascii') + } + + if (options.pfx) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.pfx.toString('ascii') + } + + if (options.ciphers) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.ciphers + } + + if (options.secureProtocol) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.secureProtocol + } + + if (options.secureOptions) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.secureOptions + } + } + + if (self.pool === globalPool && !poolKey && Object.keys(options).length === 0 && self.httpModule.globalAgent) { + // not doing anything special. Use the globalAgent + return self.httpModule.globalAgent + } + + // we're using a stored agent. Make sure it's protocol-specific + poolKey = self.uri.protocol + poolKey + + // generate a new agent for this setting if none yet exists + if (!self.pool[poolKey]) { + self.pool[poolKey] = new Agent(options) + // properly set maxSockets on new agents + if (self.pool.maxSockets) { + self.pool[poolKey].maxSockets = self.pool.maxSockets + } + } + + return self.pool[poolKey] +} + +Request.prototype.start = function () { + // start() is called once we are ready to send the outgoing HTTP request. + // this is usually called on the first write(), end() or on nextTick() + var self = this + + if (self.timing) { + // All timings will be relative to this request's startTime. In order to do this, + // we need to capture the wall-clock start time (via Date), immediately followed + // by the high-resolution timer (via now()). While these two won't be set + // at the _exact_ same time, they should be close enough to be able to calculate + // high-resolution, monotonically non-decreasing timestamps relative to startTime. + var startTime = new Date().getTime() + var startTimeNow = now() + } + + if (self._aborted) { + return + } + + self._started = true + self.method = self.method || 'GET' + self.href = self.uri.href + + if (self.src && self.src.stat && self.src.stat.size && !self.hasHeader('content-length')) { + self.setHeader('content-length', self.src.stat.size) + } + if (self._aws) { + self.aws(self._aws, true) + } + + // We have a method named auth, which is completely different from the http.request + // auth option. If we don't remove it, we're gonna have a bad time. + var reqOptions = copy(self) + delete reqOptions.auth + + debug('make request', self.uri.href) + + // node v6.8.0 now supports a `timeout` value in `http.request()`, but we + // should delete it for now since we handle timeouts manually for better + // consistency with node versions before v6.8.0 + delete reqOptions.timeout + + try { + self.req = self.httpModule.request(reqOptions) + } catch (err) { + self.emit('error', err) + return + } + + if (self.timing) { + self.startTime = startTime + self.startTimeNow = startTimeNow + + // Timing values will all be relative to startTime (by comparing to startTimeNow + // so we have an accurate clock) + self.timings = {} + } + + var timeout + if (self.timeout && !self.timeoutTimer) { + if (self.timeout < 0) { + timeout = 0 + } else if (typeof self.timeout === 'number' && isFinite(self.timeout)) { + timeout = self.timeout + } + } + + self.req.on('response', self.onRequestResponse.bind(self)) + self.req.on('error', self.onRequestError.bind(self)) + self.req.on('drain', function () { + self.emit('drain') + }) + + self.req.on('socket', function (socket) { + // `._connecting` was the old property which was made public in node v6.1.0 + var isConnecting = socket._connecting || socket.connecting + if (self.timing) { + self.timings.socket = now() - self.startTimeNow + + if (isConnecting) { + var onLookupTiming = function () { + self.timings.lookup = now() - self.startTimeNow + } + + var onConnectTiming = function () { + self.timings.connect = now() - self.startTimeNow + } + + socket.once('lookup', onLookupTiming) + socket.once('connect', onConnectTiming) + + // clean up timing event listeners if needed on error + self.req.once('error', function () { + socket.removeListener('lookup', onLookupTiming) + socket.removeListener('connect', onConnectTiming) + }) + } + } + + var setReqTimeout = function () { + // This timeout sets the amount of time to wait *between* bytes sent + // from the server once connected. + // + // In particular, it's useful for erroring if the server fails to send + // data halfway through streaming a response. + self.req.setTimeout(timeout, function () { + if (self.req) { + self.abort() + var e = new Error('ESOCKETTIMEDOUT') + e.code = 'ESOCKETTIMEDOUT' + e.connect = false + self.emit('error', e) + } + }) + } + if (timeout !== undefined) { + // Only start the connection timer if we're actually connecting a new + // socket, otherwise if we're already connected (because this is a + // keep-alive connection) do not bother. This is important since we won't + // get a 'connect' event for an already connected socket. + if (isConnecting) { + var onReqSockConnect = function () { + socket.removeListener('connect', onReqSockConnect) + self.clearTimeout() + setReqTimeout() + } + + socket.on('connect', onReqSockConnect) + + self.req.on('error', function (err) { // eslint-disable-line handle-callback-err + socket.removeListener('connect', onReqSockConnect) + }) + + // Set a timeout in memory - this block will throw if the server takes more + // than `timeout` to write the HTTP status and headers (corresponding to + // the on('response') event on the client). NB: this measures wall-clock + // time, not the time between bytes sent by the server. + self.timeoutTimer = setTimeout(function () { + socket.removeListener('connect', onReqSockConnect) + self.abort() + var e = new Error('ETIMEDOUT') + e.code = 'ETIMEDOUT' + e.connect = true + self.emit('error', e) + }, timeout) + } else { + // We're already connected + setReqTimeout() + } + } + self.emit('socket', socket) + }) + + self.emit('request', self.req) +} + +Request.prototype.onRequestError = function (error) { + var self = this + if (self._aborted) { + return + } + if (self.req && self.req._reusedSocket && error.code === 'ECONNRESET' && + self.agent.addRequestNoreuse) { + self.agent = { addRequest: self.agent.addRequestNoreuse.bind(self.agent) } + self.start() + self.req.end() + return + } + self.clearTimeout() + self.emit('error', error) +} + +Request.prototype.onRequestResponse = function (response) { + var self = this + + if (self.timing) { + self.timings.response = now() - self.startTimeNow + } + + debug('onRequestResponse', self.uri.href, response.statusCode, response.headers) + response.on('end', function () { + if (self.timing) { + self.timings.end = now() - self.startTimeNow + response.timingStart = self.startTime + + // fill in the blanks for any periods that didn't trigger, such as + // no lookup or connect due to keep alive + if (!self.timings.socket) { + self.timings.socket = 0 + } + if (!self.timings.lookup) { + self.timings.lookup = self.timings.socket + } + if (!self.timings.connect) { + self.timings.connect = self.timings.lookup + } + if (!self.timings.response) { + self.timings.response = self.timings.connect + } + + debug('elapsed time', self.timings.end) + + // elapsedTime includes all redirects + self.elapsedTime += Math.round(self.timings.end) + + // NOTE: elapsedTime is deprecated in favor of .timings + response.elapsedTime = self.elapsedTime + + // timings is just for the final fetch + response.timings = self.timings + + // pre-calculate phase timings as well + response.timingPhases = { + wait: self.timings.socket, + dns: self.timings.lookup - self.timings.socket, + tcp: self.timings.connect - self.timings.lookup, + firstByte: self.timings.response - self.timings.connect, + download: self.timings.end - self.timings.response, + total: self.timings.end + } + } + debug('response end', self.uri.href, response.statusCode, response.headers) + }) + + if (self._aborted) { + debug('aborted', self.uri.href) + response.resume() + return + } + + self.response = response + response.request = self + response.toJSON = responseToJSON + + // XXX This is different on 0.10, because SSL is strict by default + if (self.httpModule === https && + self.strictSSL && (!response.hasOwnProperty('socket') || + !response.socket.authorized)) { + debug('strict ssl error', self.uri.href) + var sslErr = response.hasOwnProperty('socket') ? response.socket.authorizationError : self.uri.href + ' does not support SSL' + self.emit('error', new Error('SSL Error: ' + sslErr)) + return + } + + // Save the original host before any redirect (if it changes, we need to + // remove any authorization headers). Also remember the case of the header + // name because lots of broken servers expect Host instead of host and we + // want the caller to be able to specify this. + self.originalHost = self.getHeader('host') + if (!self.originalHostHeaderName) { + self.originalHostHeaderName = self.hasHeader('host') + } + if (self.setHost) { + self.removeHeader('host') + } + self.clearTimeout() + + var targetCookieJar = (self._jar && self._jar.setCookie) ? self._jar : globalCookieJar + var addCookie = function (cookie) { + // set the cookie if it's domain in the href's domain. + try { + targetCookieJar.setCookie(cookie, self.uri.href, {ignoreError: true}) + } catch (e) { + self.emit('error', e) + } + } + + response.caseless = caseless(response.headers) + + if (response.caseless.has('set-cookie') && (!self._disableCookies)) { + var headerName = response.caseless.has('set-cookie') + if (Array.isArray(response.headers[headerName])) { + response.headers[headerName].forEach(addCookie) + } else { + addCookie(response.headers[headerName]) + } + } + + self._redirect.onResponse(response, function (err, followingRedirect) { + if (!err && followingRedirect) return // Ignore the rest of the response + if (err) self.emit('error', err) + + // Be a good stream and emit end when the response is finished. + // Hack to emit end on close because of a core bug that never fires end + response.on('close', function () { + if (!self._ended) { + self._ended = true + self.response.emit('end') + } + }) + + response.once('end', function () { + self._ended = true + }) + + var noBody = function (code) { + return ( + self.method === 'HEAD' || + // Informational + (code >= 100 && code < 200) || + // No Content + code === 204 || + // Not Modified + code === 304 + ) + } + + var responseContent + if (self.gzip && !noBody(response.statusCode)) { + var contentEncoding = response.headers['content-encoding'] || 'identity' + contentEncoding = contentEncoding.trim().toLowerCase() + + // Be more lenient with decoding compressed responses, since (very rarely) + // servers send slightly invalid gzip responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + var zlibOptions = { + flush: zlib.Z_SYNC_FLUSH, + finishFlush: zlib.Z_SYNC_FLUSH + } + + if (contentEncoding === 'gzip') { + responseContent = zlib.createGunzip(zlibOptions) + response.pipe(responseContent) + } else if (contentEncoding === 'deflate') { + responseContent = zlib.createInflate(zlibOptions) + response.pipe(responseContent) + } else { + // Since previous versions didn't check for Content-Encoding header, + // ignore any invalid values to preserve backwards-compatibility + if (contentEncoding !== 'identity') { + debug('ignoring unrecognized Content-Encoding ' + contentEncoding) + } + responseContent = response + } + } else { + responseContent = response + } + + if (self.encoding) { + if (self.dests.length !== 0) { + console.error('Ignoring encoding parameter as this stream is being piped to another stream which makes the encoding option invalid.') + } else { + responseContent.setEncoding(self.encoding) + } + } + + if (self._paused) { + responseContent.pause() + } + + self.responseContent = responseContent + + self.emit('response', response) + + self.dests.forEach(function (dest) { + self.pipeDest(dest) + }) + + responseContent.on('data', function (chunk) { + if (self.timing && !self.responseStarted) { + self.responseStartTime = (new Date()).getTime() + + // NOTE: responseStartTime is deprecated in favor of .timings + response.responseStartTime = self.responseStartTime + } + self._destdata = true + self.emit('data', chunk) + }) + responseContent.once('end', function (chunk) { + self.emit('end', chunk) + }) + responseContent.on('error', function (error) { + if (error.code === 'ECONNRESET' && error.message === 'aborted' && self.listenerCount('error') === 0) { + // Node 16 causes aborts to emit errors if there is an error listener. + // Without this short-circuit, it will cause unhandled exceptions since + // there is not always an `error` listener on `self`, but there will + // always be an `error` listener on `responseContent`. + // @see https://github.com/nodejs/node/pull/33172 + return + } + self.emit('error', error) + }) + responseContent.on('close', function () { self.emit('close') }) + + if (self.callback) { + self.readResponseBody(response) + } else { // if no callback + self.on('end', function () { + if (self._aborted) { + debug('aborted', self.uri.href) + return + } + self.emit('complete', response) + }) + } + debug('finish init function', self.uri.href) + }) +} + +Request.prototype.readResponseBody = function (response) { + var self = this + debug("reading response's body") + var buffers = [] + var bufferLength = 0 + var strings = [] + + self.on('data', function (chunk) { + if (!Buffer.isBuffer(chunk)) { + strings.push(chunk) + } else if (chunk.length) { + bufferLength += chunk.length + buffers.push(chunk) + } + }) + self.on('end', function () { + debug('end event', self.uri.href) + if (self._aborted) { + debug('aborted', self.uri.href) + // `buffer` is defined in the parent scope and used in a closure it exists for the life of the request. + // This can lead to leaky behavior if the user retains a reference to the request object. + buffers = [] + bufferLength = 0 + return + } + + if (bufferLength) { + debug('has body', self.uri.href, bufferLength) + response.body = Buffer.concat(buffers, bufferLength) + if (self.encoding !== null) { + response.body = response.body.toString(self.encoding) + } + // `buffer` is defined in the parent scope and used in a closure it exists for the life of the Request. + // This can lead to leaky behavior if the user retains a reference to the request object. + buffers = [] + bufferLength = 0 + } else if (strings.length) { + // The UTF8 BOM [0xEF,0xBB,0xBF] is converted to [0xFE,0xFF] in the JS UTC16/UCS2 representation. + // Strip this value out when the encoding is set to 'utf8', as upstream consumers won't expect it and it breaks JSON.parse(). + if (self.encoding === 'utf8' && strings[0].length > 0 && strings[0][0] === '\uFEFF') { + strings[0] = strings[0].substring(1) + } + response.body = strings.join('') + } + + if (self._json) { + try { + response.body = JSON.parse(response.body, self._jsonReviver) + } catch (e) { + debug('invalid JSON received', self.uri.href) + } + } + debug('emitting complete', self.uri.href) + if (typeof response.body === 'undefined' && !self._json) { + response.body = self.encoding === null ? Buffer.alloc(0) : '' + } + self.emit('complete', response, response.body) + }) +} + +Request.prototype.abort = function () { + var self = this + self._aborted = true + + if (self.req) { + self.req.abort() + } else if (self.response) { + self.response.destroy() + } + + self.clearTimeout() + self.emit('abort') +} + +Request.prototype.pipeDest = function (dest) { + var self = this + var response = self.response + // Called after the response is received + if (dest.headers && !dest.headersSent) { + if (response.caseless.has('content-type')) { + var ctname = response.caseless.has('content-type') + if (dest.setHeader) { + dest.setHeader(ctname, response.headers[ctname]) + } else { + dest.headers[ctname] = response.headers[ctname] + } + } + + if (response.caseless.has('content-length')) { + var clname = response.caseless.has('content-length') + if (dest.setHeader) { + dest.setHeader(clname, response.headers[clname]) + } else { + dest.headers[clname] = response.headers[clname] + } + } + } + if (dest.setHeader && !dest.headersSent) { + for (var i in response.headers) { + // If the response content is being decoded, the Content-Encoding header + // of the response doesn't represent the piped content, so don't pass it. + if (!self.gzip || i !== 'content-encoding') { + dest.setHeader(i, response.headers[i]) + } + } + dest.statusCode = response.statusCode + } + if (self.pipefilter) { + self.pipefilter(response, dest) + } +} + +Request.prototype.qs = function (q, clobber) { + var self = this + var base + if (!clobber && self.uri.query) { + base = self._qs.parse(self.uri.query) + } else { + base = {} + } + + for (var i in q) { + base[i] = q[i] + } + + var qs = self._qs.stringify(base) + + if (qs === '') { + return self + } + + self.uri = url.parse(self.uri.href.split('?')[0] + '?' + qs) + self.url = self.uri + self.path = self.uri.path + + if (self.uri.host === 'unix') { + self.enableUnixSocket() + } + + return self +} +Request.prototype.form = function (form) { + var self = this + if (form) { + if (!/^application\/x-www-form-urlencoded\b/.test(self.getHeader('content-type'))) { + self.setHeader('content-type', 'application/x-www-form-urlencoded') + } + self.body = (typeof form === 'string') + ? self._qs.rfc3986(form.toString('utf8')) + : self._qs.stringify(form).toString('utf8') + return self + } + // create form-data object + self._form = new FormData() + self._form.on('error', function (err) { + err.message = 'form-data: ' + err.message + self.emit('error', err) + self.abort() + }) + return self._form +} +Request.prototype.multipart = function (multipart) { + var self = this + + self._multipart.onRequest(multipart) + + if (!self._multipart.chunked) { + self.body = self._multipart.body + } + + return self +} +Request.prototype.json = function (val) { + var self = this + + if (!self.hasHeader('accept')) { + self.setHeader('accept', 'application/json') + } + + if (typeof self.jsonReplacer === 'function') { + self._jsonReplacer = self.jsonReplacer + } + + self._json = true + if (typeof val === 'boolean') { + if (self.body !== undefined) { + if (!/^application\/x-www-form-urlencoded\b/.test(self.getHeader('content-type'))) { + self.body = safeStringify(self.body, self._jsonReplacer) + } else { + self.body = self._qs.rfc3986(self.body) + } + if (!self.hasHeader('content-type')) { + self.setHeader('content-type', 'application/json') + } + } + } else { + self.body = safeStringify(val, self._jsonReplacer) + if (!self.hasHeader('content-type')) { + self.setHeader('content-type', 'application/json') + } + } + + if (typeof self.jsonReviver === 'function') { + self._jsonReviver = self.jsonReviver + } + + return self +} +Request.prototype.getHeader = function (name, headers) { + var self = this + var result, re, match + if (!headers) { + headers = self.headers + } + Object.keys(headers).forEach(function (key) { + if (key.length !== name.length) { + return + } + re = new RegExp(name, 'i') + match = key.match(re) + if (match) { + result = headers[key] + } + }) + return result +} +Request.prototype.enableUnixSocket = function () { + // Get the socket & request paths from the URL + var unixParts = this.uri.path.split(':') + var host = unixParts[0] + var path = unixParts[1] + // Apply unix properties to request + this.socketPath = host + this.uri.pathname = path + this.uri.path = path + this.uri.host = host + this.uri.hostname = host + this.uri.isUnix = true +} + +Request.prototype.auth = function (user, pass, sendImmediately, bearer) { + var self = this + + self._auth.onRequest(user, pass, sendImmediately, bearer) + + return self +} +Request.prototype.aws = function (opts, now) { + var self = this + + if (!now) { + self._aws = opts + return self + } + + if (opts.sign_version === 4 || opts.sign_version === '4') { + // use aws4 + var options = { + host: self.uri.host, + path: self.uri.path, + method: self.method, + headers: self.headers, + body: self.body + } + if (opts.service) { + options.service = opts.service + } + var signRes = aws4.sign(options, { + accessKeyId: opts.key, + secretAccessKey: opts.secret, + sessionToken: opts.session + }) + self.setHeader('authorization', signRes.headers.Authorization) + self.setHeader('x-amz-date', signRes.headers['X-Amz-Date']) + if (signRes.headers['X-Amz-Security-Token']) { + self.setHeader('x-amz-security-token', signRes.headers['X-Amz-Security-Token']) + } + } else { + // default: use aws-sign2 + var date = new Date() + self.setHeader('date', date.toUTCString()) + var auth = { + key: opts.key, + secret: opts.secret, + verb: self.method.toUpperCase(), + date: date, + contentType: self.getHeader('content-type') || '', + md5: self.getHeader('content-md5') || '', + amazonHeaders: aws2.canonicalizeHeaders(self.headers) + } + var path = self.uri.path + if (opts.bucket && path) { + auth.resource = '/' + opts.bucket + path + } else if (opts.bucket && !path) { + auth.resource = '/' + opts.bucket + } else if (!opts.bucket && path) { + auth.resource = path + } else if (!opts.bucket && !path) { + auth.resource = '/' + } + auth.resource = aws2.canonicalizeResource(auth.resource) + self.setHeader('authorization', aws2.authorization(auth)) + } + + return self +} +Request.prototype.httpSignature = function (opts) { + var self = this + httpSignature.signRequest({ + getHeader: function (header) { + return self.getHeader(header, self.headers) + }, + setHeader: function (header, value) { + self.setHeader(header, value) + }, + method: self.method, + path: self.path + }, opts) + debug('httpSignature authorization', self.getHeader('authorization')) + + return self +} +Request.prototype.hawk = function (opts) { + var self = this + self.setHeader('Authorization', hawk.header(self.uri, self.method, opts)) +} + +Request.prototype.jar = function (jar) { + var self = this + var cookies + + if (self._redirect.redirectsFollowed === 0) { + self.originalCookieHeader = self.getHeader('cookie') + } + + if (!jar) { + // disable cookies + cookies = false + self._disableCookies = true + } else { + var targetCookieJar = jar.getCookieString ? jar : globalCookieJar + var urihref = self.uri.href + // fetch cookie in the Specified host + if (targetCookieJar) { + cookies = targetCookieJar.getCookieString(urihref) + } + } + + // if need cookie and cookie is not empty + if (cookies && cookies.length) { + if (self.originalCookieHeader) { + // Don't overwrite existing Cookie header + self.setHeader('cookie', self.originalCookieHeader + '; ' + cookies) + } else { + self.setHeader('cookie', cookies) + } + } + self._jar = jar + return self +} + +// Stream API +Request.prototype.pipe = function (dest, opts) { + var self = this + + if (self.response) { + if (self._destdata) { + self.emit('error', new Error('You cannot pipe after data has been emitted from the response.')) + } else if (self._ended) { + self.emit('error', new Error('You cannot pipe after the response has been ended.')) + } else { + stream.Stream.prototype.pipe.call(self, dest, opts) + self.pipeDest(dest) + return dest + } + } else { + self.dests.push(dest) + stream.Stream.prototype.pipe.call(self, dest, opts) + return dest + } +} +Request.prototype.write = function () { + var self = this + if (self._aborted) { return } + + if (!self._started) { + self.start() + } + if (self.req) { + return self.req.write.apply(self.req, arguments) + } +} +Request.prototype.end = function (chunk) { + var self = this + if (self._aborted) { return } + + if (chunk) { + self.write(chunk) + } + if (!self._started) { + self.start() + } + if (self.req) { + self.req.end() + } +} +Request.prototype.pause = function () { + var self = this + if (!self.responseContent) { + self._paused = true + } else { + self.responseContent.pause.apply(self.responseContent, arguments) + } +} +Request.prototype.resume = function () { + var self = this + if (!self.responseContent) { + self._paused = false + } else { + self.responseContent.resume.apply(self.responseContent, arguments) + } +} +Request.prototype.destroy = function () { + var self = this + this.clearTimeout() + if (!self._ended) { + self.end() + } else if (self.response) { + self.response.destroy() + } +} + +Request.prototype.clearTimeout = function () { + if (this.timeoutTimer) { + clearTimeout(this.timeoutTimer) + this.timeoutTimer = null + } +} + +Request.defaultProxyHeaderWhiteList = + Tunnel.defaultProxyHeaderWhiteList.slice() + +Request.defaultProxyHeaderExclusiveList = + Tunnel.defaultProxyHeaderExclusiveList.slice() + +// Exports + +Request.prototype.toJSON = requestToJSON +module.exports = Request diff --git a/node_modules/@types/node-forge/LICENSE b/node_modules/@types/node-forge/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..9e841e7a26e4eb057b24511e7b92d42b257a80e5 --- /dev/null +++ b/node_modules/@types/node-forge/LICENSE @@ -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 diff --git a/node_modules/@types/node-forge/README.md b/node_modules/@types/node-forge/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b749350494a0aefd8d59a88c166655f34c761eae --- /dev/null +++ b/node_modules/@types/node-forge/README.md @@ -0,0 +1,15 @@ +# Installation +> `npm install --save @types/node-forge` + +# Summary +This package contains type definitions for node-forge (https://github.com/digitalbazaar/forge). + +# Details +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-forge. + +### Additional Details + * Last updated: Mon, 20 Nov 2023 23:36:24 GMT + * Dependencies: [@types/node](https://npmjs.com/package/@types/node) + +# Credits +These definitions were written by [Seth Westphal ](https://github.com/westy92), [Kay Schecker ](https://github.com/flynetworks), [Aakash Goenka ](https://github.com/a-k-g), [Rafal2228 ](https://github.com/rafal2228), [Beeno Tung ](https://github.com/beenotung), [Joe Flateau ](https://github.com/joeflateau), [timhwang21 ](https://github.com/timhwang21), [Anders Kaseorg ](https://github.com/andersk), [Sascha Zarhuber ](https://github.com/saschazar21), [Rogier Schouten ](https://github.com/rogierschouten), [Ivan Aseev ](https://github.com/aseevia), [Wiktor Kwapisiewicz](https://github.com/wiktor-k), [Ligia Frangello ](https://github.com/frangello), [Dmitry Avezov ](https://github.com/avezov), [Jose Fuentes ](https://github.com/j-fuentes), [Anya Reyes ](https://github.com/darkade), and [BendingBender ](https://github.com/BendingBender). diff --git a/node_modules/@types/node-forge/index.d.ts b/node_modules/@types/node-forge/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd465b66f586ae8087af9ea52bb318503cda6cf1 --- /dev/null +++ b/node_modules/@types/node-forge/index.d.ts @@ -0,0 +1,1546 @@ +/// + +declare module "node-forge" { + type Byte = number; + type Bytes = string; + type Hex = string; + type Base64 = string; + type Utf8 = string; + type OID = string; + type Encoding = "raw" | "utf8"; + + namespace jsbn { + interface RandomGenerator { + nextBytes(bytes: number[]): void; + } + class BigInteger { + static ZERO: BigInteger; + static ONE: BigInteger; + constructor(a: null); + constructor(a: number, c: RandomGenerator); + constructor(a: number, b: number, c: RandomGenerator); + constructor(a: string, b?: number); + constructor(a: number[], b?: number); + constructor(a: BigInteger); + data: number[]; + t: number; + s: number; + am(i: number, x: number, w: BigInteger, j: number, c: number, n: number): number; + toString(b?: number): string; + bitLength(): number; + negate(): BigInteger; + abs(): BigInteger; + compareTo(a: BigInteger): number; + bitLength(): number; + mod(a: BigInteger): BigInteger; + modPowInt(e: number, m: BigInteger): BigInteger; + clone(): BigInteger; + intValue(): number; + byteValue(): number; + shortValue(): number; + signum(): number; + toByteArray(): number[]; + equals(a: BigInteger): boolean; + min(a: BigInteger): BigInteger; + max(a: BigInteger): BigInteger; + and(a: BigInteger): BigInteger; + or(a: BigInteger): BigInteger; + xor(a: BigInteger): BigInteger; + andNot(a: BigInteger): BigInteger; + not(): BigInteger; + shiftLeft(n: number): BigInteger; + shiftRight(n: number): BigInteger; + getLowestSetBit(): number; + bitCount(): number; + testBit(n: number): boolean; + clearBit(n: number): BigInteger; + flipBit(n: number): BigInteger; + add(a: BigInteger): BigInteger; + subtract(a: BigInteger): BigInteger; + multiply(a: BigInteger): BigInteger; + squareTo(a: BigInteger): BigInteger; + divide(a: BigInteger): BigInteger; + remainder(a: BigInteger): BigInteger; + divideAndRemainder(a: BigInteger): BigInteger[]; // Array of 2 items + pow(e: number): BigInteger; + modPow(e: BigInteger, m: BigInteger): BigInteger; + gcd(a: BigInteger): BigInteger; + modInverse(m: BigInteger): BigInteger; + isProbablePrime(t: number): boolean; + } + } + + namespace rc2 { + type pad_function = (blockSize: number, buffer: util.ByteBuffer, decrypt: boolean) => boolean; + interface cipher { + start(iv: util.ByteBuffer | string | null, output?: util.ByteBuffer): void; + update(input: util.ByteBuffer): void; + finish(pad?: pad_function): boolean; + output: util.ByteBuffer; + } + + function expandKey(key: string | util.ByteBuffer, effKeyBits?: number): util.ByteBuffer; + function startEncrypting( + key: string | util.ByteBuffer, + iv: util.ByteBuffer | Byte[] | Bytes, + output: util.ByteBuffer | null, + ): rc2.cipher; + function createEncryptionCipher(key: string | util.ByteBuffer, bits?: number): rc2.cipher; + function startDecrypting( + key: string | util.ByteBuffer, + iv: util.ByteBuffer | Byte[] | Bytes, + output: util.ByteBuffer | null, + ): rc2.cipher; + function createDecryptionCipher(key: string | util.ByteBuffer, bits?: number): rc2.cipher; + } + + namespace kem { + namespace rsa { + interface kem { + /** + * Generates a secret key and its encapsulation. + * + * @param publicKey the RSA public key to encrypt with. + * @param keyLength the length, in bytes, of the secret key to generate. + */ + encrypt(publicKey: pki.rsa.PublicKey, keyLength: number): EncryptResult; + /** + * Decrypts an encapsulated secret key. + * + * @param privateKey the RSA private key to decrypt with. + * @param encapsulation the ciphertext for generating the secret key, as a binary-encoded + * string of bytes. + * @param keyLength the length, in bytes, of the secret key to generate. + * + * @return the secret key as a binary-encoded string of bytes. + */ + decrypt(privateKey: pki.rsa.PrivateKey, encapsulation: string, keyLength: number): string; + } + + interface random { + getBytesSync(count: number): Bytes; + } + + interface Options { + /** + * A custom crypto-secure pseudo-random number generator to use. + */ + prng?: random | undefined; + } + + /** + * Creates an RSA KEM API object for generating a secret asymmetric key. + * + * The symmetric key may be generated via a call to 'encrypt', which will + * produce a ciphertext to be transmitted to the recipient and a key to be + * kept secret. The ciphertext is a parameter to be passed to 'decrypt' which + * will produce the same secret key for the recipient to use to decrypt a + * message that was encrypted with the secret key. + * + * @param kdf the KDF API to use (eg: `new forge.kem.kdf1()`). + * @param options the options to use. + */ + function create(kdf: KDF, options?: Options): kem; + } + + interface EncryptResult { + /** + * The ciphertext for generating the secret key, as a binary-encoded string of bytes. + */ + encapsulation: string; + /** + * The secret key to use for encrypting a message. + */ + key: string; + } + + interface KDF { + /** + * Generate a key of the specified length. + * + * @param x the binary-encoded byte string to generate a key from. + * @param length the number of bytes to generate (the size of the key). + * + * @return the key as a binary-encoded string. + */ + generate(x: string, length: number): string; + } + + /** + * Creates a key derivation API object that implements KDF1 per ISO 18033-2. + * + * @param md the hash API to use. + * @param digestLength a digest length that must be positive and less than or equal to `md.digestLength`. + * + * @return a KDF1 API object. + */ + class kdf1 implements KDF { + constructor(md: md.MessageDigest, digestLength?: number); + /** + * Generate a key of the specified length. + * + * @param x the binary-encoded byte string to generate a key from. + * @param length the number of bytes to generate (the size of the key). + * + * @return the key as a binary-encoded string. + */ + generate(x: string, length: number): string; + } + + /** + * Creates a key derivation API object that implements KDF2 per ISO 18033-2. + * + * @param md the hash API to use. + * @param digestLength a digest length that must be positive and less than or equal to `md.digestLength`. + * + * @return a KDF2 API object. + */ + class kdf2 implements KDF { + constructor(md: md.MessageDigest, digestLength?: number); + /** + * Generate a key of the specified length. + * + * @param x the binary-encoded byte string to generate a key from. + * @param length the number of bytes to generate (the size of the key). + * + * @return the key as a binary-encoded string. + */ + generate(x: string, length: number): string; + } + } + + namespace pem { + interface EncodeOptions { + maxline?: number | undefined; + } + + interface ObjectPEM { + type: string; + body: Bytes; + procType?: any; + contentDomain?: any; + dekInfo?: any; + headers?: any[] | undefined; + } + + function encode(msg: ObjectPEM, options?: EncodeOptions): string; + function decode(str: string): ObjectPEM[]; + } + + namespace pki { + type PEM = string; + type PublicKey = rsa.PublicKey | ed25519.Key; + type PrivateKey = rsa.PrivateKey | ed25519.Key; + type EncryptionOptions = { + algorithm?: "aes128" | "aes192" | "aes256" | "3des" | undefined; + count?: number | undefined; + saltSize?: number | undefined; + prfAlgorithm?: "sha1" | "sha224" | "sha256" | "sha384" | "sha512" | undefined; + legacy?: boolean | undefined; + }; + + interface ByteBufferFingerprintOptions { + /** + * @description The type of fingerprint. If not specified, defaults to 'RSAPublicKey' + */ + type?: "SubjectPublicKeyInfo" | "RSAPublicKey" | undefined; + /** + * @description the delimiter to use between bytes for `hex` encoded output + */ + delimiter?: string | undefined; + /** + * @description if not specified defaults to `md.md5` + */ + md?: md.MessageDigest | undefined; + } + + interface HexFingerprintOptions extends ByteBufferFingerprintOptions { + /** + * @description if not specified, the function will return `ByteStringBuffer` + */ + encoding: "hex"; + } + + interface BinaryFingerprintOptions extends ByteBufferFingerprintOptions { + /** + * @description if not specified, the function will return `ByteStringBuffer` + */ + encoding: "binary"; + } + + interface KeyPair { + publicKey: PublicKey; + privateKey: PrivateKey; + } + + interface oids { + [key: string]: string; + } + var oids: oids; + + namespace rsa { + type EncryptionScheme = "RSAES-PKCS1-V1_5" | "RSA-OAEP" | "RAW" | "NONE" | null; + type SignatureScheme = "RSASSA-PKCS1-V1_5" | pss.PSS | "NONE" | null; + + interface PublicKey { + n: jsbn.BigInteger; + e: jsbn.BigInteger; + encrypt(data: Bytes, scheme?: EncryptionScheme, schemeOptions?: any): Bytes; + verify(digest: Bytes, signature: Bytes, scheme?: SignatureScheme): boolean; + } + + interface PrivateKey { + n: jsbn.BigInteger; + e: jsbn.BigInteger; + d: jsbn.BigInteger; + p: jsbn.BigInteger; + q: jsbn.BigInteger; + dP: jsbn.BigInteger; + dQ: jsbn.BigInteger; + qInv: jsbn.BigInteger; + decrypt(data: Bytes, scheme?: EncryptionScheme, schemeOptions?: any): Bytes; + sign(md: md.MessageDigest | Bytes, scheme?: SignatureScheme): Bytes; + } + + interface KeyPair { + publicKey: PublicKey; + privateKey: PrivateKey; + } + + interface GenerateKeyPairOptions { + bits?: number | undefined; + e?: number | undefined; + workerScript?: string | undefined; + workers?: number | undefined; + workLoad?: number | undefined; + prng?: any; + algorithm?: string | undefined; + } + + function setPublicKey(n: jsbn.BigInteger, e: jsbn.BigInteger): PublicKey; + + function setPrivateKey( + n: jsbn.BigInteger, + e: jsbn.BigInteger, + d: jsbn.BigInteger, + p: jsbn.BigInteger, + q: jsbn.BigInteger, + dP: jsbn.BigInteger, + dQ: jsbn.BigInteger, + qInv: jsbn.BigInteger, + ): PrivateKey; + + function generateKeyPair( + bits?: number, + e?: number, + callback?: (err: Error, keypair: KeyPair) => void, + ): KeyPair; + function generateKeyPair( + options?: GenerateKeyPairOptions, + callback?: (err: Error, keypair: KeyPair) => void, + ): KeyPair; + } + + namespace ed25519 { + type NativeBuffer = Buffer | Uint8Array; + type Key = NativeBuffer; + + type ToNativeBufferParameters = + | { + md: md.MessageDigest; + } + | { + message: NativeBuffer | util.ByteBuffer; + } + | { + message: string; + encoding: "binary" | "utf8"; + }; + + // `string`s will be converted by toNativeBuffer with `encoding: 'binary'` + type BinaryBuffer = NativeBuffer | util.ByteBuffer | string; + + namespace constants { + const PUBLIC_KEY_BYTE_LENGTH = 32; + const PRIVATE_KEY_BYTE_LENGTH = 64; + const SEED_BYTE_LENGTH = 32; + const SIGN_BYTE_LENGTH = 64; + const HASH_BYTE_LENGTH = 64; + } + + // generateKeyPair does not currently accept `util.ByteBuffer` as the seed. + function generateKeyPair(options?: { seed?: NativeBuffer | string | undefined }): { + publicKey: NativeBuffer; + privateKey: NativeBuffer; + }; + + function privateKeyFromAsn1(obj: asn1.Asn1): { privateKeyBytes: NativeBuffer }; + + function publicKeyFromAsn1(obj: asn1.Asn1): NativeBuffer; + + function publicKeyFromPrivateKey(options: { privateKey: BinaryBuffer }): NativeBuffer; + + function sign( + options: ToNativeBufferParameters & { + privateKey: BinaryBuffer; + }, + ): NativeBuffer; + + function verify( + options: ToNativeBufferParameters & { + signature: BinaryBuffer; + publicKey: BinaryBuffer; + }, + ): boolean; + } + + interface CertificateFieldOptions { + name?: string | undefined; + type?: string | undefined; + shortName?: string | undefined; + } + + interface CertificateField extends CertificateFieldOptions { + valueConstructed?: boolean | undefined; + valueTagClass?: asn1.Class | undefined; + value?: any[] | string | undefined; + extensions?: any[] | undefined; + } + + interface Certificate { + version: number; + serialNumber: string; + signatureOid: string; + signature: any; + siginfo: { + algorithmOid: string; + parameters: any; + }; + validity: { + notBefore: Date; + notAfter: Date; + }; + issuer: { + getField(sn: string | CertificateFieldOptions): any; + addField(attr: CertificateField): void; + attributes: CertificateField[]; + hash: any; + }; + subject: { + getField(sn: string | CertificateFieldOptions): any; + addField(attr: CertificateField): void; + attributes: CertificateField[]; + hash: any; + }; + extensions: any[]; + privateKey: PrivateKey; + publicKey: PublicKey; + md: md.MessageDigest; + signatureParameters: any; + tbsCertificate: asn1.Asn1; + /** + * Sets the subject of this certificate. + * + * @param attrs the array of subject attributes to use. + * @param uniqueId an optional a unique ID to use. + */ + setSubject(attrs: CertificateField[], uniqueId?: string): void; + /** + * Sets the issuer of this certificate. + * + * @param attrs the array of subject attributes to use. + * @param uniqueId an optional a unique ID to use. + */ + setIssuer(attrs: CertificateField[], uniqueId?: string): void; + /** + * Sets the extensions of this certificate. + * + * @param exts the array of extensions to use. + */ + setExtensions(exts: any[]): void; + /** + * Gets an extension by its name or id. + * + * @param options the name to use or an object with: + * name the name to use. + * id the id to use. + * + * @return the extension or null if not found. + */ + getExtension(options: string | { name: string } | { id: number }): {} | undefined; + + /** + * Signs this certificate using the given private key. + * + * @param key the private key to sign with. + * @param md the message digest object to use (defaults to forge.md.sha1). + */ + sign(key: pki.PrivateKey, md?: md.MessageDigest): void; + /** + * Attempts verify the signature on the passed certificate using this + * certificate's public key. + * + * @param child the certificate to verify. + * + * @return true if verified, false if not. + */ + verify(child: Certificate): boolean; + + /** + * Returns true if this certificate's issuer matches the passed + * certificate's subject. Note that no signature check is performed. + * + * @param parent the certificate to check. + * + * @return true if this certificate's issuer matches the passed certificate's + * subject. + */ + isIssuer(parent: Certificate): boolean; + + /** + * Returns true if this certificate's subject matches the issuer of the + * given certificate). Note that not signature check is performed. + * + * @param child the certificate to check. + * + * @return true if this certificate's subject matches the passed + * certificate's issuer. + */ + issued(child: Certificate): boolean; + + /** + * Generates the subjectKeyIdentifier for this certificate as byte buffer. + * + * @return the subjectKeyIdentifier for this certificate as byte buffer. + */ + generateSubjectKeyIdentifier(): util.ByteStringBuffer; + + /** + * Verifies the subjectKeyIdentifier extension value for this certificate + * against its public key. If no extension is found, false will be + * returned. + * + * @return true if verified, false if not. + */ + verifySubjectKeyIdentifier(): boolean; + } + + interface CertificateRequest extends Certificate { + /** + * Gets an issuer or subject attribute from its name, type, or short name. + * + * @param opts a short name string or an object with: + * shortName the short name for the attribute. + * name the name for the attribute. + * type the type for the attribute. + * + * @return the attribute. + */ + getAttribute(opts: string | GetAttributeOpts): Attribute | null; + } + + /** + * Attribute members to search on; any one hit will return the attribute + */ + interface GetAttributeOpts { + /** + * OID + */ + type?: string | undefined; + /** + * Long name + */ + name?: string | undefined; + /** + * Short name + */ + shortName?: string | undefined; + } + + interface Attribute { + /** + * e.g. challengePassword + */ + name: string; + /** + * Short name, if available (e.g. 'CN' for 'commonName') + */ + shortName?: string | undefined; + /** + * OID, e.g. '1.2.840.113549.1.9.7' + */ + type: string; + /** + * Attribute value + */ + value: any; + /** + * Attribute value data type + */ + valueTagClass: number; + /** + * Extensions + */ + extensions?: any[] | undefined; + } + + interface CAStore { + addCertificate(cert: Certificate | string): void; + hasCertificate(cert: Certificate | string): boolean; + removeCertificate(cert: Certificate | string): Certificate | null; + listAllCertificates(): pki.Certificate[]; + getIssuer(subject: Certificate): Certificate | null; + getBySubject(subject: string): Certificate | null; + } + + function certificateFromAsn1(obj: asn1.Asn1, computeHash?: boolean): Certificate; + + function certificationRequestFromAsn1(obj: asn1.Asn1, computeHash?: boolean): Certificate; + + function certificateToAsn1(cert: Certificate): asn1.Asn1; + + function certificationRequestToAsn1(cert: Certificate): asn1.Asn1; + + function decryptRsaPrivateKey(pem: PEM, passphrase?: string): rsa.PrivateKey; + + function createCertificate(): Certificate; + + function certificationRequestToPem(cert: Certificate, maxline?: number): PEM; + + function certificationRequestFromPem(pem: PEM, computeHash?: boolean, strict?: boolean): Certificate; + + function createCertificationRequest(): CertificateRequest; + + function certificateToPem(cert: Certificate, maxline?: number): PEM; + + function certificateFromPem(pem: PEM, computeHash?: boolean, strict?: boolean): Certificate; + + function createCaStore(certs?: ReadonlyArray): CAStore; + + function verifyCertificateChain( + caStore: CAStore, + chain: Certificate[], + options?: + | ((verified: boolean | string, depth: number, certs: Certificate[]) => boolean) + | { + verify?: + | ((verified: boolean | string, depth: number, certs: Certificate[]) => boolean) + | undefined; + validityCheckDate?: Date | null | undefined; + }, + ): boolean; + + function pemToDer(pem: PEM): util.ByteStringBuffer; + + function privateKeyToPem(key: PrivateKey, maxline?: number): PEM; + + function privateKeyInfoToPem(key: asn1.Asn1, maxline?: number): PEM; + + function publicKeyToPem(key: PublicKey, maxline?: number): PEM; + + function publicKeyToRSAPublicKeyPem(key: PublicKey, maxline?: number): PEM; + + function publicKeyFromPem(pem: PEM): rsa.PublicKey; + + function privateKeyFromPem(pem: PEM): rsa.PrivateKey; + + function decryptPrivateKeyInfo(obj: asn1.Asn1, password: string): asn1.Asn1; + + function encryptPrivateKeyInfo(obj: asn1.Asn1, password: string, options?: EncryptionOptions): asn1.Asn1; + + function encryptedPrivateKeyFromPem(pem: PEM): asn1.Asn1; + + function encryptedPrivateKeyToPem(obj: asn1.Asn1): PEM; + + function decryptRsaPrivateKey(pem: PEM, password: string): rsa.PrivateKey; + + function encryptRsaPrivateKey(privateKey: PrivateKey, password: string, options?: EncryptionOptions): PEM; + + function privateKeyFromAsn1(privateKey: asn1.Asn1): rsa.PrivateKey; + + function privateKeyToAsn1(privateKey: PrivateKey): asn1.Asn1; + + function publicKeyFromAsn1(publicKey: asn1.Asn1): rsa.PublicKey; + + function publicKeyToAsn1(publicKey: PublicKey): asn1.Asn1; + + function publicKeyToRSAPublicKey(publicKey: PublicKey): any; + + const setRsaPublicKey: typeof pki.rsa.setPublicKey; + + const setRsaPrivateKey: typeof pki.rsa.setPrivateKey; + + function wrapRsaPrivateKey(privateKey: asn1.Asn1): asn1.Asn1; + + function getPublicKeyFingerprint( + publicKey: PublicKey, + options?: ByteBufferFingerprintOptions, + ): util.ByteStringBuffer; + function getPublicKeyFingerprint(publicKey: PublicKey, options: HexFingerprintOptions): Hex; + function getPublicKeyFingerprint(publicKey: PublicKey, options: BinaryFingerprintOptions): Bytes; + } + + namespace random { + function getBytes(count: number, callback?: (err: Error | null, bytes: Bytes) => any): void; + function getBytesSync(count: number): Bytes; + type CB = (_: any, seed: string) => void; + interface Random { + seedFileSync: (needed: number) => string; + seedFile: (needed: number, cb: CB) => void; + } + function createInstance(): Random; + } + + namespace ssh { + interface FingerprintOptions { + /** + * @description the delimiter to use between bytes for `hex` encoded output + */ + delimiter?: string | undefined; + /** + * @description if not specified, the function will return `ByteStringBuffer` + */ + encoding?: "hex" | "binary" | undefined; + /** + * @description if not specified defaults to `md.md5` + */ + md?: md.MessageDigest | undefined; + } + + /** + * @description Encodes a private RSA key as an OpenSSH file + */ + function privateKeyToOpenSSH(privateKey: pki.PrivateKey, passphrase?: string): string; + + /** + * @description Encodes (and optionally encrypts) a private RSA key as a Putty PPK file + */ + function privateKeyToPutty(privateKey: pki.PrivateKey, passphrase?: string, comment?: string): string; + + /** + * @description Encodes a public RSA key as an OpenSSH file + */ + function publicKeyToOpenSSH(publicKey: pki.PublicKey, comment?: string): string | pki.PEM; + + /** + * @description Gets the SSH fingerprint for the given public key + */ + function getPublicKeyFingerprint( + publicKey: pki.PublicKey, + options?: FingerprintOptions, + ): util.ByteStringBuffer | Hex | string; + } + + namespace asn1 { + enum Class { + UNIVERSAL = 0x00, + APPLICATION = 0x40, + CONTEXT_SPECIFIC = 0x80, + PRIVATE = 0xc0, + } + + enum Type { + NONE = 0, + BOOLEAN = 1, + INTEGER = 2, + BITSTRING = 3, + OCTETSTRING = 4, + NULL = 5, + OID = 6, + ODESC = 7, + EXTERNAL = 8, + REAL = 9, + ENUMERATED = 10, + EMBEDDED = 11, + UTF8 = 12, + ROID = 13, + SEQUENCE = 16, + SET = 17, + PRINTABLESTRING = 19, + IA5STRING = 22, + UTCTIME = 23, + GENERALIZEDTIME = 24, + BMPSTRING = 30, + } + + interface Asn1 { + tagClass: Class; + type: Type; + constructed: boolean; + composed: boolean; + value: Bytes | Asn1[]; + } + + function create(tagClass: Class, type: Type, constructed: boolean, value: Bytes | Asn1[]): Asn1; + function fromDer(bytes: Bytes | util.ByteBuffer, strict?: boolean): Asn1; + function toDer(obj: Asn1): util.ByteBuffer; + + /** + * Converts an OID dot-separated string to a byte buffer. The byte buffer + * contains only the DER-encoded value, not any tag or length bytes. + * + * @param oid the OID dot-separated string. + * + * @return the byte buffer. + */ + function oidToDer(oid: OID): util.ByteBuffer; + + /** + * Converts a DER-encoded byte buffer to an OID dot-separated string. The + * byte buffer should contain only the DER-encoded value, not any tag or + * length bytes. + * + * @param bytes the byte buffer. + * + * @return the OID dot-separated string. + */ + function derToOid(bytes: Bytes | util.ByteBuffer): OID; + + function integerToDer(int: number): util.ByteBuffer; + function derToInteger(bytes: Bytes | util.ByteBuffer): number; + + function dateToUtcTime(date: Date | string): Bytes; + function utcTimeToDate(bytes: Bytes): Date; + + function dateToGeneralizedTime(date: Date | string): Bytes; + function generalizedTimeToDate(bytes: Bytes): Date; + } + + namespace util { + function isArray(x: any): boolean; + function isArrayBuffer(x: any): boolean; + function isArrayBufferView(x: any): boolean; + + interface ArrayBufferView { + buffer: ArrayBuffer; + byteLength: number; + } + + type ByteBuffer = ByteStringBuffer; + class ByteStringBuffer { + constructor(bytes?: Bytes | ArrayBuffer | ArrayBufferView | ByteStringBuffer); + data: string; + read: number; + length(): number; + isEmpty(): boolean; + putByte(byte: Byte): ByteStringBuffer; + fillWithByte(byte: Byte, n: number): ByteStringBuffer; + putBytes(bytes: Bytes): ByteStringBuffer; + putString(str: string): ByteStringBuffer; + putInt16(int: number): ByteStringBuffer; + putInt24(int: number): ByteStringBuffer; + putInt32(int: number): ByteStringBuffer; + putInt16Le(int: number): ByteStringBuffer; + putInt24Le(int: number): ByteStringBuffer; + putInt32Le(int: number): ByteStringBuffer; + putInt(int: number, numOfBits: number): ByteStringBuffer; + putSignedInt(int: number, numOfBits: number): ByteStringBuffer; + putBuffer(buffer: ByteStringBuffer): ByteStringBuffer; + getByte(): number; + getInt16(): number; + getInt24(): number; + getInt32(): number; + getInt16Le(): number; + getInt24Le(): number; + getInt32Le(): number; + getInt(numOfBits: number): number; + getSignedInt(numOfBits: number): number; + getBytes(count?: number): Bytes; + bytes(count?: number): Bytes; + at(index: number): Byte; + setAt(index: number, byte: number): ByteStringBuffer; + last(): Byte; + copy(): ByteStringBuffer; + compact(): ByteStringBuffer; + clear(): ByteStringBuffer; + truncate(): ByteStringBuffer; + toHex(): Hex; + toString(): string; + } + + function fillString(char: string, count: number): string; + function xorBytes(bytes1: string, bytes2: string, count: number): string; + function hexToBytes(hex: Hex): Bytes; + function bytesToHex(bytes: Bytes): Hex; + function int32ToBytes(int: number): Bytes; + function encode64(bytes: Bytes, maxline?: number): Base64; + function decode64(encoded: Base64): Bytes; + function encodeUtf8(str: string): Utf8; + function decodeUtf8(encoded: Utf8): string; + + function createBuffer(): ByteBuffer; + function createBuffer( + input: Bytes | ArrayBuffer | ArrayBufferView | ByteStringBuffer, + encoding?: Encoding, + ): ByteBuffer; + + namespace binary { + namespace raw { + function encode(x: Uint8Array): Bytes; + function decode(str: Bytes, output?: Uint8Array, offset?: number): Uint8Array; + } + namespace hex { + function encode(bytes: Bytes | ArrayBuffer | ArrayBufferView | ByteStringBuffer): Hex; + function decode(hex: Hex, output?: Uint8Array, offset?: number): Uint8Array; + } + namespace base64 { + function encode(input: Uint8Array, maxline?: number): Base64; + function decode(input: Base64, output?: Uint8Array, offset?: number): Uint8Array; + } + } + + namespace text { + namespace utf8 { + function encode(str: string, output?: Uint8Array, offset?: number): Uint8Array; + function decode(bytes: Uint8Array): Utf8; + } + namespace utf16 { + function encode(str: string, output?: Uint8Array, offset?: number): Uint8Array; + function decode(bytes: Uint8Array): string; + } + } + } + + namespace pkcs12 { + interface BagsFilter { + localKeyId?: string | undefined; + localKeyIdHex?: string | undefined; + friendlyName?: string | undefined; + bagType?: string | undefined; + } + + interface Bag { + type: string; + attributes: any; + key?: pki.PrivateKey | undefined; + cert?: pki.Certificate | undefined; + asn1: asn1.Asn1; + } + + interface Pkcs12Pfx { + version: string; + safeContents: Array<{ + encrypted: boolean; + safeBags: Bag[]; + }>; + getBags: (filter: BagsFilter) => { + [key: string]: Bag[] | undefined; + localKeyId?: Bag[] | undefined; + friendlyName?: Bag[] | undefined; + }; + getBagsByFriendlyName: (fiendlyName: string, bagType: string) => Bag[]; + getBagsByLocalKeyId: (localKeyId: string, bagType: string) => Bag[]; + } + + function pkcs12FromAsn1(obj: any, strict?: boolean, password?: string): Pkcs12Pfx; + function pkcs12FromAsn1(obj: any, password?: string): Pkcs12Pfx; + + function toPkcs12Asn1( + key: pki.PrivateKey | null, + cert: pki.Certificate | pki.Certificate[], + password: string | null, + options?: { + algorithm?: "aes128" | "aes192" | "aes256" | "3des" | undefined; + count?: number | undefined; + saltSize?: number | undefined; + useMac?: boolean | undefined; + localKeyId?: Hex | undefined; + friendlyName?: string | undefined; + generateLocalKeyId?: boolean | undefined; + }, + ): asn1.Asn1; + + function generateKey( + password: string | null | undefined, + salt: util.ByteBuffer, + id: Byte, + iter: number, + n: number, + md?: md.MessageDigest, + ): util.ByteBuffer; + } + + namespace pkcs7 { + interface PkcsSignedData { + content?: string | util.ByteBuffer | undefined; + contentInfo?: { value: any[] } | undefined; + + certificates: pki.Certificate[]; + + addCertificate(certificate: pki.Certificate | string): void; + addSigner(options: { + key: pki.rsa.PrivateKey | string; + certificate: pki.Certificate | string; + digestAlgorithm: string; + authenticatedAttributes?: Array<{ type: string; value?: string | undefined }> | undefined; + }): void; + sign(options?: { detached?: boolean | undefined }): void; + toAsn1(): asn1.Asn1; + } + + function createSignedData(): PkcsSignedData; + + interface Recipient { + version: number; + issuer: pki.CertificateField[]; + serialNumber: Hex; + encryptedContent: { + algorithm: OID; + parameter: Bytes; + content: Bytes; + }; + } + + interface PkcsEnvelopedData { + content?: string | util.ByteBuffer | undefined; + recipients: Recipient[]; + + /** + * Add (another) entity to list of recipients. + * + * @param certificate The certificate of the entity to add. + */ + addRecipient(certificate: pki.Certificate): void; + /** + * Encrypt enveloped content. + * + * This function supports two optional arguments, cipher and key, which + * can be used to influence symmetric encryption. Unless cipher is + * provided, the cipher specified in encryptedContent.algorithm is used + * (defaults to AES-256-CBC). If no key is provided, encryptedContent.key + * is (re-)used. If that one's not set, a random key will be generated + * automatically. + * + * @param [key] The key to be used for symmetric encryption. + * @param [cipher] The OID of the symmetric cipher to use. + */ + encrypt(key?: util.ByteBuffer, cipher?: OID): void; + + /** + * Find recipient by X.509 certificate's issuer and serialNumber. + * + * @param cert the certificate with the issuer to look for. + * + * @return the recipient object, or `null` if no match. + */ + findRecipient(cert: pki.Certificate): Recipient | null; + /** + * Decrypt enveloped content + * + * @param recipient The recipient object related to the private key + * @param privKey The (RSA) private key object + */ + decrypt(recipient: Recipient, privKey: pki.rsa.PrivateKey): void; + + toAsn1(): asn1.Asn1; + } + + function createEnvelopedData(): PkcsEnvelopedData; + + /** When a PKCS#7 object has been created by reading from a message, the raw captured object is joined */ + type Captured = T & { + rawCapture: any; + }; + + /** + * Converts a PKCS#7 message to PEM format. + * + * @param msg The PKCS#7 message object + * @param maxline The maximum characters per line, defaults to 64. + * + * @return The PEM-formatted PKCS#7 message. + */ + function messageToPem(msg: PkcsSignedData, maxline?: number): string; + + /** + * Converts a PKCS#7 message from PEM format. + * + * @param pem the PEM-formatted PKCS#7 message. + * + * @return the PKCS#7 message. + */ + function messageFromPem(pem: pki.PEM): Captured; + + /** + * Converts a PKCS#7 message from an ASN.1 object. + * + * @param asn the ASN.1 representation of a ContentInfo. + * + * @return the PKCS#7 message. + */ + function messageFromAsn1(asn: asn1.Asn1): Captured; + } + + namespace pkcs5 { + function pbkdf2(password: string, salt: string, iterations: number, keySize: number): string; + function pbkdf2( + password: string, + salt: string, + iterations: number, + keySize: number, + messageDigest: md.MessageDigest | md.Algorithm, + ): string; + function pbkdf2( + password: string, + salt: string, + iterations: number, + keySize: number, + callback: (err: Error | null, dk: string | null) => any, + ): void; + function pbkdf2( + password: string, + salt: string, + iterations: number, + keySize: number, + messageDigest?: md.MessageDigest | md.Algorithm, + callback?: (err: Error | null, dk: string) => any, + ): void; + } + + const md: { + sha1: { + create(): md.sha1.MessageDigest; + }; + sha256: { + create(): md.sha256.MessageDigest; + }; + sha512: { + create( + /** @default 'SHA-512' */ + algorithm?: TAlg, + ): TAlg extends md.sha512.AlgorithmSelection.Sha384 ? md.sha512.Sha384MessageDigest + : TAlg extends md.sha512.AlgorithmSelection.Sha512224 ? md.sha512.Sha512224MessageDigest + : TAlg extends md.sha512.AlgorithmSelection.Sha512256 ? md.sha512.Sha512256MessageDigest + : TAlg extends md.sha512.AlgorithmSelection.Sha512 ? md.sha512.Sha512MessageDigest + : never; + sha224: { + create(): md.sha512.Sha512224MessageDigest; + }; + sha256: { + create(): md.sha512.Sha512256MessageDigest; + }; + sha384: { + create(): md.sha512.Sha384MessageDigest; + }; + }; + sha384: typeof md.sha512.sha384; + "sha512/224": typeof md.sha512.sha224; + "sha512/256": typeof md.sha512.sha256; + md5: { + create(): md.md5.MessageDigest; + }; + algorithms: { + md5: typeof md.md5; + sha1: typeof md.sha1; + sha256: typeof md.sha256; + sha384: typeof md.sha384; + sha512: typeof md.sha512; + "sha512/224": (typeof md)["sha512/224"]; + "sha512/256": (typeof md)["sha512/256"]; + }; + }; + + const md5: typeof md.md5; + const sha1: typeof md.sha1; + const sha256: typeof md.sha256; + const sha384: typeof md.sha384; + const sha512: typeof md.sha512; + + namespace md { + type Algorithm = md5.Algorithm | sha1.Algorithm | sha256.Algorithm | sha512.Algorithm; + + interface MessageDigest { + readonly algorithm: Algorithm; + readonly blockLength: number; + readonly digestLength: number; + messageLength: number; + fullMessageLength: number[] | null; + readonly messageLengthSize: number; + update(msg: string, encoding?: Encoding): this; + digest(): util.ByteStringBuffer; + } + + namespace md5 { + type Algorithm = "md5"; + + interface MessageDigest extends md.MessageDigest { + readonly algorithm: Algorithm; + readonly blockLength: 64; + readonly digestLength: 16; + readonly messageLengthSize: 8; + } + } + + namespace sha1 { + type Algorithm = "sha1"; + + interface MessageDigest extends md.MessageDigest { + readonly algorithm: Algorithm; + readonly blockLength: 64; + readonly digestLength: 20; + readonly messageLengthSize: 8; + } + } + + namespace sha256 { + type Algorithm = "sha256"; + + interface MessageDigest extends md.MessageDigest { + readonly algorithm: Algorithm; + readonly blockLength: 64; + readonly digestLength: 32; + readonly messageLengthSize: 8; + } + } + + namespace sha512 { + type Algorithm = Algorithm.Sha384 | Algorithm.Sha512 | Algorithm.Sha512224 | Algorithm.Sha512256; + namespace Algorithm { + type Sha384 = "sha384"; + type Sha512 = "sha512"; + type Sha512224 = "sha512/224"; + type Sha512256 = "sha512/256"; + } + + type AlgorithmSelection = + | AlgorithmSelection.Sha384 + | AlgorithmSelection.Sha512 + | AlgorithmSelection.Sha512224 + | AlgorithmSelection.Sha512256; + namespace AlgorithmSelection { + type Sha384 = "SHA-384"; + type Sha512 = "SHA-512"; + type Sha512224 = "SHA-512/224"; + type Sha512256 = "SHA-512/256"; + } + + interface MessageDigest extends md.MessageDigest { + readonly algorithm: Algorithm; + readonly blockLength: 128; + readonly messageLengthSize: 16; + } + + interface Sha512224MessageDigest extends MessageDigest { + readonly algorithm: Algorithm.Sha512224; + readonly digestLength: 28; + } + + interface Sha512256MessageDigest extends MessageDigest { + readonly algorithm: Algorithm.Sha512256; + readonly digestLength: 32; + } + + interface Sha384MessageDigest extends MessageDigest { + readonly algorithm: Algorithm.Sha384; + readonly digestLength: 48; + } + + interface Sha512MessageDigest extends MessageDigest { + readonly algorithm: Algorithm.Sha512; + readonly digestLength: 64; + } + } + } + + namespace hmac { + type Algorithm = md.Algorithm; + + interface HMAC { + digest(): util.ByteBuffer; + getMac(): util.ByteBuffer; + start(md: Algorithm | md.MessageDigest, key: string | util.ByteBuffer | null): void; + update(bytes: string): void; + } + + function create(): HMAC; + } + + namespace cipher { + type Algorithm = + | "AES-ECB" + | "AES-CBC" + | "AES-CFB" + | "AES-OFB" + | "AES-CTR" + | "AES-GCM" + | "3DES-ECB" + | "3DES-CBC" + | "DES-ECB" + | "DES-CBC"; + + function createCipher(algorithm: Algorithm, payload: util.ByteBuffer | Bytes): BlockCipher; + function createDecipher(algorithm: Algorithm, payload: util.ByteBuffer | Bytes): BlockCipher; + + interface StartOptions { + iv?: util.ByteBuffer | Byte[] | Bytes | undefined; + tag?: util.ByteStringBuffer | undefined; + tagLength?: number | undefined; + additionalData?: string | undefined; + } + + interface BlockCipher { + start: (options?: StartOptions) => void; + update: (payload: util.ByteBuffer) => void; + finish: () => boolean; + output: util.ByteStringBuffer; + mode: Mode; + } + + interface Mode { + tag: util.ByteStringBuffer; + } + } + + namespace pss { + type PSS = any; + + function create(any: any): PSS; + } + + namespace mgf { + namespace mgf1 { + function create(any: any): any; + } + } + + namespace tls { + interface ProtocolVersion { + major: Byte; + minor: Byte; + } + + const Versions: ProtocolVersion[]; + const SupportedVersions: ProtocolVersion[]; + const Version: ProtocolVersion; + + const MaxFragment: number; + + enum ConnectionEnd { + server = 0, + client = 1, + } + + enum PRFAlgorithm { + tls_prf_sha256 = 0, + } + + enum BulkCipherAlgorithm { + rc4 = 0, + des3 = 1, + aes = 2, + } + + enum CipherType { + stream = 0, + block = 1, + aead = 2, + } + + enum MACAlgorithm { + hmac_md5 = 0, + hmac_sha1 = 1, + hmac_sha256 = 2, + hmac_sha384 = 3, + hmac_sha512 = 4, + } + + enum CompressionMethod { + none = 0, + deflate = 1, + } + + enum ContentType { + change_cipher_spec = 20, + alert = 21, + handshake = 22, + application_data = 23, + heartbeat = 24, + } + + enum HandshakeType { + hello_request = 0, + client_hello = 1, + server_hello = 2, + certificate = 11, + server_key_exchange = 12, + certificate_request = 13, + server_hello_done = 14, + certificate_verify = 15, + client_key_exchange = 16, + finished = 20, + } + + namespace Alert { + enum Level { + warning = 1, + fatal = 2, + } + + enum Description { + close_notify = 0, + unexpected_message = 10, + bad_record_mac = 20, + decryption_failed = 21, + record_overflow = 22, + decompression_failure = 30, + handshake_failure = 40, + bad_certificate = 42, + unsupported_certificate = 43, + certificate_revoked = 44, + certificate_expired = 45, + certificate_unknown = 46, + illegal_parameter = 47, + unknown_ca = 48, + access_denied = 49, + decode_error = 50, + decrypt_error = 51, + export_restriction = 60, + protocol_version = 70, + insufficient_security = 71, + internal_error = 80, + user_canceled = 90, + no_renegotiation = 100, + } + } + + enum HeartbeatMessageType { + heartbeat_request = 1, + heartbeat_response = 2, + } + + interface CipherSuite { + id: [Byte, Byte]; + name: string; + } + + const CipherSuites: { [name: string]: CipherSuite }; + + interface CertificateRequest { + certificate_types: util.ByteBuffer; + certificate_authorities: util.ByteBuffer; + } + + type ConnectionState = any; + + interface Connection { + version: ProtocolVersion; + entity: ConnectionEnd; + sessionId: Bytes | null; + caStore: pki.CAStore; + sessionCache: SessionCache | null; + cipherSuites: CipherSuite[]; + connected(conn: Connection): void; + virtualHost: string | null; + verifyClient: boolean; + verify(conn: Connection, verified: Verified, depth: number, certs: pki.Certificate[]): Verified; + getCertificate: + | ((conn: Connection, hint: CertificateRequest | string[]) => pki.PEM | readonly pki.PEM[]) + | null; + getPrivateKey: ((conn: Connection, certificate: pki.Certificate) => pki.PEM) | null; + getSignature: + | ((conn: Connection, bytes: Bytes, callback: (conn: Connection, bytes: Bytes) => void) => void) + | null; + input: util.ByteBuffer; + tlsData: util.ByteBuffer; + data: util.ByteBuffer; + tlsDataReady(conn: Connection): void; + dataReady(conn: Connection): void; + heartbeatReceived: ((conn: Connection, payload: util.ByteBuffer) => void) | undefined; + closed(conn: Connection): void; + error(conn: Connection, error: TLSError): void; + deflate: ((inBytes: Bytes) => Bytes) | null; + inflate: ((inBytes: Bytes) => Bytes) | null; + reset(clearFail?: boolean): void; + record: Record | null; + session: Session | null; + peerCertificate: pki.Certificate | null; + state: { pending: ConnectionState | null; current: ConnectionState }; + expect: number; + fragmented: Record | null; + records: Record[]; + open: boolean; + handshakes: number; + handshaking: boolean; + isConnected: boolean; + fail: boolean; + handshake(sessionId?: Bytes | null): void; + process(data: Bytes): number; + prepare(data: Bytes): boolean; + prepareHeartbeatRequest(payload: Bytes | util.ByteBuffer, payloadLength?: number): boolean; + close(clearFail?: boolean): Connection; + } + + interface Record { + type: ContentType; + version: ProtocolVersion; + length: number; + fragment: util.ByteBuffer; + ready?: boolean | undefined; + } + + interface Session { + version: ProtocolVersion | null; + extensions: { [_: string]: object }; + cipherSuite: CipherSuite | null; + compressionMethod: CompressionMethod | null; + serverCertificate: pki.Certificate | null; + clientCertificate: pki.Certificate | null; + md5: md.MessageDigest; + sha1: md.MessageDigest; + } + + interface SessionCache { + cache: { [key: string]: Session }; + capacity: number; + order: [Hex]; + getSession(sessionId: Bytes): Session; + setSession(sessionId: Bytes, session: Session): void; + } + + function createSessionCache(cache?: SessionCache | { [key: string]: Session }, capacity?: number): SessionCache; + + interface Alert { + level: Alert.Level; + description: Alert.Description; + } + + interface TLSError extends Error { + message: string; + send: boolean; + origin: "server" | "client"; + alert: Alert; + } + + type Verified = true | { message?: string | undefined; alert?: Alert.Description | undefined }; + + function createConnection(options: { + server?: boolean | undefined; + sessionId?: Bytes | null | undefined; + caStore?: pki.CAStore | readonly pki.Certificate[] | undefined; + sessionCache?: SessionCache | { [key: string]: Session } | undefined; + cipherSuites?: CipherSuite[] | undefined; + connected(conn: Connection): void; + virtualHost?: string | undefined; + verifyClient?: boolean | undefined; + verify?(conn: Connection, verified: Verified, depth: number, certs: pki.Certificate[]): Verified; + getCertificate?(conn: Connection, hint: CertificateRequest | string[]): pki.PEM | readonly pki.PEM[]; + getPrivateKey?(conn: Connection, certificate: pki.Certificate): pki.PEM; + getSignature?(conn: Connection, bytes: Bytes, callback: (conn: Connection, bytes: Bytes) => void): void; + tlsDataReady(conn: Connection): void; + dataReady(conn: Connection): void; + heartbeatReceived?(conn: Connection, payload: util.ByteBuffer): void; + closed(conn: Connection): void; + error(conn: Connection, error: TLSError): void; + deflate?(inBytes: Bytes): Bytes; + inflate?(inBytes: Bytes): Bytes; + }): Connection; + + function prf_tls1(secret: string, label: string, seed: string, length: number): util.ByteBuffer; + + function hmac_sha1( + key: string | readonly Byte[] | util.ByteBuffer, + seqNum: [number, number], + record: Record, + ): Bytes; + } +} diff --git a/node_modules/@types/node-forge/package.json b/node_modules/@types/node-forge/package.json new file mode 100644 index 0000000000000000000000000000000000000000..c2c655fc2dea38f491e6196cd55c37fa179021c4 --- /dev/null +++ b/node_modules/@types/node-forge/package.json @@ -0,0 +1,107 @@ +{ + "name": "@types/node-forge", + "version": "1.3.10", + "description": "TypeScript definitions for node-forge", + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-forge", + "license": "MIT", + "contributors": [ + { + "name": "Seth Westphal ", + "githubUsername": "westy92", + "url": "https://github.com/westy92" + }, + { + "name": "Kay Schecker ", + "githubUsername": "flynetworks", + "url": "https://github.com/flynetworks" + }, + { + "name": "Aakash Goenka ", + "githubUsername": "a-k-g", + "url": "https://github.com/a-k-g" + }, + { + "name": "Rafal2228 ", + "githubUsername": "rafal2228", + "url": "https://github.com/rafal2228" + }, + { + "name": "Beeno Tung ", + "githubUsername": "beenotung", + "url": "https://github.com/beenotung" + }, + { + "name": "Joe Flateau ", + "githubUsername": "joeflateau", + "url": "https://github.com/joeflateau" + }, + { + "name": "timhwang21 ", + "githubUsername": "timhwang21", + "url": "https://github.com/timhwang21" + }, + { + "name": "Anders Kaseorg ", + "githubUsername": "andersk", + "url": "https://github.com/andersk" + }, + { + "name": "Sascha Zarhuber ", + "githubUsername": "saschazar21", + "url": "https://github.com/saschazar21" + }, + { + "name": "Rogier Schouten ", + "githubUsername": "rogierschouten", + "url": "https://github.com/rogierschouten" + }, + { + "name": "Ivan Aseev ", + "githubUsername": "aseevia", + "url": "https://github.com/aseevia" + }, + { + "name": "Wiktor Kwapisiewicz", + "githubUsername": "wiktor-k", + "url": "https://github.com/wiktor-k" + }, + { + "name": "Ligia Frangello ", + "githubUsername": "frangello", + "url": "https://github.com/frangello" + }, + { + "name": "Dmitry Avezov ", + "githubUsername": "avezov", + "url": "https://github.com/avezov" + }, + { + "name": "Jose Fuentes ", + "githubUsername": "j-fuentes", + "url": "https://github.com/j-fuentes" + }, + { + "name": "Anya Reyes ", + "githubUsername": "darkade", + "url": "https://github.com/darkade" + }, + { + "name": "BendingBender ", + "githubUsername": "BendingBender", + "url": "https://github.com/BendingBender" + } + ], + "main": "", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "directory": "types/node-forge" + }, + "scripts": {}, + "dependencies": { + "@types/node": "*" + }, + "typesPublisherContentHash": "a180a64b863d76f135e272767df6eb149228c12ea1efffb145eeb779563c500d", + "typeScriptVersion": "4.5" +} \ No newline at end of file diff --git a/node_modules/@types/node/LICENSE b/node_modules/@types/node/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..9e841e7a26e4eb057b24511e7b92d42b257a80e5 --- /dev/null +++ b/node_modules/@types/node/LICENSE @@ -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 diff --git a/node_modules/@types/node/README.md b/node_modules/@types/node/README.md new file mode 100644 index 0000000000000000000000000000000000000000..cd7df58fd501c90da8402084712e4b239e24fe17 --- /dev/null +++ b/node_modules/@types/node/README.md @@ -0,0 +1,15 @@ +# Installation +> `npm install --save @types/node` + +# Summary +This package contains type definitions for node (https://nodejs.org/). + +# Details +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node. + +### Additional Details + * Last updated: Wed, 29 Nov 2023 19:35:57 GMT + * Dependencies: [undici-types](https://npmjs.com/package/undici-types) + +# Credits +These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky). diff --git a/node_modules/@types/node/assert.d.ts b/node_modules/@types/node/assert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd821433575b42840106da9995aaaec26eb0edc7 --- /dev/null +++ b/node_modules/@types/node/assert.d.ts @@ -0,0 +1,996 @@ +/** + * The `node:assert` module provides a set of assertion functions for verifying + * invariants. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js) + */ +declare module "assert" { + /** + * An alias of {@link ok}. + * @since v0.5.9 + * @param value The input that is checked for being truthy. + */ + function assert(value: unknown, message?: string | Error): asserts value; + namespace assert { + /** + * Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class. + */ + class AssertionError extends Error { + /** + * Set to the `actual` argument for methods such as {@link assert.strictEqual()}. + */ + actual: unknown; + /** + * Set to the `expected` argument for methods such as {@link assert.strictEqual()}. + */ + expected: unknown; + /** + * Set to the passed in operator value. + */ + operator: string; + /** + * Indicates if the message was auto-generated (`true`) or not. + */ + generatedMessage: boolean; + /** + * Value is always `ERR_ASSERTION` to show that the error is an assertion error. + */ + code: "ERR_ASSERTION"; + constructor(options?: { + /** If provided, the error message is set to this value. */ + message?: string | undefined; + /** The `actual` property on the error instance. */ + actual?: unknown | undefined; + /** The `expected` property on the error instance. */ + expected?: unknown | undefined; + /** The `operator` property on the error instance. */ + operator?: string | undefined; + /** If provided, the generated stack trace omits frames before this function. */ + // eslint-disable-next-line @typescript-eslint/ban-types + stackStartFn?: Function | undefined; + }); + } + /** + * This feature is deprecated and will be removed in a future version. + * Please consider using alternatives such as the `mock` helper function. + * @since v14.2.0, v12.19.0 + * @deprecated Deprecated + */ + class CallTracker { + /** + * The wrapper function is expected to be called exactly `exact` times. If the + * function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an + * error. + * + * ```js + * import assert from 'node:assert'; + * + * // Creates call tracker. + * const tracker = new assert.CallTracker(); + * + * function func() {} + * + * // Returns a function that wraps func() that must be called exact times + * // before tracker.verify(). + * const callsfunc = tracker.calls(func); + * ``` + * @since v14.2.0, v12.19.0 + * @param [fn='A no-op function'] + * @param [exact=1] + * @return that wraps `fn`. + */ + calls(exact?: number): () => void; + calls any>(fn?: Func, exact?: number): Func; + /** + * Example: + * + * ```js + * import assert from 'node:assert'; + * + * const tracker = new assert.CallTracker(); + * + * function func() {} + * const callsfunc = tracker.calls(func); + * callsfunc(1, 2, 3); + * + * assert.deepStrictEqual(tracker.getCalls(callsfunc), + * [{ thisArg: undefined, arguments: [1, 2, 3] }]); + * ``` + * @since v18.8.0, v16.18.0 + * @param fn + * @return An Array with all the calls to a tracked function. + */ + getCalls(fn: Function): CallTrackerCall[]; + /** + * The arrays contains information about the expected and actual number of calls of + * the functions that have not been called the expected number of times. + * + * ```js + * import assert from 'node:assert'; + * + * // Creates call tracker. + * const tracker = new assert.CallTracker(); + * + * function func() {} + * + * // Returns a function that wraps func() that must be called exact times + * // before tracker.verify(). + * const callsfunc = tracker.calls(func, 2); + * + * // Returns an array containing information on callsfunc() + * console.log(tracker.report()); + * // [ + * // { + * // message: 'Expected the func function to be executed 2 time(s) but was + * // executed 0 time(s).', + * // actual: 0, + * // expected: 2, + * // operator: 'func', + * // stack: stack trace + * // } + * // ] + * ``` + * @since v14.2.0, v12.19.0 + * @return An Array of objects containing information about the wrapper functions returned by `calls`. + */ + report(): CallTrackerReportInformation[]; + /** + * Reset calls of the call tracker. + * If a tracked function is passed as an argument, the calls will be reset for it. + * If no arguments are passed, all tracked functions will be reset. + * + * ```js + * import assert from 'node:assert'; + * + * const tracker = new assert.CallTracker(); + * + * function func() {} + * const callsfunc = tracker.calls(func); + * + * callsfunc(); + * // Tracker was called once + * assert.strictEqual(tracker.getCalls(callsfunc).length, 1); + * + * tracker.reset(callsfunc); + * assert.strictEqual(tracker.getCalls(callsfunc).length, 0); + * ``` + * @since v18.8.0, v16.18.0 + * @param fn a tracked function to reset. + */ + reset(fn?: Function): void; + /** + * Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that + * have not been called the expected number of times. + * + * ```js + * import assert from 'node:assert'; + * + * // Creates call tracker. + * const tracker = new assert.CallTracker(); + * + * function func() {} + * + * // Returns a function that wraps func() that must be called exact times + * // before tracker.verify(). + * const callsfunc = tracker.calls(func, 2); + * + * callsfunc(); + * + * // Will throw an error since callsfunc() was only called once. + * tracker.verify(); + * ``` + * @since v14.2.0, v12.19.0 + */ + verify(): void; + } + interface CallTrackerCall { + thisArg: object; + arguments: unknown[]; + } + interface CallTrackerReportInformation { + message: string; + /** The actual number of times the function was called. */ + actual: number; + /** The number of times the function was expected to be called. */ + expected: number; + /** The name of the function that is wrapped. */ + operator: string; + /** A stack trace of the function. */ + stack: object; + } + type AssertPredicate = RegExp | (new() => object) | ((thrown: unknown) => boolean) | object | Error; + /** + * Throws an `AssertionError` with the provided error message or a default + * error message. If the `message` parameter is an instance of an `Error` then + * it will be thrown instead of the `AssertionError`. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.fail(); + * // AssertionError [ERR_ASSERTION]: Failed + * + * assert.fail('boom'); + * // AssertionError [ERR_ASSERTION]: boom + * + * assert.fail(new TypeError('need array')); + * // TypeError: need array + * ``` + * + * Using `assert.fail()` with more than two arguments is possible but deprecated. + * See below for further details. + * @since v0.1.21 + * @param [message='Failed'] + */ + function fail(message?: string | Error): never; + /** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */ + function fail( + actual: unknown, + expected: unknown, + message?: string | Error, + operator?: string, + // eslint-disable-next-line @typescript-eslint/ban-types + stackStartFn?: Function, + ): never; + /** + * Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`. + * + * If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default + * error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`. + * If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``. + * + * Be aware that in the `repl` the error message will be different to the one + * thrown in a file! See below for further details. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.ok(true); + * // OK + * assert.ok(1); + * // OK + * + * assert.ok(); + * // AssertionError: No value argument passed to `assert.ok()` + * + * assert.ok(false, 'it\'s false'); + * // AssertionError: it's false + * + * // In the repl: + * assert.ok(typeof 123 === 'string'); + * // AssertionError: false == true + * + * // In a file (e.g. test.js): + * assert.ok(typeof 123 === 'string'); + * // AssertionError: The expression evaluated to a falsy value: + * // + * // assert.ok(typeof 123 === 'string') + * + * assert.ok(false); + * // AssertionError: The expression evaluated to a falsy value: + * // + * // assert.ok(false) + * + * assert.ok(0); + * // AssertionError: The expression evaluated to a falsy value: + * // + * // assert.ok(0) + * ``` + * + * ```js + * import assert from 'node:assert/strict'; + * + * // Using `assert()` works the same: + * assert(0); + * // AssertionError: The expression evaluated to a falsy value: + * // + * // assert(0) + * ``` + * @since v0.1.21 + */ + function ok(value: unknown, message?: string | Error): asserts value; + /** + * **Strict assertion mode** + * + * An alias of {@link strictEqual}. + * + * **Legacy assertion mode** + * + * > Stability: 3 - Legacy: Use {@link strictEqual} instead. + * + * Tests shallow, coercive equality between the `actual` and `expected` parameters + * using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled + * and treated as being identical if both sides are `NaN`. + * + * ```js + * import assert from 'node:assert'; + * + * assert.equal(1, 1); + * // OK, 1 == 1 + * assert.equal(1, '1'); + * // OK, 1 == '1' + * assert.equal(NaN, NaN); + * // OK + * + * assert.equal(1, 2); + * // AssertionError: 1 == 2 + * assert.equal({ a: { b: 1 } }, { a: { b: 1 } }); + * // AssertionError: { a: { b: 1 } } == { a: { b: 1 } } + * ``` + * + * If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default + * error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`. + * @since v0.1.21 + */ + function equal(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * **Strict assertion mode** + * + * An alias of {@link notStrictEqual}. + * + * **Legacy assertion mode** + * + * > Stability: 3 - Legacy: Use {@link notStrictEqual} instead. + * + * Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is + * specially handled and treated as being identical if both sides are `NaN`. + * + * ```js + * import assert from 'node:assert'; + * + * assert.notEqual(1, 2); + * // OK + * + * assert.notEqual(1, 1); + * // AssertionError: 1 != 1 + * + * assert.notEqual(1, '1'); + * // AssertionError: 1 != '1' + * ``` + * + * If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error + * message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`. + * @since v0.1.21 + */ + function notEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * **Strict assertion mode** + * + * An alias of {@link deepStrictEqual}. + * + * **Legacy assertion mode** + * + * > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead. + * + * Tests for deep equality between the `actual` and `expected` parameters. Consider + * using {@link deepStrictEqual} instead. {@link deepEqual} can have + * surprising results. + * + * _Deep equality_ means that the enumerable "own" properties of child objects + * are also recursively evaluated by the following rules. + * @since v0.1.21 + */ + function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * **Strict assertion mode** + * + * An alias of {@link notDeepStrictEqual}. + * + * **Legacy assertion mode** + * + * > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead. + * + * Tests for any deep inequality. Opposite of {@link deepEqual}. + * + * ```js + * import assert from 'node:assert'; + * + * const obj1 = { + * a: { + * b: 1, + * }, + * }; + * const obj2 = { + * a: { + * b: 2, + * }, + * }; + * const obj3 = { + * a: { + * b: 1, + * }, + * }; + * const obj4 = { __proto__: obj1 }; + * + * assert.notDeepEqual(obj1, obj1); + * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } + * + * assert.notDeepEqual(obj1, obj2); + * // OK + * + * assert.notDeepEqual(obj1, obj3); + * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } + * + * assert.notDeepEqual(obj1, obj4); + * // OK + * ``` + * + * If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default + * error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown + * instead of the `AssertionError`. + * @since v0.1.21 + */ + function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * Tests strict equality between the `actual` and `expected` parameters as + * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.strictEqual(1, 2); + * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal: + * // + * // 1 !== 2 + * + * assert.strictEqual(1, 1); + * // OK + * + * assert.strictEqual('Hello foobar', 'Hello World!'); + * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal: + * // + actual - expected + * // + * // + 'Hello foobar' + * // - 'Hello World!' + * // ^ + * + * const apples = 1; + * const oranges = 2; + * assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`); + * // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2 + * + * assert.strictEqual(1, '1', new TypeError('Inputs are not identical')); + * // TypeError: Inputs are not identical + * ``` + * + * If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a + * default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown + * instead of the `AssertionError`. + * @since v0.1.21 + */ + function strictEqual(actual: unknown, expected: T, message?: string | Error): asserts actual is T; + /** + * Tests strict inequality between the `actual` and `expected` parameters as + * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.notStrictEqual(1, 2); + * // OK + * + * assert.notStrictEqual(1, 1); + * // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to: + * // + * // 1 + * + * assert.notStrictEqual(1, '1'); + * // OK + * ``` + * + * If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a + * default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown + * instead of the `AssertionError`. + * @since v0.1.21 + */ + function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * Tests for deep equality between the `actual` and `expected` parameters. + * "Deep" equality means that the enumerable "own" properties of child objects + * are recursively evaluated also by the following rules. + * @since v1.2.0 + */ + function deepStrictEqual(actual: unknown, expected: T, message?: string | Error): asserts actual is T; + /** + * Tests for deep strict inequality. Opposite of {@link deepStrictEqual}. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.notDeepStrictEqual({ a: 1 }, { a: '1' }); + * // OK + * ``` + * + * If the values are deeply and strictly equal, an `AssertionError` is thrown + * with a `message` property set equal to the value of the `message` parameter. If + * the `message` parameter is undefined, a default error message is assigned. If + * the `message` parameter is an instance of an `Error` then it will be thrown + * instead of the `AssertionError`. + * @since v1.2.0 + */ + function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * Expects the function `fn` to throw an error. + * + * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function, + * a validation object where each property will be tested for strict deep equality, + * or an instance of error where each property will be tested for strict deep + * equality including the non-enumerable `message` and `name` properties. When + * using an object, it is also possible to use a regular expression, when + * validating against a string property. See below for examples. + * + * If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation + * fails. + * + * Custom validation object/error instance: + * + * ```js + * import assert from 'node:assert/strict'; + * + * const err = new TypeError('Wrong value'); + * err.code = 404; + * err.foo = 'bar'; + * err.info = { + * nested: true, + * baz: 'text', + * }; + * err.reg = /abc/i; + * + * assert.throws( + * () => { + * throw err; + * }, + * { + * name: 'TypeError', + * message: 'Wrong value', + * info: { + * nested: true, + * baz: 'text', + * }, + * // Only properties on the validation object will be tested for. + * // Using nested objects requires all properties to be present. Otherwise + * // the validation is going to fail. + * }, + * ); + * + * // Using regular expressions to validate error properties: + * assert.throws( + * () => { + * throw err; + * }, + * { + * // The `name` and `message` properties are strings and using regular + * // expressions on those will match against the string. If they fail, an + * // error is thrown. + * name: /^TypeError$/, + * message: /Wrong/, + * foo: 'bar', + * info: { + * nested: true, + * // It is not possible to use regular expressions for nested properties! + * baz: 'text', + * }, + * // The `reg` property contains a regular expression and only if the + * // validation object contains an identical regular expression, it is going + * // to pass. + * reg: /abc/i, + * }, + * ); + * + * // Fails due to the different `message` and `name` properties: + * assert.throws( + * () => { + * const otherErr = new Error('Not found'); + * // Copy all enumerable properties from `err` to `otherErr`. + * for (const [key, value] of Object.entries(err)) { + * otherErr[key] = value; + * } + * throw otherErr; + * }, + * // The error's `message` and `name` properties will also be checked when using + * // an error as validation object. + * err, + * ); + * ``` + * + * Validate instanceof using constructor: + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.throws( + * () => { + * throw new Error('Wrong value'); + * }, + * Error, + * ); + * ``` + * + * Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions): + * + * Using a regular expression runs `.toString` on the error object, and will + * therefore also include the error name. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.throws( + * () => { + * throw new Error('Wrong value'); + * }, + * /^Error: Wrong value$/, + * ); + * ``` + * + * Custom error validation: + * + * The function must return `true` to indicate all internal validations passed. + * It will otherwise fail with an `AssertionError`. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.throws( + * () => { + * throw new Error('Wrong value'); + * }, + * (err) => { + * assert(err instanceof Error); + * assert(/value/.test(err)); + * // Avoid returning anything from validation functions besides `true`. + * // Otherwise, it's not clear what part of the validation failed. Instead, + * // throw an error about the specific validation that failed (as done in this + * // example) and add as much helpful debugging information to that error as + * // possible. + * return true; + * }, + * 'unexpected error', + * ); + * ``` + * + * `error` cannot be a string. If a string is provided as the second + * argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same + * message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using + * a string as the second argument gets considered: + * + * ```js + * import assert from 'node:assert/strict'; + * + * function throwingFirst() { + * throw new Error('First'); + * } + * + * function throwingSecond() { + * throw new Error('Second'); + * } + * + * function notThrowing() {} + * + * // The second argument is a string and the input function threw an Error. + * // The first case will not throw as it does not match for the error message + * // thrown by the input function! + * assert.throws(throwingFirst, 'Second'); + * // In the next example the message has no benefit over the message from the + * // error and since it is not clear if the user intended to actually match + * // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error. + * assert.throws(throwingSecond, 'Second'); + * // TypeError [ERR_AMBIGUOUS_ARGUMENT] + * + * // The string is only used (as message) in case the function does not throw: + * assert.throws(notThrowing, 'Second'); + * // AssertionError [ERR_ASSERTION]: Missing expected exception: Second + * + * // If it was intended to match for the error message do this instead: + * // It does not throw because the error messages match. + * assert.throws(throwingSecond, /Second$/); + * + * // If the error message does not match, an AssertionError is thrown. + * assert.throws(throwingFirst, /Second$/); + * // AssertionError [ERR_ASSERTION] + * ``` + * + * Due to the confusing error-prone notation, avoid a string as the second + * argument. + * @since v0.1.21 + */ + function throws(block: () => unknown, message?: string | Error): void; + function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void; + /** + * Asserts that the function `fn` does not throw an error. + * + * Using `assert.doesNotThrow()` is actually not useful because there + * is no benefit in catching an error and then rethrowing it. Instead, consider + * adding a comment next to the specific code path that should not throw and keep + * error messages as expressive as possible. + * + * When `assert.doesNotThrow()` is called, it will immediately call the `fn`function. + * + * If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a + * different type, or if the `error` parameter is undefined, the error is + * propagated back to the caller. + * + * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation + * function. See {@link throws} for more details. + * + * The following, for instance, will throw the `TypeError` because there is no + * matching error type in the assertion: + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * SyntaxError, + * ); + * ``` + * + * However, the following will result in an `AssertionError` with the message + * 'Got unwanted exception...': + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * TypeError, + * ); + * ``` + * + * If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message: + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * /Wrong value/, + * 'Whoops', + * ); + * // Throws: AssertionError: Got unwanted exception: Whoops + * ``` + * @since v0.1.21 + */ + function doesNotThrow(block: () => unknown, message?: string | Error): void; + function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void; + /** + * Throws `value` if `value` is not `undefined` or `null`. This is useful when + * testing the `error` argument in callbacks. The stack trace contains all frames + * from the error passed to `ifError()` including the potential new frames for`ifError()` itself. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.ifError(null); + * // OK + * assert.ifError(0); + * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0 + * assert.ifError('error'); + * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error' + * assert.ifError(new Error()); + * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error + * + * // Create some random error frames. + * let err; + * (function errorFrame() { + * err = new Error('test error'); + * })(); + * + * (function ifErrorFrame() { + * assert.ifError(err); + * })(); + * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error + * // at ifErrorFrame + * // at errorFrame + * ``` + * @since v0.1.97 + */ + function ifError(value: unknown): asserts value is null | undefined; + /** + * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately + * calls the function and awaits the returned promise to complete. It will then + * check that the promise is rejected. + * + * If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the + * function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error + * handler is skipped. + * + * Besides the async nature to await the completion behaves identically to {@link throws}. + * + * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function, + * an object where each property will be tested for, or an instance of error where + * each property will be tested for including the non-enumerable `message` and`name` properties. + * + * If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject. + * + * ```js + * import assert from 'node:assert/strict'; + * + * await assert.rejects( + * async () => { + * throw new TypeError('Wrong value'); + * }, + * { + * name: 'TypeError', + * message: 'Wrong value', + * }, + * ); + * ``` + * + * ```js + * import assert from 'node:assert/strict'; + * + * await assert.rejects( + * async () => { + * throw new TypeError('Wrong value'); + * }, + * (err) => { + * assert.strictEqual(err.name, 'TypeError'); + * assert.strictEqual(err.message, 'Wrong value'); + * return true; + * }, + * ); + * ``` + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.rejects( + * Promise.reject(new Error('Wrong value')), + * Error, + * ).then(() => { + * // ... + * }); + * ``` + * + * `error` cannot be a string. If a string is provided as the second + * argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the + * example in {@link throws} carefully if using a string as the second + * argument gets considered. + * @since v10.0.0 + */ + function rejects(block: (() => Promise) | Promise, message?: string | Error): Promise; + function rejects( + block: (() => Promise) | Promise, + error: AssertPredicate, + message?: string | Error, + ): Promise; + /** + * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately + * calls the function and awaits the returned promise to complete. It will then + * check that the promise is not rejected. + * + * If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If + * the function does not return a promise, `assert.doesNotReject()` will return a + * rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases + * the error handler is skipped. + * + * Using `assert.doesNotReject()` is actually not useful because there is little + * benefit in catching a rejection and then rejecting it again. Instead, consider + * adding a comment next to the specific code path that should not reject and keep + * error messages as expressive as possible. + * + * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation + * function. See {@link throws} for more details. + * + * Besides the async nature to await the completion behaves identically to {@link doesNotThrow}. + * + * ```js + * import assert from 'node:assert/strict'; + * + * await assert.doesNotReject( + * async () => { + * throw new TypeError('Wrong value'); + * }, + * SyntaxError, + * ); + * ``` + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotReject(Promise.reject(new TypeError('Wrong value'))) + * .then(() => { + * // ... + * }); + * ``` + * @since v10.0.0 + */ + function doesNotReject( + block: (() => Promise) | Promise, + message?: string | Error, + ): Promise; + function doesNotReject( + block: (() => Promise) | Promise, + error: AssertPredicate, + message?: string | Error, + ): Promise; + /** + * Expects the `string` input to match the regular expression. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.match('I will fail', /pass/); + * // AssertionError [ERR_ASSERTION]: The input did not match the regular ... + * + * assert.match(123, /pass/); + * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string. + * + * assert.match('I will pass', /pass/); + * // OK + * ``` + * + * If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal + * to the value of the `message` parameter. If the `message` parameter is + * undefined, a default error message is assigned. If the `message` parameter is an + * instance of an `Error` then it will be thrown instead of the `AssertionError`. + * @since v13.6.0, v12.16.0 + */ + function match(value: string, regExp: RegExp, message?: string | Error): void; + /** + * Expects the `string` input not to match the regular expression. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotMatch('I will fail', /fail/); + * // AssertionError [ERR_ASSERTION]: The input was expected to not match the ... + * + * assert.doesNotMatch(123, /pass/); + * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string. + * + * assert.doesNotMatch('I will pass', /different/); + * // OK + * ``` + * + * If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal + * to the value of the `message` parameter. If the `message` parameter is + * undefined, a default error message is assigned. If the `message` parameter is an + * instance of an `Error` then it will be thrown instead of the `AssertionError`. + * @since v13.6.0, v12.16.0 + */ + function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void; + const strict: + & Omit< + typeof assert, + | "equal" + | "notEqual" + | "deepEqual" + | "notDeepEqual" + | "ok" + | "strictEqual" + | "deepStrictEqual" + | "ifError" + | "strict" + > + & { + (value: unknown, message?: string | Error): asserts value; + equal: typeof strictEqual; + notEqual: typeof notStrictEqual; + deepEqual: typeof deepStrictEqual; + notDeepEqual: typeof notDeepStrictEqual; + // Mapped types and assertion functions are incompatible? + // TS2775: Assertions require every name in the call target + // to be declared with an explicit type annotation. + ok: typeof ok; + strictEqual: typeof strictEqual; + deepStrictEqual: typeof deepStrictEqual; + ifError: typeof ifError; + strict: typeof strict; + }; + } + export = assert; +} +declare module "node:assert" { + import assert = require("assert"); + export = assert; +} diff --git a/node_modules/@types/node/assert/strict.d.ts b/node_modules/@types/node/assert/strict.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f333913a4565f7067b05ddbc415490e585f2d1e1 --- /dev/null +++ b/node_modules/@types/node/assert/strict.d.ts @@ -0,0 +1,8 @@ +declare module "assert/strict" { + import { strict } from "node:assert"; + export = strict; +} +declare module "node:assert/strict" { + import { strict } from "node:assert"; + export = strict; +} diff --git a/node_modules/@types/node/async_hooks.d.ts b/node_modules/@types/node/async_hooks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0667a6150af717a759e15e4fe04b6d29fe533411 --- /dev/null +++ b/node_modules/@types/node/async_hooks.d.ts @@ -0,0 +1,539 @@ +/** + * We strongly discourage the use of the `async_hooks` API. + * Other APIs that can cover most of its use cases include: + * + * * `AsyncLocalStorage` tracks async context + * * `process.getActiveResourcesInfo()` tracks active resources + * + * The `node:async_hooks` module provides an API to track asynchronous resources. + * It can be accessed using: + * + * ```js + * import async_hooks from 'node:async_hooks'; + * ``` + * @experimental + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/async_hooks.js) + */ +declare module "async_hooks" { + /** + * ```js + * import { executionAsyncId } from 'node:async_hooks'; + * import fs from 'node:fs'; + * + * console.log(executionAsyncId()); // 1 - bootstrap + * const path = '.'; + * fs.open(path, 'r', (err, fd) => { + * console.log(executionAsyncId()); // 6 - open() + * }); + * ``` + * + * The ID returned from `executionAsyncId()` is related to execution timing, not + * causality (which is covered by `triggerAsyncId()`): + * + * ```js + * const server = net.createServer((conn) => { + * // Returns the ID of the server, not of the new connection, because the + * // callback runs in the execution scope of the server's MakeCallback(). + * async_hooks.executionAsyncId(); + * + * }).listen(port, () => { + * // Returns the ID of a TickObject (process.nextTick()) because all + * // callbacks passed to .listen() are wrapped in a nextTick(). + * async_hooks.executionAsyncId(); + * }); + * ``` + * + * Promise contexts may not get precise `executionAsyncIds` by default. + * See the section on `promise execution tracking`. + * @since v8.1.0 + * @return The `asyncId` of the current execution context. Useful to track when something calls. + */ + function executionAsyncId(): number; + /** + * Resource objects returned by `executionAsyncResource()` are most often internal + * Node.js handle objects with undocumented APIs. Using any functions or properties + * on the object is likely to crash your application and should be avoided. + * + * Using `executionAsyncResource()` in the top-level execution context will + * return an empty object as there is no handle or request object to use, + * but having an object representing the top-level can be helpful. + * + * ```js + * import { open } from 'node:fs'; + * import { executionAsyncId, executionAsyncResource } from 'node:async_hooks'; + * + * console.log(executionAsyncId(), executionAsyncResource()); // 1 {} + * open(new URL(import.meta.url), 'r', (err, fd) => { + * console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap + * }); + * ``` + * + * This can be used to implement continuation local storage without the + * use of a tracking `Map` to store the metadata: + * + * ```js + * import { createServer } from 'node:http'; + * import { + * executionAsyncId, + * executionAsyncResource, + * createHook, + * } from 'async_hooks'; + * const sym = Symbol('state'); // Private symbol to avoid pollution + * + * createHook({ + * init(asyncId, type, triggerAsyncId, resource) { + * const cr = executionAsyncResource(); + * if (cr) { + * resource[sym] = cr[sym]; + * } + * }, + * }).enable(); + * + * const server = createServer((req, res) => { + * executionAsyncResource()[sym] = { state: req.url }; + * setTimeout(function() { + * res.end(JSON.stringify(executionAsyncResource()[sym])); + * }, 100); + * }).listen(3000); + * ``` + * @since v13.9.0, v12.17.0 + * @return The resource representing the current execution. Useful to store data within the resource. + */ + function executionAsyncResource(): object; + /** + * ```js + * const server = net.createServer((conn) => { + * // The resource that caused (or triggered) this callback to be called + * // was that of the new connection. Thus the return value of triggerAsyncId() + * // is the asyncId of "conn". + * async_hooks.triggerAsyncId(); + * + * }).listen(port, () => { + * // Even though all callbacks passed to .listen() are wrapped in a nextTick() + * // the callback itself exists because the call to the server's .listen() + * // was made. So the return value would be the ID of the server. + * async_hooks.triggerAsyncId(); + * }); + * ``` + * + * Promise contexts may not get valid `triggerAsyncId`s by default. See + * the section on `promise execution tracking`. + * @return The ID of the resource responsible for calling the callback that is currently being executed. + */ + function triggerAsyncId(): number; + interface HookCallbacks { + /** + * Called when a class is constructed that has the possibility to emit an asynchronous event. + * @param asyncId a unique ID for the async resource + * @param type the type of the async resource + * @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created + * @param resource reference to the resource representing the async operation, needs to be released during destroy + */ + init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void; + /** + * When an asynchronous operation is initiated or completes a callback is called to notify the user. + * The before callback is called just before said callback is executed. + * @param asyncId the unique identifier assigned to the resource about to execute the callback. + */ + before?(asyncId: number): void; + /** + * Called immediately after the callback specified in before is completed. + * @param asyncId the unique identifier assigned to the resource which has executed the callback. + */ + after?(asyncId: number): void; + /** + * Called when a promise has resolve() called. This may not be in the same execution id + * as the promise itself. + * @param asyncId the unique id for the promise that was resolve()d. + */ + promiseResolve?(asyncId: number): void; + /** + * Called after the resource corresponding to asyncId is destroyed + * @param asyncId a unique ID for the async resource + */ + destroy?(asyncId: number): void; + } + interface AsyncHook { + /** + * Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop. + */ + enable(): this; + /** + * Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled. + */ + disable(): this; + } + /** + * Registers functions to be called for different lifetime events of each async + * operation. + * + * The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the + * respective asynchronous event during a resource's lifetime. + * + * All callbacks are optional. For example, if only resource cleanup needs to + * be tracked, then only the `destroy` callback needs to be passed. The + * specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section. + * + * ```js + * import { createHook } from 'node:async_hooks'; + * + * const asyncHook = createHook({ + * init(asyncId, type, triggerAsyncId, resource) { }, + * destroy(asyncId) { }, + * }); + * ``` + * + * The callbacks will be inherited via the prototype chain: + * + * ```js + * class MyAsyncCallbacks { + * init(asyncId, type, triggerAsyncId, resource) { } + * destroy(asyncId) {} + * } + * + * class MyAddedCallbacks extends MyAsyncCallbacks { + * before(asyncId) { } + * after(asyncId) { } + * } + * + * const asyncHook = async_hooks.createHook(new MyAddedCallbacks()); + * ``` + * + * Because promises are asynchronous resources whose lifecycle is tracked + * via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises. + * @since v8.1.0 + * @param callbacks The `Hook Callbacks` to register + * @return Instance used for disabling and enabling hooks + */ + function createHook(callbacks: HookCallbacks): AsyncHook; + interface AsyncResourceOptions { + /** + * The ID of the execution context that created this async event. + * @default executionAsyncId() + */ + triggerAsyncId?: number | undefined; + /** + * Disables automatic `emitDestroy` when the object is garbage collected. + * This usually does not need to be set (even if `emitDestroy` is called + * manually), unless the resource's `asyncId` is retrieved and the + * sensitive API's `emitDestroy` is called with it. + * @default false + */ + requireManualDestroy?: boolean | undefined; + } + /** + * The class `AsyncResource` is designed to be extended by the embedder's async + * resources. Using this, users can easily trigger the lifetime events of their + * own resources. + * + * The `init` hook will trigger when an `AsyncResource` is instantiated. + * + * The following is an overview of the `AsyncResource` API. + * + * ```js + * import { AsyncResource, executionAsyncId } from 'node:async_hooks'; + * + * // AsyncResource() is meant to be extended. Instantiating a + * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then + * // async_hook.executionAsyncId() is used. + * const asyncResource = new AsyncResource( + * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }, + * ); + * + * // Run a function in the execution context of the resource. This will + * // * establish the context of the resource + * // * trigger the AsyncHooks before callbacks + * // * call the provided function `fn` with the supplied arguments + * // * trigger the AsyncHooks after callbacks + * // * restore the original execution context + * asyncResource.runInAsyncScope(fn, thisArg, ...args); + * + * // Call AsyncHooks destroy callbacks. + * asyncResource.emitDestroy(); + * + * // Return the unique ID assigned to the AsyncResource instance. + * asyncResource.asyncId(); + * + * // Return the trigger ID for the AsyncResource instance. + * asyncResource.triggerAsyncId(); + * ``` + */ + class AsyncResource { + /** + * AsyncResource() is meant to be extended. Instantiating a + * new AsyncResource() also triggers init. If triggerAsyncId is omitted then + * async_hook.executionAsyncId() is used. + * @param type The type of async event. + * @param triggerAsyncId The ID of the execution context that created + * this async event (default: `executionAsyncId()`), or an + * AsyncResourceOptions object (since v9.3.0) + */ + constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions); + /** + * Binds the given function to the current execution context. + * @since v14.8.0, v12.19.0 + * @param fn The function to bind to the current execution context. + * @param type An optional name to associate with the underlying `AsyncResource`. + */ + static bind any, ThisArg>( + fn: Func, + type?: string, + thisArg?: ThisArg, + ): Func; + /** + * Binds the given function to execute to this `AsyncResource`'s scope. + * @since v14.8.0, v12.19.0 + * @param fn The function to bind to the current `AsyncResource`. + */ + bind any>(fn: Func): Func; + /** + * Call the provided function with the provided arguments in the execution context + * of the async resource. This will establish the context, trigger the AsyncHooks + * before callbacks, call the function, trigger the AsyncHooks after callbacks, and + * then restore the original execution context. + * @since v9.6.0 + * @param fn The function to call in the execution context of this async resource. + * @param thisArg The receiver to be used for the function call. + * @param args Optional arguments to pass to the function. + */ + runInAsyncScope( + fn: (this: This, ...args: any[]) => Result, + thisArg?: This, + ...args: any[] + ): Result; + /** + * Call all `destroy` hooks. This should only ever be called once. An error will + * be thrown if it is called more than once. This **must** be manually called. If + * the resource is left to be collected by the GC then the `destroy` hooks will + * never be called. + * @return A reference to `asyncResource`. + */ + emitDestroy(): this; + /** + * @return The unique `asyncId` assigned to the resource. + */ + asyncId(): number; + /** + * @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. + */ + triggerAsyncId(): number; + } + /** + * This class creates stores that stay coherent through asynchronous operations. + * + * While you can create your own implementation on top of the `node:async_hooks`module, `AsyncLocalStorage` should be preferred as it is a performant and memory + * safe implementation that involves significant optimizations that are non-obvious + * to implement. + * + * The following example uses `AsyncLocalStorage` to build a simple logger + * that assigns IDs to incoming HTTP requests and includes them in messages + * logged within each request. + * + * ```js + * import http from 'node:http'; + * import { AsyncLocalStorage } from 'node:async_hooks'; + * + * const asyncLocalStorage = new AsyncLocalStorage(); + * + * function logWithId(msg) { + * const id = asyncLocalStorage.getStore(); + * console.log(`${id !== undefined ? id : '-'}:`, msg); + * } + * + * let idSeq = 0; + * http.createServer((req, res) => { + * asyncLocalStorage.run(idSeq++, () => { + * logWithId('start'); + * // Imagine any chain of async operations here + * setImmediate(() => { + * logWithId('finish'); + * res.end(); + * }); + * }); + * }).listen(8080); + * + * http.get('http://localhost:8080'); + * http.get('http://localhost:8080'); + * // Prints: + * // 0: start + * // 1: start + * // 0: finish + * // 1: finish + * ``` + * + * Each instance of `AsyncLocalStorage` maintains an independent storage context. + * Multiple instances can safely exist simultaneously without risk of interfering + * with each other's data. + * @since v13.10.0, v12.17.0 + */ + class AsyncLocalStorage { + /** + * Binds the given function to the current execution context. + * @since v19.8.0 + * @experimental + * @param fn The function to bind to the current execution context. + * @return A new function that calls `fn` within the captured execution context. + */ + static bind any>(fn: Func): Func; + /** + * Captures the current execution context and returns a function that accepts a + * function as an argument. Whenever the returned function is called, it + * calls the function passed to it within the captured context. + * + * ```js + * const asyncLocalStorage = new AsyncLocalStorage(); + * const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot()); + * const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore())); + * console.log(result); // returns 123 + * ``` + * + * AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple + * async context tracking purposes, for example: + * + * ```js + * class Foo { + * #runInAsyncScope = AsyncLocalStorage.snapshot(); + * + * get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); } + * } + * + * const foo = asyncLocalStorage.run(123, () => new Foo()); + * console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123 + * ``` + * @since v19.8.0 + * @experimental + * @return A new function with the signature `(fn: (...args) : R, ...args) : R`. + */ + static snapshot(): (fn: (...args: TArgs) => R, ...args: TArgs) => R; + /** + * Disables the instance of `AsyncLocalStorage`. All subsequent calls + * to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again. + * + * When calling `asyncLocalStorage.disable()`, all current contexts linked to the + * instance will be exited. + * + * Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores + * provided by the `asyncLocalStorage`, as those objects are garbage collected + * along with the corresponding async resources. + * + * Use this method when the `asyncLocalStorage` is not in use anymore + * in the current process. + * @since v13.10.0, v12.17.0 + * @experimental + */ + disable(): void; + /** + * Returns the current store. + * If called outside of an asynchronous context initialized by + * calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it + * returns `undefined`. + * @since v13.10.0, v12.17.0 + */ + getStore(): T | undefined; + /** + * Runs a function synchronously within a context and returns its + * return value. The store is not accessible outside of the callback function. + * The store is accessible to any asynchronous operations created within the + * callback. + * + * The optional `args` are passed to the callback function. + * + * If the callback function throws an error, the error is thrown by `run()` too. + * The stacktrace is not impacted by this call and the context is exited. + * + * Example: + * + * ```js + * const store = { id: 2 }; + * try { + * asyncLocalStorage.run(store, () => { + * asyncLocalStorage.getStore(); // Returns the store object + * setTimeout(() => { + * asyncLocalStorage.getStore(); // Returns the store object + * }, 200); + * throw new Error(); + * }); + * } catch (e) { + * asyncLocalStorage.getStore(); // Returns undefined + * // The error will be caught here + * } + * ``` + * @since v13.10.0, v12.17.0 + */ + run(store: T, callback: () => R): R; + run(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R; + /** + * Runs a function synchronously outside of a context and returns its + * return value. The store is not accessible within the callback function or + * the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`. + * + * The optional `args` are passed to the callback function. + * + * If the callback function throws an error, the error is thrown by `exit()` too. + * The stacktrace is not impacted by this call and the context is re-entered. + * + * Example: + * + * ```js + * // Within a call to run + * try { + * asyncLocalStorage.getStore(); // Returns the store object or value + * asyncLocalStorage.exit(() => { + * asyncLocalStorage.getStore(); // Returns undefined + * throw new Error(); + * }); + * } catch (e) { + * asyncLocalStorage.getStore(); // Returns the same object or value + * // The error will be caught here + * } + * ``` + * @since v13.10.0, v12.17.0 + * @experimental + */ + exit(callback: (...args: TArgs) => R, ...args: TArgs): R; + /** + * Transitions into the context for the remainder of the current + * synchronous execution and then persists the store through any following + * asynchronous calls. + * + * Example: + * + * ```js + * const store = { id: 1 }; + * // Replaces previous store with the given store object + * asyncLocalStorage.enterWith(store); + * asyncLocalStorage.getStore(); // Returns the store object + * someAsyncOperation(() => { + * asyncLocalStorage.getStore(); // Returns the same object + * }); + * ``` + * + * This transition will continue for the _entire_ synchronous execution. + * This means that if, for example, the context is entered within an event + * handler subsequent event handlers will also run within that context unless + * specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons + * to use the latter method. + * + * ```js + * const store = { id: 1 }; + * + * emitter.on('my-event', () => { + * asyncLocalStorage.enterWith(store); + * }); + * emitter.on('my-event', () => { + * asyncLocalStorage.getStore(); // Returns the same object + * }); + * + * asyncLocalStorage.getStore(); // Returns undefined + * emitter.emit('my-event'); + * asyncLocalStorage.getStore(); // Returns the same object + * ``` + * @since v13.11.0, v12.17.0 + * @experimental + */ + enterWith(store: T): void; + } +} +declare module "node:async_hooks" { + export * from "async_hooks"; +} diff --git a/node_modules/@types/node/buffer.d.ts b/node_modules/@types/node/buffer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ee5c013552af28e2d3babe3e3e3c1ed8b30206d --- /dev/null +++ b/node_modules/@types/node/buffer.d.ts @@ -0,0 +1,2362 @@ +/** + * `Buffer` objects are used to represent a fixed-length sequence of bytes. Many + * Node.js APIs support `Buffer`s. + * + * The `Buffer` class is a subclass of JavaScript's [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) class and + * extends it with methods that cover additional use cases. Node.js APIs accept + * plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) s wherever `Buffer`s are supported as well. + * + * While the `Buffer` class is available within the global scope, it is still + * recommended to explicitly reference it via an import or require statement. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Creates a zero-filled Buffer of length 10. + * const buf1 = Buffer.alloc(10); + * + * // Creates a Buffer of length 10, + * // filled with bytes which all have the value `1`. + * const buf2 = Buffer.alloc(10, 1); + * + * // Creates an uninitialized buffer of length 10. + * // This is faster than calling Buffer.alloc() but the returned + * // Buffer instance might contain old data that needs to be + * // overwritten using fill(), write(), or other functions that fill the Buffer's + * // contents. + * const buf3 = Buffer.allocUnsafe(10); + * + * // Creates a Buffer containing the bytes [1, 2, 3]. + * const buf4 = Buffer.from([1, 2, 3]); + * + * // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries + * // are all truncated using `(value & 255)` to fit into the range 0–255. + * const buf5 = Buffer.from([257, 257.5, -255, '1']); + * + * // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést': + * // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation) + * // [116, 195, 169, 115, 116] (in decimal notation) + * const buf6 = Buffer.from('tést'); + * + * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74]. + * const buf7 = Buffer.from('tést', 'latin1'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/buffer.js) + */ +declare module "buffer" { + import { BinaryLike } from "node:crypto"; + import { ReadableStream as WebReadableStream } from "node:stream/web"; + /** + * This function returns `true` if `input` contains only valid UTF-8-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since v19.4.0, v18.14.0 + * @param input The input to validate. + */ + export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean; + /** + * This function returns `true` if `input` contains only valid ASCII-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since v19.6.0, v18.15.0 + * @param input The input to validate. + */ + export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean; + export const INSPECT_MAX_BYTES: number; + export const kMaxLength: number; + export const kStringMaxLength: number; + export const constants: { + MAX_LENGTH: number; + MAX_STRING_LENGTH: number; + }; + export type TranscodeEncoding = + | "ascii" + | "utf8" + | "utf-8" + | "utf16le" + | "utf-16le" + | "ucs2" + | "ucs-2" + | "latin1" + | "binary"; + /** + * Re-encodes the given `Buffer` or `Uint8Array` instance from one character + * encoding to another. Returns a new `Buffer` instance. + * + * Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if + * conversion from `fromEnc` to `toEnc` is not permitted. + * + * Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`,`'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`. + * + * The transcoding process will use substitution characters if a given byte + * sequence cannot be adequately represented in the target encoding. For instance: + * + * ```js + * import { Buffer, transcode } from 'node:buffer'; + * + * const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii'); + * console.log(newBuf.toString('ascii')); + * // Prints: '?' + * ``` + * + * Because the Euro (`€`) sign is not representable in US-ASCII, it is replaced + * with `?` in the transcoded `Buffer`. + * @since v7.1.0 + * @param source A `Buffer` or `Uint8Array` instance. + * @param fromEnc The current encoding. + * @param toEnc To target encoding. + */ + export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer; + export const SlowBuffer: { + /** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */ + new(size: number): Buffer; + prototype: Buffer; + }; + /** + * Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using + * a prior call to `URL.createObjectURL()`. + * @since v16.7.0 + * @experimental + * @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`. + */ + export function resolveObjectURL(id: string): Blob | undefined; + export { Buffer }; + /** + * @experimental + */ + export interface BlobOptions { + /** + * @default 'utf8' + */ + encoding?: BufferEncoding | undefined; + /** + * The Blob content-type. The intent is for `type` to convey + * the MIME media type of the data, however no validation of the type format + * is performed. + */ + type?: string | undefined; + } + /** + * A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across + * multiple worker threads. + * @since v15.7.0, v14.18.0 + */ + export class Blob { + /** + * The total size of the `Blob` in bytes. + * @since v15.7.0, v14.18.0 + */ + readonly size: number; + /** + * The content-type of the `Blob`. + * @since v15.7.0, v14.18.0 + */ + readonly type: string; + /** + * Creates a new `Blob` object containing a concatenation of the given sources. + * + * {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into + * the 'Blob' and can therefore be safely modified after the 'Blob' is created. + * + * String sources are also copied into the `Blob`. + */ + constructor(sources: Array, options?: BlobOptions); + /** + * Returns a promise that fulfills with an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) containing a copy of + * the `Blob` data. + * @since v15.7.0, v14.18.0 + */ + arrayBuffer(): Promise; + /** + * Creates and returns a new `Blob` containing a subset of this `Blob` objects + * data. The original `Blob` is not altered. + * @since v15.7.0, v14.18.0 + * @param start The starting index. + * @param end The ending index. + * @param type The content-type for the new `Blob` + */ + slice(start?: number, end?: number, type?: string): Blob; + /** + * Returns a promise that fulfills with the contents of the `Blob` decoded as a + * UTF-8 string. + * @since v15.7.0, v14.18.0 + */ + text(): Promise; + /** + * Returns a new `ReadableStream` that allows the content of the `Blob` to be read. + * @since v16.7.0 + */ + stream(): WebReadableStream; + } + export interface FileOptions { + /** + * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be + * converted to the platform native line-ending as specified by `require('node:os').EOL`. + */ + endings?: "native" | "transparent"; + /** The File content-type. */ + type?: string; + /** The last modified date of the file. `Default`: Date.now(). */ + lastModified?: number; + } + /** + * A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files. + * @since v19.2.0, v18.13.0 + */ + export class File extends Blob { + constructor(sources: Array, fileName: string, options?: FileOptions); + /** + * The name of the `File`. + * @since v19.2.0, v18.13.0 + */ + readonly name: string; + /** + * The last modified date of the `File`. + * @since v19.2.0, v18.13.0 + */ + readonly lastModified: number; + } + export import atob = globalThis.atob; + export import btoa = globalThis.btoa; + import { Blob as NodeBlob } from "buffer"; + // This conditional type will be the existing global Blob in a browser, or + // the copy below in a Node environment. + type __Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : NodeBlob; + global { + namespace NodeJS { + export { BufferEncoding }; + } + // Buffer class + type BufferEncoding = + | "ascii" + | "utf8" + | "utf-8" + | "utf16le" + | "utf-16le" + | "ucs2" + | "ucs-2" + | "base64" + | "base64url" + | "latin1" + | "binary" + | "hex"; + type WithImplicitCoercion = + | T + | { + valueOf(): T; + }; + /** + * Raw data is stored in instances of the Buffer class. + * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. + * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex' + */ + interface BufferConstructor { + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead. + */ + new(str: string, encoding?: BufferEncoding): Buffer; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`). + */ + new(size: number): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead. + */ + new(array: Uint8Array): Buffer; + /** + * Produces a Buffer backed by the same allocated memory as + * the given {ArrayBuffer}/{SharedArrayBuffer}. + * + * @param arrayBuffer The ArrayBuffer with which to share memory. + * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead. + */ + new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead. + */ + new(array: readonly any[]): Buffer; + /** + * Copies the passed {buffer} data onto a new {Buffer} instance. + * + * @param buffer The buffer to copy. + * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead. + */ + new(buffer: Buffer): Buffer; + /** + * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`. + * Array entries outside that range will be truncated to fit into it. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'. + * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); + * ``` + * + * If `array` is an `Array`\-like object (that is, one with a `length` property of + * type `number`), it is treated as if it is an array, unless it is a `Buffer` or + * a `Uint8Array`. This means all other `TypedArray` variants get treated as an`Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`. + * + * A `TypeError` will be thrown if `array` is not an `Array` or another type + * appropriate for `Buffer.from()` variants. + * + * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does. + * @since v5.10.0 + */ + from( + arrayBuffer: WithImplicitCoercion, + byteOffset?: number, + length?: number, + ): Buffer; + /** + * Creates a new Buffer using the passed {data} + * @param data data to create a new Buffer + */ + from(data: Uint8Array | readonly number[]): Buffer; + from(data: WithImplicitCoercion): Buffer; + /** + * Creates a new Buffer containing the given JavaScript string {str}. + * If provided, the {encoding} parameter identifies the character encoding. + * If not provided, {encoding} defaults to 'utf8'. + */ + from( + str: + | WithImplicitCoercion + | { + [Symbol.toPrimitive](hint: "string"): string; + }, + encoding?: BufferEncoding, + ): Buffer; + /** + * Creates a new Buffer using the passed {data} + * @param values to create a new Buffer + */ + of(...items: number[]): Buffer; + /** + * Returns `true` if `obj` is a `Buffer`, `false` otherwise. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * Buffer.isBuffer(Buffer.alloc(10)); // true + * Buffer.isBuffer(Buffer.from('foo')); // true + * Buffer.isBuffer('a string'); // false + * Buffer.isBuffer([]); // false + * Buffer.isBuffer(new Uint8Array(1024)); // false + * ``` + * @since v0.1.101 + */ + isBuffer(obj: any): obj is Buffer; + /** + * Returns `true` if `encoding` is the name of a supported character encoding, + * or `false` otherwise. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * console.log(Buffer.isEncoding('utf8')); + * // Prints: true + * + * console.log(Buffer.isEncoding('hex')); + * // Prints: true + * + * console.log(Buffer.isEncoding('utf/8')); + * // Prints: false + * + * console.log(Buffer.isEncoding('')); + * // Prints: false + * ``` + * @since v0.9.1 + * @param encoding A character encoding name to check. + */ + isEncoding(encoding: string): encoding is BufferEncoding; + /** + * Returns the byte length of a string when encoded using `encoding`. + * This is not the same as [`String.prototype.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), which does not account + * for the encoding that is used to convert the string into bytes. + * + * For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input. + * For strings that contain non-base64/hex-encoded data (e.g. whitespace), the + * return value might be greater than the length of a `Buffer` created from the + * string. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const str = '\u00bd + \u00bc = \u00be'; + * + * console.log(`${str}: ${str.length} characters, ` + + * `${Buffer.byteLength(str, 'utf8')} bytes`); + * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes + * ``` + * + * When `string` is a + * `Buffer`/[`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)/[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/- + * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop- + * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned. + * @since v0.1.90 + * @param string A value to calculate the length of. + * @param [encoding='utf8'] If `string` is a string, this is its encoding. + * @return The number of bytes contained within `string`. + */ + byteLength( + string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, + encoding?: BufferEncoding, + ): number; + /** + * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together. + * + * If the list has no items, or if the `totalLength` is 0, then a new zero-length`Buffer` is returned. + * + * If `totalLength` is not provided, it is calculated from the `Buffer` instances + * in `list` by adding their lengths. + * + * If `totalLength` is provided, it is coerced to an unsigned integer. If the + * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is + * truncated to `totalLength`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Create a single `Buffer` from a list of three `Buffer` instances. + * + * const buf1 = Buffer.alloc(10); + * const buf2 = Buffer.alloc(14); + * const buf3 = Buffer.alloc(18); + * const totalLength = buf1.length + buf2.length + buf3.length; + * + * console.log(totalLength); + * // Prints: 42 + * + * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength); + * + * console.log(bufA); + * // Prints: + * console.log(bufA.length); + * // Prints: 42 + * ``` + * + * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does. + * @since v0.7.11 + * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate. + * @param totalLength Total length of the `Buffer` instances in `list` when concatenated. + */ + concat(list: readonly Uint8Array[], totalLength?: number): Buffer; + /** + * Copies the underlying memory of `view` into a new `Buffer`. + * + * ```js + * const u16 = new Uint16Array([0, 0xffff]); + * const buf = Buffer.copyBytesFrom(u16, 1, 1); + * u16[1] = 0; + * console.log(buf.length); // 2 + * console.log(buf[0]); // 255 + * console.log(buf[1]); // 255 + * ``` + * @since v19.8.0 + * @param view The {TypedArray} to copy. + * @param [offset=': 0'] The starting offset within `view`. + * @param [length=view.length - offset] The number of elements from `view` to copy. + */ + copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer; + /** + * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from('1234'); + * const buf2 = Buffer.from('0123'); + * const arr = [buf1, buf2]; + * + * console.log(arr.sort(Buffer.compare)); + * // Prints: [ , ] + * // (This result is equal to: [buf2, buf1].) + * ``` + * @since v0.11.13 + * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details. + */ + compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1; + /** + * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.alloc(5); + * + * console.log(buf); + * // Prints: + * ``` + * + * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. + * + * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.alloc(5, 'a'); + * + * console.log(buf); + * // Prints: + * ``` + * + * If both `fill` and `encoding` are specified, the allocated `Buffer` will be + * initialized by calling `buf.fill(fill, encoding)`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); + * + * console.log(buf); + * // Prints: + * ``` + * + * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance + * contents will never contain sensitive data from previous allocations, including + * data that might not have been allocated for `Buffer`s. + * + * A `TypeError` will be thrown if `size` is not a number. + * @since v5.10.0 + * @param size The desired length of the new `Buffer`. + * @param [fill=0] A value to pre-fill the new `Buffer` with. + * @param [encoding='utf8'] If `fill` is a string, this is its encoding. + */ + alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer; + /** + * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. + * + * The underlying memory for `Buffer` instances created in this way is _not_ + * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(10); + * + * console.log(buf); + * // Prints (contents may vary): + * + * buf.fill(0); + * + * console.log(buf); + * // Prints: + * ``` + * + * A `TypeError` will be thrown if `size` is not a number. + * + * The `Buffer` module pre-allocates an internal `Buffer` instance of + * size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`, + * and `Buffer.concat()` only when `size` is less than or equal to`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). + * + * Use of this pre-allocated internal memory pool is a key difference between + * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`. + * Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less + * than or equal to half `Buffer.poolSize`. The + * difference is subtle but can be important when an application requires the + * additional performance that `Buffer.allocUnsafe()` provides. + * @since v5.10.0 + * @param size The desired length of the new `Buffer`. + */ + allocUnsafe(size: number): Buffer; + /** + * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if + * `size` is 0. + * + * The underlying memory for `Buffer` instances created in this way is _not_ + * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize + * such `Buffer` instances with zeroes. + * + * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances, + * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This + * allows applications to avoid the garbage collection overhead of creating many + * individually allocated `Buffer` instances. This approach improves both + * performance and memory usage by eliminating the need to track and clean up as + * many individual `ArrayBuffer` objects. + * + * However, in the case where a developer may need to retain a small chunk of + * memory from a pool for an indeterminate amount of time, it may be appropriate + * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and + * then copying out the relevant bits. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Need to keep around a few small chunks of memory. + * const store = []; + * + * socket.on('readable', () => { + * let data; + * while (null !== (data = readable.read())) { + * // Allocate for retained data. + * const sb = Buffer.allocUnsafeSlow(10); + * + * // Copy the data into the new allocation. + * data.copy(sb, 0, 0, 10); + * + * store.push(sb); + * } + * }); + * ``` + * + * A `TypeError` will be thrown if `size` is not a number. + * @since v5.12.0 + * @param size The desired length of the new `Buffer`. + */ + allocUnsafeSlow(size: number): Buffer; + /** + * This is the size (in bytes) of pre-allocated internal `Buffer` instances used + * for pooling. This value may be modified. + * @since v0.11.3 + */ + poolSize: number; + } + interface Buffer extends Uint8Array { + /** + * Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did + * not contain enough space to fit the entire string, only part of `string` will be + * written. However, partially encoded characters will not be written. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.alloc(256); + * + * const len = buf.write('\u00bd + \u00bc = \u00be', 0); + * + * console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); + * // Prints: 12 bytes: ½ + ¼ = ¾ + * + * const buffer = Buffer.alloc(10); + * + * const length = buffer.write('abcd', 8); + * + * console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`); + * // Prints: 2 bytes : ab + * ``` + * @since v0.1.90 + * @param string String to write to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write `string`. + * @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`). + * @param [encoding='utf8'] The character encoding of `string`. + * @return Number of bytes written. + */ + write(string: string, encoding?: BufferEncoding): number; + write(string: string, offset: number, encoding?: BufferEncoding): number; + write(string: string, offset: number, length: number, encoding?: BufferEncoding): number; + /** + * Decodes `buf` to a string according to the specified character encoding in`encoding`. `start` and `end` may be passed to decode only a subset of `buf`. + * + * If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8, + * then each invalid byte is replaced with the replacement character `U+FFFD`. + * + * The maximum length of a string instance (in UTF-16 code units) is available + * as {@link constants.MAX_STRING_LENGTH}. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.allocUnsafe(26); + * + * for (let i = 0; i < 26; i++) { + * // 97 is the decimal ASCII value for 'a'. + * buf1[i] = i + 97; + * } + * + * console.log(buf1.toString('utf8')); + * // Prints: abcdefghijklmnopqrstuvwxyz + * console.log(buf1.toString('utf8', 0, 5)); + * // Prints: abcde + * + * const buf2 = Buffer.from('tést'); + * + * console.log(buf2.toString('hex')); + * // Prints: 74c3a97374 + * console.log(buf2.toString('utf8', 0, 3)); + * // Prints: té + * console.log(buf2.toString(undefined, 0, 3)); + * // Prints: té + * ``` + * @since v0.1.90 + * @param [encoding='utf8'] The character encoding to use. + * @param [start=0] The byte offset to start decoding at. + * @param [end=buf.length] The byte offset to stop decoding at (not inclusive). + */ + toString(encoding?: BufferEncoding, start?: number, end?: number): string; + /** + * Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls + * this function when stringifying a `Buffer` instance. + * + * `Buffer.from()` accepts objects in the format returned from this method. + * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]); + * const json = JSON.stringify(buf); + * + * console.log(json); + * // Prints: {"type":"Buffer","data":[1,2,3,4,5]} + * + * const copy = JSON.parse(json, (key, value) => { + * return value && value.type === 'Buffer' ? + * Buffer.from(value) : + * value; + * }); + * + * console.log(copy); + * // Prints: + * ``` + * @since v0.9.2 + */ + toJSON(): { + type: "Buffer"; + data: number[]; + }; + /** + * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from('ABC'); + * const buf2 = Buffer.from('414243', 'hex'); + * const buf3 = Buffer.from('ABCD'); + * + * console.log(buf1.equals(buf2)); + * // Prints: true + * console.log(buf1.equals(buf3)); + * // Prints: false + * ``` + * @since v0.11.13 + * @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`. + */ + equals(otherBuffer: Uint8Array): boolean; + /** + * Compares `buf` with `target` and returns a number indicating whether `buf`comes before, after, or is the same as `target` in sort order. + * Comparison is based on the actual sequence of bytes in each `Buffer`. + * + * * `0` is returned if `target` is the same as `buf` + * * `1` is returned if `target` should come _before_`buf` when sorted. + * * `-1` is returned if `target` should come _after_`buf` when sorted. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from('ABC'); + * const buf2 = Buffer.from('BCD'); + * const buf3 = Buffer.from('ABCD'); + * + * console.log(buf1.compare(buf1)); + * // Prints: 0 + * console.log(buf1.compare(buf2)); + * // Prints: -1 + * console.log(buf1.compare(buf3)); + * // Prints: -1 + * console.log(buf2.compare(buf1)); + * // Prints: 1 + * console.log(buf2.compare(buf3)); + * // Prints: 1 + * console.log([buf1, buf2, buf3].sort(Buffer.compare)); + * // Prints: [ , , ] + * // (This result is equal to: [buf1, buf3, buf2].) + * ``` + * + * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]); + * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]); + * + * console.log(buf1.compare(buf2, 5, 9, 0, 4)); + * // Prints: 0 + * console.log(buf1.compare(buf2, 0, 6, 4)); + * // Prints: -1 + * console.log(buf1.compare(buf2, 5, 6, 5)); + * // Prints: 1 + * ``` + * + * `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`,`targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`. + * @since v0.11.13 + * @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`. + * @param [targetStart=0] The offset within `target` at which to begin comparison. + * @param [targetEnd=target.length] The offset within `target` at which to end comparison (not inclusive). + * @param [sourceStart=0] The offset within `buf` at which to begin comparison. + * @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive). + */ + compare( + target: Uint8Array, + targetStart?: number, + targetEnd?: number, + sourceStart?: number, + sourceEnd?: number, + ): -1 | 0 | 1; + /** + * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`. + * + * [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available + * for all TypedArrays, including Node.js `Buffer`s, although it takes + * different function arguments. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Create two `Buffer` instances. + * const buf1 = Buffer.allocUnsafe(26); + * const buf2 = Buffer.allocUnsafe(26).fill('!'); + * + * for (let i = 0; i < 26; i++) { + * // 97 is the decimal ASCII value for 'a'. + * buf1[i] = i + 97; + * } + * + * // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`. + * buf1.copy(buf2, 8, 16, 20); + * // This is equivalent to: + * // buf2.set(buf1.subarray(16, 20), 8); + * + * console.log(buf2.toString('ascii', 0, 25)); + * // Prints: !!!!!!!!qrst!!!!!!!!!!!!! + * ``` + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Create a `Buffer` and copy data from one region to an overlapping region + * // within the same `Buffer`. + * + * const buf = Buffer.allocUnsafe(26); + * + * for (let i = 0; i < 26; i++) { + * // 97 is the decimal ASCII value for 'a'. + * buf[i] = i + 97; + * } + * + * buf.copy(buf, 0, 4, 10); + * + * console.log(buf.toString()); + * // Prints: efghijghijklmnopqrstuvwxyz + * ``` + * @since v0.1.90 + * @param target A `Buffer` or {@link Uint8Array} to copy into. + * @param [targetStart=0] The offset within `target` at which to begin writing. + * @param [sourceStart=0] The offset within `buf` from which to begin copying. + * @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive). + * @return The number of bytes copied. + */ + copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + /** + * Returns a new `Buffer` that references the same memory as the original, but + * offset and cropped by the `start` and `end` indices. + * + * This method is not compatible with the `Uint8Array.prototype.slice()`, + * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('buffer'); + * + * const copiedBuf = Uint8Array.prototype.slice.call(buf); + * copiedBuf[0]++; + * console.log(copiedBuf.toString()); + * // Prints: cuffer + * + * console.log(buf.toString()); + * // Prints: buffer + * + * // With buf.slice(), the original buffer is modified. + * const notReallyCopiedBuf = buf.slice(); + * notReallyCopiedBuf[0]++; + * console.log(notReallyCopiedBuf.toString()); + * // Prints: cuffer + * console.log(buf.toString()); + * // Also prints: cuffer (!) + * ``` + * @since v0.3.0 + * @deprecated Use `subarray` instead. + * @param [start=0] Where the new `Buffer` will start. + * @param [end=buf.length] Where the new `Buffer` will end (not inclusive). + */ + slice(start?: number, end?: number): Buffer; + /** + * Returns a new `Buffer` that references the same memory as the original, but + * offset and cropped by the `start` and `end` indices. + * + * Specifying `end` greater than `buf.length` will return the same result as + * that of `end` equal to `buf.length`. + * + * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray). + * + * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte + * // from the original `Buffer`. + * + * const buf1 = Buffer.allocUnsafe(26); + * + * for (let i = 0; i < 26; i++) { + * // 97 is the decimal ASCII value for 'a'. + * buf1[i] = i + 97; + * } + * + * const buf2 = buf1.subarray(0, 3); + * + * console.log(buf2.toString('ascii', 0, buf2.length)); + * // Prints: abc + * + * buf1[0] = 33; + * + * console.log(buf2.toString('ascii', 0, buf2.length)); + * // Prints: !bc + * ``` + * + * Specifying negative indexes causes the slice to be generated relative to the + * end of `buf` rather than the beginning. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('buffer'); + * + * console.log(buf.subarray(-6, -1).toString()); + * // Prints: buffe + * // (Equivalent to buf.subarray(0, 5).) + * + * console.log(buf.subarray(-6, -2).toString()); + * // Prints: buff + * // (Equivalent to buf.subarray(0, 4).) + * + * console.log(buf.subarray(-5, -2).toString()); + * // Prints: uff + * // (Equivalent to buf.subarray(1, 4).) + * ``` + * @since v3.0.0 + * @param [start=0] Where the new `Buffer` will start. + * @param [end=buf.length] Where the new `Buffer` will end (not inclusive). + */ + subarray(start?: number, end?: number): Buffer; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. + * + * `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeBigInt64BE(0x0102030405060708n, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v12.0.0, v10.20.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeBigInt64BE(value: bigint, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. + * + * `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeBigInt64LE(0x0102030405060708n, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v12.0.0, v10.20.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeBigInt64LE(value: bigint, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. + * + * This function is also available under the `writeBigUint64BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeBigUInt64BE(0xdecafafecacefaden, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v12.0.0, v10.20.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeBigUInt64BE(value: bigint, offset?: number): number; + /** + * @alias Buffer.writeBigUInt64BE + * @since v14.10.0, v12.19.0 + */ + writeBigUint64BE(value: bigint, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeBigUInt64LE(0xdecafafecacefaden, 0); + * + * console.log(buf); + * // Prints: + * ``` + * + * This function is also available under the `writeBigUint64LE` alias. + * @since v12.0.0, v10.20.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeBigUInt64LE(value: bigint, offset?: number): number; + /** + * @alias Buffer.writeBigUInt64LE + * @since v14.10.0, v12.19.0 + */ + writeBigUint64LE(value: bigint, offset?: number): number; + /** + * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined + * when `value` is anything other than an unsigned integer. + * + * This function is also available under the `writeUintLE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(6); + * + * buf.writeUIntLE(0x1234567890ab, 0, 6); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. + * @return `offset` plus the number of bytes written. + */ + writeUIntLE(value: number, offset: number, byteLength: number): number; + /** + * @alias Buffer.writeUIntLE + * @since v14.9.0, v12.19.0 + */ + writeUintLE(value: number, offset: number, byteLength: number): number; + /** + * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined + * when `value` is anything other than an unsigned integer. + * + * This function is also available under the `writeUintBE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(6); + * + * buf.writeUIntBE(0x1234567890ab, 0, 6); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. + * @return `offset` plus the number of bytes written. + */ + writeUIntBE(value: number, offset: number, byteLength: number): number; + /** + * @alias Buffer.writeUIntBE + * @since v14.9.0, v12.19.0 + */ + writeUintBE(value: number, offset: number, byteLength: number): number; + /** + * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined + * when `value` is anything other than a signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(6); + * + * buf.writeIntLE(0x1234567890ab, 0, 6); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. + * @return `offset` plus the number of bytes written. + */ + writeIntLE(value: number, offset: number, byteLength: number): number; + /** + * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when`value` is anything other than a + * signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(6); + * + * buf.writeIntBE(0x1234567890ab, 0, 6); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. + * @return `offset` plus the number of bytes written. + */ + writeIntBE(value: number, offset: number, byteLength: number): number; + /** + * Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readBigUint64BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); + * + * console.log(buf.readBigUInt64BE(0)); + * // Prints: 4294967295n + * ``` + * @since v12.0.0, v10.20.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. + */ + readBigUInt64BE(offset?: number): bigint; + /** + * @alias Buffer.readBigUInt64BE + * @since v14.10.0, v12.19.0 + */ + readBigUint64BE(offset?: number): bigint; + /** + * Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readBigUint64LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); + * + * console.log(buf.readBigUInt64LE(0)); + * // Prints: 18446744069414584320n + * ``` + * @since v12.0.0, v10.20.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. + */ + readBigUInt64LE(offset?: number): bigint; + /** + * @alias Buffer.readBigUInt64LE + * @since v14.10.0, v12.19.0 + */ + readBigUint64LE(offset?: number): bigint; + /** + * Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed + * values. + * @since v12.0.0, v10.20.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. + */ + readBigInt64BE(offset?: number): bigint; + /** + * Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed + * values. + * @since v12.0.0, v10.20.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. + */ + readBigInt64LE(offset?: number): bigint; + /** + * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned, little-endian integer supporting + * up to 48 bits of accuracy. + * + * This function is also available under the `readUintLE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); + * + * console.log(buf.readUIntLE(0, 6).toString(16)); + * // Prints: ab9078563412 + * ``` + * @since v0.11.15 + * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. + */ + readUIntLE(offset: number, byteLength: number): number; + /** + * @alias Buffer.readUIntLE + * @since v14.9.0, v12.19.0 + */ + readUintLE(offset: number, byteLength: number): number; + /** + * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned big-endian integer supporting + * up to 48 bits of accuracy. + * + * This function is also available under the `readUintBE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); + * + * console.log(buf.readUIntBE(0, 6).toString(16)); + * // Prints: 1234567890ab + * console.log(buf.readUIntBE(1, 6).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.11.15 + * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. + */ + readUIntBE(offset: number, byteLength: number): number; + /** + * @alias Buffer.readUIntBE + * @since v14.9.0, v12.19.0 + */ + readUintBE(offset: number, byteLength: number): number; + /** + * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a little-endian, two's complement signed value + * supporting up to 48 bits of accuracy. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); + * + * console.log(buf.readIntLE(0, 6).toString(16)); + * // Prints: -546f87a9cbee + * ``` + * @since v0.11.15 + * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. + */ + readIntLE(offset: number, byteLength: number): number; + /** + * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a big-endian, two's complement signed value + * supporting up to 48 bits of accuracy. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); + * + * console.log(buf.readIntBE(0, 6).toString(16)); + * // Prints: 1234567890ab + * console.log(buf.readIntBE(1, 6).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * console.log(buf.readIntBE(1, 0).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.11.15 + * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. + */ + readIntBE(offset: number, byteLength: number): number; + /** + * Reads an unsigned 8-bit integer from `buf` at the specified `offset`. + * + * This function is also available under the `readUint8` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, -2]); + * + * console.log(buf.readUInt8(0)); + * // Prints: 1 + * console.log(buf.readUInt8(1)); + * // Prints: 254 + * console.log(buf.readUInt8(2)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`. + */ + readUInt8(offset?: number): number; + /** + * @alias Buffer.readUInt8 + * @since v14.9.0, v12.19.0 + */ + readUint8(offset?: number): number; + /** + * Reads an unsigned, little-endian 16-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readUint16LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56]); + * + * console.log(buf.readUInt16LE(0).toString(16)); + * // Prints: 3412 + * console.log(buf.readUInt16LE(1).toString(16)); + * // Prints: 5634 + * console.log(buf.readUInt16LE(2).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. + */ + readUInt16LE(offset?: number): number; + /** + * @alias Buffer.readUInt16LE + * @since v14.9.0, v12.19.0 + */ + readUint16LE(offset?: number): number; + /** + * Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readUint16BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56]); + * + * console.log(buf.readUInt16BE(0).toString(16)); + * // Prints: 1234 + * console.log(buf.readUInt16BE(1).toString(16)); + * // Prints: 3456 + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. + */ + readUInt16BE(offset?: number): number; + /** + * @alias Buffer.readUInt16BE + * @since v14.9.0, v12.19.0 + */ + readUint16BE(offset?: number): number; + /** + * Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readUint32LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); + * + * console.log(buf.readUInt32LE(0).toString(16)); + * // Prints: 78563412 + * console.log(buf.readUInt32LE(1).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readUInt32LE(offset?: number): number; + /** + * @alias Buffer.readUInt32LE + * @since v14.9.0, v12.19.0 + */ + readUint32LE(offset?: number): number; + /** + * Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readUint32BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); + * + * console.log(buf.readUInt32BE(0).toString(16)); + * // Prints: 12345678 + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readUInt32BE(offset?: number): number; + /** + * @alias Buffer.readUInt32BE + * @since v14.9.0, v12.19.0 + */ + readUint32BE(offset?: number): number; + /** + * Reads a signed 8-bit integer from `buf` at the specified `offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([-1, 5]); + * + * console.log(buf.readInt8(0)); + * // Prints: -1 + * console.log(buf.readInt8(1)); + * // Prints: 5 + * console.log(buf.readInt8(2)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`. + */ + readInt8(offset?: number): number; + /** + * Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0, 5]); + * + * console.log(buf.readInt16LE(0)); + * // Prints: 1280 + * console.log(buf.readInt16LE(1)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. + */ + readInt16LE(offset?: number): number; + /** + * Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0, 5]); + * + * console.log(buf.readInt16BE(0)); + * // Prints: 5 + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. + */ + readInt16BE(offset?: number): number; + /** + * Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0, 0, 0, 5]); + * + * console.log(buf.readInt32LE(0)); + * // Prints: 83886080 + * console.log(buf.readInt32LE(1)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readInt32LE(offset?: number): number; + /** + * Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0, 0, 0, 5]); + * + * console.log(buf.readInt32BE(0)); + * // Prints: 5 + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readInt32BE(offset?: number): number; + /** + * Reads a 32-bit, little-endian float from `buf` at the specified `offset`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, 2, 3, 4]); + * + * console.log(buf.readFloatLE(0)); + * // Prints: 1.539989614439558e-36 + * console.log(buf.readFloatLE(1)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.11.15 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readFloatLE(offset?: number): number; + /** + * Reads a 32-bit, big-endian float from `buf` at the specified `offset`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, 2, 3, 4]); + * + * console.log(buf.readFloatBE(0)); + * // Prints: 2.387939260590663e-38 + * ``` + * @since v0.11.15 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readFloatBE(offset?: number): number; + /** + * Reads a 64-bit, little-endian double from `buf` at the specified `offset`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); + * + * console.log(buf.readDoubleLE(0)); + * // Prints: 5.447603722011605e-270 + * console.log(buf.readDoubleLE(1)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.11.15 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`. + */ + readDoubleLE(offset?: number): number; + /** + * Reads a 64-bit, big-endian double from `buf` at the specified `offset`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); + * + * console.log(buf.readDoubleBE(0)); + * // Prints: 8.20788039913184e-304 + * ``` + * @since v0.11.15 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`. + */ + readDoubleBE(offset?: number): number; + reverse(): this; + /** + * Interprets `buf` as an array of unsigned 16-bit integers and swaps the + * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); + * + * console.log(buf1); + * // Prints: + * + * buf1.swap16(); + * + * console.log(buf1); + * // Prints: + * + * const buf2 = Buffer.from([0x1, 0x2, 0x3]); + * + * buf2.swap16(); + * // Throws ERR_INVALID_BUFFER_SIZE. + * ``` + * + * One convenient use of `buf.swap16()` is to perform a fast in-place conversion + * between UTF-16 little-endian and UTF-16 big-endian: + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le'); + * buf.swap16(); // Convert to big-endian UTF-16 text. + * ``` + * @since v5.10.0 + * @return A reference to `buf`. + */ + swap16(): Buffer; + /** + * Interprets `buf` as an array of unsigned 32-bit integers and swaps the + * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); + * + * console.log(buf1); + * // Prints: + * + * buf1.swap32(); + * + * console.log(buf1); + * // Prints: + * + * const buf2 = Buffer.from([0x1, 0x2, 0x3]); + * + * buf2.swap32(); + * // Throws ERR_INVALID_BUFFER_SIZE. + * ``` + * @since v5.10.0 + * @return A reference to `buf`. + */ + swap32(): Buffer; + /** + * Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_. + * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); + * + * console.log(buf1); + * // Prints: + * + * buf1.swap64(); + * + * console.log(buf1); + * // Prints: + * + * const buf2 = Buffer.from([0x1, 0x2, 0x3]); + * + * buf2.swap64(); + * // Throws ERR_INVALID_BUFFER_SIZE. + * ``` + * @since v6.3.0 + * @return A reference to `buf`. + */ + swap64(): Buffer; + /** + * Writes `value` to `buf` at the specified `offset`. `value` must be a + * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything + * other than an unsigned 8-bit integer. + * + * This function is also available under the `writeUint8` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt8(0x3, 0); + * buf.writeUInt8(0x4, 1); + * buf.writeUInt8(0x23, 2); + * buf.writeUInt8(0x42, 3); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`. + * @return `offset` plus the number of bytes written. + */ + writeUInt8(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt8 + * @since v14.9.0, v12.19.0 + */ + writeUint8(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is + * anything other than an unsigned 16-bit integer. + * + * This function is also available under the `writeUint16LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt16LE(0xdead, 0); + * buf.writeUInt16LE(0xbeef, 2); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. + * @return `offset` plus the number of bytes written. + */ + writeUInt16LE(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt16LE + * @since v14.9.0, v12.19.0 + */ + writeUint16LE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an + * unsigned 16-bit integer. + * + * This function is also available under the `writeUint16BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt16BE(0xdead, 0); + * buf.writeUInt16BE(0xbeef, 2); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. + * @return `offset` plus the number of bytes written. + */ + writeUInt16BE(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt16BE + * @since v14.9.0, v12.19.0 + */ + writeUint16BE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is + * anything other than an unsigned 32-bit integer. + * + * This function is also available under the `writeUint32LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt32LE(0xfeedface, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeUInt32LE(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt32LE + * @since v14.9.0, v12.19.0 + */ + writeUint32LE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an + * unsigned 32-bit integer. + * + * This function is also available under the `writeUint32BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt32BE(0xfeedface, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeUInt32BE(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt32BE + * @since v14.9.0, v12.19.0 + */ + writeUint32BE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset`. `value` must be a valid + * signed 8-bit integer. Behavior is undefined when `value` is anything other than + * a signed 8-bit integer. + * + * `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(2); + * + * buf.writeInt8(2, 0); + * buf.writeInt8(-2, 1); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`. + * @return `offset` plus the number of bytes written. + */ + writeInt8(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is + * anything other than a signed 16-bit integer. + * + * The `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(2); + * + * buf.writeInt16LE(0x0304, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. + * @return `offset` plus the number of bytes written. + */ + writeInt16LE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is + * anything other than a signed 16-bit integer. + * + * The `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(2); + * + * buf.writeInt16BE(0x0102, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. + * @return `offset` plus the number of bytes written. + */ + writeInt16BE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is + * anything other than a signed 32-bit integer. + * + * The `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeInt32LE(0x05060708, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeInt32LE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is + * anything other than a signed 32-bit integer. + * + * The `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeInt32BE(0x01020304, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeInt32BE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is + * undefined when `value` is anything other than a JavaScript number. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeFloatLE(0xcafebabe, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeFloatLE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is + * undefined when `value` is anything other than a JavaScript number. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeFloatBE(0xcafebabe, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeFloatBE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything + * other than a JavaScript number. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeDoubleLE(123.456, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeDoubleLE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything + * other than a JavaScript number. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeDoubleBE(123.456, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeDoubleBE(value: number, offset?: number): number; + /** + * Fills `buf` with the specified `value`. If the `offset` and `end` are not given, + * the entire `buf` will be filled: + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Fill a `Buffer` with the ASCII character 'h'. + * + * const b = Buffer.allocUnsafe(50).fill('h'); + * + * console.log(b.toString()); + * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh + * + * // Fill a buffer with empty string + * const c = Buffer.allocUnsafe(5).fill(''); + * + * console.log(c.fill('')); + * // Prints: + * ``` + * + * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or + * integer. If the resulting integer is greater than `255` (decimal), `buf` will be + * filled with `value & 255`. + * + * If the final write of a `fill()` operation falls on a multi-byte character, + * then only the bytes of that character that fit into `buf` are written: + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Fill a `Buffer` with character that takes up two bytes in UTF-8. + * + * console.log(Buffer.allocUnsafe(5).fill('\u0222')); + * // Prints: + * ``` + * + * If `value` contains invalid characters, it is truncated; if no valid + * fill data remains, an exception is thrown: + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(5); + * + * console.log(buf.fill('a')); + * // Prints: + * console.log(buf.fill('aazz', 'hex')); + * // Prints: + * console.log(buf.fill('zz', 'hex')); + * // Throws an exception. + * ``` + * @since v0.5.0 + * @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`. + * @param [offset=0] Number of bytes to skip before starting to fill `buf`. + * @param [end=buf.length] Where to stop filling `buf` (not inclusive). + * @param [encoding='utf8'] The encoding for `value` if `value` is a string. + * @return A reference to `buf`. + */ + fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this; + /** + * If `value` is: + * + * * a string, `value` is interpreted according to the character encoding in`encoding`. + * * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety. + * To compare a partial `Buffer`, use `buf.subarray`. + * * a number, `value` will be interpreted as an unsigned 8-bit integer + * value between `0` and `255`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('this is a buffer'); + * + * console.log(buf.indexOf('this')); + * // Prints: 0 + * console.log(buf.indexOf('is')); + * // Prints: 2 + * console.log(buf.indexOf(Buffer.from('a buffer'))); + * // Prints: 8 + * console.log(buf.indexOf(97)); + * // Prints: 8 (97 is the decimal ASCII value for 'a') + * console.log(buf.indexOf(Buffer.from('a buffer example'))); + * // Prints: -1 + * console.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8))); + * // Prints: 8 + * + * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le'); + * + * console.log(utf16Buffer.indexOf('\u03a3', 0, 'utf16le')); + * // Prints: 4 + * console.log(utf16Buffer.indexOf('\u03a3', -4, 'utf16le')); + * // Prints: 6 + * ``` + * + * If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value, + * an integer between 0 and 255. + * + * If `byteOffset` is not a number, it will be coerced to a number. If the result + * of coercion is `NaN` or `0`, then the entire buffer will be searched. This + * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf). + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const b = Buffer.from('abcdef'); + * + * // Passing a value that's a number, but not a valid byte. + * // Prints: 2, equivalent to searching for 99 or 'c'. + * console.log(b.indexOf(99.9)); + * console.log(b.indexOf(256 + 99)); + * + * // Passing a byteOffset that coerces to NaN or 0. + * // Prints: 1, searching the whole buffer. + * console.log(b.indexOf('b', undefined)); + * console.log(b.indexOf('b', {})); + * console.log(b.indexOf('b', null)); + * console.log(b.indexOf('b', [])); + * ``` + * + * If `value` is an empty string or empty `Buffer` and `byteOffset` is less + * than `buf.length`, `byteOffset` will be returned. If `value` is empty and`byteOffset` is at least `buf.length`, `buf.length` will be returned. + * @since v1.5.0 + * @param value What to search for. + * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. + * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`. + * @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`. + */ + indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; + /** + * Identical to `buf.indexOf()`, except the last occurrence of `value` is found + * rather than the first occurrence. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('this buffer is a buffer'); + * + * console.log(buf.lastIndexOf('this')); + * // Prints: 0 + * console.log(buf.lastIndexOf('buffer')); + * // Prints: 17 + * console.log(buf.lastIndexOf(Buffer.from('buffer'))); + * // Prints: 17 + * console.log(buf.lastIndexOf(97)); + * // Prints: 15 (97 is the decimal ASCII value for 'a') + * console.log(buf.lastIndexOf(Buffer.from('yolo'))); + * // Prints: -1 + * console.log(buf.lastIndexOf('buffer', 5)); + * // Prints: 5 + * console.log(buf.lastIndexOf('buffer', 4)); + * // Prints: -1 + * + * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le'); + * + * console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le')); + * // Prints: 6 + * console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le')); + * // Prints: 4 + * ``` + * + * If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value, + * an integer between 0 and 255. + * + * If `byteOffset` is not a number, it will be coerced to a number. Any arguments + * that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer. + * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf). + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const b = Buffer.from('abcdef'); + * + * // Passing a value that's a number, but not a valid byte. + * // Prints: 2, equivalent to searching for 99 or 'c'. + * console.log(b.lastIndexOf(99.9)); + * console.log(b.lastIndexOf(256 + 99)); + * + * // Passing a byteOffset that coerces to NaN. + * // Prints: 1, searching the whole buffer. + * console.log(b.lastIndexOf('b', undefined)); + * console.log(b.lastIndexOf('b', {})); + * + * // Passing a byteOffset that coerces to 0. + * // Prints: -1, equivalent to passing 0. + * console.log(b.lastIndexOf('b', null)); + * console.log(b.lastIndexOf('b', [])); + * ``` + * + * If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned. + * @since v6.0.0 + * @param value What to search for. + * @param [byteOffset=buf.length - 1] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. + * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`. + * @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`. + */ + lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; + /** + * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `[index, byte]` pairs from the contents + * of `buf`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Log the entire contents of a `Buffer`. + * + * const buf = Buffer.from('buffer'); + * + * for (const pair of buf.entries()) { + * console.log(pair); + * } + * // Prints: + * // [0, 98] + * // [1, 117] + * // [2, 102] + * // [3, 102] + * // [4, 101] + * // [5, 114] + * ``` + * @since v1.1.0 + */ + entries(): IterableIterator<[number, number]>; + /** + * Equivalent to `buf.indexOf() !== -1`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('this is a buffer'); + * + * console.log(buf.includes('this')); + * // Prints: true + * console.log(buf.includes('is')); + * // Prints: true + * console.log(buf.includes(Buffer.from('a buffer'))); + * // Prints: true + * console.log(buf.includes(97)); + * // Prints: true (97 is the decimal ASCII value for 'a') + * console.log(buf.includes(Buffer.from('a buffer example'))); + * // Prints: false + * console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8))); + * // Prints: true + * console.log(buf.includes('this', 4)); + * // Prints: false + * ``` + * @since v5.3.0 + * @param value What to search for. + * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. + * @param [encoding='utf8'] If `value` is a string, this is its encoding. + * @return `true` if `value` was found in `buf`, `false` otherwise. + */ + includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean; + /** + * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices). + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('buffer'); + * + * for (const key of buf.keys()) { + * console.log(key); + * } + * // Prints: + * // 0 + * // 1 + * // 2 + * // 3 + * // 4 + * // 5 + * ``` + * @since v1.1.0 + */ + keys(): IterableIterator; + /** + * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) for `buf` values (bytes). This function is + * called automatically when a `Buffer` is used in a `for..of` statement. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('buffer'); + * + * for (const value of buf.values()) { + * console.log(value); + * } + * // Prints: + * // 98 + * // 117 + * // 102 + * // 102 + * // 101 + * // 114 + * + * for (const value of buf) { + * console.log(value); + * } + * // Prints: + * // 98 + * // 117 + * // 102 + * // 102 + * // 101 + * // 114 + * ``` + * @since v1.1.0 + */ + values(): IterableIterator; + } + var Buffer: BufferConstructor; + /** + * Decodes a string of Base64-encoded data into bytes, and encodes those bytes + * into a string using Latin-1 (ISO-8859-1). + * + * The `data` may be any JavaScript-value that can be coerced into a string. + * + * **This function is only provided for compatibility with legacy web platform APIs** + * **and should never be used in new code, because they use strings to represent** + * **binary data and predate the introduction of typed arrays in JavaScript.** + * **For code running using Node.js APIs, converting between base64-encoded strings** + * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.** + * @since v15.13.0, v14.17.0 + * @legacy Use `Buffer.from(data, 'base64')` instead. + * @param data The Base64-encoded input string. + */ + function atob(data: string): string; + /** + * Decodes a string into bytes using Latin-1 (ISO-8859), and encodes those bytes + * into a string using Base64. + * + * The `data` may be any JavaScript-value that can be coerced into a string. + * + * **This function is only provided for compatibility with legacy web platform APIs** + * **and should never be used in new code, because they use strings to represent** + * **binary data and predate the introduction of typed arrays in JavaScript.** + * **For code running using Node.js APIs, converting between base64-encoded strings** + * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.** + * @since v15.13.0, v14.17.0 + * @legacy Use `buf.toString('base64')` instead. + * @param data An ASCII (Latin1) string. + */ + function btoa(data: string): string; + interface Blob extends __Blob {} + /** + * `Blob` class is a global reference for `require('node:buffer').Blob` + * https://nodejs.org/api/buffer.html#class-blob + * @since v18.0.0 + */ + var Blob: typeof globalThis extends { + onmessage: any; + Blob: infer T; + } ? T + : typeof NodeBlob; + } +} +declare module "node:buffer" { + export * from "buffer"; +} diff --git a/node_modules/@types/node/child_process.d.ts b/node_modules/@types/node/child_process.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a97532b474dd66ee96bf1c13335136727f4c0398 --- /dev/null +++ b/node_modules/@types/node/child_process.d.ts @@ -0,0 +1,1540 @@ +/** + * The `node:child_process` module provides the ability to spawn subprocesses in + * a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability + * is primarily provided by the {@link spawn} function: + * + * ```js + * const { spawn } = require('node:child_process'); + * const ls = spawn('ls', ['-lh', '/usr']); + * + * ls.stdout.on('data', (data) => { + * console.log(`stdout: ${data}`); + * }); + * + * ls.stderr.on('data', (data) => { + * console.error(`stderr: ${data}`); + * }); + * + * ls.on('close', (code) => { + * console.log(`child process exited with code ${code}`); + * }); + * ``` + * + * By default, pipes for `stdin`, `stdout`, and `stderr` are established between + * the parent Node.js process and the spawned subprocess. These pipes have + * limited (and platform-specific) capacity. If the subprocess writes to + * stdout in excess of that limit without the output being captured, the + * subprocess blocks waiting for the pipe buffer to accept more data. This is + * identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`option if the output will not be consumed. + * + * The command lookup is performed using the `options.env.PATH` environment + * variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is + * used. If `options.env` is set without `PATH`, lookup on Unix is performed + * on a default search path search of `/usr/bin:/bin` (see your operating system's + * manual for execvpe/execvp), on Windows the current processes environment + * variable `PATH` is used. + * + * On Windows, environment variables are case-insensitive. Node.js + * lexicographically sorts the `env` keys and uses the first one that + * case-insensitively matches. Only first (in lexicographic order) entry will be + * passed to the subprocess. This might lead to issues on Windows when passing + * objects to the `env` option that have multiple variants of the same key, such as`PATH` and `Path`. + * + * The {@link spawn} method spawns the child process asynchronously, + * without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks + * the event loop until the spawned process either exits or is terminated. + * + * For convenience, the `node:child_process` module provides a handful of + * synchronous and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on + * top of {@link spawn} or {@link spawnSync}. + * + * * {@link exec}: spawns a shell and runs a command within that + * shell, passing the `stdout` and `stderr` to a callback function when + * complete. + * * {@link execFile}: similar to {@link exec} except + * that it spawns the command directly without first spawning a shell by + * default. + * * {@link fork}: spawns a new Node.js process and invokes a + * specified module with an IPC communication channel established that allows + * sending messages between parent and child. + * * {@link execSync}: a synchronous version of {@link exec} that will block the Node.js event loop. + * * {@link execFileSync}: a synchronous version of {@link execFile} that will block the Node.js event loop. + * + * For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however, + * the synchronous methods can have significant impact on performance due to + * stalling the event loop while spawned processes complete. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/child_process.js) + */ +declare module "child_process" { + import { ObjectEncodingOptions } from "node:fs"; + import { Abortable, EventEmitter } from "node:events"; + import * as net from "node:net"; + import { Pipe, Readable, Stream, Writable } from "node:stream"; + import { URL } from "node:url"; + type Serializable = string | object | number | boolean | bigint; + type SendHandle = net.Socket | net.Server; + /** + * Instances of the `ChildProcess` represent spawned child processes. + * + * Instances of `ChildProcess` are not intended to be created directly. Rather, + * use the {@link spawn}, {@link exec},{@link execFile}, or {@link fork} methods to create + * instances of `ChildProcess`. + * @since v2.2.0 + */ + class ChildProcess extends EventEmitter { + /** + * A `Writable Stream` that represents the child process's `stdin`. + * + * If a child process waits to read all of its input, the child will not continue + * until this stream has been closed via `end()`. + * + * If the child was spawned with `stdio[0]` set to anything other than `'pipe'`, + * then this will be `null`. + * + * `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will + * refer to the same value. + * + * The `subprocess.stdin` property can be `null` or `undefined`if the child process could not be successfully spawned. + * @since v0.1.90 + */ + stdin: Writable | null; + /** + * A `Readable Stream` that represents the child process's `stdout`. + * + * If the child was spawned with `stdio[1]` set to anything other than `'pipe'`, + * then this will be `null`. + * + * `subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will + * refer to the same value. + * + * ```js + * const { spawn } = require('node:child_process'); + * + * const subprocess = spawn('ls'); + * + * subprocess.stdout.on('data', (data) => { + * console.log(`Received chunk ${data}`); + * }); + * ``` + * + * The `subprocess.stdout` property can be `null` or `undefined`if the child process could not be successfully spawned. + * @since v0.1.90 + */ + stdout: Readable | null; + /** + * A `Readable Stream` that represents the child process's `stderr`. + * + * If the child was spawned with `stdio[2]` set to anything other than `'pipe'`, + * then this will be `null`. + * + * `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will + * refer to the same value. + * + * The `subprocess.stderr` property can be `null` or `undefined`if the child process could not be successfully spawned. + * @since v0.1.90 + */ + stderr: Readable | null; + /** + * The `subprocess.channel` property is a reference to the child's IPC channel. If + * no IPC channel exists, this property is `undefined`. + * @since v7.1.0 + */ + readonly channel?: Pipe | null | undefined; + /** + * A sparse array of pipes to the child process, corresponding with positions in + * the `stdio` option passed to {@link spawn} that have been set + * to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and`subprocess.stdio[2]` are also available as `subprocess.stdin`,`subprocess.stdout`, and `subprocess.stderr`, + * respectively. + * + * In the following example, only the child's fd `1` (stdout) is configured as a + * pipe, so only the parent's `subprocess.stdio[1]` is a stream, all other values + * in the array are `null`. + * + * ```js + * const assert = require('node:assert'); + * const fs = require('node:fs'); + * const child_process = require('node:child_process'); + * + * const subprocess = child_process.spawn('ls', { + * stdio: [ + * 0, // Use parent's stdin for child. + * 'pipe', // Pipe child's stdout to parent. + * fs.openSync('err.out', 'w'), // Direct child's stderr to a file. + * ], + * }); + * + * assert.strictEqual(subprocess.stdio[0], null); + * assert.strictEqual(subprocess.stdio[0], subprocess.stdin); + * + * assert(subprocess.stdout); + * assert.strictEqual(subprocess.stdio[1], subprocess.stdout); + * + * assert.strictEqual(subprocess.stdio[2], null); + * assert.strictEqual(subprocess.stdio[2], subprocess.stderr); + * ``` + * + * The `subprocess.stdio` property can be `undefined` if the child process could + * not be successfully spawned. + * @since v0.7.10 + */ + readonly stdio: [ + Writable | null, + // stdin + Readable | null, + // stdout + Readable | null, + // stderr + Readable | Writable | null | undefined, + // extra + Readable | Writable | null | undefined, // extra + ]; + /** + * The `subprocess.killed` property indicates whether the child process + * successfully received a signal from `subprocess.kill()`. The `killed` property + * does not indicate that the child process has been terminated. + * @since v0.5.10 + */ + readonly killed: boolean; + /** + * Returns the process identifier (PID) of the child process. If the child process + * fails to spawn due to errors, then the value is `undefined` and `error` is + * emitted. + * + * ```js + * const { spawn } = require('node:child_process'); + * const grep = spawn('grep', ['ssh']); + * + * console.log(`Spawned child pid: ${grep.pid}`); + * grep.stdin.end(); + * ``` + * @since v0.1.90 + */ + readonly pid?: number | undefined; + /** + * The `subprocess.connected` property indicates whether it is still possible to + * send and receive messages from a child process. When `subprocess.connected` is`false`, it is no longer possible to send or receive messages. + * @since v0.7.2 + */ + readonly connected: boolean; + /** + * The `subprocess.exitCode` property indicates the exit code of the child process. + * If the child process is still running, the field will be `null`. + */ + readonly exitCode: number | null; + /** + * The `subprocess.signalCode` property indicates the signal received by + * the child process if any, else `null`. + */ + readonly signalCode: NodeJS.Signals | null; + /** + * The `subprocess.spawnargs` property represents the full list of command-line + * arguments the child process was launched with. + */ + readonly spawnargs: string[]; + /** + * The `subprocess.spawnfile` property indicates the executable file name of + * the child process that is launched. + * + * For {@link fork}, its value will be equal to `process.execPath`. + * For {@link spawn}, its value will be the name of + * the executable file. + * For {@link exec}, its value will be the name of the shell + * in which the child process is launched. + */ + readonly spawnfile: string; + /** + * The `subprocess.kill()` method sends a signal to the child process. If no + * argument is given, the process will be sent the `'SIGTERM'` signal. See [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for a list of available signals. This function + * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise. + * + * ```js + * const { spawn } = require('node:child_process'); + * const grep = spawn('grep', ['ssh']); + * + * grep.on('close', (code, signal) => { + * console.log( + * `child process terminated due to receipt of signal ${signal}`); + * }); + * + * // Send SIGHUP to process. + * grep.kill('SIGHUP'); + * ``` + * + * The `ChildProcess` object may emit an `'error'` event if the signal + * cannot be delivered. Sending a signal to a child process that has already exited + * is not an error but may have unforeseen consequences. Specifically, if the + * process identifier (PID) has been reassigned to another process, the signal will + * be delivered to that process instead which can have unexpected results. + * + * While the function is called `kill`, the signal delivered to the child process + * may not actually terminate the process. + * + * See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference. + * + * On Windows, where POSIX signals do not exist, the `signal` argument will be + * ignored, and the process will be killed forcefully and abruptly (similar to`'SIGKILL'`). + * See `Signal Events` for more details. + * + * On Linux, child processes of child processes will not be terminated + * when attempting to kill their parent. This is likely to happen when running a + * new process in a shell or with the use of the `shell` option of `ChildProcess`: + * + * ```js + * 'use strict'; + * const { spawn } = require('node:child_process'); + * + * const subprocess = spawn( + * 'sh', + * [ + * '-c', + * `node -e "setInterval(() => { + * console.log(process.pid, 'is alive') + * }, 500);"`, + * ], { + * stdio: ['inherit', 'inherit', 'inherit'], + * }, + * ); + * + * setTimeout(() => { + * subprocess.kill(); // Does not terminate the Node.js process in the shell. + * }, 2000); + * ``` + * @since v0.1.90 + */ + kill(signal?: NodeJS.Signals | number): boolean; + /** + * Calls {@link ChildProcess.kill} with `'SIGTERM'`. + * @since v20.5.0 + */ + [Symbol.dispose](): void; + /** + * When an IPC channel has been established between the parent and child ( + * i.e. when using {@link fork}), the `subprocess.send()` method can + * be used to send messages to the child process. When the child process is a + * Node.js instance, these messages can be received via the `'message'` event. + * + * The message goes through serialization and parsing. The resulting + * message might not be the same as what is originally sent. + * + * For example, in the parent script: + * + * ```js + * const cp = require('node:child_process'); + * const n = cp.fork(`${__dirname}/sub.js`); + * + * n.on('message', (m) => { + * console.log('PARENT got message:', m); + * }); + * + * // Causes the child to print: CHILD got message: { hello: 'world' } + * n.send({ hello: 'world' }); + * ``` + * + * And then the child script, `'sub.js'` might look like this: + * + * ```js + * process.on('message', (m) => { + * console.log('CHILD got message:', m); + * }); + * + * // Causes the parent to print: PARENT got message: { foo: 'bar', baz: null } + * process.send({ foo: 'bar', baz: NaN }); + * ``` + * + * Child Node.js processes will have a `process.send()` method of their own + * that allows the child to send messages back to the parent. + * + * There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages + * containing a `NODE_` prefix in the `cmd` property are reserved for use within + * Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the`'internalMessage'` event and are consumed internally by Node.js. + * Applications should avoid using such messages or listening for`'internalMessage'` events as it is subject to change without notice. + * + * The optional `sendHandle` argument that may be passed to `subprocess.send()` is + * for passing a TCP server or socket object to the child process. The child will + * receive the object as the second argument passed to the callback function + * registered on the `'message'` event. Any data that is received + * and buffered in the socket will not be sent to the child. + * + * The optional `callback` is a function that is invoked after the message is + * sent but before the child may have received it. The function is called with a + * single argument: `null` on success, or an `Error` object on failure. + * + * If no `callback` function is provided and the message cannot be sent, an`'error'` event will be emitted by the `ChildProcess` object. This can + * happen, for instance, when the child process has already exited. + * + * `subprocess.send()` will return `false` if the channel has closed or when the + * backlog of unsent messages exceeds a threshold that makes it unwise to send + * more. Otherwise, the method returns `true`. The `callback` function can be + * used to implement flow control. + * + * #### Example: sending a server object + * + * The `sendHandle` argument can be used, for instance, to pass the handle of + * a TCP server object to the child process as illustrated in the example below: + * + * ```js + * const subprocess = require('node:child_process').fork('subprocess.js'); + * + * // Open up the server object and send the handle. + * const server = require('node:net').createServer(); + * server.on('connection', (socket) => { + * socket.end('handled by parent'); + * }); + * server.listen(1337, () => { + * subprocess.send('server', server); + * }); + * ``` + * + * The child would then receive the server object as: + * + * ```js + * process.on('message', (m, server) => { + * if (m === 'server') { + * server.on('connection', (socket) => { + * socket.end('handled by child'); + * }); + * } + * }); + * ``` + * + * Once the server is now shared between the parent and child, some connections + * can be handled by the parent and some by the child. + * + * While the example above uses a server created using the `node:net` module,`node:dgram` module servers use exactly the same workflow with the exceptions of + * listening on a `'message'` event instead of `'connection'` and using`server.bind()` instead of `server.listen()`. This is, however, only + * supported on Unix platforms. + * + * #### Example: sending a socket object + * + * Similarly, the `sendHandler` argument can be used to pass the handle of a + * socket to the child process. The example below spawns two children that each + * handle connections with "normal" or "special" priority: + * + * ```js + * const { fork } = require('node:child_process'); + * const normal = fork('subprocess.js', ['normal']); + * const special = fork('subprocess.js', ['special']); + * + * // Open up the server and send sockets to child. Use pauseOnConnect to prevent + * // the sockets from being read before they are sent to the child process. + * const server = require('node:net').createServer({ pauseOnConnect: true }); + * server.on('connection', (socket) => { + * + * // If this is special priority... + * if (socket.remoteAddress === '74.125.127.100') { + * special.send('socket', socket); + * return; + * } + * // This is normal priority. + * normal.send('socket', socket); + * }); + * server.listen(1337); + * ``` + * + * The `subprocess.js` would receive the socket handle as the second argument + * passed to the event callback function: + * + * ```js + * process.on('message', (m, socket) => { + * if (m === 'socket') { + * if (socket) { + * // Check that the client socket exists. + * // It is possible for the socket to be closed between the time it is + * // sent and the time it is received in the child process. + * socket.end(`Request handled with ${process.argv[2]} priority`); + * } + * } + * }); + * ``` + * + * Do not use `.maxConnections` on a socket that has been passed to a subprocess. + * The parent cannot track when the socket is destroyed. + * + * Any `'message'` handlers in the subprocess should verify that `socket` exists, + * as the connection may have been closed during the time it takes to send the + * connection to the child. + * @since v0.5.9 + * @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties: + */ + send(message: Serializable, callback?: (error: Error | null) => void): boolean; + send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean; + send( + message: Serializable, + sendHandle?: SendHandle, + options?: MessageOptions, + callback?: (error: Error | null) => void, + ): boolean; + /** + * Closes the IPC channel between parent and child, allowing the child to exit + * gracefully once there are no other connections keeping it alive. After calling + * this method the `subprocess.connected` and `process.connected` properties in + * both the parent and child (respectively) will be set to `false`, and it will be + * no longer possible to pass messages between the processes. + * + * The `'disconnect'` event will be emitted when there are no messages in the + * process of being received. This will most often be triggered immediately after + * calling `subprocess.disconnect()`. + * + * When the child process is a Node.js instance (e.g. spawned using {@link fork}), the `process.disconnect()` method can be invoked + * within the child process to close the IPC channel as well. + * @since v0.7.2 + */ + disconnect(): void; + /** + * By default, the parent will wait for the detached child to exit. To prevent the + * parent from waiting for a given `subprocess` to exit, use the`subprocess.unref()` method. Doing so will cause the parent's event loop to not + * include the child in its reference count, allowing the parent to exit + * independently of the child, unless there is an established IPC channel between + * the child and the parent. + * + * ```js + * const { spawn } = require('node:child_process'); + * + * const subprocess = spawn(process.argv[0], ['child_program.js'], { + * detached: true, + * stdio: 'ignore', + * }); + * + * subprocess.unref(); + * ``` + * @since v0.7.10 + */ + unref(): void; + /** + * Calling `subprocess.ref()` after making a call to `subprocess.unref()` will + * restore the removed reference count for the child process, forcing the parent + * to wait for the child to exit before exiting itself. + * + * ```js + * const { spawn } = require('node:child_process'); + * + * const subprocess = spawn(process.argv[0], ['child_program.js'], { + * detached: true, + * stdio: 'ignore', + * }); + * + * subprocess.unref(); + * subprocess.ref(); + * ``` + * @since v0.7.10 + */ + ref(): void; + /** + * events.EventEmitter + * 1. close + * 2. disconnect + * 3. error + * 4. exit + * 5. message + * 6. spawn + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + addListener(event: "disconnect", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + addListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + addListener(event: "spawn", listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close", code: number | null, signal: NodeJS.Signals | null): boolean; + emit(event: "disconnect"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "exit", code: number | null, signal: NodeJS.Signals | null): boolean; + emit(event: "message", message: Serializable, sendHandle: SendHandle): boolean; + emit(event: "spawn", listener: () => void): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + on(event: "disconnect", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + on(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + on(event: "spawn", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + once(event: "disconnect", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + once(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + once(event: "spawn", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + prependListener(event: "disconnect", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + prependListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + prependListener(event: "spawn", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener( + event: "close", + listener: (code: number | null, signal: NodeJS.Signals | null) => void, + ): this; + prependOnceListener(event: "disconnect", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener( + event: "exit", + listener: (code: number | null, signal: NodeJS.Signals | null) => void, + ): this; + prependOnceListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + prependOnceListener(event: "spawn", listener: () => void): this; + } + // return this object when stdio option is undefined or not specified + interface ChildProcessWithoutNullStreams extends ChildProcess { + stdin: Writable; + stdout: Readable; + stderr: Readable; + readonly stdio: [ + Writable, + Readable, + Readable, + // stderr + Readable | Writable | null | undefined, + // extra, no modification + Readable | Writable | null | undefined, // extra, no modification + ]; + } + // return this object when stdio option is a tuple of 3 + interface ChildProcessByStdio + extends ChildProcess + { + stdin: I; + stdout: O; + stderr: E; + readonly stdio: [ + I, + O, + E, + Readable | Writable | null | undefined, + // extra, no modification + Readable | Writable | null | undefined, // extra, no modification + ]; + } + interface MessageOptions { + keepOpen?: boolean | undefined; + } + type IOType = "overlapped" | "pipe" | "ignore" | "inherit"; + type StdioOptions = IOType | Array; + type SerializationType = "json" | "advanced"; + interface MessagingOptions extends Abortable { + /** + * Specify the kind of serialization used for sending messages between processes. + * @default 'json' + */ + serialization?: SerializationType | undefined; + /** + * The signal value to be used when the spawned process will be killed by the abort signal. + * @default 'SIGTERM' + */ + killSignal?: NodeJS.Signals | number | undefined; + /** + * In milliseconds the maximum amount of time the process is allowed to run. + */ + timeout?: number | undefined; + } + interface ProcessEnvOptions { + uid?: number | undefined; + gid?: number | undefined; + cwd?: string | URL | undefined; + env?: NodeJS.ProcessEnv | undefined; + } + interface CommonOptions extends ProcessEnvOptions { + /** + * @default false + */ + windowsHide?: boolean | undefined; + /** + * @default 0 + */ + timeout?: number | undefined; + } + interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable { + argv0?: string | undefined; + /** + * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ + stdio?: StdioOptions | undefined; + shell?: boolean | string | undefined; + windowsVerbatimArguments?: boolean | undefined; + } + interface SpawnOptions extends CommonSpawnOptions { + detached?: boolean | undefined; + } + interface SpawnOptionsWithoutStdio extends SpawnOptions { + stdio?: StdioPipeNamed | StdioPipe[] | undefined; + } + type StdioNull = "inherit" | "ignore" | Stream; + type StdioPipeNamed = "pipe" | "overlapped"; + type StdioPipe = undefined | null | StdioPipeNamed; + interface SpawnOptionsWithStdioTuple< + Stdin extends StdioNull | StdioPipe, + Stdout extends StdioNull | StdioPipe, + Stderr extends StdioNull | StdioPipe, + > extends SpawnOptions { + stdio: [Stdin, Stdout, Stderr]; + } + /** + * The `child_process.spawn()` method spawns a new process using the given`command`, with command-line arguments in `args`. If omitted, `args` defaults + * to an empty array. + * + * **If the `shell` option is enabled, do not pass unsanitized user input to this** + * **function. Any input containing shell metacharacters may be used to trigger** + * **arbitrary command execution.** + * + * A third argument may be used to specify additional options, with these defaults: + * + * ```js + * const defaults = { + * cwd: undefined, + * env: process.env, + * }; + * ``` + * + * Use `cwd` to specify the working directory from which the process is spawned. + * If not given, the default is to inherit the current working directory. If given, + * but the path does not exist, the child process emits an `ENOENT` error + * and exits immediately. `ENOENT` is also emitted when the command + * does not exist. + * + * Use `env` to specify environment variables that will be visible to the new + * process, the default is `process.env`. + * + * `undefined` values in `env` will be ignored. + * + * Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the + * exit code: + * + * ```js + * const { spawn } = require('node:child_process'); + * const ls = spawn('ls', ['-lh', '/usr']); + * + * ls.stdout.on('data', (data) => { + * console.log(`stdout: ${data}`); + * }); + * + * ls.stderr.on('data', (data) => { + * console.error(`stderr: ${data}`); + * }); + * + * ls.on('close', (code) => { + * console.log(`child process exited with code ${code}`); + * }); + * ``` + * + * Example: A very elaborate way to run `ps ax | grep ssh` + * + * ```js + * const { spawn } = require('node:child_process'); + * const ps = spawn('ps', ['ax']); + * const grep = spawn('grep', ['ssh']); + * + * ps.stdout.on('data', (data) => { + * grep.stdin.write(data); + * }); + * + * ps.stderr.on('data', (data) => { + * console.error(`ps stderr: ${data}`); + * }); + * + * ps.on('close', (code) => { + * if (code !== 0) { + * console.log(`ps process exited with code ${code}`); + * } + * grep.stdin.end(); + * }); + * + * grep.stdout.on('data', (data) => { + * console.log(data.toString()); + * }); + * + * grep.stderr.on('data', (data) => { + * console.error(`grep stderr: ${data}`); + * }); + * + * grep.on('close', (code) => { + * if (code !== 0) { + * console.log(`grep process exited with code ${code}`); + * } + * }); + * ``` + * + * Example of checking for failed `spawn`: + * + * ```js + * const { spawn } = require('node:child_process'); + * const subprocess = spawn('bad_command'); + * + * subprocess.on('error', (err) => { + * console.error('Failed to start subprocess.'); + * }); + * ``` + * + * Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process + * title while others (Windows, SunOS) will use `command`. + * + * Node.js overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent. Retrieve + * it with the`process.argv0` property instead. + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except + * the error passed to the callback will be an `AbortError`: + * + * ```js + * const { spawn } = require('node:child_process'); + * const controller = new AbortController(); + * const { signal } = controller; + * const grep = spawn('grep', ['ssh'], { signal }); + * grep.on('error', (err) => { + * // This will be called with err being an AbortError if the controller aborts + * }); + * controller.abort(); // Stops the child process + * ``` + * @since v0.1.90 + * @param command The command to run. + * @param args List of string arguments. + */ + function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn(command: string, options: SpawnOptions): ChildProcess; + // overloads of spawn with 'args' + function spawn( + command: string, + args?: readonly string[], + options?: SpawnOptionsWithoutStdio, + ): ChildProcessWithoutNullStreams; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn(command: string, args: readonly string[], options: SpawnOptions): ChildProcess; + interface ExecOptions extends CommonOptions { + shell?: string | undefined; + signal?: AbortSignal | undefined; + maxBuffer?: number | undefined; + killSignal?: NodeJS.Signals | number | undefined; + } + interface ExecOptionsWithStringEncoding extends ExecOptions { + encoding: BufferEncoding; + } + interface ExecOptionsWithBufferEncoding extends ExecOptions { + encoding: BufferEncoding | null; // specify `null`. + } + interface ExecException extends Error { + cmd?: string | undefined; + killed?: boolean | undefined; + code?: number | undefined; + signal?: NodeJS.Signals | undefined; + } + /** + * Spawns a shell then executes the `command` within that shell, buffering any + * generated output. The `command` string passed to the exec function is processed + * directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters)) + * need to be dealt with accordingly: + * + * ```js + * const { exec } = require('node:child_process'); + * + * exec('"/path/to/test file/test.sh" arg1 arg2'); + * // Double quotes are used so that the space in the path is not interpreted as + * // a delimiter of multiple arguments. + * + * exec('echo "The \\$HOME variable is $HOME"'); + * // The $HOME variable is escaped in the first instance, but not in the second. + * ``` + * + * **Never pass unsanitized user input to this function. Any input containing shell** + * **metacharacters may be used to trigger arbitrary command execution.** + * + * If a `callback` function is provided, it is called with the arguments`(error, stdout, stderr)`. On success, `error` will be `null`. On error,`error` will be an instance of `Error`. The + * `error.code` property will be + * the exit code of the process. By convention, any exit code other than `0`indicates an error. `error.signal` will be the signal that terminated the + * process. + * + * The `stdout` and `stderr` arguments passed to the callback will contain the + * stdout and stderr output of the child process. By default, Node.js will decode + * the output as UTF-8 and pass strings to the callback. The `encoding` option + * can be used to specify the character encoding used to decode the stdout and + * stderr output. If `encoding` is `'buffer'`, or an unrecognized character + * encoding, `Buffer` objects will be passed to the callback instead. + * + * ```js + * const { exec } = require('node:child_process'); + * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => { + * if (error) { + * console.error(`exec error: ${error}`); + * return; + * } + * console.log(`stdout: ${stdout}`); + * console.error(`stderr: ${stderr}`); + * }); + * ``` + * + * If `timeout` is greater than `0`, the parent will send the signal + * identified by the `killSignal` property (the default is `'SIGTERM'`) if the + * child runs longer than `timeout` milliseconds. + * + * Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace + * the existing process and uses a shell to execute the command. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In + * case of an error (including any error resulting in an exit code other than 0), a + * rejected promise is returned, with the same `error` object given in the + * callback, but with two additional properties `stdout` and `stderr`. + * + * ```js + * const util = require('node:util'); + * const exec = util.promisify(require('node:child_process').exec); + * + * async function lsExample() { + * const { stdout, stderr } = await exec('ls'); + * console.log('stdout:', stdout); + * console.error('stderr:', stderr); + * } + * lsExample(); + * ``` + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except + * the error passed to the callback will be an `AbortError`: + * + * ```js + * const { exec } = require('node:child_process'); + * const controller = new AbortController(); + * const { signal } = controller; + * const child = exec('grep ssh', { signal }, (error) => { + * console.error(error); // an AbortError + * }); + * controller.abort(); + * ``` + * @since v0.1.90 + * @param command The command to run, with space-separated arguments. + * @param callback called with the output when process terminates. + */ + function exec( + command: string, + callback?: (error: ExecException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`. + function exec( + command: string, + options: { + encoding: "buffer" | null; + } & ExecOptions, + callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void, + ): ChildProcess; + // `options` with well known `encoding` means stdout/stderr are definitely `string`. + function exec( + command: string, + options: { + encoding: BufferEncoding; + } & ExecOptions, + callback?: (error: ExecException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`. + // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`. + function exec( + command: string, + options: { + encoding: BufferEncoding; + } & ExecOptions, + callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void, + ): ChildProcess; + // `options` without an `encoding` means stdout/stderr are definitely `string`. + function exec( + command: string, + options: ExecOptions, + callback?: (error: ExecException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // fallback if nothing else matches. Worst case is always `string | Buffer`. + function exec( + command: string, + options: (ObjectEncodingOptions & ExecOptions) | undefined | null, + callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void, + ): ChildProcess; + interface PromiseWithChild extends Promise { + child: ChildProcess; + } + namespace exec { + function __promisify__(command: string): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + command: string, + options: { + encoding: "buffer" | null; + } & ExecOptions, + ): PromiseWithChild<{ + stdout: Buffer; + stderr: Buffer; + }>; + function __promisify__( + command: string, + options: { + encoding: BufferEncoding; + } & ExecOptions, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + command: string, + options: ExecOptions, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + command: string, + options?: (ObjectEncodingOptions & ExecOptions) | null, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + } + interface ExecFileOptions extends CommonOptions, Abortable { + maxBuffer?: number | undefined; + killSignal?: NodeJS.Signals | number | undefined; + windowsVerbatimArguments?: boolean | undefined; + shell?: boolean | string | undefined; + signal?: AbortSignal | undefined; + } + interface ExecFileOptionsWithStringEncoding extends ExecFileOptions { + encoding: BufferEncoding; + } + interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions { + encoding: "buffer" | null; + } + interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions { + encoding: BufferEncoding; + } + type ExecFileException = + & Omit + & Omit + & { code?: string | number | undefined | null }; + /** + * The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified + * executable `file` is spawned directly as a new process making it slightly more + * efficient than {@link exec}. + * + * The same options as {@link exec} are supported. Since a shell is + * not spawned, behaviors such as I/O redirection and file globbing are not + * supported. + * + * ```js + * const { execFile } = require('node:child_process'); + * const child = execFile('node', ['--version'], (error, stdout, stderr) => { + * if (error) { + * throw error; + * } + * console.log(stdout); + * }); + * ``` + * + * The `stdout` and `stderr` arguments passed to the callback will contain the + * stdout and stderr output of the child process. By default, Node.js will decode + * the output as UTF-8 and pass strings to the callback. The `encoding` option + * can be used to specify the character encoding used to decode the stdout and + * stderr output. If `encoding` is `'buffer'`, or an unrecognized character + * encoding, `Buffer` objects will be passed to the callback instead. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In + * case of an error (including any error resulting in an exit code other than 0), a + * rejected promise is returned, with the same `error` object given in the + * callback, but with two additional properties `stdout` and `stderr`. + * + * ```js + * const util = require('node:util'); + * const execFile = util.promisify(require('node:child_process').execFile); + * async function getVersion() { + * const { stdout } = await execFile('node', ['--version']); + * console.log(stdout); + * } + * getVersion(); + * ``` + * + * **If the `shell` option is enabled, do not pass unsanitized user input to this** + * **function. Any input containing shell metacharacters may be used to trigger** + * **arbitrary command execution.** + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except + * the error passed to the callback will be an `AbortError`: + * + * ```js + * const { execFile } = require('node:child_process'); + * const controller = new AbortController(); + * const { signal } = controller; + * const child = execFile('node', ['--version'], { signal }, (error) => { + * console.error(error); // an AbortError + * }); + * controller.abort(); + * ``` + * @since v0.1.91 + * @param file The name or path of the executable file to run. + * @param args List of string arguments. + * @param callback Called with the output when process terminates. + */ + function execFile(file: string): ChildProcess; + function execFile( + file: string, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + ): ChildProcess; + function execFile(file: string, args?: readonly string[] | null): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + ): ChildProcess; + // no `options` definitely means stdout/stderr are `string`. + function execFile( + file: string, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`. + function execFile( + file: string, + options: ExecFileOptionsWithBufferEncoding, + callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithBufferEncoding, + callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void, + ): ChildProcess; + // `options` with well known `encoding` means stdout/stderr are definitely `string`. + function execFile( + file: string, + options: ExecFileOptionsWithStringEncoding, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithStringEncoding, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`. + // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`. + function execFile( + file: string, + options: ExecFileOptionsWithOtherEncoding, + callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithOtherEncoding, + callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void, + ): ChildProcess; + // `options` without an `encoding` means stdout/stderr are definitely `string`. + function execFile( + file: string, + options: ExecFileOptions, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptions, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // fallback if nothing else matches. Worst case is always `string | Buffer`. + function execFile( + file: string, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + callback: + | ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) + | undefined + | null, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + callback: + | ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) + | undefined + | null, + ): ChildProcess; + namespace execFile { + function __promisify__(file: string): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + options: ExecFileOptionsWithBufferEncoding, + ): PromiseWithChild<{ + stdout: Buffer; + stderr: Buffer; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithBufferEncoding, + ): PromiseWithChild<{ + stdout: Buffer; + stderr: Buffer; + }>; + function __promisify__( + file: string, + options: ExecFileOptionsWithStringEncoding, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithStringEncoding, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + options: ExecFileOptionsWithOtherEncoding, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithOtherEncoding, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + function __promisify__( + file: string, + options: ExecFileOptions, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptions, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + } + interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable { + execPath?: string | undefined; + execArgv?: string[] | undefined; + silent?: boolean | undefined; + /** + * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ + stdio?: StdioOptions | undefined; + detached?: boolean | undefined; + windowsVerbatimArguments?: boolean | undefined; + } + /** + * The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes. + * Like {@link spawn}, a `ChildProcess` object is returned. The + * returned `ChildProcess` will have an additional communication channel + * built-in that allows messages to be passed back and forth between the parent and + * child. See `subprocess.send()` for details. + * + * Keep in mind that spawned Node.js child processes are + * independent of the parent with exception of the IPC communication channel + * that is established between the two. Each process has its own memory, with + * their own V8 instances. Because of the additional resource allocations + * required, spawning a large number of child Node.js processes is not + * recommended. + * + * By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the`options` object allows for an alternative + * execution path to be used. + * + * Node.js processes launched with a custom `execPath` will communicate with the + * parent process using the file descriptor (fd) identified using the + * environment variable `NODE_CHANNEL_FD` on the child process. + * + * Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the + * current process. + * + * The `shell` option available in {@link spawn} is not supported by`child_process.fork()` and will be ignored if set. + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except + * the error passed to the callback will be an `AbortError`: + * + * ```js + * if (process.argv[2] === 'child') { + * setTimeout(() => { + * console.log(`Hello from ${process.argv[2]}!`); + * }, 1_000); + * } else { + * const { fork } = require('node:child_process'); + * const controller = new AbortController(); + * const { signal } = controller; + * const child = fork(__filename, ['child'], { signal }); + * child.on('error', (err) => { + * // This will be called with err being an AbortError if the controller aborts + * }); + * controller.abort(); // Stops the child process + * } + * ``` + * @since v0.5.0 + * @param modulePath The module to run in the child. + * @param args List of string arguments. + */ + function fork(modulePath: string, options?: ForkOptions): ChildProcess; + function fork(modulePath: string, args?: readonly string[], options?: ForkOptions): ChildProcess; + interface SpawnSyncOptions extends CommonSpawnOptions { + input?: string | NodeJS.ArrayBufferView | undefined; + maxBuffer?: number | undefined; + encoding?: BufferEncoding | "buffer" | null | undefined; + } + interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions { + encoding: BufferEncoding; + } + interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions { + encoding?: "buffer" | null | undefined; + } + interface SpawnSyncReturns { + pid: number; + output: Array; + stdout: T; + stderr: T; + status: number | null; + signal: NodeJS.Signals | null; + error?: Error | undefined; + } + /** + * The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return + * until the child process has fully closed. When a timeout has been encountered + * and `killSignal` is sent, the method won't return until the process has + * completely exited. If the process intercepts and handles the `SIGTERM` signal + * and doesn't exit, the parent process will wait until the child process has + * exited. + * + * **If the `shell` option is enabled, do not pass unsanitized user input to this** + * **function. Any input containing shell metacharacters may be used to trigger** + * **arbitrary command execution.** + * @since v0.11.12 + * @param command The command to run. + * @param args List of string arguments. + */ + function spawnSync(command: string): SpawnSyncReturns; + function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; + function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; + function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; + function spawnSync(command: string, args: readonly string[]): SpawnSyncReturns; + function spawnSync( + command: string, + args: readonly string[], + options: SpawnSyncOptionsWithStringEncoding, + ): SpawnSyncReturns; + function spawnSync( + command: string, + args: readonly string[], + options: SpawnSyncOptionsWithBufferEncoding, + ): SpawnSyncReturns; + function spawnSync( + command: string, + args?: readonly string[], + options?: SpawnSyncOptions, + ): SpawnSyncReturns; + interface CommonExecOptions extends CommonOptions { + input?: string | NodeJS.ArrayBufferView | undefined; + /** + * Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ + stdio?: StdioOptions | undefined; + killSignal?: NodeJS.Signals | number | undefined; + maxBuffer?: number | undefined; + encoding?: BufferEncoding | "buffer" | null | undefined; + } + interface ExecSyncOptions extends CommonExecOptions { + shell?: string | undefined; + } + interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions { + encoding: BufferEncoding; + } + interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions { + encoding?: "buffer" | null | undefined; + } + /** + * The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return + * until the child process has fully closed. When a timeout has been encountered + * and `killSignal` is sent, the method won't return until the process has + * completely exited. If the child process intercepts and handles the `SIGTERM`signal and doesn't exit, the parent process will wait until the child process + * has exited. + * + * If the process times out or has a non-zero exit code, this method will throw. + * The `Error` object will contain the entire result from {@link spawnSync}. + * + * **Never pass unsanitized user input to this function. Any input containing shell** + * **metacharacters may be used to trigger arbitrary command execution.** + * @since v0.11.12 + * @param command The command to run. + * @return The stdout from the command. + */ + function execSync(command: string): Buffer; + function execSync(command: string, options: ExecSyncOptionsWithStringEncoding): string; + function execSync(command: string, options: ExecSyncOptionsWithBufferEncoding): Buffer; + function execSync(command: string, options?: ExecSyncOptions): string | Buffer; + interface ExecFileSyncOptions extends CommonExecOptions { + shell?: boolean | string | undefined; + } + interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions { + encoding: BufferEncoding; + } + interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions { + encoding?: "buffer" | null; // specify `null`. + } + /** + * The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not + * return until the child process has fully closed. When a timeout has been + * encountered and `killSignal` is sent, the method won't return until the process + * has completely exited. + * + * If the child process intercepts and handles the `SIGTERM` signal and + * does not exit, the parent process will still wait until the child process has + * exited. + * + * If the process times out or has a non-zero exit code, this method will throw an `Error` that will include the full result of the underlying {@link spawnSync}. + * + * **If the `shell` option is enabled, do not pass unsanitized user input to this** + * **function. Any input containing shell metacharacters may be used to trigger** + * **arbitrary command execution.** + * @since v0.11.12 + * @param file The name or path of the executable file to run. + * @param args List of string arguments. + * @return The stdout from the command. + */ + function execFileSync(file: string): Buffer; + function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string; + function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer; + function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer; + function execFileSync(file: string, args: readonly string[]): Buffer; + function execFileSync( + file: string, + args: readonly string[], + options: ExecFileSyncOptionsWithStringEncoding, + ): string; + function execFileSync( + file: string, + args: readonly string[], + options: ExecFileSyncOptionsWithBufferEncoding, + ): Buffer; + function execFileSync(file: string, args?: readonly string[], options?: ExecFileSyncOptions): string | Buffer; +} +declare module "node:child_process" { + export * from "child_process"; +} diff --git a/node_modules/@types/node/cluster.d.ts b/node_modules/@types/node/cluster.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39cd56ad3c6e2fa946dc94c84e581e385eab2627 --- /dev/null +++ b/node_modules/@types/node/cluster.d.ts @@ -0,0 +1,432 @@ +/** + * Clusters of Node.js processes can be used to run multiple instances of Node.js + * that can distribute workloads among their application threads. When process + * isolation is not needed, use the `worker_threads` module instead, which + * allows running multiple application threads within a single Node.js instance. + * + * The cluster module allows easy creation of child processes that all share + * server ports. + * + * ```js + * import cluster from 'node:cluster'; + * import http from 'node:http'; + * import { availableParallelism } from 'node:os'; + * import process from 'node:process'; + * + * const numCPUs = availableParallelism(); + * + * if (cluster.isPrimary) { + * console.log(`Primary ${process.pid} is running`); + * + * // Fork workers. + * for (let i = 0; i < numCPUs; i++) { + * cluster.fork(); + * } + * + * cluster.on('exit', (worker, code, signal) => { + * console.log(`worker ${worker.process.pid} died`); + * }); + * } else { + * // Workers can share any TCP connection + * // In this case it is an HTTP server + * http.createServer((req, res) => { + * res.writeHead(200); + * res.end('hello world\n'); + * }).listen(8000); + * + * console.log(`Worker ${process.pid} started`); + * } + * ``` + * + * Running Node.js will now share port 8000 between the workers: + * + * ```console + * $ node server.js + * Primary 3596 is running + * Worker 4324 started + * Worker 4520 started + * Worker 6056 started + * Worker 5644 started + * ``` + * + * On Windows, it is not yet possible to set up a named pipe server in a worker. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/cluster.js) + */ +declare module "cluster" { + import * as child from "node:child_process"; + import EventEmitter = require("node:events"); + import * as net from "node:net"; + type SerializationType = "json" | "advanced"; + export interface ClusterSettings { + execArgv?: string[] | undefined; // default: process.execArgv + exec?: string | undefined; + args?: string[] | undefined; + silent?: boolean | undefined; + stdio?: any[] | undefined; + uid?: number | undefined; + gid?: number | undefined; + inspectPort?: number | (() => number) | undefined; + serialization?: SerializationType | undefined; + cwd?: string | undefined; + windowsHide?: boolean | undefined; + } + export interface Address { + address: string; + port: number; + addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6" + } + /** + * A `Worker` object contains all public information and method about a worker. + * In the primary it can be obtained using `cluster.workers`. In a worker + * it can be obtained using `cluster.worker`. + * @since v0.7.0 + */ + export class Worker extends EventEmitter { + /** + * Each new worker is given its own unique id, this id is stored in the`id`. + * + * While a worker is alive, this is the key that indexes it in`cluster.workers`. + * @since v0.8.0 + */ + id: number; + /** + * All workers are created using `child_process.fork()`, the returned object + * from this function is stored as `.process`. In a worker, the global `process`is stored. + * + * See: `Child Process module`. + * + * Workers will call `process.exit(0)` if the `'disconnect'` event occurs + * on `process` and `.exitedAfterDisconnect` is not `true`. This protects against + * accidental disconnection. + * @since v0.7.0 + */ + process: child.ChildProcess; + /** + * Send a message to a worker or primary, optionally with a handle. + * + * In the primary, this sends a message to a specific worker. It is identical to `ChildProcess.send()`. + * + * In a worker, this sends a message to the primary. It is identical to`process.send()`. + * + * This example will echo back all messages from the primary: + * + * ```js + * if (cluster.isPrimary) { + * const worker = cluster.fork(); + * worker.send('hi there'); + * + * } else if (cluster.isWorker) { + * process.on('message', (msg) => { + * process.send(msg); + * }); + * } + * ``` + * @since v0.7.0 + * @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties: + */ + send(message: child.Serializable, callback?: (error: Error | null) => void): boolean; + send( + message: child.Serializable, + sendHandle: child.SendHandle, + callback?: (error: Error | null) => void, + ): boolean; + send( + message: child.Serializable, + sendHandle: child.SendHandle, + options?: child.MessageOptions, + callback?: (error: Error | null) => void, + ): boolean; + /** + * This function will kill the worker. In the primary worker, it does this by + * disconnecting the `worker.process`, and once disconnected, killing with`signal`. In the worker, it does it by killing the process with `signal`. + * + * The `kill()` function kills the worker process without waiting for a graceful + * disconnect, it has the same behavior as `worker.process.kill()`. + * + * This method is aliased as `worker.destroy()` for backwards compatibility. + * + * In a worker, `process.kill()` exists, but it is not this function; + * it is `kill()`. + * @since v0.9.12 + * @param [signal='SIGTERM'] Name of the kill signal to send to the worker process. + */ + kill(signal?: string): void; + destroy(signal?: string): void; + /** + * In a worker, this function will close all servers, wait for the `'close'` event + * on those servers, and then disconnect the IPC channel. + * + * In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself. + * + * Causes `.exitedAfterDisconnect` to be set. + * + * After a server is closed, it will no longer accept new connections, + * but connections may be accepted by any other listening worker. Existing + * connections will be allowed to close as usual. When no more connections exist, + * see `server.close()`, the IPC channel to the worker will close allowing it + * to die gracefully. + * + * The above applies _only_ to server connections, client connections are not + * automatically closed by workers, and disconnect does not wait for them to close + * before exiting. + * + * In a worker, `process.disconnect` exists, but it is not this function; + * it is `disconnect()`. + * + * Because long living server connections may block workers from disconnecting, it + * may be useful to send a message, so application specific actions may be taken to + * close them. It also may be useful to implement a timeout, killing a worker if + * the `'disconnect'` event has not been emitted after some time. + * + * ```js + * if (cluster.isPrimary) { + * const worker = cluster.fork(); + * let timeout; + * + * worker.on('listening', (address) => { + * worker.send('shutdown'); + * worker.disconnect(); + * timeout = setTimeout(() => { + * worker.kill(); + * }, 2000); + * }); + * + * worker.on('disconnect', () => { + * clearTimeout(timeout); + * }); + * + * } else if (cluster.isWorker) { + * const net = require('node:net'); + * const server = net.createServer((socket) => { + * // Connections never end + * }); + * + * server.listen(8000); + * + * process.on('message', (msg) => { + * if (msg === 'shutdown') { + * // Initiate graceful close of any connections to server + * } + * }); + * } + * ``` + * @since v0.7.7 + * @return A reference to `worker`. + */ + disconnect(): void; + /** + * This function returns `true` if the worker is connected to its primary via its + * IPC channel, `false` otherwise. A worker is connected to its primary after it + * has been created. It is disconnected after the `'disconnect'` event is emitted. + * @since v0.11.14 + */ + isConnected(): boolean; + /** + * This function returns `true` if the worker's process has terminated (either + * because of exiting or being signaled). Otherwise, it returns `false`. + * + * ```js + * import cluster from 'node:cluster'; + * import http from 'node:http'; + * import { availableParallelism } from 'node:os'; + * import process from 'node:process'; + * + * const numCPUs = availableParallelism(); + * + * if (cluster.isPrimary) { + * console.log(`Primary ${process.pid} is running`); + * + * // Fork workers. + * for (let i = 0; i < numCPUs; i++) { + * cluster.fork(); + * } + * + * cluster.on('fork', (worker) => { + * console.log('worker is dead:', worker.isDead()); + * }); + * + * cluster.on('exit', (worker, code, signal) => { + * console.log('worker is dead:', worker.isDead()); + * }); + * } else { + * // Workers can share any TCP connection. In this case, it is an HTTP server. + * http.createServer((req, res) => { + * res.writeHead(200); + * res.end(`Current process\n ${process.pid}`); + * process.kill(process.pid); + * }).listen(8000); + * } + * ``` + * @since v0.11.14 + */ + isDead(): boolean; + /** + * This property is `true` if the worker exited due to `.disconnect()`. + * If the worker exited any other way, it is `false`. If the + * worker has not exited, it is `undefined`. + * + * The boolean `worker.exitedAfterDisconnect` allows distinguishing between + * voluntary and accidental exit, the primary may choose not to respawn a worker + * based on this value. + * + * ```js + * cluster.on('exit', (worker, code, signal) => { + * if (worker.exitedAfterDisconnect === true) { + * console.log('Oh, it was just voluntary – no need to worry'); + * } + * }); + * + * // kill worker + * worker.kill(); + * ``` + * @since v6.0.0 + */ + exitedAfterDisconnect: boolean; + /** + * events.EventEmitter + * 1. disconnect + * 2. error + * 3. exit + * 4. listening + * 5. message + * 6. online + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "disconnect", listener: () => void): this; + addListener(event: "error", listener: (error: Error) => void): this; + addListener(event: "exit", listener: (code: number, signal: string) => void): this; + addListener(event: "listening", listener: (address: Address) => void): this; + addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + addListener(event: "online", listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "disconnect"): boolean; + emit(event: "error", error: Error): boolean; + emit(event: "exit", code: number, signal: string): boolean; + emit(event: "listening", address: Address): boolean; + emit(event: "message", message: any, handle: net.Socket | net.Server): boolean; + emit(event: "online"): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "disconnect", listener: () => void): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "exit", listener: (code: number, signal: string) => void): this; + on(event: "listening", listener: (address: Address) => void): this; + on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + on(event: "online", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "disconnect", listener: () => void): this; + once(event: "error", listener: (error: Error) => void): this; + once(event: "exit", listener: (code: number, signal: string) => void): this; + once(event: "listening", listener: (address: Address) => void): this; + once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + once(event: "online", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "disconnect", listener: () => void): this; + prependListener(event: "error", listener: (error: Error) => void): this; + prependListener(event: "exit", listener: (code: number, signal: string) => void): this; + prependListener(event: "listening", listener: (address: Address) => void): this; + prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + prependListener(event: "online", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "disconnect", listener: () => void): this; + prependOnceListener(event: "error", listener: (error: Error) => void): this; + prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; + prependOnceListener(event: "listening", listener: (address: Address) => void): this; + prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + prependOnceListener(event: "online", listener: () => void): this; + } + export interface Cluster extends EventEmitter { + disconnect(callback?: () => void): void; + fork(env?: any): Worker; + /** @deprecated since v16.0.0 - use isPrimary. */ + readonly isMaster: boolean; + readonly isPrimary: boolean; + readonly isWorker: boolean; + schedulingPolicy: number; + readonly settings: ClusterSettings; + /** @deprecated since v16.0.0 - use setupPrimary. */ + setupMaster(settings?: ClusterSettings): void; + /** + * `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings. + */ + setupPrimary(settings?: ClusterSettings): void; + readonly worker?: Worker | undefined; + readonly workers?: NodeJS.Dict | undefined; + readonly SCHED_NONE: number; + readonly SCHED_RR: number; + /** + * events.EventEmitter + * 1. disconnect + * 2. exit + * 3. fork + * 4. listening + * 5. message + * 6. online + * 7. setup + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "disconnect", listener: (worker: Worker) => void): this; + addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + addListener(event: "fork", listener: (worker: Worker) => void): this; + addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + addListener( + event: "message", + listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void, + ): this; // the handle is a net.Socket or net.Server object, or undefined. + addListener(event: "online", listener: (worker: Worker) => void): this; + addListener(event: "setup", listener: (settings: ClusterSettings) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "disconnect", worker: Worker): boolean; + emit(event: "exit", worker: Worker, code: number, signal: string): boolean; + emit(event: "fork", worker: Worker): boolean; + emit(event: "listening", worker: Worker, address: Address): boolean; + emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean; + emit(event: "online", worker: Worker): boolean; + emit(event: "setup", settings: ClusterSettings): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "disconnect", listener: (worker: Worker) => void): this; + on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + on(event: "fork", listener: (worker: Worker) => void): this; + on(event: "listening", listener: (worker: Worker, address: Address) => void): this; + on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + on(event: "online", listener: (worker: Worker) => void): this; + on(event: "setup", listener: (settings: ClusterSettings) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "disconnect", listener: (worker: Worker) => void): this; + once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + once(event: "fork", listener: (worker: Worker) => void): this; + once(event: "listening", listener: (worker: Worker, address: Address) => void): this; + once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + once(event: "online", listener: (worker: Worker) => void): this; + once(event: "setup", listener: (settings: ClusterSettings) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "disconnect", listener: (worker: Worker) => void): this; + prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + prependListener(event: "fork", listener: (worker: Worker) => void): this; + prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + // the handle is a net.Socket or net.Server object, or undefined. + prependListener( + event: "message", + listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void, + ): this; + prependListener(event: "online", listener: (worker: Worker) => void): this; + prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; + prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; + prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + // the handle is a net.Socket or net.Server object, or undefined. + prependOnceListener( + event: "message", + listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void, + ): this; + prependOnceListener(event: "online", listener: (worker: Worker) => void): this; + prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this; + } + const cluster: Cluster; + export default cluster; +} +declare module "node:cluster" { + export * from "cluster"; + export { default as default } from "cluster"; +} diff --git a/node_modules/@types/node/console.d.ts b/node_modules/@types/node/console.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bcc345042058790cbb22a77c89c62cab472ab86d --- /dev/null +++ b/node_modules/@types/node/console.d.ts @@ -0,0 +1,415 @@ +/** + * The `node:console` module provides a simple debugging console that is similar to + * the JavaScript console mechanism provided by web browsers. + * + * The module exports two specific components: + * + * * A `Console` class with methods such as `console.log()`, `console.error()`, and`console.warn()` that can be used to write to any Node.js stream. + * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('node:console')`. + * + * _**Warning**_: The global console object's methods are neither consistently + * synchronous like the browser APIs they resemble, nor are they consistently + * asynchronous like all other Node.js streams. See the `note on process I/O` for + * more information. + * + * Example using the global `console`: + * + * ```js + * console.log('hello world'); + * // Prints: hello world, to stdout + * console.log('hello %s', 'world'); + * // Prints: hello world, to stdout + * console.error(new Error('Whoops, something bad happened')); + * // Prints error message and stack trace to stderr: + * // Error: Whoops, something bad happened + * // at [eval]:5:15 + * // at Script.runInThisContext (node:vm:132:18) + * // at Object.runInThisContext (node:vm:309:38) + * // at node:internal/process/execution:77:19 + * // at [eval]-wrapper:6:22 + * // at evalScript (node:internal/process/execution:76:60) + * // at node:internal/main/eval_string:23:3 + * + * const name = 'Will Robinson'; + * console.warn(`Danger ${name}! Danger!`); + * // Prints: Danger Will Robinson! Danger!, to stderr + * ``` + * + * Example using the `Console` class: + * + * ```js + * const out = getStreamSomehow(); + * const err = getStreamSomehow(); + * const myConsole = new console.Console(out, err); + * + * myConsole.log('hello world'); + * // Prints: hello world, to out + * myConsole.log('hello %s', 'world'); + * // Prints: hello world, to out + * myConsole.error(new Error('Whoops, something bad happened')); + * // Prints: [Error: Whoops, something bad happened], to err + * + * const name = 'Will Robinson'; + * myConsole.warn(`Danger ${name}! Danger!`); + * // Prints: Danger Will Robinson! Danger!, to err + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/console.js) + */ +declare module "console" { + import console = require("node:console"); + export = console; +} +declare module "node:console" { + import { InspectOptions } from "node:util"; + global { + // This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build + interface Console { + Console: console.ConsoleConstructor; + /** + * `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only + * writes a message and does not otherwise affect execution. The output always + * starts with `"Assertion failed"`. If provided, `message` is formatted using `util.format()`. + * + * If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens. + * + * ```js + * console.assert(true, 'does nothing'); + * + * console.assert(false, 'Whoops %s work', 'didn\'t'); + * // Assertion failed: Whoops didn't work + * + * console.assert(); + * // Assertion failed + * ``` + * @since v0.1.101 + * @param value The value tested for being truthy. + * @param message All arguments besides `value` are used as error message. + */ + assert(value: any, message?: string, ...optionalParams: any[]): void; + /** + * When `stdout` is a TTY, calling `console.clear()` will attempt to clear the + * TTY. When `stdout` is not a TTY, this method does nothing. + * + * The specific operation of `console.clear()` can vary across operating systems + * and terminal types. For most Linux operating systems, `console.clear()`operates similarly to the `clear` shell command. On Windows, `console.clear()`will clear only the output in the + * current terminal viewport for the Node.js + * binary. + * @since v8.3.0 + */ + clear(): void; + /** + * Maintains an internal counter specific to `label` and outputs to `stdout` the + * number of times `console.count()` has been called with the given `label`. + * + * ```js + * > console.count() + * default: 1 + * undefined + * > console.count('default') + * default: 2 + * undefined + * > console.count('abc') + * abc: 1 + * undefined + * > console.count('xyz') + * xyz: 1 + * undefined + * > console.count('abc') + * abc: 2 + * undefined + * > console.count() + * default: 3 + * undefined + * > + * ``` + * @since v8.3.0 + * @param [label='default'] The display label for the counter. + */ + count(label?: string): void; + /** + * Resets the internal counter specific to `label`. + * + * ```js + * > console.count('abc'); + * abc: 1 + * undefined + * > console.countReset('abc'); + * undefined + * > console.count('abc'); + * abc: 1 + * undefined + * > + * ``` + * @since v8.3.0 + * @param [label='default'] The display label for the counter. + */ + countReset(label?: string): void; + /** + * The `console.debug()` function is an alias for {@link log}. + * @since v8.0.0 + */ + debug(message?: any, ...optionalParams: any[]): void; + /** + * Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`. + * This function bypasses any custom `inspect()` function defined on `obj`. + * @since v0.1.101 + */ + dir(obj: any, options?: InspectOptions): void; + /** + * This method calls `console.log()` passing it the arguments received. + * This method does not produce any XML formatting. + * @since v8.0.0 + */ + dirxml(...data: any[]): void; + /** + * Prints to `stderr` with newline. Multiple arguments can be passed, with the + * first used as the primary message and all additional used as substitution + * values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`). + * + * ```js + * const code = 5; + * console.error('error #%d', code); + * // Prints: error #5, to stderr + * console.error('error', code); + * // Prints: error 5, to stderr + * ``` + * + * If formatting elements (e.g. `%d`) are not found in the first string then `util.inspect()` is called on each argument and the resulting string + * values are concatenated. See `util.format()` for more information. + * @since v0.1.100 + */ + error(message?: any, ...optionalParams: any[]): void; + /** + * Increases indentation of subsequent lines by spaces for `groupIndentation`length. + * + * If one or more `label`s are provided, those are printed first without the + * additional indentation. + * @since v8.5.0 + */ + group(...label: any[]): void; + /** + * An alias for {@link group}. + * @since v8.5.0 + */ + groupCollapsed(...label: any[]): void; + /** + * Decreases indentation of subsequent lines by spaces for `groupIndentation`length. + * @since v8.5.0 + */ + groupEnd(): void; + /** + * The `console.info()` function is an alias for {@link log}. + * @since v0.1.100 + */ + info(message?: any, ...optionalParams: any[]): void; + /** + * Prints to `stdout` with newline. Multiple arguments can be passed, with the + * first used as the primary message and all additional used as substitution + * values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`). + * + * ```js + * const count = 5; + * console.log('count: %d', count); + * // Prints: count: 5, to stdout + * console.log('count:', count); + * // Prints: count: 5, to stdout + * ``` + * + * See `util.format()` for more information. + * @since v0.1.100 + */ + log(message?: any, ...optionalParams: any[]): void; + /** + * Try to construct a table with the columns of the properties of `tabularData`(or use `properties`) and rows of `tabularData` and log it. Falls back to just + * logging the argument if it can't be parsed as tabular. + * + * ```js + * // These can't be parsed as tabular data + * console.table(Symbol()); + * // Symbol() + * + * console.table(undefined); + * // undefined + * + * console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]); + * // ┌─────────┬─────┬─────┐ + * // │ (index) │ a │ b │ + * // ├─────────┼─────┼─────┤ + * // │ 0 │ 1 │ 'Y' │ + * // │ 1 │ 'Z' │ 2 │ + * // └─────────┴─────┴─────┘ + * + * console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']); + * // ┌─────────┬─────┐ + * // │ (index) │ a │ + * // ├─────────┼─────┤ + * // │ 0 │ 1 │ + * // │ 1 │ 'Z' │ + * // └─────────┴─────┘ + * ``` + * @since v10.0.0 + * @param properties Alternate properties for constructing the table. + */ + table(tabularData: any, properties?: readonly string[]): void; + /** + * Starts a timer that can be used to compute the duration of an operation. Timers + * are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in + * suitable time units to `stdout`. For example, if the elapsed + * time is 3869ms, `console.timeEnd()` displays "3.869s". + * @since v0.1.104 + * @param [label='default'] + */ + time(label?: string): void; + /** + * Stops a timer that was previously started by calling {@link time} and + * prints the result to `stdout`: + * + * ```js + * console.time('bunch-of-stuff'); + * // Do a bunch of stuff. + * console.timeEnd('bunch-of-stuff'); + * // Prints: bunch-of-stuff: 225.438ms + * ``` + * @since v0.1.104 + * @param [label='default'] + */ + timeEnd(label?: string): void; + /** + * For a timer that was previously started by calling {@link time}, prints + * the elapsed time and other `data` arguments to `stdout`: + * + * ```js + * console.time('process'); + * const value = expensiveProcess1(); // Returns 42 + * console.timeLog('process', value); + * // Prints "process: 365.227ms 42". + * doExpensiveProcess2(value); + * console.timeEnd('process'); + * ``` + * @since v10.7.0 + * @param [label='default'] + */ + timeLog(label?: string, ...data: any[]): void; + /** + * Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code. + * + * ```js + * console.trace('Show me'); + * // Prints: (stack trace will vary based on where trace is called) + * // Trace: Show me + * // at repl:2:9 + * // at REPLServer.defaultEval (repl.js:248:27) + * // at bound (domain.js:287:14) + * // at REPLServer.runBound [as eval] (domain.js:300:12) + * // at REPLServer. (repl.js:412:12) + * // at emitOne (events.js:82:20) + * // at REPLServer.emit (events.js:169:7) + * // at REPLServer.Interface._onLine (readline.js:210:10) + * // at REPLServer.Interface._line (readline.js:549:8) + * // at REPLServer.Interface._ttyWrite (readline.js:826:14) + * ``` + * @since v0.1.104 + */ + trace(message?: any, ...optionalParams: any[]): void; + /** + * The `console.warn()` function is an alias for {@link error}. + * @since v0.1.100 + */ + warn(message?: any, ...optionalParams: any[]): void; + // --- Inspector mode only --- + /** + * This method does not display anything unless used in the inspector. + * Starts a JavaScript CPU profile with an optional label. + */ + profile(label?: string): void; + /** + * This method does not display anything unless used in the inspector. + * Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector. + */ + profileEnd(label?: string): void; + /** + * This method does not display anything unless used in the inspector. + * Adds an event with the label `label` to the Timeline panel of the inspector. + */ + timeStamp(label?: string): void; + } + /** + * The `console` module provides a simple debugging console that is similar to the + * JavaScript console mechanism provided by web browsers. + * + * The module exports two specific components: + * + * * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream. + * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`. + * + * _**Warning**_: The global console object's methods are neither consistently + * synchronous like the browser APIs they resemble, nor are they consistently + * asynchronous like all other Node.js streams. See the `note on process I/O` for + * more information. + * + * Example using the global `console`: + * + * ```js + * console.log('hello world'); + * // Prints: hello world, to stdout + * console.log('hello %s', 'world'); + * // Prints: hello world, to stdout + * console.error(new Error('Whoops, something bad happened')); + * // Prints error message and stack trace to stderr: + * // Error: Whoops, something bad happened + * // at [eval]:5:15 + * // at Script.runInThisContext (node:vm:132:18) + * // at Object.runInThisContext (node:vm:309:38) + * // at node:internal/process/execution:77:19 + * // at [eval]-wrapper:6:22 + * // at evalScript (node:internal/process/execution:76:60) + * // at node:internal/main/eval_string:23:3 + * + * const name = 'Will Robinson'; + * console.warn(`Danger ${name}! Danger!`); + * // Prints: Danger Will Robinson! Danger!, to stderr + * ``` + * + * Example using the `Console` class: + * + * ```js + * const out = getStreamSomehow(); + * const err = getStreamSomehow(); + * const myConsole = new console.Console(out, err); + * + * myConsole.log('hello world'); + * // Prints: hello world, to out + * myConsole.log('hello %s', 'world'); + * // Prints: hello world, to out + * myConsole.error(new Error('Whoops, something bad happened')); + * // Prints: [Error: Whoops, something bad happened], to err + * + * const name = 'Will Robinson'; + * myConsole.warn(`Danger ${name}! Danger!`); + * // Prints: Danger Will Robinson! Danger!, to err + * ``` + * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js) + */ + namespace console { + interface ConsoleConstructorOptions { + stdout: NodeJS.WritableStream; + stderr?: NodeJS.WritableStream | undefined; + ignoreErrors?: boolean | undefined; + colorMode?: boolean | "auto" | undefined; + inspectOptions?: InspectOptions | undefined; + /** + * Set group indentation + * @default 2 + */ + groupIndentation?: number | undefined; + } + interface ConsoleConstructor { + prototype: Console; + new(stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console; + new(options: ConsoleConstructorOptions): Console; + } + } + var console: Console; + } + export = globalThis.console; +} diff --git a/node_modules/@types/node/constants.d.ts b/node_modules/@types/node/constants.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3ac2b826436020bc945c03bb85c9a9479245f2f --- /dev/null +++ b/node_modules/@types/node/constants.d.ts @@ -0,0 +1,19 @@ +/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */ +declare module "constants" { + import { constants as osConstants, SignalConstants } from "node:os"; + import { constants as cryptoConstants } from "node:crypto"; + import { constants as fsConstants } from "node:fs"; + + const exp: + & typeof osConstants.errno + & typeof osConstants.priority + & SignalConstants + & typeof cryptoConstants + & typeof fsConstants; + export = exp; +} + +declare module "node:constants" { + import constants = require("constants"); + export = constants; +} diff --git a/node_modules/@types/node/crypto.d.ts b/node_modules/@types/node/crypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f2038e01a1ec6b18d9457e0ea7809fb2db29471 --- /dev/null +++ b/node_modules/@types/node/crypto.d.ts @@ -0,0 +1,4456 @@ +/** + * The `node:crypto` module provides cryptographic functionality that includes a + * set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify + * functions. + * + * ```js + * const { createHmac } = await import('node:crypto'); + * + * const secret = 'abcdefg'; + * const hash = createHmac('sha256', secret) + * .update('I love cupcakes') + * .digest('hex'); + * console.log(hash); + * // Prints: + * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/crypto.js) + */ +declare module "crypto" { + import * as stream from "node:stream"; + import { PeerCertificate } from "node:tls"; + /** + * SPKAC is a Certificate Signing Request mechanism originally implemented by + * Netscape and was specified formally as part of HTML5's `keygen` element. + * + * `` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects + * should not use this element anymore. + * + * The `node:crypto` module provides the `Certificate` class for working with SPKAC + * data. The most common usage is handling output generated by the HTML5`` element. Node.js uses [OpenSSL's SPKAC + * implementation](https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html) internally. + * @since v0.11.8 + */ + class Certificate { + /** + * ```js + * const { Certificate } = await import('node:crypto'); + * const spkac = getSpkacSomehow(); + * const challenge = Certificate.exportChallenge(spkac); + * console.log(challenge.toString('utf8')); + * // Prints: the challenge as a UTF8 string + * ``` + * @since v9.0.0 + * @param encoding The `encoding` of the `spkac` string. + * @return The challenge component of the `spkac` data structure, which includes a public key and a challenge. + */ + static exportChallenge(spkac: BinaryLike): Buffer; + /** + * ```js + * const { Certificate } = await import('node:crypto'); + * const spkac = getSpkacSomehow(); + * const publicKey = Certificate.exportPublicKey(spkac); + * console.log(publicKey); + * // Prints: the public key as + * ``` + * @since v9.0.0 + * @param encoding The `encoding` of the `spkac` string. + * @return The public key component of the `spkac` data structure, which includes a public key and a challenge. + */ + static exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer; + /** + * ```js + * import { Buffer } from 'node:buffer'; + * const { Certificate } = await import('node:crypto'); + * + * const spkac = getSpkacSomehow(); + * console.log(Certificate.verifySpkac(Buffer.from(spkac))); + * // Prints: true or false + * ``` + * @since v9.0.0 + * @param encoding The `encoding` of the `spkac` string. + * @return `true` if the given `spkac` data structure is valid, `false` otherwise. + */ + static verifySpkac(spkac: NodeJS.ArrayBufferView): boolean; + /** + * @deprecated + * @param spkac + * @returns The challenge component of the `spkac` data structure, + * which includes a public key and a challenge. + */ + exportChallenge(spkac: BinaryLike): Buffer; + /** + * @deprecated + * @param spkac + * @param encoding The encoding of the spkac string. + * @returns The public key component of the `spkac` data structure, + * which includes a public key and a challenge. + */ + exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer; + /** + * @deprecated + * @param spkac + * @returns `true` if the given `spkac` data structure is valid, + * `false` otherwise. + */ + verifySpkac(spkac: NodeJS.ArrayBufferView): boolean; + } + namespace constants { + // https://nodejs.org/dist/latest-v20.x/docs/api/crypto.html#crypto-constants + const OPENSSL_VERSION_NUMBER: number; + /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */ + const SSL_OP_ALL: number; + /** Allows legacy insecure renegotiation between OpenSSL and unpatched clients or servers. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */ + const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; + /** Attempts to use the server's preferences instead of the client's when selecting a cipher. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */ + const SSL_OP_CIPHER_SERVER_PREFERENCE: number; + /** Instructs OpenSSL to use Cisco's "speshul" version of DTLS_BAD_VER. */ + const SSL_OP_CISCO_ANYCONNECT: number; + /** Instructs OpenSSL to turn on cookie exchange. */ + const SSL_OP_COOKIE_EXCHANGE: number; + /** Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. */ + const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; + /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */ + const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; + /** Allows initial connection to servers that do not support RI. */ + const SSL_OP_LEGACY_SERVER_CONNECT: number; + /** Instructs OpenSSL to disable support for SSL/TLS compression. */ + const SSL_OP_NO_COMPRESSION: number; + const SSL_OP_NO_QUERY_MTU: number; + /** Instructs OpenSSL to always start a new session when performing renegotiation. */ + const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; + const SSL_OP_NO_SSLv2: number; + const SSL_OP_NO_SSLv3: number; + const SSL_OP_NO_TICKET: number; + const SSL_OP_NO_TLSv1: number; + const SSL_OP_NO_TLSv1_1: number; + const SSL_OP_NO_TLSv1_2: number; + /** Instructs OpenSSL to disable version rollback attack detection. */ + const SSL_OP_TLS_ROLLBACK_BUG: number; + const ENGINE_METHOD_RSA: number; + const ENGINE_METHOD_DSA: number; + const ENGINE_METHOD_DH: number; + const ENGINE_METHOD_RAND: number; + const ENGINE_METHOD_EC: number; + const ENGINE_METHOD_CIPHERS: number; + const ENGINE_METHOD_DIGESTS: number; + const ENGINE_METHOD_PKEY_METHS: number; + const ENGINE_METHOD_PKEY_ASN1_METHS: number; + const ENGINE_METHOD_ALL: number; + const ENGINE_METHOD_NONE: number; + const DH_CHECK_P_NOT_SAFE_PRIME: number; + const DH_CHECK_P_NOT_PRIME: number; + const DH_UNABLE_TO_CHECK_GENERATOR: number; + const DH_NOT_SUITABLE_GENERATOR: number; + const RSA_PKCS1_PADDING: number; + const RSA_SSLV23_PADDING: number; + const RSA_NO_PADDING: number; + const RSA_PKCS1_OAEP_PADDING: number; + const RSA_X931_PADDING: number; + const RSA_PKCS1_PSS_PADDING: number; + /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the digest size when signing or verifying. */ + const RSA_PSS_SALTLEN_DIGEST: number; + /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the maximum permissible value when signing data. */ + const RSA_PSS_SALTLEN_MAX_SIGN: number; + /** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */ + const RSA_PSS_SALTLEN_AUTO: number; + const POINT_CONVERSION_COMPRESSED: number; + const POINT_CONVERSION_UNCOMPRESSED: number; + const POINT_CONVERSION_HYBRID: number; + /** Specifies the built-in default cipher list used by Node.js (colon-separated values). */ + const defaultCoreCipherList: string; + /** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */ + const defaultCipherList: string; + } + interface HashOptions extends stream.TransformOptions { + /** + * For XOF hash functions such as `shake256`, the + * outputLength option can be used to specify the desired output length in bytes. + */ + outputLength?: number | undefined; + } + /** @deprecated since v10.0.0 */ + const fips: boolean; + /** + * Creates and returns a `Hash` object that can be used to generate hash digests + * using the given `algorithm`. Optional `options` argument controls stream + * behavior. For XOF hash functions such as `'shake256'`, the `outputLength` option + * can be used to specify the desired output length in bytes. + * + * The `algorithm` is dependent on the available algorithms supported by the + * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. + * On recent releases of OpenSSL, `openssl list -digest-algorithms` will + * display the available digest algorithms. + * + * Example: generating the sha256 sum of a file + * + * ```js + * import { + * createReadStream, + * } from 'node:fs'; + * import { argv } from 'node:process'; + * const { + * createHash, + * } = await import('node:crypto'); + * + * const filename = argv[2]; + * + * const hash = createHash('sha256'); + * + * const input = createReadStream(filename); + * input.on('readable', () => { + * // Only one element is going to be produced by the + * // hash stream. + * const data = input.read(); + * if (data) + * hash.update(data); + * else { + * console.log(`${hash.digest('hex')} ${filename}`); + * } + * }); + * ``` + * @since v0.1.92 + * @param options `stream.transform` options + */ + function createHash(algorithm: string, options?: HashOptions): Hash; + /** + * Creates and returns an `Hmac` object that uses the given `algorithm` and `key`. + * Optional `options` argument controls stream behavior. + * + * The `algorithm` is dependent on the available algorithms supported by the + * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. + * On recent releases of OpenSSL, `openssl list -digest-algorithms` will + * display the available digest algorithms. + * + * The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is + * a `KeyObject`, its type must be `secret`. If it is a string, please consider `caveats when using strings as inputs to cryptographic APIs`. If it was + * obtained from a cryptographically secure source of entropy, such as {@link randomBytes} or {@link generateKey}, its length should not + * exceed the block size of `algorithm` (e.g., 512 bits for SHA-256). + * + * Example: generating the sha256 HMAC of a file + * + * ```js + * import { + * createReadStream, + * } from 'node:fs'; + * import { argv } from 'node:process'; + * const { + * createHmac, + * } = await import('node:crypto'); + * + * const filename = argv[2]; + * + * const hmac = createHmac('sha256', 'a secret'); + * + * const input = createReadStream(filename); + * input.on('readable', () => { + * // Only one element is going to be produced by the + * // hash stream. + * const data = input.read(); + * if (data) + * hmac.update(data); + * else { + * console.log(`${hmac.digest('hex')} ${filename}`); + * } + * }); + * ``` + * @since v0.1.94 + * @param options `stream.transform` options + */ + function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac; + // https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings + type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary"; + type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1"; + type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2"; + type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding; + type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; + /** + * The `Hash` class is a utility for creating hash digests of data. It can be + * used in one of two ways: + * + * * As a `stream` that is both readable and writable, where data is written + * to produce a computed hash digest on the readable side, or + * * Using the `hash.update()` and `hash.digest()` methods to produce the + * computed hash. + * + * The {@link createHash} method is used to create `Hash` instances. `Hash`objects are not to be created directly using the `new` keyword. + * + * Example: Using `Hash` objects as streams: + * + * ```js + * const { + * createHash, + * } = await import('node:crypto'); + * + * const hash = createHash('sha256'); + * + * hash.on('readable', () => { + * // Only one element is going to be produced by the + * // hash stream. + * const data = hash.read(); + * if (data) { + * console.log(data.toString('hex')); + * // Prints: + * // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50 + * } + * }); + * + * hash.write('some data to hash'); + * hash.end(); + * ``` + * + * Example: Using `Hash` and piped streams: + * + * ```js + * import { createReadStream } from 'node:fs'; + * import { stdout } from 'node:process'; + * const { createHash } = await import('node:crypto'); + * + * const hash = createHash('sha256'); + * + * const input = createReadStream('test.js'); + * input.pipe(hash).setEncoding('hex').pipe(stdout); + * ``` + * + * Example: Using the `hash.update()` and `hash.digest()` methods: + * + * ```js + * const { + * createHash, + * } = await import('node:crypto'); + * + * const hash = createHash('sha256'); + * + * hash.update('some data to hash'); + * console.log(hash.digest('hex')); + * // Prints: + * // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50 + * ``` + * @since v0.1.92 + */ + class Hash extends stream.Transform { + private constructor(); + /** + * Creates a new `Hash` object that contains a deep copy of the internal state + * of the current `Hash` object. + * + * The optional `options` argument controls stream behavior. For XOF hash + * functions such as `'shake256'`, the `outputLength` option can be used to + * specify the desired output length in bytes. + * + * An error is thrown when an attempt is made to copy the `Hash` object after + * its `hash.digest()` method has been called. + * + * ```js + * // Calculate a rolling hash. + * const { + * createHash, + * } = await import('node:crypto'); + * + * const hash = createHash('sha256'); + * + * hash.update('one'); + * console.log(hash.copy().digest('hex')); + * + * hash.update('two'); + * console.log(hash.copy().digest('hex')); + * + * hash.update('three'); + * console.log(hash.copy().digest('hex')); + * + * // Etc. + * ``` + * @since v13.1.0 + * @param options `stream.transform` options + */ + copy(options?: stream.TransformOptions): Hash; + /** + * Updates the hash content with the given `data`, the encoding of which + * is given in `inputEncoding`. + * If `encoding` is not provided, and the `data` is a string, an + * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored. + * + * This can be called many times with new data as it is streamed. + * @since v0.1.92 + * @param inputEncoding The `encoding` of the `data` string. + */ + update(data: BinaryLike): Hash; + update(data: string, inputEncoding: Encoding): Hash; + /** + * Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method). + * If `encoding` is provided a string will be returned; otherwise + * a `Buffer` is returned. + * + * The `Hash` object can not be used again after `hash.digest()` method has been + * called. Multiple calls will cause an error to be thrown. + * @since v0.1.92 + * @param encoding The `encoding` of the return value. + */ + digest(): Buffer; + digest(encoding: BinaryToTextEncoding): string; + } + /** + * The `Hmac` class is a utility for creating cryptographic HMAC digests. It can + * be used in one of two ways: + * + * * As a `stream` that is both readable and writable, where data is written + * to produce a computed HMAC digest on the readable side, or + * * Using the `hmac.update()` and `hmac.digest()` methods to produce the + * computed HMAC digest. + * + * The {@link createHmac} method is used to create `Hmac` instances. `Hmac`objects are not to be created directly using the `new` keyword. + * + * Example: Using `Hmac` objects as streams: + * + * ```js + * const { + * createHmac, + * } = await import('node:crypto'); + * + * const hmac = createHmac('sha256', 'a secret'); + * + * hmac.on('readable', () => { + * // Only one element is going to be produced by the + * // hash stream. + * const data = hmac.read(); + * if (data) { + * console.log(data.toString('hex')); + * // Prints: + * // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e + * } + * }); + * + * hmac.write('some data to hash'); + * hmac.end(); + * ``` + * + * Example: Using `Hmac` and piped streams: + * + * ```js + * import { createReadStream } from 'node:fs'; + * import { stdout } from 'node:process'; + * const { + * createHmac, + * } = await import('node:crypto'); + * + * const hmac = createHmac('sha256', 'a secret'); + * + * const input = createReadStream('test.js'); + * input.pipe(hmac).pipe(stdout); + * ``` + * + * Example: Using the `hmac.update()` and `hmac.digest()` methods: + * + * ```js + * const { + * createHmac, + * } = await import('node:crypto'); + * + * const hmac = createHmac('sha256', 'a secret'); + * + * hmac.update('some data to hash'); + * console.log(hmac.digest('hex')); + * // Prints: + * // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e + * ``` + * @since v0.1.94 + */ + class Hmac extends stream.Transform { + private constructor(); + /** + * Updates the `Hmac` content with the given `data`, the encoding of which + * is given in `inputEncoding`. + * If `encoding` is not provided, and the `data` is a string, an + * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored. + * + * This can be called many times with new data as it is streamed. + * @since v0.1.94 + * @param inputEncoding The `encoding` of the `data` string. + */ + update(data: BinaryLike): Hmac; + update(data: string, inputEncoding: Encoding): Hmac; + /** + * Calculates the HMAC digest of all of the data passed using `hmac.update()`. + * If `encoding` is + * provided a string is returned; otherwise a `Buffer` is returned; + * + * The `Hmac` object can not be used again after `hmac.digest()` has been + * called. Multiple calls to `hmac.digest()` will result in an error being thrown. + * @since v0.1.94 + * @param encoding The `encoding` of the return value. + */ + digest(): Buffer; + digest(encoding: BinaryToTextEncoding): string; + } + type KeyObjectType = "secret" | "public" | "private"; + interface KeyExportOptions { + type: "pkcs1" | "spki" | "pkcs8" | "sec1"; + format: T; + cipher?: string | undefined; + passphrase?: string | Buffer | undefined; + } + interface JwkKeyExportOptions { + format: "jwk"; + } + interface JsonWebKey { + crv?: string | undefined; + d?: string | undefined; + dp?: string | undefined; + dq?: string | undefined; + e?: string | undefined; + k?: string | undefined; + kty?: string | undefined; + n?: string | undefined; + p?: string | undefined; + q?: string | undefined; + qi?: string | undefined; + x?: string | undefined; + y?: string | undefined; + [key: string]: unknown; + } + interface AsymmetricKeyDetails { + /** + * Key size in bits (RSA, DSA). + */ + modulusLength?: number | undefined; + /** + * Public exponent (RSA). + */ + publicExponent?: bigint | undefined; + /** + * Name of the message digest (RSA-PSS). + */ + hashAlgorithm?: string | undefined; + /** + * Name of the message digest used by MGF1 (RSA-PSS). + */ + mgf1HashAlgorithm?: string | undefined; + /** + * Minimal salt length in bytes (RSA-PSS). + */ + saltLength?: number | undefined; + /** + * Size of q in bits (DSA). + */ + divisorLength?: number | undefined; + /** + * Name of the curve (EC). + */ + namedCurve?: string | undefined; + } + /** + * Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key, + * and each kind of key exposes different functions. The {@link createSecretKey}, {@link createPublicKey} and {@link createPrivateKey} methods are used to create `KeyObject`instances. `KeyObject` + * objects are not to be created directly using the `new`keyword. + * + * Most applications should consider using the new `KeyObject` API instead of + * passing keys as strings or `Buffer`s due to improved security features. + * + * `KeyObject` instances can be passed to other threads via `postMessage()`. + * The receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to + * be listed in the `transferList` argument. + * @since v11.6.0 + */ + class KeyObject { + private constructor(); + /** + * Example: Converting a `CryptoKey` instance to a `KeyObject`: + * + * ```js + * const { KeyObject } = await import('node:crypto'); + * const { subtle } = globalThis.crypto; + * + * const key = await subtle.generateKey({ + * name: 'HMAC', + * hash: 'SHA-256', + * length: 256, + * }, true, ['sign', 'verify']); + * + * const keyObject = KeyObject.from(key); + * console.log(keyObject.symmetricKeySize); + * // Prints: 32 (symmetric key size in bytes) + * ``` + * @since v15.0.0 + */ + static from(key: webcrypto.CryptoKey): KeyObject; + /** + * For asymmetric keys, this property represents the type of the key. Supported key + * types are: + * + * * `'rsa'` (OID 1.2.840.113549.1.1.1) + * * `'rsa-pss'` (OID 1.2.840.113549.1.1.10) + * * `'dsa'` (OID 1.2.840.10040.4.1) + * * `'ec'` (OID 1.2.840.10045.2.1) + * * `'x25519'` (OID 1.3.101.110) + * * `'x448'` (OID 1.3.101.111) + * * `'ed25519'` (OID 1.3.101.112) + * * `'ed448'` (OID 1.3.101.113) + * * `'dh'` (OID 1.2.840.113549.1.3.1) + * + * This property is `undefined` for unrecognized `KeyObject` types and symmetric + * keys. + * @since v11.6.0 + */ + asymmetricKeyType?: KeyType | undefined; + /** + * For asymmetric keys, this property represents the size of the embedded key in + * bytes. This property is `undefined` for symmetric keys. + */ + asymmetricKeySize?: number | undefined; + /** + * This property exists only on asymmetric keys. Depending on the type of the key, + * this object contains information about the key. None of the information obtained + * through this property can be used to uniquely identify a key or to compromise + * the security of the key. + * + * For RSA-PSS keys, if the key material contains a `RSASSA-PSS-params` sequence, + * the `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` properties will be + * set. + * + * Other key details might be exposed via this API using additional attributes. + * @since v15.7.0 + */ + asymmetricKeyDetails?: AsymmetricKeyDetails | undefined; + /** + * For symmetric keys, the following encoding options can be used: + * + * For public keys, the following encoding options can be used: + * + * For private keys, the following encoding options can be used: + * + * The result type depends on the selected encoding format, when PEM the + * result is a string, when DER it will be a buffer containing the data + * encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object. + * + * When [JWK](https://tools.ietf.org/html/rfc7517) encoding format was selected, all other encoding options are + * ignored. + * + * PKCS#1, SEC1, and PKCS#8 type keys can be encrypted by using a combination of + * the `cipher` and `format` options. The PKCS#8 `type` can be used with any`format` to encrypt any key algorithm (RSA, EC, or DH) by specifying a`cipher`. PKCS#1 and SEC1 can only be + * encrypted by specifying a `cipher`when the PEM `format` is used. For maximum compatibility, use PKCS#8 for + * encrypted private keys. Since PKCS#8 defines its own + * encryption mechanism, PEM-level encryption is not supported when encrypting + * a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption and [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for + * PKCS#1 and SEC1 encryption. + * @since v11.6.0 + */ + export(options: KeyExportOptions<"pem">): string | Buffer; + export(options?: KeyExportOptions<"der">): Buffer; + export(options?: JwkKeyExportOptions): JsonWebKey; + /** + * For secret keys, this property represents the size of the key in bytes. This + * property is `undefined` for asymmetric keys. + * @since v11.6.0 + */ + symmetricKeySize?: number | undefined; + /** + * Depending on the type of this `KeyObject`, this property is either`'secret'` for secret (symmetric) keys, `'public'` for public (asymmetric) keys + * or `'private'` for private (asymmetric) keys. + * @since v11.6.0 + */ + type: KeyObjectType; + } + type CipherCCMTypes = "aes-128-ccm" | "aes-192-ccm" | "aes-256-ccm" | "chacha20-poly1305"; + type CipherGCMTypes = "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm"; + type CipherOCBTypes = "aes-128-ocb" | "aes-192-ocb" | "aes-256-ocb"; + type BinaryLike = string | NodeJS.ArrayBufferView; + type CipherKey = BinaryLike | KeyObject; + interface CipherCCMOptions extends stream.TransformOptions { + authTagLength: number; + } + interface CipherGCMOptions extends stream.TransformOptions { + authTagLength?: number | undefined; + } + interface CipherOCBOptions extends stream.TransformOptions { + authTagLength: number; + } + /** + * Creates and returns a `Cipher` object that uses the given `algorithm` and`password`. + * + * The `options` argument controls stream behavior and is optional except when a + * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the + * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication + * tag that will be returned by `getAuthTag()` and defaults to 16 bytes. + * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. + * + * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On + * recent OpenSSL releases, `openssl list -cipher-algorithms` will + * display the available cipher algorithms. + * + * The `password` is used to derive the cipher key and initialization vector (IV). + * The value must be either a `'latin1'` encoded string, a `Buffer`, a`TypedArray`, or a `DataView`. + * + * **This function is semantically insecure for all** + * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,** + * **GCM, or CCM).** + * + * The implementation of `crypto.createCipher()` derives keys using the OpenSSL + * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one + * iteration, and no salt. The lack of salt allows dictionary attacks as the same + * password always creates the same key. The low iteration count and + * non-cryptographically secure hash algorithm allow passwords to be tested very + * rapidly. + * + * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that + * developers derive a key and IV on + * their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode + * (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when + * they are used in order to avoid the risk of IV reuse that causes + * vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting Adversaries](https://github.com/nonce-disrespect/nonce-disrespect) for details. + * @since v0.1.94 + * @deprecated Since v10.0.0 - Use {@link createCipheriv} instead. + * @param options `stream.transform` options + */ + function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM; + /** @deprecated since v10.0.0 use `createCipheriv()` */ + function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM; + /** @deprecated since v10.0.0 use `createCipheriv()` */ + function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher; + /** + * Creates and returns a `Cipher` object, with the given `algorithm`, `key` and + * initialization vector (`iv`). + * + * The `options` argument controls stream behavior and is optional except when a + * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the + * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication + * tag that will be returned by `getAuthTag()` and defaults to 16 bytes. + * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. + * + * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On + * recent OpenSSL releases, `openssl list -cipher-algorithms` will + * display the available cipher algorithms. + * + * The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded + * strings,`Buffers`, `TypedArray`, or `DataView`s. The `key` may optionally be + * a `KeyObject` of type `secret`. If the cipher does not need + * an initialization vector, `iv` may be `null`. + * + * When passing strings for `key` or `iv`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * Initialization vectors should be unpredictable and unique; ideally, they will be + * cryptographically random. They do not have to be secret: IVs are typically just + * added to ciphertext messages unencrypted. It may sound contradictory that + * something has to be unpredictable and unique, but does not have to be secret; + * remember that an attacker must not be able to predict ahead of time what a + * given IV will be. + * @since v0.1.94 + * @param options `stream.transform` options + */ + function createCipheriv( + algorithm: CipherCCMTypes, + key: CipherKey, + iv: BinaryLike, + options: CipherCCMOptions, + ): CipherCCM; + function createCipheriv( + algorithm: CipherOCBTypes, + key: CipherKey, + iv: BinaryLike, + options: CipherOCBOptions, + ): CipherOCB; + function createCipheriv( + algorithm: CipherGCMTypes, + key: CipherKey, + iv: BinaryLike, + options?: CipherGCMOptions, + ): CipherGCM; + function createCipheriv( + algorithm: string, + key: CipherKey, + iv: BinaryLike | null, + options?: stream.TransformOptions, + ): Cipher; + /** + * Instances of the `Cipher` class are used to encrypt data. The class can be + * used in one of two ways: + * + * * As a `stream` that is both readable and writable, where plain unencrypted + * data is written to produce encrypted data on the readable side, or + * * Using the `cipher.update()` and `cipher.final()` methods to produce + * the encrypted data. + * + * The {@link createCipher} or {@link createCipheriv} methods are + * used to create `Cipher` instances. `Cipher` objects are not to be created + * directly using the `new` keyword. + * + * Example: Using `Cipher` objects as streams: + * + * ```js + * const { + * scrypt, + * randomFill, + * createCipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * + * // First, we'll generate the key. The key length is dependent on the algorithm. + * // In this case for aes192, it is 24 bytes (192 bits). + * scrypt(password, 'salt', 24, (err, key) => { + * if (err) throw err; + * // Then, we'll generate a random initialization vector + * randomFill(new Uint8Array(16), (err, iv) => { + * if (err) throw err; + * + * // Once we have the key and iv, we can create and use the cipher... + * const cipher = createCipheriv(algorithm, key, iv); + * + * let encrypted = ''; + * cipher.setEncoding('hex'); + * + * cipher.on('data', (chunk) => encrypted += chunk); + * cipher.on('end', () => console.log(encrypted)); + * + * cipher.write('some clear text data'); + * cipher.end(); + * }); + * }); + * ``` + * + * Example: Using `Cipher` and piped streams: + * + * ```js + * import { + * createReadStream, + * createWriteStream, + * } from 'node:fs'; + * + * import { + * pipeline, + * } from 'node:stream'; + * + * const { + * scrypt, + * randomFill, + * createCipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * + * // First, we'll generate the key. The key length is dependent on the algorithm. + * // In this case for aes192, it is 24 bytes (192 bits). + * scrypt(password, 'salt', 24, (err, key) => { + * if (err) throw err; + * // Then, we'll generate a random initialization vector + * randomFill(new Uint8Array(16), (err, iv) => { + * if (err) throw err; + * + * const cipher = createCipheriv(algorithm, key, iv); + * + * const input = createReadStream('test.js'); + * const output = createWriteStream('test.enc'); + * + * pipeline(input, cipher, output, (err) => { + * if (err) throw err; + * }); + * }); + * }); + * ``` + * + * Example: Using the `cipher.update()` and `cipher.final()` methods: + * + * ```js + * const { + * scrypt, + * randomFill, + * createCipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * + * // First, we'll generate the key. The key length is dependent on the algorithm. + * // In this case for aes192, it is 24 bytes (192 bits). + * scrypt(password, 'salt', 24, (err, key) => { + * if (err) throw err; + * // Then, we'll generate a random initialization vector + * randomFill(new Uint8Array(16), (err, iv) => { + * if (err) throw err; + * + * const cipher = createCipheriv(algorithm, key, iv); + * + * let encrypted = cipher.update('some clear text data', 'utf8', 'hex'); + * encrypted += cipher.final('hex'); + * console.log(encrypted); + * }); + * }); + * ``` + * @since v0.1.94 + */ + class Cipher extends stream.Transform { + private constructor(); + /** + * Updates the cipher with `data`. If the `inputEncoding` argument is given, + * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`, `TypedArray`, or`DataView`. If `data` is a `Buffer`, + * `TypedArray`, or `DataView`, then`inputEncoding` is ignored. + * + * The `outputEncoding` specifies the output format of the enciphered + * data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned. + * + * The `cipher.update()` method can be called multiple times with new data until `cipher.final()` is called. Calling `cipher.update()` after `cipher.final()` will result in an error being + * thrown. + * @since v0.1.94 + * @param inputEncoding The `encoding` of the data. + * @param outputEncoding The `encoding` of the return value. + */ + update(data: BinaryLike): Buffer; + update(data: string, inputEncoding: Encoding): Buffer; + update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string; + update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string; + /** + * Once the `cipher.final()` method has been called, the `Cipher` object can no + * longer be used to encrypt data. Attempts to call `cipher.final()` more than + * once will result in an error being thrown. + * @since v0.1.94 + * @param outputEncoding The `encoding` of the return value. + * @return Any remaining enciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned. + */ + final(): Buffer; + final(outputEncoding: BufferEncoding): string; + /** + * When using block encryption algorithms, the `Cipher` class will automatically + * add padding to the input data to the appropriate block size. To disable the + * default padding call `cipher.setAutoPadding(false)`. + * + * When `autoPadding` is `false`, the length of the entire input data must be a + * multiple of the cipher's block size or `cipher.final()` will throw an error. + * Disabling automatic padding is useful for non-standard padding, for instance + * using `0x0` instead of PKCS padding. + * + * The `cipher.setAutoPadding()` method must be called before `cipher.final()`. + * @since v0.7.1 + * @param [autoPadding=true] + * @return for method chaining. + */ + setAutoPadding(autoPadding?: boolean): this; + } + interface CipherCCM extends Cipher { + setAAD( + buffer: NodeJS.ArrayBufferView, + options: { + plaintextLength: number; + }, + ): this; + getAuthTag(): Buffer; + } + interface CipherGCM extends Cipher { + setAAD( + buffer: NodeJS.ArrayBufferView, + options?: { + plaintextLength: number; + }, + ): this; + getAuthTag(): Buffer; + } + interface CipherOCB extends Cipher { + setAAD( + buffer: NodeJS.ArrayBufferView, + options?: { + plaintextLength: number; + }, + ): this; + getAuthTag(): Buffer; + } + /** + * Creates and returns a `Decipher` object that uses the given `algorithm` and`password` (key). + * + * The `options` argument controls stream behavior and is optional except when a + * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the + * authentication tag in bytes, see `CCM mode`. + * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. + * + * **This function is semantically insecure for all** + * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,** + * **GCM, or CCM).** + * + * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL + * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one + * iteration, and no salt. The lack of salt allows dictionary attacks as the same + * password always creates the same key. The low iteration count and + * non-cryptographically secure hash algorithm allow passwords to be tested very + * rapidly. + * + * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that + * developers derive a key and IV on + * their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object. + * @since v0.1.94 + * @deprecated Since v10.0.0 - Use {@link createDecipheriv} instead. + * @param options `stream.transform` options + */ + function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM; + /** @deprecated since v10.0.0 use `createDecipheriv()` */ + function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM; + /** @deprecated since v10.0.0 use `createDecipheriv()` */ + function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher; + /** + * Creates and returns a `Decipher` object that uses the given `algorithm`, `key`and initialization vector (`iv`). + * + * The `options` argument controls stream behavior and is optional except when a + * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the + * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to restrict accepted authentication tags + * to those with the specified length. + * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. + * + * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On + * recent OpenSSL releases, `openssl list -cipher-algorithms` will + * display the available cipher algorithms. + * + * The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded + * strings,`Buffers`, `TypedArray`, or `DataView`s. The `key` may optionally be + * a `KeyObject` of type `secret`. If the cipher does not need + * an initialization vector, `iv` may be `null`. + * + * When passing strings for `key` or `iv`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * Initialization vectors should be unpredictable and unique; ideally, they will be + * cryptographically random. They do not have to be secret: IVs are typically just + * added to ciphertext messages unencrypted. It may sound contradictory that + * something has to be unpredictable and unique, but does not have to be secret; + * remember that an attacker must not be able to predict ahead of time what a given + * IV will be. + * @since v0.1.94 + * @param options `stream.transform` options + */ + function createDecipheriv( + algorithm: CipherCCMTypes, + key: CipherKey, + iv: BinaryLike, + options: CipherCCMOptions, + ): DecipherCCM; + function createDecipheriv( + algorithm: CipherOCBTypes, + key: CipherKey, + iv: BinaryLike, + options: CipherOCBOptions, + ): DecipherOCB; + function createDecipheriv( + algorithm: CipherGCMTypes, + key: CipherKey, + iv: BinaryLike, + options?: CipherGCMOptions, + ): DecipherGCM; + function createDecipheriv( + algorithm: string, + key: CipherKey, + iv: BinaryLike | null, + options?: stream.TransformOptions, + ): Decipher; + /** + * Instances of the `Decipher` class are used to decrypt data. The class can be + * used in one of two ways: + * + * * As a `stream` that is both readable and writable, where plain encrypted + * data is written to produce unencrypted data on the readable side, or + * * Using the `decipher.update()` and `decipher.final()` methods to + * produce the unencrypted data. + * + * The {@link createDecipher} or {@link createDecipheriv} methods are + * used to create `Decipher` instances. `Decipher` objects are not to be created + * directly using the `new` keyword. + * + * Example: Using `Decipher` objects as streams: + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { + * scryptSync, + * createDecipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * // Key length is dependent on the algorithm. In this case for aes192, it is + * // 24 bytes (192 bits). + * // Use the async `crypto.scrypt()` instead. + * const key = scryptSync(password, 'salt', 24); + * // The IV is usually passed along with the ciphertext. + * const iv = Buffer.alloc(16, 0); // Initialization vector. + * + * const decipher = createDecipheriv(algorithm, key, iv); + * + * let decrypted = ''; + * decipher.on('readable', () => { + * let chunk; + * while (null !== (chunk = decipher.read())) { + * decrypted += chunk.toString('utf8'); + * } + * }); + * decipher.on('end', () => { + * console.log(decrypted); + * // Prints: some clear text data + * }); + * + * // Encrypted with same algorithm, key and iv. + * const encrypted = + * 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; + * decipher.write(encrypted, 'hex'); + * decipher.end(); + * ``` + * + * Example: Using `Decipher` and piped streams: + * + * ```js + * import { + * createReadStream, + * createWriteStream, + * } from 'node:fs'; + * import { Buffer } from 'node:buffer'; + * const { + * scryptSync, + * createDecipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * // Use the async `crypto.scrypt()` instead. + * const key = scryptSync(password, 'salt', 24); + * // The IV is usually passed along with the ciphertext. + * const iv = Buffer.alloc(16, 0); // Initialization vector. + * + * const decipher = createDecipheriv(algorithm, key, iv); + * + * const input = createReadStream('test.enc'); + * const output = createWriteStream('test.js'); + * + * input.pipe(decipher).pipe(output); + * ``` + * + * Example: Using the `decipher.update()` and `decipher.final()` methods: + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { + * scryptSync, + * createDecipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * // Use the async `crypto.scrypt()` instead. + * const key = scryptSync(password, 'salt', 24); + * // The IV is usually passed along with the ciphertext. + * const iv = Buffer.alloc(16, 0); // Initialization vector. + * + * const decipher = createDecipheriv(algorithm, key, iv); + * + * // Encrypted using same algorithm, key and iv. + * const encrypted = + * 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; + * let decrypted = decipher.update(encrypted, 'hex', 'utf8'); + * decrypted += decipher.final('utf8'); + * console.log(decrypted); + * // Prints: some clear text data + * ``` + * @since v0.1.94 + */ + class Decipher extends stream.Transform { + private constructor(); + /** + * Updates the decipher with `data`. If the `inputEncoding` argument is given, + * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`. If `data` is a `Buffer` then `inputEncoding` is + * ignored. + * + * The `outputEncoding` specifies the output format of the enciphered + * data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned. + * + * The `decipher.update()` method can be called multiple times with new data until `decipher.final()` is called. Calling `decipher.update()` after `decipher.final()` will result in an error + * being thrown. + * @since v0.1.94 + * @param inputEncoding The `encoding` of the `data` string. + * @param outputEncoding The `encoding` of the return value. + */ + update(data: NodeJS.ArrayBufferView): Buffer; + update(data: string, inputEncoding: Encoding): Buffer; + update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string; + update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string; + /** + * Once the `decipher.final()` method has been called, the `Decipher` object can + * no longer be used to decrypt data. Attempts to call `decipher.final()` more + * than once will result in an error being thrown. + * @since v0.1.94 + * @param outputEncoding The `encoding` of the return value. + * @return Any remaining deciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned. + */ + final(): Buffer; + final(outputEncoding: BufferEncoding): string; + /** + * When data has been encrypted without standard block padding, calling`decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and + * removing padding. + * + * Turning auto padding off will only work if the input data's length is a + * multiple of the ciphers block size. + * + * The `decipher.setAutoPadding()` method must be called before `decipher.final()`. + * @since v0.7.1 + * @param [autoPadding=true] + * @return for method chaining. + */ + setAutoPadding(auto_padding?: boolean): this; + } + interface DecipherCCM extends Decipher { + setAuthTag(buffer: NodeJS.ArrayBufferView): this; + setAAD( + buffer: NodeJS.ArrayBufferView, + options: { + plaintextLength: number; + }, + ): this; + } + interface DecipherGCM extends Decipher { + setAuthTag(buffer: NodeJS.ArrayBufferView): this; + setAAD( + buffer: NodeJS.ArrayBufferView, + options?: { + plaintextLength: number; + }, + ): this; + } + interface DecipherOCB extends Decipher { + setAuthTag(buffer: NodeJS.ArrayBufferView): this; + setAAD( + buffer: NodeJS.ArrayBufferView, + options?: { + plaintextLength: number; + }, + ): this; + } + interface PrivateKeyInput { + key: string | Buffer; + format?: KeyFormat | undefined; + type?: "pkcs1" | "pkcs8" | "sec1" | undefined; + passphrase?: string | Buffer | undefined; + encoding?: string | undefined; + } + interface PublicKeyInput { + key: string | Buffer; + format?: KeyFormat | undefined; + type?: "pkcs1" | "spki" | undefined; + encoding?: string | undefined; + } + /** + * Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`. + * + * ```js + * const { + * generateKey, + * } = await import('node:crypto'); + * + * generateKey('hmac', { length: 512 }, (err, key) => { + * if (err) throw err; + * console.log(key.export().toString('hex')); // 46e..........620 + * }); + * ``` + * + * The size of a generated HMAC key should not exceed the block size of the + * underlying hash function. See {@link createHmac} for more information. + * @since v15.0.0 + * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`. + */ + function generateKey( + type: "hmac" | "aes", + options: { + length: number; + }, + callback: (err: Error | null, key: KeyObject) => void, + ): void; + /** + * Synchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`. + * + * ```js + * const { + * generateKeySync, + * } = await import('node:crypto'); + * + * const key = generateKeySync('hmac', { length: 512 }); + * console.log(key.export().toString('hex')); // e89..........41e + * ``` + * + * The size of a generated HMAC key should not exceed the block size of the + * underlying hash function. See {@link createHmac} for more information. + * @since v15.0.0 + * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`. + */ + function generateKeySync( + type: "hmac" | "aes", + options: { + length: number; + }, + ): KeyObject; + interface JsonWebKeyInput { + key: JsonWebKey; + format: "jwk"; + } + /** + * Creates and returns a new key object containing a private key. If `key` is a + * string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key`must be an object with the properties described above. + * + * If the private key is encrypted, a `passphrase` must be specified. The length + * of the passphrase is limited to 1024 bytes. + * @since v11.6.0 + */ + function createPrivateKey(key: PrivateKeyInput | string | Buffer | JsonWebKeyInput): KeyObject; + /** + * Creates and returns a new key object containing a public key. If `key` is a + * string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject`with type `'private'`, the public key is derived from the given private key; + * otherwise, `key` must be an object with the properties described above. + * + * If the format is `'pem'`, the `'key'` may also be an X.509 certificate. + * + * Because public keys can be derived from private keys, a private key may be + * passed instead of a public key. In that case, this function behaves as if {@link createPrivateKey} had been called, except that the type of the + * returned `KeyObject` will be `'public'` and that the private key cannot be + * extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type`'private'` is given, a new `KeyObject` with type `'public'` will be returned + * and it will be impossible to extract the private key from the returned object. + * @since v11.6.0 + */ + function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject | JsonWebKeyInput): KeyObject; + /** + * Creates and returns a new key object containing a secret key for symmetric + * encryption or `Hmac`. + * @since v11.6.0 + * @param encoding The string encoding when `key` is a string. + */ + function createSecretKey(key: NodeJS.ArrayBufferView): KeyObject; + function createSecretKey(key: string, encoding: BufferEncoding): KeyObject; + /** + * Creates and returns a `Sign` object that uses the given `algorithm`. Use {@link getHashes} to obtain the names of the available digest algorithms. + * Optional `options` argument controls the `stream.Writable` behavior. + * + * In some cases, a `Sign` instance can be created using the name of a signature + * algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use + * the corresponding digest algorithm. This does not work for all signature + * algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest + * algorithm names. + * @since v0.1.92 + * @param options `stream.Writable` options + */ + function createSign(algorithm: string, options?: stream.WritableOptions): Sign; + type DSAEncoding = "der" | "ieee-p1363"; + interface SigningOptions { + /** + * @see crypto.constants.RSA_PKCS1_PADDING + */ + padding?: number | undefined; + saltLength?: number | undefined; + dsaEncoding?: DSAEncoding | undefined; + } + interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {} + interface SignKeyObjectInput extends SigningOptions { + key: KeyObject; + } + interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {} + interface VerifyKeyObjectInput extends SigningOptions { + key: KeyObject; + } + interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {} + type KeyLike = string | Buffer | KeyObject; + /** + * The `Sign` class is a utility for generating signatures. It can be used in one + * of two ways: + * + * * As a writable `stream`, where data to be signed is written and the `sign.sign()` method is used to generate and return the signature, or + * * Using the `sign.update()` and `sign.sign()` methods to produce the + * signature. + * + * The {@link createSign} method is used to create `Sign` instances. The + * argument is the string name of the hash function to use. `Sign` objects are not + * to be created directly using the `new` keyword. + * + * Example: Using `Sign` and `Verify` objects as streams: + * + * ```js + * const { + * generateKeyPairSync, + * createSign, + * createVerify, + * } = await import('node:crypto'); + * + * const { privateKey, publicKey } = generateKeyPairSync('ec', { + * namedCurve: 'sect239k1', + * }); + * + * const sign = createSign('SHA256'); + * sign.write('some data to sign'); + * sign.end(); + * const signature = sign.sign(privateKey, 'hex'); + * + * const verify = createVerify('SHA256'); + * verify.write('some data to sign'); + * verify.end(); + * console.log(verify.verify(publicKey, signature, 'hex')); + * // Prints: true + * ``` + * + * Example: Using the `sign.update()` and `verify.update()` methods: + * + * ```js + * const { + * generateKeyPairSync, + * createSign, + * createVerify, + * } = await import('node:crypto'); + * + * const { privateKey, publicKey } = generateKeyPairSync('rsa', { + * modulusLength: 2048, + * }); + * + * const sign = createSign('SHA256'); + * sign.update('some data to sign'); + * sign.end(); + * const signature = sign.sign(privateKey); + * + * const verify = createVerify('SHA256'); + * verify.update('some data to sign'); + * verify.end(); + * console.log(verify.verify(publicKey, signature)); + * // Prints: true + * ``` + * @since v0.1.92 + */ + class Sign extends stream.Writable { + private constructor(); + /** + * Updates the `Sign` content with the given `data`, the encoding of which + * is given in `inputEncoding`. + * If `encoding` is not provided, and the `data` is a string, an + * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored. + * + * This can be called many times with new data as it is streamed. + * @since v0.1.92 + * @param inputEncoding The `encoding` of the `data` string. + */ + update(data: BinaryLike): this; + update(data: string, inputEncoding: Encoding): this; + /** + * Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`. + * + * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an + * object, the following additional properties can be passed: + * + * If `outputEncoding` is provided a string is returned; otherwise a `Buffer` is returned. + * + * The `Sign` object can not be again used after `sign.sign()` method has been + * called. Multiple calls to `sign.sign()` will result in an error being thrown. + * @since v0.1.92 + */ + sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer; + sign( + privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput, + outputFormat: BinaryToTextEncoding, + ): string; + } + /** + * Creates and returns a `Verify` object that uses the given algorithm. + * Use {@link getHashes} to obtain an array of names of the available + * signing algorithms. Optional `options` argument controls the`stream.Writable` behavior. + * + * In some cases, a `Verify` instance can be created using the name of a signature + * algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use + * the corresponding digest algorithm. This does not work for all signature + * algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest + * algorithm names. + * @since v0.1.92 + * @param options `stream.Writable` options + */ + function createVerify(algorithm: string, options?: stream.WritableOptions): Verify; + /** + * The `Verify` class is a utility for verifying signatures. It can be used in one + * of two ways: + * + * * As a writable `stream` where written data is used to validate against the + * supplied signature, or + * * Using the `verify.update()` and `verify.verify()` methods to verify + * the signature. + * + * The {@link createVerify} method is used to create `Verify` instances.`Verify` objects are not to be created directly using the `new` keyword. + * + * See `Sign` for examples. + * @since v0.1.92 + */ + class Verify extends stream.Writable { + private constructor(); + /** + * Updates the `Verify` content with the given `data`, the encoding of which + * is given in `inputEncoding`. + * If `inputEncoding` is not provided, and the `data` is a string, an + * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored. + * + * This can be called many times with new data as it is streamed. + * @since v0.1.92 + * @param inputEncoding The `encoding` of the `data` string. + */ + update(data: BinaryLike): Verify; + update(data: string, inputEncoding: Encoding): Verify; + /** + * Verifies the provided data using the given `object` and `signature`. + * + * If `object` is not a `KeyObject`, this function behaves as if`object` had been passed to {@link createPublicKey}. If it is an + * object, the following additional properties can be passed: + * + * The `signature` argument is the previously calculated signature for the data, in + * the `signatureEncoding`. + * If a `signatureEncoding` is specified, the `signature` is expected to be a + * string; otherwise `signature` is expected to be a `Buffer`,`TypedArray`, or `DataView`. + * + * The `verify` object can not be used again after `verify.verify()` has been + * called. Multiple calls to `verify.verify()` will result in an error being + * thrown. + * + * Because public keys can be derived from private keys, a private key may + * be passed instead of a public key. + * @since v0.1.92 + */ + verify( + object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: NodeJS.ArrayBufferView, + ): boolean; + verify( + object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: string, + signature_format?: BinaryToTextEncoding, + ): boolean; + } + /** + * Creates a `DiffieHellman` key exchange object using the supplied `prime` and an + * optional specific `generator`. + * + * The `generator` argument can be a number, string, or `Buffer`. If`generator` is not specified, the value `2` is used. + * + * If `primeEncoding` is specified, `prime` is expected to be a string; otherwise + * a `Buffer`, `TypedArray`, or `DataView` is expected. + * + * If `generatorEncoding` is specified, `generator` is expected to be a string; + * otherwise a number, `Buffer`, `TypedArray`, or `DataView` is expected. + * @since v0.11.12 + * @param primeEncoding The `encoding` of the `prime` string. + * @param [generator=2] + * @param generatorEncoding The `encoding` of the `generator` string. + */ + function createDiffieHellman(primeLength: number, generator?: number): DiffieHellman; + function createDiffieHellman( + prime: ArrayBuffer | NodeJS.ArrayBufferView, + generator?: number | ArrayBuffer | NodeJS.ArrayBufferView, + ): DiffieHellman; + function createDiffieHellman( + prime: ArrayBuffer | NodeJS.ArrayBufferView, + generator: string, + generatorEncoding: BinaryToTextEncoding, + ): DiffieHellman; + function createDiffieHellman( + prime: string, + primeEncoding: BinaryToTextEncoding, + generator?: number | ArrayBuffer | NodeJS.ArrayBufferView, + ): DiffieHellman; + function createDiffieHellman( + prime: string, + primeEncoding: BinaryToTextEncoding, + generator: string, + generatorEncoding: BinaryToTextEncoding, + ): DiffieHellman; + /** + * The `DiffieHellman` class is a utility for creating Diffie-Hellman key + * exchanges. + * + * Instances of the `DiffieHellman` class can be created using the {@link createDiffieHellman} function. + * + * ```js + * import assert from 'node:assert'; + * + * const { + * createDiffieHellman, + * } = await import('node:crypto'); + * + * // Generate Alice's keys... + * const alice = createDiffieHellman(2048); + * const aliceKey = alice.generateKeys(); + * + * // Generate Bob's keys... + * const bob = createDiffieHellman(alice.getPrime(), alice.getGenerator()); + * const bobKey = bob.generateKeys(); + * + * // Exchange and generate the secret... + * const aliceSecret = alice.computeSecret(bobKey); + * const bobSecret = bob.computeSecret(aliceKey); + * + * // OK + * assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); + * ``` + * @since v0.5.0 + */ + class DiffieHellman { + private constructor(); + /** + * Generates private and public Diffie-Hellman key values unless they have been + * generated or computed already, and returns + * the public key in the specified `encoding`. This key should be + * transferred to the other party. + * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned. + * + * This function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular, + * once a private key has been generated or set, calling this function only updates + * the public key but does not generate a new private key. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + generateKeys(): Buffer; + generateKeys(encoding: BinaryToTextEncoding): string; + /** + * Computes the shared secret using `otherPublicKey` as the other + * party's public key and returns the computed shared secret. The supplied + * key is interpreted using the specified `inputEncoding`, and secret is + * encoded using specified `outputEncoding`. + * If the `inputEncoding` is not + * provided, `otherPublicKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`. + * + * If `outputEncoding` is given a string is returned; otherwise, a `Buffer` is returned. + * @since v0.5.0 + * @param inputEncoding The `encoding` of an `otherPublicKey` string. + * @param outputEncoding The `encoding` of the return value. + */ + computeSecret(otherPublicKey: NodeJS.ArrayBufferView, inputEncoding?: null, outputEncoding?: null): Buffer; + computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding?: null): Buffer; + computeSecret( + otherPublicKey: NodeJS.ArrayBufferView, + inputEncoding: null, + outputEncoding: BinaryToTextEncoding, + ): string; + computeSecret( + otherPublicKey: string, + inputEncoding: BinaryToTextEncoding, + outputEncoding: BinaryToTextEncoding, + ): string; + /** + * Returns the Diffie-Hellman prime in the specified `encoding`. + * If `encoding` is provided a string is + * returned; otherwise a `Buffer` is returned. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + getPrime(): Buffer; + getPrime(encoding: BinaryToTextEncoding): string; + /** + * Returns the Diffie-Hellman generator in the specified `encoding`. + * If `encoding` is provided a string is + * returned; otherwise a `Buffer` is returned. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + getGenerator(): Buffer; + getGenerator(encoding: BinaryToTextEncoding): string; + /** + * Returns the Diffie-Hellman public key in the specified `encoding`. + * If `encoding` is provided a + * string is returned; otherwise a `Buffer` is returned. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + getPublicKey(): Buffer; + getPublicKey(encoding: BinaryToTextEncoding): string; + /** + * Returns the Diffie-Hellman private key in the specified `encoding`. + * If `encoding` is provided a + * string is returned; otherwise a `Buffer` is returned. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + getPrivateKey(): Buffer; + getPrivateKey(encoding: BinaryToTextEncoding): string; + /** + * Sets the Diffie-Hellman public key. If the `encoding` argument is provided,`publicKey` is expected + * to be a string. If no `encoding` is provided, `publicKey` is expected + * to be a `Buffer`, `TypedArray`, or `DataView`. + * @since v0.5.0 + * @param encoding The `encoding` of the `publicKey` string. + */ + setPublicKey(publicKey: NodeJS.ArrayBufferView): void; + setPublicKey(publicKey: string, encoding: BufferEncoding): void; + /** + * Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected + * to be a string. If no `encoding` is provided, `privateKey` is expected + * to be a `Buffer`, `TypedArray`, or `DataView`. + * + * This function does not automatically compute the associated public key. Either `diffieHellman.setPublicKey()` or `diffieHellman.generateKeys()` can be + * used to manually provide the public key or to automatically derive it. + * @since v0.5.0 + * @param encoding The `encoding` of the `privateKey` string. + */ + setPrivateKey(privateKey: NodeJS.ArrayBufferView): void; + setPrivateKey(privateKey: string, encoding: BufferEncoding): void; + /** + * A bit field containing any warnings and/or errors resulting from a check + * performed during initialization of the `DiffieHellman` object. + * + * The following values are valid for this property (as defined in `node:constants` module): + * + * * `DH_CHECK_P_NOT_SAFE_PRIME` + * * `DH_CHECK_P_NOT_PRIME` + * * `DH_UNABLE_TO_CHECK_GENERATOR` + * * `DH_NOT_SUITABLE_GENERATOR` + * @since v0.11.12 + */ + verifyError: number; + } + /** + * The `DiffieHellmanGroup` class takes a well-known modp group as its argument. + * It works the same as `DiffieHellman`, except that it does not allow changing its keys after creation. + * In other words, it does not implement `setPublicKey()` or `setPrivateKey()` methods. + * + * ```js + * const { createDiffieHellmanGroup } = await import('node:crypto'); + * const dh = createDiffieHellmanGroup('modp1'); + * ``` + * The name (e.g. `'modp1'`) is taken from [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt) (modp1 and 2) and [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt): + * ```bash + * $ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h + * modp1 # 768 bits + * modp2 # 1024 bits + * modp5 # 1536 bits + * modp14 # 2048 bits + * modp15 # etc. + * modp16 + * modp17 + * modp18 + * ``` + * @since v0.7.5 + */ + const DiffieHellmanGroup: DiffieHellmanGroupConstructor; + interface DiffieHellmanGroupConstructor { + new(name: string): DiffieHellmanGroup; + (name: string): DiffieHellmanGroup; + readonly prototype: DiffieHellmanGroup; + } + type DiffieHellmanGroup = Omit; + /** + * Creates a predefined `DiffieHellmanGroup` key exchange object. The + * supported groups are listed in the documentation for `DiffieHellmanGroup`. + * + * The returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing + * the keys (with `diffieHellman.setPublicKey()`, for example). The + * advantage of using this method is that the parties do not have to + * generate nor exchange a group modulus beforehand, saving both processor + * and communication time. + * + * Example (obtaining a shared secret): + * + * ```js + * const { + * getDiffieHellman, + * } = await import('node:crypto'); + * const alice = getDiffieHellman('modp14'); + * const bob = getDiffieHellman('modp14'); + * + * alice.generateKeys(); + * bob.generateKeys(); + * + * const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex'); + * const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex'); + * + * // aliceSecret and bobSecret should be the same + * console.log(aliceSecret === bobSecret); + * ``` + * @since v0.7.5 + */ + function getDiffieHellman(groupName: string): DiffieHellmanGroup; + /** + * An alias for {@link getDiffieHellman} + * @since v0.9.3 + */ + function createDiffieHellmanGroup(name: string): DiffieHellmanGroup; + /** + * Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) + * implementation. A selected HMAC digest algorithm specified by `digest` is + * applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`. + * + * The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an error occurs while deriving the key, `err` will be set; + * otherwise `err` will be `null`. By default, the successfully generated`derivedKey` will be passed to the callback as a `Buffer`. An error will be + * thrown if any of the input arguments specify invalid values or types. + * + * The `iterations` argument must be a number set as high as possible. The + * higher the number of iterations, the more secure the derived key will be, + * but will take a longer amount of time to complete. + * + * The `salt` should be as unique as possible. It is recommended that a salt is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * ```js + * const { + * pbkdf2, + * } = await import('node:crypto'); + * + * pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => { + * if (err) throw err; + * console.log(derivedKey.toString('hex')); // '3745e48...08d59ae' + * }); + * ``` + * + * An array of supported digest functions can be retrieved using {@link getHashes}. + * + * This API uses libuv's threadpool, which can have surprising and + * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information. + * @since v0.5.5 + */ + function pbkdf2( + password: BinaryLike, + salt: BinaryLike, + iterations: number, + keylen: number, + digest: string, + callback: (err: Error | null, derivedKey: Buffer) => void, + ): void; + /** + * Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2) + * implementation. A selected HMAC digest algorithm specified by `digest` is + * applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`. + * + * If an error occurs an `Error` will be thrown, otherwise the derived key will be + * returned as a `Buffer`. + * + * The `iterations` argument must be a number set as high as possible. The + * higher the number of iterations, the more secure the derived key will be, + * but will take a longer amount of time to complete. + * + * The `salt` should be as unique as possible. It is recommended that a salt is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * ```js + * const { + * pbkdf2Sync, + * } = await import('node:crypto'); + * + * const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512'); + * console.log(key.toString('hex')); // '3745e48...08d59ae' + * ``` + * + * An array of supported digest functions can be retrieved using {@link getHashes}. + * @since v0.9.3 + */ + function pbkdf2Sync( + password: BinaryLike, + salt: BinaryLike, + iterations: number, + keylen: number, + digest: string, + ): Buffer; + /** + * Generates cryptographically strong pseudorandom data. The `size` argument + * is a number indicating the number of bytes to generate. + * + * If a `callback` function is provided, the bytes are generated asynchronously + * and the `callback` function is invoked with two arguments: `err` and `buf`. + * If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The`buf` argument is a `Buffer` containing the generated bytes. + * + * ```js + * // Asynchronous + * const { + * randomBytes, + * } = await import('node:crypto'); + * + * randomBytes(256, (err, buf) => { + * if (err) throw err; + * console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`); + * }); + * ``` + * + * If the `callback` function is not provided, the random bytes are generated + * synchronously and returned as a `Buffer`. An error will be thrown if + * there is a problem generating the bytes. + * + * ```js + * // Synchronous + * const { + * randomBytes, + * } = await import('node:crypto'); + * + * const buf = randomBytes(256); + * console.log( + * `${buf.length} bytes of random data: ${buf.toString('hex')}`); + * ``` + * + * The `crypto.randomBytes()` method will not complete until there is + * sufficient entropy available. + * This should normally never take longer than a few milliseconds. The only time + * when generating the random bytes may conceivably block for a longer period of + * time is right after boot, when the whole system is still low on entropy. + * + * This API uses libuv's threadpool, which can have surprising and + * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information. + * + * The asynchronous version of `crypto.randomBytes()` is carried out in a single + * threadpool request. To minimize threadpool task length variation, partition + * large `randomBytes` requests when doing so as part of fulfilling a client + * request. + * @since v0.5.8 + * @param size The number of bytes to generate. The `size` must not be larger than `2**31 - 1`. + * @return if the `callback` function is not provided. + */ + function randomBytes(size: number): Buffer; + function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void; + function pseudoRandomBytes(size: number): Buffer; + function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void; + /** + * Return a random integer `n` such that `min <= n < max`. This + * implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias). + * + * The range (`max - min`) must be less than 248. `min` and `max` must + * be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger). + * + * If the `callback` function is not provided, the random integer is + * generated synchronously. + * + * ```js + * // Asynchronous + * const { + * randomInt, + * } = await import('node:crypto'); + * + * randomInt(3, (err, n) => { + * if (err) throw err; + * console.log(`Random number chosen from (0, 1, 2): ${n}`); + * }); + * ``` + * + * ```js + * // Synchronous + * const { + * randomInt, + * } = await import('node:crypto'); + * + * const n = randomInt(3); + * console.log(`Random number chosen from (0, 1, 2): ${n}`); + * ``` + * + * ```js + * // With `min` argument + * const { + * randomInt, + * } = await import('node:crypto'); + * + * const n = randomInt(1, 7); + * console.log(`The dice rolled: ${n}`); + * ``` + * @since v14.10.0, v12.19.0 + * @param [min=0] Start of random range (inclusive). + * @param max End of random range (exclusive). + * @param callback `function(err, n) {}`. + */ + function randomInt(max: number): number; + function randomInt(min: number, max: number): number; + function randomInt(max: number, callback: (err: Error | null, value: number) => void): void; + function randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void; + /** + * Synchronous version of {@link randomFill}. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { randomFillSync } = await import('node:crypto'); + * + * const buf = Buffer.alloc(10); + * console.log(randomFillSync(buf).toString('hex')); + * + * randomFillSync(buf, 5); + * console.log(buf.toString('hex')); + * + * // The above is equivalent to the following: + * randomFillSync(buf, 5, 5); + * console.log(buf.toString('hex')); + * ``` + * + * Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as`buffer`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { randomFillSync } = await import('node:crypto'); + * + * const a = new Uint32Array(10); + * console.log(Buffer.from(randomFillSync(a).buffer, + * a.byteOffset, a.byteLength).toString('hex')); + * + * const b = new DataView(new ArrayBuffer(10)); + * console.log(Buffer.from(randomFillSync(b).buffer, + * b.byteOffset, b.byteLength).toString('hex')); + * + * const c = new ArrayBuffer(10); + * console.log(Buffer.from(randomFillSync(c)).toString('hex')); + * ``` + * @since v7.10.0, v6.13.0 + * @param buffer Must be supplied. The size of the provided `buffer` must not be larger than `2**31 - 1`. + * @param [offset=0] + * @param [size=buffer.length - offset] + * @return The object passed as `buffer` argument. + */ + function randomFillSync(buffer: T, offset?: number, size?: number): T; + /** + * This function is similar to {@link randomBytes} but requires the first + * argument to be a `Buffer` that will be filled. It also + * requires that a callback is passed in. + * + * If the `callback` function is not provided, an error will be thrown. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { randomFill } = await import('node:crypto'); + * + * const buf = Buffer.alloc(10); + * randomFill(buf, (err, buf) => { + * if (err) throw err; + * console.log(buf.toString('hex')); + * }); + * + * randomFill(buf, 5, (err, buf) => { + * if (err) throw err; + * console.log(buf.toString('hex')); + * }); + * + * // The above is equivalent to the following: + * randomFill(buf, 5, 5, (err, buf) => { + * if (err) throw err; + * console.log(buf.toString('hex')); + * }); + * ``` + * + * Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as`buffer`. + * + * While this includes instances of `Float32Array` and `Float64Array`, this + * function should not be used to generate random floating-point numbers. The + * result may contain `+Infinity`, `-Infinity`, and `NaN`, and even if the array + * contains finite numbers only, they are not drawn from a uniform random + * distribution and have no meaningful lower or upper bounds. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { randomFill } = await import('node:crypto'); + * + * const a = new Uint32Array(10); + * randomFill(a, (err, buf) => { + * if (err) throw err; + * console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength) + * .toString('hex')); + * }); + * + * const b = new DataView(new ArrayBuffer(10)); + * randomFill(b, (err, buf) => { + * if (err) throw err; + * console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength) + * .toString('hex')); + * }); + * + * const c = new ArrayBuffer(10); + * randomFill(c, (err, buf) => { + * if (err) throw err; + * console.log(Buffer.from(buf).toString('hex')); + * }); + * ``` + * + * This API uses libuv's threadpool, which can have surprising and + * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information. + * + * The asynchronous version of `crypto.randomFill()` is carried out in a single + * threadpool request. To minimize threadpool task length variation, partition + * large `randomFill` requests when doing so as part of fulfilling a client + * request. + * @since v7.10.0, v6.13.0 + * @param buffer Must be supplied. The size of the provided `buffer` must not be larger than `2**31 - 1`. + * @param [offset=0] + * @param [size=buffer.length - offset] + * @param callback `function(err, buf) {}`. + */ + function randomFill( + buffer: T, + callback: (err: Error | null, buf: T) => void, + ): void; + function randomFill( + buffer: T, + offset: number, + callback: (err: Error | null, buf: T) => void, + ): void; + function randomFill( + buffer: T, + offset: number, + size: number, + callback: (err: Error | null, buf: T) => void, + ): void; + interface ScryptOptions { + cost?: number | undefined; + blockSize?: number | undefined; + parallelization?: number | undefined; + N?: number | undefined; + r?: number | undefined; + p?: number | undefined; + maxmem?: number | undefined; + } + /** + * Provides an asynchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based + * key derivation function that is designed to be expensive computationally and + * memory-wise in order to make brute-force attacks unrewarding. + * + * The `salt` should be as unique as possible. It is recommended that a salt is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * The `callback` function is called with two arguments: `err` and `derivedKey`.`err` is an exception object when key derivation fails, otherwise `err` is`null`. `derivedKey` is passed to the + * callback as a `Buffer`. + * + * An exception is thrown when any of the input arguments specify invalid values + * or types. + * + * ```js + * const { + * scrypt, + * } = await import('node:crypto'); + * + * // Using the factory defaults. + * scrypt('password', 'salt', 64, (err, derivedKey) => { + * if (err) throw err; + * console.log(derivedKey.toString('hex')); // '3745e48...08d59ae' + * }); + * // Using a custom N parameter. Must be a power of two. + * scrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => { + * if (err) throw err; + * console.log(derivedKey.toString('hex')); // '3745e48...aa39b34' + * }); + * ``` + * @since v10.5.0 + */ + function scrypt( + password: BinaryLike, + salt: BinaryLike, + keylen: number, + callback: (err: Error | null, derivedKey: Buffer) => void, + ): void; + function scrypt( + password: BinaryLike, + salt: BinaryLike, + keylen: number, + options: ScryptOptions, + callback: (err: Error | null, derivedKey: Buffer) => void, + ): void; + /** + * Provides a synchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based + * key derivation function that is designed to be expensive computationally and + * memory-wise in order to make brute-force attacks unrewarding. + * + * The `salt` should be as unique as possible. It is recommended that a salt is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * An exception is thrown when key derivation fails, otherwise the derived key is + * returned as a `Buffer`. + * + * An exception is thrown when any of the input arguments specify invalid values + * or types. + * + * ```js + * const { + * scryptSync, + * } = await import('node:crypto'); + * // Using the factory defaults. + * + * const key1 = scryptSync('password', 'salt', 64); + * console.log(key1.toString('hex')); // '3745e48...08d59ae' + * // Using a custom N parameter. Must be a power of two. + * const key2 = scryptSync('password', 'salt', 64, { N: 1024 }); + * console.log(key2.toString('hex')); // '3745e48...aa39b34' + * ``` + * @since v10.5.0 + */ + function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer; + interface RsaPublicKey { + key: KeyLike; + padding?: number | undefined; + } + interface RsaPrivateKey { + key: KeyLike; + passphrase?: string | undefined; + /** + * @default 'sha1' + */ + oaepHash?: string | undefined; + oaepLabel?: NodeJS.TypedArray | undefined; + padding?: number | undefined; + } + /** + * Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using + * the corresponding private key, for example using {@link privateDecrypt}. + * + * If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an + * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`. + * + * Because RSA public keys can be derived from private keys, a private key may + * be passed instead of a public key. + * @since v0.11.14 + */ + function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer; + /** + * Decrypts `buffer` with `key`.`buffer` was previously encrypted using + * the corresponding private key, for example using {@link privateEncrypt}. + * + * If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an + * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`. + * + * Because RSA public keys can be derived from private keys, a private key may + * be passed instead of a public key. + * @since v1.1.0 + */ + function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer; + /** + * Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using + * the corresponding public key, for example using {@link publicEncrypt}. + * + * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an + * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`. + * @since v0.11.14 + */ + function privateDecrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer; + /** + * Encrypts `buffer` with `privateKey`. The returned data can be decrypted using + * the corresponding public key, for example using {@link publicDecrypt}. + * + * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an + * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`. + * @since v1.1.0 + */ + function privateEncrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer; + /** + * ```js + * const { + * getCiphers, + * } = await import('node:crypto'); + * + * console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...] + * ``` + * @since v0.9.3 + * @return An array with the names of the supported cipher algorithms. + */ + function getCiphers(): string[]; + /** + * ```js + * const { + * getCurves, + * } = await import('node:crypto'); + * + * console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] + * ``` + * @since v2.3.0 + * @return An array with the names of the supported elliptic curves. + */ + function getCurves(): string[]; + /** + * @since v10.0.0 + * @return `1` if and only if a FIPS compliant crypto provider is currently in use, `0` otherwise. A future semver-major release may change the return type of this API to a {boolean}. + */ + function getFips(): 1 | 0; + /** + * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. + * Throws an error if FIPS mode is not available. + * @since v10.0.0 + * @param bool `true` to enable FIPS mode. + */ + function setFips(bool: boolean): void; + /** + * ```js + * const { + * getHashes, + * } = await import('node:crypto'); + * + * console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...] + * ``` + * @since v0.9.3 + * @return An array of the names of the supported hash algorithms, such as `'RSA-SHA256'`. Hash algorithms are also called "digest" algorithms. + */ + function getHashes(): string[]; + /** + * The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH) + * key exchanges. + * + * Instances of the `ECDH` class can be created using the {@link createECDH} function. + * + * ```js + * import assert from 'node:assert'; + * + * const { + * createECDH, + * } = await import('node:crypto'); + * + * // Generate Alice's keys... + * const alice = createECDH('secp521r1'); + * const aliceKey = alice.generateKeys(); + * + * // Generate Bob's keys... + * const bob = createECDH('secp521r1'); + * const bobKey = bob.generateKeys(); + * + * // Exchange and generate the secret... + * const aliceSecret = alice.computeSecret(bobKey); + * const bobSecret = bob.computeSecret(aliceKey); + * + * assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); + * // OK + * ``` + * @since v0.11.14 + */ + class ECDH { + private constructor(); + /** + * Converts the EC Diffie-Hellman public key specified by `key` and `curve` to the + * format specified by `format`. The `format` argument specifies point encoding + * and can be `'compressed'`, `'uncompressed'` or `'hybrid'`. The supplied key is + * interpreted using the specified `inputEncoding`, and the returned key is encoded + * using the specified `outputEncoding`. + * + * Use {@link getCurves} to obtain a list of available curve names. + * On recent OpenSSL releases, `openssl ecparam -list_curves` will also display + * the name and description of each available elliptic curve. + * + * If `format` is not specified the point will be returned in `'uncompressed'`format. + * + * If the `inputEncoding` is not provided, `key` is expected to be a `Buffer`,`TypedArray`, or `DataView`. + * + * Example (uncompressing a key): + * + * ```js + * const { + * createECDH, + * ECDH, + * } = await import('node:crypto'); + * + * const ecdh = createECDH('secp256k1'); + * ecdh.generateKeys(); + * + * const compressedKey = ecdh.getPublicKey('hex', 'compressed'); + * + * const uncompressedKey = ECDH.convertKey(compressedKey, + * 'secp256k1', + * 'hex', + * 'hex', + * 'uncompressed'); + * + * // The converted key and the uncompressed public key should be the same + * console.log(uncompressedKey === ecdh.getPublicKey('hex')); + * ``` + * @since v10.0.0 + * @param inputEncoding The `encoding` of the `key` string. + * @param outputEncoding The `encoding` of the return value. + * @param [format='uncompressed'] + */ + static convertKey( + key: BinaryLike, + curve: string, + inputEncoding?: BinaryToTextEncoding, + outputEncoding?: "latin1" | "hex" | "base64" | "base64url", + format?: "uncompressed" | "compressed" | "hybrid", + ): Buffer | string; + /** + * Generates private and public EC Diffie-Hellman key values, and returns + * the public key in the specified `format` and `encoding`. This key should be + * transferred to the other party. + * + * The `format` argument specifies point encoding and can be `'compressed'` or`'uncompressed'`. If `format` is not specified, the point will be returned in`'uncompressed'` format. + * + * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned. + * @since v0.11.14 + * @param encoding The `encoding` of the return value. + * @param [format='uncompressed'] + */ + generateKeys(): Buffer; + generateKeys(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string; + /** + * Computes the shared secret using `otherPublicKey` as the other + * party's public key and returns the computed shared secret. The supplied + * key is interpreted using specified `inputEncoding`, and the returned secret + * is encoded using the specified `outputEncoding`. + * If the `inputEncoding` is not + * provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or`DataView`. + * + * If `outputEncoding` is given a string will be returned; otherwise a `Buffer` is returned. + * + * `ecdh.computeSecret` will throw an`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey`lies outside of the elliptic curve. Since `otherPublicKey` is + * usually supplied from a remote user over an insecure network, + * be sure to handle this exception accordingly. + * @since v0.11.14 + * @param inputEncoding The `encoding` of the `otherPublicKey` string. + * @param outputEncoding The `encoding` of the return value. + */ + computeSecret(otherPublicKey: NodeJS.ArrayBufferView): Buffer; + computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): Buffer; + computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string; + computeSecret( + otherPublicKey: string, + inputEncoding: BinaryToTextEncoding, + outputEncoding: BinaryToTextEncoding, + ): string; + /** + * If `encoding` is specified, a string is returned; otherwise a `Buffer` is + * returned. + * @since v0.11.14 + * @param encoding The `encoding` of the return value. + * @return The EC Diffie-Hellman in the specified `encoding`. + */ + getPrivateKey(): Buffer; + getPrivateKey(encoding: BinaryToTextEncoding): string; + /** + * The `format` argument specifies point encoding and can be `'compressed'` or`'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format. + * + * If `encoding` is specified, a string is returned; otherwise a `Buffer` is + * returned. + * @since v0.11.14 + * @param encoding The `encoding` of the return value. + * @param [format='uncompressed'] + * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`. + */ + getPublicKey(encoding?: null, format?: ECDHKeyFormat): Buffer; + getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string; + /** + * Sets the EC Diffie-Hellman private key. + * If `encoding` is provided, `privateKey` is expected + * to be a string; otherwise `privateKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`. + * + * If `privateKey` is not valid for the curve specified when the `ECDH` object was + * created, an error is thrown. Upon setting the private key, the associated + * public point (key) is also generated and set in the `ECDH` object. + * @since v0.11.14 + * @param encoding The `encoding` of the `privateKey` string. + */ + setPrivateKey(privateKey: NodeJS.ArrayBufferView): void; + setPrivateKey(privateKey: string, encoding: BinaryToTextEncoding): void; + } + /** + * Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a + * predefined curve specified by the `curveName` string. Use {@link getCurves} to obtain a list of available curve names. On recent + * OpenSSL releases, `openssl ecparam -list_curves` will also display the name + * and description of each available elliptic curve. + * @since v0.11.14 + */ + function createECDH(curveName: string): ECDH; + /** + * This function compares the underlying bytes that represent the given`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time + * algorithm. + * + * This function does not leak timing information that + * would allow an attacker to guess one of the values. This is suitable for + * comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/). + * + * `a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they + * must have the same byte length. An error is thrown if `a` and `b` have + * different byte lengths. + * + * If at least one of `a` and `b` is a `TypedArray` with more than one byte per + * entry, such as `Uint16Array`, the result will be computed using the platform + * byte order. + * + * **When both of the inputs are `Float32Array`s or`Float64Array`s, this function might return unexpected results due to IEEE 754** + * **encoding of floating-point numbers. In particular, neither `x === y` nor`Object.is(x, y)` implies that the byte representations of two floating-point** + * **numbers `x` and `y` are equal.** + * + * Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code + * is timing-safe. Care should be taken to ensure that the surrounding code does + * not introduce timing vulnerabilities. + * @since v6.6.0 + */ + function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean; + type KeyType = "rsa" | "rsa-pss" | "dsa" | "ec" | "ed25519" | "ed448" | "x25519" | "x448"; + type KeyFormat = "pem" | "der" | "jwk"; + interface BasePrivateKeyEncodingOptions { + format: T; + cipher?: string | undefined; + passphrase?: string | undefined; + } + interface KeyPairKeyObjectResult { + publicKey: KeyObject; + privateKey: KeyObject; + } + interface ED25519KeyPairKeyObjectOptions {} + interface ED448KeyPairKeyObjectOptions {} + interface X25519KeyPairKeyObjectOptions {} + interface X448KeyPairKeyObjectOptions {} + interface ECKeyPairKeyObjectOptions { + /** + * Name of the curve to use + */ + namedCurve: string; + } + interface RSAKeyPairKeyObjectOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Public exponent + * @default 0x10001 + */ + publicExponent?: number | undefined; + } + interface RSAPSSKeyPairKeyObjectOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Public exponent + * @default 0x10001 + */ + publicExponent?: number | undefined; + /** + * Name of the message digest + */ + hashAlgorithm?: string; + /** + * Name of the message digest used by MGF1 + */ + mgf1HashAlgorithm?: string; + /** + * Minimal salt length in bytes + */ + saltLength?: string; + } + interface DSAKeyPairKeyObjectOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Size of q in bits + */ + divisorLength: number; + } + interface RSAKeyPairOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Public exponent + * @default 0x10001 + */ + publicExponent?: number | undefined; + publicKeyEncoding: { + type: "pkcs1" | "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs1" | "pkcs8"; + }; + } + interface RSAPSSKeyPairOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Public exponent + * @default 0x10001 + */ + publicExponent?: number | undefined; + /** + * Name of the message digest + */ + hashAlgorithm?: string; + /** + * Name of the message digest used by MGF1 + */ + mgf1HashAlgorithm?: string; + /** + * Minimal salt length in bytes + */ + saltLength?: string; + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface DSAKeyPairOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Size of q in bits + */ + divisorLength: number; + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface ECKeyPairOptions { + /** + * Name of the curve to use. + */ + namedCurve: string; + publicKeyEncoding: { + type: "pkcs1" | "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "sec1" | "pkcs8"; + }; + } + interface ED25519KeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface ED448KeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface X25519KeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface X448KeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface KeyPairSyncResult { + publicKey: T1; + privateKey: T2; + } + /** + * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC, + * Ed25519, Ed448, X25519, X448, and DH are currently supported. + * + * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function + * behaves as if `keyObject.export()` had been called on its result. Otherwise, + * the respective part of the key is returned as a `KeyObject`. + * + * When encoding public keys, it is recommended to use `'spki'`. When encoding + * private keys, it is recommended to use `'pkcs8'` with a strong passphrase, + * and to keep the passphrase confidential. + * + * ```js + * const { + * generateKeyPairSync, + * } = await import('node:crypto'); + * + * const { + * publicKey, + * privateKey, + * } = generateKeyPairSync('rsa', { + * modulusLength: 4096, + * publicKeyEncoding: { + * type: 'spki', + * format: 'pem', + * }, + * privateKeyEncoding: { + * type: 'pkcs8', + * format: 'pem', + * cipher: 'aes-256-cbc', + * passphrase: 'top secret', + * }, + * }); + * ``` + * + * The return value `{ publicKey, privateKey }` represents the generated key pair. + * When PEM encoding was selected, the respective key will be a string, otherwise + * it will be a buffer containing the data encoded as DER. + * @since v10.12.0 + * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`. + */ + function generateKeyPairSync( + type: "rsa", + options: RSAKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa", + options: RSAKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa", + options: RSAKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa", + options: RSAKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "rsa", options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "rsa-pss", options: RSAPSSKeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "dsa", + options: DSAKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "dsa", + options: DSAKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "dsa", + options: DSAKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "dsa", + options: DSAKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "dsa", options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "ec", + options: ECKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ec", + options: ECKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ec", + options: ECKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ec", + options: ECKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "ec", options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "ed25519", options?: ED25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "ed448", + options: ED448KeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed448", + options: ED448KeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed448", + options: ED448KeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed448", + options: ED448KeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "ed448", options?: ED448KeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "x25519", + options: X25519KeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x25519", + options: X25519KeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x25519", + options: X25519KeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x25519", + options: X25519KeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "x25519", options?: X25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "x448", + options: X448KeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x448", + options: X448KeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x448", + options: X448KeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x448", + options: X448KeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "x448", options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult; + /** + * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC, + * Ed25519, Ed448, X25519, X448, and DH are currently supported. + * + * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function + * behaves as if `keyObject.export()` had been called on its result. Otherwise, + * the respective part of the key is returned as a `KeyObject`. + * + * It is recommended to encode public keys as `'spki'` and private keys as`'pkcs8'` with encryption for long-term storage: + * + * ```js + * const { + * generateKeyPair, + * } = await import('node:crypto'); + * + * generateKeyPair('rsa', { + * modulusLength: 4096, + * publicKeyEncoding: { + * type: 'spki', + * format: 'pem', + * }, + * privateKeyEncoding: { + * type: 'pkcs8', + * format: 'pem', + * cipher: 'aes-256-cbc', + * passphrase: 'top secret', + * }, + * }, (err, publicKey, privateKey) => { + * // Handle errors and use the generated key pair. + * }); + * ``` + * + * On completion, `callback` will be called with `err` set to `undefined` and`publicKey` / `privateKey` representing the generated key pair. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a `Promise` for an `Object` with `publicKey` and `privateKey` properties. + * @since v10.12.0 + * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`. + */ + function generateKeyPair( + type: "rsa", + options: RSAKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "rsa", + options: RSAKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "rsa", + options: RSAKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "rsa", + options: RSAKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "rsa", + options: RSAKeyPairKeyObjectOptions, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairKeyObjectOptions, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairKeyObjectOptions, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairKeyObjectOptions, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + namespace generateKeyPair { + function __promisify__( + type: "rsa", + options: RSAKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "rsa", + options: RSAKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "rsa", + options: RSAKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "rsa", + options: RSAKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairKeyObjectOptions, + ): Promise; + function __promisify__( + type: "dsa", + options: DSAKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "dsa", + options: DSAKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "dsa", + options: DSAKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "dsa", + options: DSAKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise; + function __promisify__( + type: "ec", + options: ECKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "ec", + options: ECKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "ec", + options: ECKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "ec", + options: ECKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise; + function __promisify__( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__( + type: "ed25519", + options?: ED25519KeyPairKeyObjectOptions, + ): Promise; + function __promisify__( + type: "ed448", + options: ED448KeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "ed448", + options: ED448KeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "ed448", + options: ED448KeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "ed448", + options: ED448KeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "ed448", options?: ED448KeyPairKeyObjectOptions): Promise; + function __promisify__( + type: "x25519", + options: X25519KeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "x25519", + options: X25519KeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "x25519", + options: X25519KeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "x25519", + options: X25519KeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__( + type: "x25519", + options?: X25519KeyPairKeyObjectOptions, + ): Promise; + function __promisify__( + type: "x448", + options: X448KeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "x448", + options: X448KeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "x448", + options: X448KeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "x448", + options: X448KeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "x448", options?: X448KeyPairKeyObjectOptions): Promise; + } + /** + * Calculates and returns the signature for `data` using the given private key and + * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is + * dependent upon the key type (especially Ed25519 and Ed448). + * + * If `key` is not a `KeyObject`, this function behaves as if `key` had been + * passed to {@link createPrivateKey}. If it is an object, the following + * additional properties can be passed: + * + * If the `callback` function is provided this function uses libuv's threadpool. + * @since v12.0.0 + */ + function sign( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput, + ): Buffer; + function sign( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput, + callback: (error: Error | null, data: Buffer) => void, + ): void; + /** + * Verifies the given signature for `data` using the given key and algorithm. If`algorithm` is `null` or `undefined`, then the algorithm is dependent upon the + * key type (especially Ed25519 and Ed448). + * + * If `key` is not a `KeyObject`, this function behaves as if `key` had been + * passed to {@link createPublicKey}. If it is an object, the following + * additional properties can be passed: + * + * The `signature` argument is the previously calculated signature for the `data`. + * + * Because public keys can be derived from private keys, a private key or a public + * key may be passed for `key`. + * + * If the `callback` function is provided this function uses libuv's threadpool. + * @since v12.0.0 + */ + function verify( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: NodeJS.ArrayBufferView, + ): boolean; + function verify( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: NodeJS.ArrayBufferView, + callback: (error: Error | null, result: boolean) => void, + ): void; + /** + * Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`. + * Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'`(for Diffie-Hellman), `'ec'` (for ECDH), `'x448'`, or `'x25519'` (for ECDH-ES). + * @since v13.9.0, v12.17.0 + */ + function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): Buffer; + type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts"; + interface CipherInfoOptions { + /** + * A test key length. + */ + keyLength?: number | undefined; + /** + * A test IV length. + */ + ivLength?: number | undefined; + } + interface CipherInfo { + /** + * The name of the cipher. + */ + name: string; + /** + * The nid of the cipher. + */ + nid: number; + /** + * The block size of the cipher in bytes. + * This property is omitted when mode is 'stream'. + */ + blockSize?: number | undefined; + /** + * The expected or default initialization vector length in bytes. + * This property is omitted if the cipher does not use an initialization vector. + */ + ivLength?: number | undefined; + /** + * The expected or default key length in bytes. + */ + keyLength: number; + /** + * The cipher mode. + */ + mode: CipherMode; + } + /** + * Returns information about a given cipher. + * + * Some ciphers accept variable length keys and initialization vectors. By default, + * the `crypto.getCipherInfo()` method will return the default values for these + * ciphers. To test if a given key length or iv length is acceptable for given + * cipher, use the `keyLength` and `ivLength` options. If the given values are + * unacceptable, `undefined` will be returned. + * @since v15.0.0 + * @param nameOrNid The name or nid of the cipher to query. + */ + function getCipherInfo(nameOrNid: string | number, options?: CipherInfoOptions): CipherInfo | undefined; + /** + * HKDF is a simple key derivation function defined in RFC 5869\. The given `ikm`,`salt` and `info` are used with the `digest` to derive a key of `keylen` bytes. + * + * The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an errors occurs while deriving the key, `err` will be set; + * otherwise `err` will be `null`. The successfully generated `derivedKey` will + * be passed to the callback as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). An error will be thrown if any + * of the input arguments specify invalid values or types. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { + * hkdf, + * } = await import('node:crypto'); + * + * hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => { + * if (err) throw err; + * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653' + * }); + * ``` + * @since v15.0.0 + * @param digest The digest algorithm to use. + * @param ikm The input keying material. Must be provided but can be zero-length. + * @param salt The salt value. Must be provided but can be zero-length. + * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes. + * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512` + * generates 64-byte hashes, making the maximum HKDF output 16320 bytes). + */ + function hkdf( + digest: string, + irm: BinaryLike | KeyObject, + salt: BinaryLike, + info: BinaryLike, + keylen: number, + callback: (err: Error | null, derivedKey: ArrayBuffer) => void, + ): void; + /** + * Provides a synchronous HKDF key derivation function as defined in RFC 5869\. The + * given `ikm`, `salt` and `info` are used with the `digest` to derive a key of`keylen` bytes. + * + * The successfully generated `derivedKey` will be returned as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). + * + * An error will be thrown if any of the input arguments specify invalid values or + * types, or if the derived key cannot be generated. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { + * hkdfSync, + * } = await import('node:crypto'); + * + * const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64); + * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653' + * ``` + * @since v15.0.0 + * @param digest The digest algorithm to use. + * @param ikm The input keying material. Must be provided but can be zero-length. + * @param salt The salt value. Must be provided but can be zero-length. + * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes. + * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512` + * generates 64-byte hashes, making the maximum HKDF output 16320 bytes). + */ + function hkdfSync( + digest: string, + ikm: BinaryLike | KeyObject, + salt: BinaryLike, + info: BinaryLike, + keylen: number, + ): ArrayBuffer; + interface SecureHeapUsage { + /** + * The total allocated secure heap size as specified using the `--secure-heap=n` command-line flag. + */ + total: number; + /** + * The minimum allocation from the secure heap as specified using the `--secure-heap-min` command-line flag. + */ + min: number; + /** + * The total number of bytes currently allocated from the secure heap. + */ + used: number; + /** + * The calculated ratio of `used` to `total` allocated bytes. + */ + utilization: number; + } + /** + * @since v15.6.0 + */ + function secureHeapUsed(): SecureHeapUsage; + interface RandomUUIDOptions { + /** + * By default, to improve performance, + * Node.js will pre-emptively generate and persistently cache enough + * random data to generate up to 128 random UUIDs. To generate a UUID + * without using the cache, set `disableEntropyCache` to `true`. + * + * @default `false` + */ + disableEntropyCache?: boolean | undefined; + } + type UUID = `${string}-${string}-${string}-${string}-${string}`; + /** + * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a + * cryptographic pseudorandom number generator. + * @since v15.6.0, v14.17.0 + */ + function randomUUID(options?: RandomUUIDOptions): UUID; + interface X509CheckOptions { + /** + * @default 'always' + */ + subject?: "always" | "default" | "never"; + /** + * @default true + */ + wildcards?: boolean; + /** + * @default true + */ + partialWildcards?: boolean; + /** + * @default false + */ + multiLabelWildcards?: boolean; + /** + * @default false + */ + singleLabelSubdomains?: boolean; + } + /** + * Encapsulates an X509 certificate and provides read-only access to + * its information. + * + * ```js + * const { X509Certificate } = await import('node:crypto'); + * + * const x509 = new X509Certificate('{... pem encoded cert ...}'); + * + * console.log(x509.subject); + * ``` + * @since v15.6.0 + */ + class X509Certificate { + /** + * Will be \`true\` if this is a Certificate Authority (CA) certificate. + * @since v15.6.0 + */ + readonly ca: boolean; + /** + * The SHA-1 fingerprint of this certificate. + * + * Because SHA-1 is cryptographically broken and because the security of SHA-1 is + * significantly worse than that of algorithms that are commonly used to sign + * certificates, consider using `x509.fingerprint256` instead. + * @since v15.6.0 + */ + readonly fingerprint: string; + /** + * The SHA-256 fingerprint of this certificate. + * @since v15.6.0 + */ + readonly fingerprint256: string; + /** + * The SHA-512 fingerprint of this certificate. + * + * Because computing the SHA-256 fingerprint is usually faster and because it is + * only half the size of the SHA-512 fingerprint, `x509.fingerprint256` may be + * a better choice. While SHA-512 presumably provides a higher level of security in + * general, the security of SHA-256 matches that of most algorithms that are + * commonly used to sign certificates. + * @since v17.2.0, v16.14.0 + */ + readonly fingerprint512: string; + /** + * The complete subject of this certificate. + * @since v15.6.0 + */ + readonly subject: string; + /** + * The subject alternative name specified for this certificate. + * + * This is a comma-separated list of subject alternative names. Each entry begins + * with a string identifying the kind of the subject alternative name followed by + * a colon and the value associated with the entry. + * + * Earlier versions of Node.js incorrectly assumed that it is safe to split this + * property at the two-character sequence `', '` (see [CVE-2021-44532](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532)). However, + * both malicious and legitimate certificates can contain subject alternative names + * that include this sequence when represented as a string. + * + * After the prefix denoting the type of the entry, the remainder of each entry + * might be enclosed in quotes to indicate that the value is a JSON string literal. + * For backward compatibility, Node.js only uses JSON string literals within this + * property when necessary to avoid ambiguity. Third-party code should be prepared + * to handle both possible entry formats. + * @since v15.6.0 + */ + readonly subjectAltName: string | undefined; + /** + * A textual representation of the certificate's authority information access + * extension. + * + * This is a line feed separated list of access descriptions. Each line begins with + * the access method and the kind of the access location, followed by a colon and + * the value associated with the access location. + * + * After the prefix denoting the access method and the kind of the access location, + * the remainder of each line might be enclosed in quotes to indicate that the + * value is a JSON string literal. For backward compatibility, Node.js only uses + * JSON string literals within this property when necessary to avoid ambiguity. + * Third-party code should be prepared to handle both possible entry formats. + * @since v15.6.0 + */ + readonly infoAccess: string | undefined; + /** + * An array detailing the key usages for this certificate. + * @since v15.6.0 + */ + readonly keyUsage: string[]; + /** + * The issuer identification included in this certificate. + * @since v15.6.0 + */ + readonly issuer: string; + /** + * The issuer certificate or `undefined` if the issuer certificate is not + * available. + * @since v15.9.0 + */ + readonly issuerCertificate?: X509Certificate | undefined; + /** + * The public key `KeyObject` for this certificate. + * @since v15.6.0 + */ + readonly publicKey: KeyObject; + /** + * A `Buffer` containing the DER encoding of this certificate. + * @since v15.6.0 + */ + readonly raw: Buffer; + /** + * The serial number of this certificate. + * + * Serial numbers are assigned by certificate authorities and do not uniquely + * identify certificates. Consider using `x509.fingerprint256` as a unique + * identifier instead. + * @since v15.6.0 + */ + readonly serialNumber: string; + /** + * The date/time from which this certificate is considered valid. + * @since v15.6.0 + */ + readonly validFrom: string; + /** + * The date/time until which this certificate is considered valid. + * @since v15.6.0 + */ + readonly validTo: string; + constructor(buffer: BinaryLike); + /** + * Checks whether the certificate matches the given email address. + * + * If the `'subject'` option is undefined or set to `'default'`, the certificate + * subject is only considered if the subject alternative name extension either does + * not exist or does not contain any email addresses. + * + * If the `'subject'` option is set to `'always'` and if the subject alternative + * name extension either does not exist or does not contain a matching email + * address, the certificate subject is considered. + * + * If the `'subject'` option is set to `'never'`, the certificate subject is never + * considered, even if the certificate contains no subject alternative names. + * @since v15.6.0 + * @return Returns `email` if the certificate matches, `undefined` if it does not. + */ + checkEmail(email: string, options?: Pick): string | undefined; + /** + * Checks whether the certificate matches the given host name. + * + * If the certificate matches the given host name, the matching subject name is + * returned. The returned name might be an exact match (e.g., `foo.example.com`) + * or it might contain wildcards (e.g., `*.example.com`). Because host name + * comparisons are case-insensitive, the returned subject name might also differ + * from the given `name` in capitalization. + * + * If the `'subject'` option is undefined or set to `'default'`, the certificate + * subject is only considered if the subject alternative name extension either does + * not exist or does not contain any DNS names. This behavior is consistent with [RFC 2818](https://www.rfc-editor.org/rfc/rfc2818.txt) ("HTTP Over TLS"). + * + * If the `'subject'` option is set to `'always'` and if the subject alternative + * name extension either does not exist or does not contain a matching DNS name, + * the certificate subject is considered. + * + * If the `'subject'` option is set to `'never'`, the certificate subject is never + * considered, even if the certificate contains no subject alternative names. + * @since v15.6.0 + * @return Returns a subject name that matches `name`, or `undefined` if no subject name matches `name`. + */ + checkHost(name: string, options?: X509CheckOptions): string | undefined; + /** + * Checks whether the certificate matches the given IP address (IPv4 or IPv6). + * + * Only [RFC 5280](https://www.rfc-editor.org/rfc/rfc5280.txt) `iPAddress` subject alternative names are considered, and they + * must match the given `ip` address exactly. Other subject alternative names as + * well as the subject field of the certificate are ignored. + * @since v15.6.0 + * @return Returns `ip` if the certificate matches, `undefined` if it does not. + */ + checkIP(ip: string): string | undefined; + /** + * Checks whether this certificate was issued by the given `otherCert`. + * @since v15.6.0 + */ + checkIssued(otherCert: X509Certificate): boolean; + /** + * Checks whether the public key for this certificate is consistent with + * the given private key. + * @since v15.6.0 + * @param privateKey A private key. + */ + checkPrivateKey(privateKey: KeyObject): boolean; + /** + * There is no standard JSON encoding for X509 certificates. The`toJSON()` method returns a string containing the PEM encoded + * certificate. + * @since v15.6.0 + */ + toJSON(): string; + /** + * Returns information about this certificate using the legacy `certificate object` encoding. + * @since v15.6.0 + */ + toLegacyObject(): PeerCertificate; + /** + * Returns the PEM-encoded certificate. + * @since v15.6.0 + */ + toString(): string; + /** + * Verifies that this certificate was signed by the given public key. + * Does not perform any other validation checks on the certificate. + * @since v15.6.0 + * @param publicKey A public key. + */ + verify(publicKey: KeyObject): boolean; + } + type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint; + interface GeneratePrimeOptions { + add?: LargeNumberLike | undefined; + rem?: LargeNumberLike | undefined; + /** + * @default false + */ + safe?: boolean | undefined; + bigint?: boolean | undefined; + } + interface GeneratePrimeOptionsBigInt extends GeneratePrimeOptions { + bigint: true; + } + interface GeneratePrimeOptionsArrayBuffer extends GeneratePrimeOptions { + bigint?: false | undefined; + } + /** + * Generates a pseudorandom prime of `size` bits. + * + * If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime. + * + * The `options.add` and `options.rem` parameters can be used to enforce additional + * requirements, e.g., for Diffie-Hellman: + * + * * If `options.add` and `options.rem` are both set, the prime will satisfy the + * condition that `prime % add = rem`. + * * If only `options.add` is set and `options.safe` is not `true`, the prime will + * satisfy the condition that `prime % add = 1`. + * * If only `options.add` is set and `options.safe` is set to `true`, the prime + * will instead satisfy the condition that `prime % add = 3`. This is necessary + * because `prime % add = 1` for `options.add > 2` would contradict the condition + * enforced by `options.safe`. + * * `options.rem` is ignored if `options.add` is not given. + * + * Both `options.add` and `options.rem` must be encoded as big-endian sequences + * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`. + * + * By default, the prime is encoded as a big-endian sequence of octets + * in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a + * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) is provided. + * @since v15.8.0 + * @param size The size (in bits) of the prime to generate. + */ + function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void; + function generatePrime( + size: number, + options: GeneratePrimeOptionsBigInt, + callback: (err: Error | null, prime: bigint) => void, + ): void; + function generatePrime( + size: number, + options: GeneratePrimeOptionsArrayBuffer, + callback: (err: Error | null, prime: ArrayBuffer) => void, + ): void; + function generatePrime( + size: number, + options: GeneratePrimeOptions, + callback: (err: Error | null, prime: ArrayBuffer | bigint) => void, + ): void; + /** + * Generates a pseudorandom prime of `size` bits. + * + * If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime. + * + * The `options.add` and `options.rem` parameters can be used to enforce additional + * requirements, e.g., for Diffie-Hellman: + * + * * If `options.add` and `options.rem` are both set, the prime will satisfy the + * condition that `prime % add = rem`. + * * If only `options.add` is set and `options.safe` is not `true`, the prime will + * satisfy the condition that `prime % add = 1`. + * * If only `options.add` is set and `options.safe` is set to `true`, the prime + * will instead satisfy the condition that `prime % add = 3`. This is necessary + * because `prime % add = 1` for `options.add > 2` would contradict the condition + * enforced by `options.safe`. + * * `options.rem` is ignored if `options.add` is not given. + * + * Both `options.add` and `options.rem` must be encoded as big-endian sequences + * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`. + * + * By default, the prime is encoded as a big-endian sequence of octets + * in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a + * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) is provided. + * @since v15.8.0 + * @param size The size (in bits) of the prime to generate. + */ + function generatePrimeSync(size: number): ArrayBuffer; + function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint; + function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer; + function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint; + interface CheckPrimeOptions { + /** + * The number of Miller-Rabin probabilistic primality iterations to perform. + * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input. + * Care must be used when selecting a number of checks. + * Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details. + * + * @default 0 + */ + checks?: number | undefined; + } + /** + * Checks the primality of the `candidate`. + * @since v15.8.0 + * @param candidate A possible prime encoded as a sequence of big endian octets of arbitrary length. + */ + function checkPrime(value: LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void; + function checkPrime( + value: LargeNumberLike, + options: CheckPrimeOptions, + callback: (err: Error | null, result: boolean) => void, + ): void; + /** + * Checks the primality of the `candidate`. + * @since v15.8.0 + * @param candidate A possible prime encoded as a sequence of big endian octets of arbitrary length. + * @return `true` if the candidate is a prime with an error probability less than `0.25 ** options.checks`. + */ + function checkPrimeSync(candidate: LargeNumberLike, options?: CheckPrimeOptions): boolean; + /** + * Load and set the `engine` for some or all OpenSSL functions (selected by flags). + * + * `engine` could be either an id or a path to the engine's shared library. + * + * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`is a bit field taking one of or a mix of the following flags (defined in`crypto.constants`): + * + * * `crypto.constants.ENGINE_METHOD_RSA` + * * `crypto.constants.ENGINE_METHOD_DSA` + * * `crypto.constants.ENGINE_METHOD_DH` + * * `crypto.constants.ENGINE_METHOD_RAND` + * * `crypto.constants.ENGINE_METHOD_EC` + * * `crypto.constants.ENGINE_METHOD_CIPHERS` + * * `crypto.constants.ENGINE_METHOD_DIGESTS` + * * `crypto.constants.ENGINE_METHOD_PKEY_METHS` + * * `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS` + * * `crypto.constants.ENGINE_METHOD_ALL` + * * `crypto.constants.ENGINE_METHOD_NONE` + * @since v0.11.11 + * @param flags + */ + function setEngine(engine: string, flags?: number): void; + /** + * A convenient alias for {@link webcrypto.getRandomValues}. This + * implementation is not compliant with the Web Crypto spec, to write + * web-compatible code use {@link webcrypto.getRandomValues} instead. + * @since v17.4.0 + * @return Returns `typedArray`. + */ + function getRandomValues(typedArray: T): T; + /** + * A convenient alias for `crypto.webcrypto.subtle`. + * @since v17.4.0 + */ + const subtle: webcrypto.SubtleCrypto; + /** + * An implementation of the Web Crypto API standard. + * + * See the {@link https://nodejs.org/docs/latest/api/webcrypto.html Web Crypto API documentation} for details. + * @since v15.0.0 + */ + const webcrypto: webcrypto.Crypto; + namespace webcrypto { + type BufferSource = ArrayBufferView | ArrayBuffer; + type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki"; + type KeyType = "private" | "public" | "secret"; + type KeyUsage = + | "decrypt" + | "deriveBits" + | "deriveKey" + | "encrypt" + | "sign" + | "unwrapKey" + | "verify" + | "wrapKey"; + type AlgorithmIdentifier = Algorithm | string; + type HashAlgorithmIdentifier = AlgorithmIdentifier; + type NamedCurve = string; + type BigInteger = Uint8Array; + interface AesCbcParams extends Algorithm { + iv: BufferSource; + } + interface AesCtrParams extends Algorithm { + counter: BufferSource; + length: number; + } + interface AesDerivedKeyParams extends Algorithm { + length: number; + } + interface AesGcmParams extends Algorithm { + additionalData?: BufferSource; + iv: BufferSource; + tagLength?: number; + } + interface AesKeyAlgorithm extends KeyAlgorithm { + length: number; + } + interface AesKeyGenParams extends Algorithm { + length: number; + } + interface Algorithm { + name: string; + } + interface EcKeyAlgorithm extends KeyAlgorithm { + namedCurve: NamedCurve; + } + interface EcKeyGenParams extends Algorithm { + namedCurve: NamedCurve; + } + interface EcKeyImportParams extends Algorithm { + namedCurve: NamedCurve; + } + interface EcdhKeyDeriveParams extends Algorithm { + public: CryptoKey; + } + interface EcdsaParams extends Algorithm { + hash: HashAlgorithmIdentifier; + } + interface Ed448Params extends Algorithm { + context?: BufferSource; + } + interface HkdfParams extends Algorithm { + hash: HashAlgorithmIdentifier; + info: BufferSource; + salt: BufferSource; + } + interface HmacImportParams extends Algorithm { + hash: HashAlgorithmIdentifier; + length?: number; + } + interface HmacKeyAlgorithm extends KeyAlgorithm { + hash: KeyAlgorithm; + length: number; + } + interface HmacKeyGenParams extends Algorithm { + hash: HashAlgorithmIdentifier; + length?: number; + } + interface JsonWebKey { + alg?: string; + crv?: string; + d?: string; + dp?: string; + dq?: string; + e?: string; + ext?: boolean; + k?: string; + key_ops?: string[]; + kty?: string; + n?: string; + oth?: RsaOtherPrimesInfo[]; + p?: string; + q?: string; + qi?: string; + use?: string; + x?: string; + y?: string; + } + interface KeyAlgorithm { + name: string; + } + interface Pbkdf2Params extends Algorithm { + hash: HashAlgorithmIdentifier; + iterations: number; + salt: BufferSource; + } + interface RsaHashedImportParams extends Algorithm { + hash: HashAlgorithmIdentifier; + } + interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm { + hash: KeyAlgorithm; + } + interface RsaHashedKeyGenParams extends RsaKeyGenParams { + hash: HashAlgorithmIdentifier; + } + interface RsaKeyAlgorithm extends KeyAlgorithm { + modulusLength: number; + publicExponent: BigInteger; + } + interface RsaKeyGenParams extends Algorithm { + modulusLength: number; + publicExponent: BigInteger; + } + interface RsaOaepParams extends Algorithm { + label?: BufferSource; + } + interface RsaOtherPrimesInfo { + d?: string; + r?: string; + t?: string; + } + interface RsaPssParams extends Algorithm { + saltLength: number; + } + /** + * Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class. + * `Crypto` is a singleton that provides access to the remainder of the crypto API. + * @since v15.0.0 + */ + interface Crypto { + /** + * Provides access to the `SubtleCrypto` API. + * @since v15.0.0 + */ + readonly subtle: SubtleCrypto; + /** + * Generates cryptographically strong random values. + * The given `typedArray` is filled with random values, and a reference to `typedArray` is returned. + * + * The given `typedArray` must be an integer-based instance of {@link NodeJS.TypedArray}, i.e. `Float32Array` and `Float64Array` are not accepted. + * + * An error will be thrown if the given `typedArray` is larger than 65,536 bytes. + * @since v15.0.0 + */ + getRandomValues>(typedArray: T): T; + /** + * Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID. + * The UUID is generated using a cryptographic pseudorandom number generator. + * @since v16.7.0 + */ + randomUUID(): UUID; + CryptoKey: CryptoKeyConstructor; + } + // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable. + interface CryptoKeyConstructor { + /** Illegal constructor */ + (_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user. + readonly length: 0; + readonly name: "CryptoKey"; + readonly prototype: CryptoKey; + } + /** + * @since v15.0.0 + */ + interface CryptoKey { + /** + * An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters. + * @since v15.0.0 + */ + readonly algorithm: KeyAlgorithm; + /** + * When `true`, the {@link CryptoKey} can be extracted using either `subtleCrypto.exportKey()` or `subtleCrypto.wrapKey()`. + * @since v15.0.0 + */ + readonly extractable: boolean; + /** + * A string identifying whether the key is a symmetric (`'secret'`) or asymmetric (`'private'` or `'public'`) key. + * @since v15.0.0 + */ + readonly type: KeyType; + /** + * An array of strings identifying the operations for which the key may be used. + * + * The possible usages are: + * - `'encrypt'` - The key may be used to encrypt data. + * - `'decrypt'` - The key may be used to decrypt data. + * - `'sign'` - The key may be used to generate digital signatures. + * - `'verify'` - The key may be used to verify digital signatures. + * - `'deriveKey'` - The key may be used to derive a new key. + * - `'deriveBits'` - The key may be used to derive bits. + * - `'wrapKey'` - The key may be used to wrap another key. + * - `'unwrapKey'` - The key may be used to unwrap another key. + * + * Valid key usages depend on the key algorithm (identified by `cryptokey.algorithm.name`). + * @since v15.0.0 + */ + readonly usages: KeyUsage[]; + } + /** + * The `CryptoKeyPair` is a simple dictionary object with `publicKey` and `privateKey` properties, representing an asymmetric key pair. + * @since v15.0.0 + */ + interface CryptoKeyPair { + /** + * A {@link CryptoKey} whose type will be `'private'`. + * @since v15.0.0 + */ + privateKey: CryptoKey; + /** + * A {@link CryptoKey} whose type will be `'public'`. + * @since v15.0.0 + */ + publicKey: CryptoKey; + } + /** + * @since v15.0.0 + */ + interface SubtleCrypto { + /** + * Using the method and parameters specified in `algorithm` and the keying material provided by `key`, + * `subtle.decrypt()` attempts to decipher the provided `data`. If successful, + * the returned promise will be resolved with an `` containing the plaintext result. + * + * The algorithms currently supported include: + * + * - `'RSA-OAEP'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * @since v15.0.0 + */ + decrypt( + algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + key: CryptoKey, + data: BufferSource, + ): Promise; + /** + * Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`, + * `subtle.deriveBits()` attempts to generate `length` bits. + * The Node.js implementation requires that when `length` is a number it must be multiple of `8`. + * When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed + * for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms. + * If successful, the returned promise will be resolved with an `` containing the generated data. + * + * The algorithms currently supported include: + * + * - `'ECDH'` + * - `'X25519'` + * - `'X448'` + * - `'HKDF'` + * - `'PBKDF2'` + * @since v15.0.0 + */ + deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise; + deriveBits( + algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params, + baseKey: CryptoKey, + length: number, + ): Promise; + /** + * Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`, + * `subtle.deriveKey()` attempts to generate a new ` based on the method and parameters in `derivedKeyAlgorithm`. + * + * Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material, + * then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input. + * + * The algorithms currently supported include: + * + * - `'ECDH'` + * - `'X25519'` + * - `'X448'` + * - `'HKDF'` + * - `'PBKDF2'` + * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. + * @since v15.0.0 + */ + deriveKey( + algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, + baseKey: CryptoKey, + derivedKeyAlgorithm: + | AlgorithmIdentifier + | AesDerivedKeyParams + | HmacImportParams + | HkdfParams + | Pbkdf2Params, + extractable: boolean, + keyUsages: readonly KeyUsage[], + ): Promise; + /** + * Using the method identified by `algorithm`, `subtle.digest()` attempts to generate a digest of `data`. + * If successful, the returned promise is resolved with an `` containing the computed digest. + * + * If `algorithm` is provided as a ``, it must be one of: + * + * - `'SHA-1'` + * - `'SHA-256'` + * - `'SHA-384'` + * - `'SHA-512'` + * + * If `algorithm` is provided as an ``, it must have a `name` property whose value is one of the above. + * @since v15.0.0 + */ + digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; + /** + * Using the method and parameters specified by `algorithm` and the keying material provided by `key`, + * `subtle.encrypt()` attempts to encipher `data`. If successful, + * the returned promise is resolved with an `` containing the encrypted result. + * + * The algorithms currently supported include: + * + * - `'RSA-OAEP'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * @since v15.0.0 + */ + encrypt( + algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + key: CryptoKey, + data: BufferSource, + ): Promise; + /** + * Exports the given key into the specified format, if supported. + * + * If the `` is not extractable, the returned promise will reject. + * + * When `format` is either `'pkcs8'` or `'spki'` and the export is successful, + * the returned promise will be resolved with an `` containing the exported key data. + * + * When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a + * JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification. + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @returns `` containing ``. + * @since v15.0.0 + */ + exportKey(format: "jwk", key: CryptoKey): Promise; + exportKey(format: Exclude, key: CryptoKey): Promise; + /** + * Using the method and parameters provided in `algorithm`, + * `subtle.generateKey()` attempts to generate new keying material. + * Depending the method used, the method may generate either a single `` or a ``. + * + * The `` (public and private key) generating algorithms supported include: + * + * - `'RSASSA-PKCS1-v1_5'` + * - `'RSA-PSS'` + * - `'RSA-OAEP'` + * - `'ECDSA'` + * - `'Ed25519'` + * - `'Ed448'` + * - `'ECDH'` + * - `'X25519'` + * - `'X448'` + * The `` (secret key) generating algorithms supported include: + * + * - `'HMAC'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * - `'AES-KW'` + * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. + * @since v15.0.0 + */ + generateKey( + algorithm: RsaHashedKeyGenParams | EcKeyGenParams, + extractable: boolean, + keyUsages: readonly KeyUsage[], + ): Promise; + generateKey( + algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, + extractable: boolean, + keyUsages: readonly KeyUsage[], + ): Promise; + generateKey( + algorithm: AlgorithmIdentifier, + extractable: boolean, + keyUsages: KeyUsage[], + ): Promise; + /** + * The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format` + * to create a `` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments. + * If the import is successful, the returned promise will be resolved with the created ``. + * + * If importing a `'PBKDF2'` key, `extractable` must be `false`. + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. + * @since v15.0.0 + */ + importKey( + format: "jwk", + keyData: JsonWebKey, + algorithm: + | AlgorithmIdentifier + | RsaHashedImportParams + | EcKeyImportParams + | HmacImportParams + | AesKeyAlgorithm, + extractable: boolean, + keyUsages: readonly KeyUsage[], + ): Promise; + importKey( + format: Exclude, + keyData: BufferSource, + algorithm: + | AlgorithmIdentifier + | RsaHashedImportParams + | EcKeyImportParams + | HmacImportParams + | AesKeyAlgorithm, + extractable: boolean, + keyUsages: KeyUsage[], + ): Promise; + /** + * Using the method and parameters given by `algorithm` and the keying material provided by `key`, + * `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful, + * the returned promise is resolved with an `` containing the generated signature. + * + * The algorithms currently supported include: + * + * - `'RSASSA-PKCS1-v1_5'` + * - `'RSA-PSS'` + * - `'ECDSA'` + * - `'Ed25519'` + * - `'Ed448'` + * - `'HMAC'` + * @since v15.0.0 + */ + sign( + algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, + key: CryptoKey, + data: BufferSource, + ): Promise; + /** + * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. + * The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `` instance. + * It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input) + * then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs. + * If successful, the returned promise is resolved with a `` object. + * + * The wrapping algorithms currently supported include: + * + * - `'RSA-OAEP'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * - `'AES-KW'` + * + * The unwrapped key algorithms supported include: + * + * - `'RSASSA-PKCS1-v1_5'` + * - `'RSA-PSS'` + * - `'RSA-OAEP'` + * - `'ECDSA'` + * - `'Ed25519'` + * - `'Ed448'` + * - `'ECDH'` + * - `'X25519'` + * - `'X448'` + * - `'HMAC'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * - `'AES-KW'` + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. + * @since v15.0.0 + */ + unwrapKey( + format: KeyFormat, + wrappedKey: BufferSource, + unwrappingKey: CryptoKey, + unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + unwrappedKeyAlgorithm: + | AlgorithmIdentifier + | RsaHashedImportParams + | EcKeyImportParams + | HmacImportParams + | AesKeyAlgorithm, + extractable: boolean, + keyUsages: KeyUsage[], + ): Promise; + /** + * Using the method and parameters given in `algorithm` and the keying material provided by `key`, + * `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`. + * The returned promise is resolved with either `true` or `false`. + * + * The algorithms currently supported include: + * + * - `'RSASSA-PKCS1-v1_5'` + * - `'RSA-PSS'` + * - `'ECDSA'` + * - `'Ed25519'` + * - `'Ed448'` + * - `'HMAC'` + * @since v15.0.0 + */ + verify( + algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, + key: CryptoKey, + signature: BufferSource, + data: BufferSource, + ): Promise; + /** + * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. + * The `subtle.wrapKey()` method exports the keying material into the format identified by `format`, + * then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`. + * It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments, + * then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs. + * If successful, the returned promise will be resolved with an `` containing the encrypted key data. + * + * The wrapping algorithms currently supported include: + * + * - `'RSA-OAEP'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * - `'AES-KW'` + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @since v15.0.0 + */ + wrapKey( + format: KeyFormat, + key: CryptoKey, + wrappingKey: CryptoKey, + wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + ): Promise; + } + } +} +declare module "node:crypto" { + export * from "crypto"; +} diff --git a/node_modules/@types/node/dgram.d.ts b/node_modules/@types/node/dgram.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..692e547fc65fe1f7f7e8dff1e65d3eb151de230c --- /dev/null +++ b/node_modules/@types/node/dgram.d.ts @@ -0,0 +1,586 @@ +/** + * The `node:dgram` module provides an implementation of UDP datagram sockets. + * + * ```js + * import dgram from 'node:dgram'; + * + * const server = dgram.createSocket('udp4'); + * + * server.on('error', (err) => { + * console.error(`server error:\n${err.stack}`); + * server.close(); + * }); + * + * server.on('message', (msg, rinfo) => { + * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`); + * }); + * + * server.on('listening', () => { + * const address = server.address(); + * console.log(`server listening ${address.address}:${address.port}`); + * }); + * + * server.bind(41234); + * // Prints: server listening 0.0.0.0:41234 + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dgram.js) + */ +declare module "dgram" { + import { AddressInfo } from "node:net"; + import * as dns from "node:dns"; + import { Abortable, EventEmitter } from "node:events"; + interface RemoteInfo { + address: string; + family: "IPv4" | "IPv6"; + port: number; + size: number; + } + interface BindOptions { + port?: number | undefined; + address?: string | undefined; + exclusive?: boolean | undefined; + fd?: number | undefined; + } + type SocketType = "udp4" | "udp6"; + interface SocketOptions extends Abortable { + type: SocketType; + reuseAddr?: boolean | undefined; + /** + * @default false + */ + ipv6Only?: boolean | undefined; + recvBufferSize?: number | undefined; + sendBufferSize?: number | undefined; + lookup?: + | (( + hostname: string, + options: dns.LookupOneOptions, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ) => void) + | undefined; + } + /** + * Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram + * messages. When `address` and `port` are not passed to `socket.bind()` the + * method will bind the socket to the "all interfaces" address on a random port + * (it does the right thing for both `udp4` and `udp6` sockets). The bound address + * and port can be retrieved using `socket.address().address` and `socket.address().port`. + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.close()` on the socket: + * + * ```js + * const controller = new AbortController(); + * const { signal } = controller; + * const server = dgram.createSocket({ type: 'udp4', signal }); + * server.on('message', (msg, rinfo) => { + * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`); + * }); + * // Later, when you want to close the server. + * controller.abort(); + * ``` + * @since v0.11.13 + * @param options Available options are: + * @param callback Attached as a listener for `'message'` events. Optional. + */ + function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + /** + * Encapsulates the datagram functionality. + * + * New instances of `dgram.Socket` are created using {@link createSocket}. + * The `new` keyword is not to be used to create `dgram.Socket` instances. + * @since v0.1.99 + */ + class Socket extends EventEmitter { + /** + * Tells the kernel to join a multicast group at the given `multicastAddress` and`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the`multicastInterface` argument is not + * specified, the operating system will choose + * one interface and will add membership to it. To add membership to every + * available interface, call `addMembership` multiple times, once per interface. + * + * When called on an unbound socket, this method will implicitly bind to a random + * port, listening on all interfaces. + * + * When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur: + * + * ```js + * import cluster from 'node:cluster'; + * import dgram from 'node:dgram'; + * + * if (cluster.isPrimary) { + * cluster.fork(); // Works ok. + * cluster.fork(); // Fails with EADDRINUSE. + * } else { + * const s = dgram.createSocket('udp4'); + * s.bind(1234, () => { + * s.addMembership('224.0.0.114'); + * }); + * } + * ``` + * @since v0.6.9 + */ + addMembership(multicastAddress: string, multicastInterface?: string): void; + /** + * Returns an object containing the address information for a socket. + * For UDP sockets, this object will contain `address`, `family`, and `port`properties. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.1.99 + */ + address(): AddressInfo; + /** + * For UDP sockets, causes the `dgram.Socket` to listen for datagram + * messages on a named `port` and optional `address`. If `port` is not + * specified or is `0`, the operating system will attempt to bind to a + * random port. If `address` is not specified, the operating system will + * attempt to listen on all addresses. Once binding is complete, a`'listening'` event is emitted and the optional `callback` function is + * called. + * + * Specifying both a `'listening'` event listener and passing a`callback` to the `socket.bind()` method is not harmful but not very + * useful. + * + * A bound datagram socket keeps the Node.js process running to receive + * datagram messages. + * + * If binding fails, an `'error'` event is generated. In rare case (e.g. + * attempting to bind with a closed socket), an `Error` may be thrown. + * + * Example of a UDP server listening on port 41234: + * + * ```js + * import dgram from 'node:dgram'; + * + * const server = dgram.createSocket('udp4'); + * + * server.on('error', (err) => { + * console.error(`server error:\n${err.stack}`); + * server.close(); + * }); + * + * server.on('message', (msg, rinfo) => { + * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`); + * }); + * + * server.on('listening', () => { + * const address = server.address(); + * console.log(`server listening ${address.address}:${address.port}`); + * }); + * + * server.bind(41234); + * // Prints: server listening 0.0.0.0:41234 + * ``` + * @since v0.1.99 + * @param callback with no parameters. Called when binding is complete. + */ + bind(port?: number, address?: string, callback?: () => void): this; + bind(port?: number, callback?: () => void): this; + bind(callback?: () => void): this; + bind(options: BindOptions, callback?: () => void): this; + /** + * Close the underlying socket and stop listening for data on it. If a callback is + * provided, it is added as a listener for the `'close'` event. + * @since v0.1.99 + * @param callback Called when the socket has been closed. + */ + close(callback?: () => void): this; + /** + * Associates the `dgram.Socket` to a remote address and port. Every + * message sent by this handle is automatically sent to that destination. Also, + * the socket will only receive messages from that remote peer. + * Trying to call `connect()` on an already connected socket will result + * in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not + * provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets) + * will be used by default. Once the connection is complete, a `'connect'` event + * is emitted and the optional `callback` function is called. In case of failure, + * the `callback` is called or, failing this, an `'error'` event is emitted. + * @since v12.0.0 + * @param callback Called when the connection is completed or on error. + */ + connect(port: number, address?: string, callback?: () => void): void; + connect(port: number, callback: () => void): void; + /** + * A synchronous function that disassociates a connected `dgram.Socket` from + * its remote address. Trying to call `disconnect()` on an unbound or already + * disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception. + * @since v12.0.0 + */ + disconnect(): void; + /** + * Instructs the kernel to leave a multicast group at `multicastAddress` using the`IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the + * kernel when the socket is closed or the process terminates, so most apps will + * never have reason to call this. + * + * If `multicastInterface` is not specified, the operating system will attempt to + * drop membership on all valid interfaces. + * @since v0.6.9 + */ + dropMembership(multicastAddress: string, multicastInterface?: string): void; + /** + * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket. + * @since v8.7.0 + * @return the `SO_RCVBUF` socket receive buffer size in bytes. + */ + getRecvBufferSize(): number; + /** + * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket. + * @since v8.7.0 + * @return the `SO_SNDBUF` socket send buffer size in bytes. + */ + getSendBufferSize(): number; + /** + * By default, binding a socket will cause it to block the Node.js process from + * exiting as long as the socket is open. The `socket.unref()` method can be used + * to exclude the socket from the reference counting that keeps the Node.js + * process active. The `socket.ref()` method adds the socket back to the reference + * counting and restores the default behavior. + * + * Calling `socket.ref()` multiples times will have no additional effect. + * + * The `socket.ref()` method returns a reference to the socket so calls can be + * chained. + * @since v0.9.1 + */ + ref(): this; + /** + * Returns an object containing the `address`, `family`, and `port` of the remote + * endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception + * if the socket is not connected. + * @since v12.0.0 + */ + remoteAddress(): AddressInfo; + /** + * Broadcasts a datagram on the socket. + * For connectionless sockets, the destination `port` and `address` must be + * specified. Connected sockets, on the other hand, will use their associated + * remote endpoint, so the `port` and `address` arguments must not be set. + * + * The `msg` argument contains the message to be sent. + * Depending on its type, different behavior can apply. If `msg` is a `Buffer`, + * any `TypedArray` or a `DataView`, + * the `offset` and `length` specify the offset within the `Buffer` where the + * message begins and the number of bytes in the message, respectively. + * If `msg` is a `String`, then it is automatically converted to a `Buffer`with `'utf8'` encoding. With messages that + * contain multi-byte characters, `offset` and `length` will be calculated with + * respect to `byte length` and not the character position. + * If `msg` is an array, `offset` and `length` must not be specified. + * + * The `address` argument is a string. If the value of `address` is a host name, + * DNS will be used to resolve the address of the host. If `address` is not + * provided or otherwise nullish, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default. + * + * If the socket has not been previously bound with a call to `bind`, the socket + * is assigned a random port number and is bound to the "all interfaces" address + * (`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.) + * + * An optional `callback` function may be specified to as a way of reporting + * DNS errors or for determining when it is safe to reuse the `buf` object. + * DNS lookups delay the time to send for at least one tick of the + * Node.js event loop. + * + * The only way to know for sure that the datagram has been sent is by using a`callback`. If an error occurs and a `callback` is given, the error will be + * passed as the first argument to the `callback`. If a `callback` is not given, + * the error is emitted as an `'error'` event on the `socket` object. + * + * Offset and length are optional but both _must_ be set if either are used. + * They are supported only when the first argument is a `Buffer`, a `TypedArray`, + * or a `DataView`. + * + * This method throws `ERR_SOCKET_BAD_PORT` if called on an unbound socket. + * + * Example of sending a UDP packet to a port on `localhost`; + * + * ```js + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; + * + * const message = Buffer.from('Some bytes'); + * const client = dgram.createSocket('udp4'); + * client.send(message, 41234, 'localhost', (err) => { + * client.close(); + * }); + * ``` + * + * Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`; + * + * ```js + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from('Some '); + * const buf2 = Buffer.from('bytes'); + * const client = dgram.createSocket('udp4'); + * client.send([buf1, buf2], 41234, (err) => { + * client.close(); + * }); + * ``` + * + * Sending multiple buffers might be faster or slower depending on the + * application and operating system. Run benchmarks to + * determine the optimal strategy on a case-by-case basis. Generally speaking, + * however, sending multiple buffers is faster. + * + * Example of sending a UDP packet using a socket connected to a port on`localhost`: + * + * ```js + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; + * + * const message = Buffer.from('Some bytes'); + * const client = dgram.createSocket('udp4'); + * client.connect(41234, 'localhost', (err) => { + * client.send(message, (err) => { + * client.close(); + * }); + * }); + * ``` + * @since v0.1.99 + * @param msg Message to be sent. + * @param offset Offset in the buffer where the message starts. + * @param length Number of bytes in the message. + * @param port Destination port. + * @param address Destination host name or IP address. + * @param callback Called when the message has been sent. + */ + send( + msg: string | Uint8Array | readonly any[], + port?: number, + address?: string, + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array | readonly any[], + port?: number, + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array | readonly any[], + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array, + offset: number, + length: number, + port?: number, + address?: string, + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array, + offset: number, + length: number, + port?: number, + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array, + offset: number, + length: number, + callback?: (error: Error | null, bytes: number) => void, + ): void; + /** + * Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP + * packets may be sent to a local interface's broadcast address. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.6.9 + */ + setBroadcast(flag: boolean): void; + /** + * _All references to scope in this section are referring to [IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC + * 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_ + * _with a scope index is written as `'IP%scope'` where scope is an interface name_ + * _or interface number._ + * + * Sets the default outgoing multicast interface of the socket to a chosen + * interface or back to system interface selection. The `multicastInterface` must + * be a valid string representation of an IP from the socket's family. + * + * For IPv4 sockets, this should be the IP configured for the desired physical + * interface. All packets sent to multicast on the socket will be sent on the + * interface determined by the most recent successful use of this call. + * + * For IPv6 sockets, `multicastInterface` should include a scope to indicate the + * interface as in the examples that follow. In IPv6, individual `send` calls can + * also use explicit scope in addresses, so only packets sent to a multicast + * address without specifying an explicit scope are affected by the most recent + * successful use of this call. + * + * This method throws `EBADF` if called on an unbound socket. + * + * #### Example: IPv6 outgoing multicast interface + * + * On most systems, where scope format uses the interface name: + * + * ```js + * const socket = dgram.createSocket('udp6'); + * + * socket.bind(1234, () => { + * socket.setMulticastInterface('::%eth1'); + * }); + * ``` + * + * On Windows, where scope format uses an interface number: + * + * ```js + * const socket = dgram.createSocket('udp6'); + * + * socket.bind(1234, () => { + * socket.setMulticastInterface('::%2'); + * }); + * ``` + * + * #### Example: IPv4 outgoing multicast interface + * + * All systems use an IP of the host on the desired physical interface: + * + * ```js + * const socket = dgram.createSocket('udp4'); + * + * socket.bind(1234, () => { + * socket.setMulticastInterface('10.0.0.2'); + * }); + * ``` + * @since v8.6.0 + */ + setMulticastInterface(multicastInterface: string): void; + /** + * Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`, + * multicast packets will also be received on the local interface. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.3.8 + */ + setMulticastLoopback(flag: boolean): boolean; + /** + * Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for + * "Time to Live", in this context it specifies the number of IP hops that a + * packet is allowed to travel through, specifically for multicast traffic. Each + * router or gateway that forwards a packet decrements the TTL. If the TTL is + * decremented to 0 by a router, it will not be forwarded. + * + * The `ttl` argument may be between 0 and 255\. The default on most systems is `1`. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.3.8 + */ + setMulticastTTL(ttl: number): number; + /** + * Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer + * in bytes. + * + * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket. + * @since v8.7.0 + */ + setRecvBufferSize(size: number): void; + /** + * Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer + * in bytes. + * + * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket. + * @since v8.7.0 + */ + setSendBufferSize(size: number): void; + /** + * Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live", + * in this context it specifies the number of IP hops that a packet is allowed to + * travel through. Each router or gateway that forwards a packet decrements the + * TTL. If the TTL is decremented to 0 by a router, it will not be forwarded. + * Changing TTL values is typically done for network probes or when multicasting. + * + * The `ttl` argument may be between 1 and 255\. The default on most systems + * is 64. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.1.101 + */ + setTTL(ttl: number): number; + /** + * By default, binding a socket will cause it to block the Node.js process from + * exiting as long as the socket is open. The `socket.unref()` method can be used + * to exclude the socket from the reference counting that keeps the Node.js + * process active, allowing the process to exit even if the socket is still + * listening. + * + * Calling `socket.unref()` multiple times will have no additional effect. + * + * The `socket.unref()` method returns a reference to the socket so calls can be + * chained. + * @since v0.9.1 + */ + unref(): this; + /** + * Tells the kernel to join a source-specific multicast channel at the given`sourceAddress` and `groupAddress`, using the `multicastInterface` with the`IP_ADD_SOURCE_MEMBERSHIP` socket + * option. If the `multicastInterface` argument + * is not specified, the operating system will choose one interface and will add + * membership to it. To add membership to every available interface, call`socket.addSourceSpecificMembership()` multiple times, once per interface. + * + * When called on an unbound socket, this method will implicitly bind to a random + * port, listening on all interfaces. + * @since v13.1.0, v12.16.0 + */ + addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void; + /** + * Instructs the kernel to leave a source-specific multicast channel at the given`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP`socket option. This method is + * automatically called by the kernel when the + * socket is closed or the process terminates, so most apps will never have + * reason to call this. + * + * If `multicastInterface` is not specified, the operating system will attempt to + * drop membership on all valid interfaces. + * @since v13.1.0, v12.16.0 + */ + dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void; + /** + * events.EventEmitter + * 1. close + * 2. connect + * 3. error + * 4. listening + * 5. message + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connect", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "connect"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connect", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connect", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connect", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connect", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + /** + * Calls `socket.close()` and returns a promise that fulfills when the socket has closed. + * @since v20.5.0 + */ + [Symbol.asyncDispose](): Promise; + } +} +declare module "node:dgram" { + export * from "dgram"; +} diff --git a/node_modules/@types/node/diagnostics_channel.d.ts b/node_modules/@types/node/diagnostics_channel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b02f591787907ad3ba942f1e250d53f2000d4a89 --- /dev/null +++ b/node_modules/@types/node/diagnostics_channel.d.ts @@ -0,0 +1,191 @@ +/** + * The `node:diagnostics_channel` module provides an API to create named channels + * to report arbitrary message data for diagnostics purposes. + * + * It can be accessed using: + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * ``` + * + * It is intended that a module writer wanting to report diagnostics messages + * will create one or many top-level channels to report messages through. + * Channels may also be acquired at runtime but it is not encouraged + * due to the additional overhead of doing so. Channels may be exported for + * convenience, but as long as the name is known it can be acquired anywhere. + * + * If you intend for your module to produce diagnostics data for others to + * consume it is recommended that you include documentation of what named + * channels are used along with the shape of the message data. Channel names + * should generally include the module name to avoid collisions with data from + * other modules. + * @since v15.1.0, v14.17.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/diagnostics_channel.js) + */ +declare module "diagnostics_channel" { + /** + * Check if there are active subscribers to the named channel. This is helpful if + * the message you want to send might be expensive to prepare. + * + * This API is optional but helpful when trying to publish messages from very + * performance-sensitive code. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * if (diagnostics_channel.hasSubscribers('my-channel')) { + * // There are subscribers, prepare and publish message + * } + * ``` + * @since v15.1.0, v14.17.0 + * @param name The channel name + * @return If there are active subscribers + */ + function hasSubscribers(name: string | symbol): boolean; + /** + * This is the primary entry-point for anyone wanting to publish to a named + * channel. It produces a channel object which is optimized to reduce overhead at + * publish time as much as possible. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * ``` + * @since v15.1.0, v14.17.0 + * @param name The channel name + * @return The named channel object + */ + function channel(name: string | symbol): Channel; + type ChannelListener = (message: unknown, name: string | symbol) => void; + /** + * Register a message handler to subscribe to this channel. This message handler + * will be run synchronously whenever a message is published to the channel. Any + * errors thrown in the message handler will trigger an `'uncaughtException'`. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * diagnostics_channel.subscribe('my-channel', (message, name) => { + * // Received data + * }); + * ``` + * @since v18.7.0, v16.17.0 + * @param name The channel name + * @param onMessage The handler to receive channel messages + */ + function subscribe(name: string | symbol, onMessage: ChannelListener): void; + /** + * Remove a message handler previously registered to this channel with {@link subscribe}. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * function onMessage(message, name) { + * // Received data + * } + * + * diagnostics_channel.subscribe('my-channel', onMessage); + * + * diagnostics_channel.unsubscribe('my-channel', onMessage); + * ``` + * @since v18.7.0, v16.17.0 + * @param name The channel name + * @param onMessage The previous subscribed handler to remove + * @return `true` if the handler was found, `false` otherwise. + */ + function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean; + /** + * The class `Channel` represents an individual named channel within the data + * pipeline. It is used to track subscribers and to publish messages when there + * are subscribers present. It exists as a separate object to avoid channel + * lookups at publish time, enabling very fast publish speeds and allowing + * for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly + * with `new Channel(name)` is not supported. + * @since v15.1.0, v14.17.0 + */ + class Channel { + readonly name: string | symbol; + /** + * Check if there are active subscribers to this channel. This is helpful if + * the message you want to send might be expensive to prepare. + * + * This API is optional but helpful when trying to publish messages from very + * performance-sensitive code. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * + * if (channel.hasSubscribers) { + * // There are subscribers, prepare and publish message + * } + * ``` + * @since v15.1.0, v14.17.0 + */ + readonly hasSubscribers: boolean; + private constructor(name: string | symbol); + /** + * Publish a message to any subscribers to the channel. This will trigger + * message handlers synchronously so they will execute within the same context. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * + * channel.publish({ + * some: 'message', + * }); + * ``` + * @since v15.1.0, v14.17.0 + * @param message The message to send to the channel subscribers + */ + publish(message: unknown): void; + /** + * Register a message handler to subscribe to this channel. This message handler + * will be run synchronously whenever a message is published to the channel. Any + * errors thrown in the message handler will trigger an `'uncaughtException'`. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * + * channel.subscribe((message, name) => { + * // Received data + * }); + * ``` + * @since v15.1.0, v14.17.0 + * @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)} + * @param onMessage The handler to receive channel messages + */ + subscribe(onMessage: ChannelListener): void; + /** + * Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * + * function onMessage(message, name) { + * // Received data + * } + * + * channel.subscribe(onMessage); + * + * channel.unsubscribe(onMessage); + * ``` + * @since v15.1.0, v14.17.0 + * @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)} + * @param onMessage The previous subscribed handler to remove + * @return `true` if the handler was found, `false` otherwise. + */ + unsubscribe(onMessage: ChannelListener): void; + } +} +declare module "node:diagnostics_channel" { + export * from "diagnostics_channel"; +} diff --git a/node_modules/@types/node/dns.d.ts b/node_modules/@types/node/dns.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..380cf7d7015e33c3fd5d2d1ff8c3f43c5f35a92d --- /dev/null +++ b/node_modules/@types/node/dns.d.ts @@ -0,0 +1,809 @@ +/** + * The `node:dns` module enables name resolution. For example, use it to look up IP + * addresses of host names. + * + * Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the + * DNS protocol for lookups. {@link lookup} uses the operating system + * facilities to perform name resolution. It may not need to perform any network + * communication. To perform name resolution the way other applications on the same + * system do, use {@link lookup}. + * + * ```js + * const dns = require('node:dns'); + * + * dns.lookup('example.org', (err, address, family) => { + * console.log('address: %j family: IPv%s', address, family); + * }); + * // address: "93.184.216.34" family: IPv4 + * ``` + * + * All other functions in the `node:dns` module connect to an actual DNS server to + * perform name resolution. They will always use the network to perform DNS + * queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform + * DNS queries, bypassing other name-resolution facilities. + * + * ```js + * const dns = require('node:dns'); + * + * dns.resolve4('archive.org', (err, addresses) => { + * if (err) throw err; + * + * console.log(`addresses: ${JSON.stringify(addresses)}`); + * + * addresses.forEach((a) => { + * dns.reverse(a, (err, hostnames) => { + * if (err) { + * throw err; + * } + * console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`); + * }); + * }); + * }); + * ``` + * + * See the `Implementation considerations section` for more information. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dns.js) + */ +declare module "dns" { + import * as dnsPromises from "node:dns/promises"; + // Supported getaddrinfo flags. + export const ADDRCONFIG: number; + export const V4MAPPED: number; + /** + * If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as + * well as IPv4 mapped IPv6 addresses. + */ + export const ALL: number; + export interface LookupOptions { + family?: number | undefined; + hints?: number | undefined; + all?: boolean | undefined; + /** + * @default true + */ + verbatim?: boolean | undefined; + } + export interface LookupOneOptions extends LookupOptions { + all?: false | undefined; + } + export interface LookupAllOptions extends LookupOptions { + all: true; + } + export interface LookupAddress { + address: string; + family: number; + } + /** + * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or + * AAAA (IPv6) record. All `option` properties are optional. If `options` is an + * integer, then it must be `4` or `6` – if `options` is `0` or not provided, then + * IPv4 and IPv6 addresses are both returned if found. + * + * With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the + * properties `address` and `family`. + * + * On error, `err` is an `Error` object, where `err.code` is the error code. + * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when + * the host name does not exist but also when the lookup fails in other ways + * such as no available file descriptors. + * + * `dns.lookup()` does not necessarily have anything to do with the DNS protocol. + * The implementation uses an operating system facility that can associate names + * with addresses and vice versa. This implementation can have subtle but + * important consequences on the behavior of any Node.js program. Please take some + * time to consult the `Implementation considerations section` before using`dns.lookup()`. + * + * Example usage: + * + * ```js + * const dns = require('node:dns'); + * const options = { + * family: 6, + * hints: dns.ADDRCONFIG | dns.V4MAPPED, + * }; + * dns.lookup('example.com', options, (err, address, family) => + * console.log('address: %j family: IPv%s', address, family)); + * // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6 + * + * // When options.all is true, the result will be an Array. + * options.all = true; + * dns.lookup('example.com', options, (err, addresses) => + * console.log('addresses: %j', addresses)); + * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}] + * ``` + * + * If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties. + * @since v0.1.90 + */ + export function lookup( + hostname: string, + family: number, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void; + export function lookup( + hostname: string, + options: LookupOneOptions, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void; + export function lookup( + hostname: string, + options: LookupAllOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void, + ): void; + export function lookup( + hostname: string, + options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void, + ): void; + export function lookup( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void; + export namespace lookup { + function __promisify__(hostname: string, options: LookupAllOptions): Promise; + function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise; + function __promisify__(hostname: string, options: LookupOptions): Promise; + } + /** + * Resolves the given `address` and `port` into a host name and service using + * the operating system's underlying `getnameinfo` implementation. + * + * If `address` is not a valid IP address, a `TypeError` will be thrown. + * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown. + * + * On an error, `err` is an `Error` object, where `err.code` is the error code. + * + * ```js + * const dns = require('node:dns'); + * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { + * console.log(hostname, service); + * // Prints: localhost ssh + * }); + * ``` + * + * If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties. + * @since v0.11.14 + */ + export function lookupService( + address: string, + port: number, + callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void, + ): void; + export namespace lookupService { + function __promisify__( + address: string, + port: number, + ): Promise<{ + hostname: string; + service: string; + }>; + } + export interface ResolveOptions { + ttl: boolean; + } + export interface ResolveWithTtlOptions extends ResolveOptions { + ttl: true; + } + export interface RecordWithTtl { + address: string; + ttl: number; + } + /** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */ + export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord; + export interface AnyARecord extends RecordWithTtl { + type: "A"; + } + export interface AnyAaaaRecord extends RecordWithTtl { + type: "AAAA"; + } + export interface CaaRecord { + critical: number; + issue?: string | undefined; + issuewild?: string | undefined; + iodef?: string | undefined; + contactemail?: string | undefined; + contactphone?: string | undefined; + } + export interface MxRecord { + priority: number; + exchange: string; + } + export interface AnyMxRecord extends MxRecord { + type: "MX"; + } + export interface NaptrRecord { + flags: string; + service: string; + regexp: string; + replacement: string; + order: number; + preference: number; + } + export interface AnyNaptrRecord extends NaptrRecord { + type: "NAPTR"; + } + export interface SoaRecord { + nsname: string; + hostmaster: string; + serial: number; + refresh: number; + retry: number; + expire: number; + minttl: number; + } + export interface AnySoaRecord extends SoaRecord { + type: "SOA"; + } + export interface SrvRecord { + priority: number; + weight: number; + port: number; + name: string; + } + export interface AnySrvRecord extends SrvRecord { + type: "SRV"; + } + export interface AnyTxtRecord { + type: "TXT"; + entries: string[]; + } + export interface AnyNsRecord { + type: "NS"; + value: string; + } + export interface AnyPtrRecord { + type: "PTR"; + value: string; + } + export interface AnyCnameRecord { + type: "CNAME"; + value: string; + } + export type AnyRecord = + | AnyARecord + | AnyAaaaRecord + | AnyCnameRecord + | AnyMxRecord + | AnyNaptrRecord + | AnyNsRecord + | AnyPtrRecord + | AnySoaRecord + | AnySrvRecord + | AnyTxtRecord; + /** + * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array + * of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource + * records. The type and structure of individual results varies based on `rrtype`: + * + * + * + * On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`. + * @since v0.1.27 + * @param hostname Host name to resolve. + * @param [rrtype='A'] Resource record type. + */ + export function resolve( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "A", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "AAAA", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "ANY", + callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "CNAME", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "MX", + callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "NAPTR", + callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "NS", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "PTR", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "SOA", + callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "SRV", + callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "TXT", + callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: string, + callback: ( + err: NodeJS.ErrnoException | null, + addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[], + ) => void, + ): void; + export namespace resolve { + function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise; + function __promisify__(hostname: string, rrtype: "ANY"): Promise; + function __promisify__(hostname: string, rrtype: "MX"): Promise; + function __promisify__(hostname: string, rrtype: "NAPTR"): Promise; + function __promisify__(hostname: string, rrtype: "SOA"): Promise; + function __promisify__(hostname: string, rrtype: "SRV"): Promise; + function __promisify__(hostname: string, rrtype: "TXT"): Promise; + function __promisify__( + hostname: string, + rrtype: string, + ): Promise; + } + /** + * Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function + * will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`). + * @since v0.1.16 + * @param hostname Host name to resolve. + */ + export function resolve4( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve4( + hostname: string, + options: ResolveWithTtlOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void, + ): void; + export function resolve4( + hostname: string, + options: ResolveOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void, + ): void; + export namespace resolve4 { + function __promisify__(hostname: string): Promise; + function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise; + function __promisify__(hostname: string, options?: ResolveOptions): Promise; + } + /** + * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function + * will contain an array of IPv6 addresses. + * @since v0.1.16 + * @param hostname Host name to resolve. + */ + export function resolve6( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve6( + hostname: string, + options: ResolveWithTtlOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void, + ): void; + export function resolve6( + hostname: string, + options: ResolveOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void, + ): void; + export namespace resolve6 { + function __promisify__(hostname: string): Promise; + function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise; + function __promisify__(hostname: string, options?: ResolveOptions): Promise; + } + /** + * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function + * will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`). + * @since v0.3.2 + */ + export function resolveCname( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export namespace resolveCname { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function + * will contain an array of certification authority authorization records + * available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`). + * @since v15.0.0, v14.17.0 + */ + export function resolveCaa( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void, + ): void; + export namespace resolveCaa { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will + * contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`). + * @since v0.1.27 + */ + export function resolveMx( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void, + ): void; + export namespace resolveMx { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of + * objects with the following properties: + * + * * `flags` + * * `service` + * * `regexp` + * * `replacement` + * * `order` + * * `preference` + * + * ```js + * { + * flags: 's', + * service: 'SIP+D2U', + * regexp: '', + * replacement: '_sip._udp.example.com', + * order: 30, + * preference: 100 + * } + * ``` + * @since v0.9.12 + */ + export function resolveNaptr( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void, + ): void; + export namespace resolveNaptr { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will + * contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`). + * @since v0.1.90 + */ + export function resolveNs( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export namespace resolveNs { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will + * be an array of strings containing the reply records. + * @since v6.0.0 + */ + export function resolvePtr( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export namespace resolvePtr { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for + * the `hostname`. The `address` argument passed to the `callback` function will + * be an object with the following properties: + * + * * `nsname` + * * `hostmaster` + * * `serial` + * * `refresh` + * * `retry` + * * `expire` + * * `minttl` + * + * ```js + * { + * nsname: 'ns.example.com', + * hostmaster: 'root.example.com', + * serial: 2013101809, + * refresh: 10000, + * retry: 2400, + * expire: 604800, + * minttl: 3600 + * } + * ``` + * @since v0.11.10 + */ + export function resolveSoa( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void, + ): void; + export namespace resolveSoa { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will + * be an array of objects with the following properties: + * + * * `priority` + * * `weight` + * * `port` + * * `name` + * + * ```js + * { + * priority: 10, + * weight: 5, + * port: 21223, + * name: 'service.example.com' + * } + * ``` + * @since v0.1.27 + */ + export function resolveSrv( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void, + ): void; + export namespace resolveSrv { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a + * two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of + * one record. Depending on the use case, these could be either joined together or + * treated separately. + * @since v0.1.27 + */ + export function resolveTxt( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void, + ): void; + export namespace resolveTxt { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query). + * The `ret` argument passed to the `callback` function will be an array containing + * various types of records. Each object has a property `type` that indicates the + * type of the current record. And depending on the `type`, additional properties + * will be present on the object: + * + * + * + * Here is an example of the `ret` object passed to the callback: + * + * ```js + * [ { type: 'A', address: '127.0.0.1', ttl: 299 }, + * { type: 'CNAME', value: 'example.com' }, + * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 }, + * { type: 'NS', value: 'ns1.example.com' }, + * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] }, + * { type: 'SOA', + * nsname: 'ns1.example.com', + * hostmaster: 'admin.example.com', + * serial: 156696742, + * refresh: 900, + * retry: 900, + * expire: 1800, + * minttl: 60 } ] + * ``` + * + * DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC + * 8482](https://tools.ietf.org/html/rfc8482). + */ + export function resolveAny( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void, + ): void; + export namespace resolveAny { + function __promisify__(hostname: string): Promise; + } + /** + * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an + * array of host names. + * + * On error, `err` is an `Error` object, where `err.code` is + * one of the `DNS error codes`. + * @since v0.1.16 + */ + export function reverse( + ip: string, + callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void, + ): void; + /** + * Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: for `verbatim` defaulting to `false`. + * * `verbatim`: for `verbatim` defaulting to `true`. + * @since v20.1.0 + */ + export function getDefaultResultOrder(): "ipv4first" | "verbatim"; + /** + * Sets the IP address and port of servers to be used when performing DNS + * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted + * addresses. If the port is the IANA default DNS port (53) it can be omitted. + * + * ```js + * dns.setServers([ + * '4.4.4.4', + * '[2001:4860:4860::8888]', + * '4.4.4.4:1053', + * '[2001:4860:4860::8888]:1053', + * ]); + * ``` + * + * An error will be thrown if an invalid address is provided. + * + * The `dns.setServers()` method must not be called while a DNS query is in + * progress. + * + * The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}). + * + * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html). + * That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with + * subsequent servers provided. Fallback DNS servers will only be used if the + * earlier ones time out or result in some other error. + * @since v0.11.3 + * @param servers array of `RFC 5952` formatted addresses + */ + export function setServers(servers: readonly string[]): void; + /** + * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6), + * that are currently configured for DNS resolution. A string will include a port + * section if a custom port is used. + * + * ```js + * [ + * '4.4.4.4', + * '2001:4860:4860::8888', + * '4.4.4.4:1053', + * '[2001:4860:4860::8888]:1053', + * ] + * ``` + * @since v0.11.3 + */ + export function getServers(): string[]; + /** + * Set the default value of `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: sets default `verbatim` `false`. + * * `verbatim`: sets default `verbatim` `true`. + * + * The default is `verbatim` and {@link setDefaultResultOrder} have higher + * priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default + * dns orders in workers. + * @since v16.4.0, v14.18.0 + * @param order must be `'ipv4first'` or `'verbatim'`. + */ + export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void; + // Error codes + export const NODATA: string; + export const FORMERR: string; + export const SERVFAIL: string; + export const NOTFOUND: string; + export const NOTIMP: string; + export const REFUSED: string; + export const BADQUERY: string; + export const BADNAME: string; + export const BADFAMILY: string; + export const BADRESP: string; + export const CONNREFUSED: string; + export const TIMEOUT: string; + export const EOF: string; + export const FILE: string; + export const NOMEM: string; + export const DESTRUCTION: string; + export const BADSTR: string; + export const BADFLAGS: string; + export const NONAME: string; + export const BADHINTS: string; + export const NOTINITIALIZED: string; + export const LOADIPHLPAPI: string; + export const ADDRGETNETWORKPARAMS: string; + export const CANCELLED: string; + export interface ResolverOptions { + timeout?: number | undefined; + /** + * @default 4 + */ + tries?: number; + } + /** + * An independent resolver for DNS requests. + * + * Creating a new resolver uses the default server settings. Setting + * the servers used for a resolver using `resolver.setServers()` does not affect + * other resolvers: + * + * ```js + * const { Resolver } = require('node:dns'); + * const resolver = new Resolver(); + * resolver.setServers(['4.4.4.4']); + * + * // This request will use the server at 4.4.4.4, independent of global settings. + * resolver.resolve4('example.org', (err, addresses) => { + * // ... + * }); + * ``` + * + * The following methods from the `node:dns` module are available: + * + * * `resolver.getServers()` + * * `resolver.resolve()` + * * `resolver.resolve4()` + * * `resolver.resolve6()` + * * `resolver.resolveAny()` + * * `resolver.resolveCaa()` + * * `resolver.resolveCname()` + * * `resolver.resolveMx()` + * * `resolver.resolveNaptr()` + * * `resolver.resolveNs()` + * * `resolver.resolvePtr()` + * * `resolver.resolveSoa()` + * * `resolver.resolveSrv()` + * * `resolver.resolveTxt()` + * * `resolver.reverse()` + * * `resolver.setServers()` + * @since v8.3.0 + */ + export class Resolver { + constructor(options?: ResolverOptions); + /** + * Cancel all outstanding DNS queries made by this resolver. The corresponding + * callbacks will be called with an error with code `ECANCELLED`. + * @since v8.3.0 + */ + cancel(): void; + getServers: typeof getServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCaa: typeof resolveCaa; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + /** + * The resolver instance will send its requests from the specified IP address. + * This allows programs to specify outbound interfaces when used on multi-homed + * systems. + * + * If a v4 or v6 address is not specified, it is set to the default and the + * operating system will choose a local address automatically. + * + * The resolver will use the v4 local address when making requests to IPv4 DNS + * servers, and the v6 local address when making requests to IPv6 DNS servers. + * The `rrtype` of resolution requests has no impact on the local address used. + * @since v15.1.0, v14.17.0 + * @param [ipv4='0.0.0.0'] A string representation of an IPv4 address. + * @param [ipv6='::0'] A string representation of an IPv6 address. + */ + setLocalAddress(ipv4?: string, ipv6?: string): void; + setServers: typeof setServers; + } + export { dnsPromises as promises }; +} +declare module "node:dns" { + export * from "dns"; +} diff --git a/node_modules/@types/node/dns/promises.d.ts b/node_modules/@types/node/dns/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef9b2228123c3a483363e3c102ab8c30ec9be2dd --- /dev/null +++ b/node_modules/@types/node/dns/promises.d.ts @@ -0,0 +1,425 @@ +/** + * The `dns.promises` API provides an alternative set of asynchronous DNS methods + * that return `Promise` objects rather than using callbacks. The API is accessible + * via `require('node:dns').promises` or `require('node:dns/promises')`. + * @since v10.6.0 + */ +declare module "dns/promises" { + import { + AnyRecord, + CaaRecord, + LookupAddress, + LookupAllOptions, + LookupOneOptions, + LookupOptions, + MxRecord, + NaptrRecord, + RecordWithTtl, + ResolveOptions, + ResolverOptions, + ResolveWithTtlOptions, + SoaRecord, + SrvRecord, + } from "node:dns"; + /** + * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6), + * that are currently configured for DNS resolution. A string will include a port + * section if a custom port is used. + * + * ```js + * [ + * '4.4.4.4', + * '2001:4860:4860::8888', + * '4.4.4.4:1053', + * '[2001:4860:4860::8888]:1053', + * ] + * ``` + * @since v10.6.0 + */ + function getServers(): string[]; + /** + * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or + * AAAA (IPv6) record. All `option` properties are optional. If `options` is an + * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4 + * and IPv6 addresses are both returned if found. + * + * With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`. + * + * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code. + * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when + * the host name does not exist but also when the lookup fails in other ways + * such as no available file descriptors. + * + * `dnsPromises.lookup()` does not necessarily have anything to do with the DNS + * protocol. The implementation uses an operating system facility that can + * associate names with addresses and vice versa. This implementation can have + * subtle but important consequences on the behavior of any Node.js program. Please + * take some time to consult the `Implementation considerations section` before + * using `dnsPromises.lookup()`. + * + * Example usage: + * + * ```js + * const dns = require('node:dns'); + * const dnsPromises = dns.promises; + * const options = { + * family: 6, + * hints: dns.ADDRCONFIG | dns.V4MAPPED, + * }; + * + * dnsPromises.lookup('example.com', options).then((result) => { + * console.log('address: %j family: IPv%s', result.address, result.family); + * // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6 + * }); + * + * // When options.all is true, the result will be an Array. + * options.all = true; + * dnsPromises.lookup('example.com', options).then((result) => { + * console.log('addresses: %j', result); + * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}] + * }); + * ``` + * @since v10.6.0 + */ + function lookup(hostname: string, family: number): Promise; + function lookup(hostname: string, options: LookupOneOptions): Promise; + function lookup(hostname: string, options: LookupAllOptions): Promise; + function lookup(hostname: string, options: LookupOptions): Promise; + function lookup(hostname: string): Promise; + /** + * Resolves the given `address` and `port` into a host name and service using + * the operating system's underlying `getnameinfo` implementation. + * + * If `address` is not a valid IP address, a `TypeError` will be thrown. + * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown. + * + * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code. + * + * ```js + * const dnsPromises = require('node:dns').promises; + * dnsPromises.lookupService('127.0.0.1', 22).then((result) => { + * console.log(result.hostname, result.service); + * // Prints: localhost ssh + * }); + * ``` + * @since v10.6.0 + */ + function lookupService( + address: string, + port: number, + ): Promise<{ + hostname: string; + service: string; + }>; + /** + * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array + * of the resource records. When successful, the `Promise` is resolved with an + * array of resource records. The type and structure of individual results vary + * based on `rrtype`: + * + * + * + * On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`. + * @since v10.6.0 + * @param hostname Host name to resolve. + * @param [rrtype='A'] Resource record type. + */ + function resolve(hostname: string): Promise; + function resolve(hostname: string, rrtype: "A"): Promise; + function resolve(hostname: string, rrtype: "AAAA"): Promise; + function resolve(hostname: string, rrtype: "ANY"): Promise; + function resolve(hostname: string, rrtype: "CAA"): Promise; + function resolve(hostname: string, rrtype: "CNAME"): Promise; + function resolve(hostname: string, rrtype: "MX"): Promise; + function resolve(hostname: string, rrtype: "NAPTR"): Promise; + function resolve(hostname: string, rrtype: "NS"): Promise; + function resolve(hostname: string, rrtype: "PTR"): Promise; + function resolve(hostname: string, rrtype: "SOA"): Promise; + function resolve(hostname: string, rrtype: "SRV"): Promise; + function resolve(hostname: string, rrtype: "TXT"): Promise; + function resolve( + hostname: string, + rrtype: string, + ): Promise; + /** + * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4 + * addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`). + * @since v10.6.0 + * @param hostname Host name to resolve. + */ + function resolve4(hostname: string): Promise; + function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise; + function resolve4(hostname: string, options: ResolveOptions): Promise; + /** + * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv6 + * addresses. + * @since v10.6.0 + * @param hostname Host name to resolve. + */ + function resolve6(hostname: string): Promise; + function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise; + function resolve6(hostname: string, options: ResolveOptions): Promise; + /** + * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query). + * On success, the `Promise` is resolved with an array containing various types of + * records. Each object has a property `type` that indicates the type of the + * current record. And depending on the `type`, additional properties will be + * present on the object: + * + * + * + * Here is an example of the result object: + * + * ```js + * [ { type: 'A', address: '127.0.0.1', ttl: 299 }, + * { type: 'CNAME', value: 'example.com' }, + * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 }, + * { type: 'NS', value: 'ns1.example.com' }, + * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] }, + * { type: 'SOA', + * nsname: 'ns1.example.com', + * hostmaster: 'admin.example.com', + * serial: 156696742, + * refresh: 900, + * retry: 900, + * expire: 1800, + * minttl: 60 } ] + * ``` + * @since v10.6.0 + */ + function resolveAny(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success, + * the `Promise` is resolved with an array of objects containing available + * certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`). + * @since v15.0.0, v14.17.0 + */ + function resolveCaa(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success, + * the `Promise` is resolved with an array of canonical name records available for + * the `hostname` (e.g. `['bar.example.com']`). + * @since v10.6.0 + */ + function resolveCname(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects + * containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`). + * @since v10.6.0 + */ + function resolveMx(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array + * of objects with the following properties: + * + * * `flags` + * * `service` + * * `regexp` + * * `replacement` + * * `order` + * * `preference` + * + * ```js + * { + * flags: 's', + * service: 'SIP+D2U', + * regexp: '', + * replacement: '_sip._udp.example.com', + * order: 30, + * preference: 100 + * } + * ``` + * @since v10.6.0 + */ + function resolveNaptr(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server + * records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`). + * @since v10.6.0 + */ + function resolveNs(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings + * containing the reply records. + * @since v10.6.0 + */ + function resolvePtr(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for + * the `hostname`. On success, the `Promise` is resolved with an object with the + * following properties: + * + * * `nsname` + * * `hostmaster` + * * `serial` + * * `refresh` + * * `retry` + * * `expire` + * * `minttl` + * + * ```js + * { + * nsname: 'ns.example.com', + * hostmaster: 'root.example.com', + * serial: 2013101809, + * refresh: 10000, + * retry: 2400, + * expire: 604800, + * minttl: 3600 + * } + * ``` + * @since v10.6.0 + */ + function resolveSoa(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with + * the following properties: + * + * * `priority` + * * `weight` + * * `port` + * * `name` + * + * ```js + * { + * priority: 10, + * weight: 5, + * port: 21223, + * name: 'service.example.com' + * } + * ``` + * @since v10.6.0 + */ + function resolveSrv(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array + * of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of + * one record. Depending on the use case, these could be either joined together or + * treated separately. + * @since v10.6.0 + */ + function resolveTxt(hostname: string): Promise; + /** + * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an + * array of host names. + * + * On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`. + * @since v10.6.0 + */ + function reverse(ip: string): Promise; + /** + * Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: for `verbatim` defaulting to `false`. + * * `verbatim`: for `verbatim` defaulting to `true`. + * @since v20.1.0 + */ + function getDefaultResultOrder(): "ipv4first" | "verbatim"; + /** + * Sets the IP address and port of servers to be used when performing DNS + * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted + * addresses. If the port is the IANA default DNS port (53) it can be omitted. + * + * ```js + * dnsPromises.setServers([ + * '4.4.4.4', + * '[2001:4860:4860::8888]', + * '4.4.4.4:1053', + * '[2001:4860:4860::8888]:1053', + * ]); + * ``` + * + * An error will be thrown if an invalid address is provided. + * + * The `dnsPromises.setServers()` method must not be called while a DNS query is in + * progress. + * + * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html). + * That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with + * subsequent servers provided. Fallback DNS servers will only be used if the + * earlier ones time out or result in some other error. + * @since v10.6.0 + * @param servers array of `RFC 5952` formatted addresses + */ + function setServers(servers: readonly string[]): void; + /** + * Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: sets default `verbatim` `false`. + * * `verbatim`: sets default `verbatim` `true`. + * + * The default is `verbatim` and `dnsPromises.setDefaultResultOrder()` have + * higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the + * default dns orders in workers. + * @since v16.4.0, v14.18.0 + * @param order must be `'ipv4first'` or `'verbatim'`. + */ + function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void; + /** + * An independent resolver for DNS requests. + * + * Creating a new resolver uses the default server settings. Setting + * the servers used for a resolver using `resolver.setServers()` does not affect + * other resolvers: + * + * ```js + * const { Resolver } = require('node:dns').promises; + * const resolver = new Resolver(); + * resolver.setServers(['4.4.4.4']); + * + * // This request will use the server at 4.4.4.4, independent of global settings. + * resolver.resolve4('example.org').then((addresses) => { + * // ... + * }); + * + * // Alternatively, the same code can be written using async-await style. + * (async function() { + * const addresses = await resolver.resolve4('example.org'); + * })(); + * ``` + * + * The following methods from the `dnsPromises` API are available: + * + * * `resolver.getServers()` + * * `resolver.resolve()` + * * `resolver.resolve4()` + * * `resolver.resolve6()` + * * `resolver.resolveAny()` + * * `resolver.resolveCaa()` + * * `resolver.resolveCname()` + * * `resolver.resolveMx()` + * * `resolver.resolveNaptr()` + * * `resolver.resolveNs()` + * * `resolver.resolvePtr()` + * * `resolver.resolveSoa()` + * * `resolver.resolveSrv()` + * * `resolver.resolveTxt()` + * * `resolver.reverse()` + * * `resolver.setServers()` + * @since v10.6.0 + */ + class Resolver { + constructor(options?: ResolverOptions); + cancel(): void; + getServers: typeof getServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCaa: typeof resolveCaa; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + setLocalAddress(ipv4?: string, ipv6?: string): void; + setServers: typeof setServers; + } +} +declare module "node:dns/promises" { + export * from "dns/promises"; +} diff --git a/node_modules/@types/node/dom-events.d.ts b/node_modules/@types/node/dom-events.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..147a7b657dfa93431b2724b9e31c05f75cfe230c --- /dev/null +++ b/node_modules/@types/node/dom-events.d.ts @@ -0,0 +1,122 @@ +export {}; // Don't export anything! + +//// DOM-like Events +// NB: The Event / EventTarget / EventListener implementations below were copied +// from lib.dom.d.ts, then edited to reflect Node's documentation at +// https://nodejs.org/api/events.html#class-eventtarget. +// Please read that link to understand important implementation differences. + +// This conditional type will be the existing global Event in a browser, or +// the copy below in a Node environment. +type __Event = typeof globalThis extends { onmessage: any; Event: any } ? {} + : { + /** This is not used in Node.js and is provided purely for completeness. */ + readonly bubbles: boolean; + /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */ + cancelBubble: () => void; + /** True if the event was created with the cancelable option */ + readonly cancelable: boolean; + /** This is not used in Node.js and is provided purely for completeness. */ + readonly composed: boolean; + /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */ + composedPath(): [EventTarget?]; + /** Alias for event.target. */ + readonly currentTarget: EventTarget | null; + /** Is true if cancelable is true and event.preventDefault() has been called. */ + readonly defaultPrevented: boolean; + /** This is not used in Node.js and is provided purely for completeness. */ + readonly eventPhase: 0 | 2; + /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */ + readonly isTrusted: boolean; + /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */ + preventDefault(): void; + /** This is not used in Node.js and is provided purely for completeness. */ + returnValue: boolean; + /** Alias for event.target. */ + readonly srcElement: EventTarget | null; + /** Stops the invocation of event listeners after the current one completes. */ + stopImmediatePropagation(): void; + /** This is not used in Node.js and is provided purely for completeness. */ + stopPropagation(): void; + /** The `EventTarget` dispatching the event */ + readonly target: EventTarget | null; + /** The millisecond timestamp when the Event object was created. */ + readonly timeStamp: number; + /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ + readonly type: string; + }; + +// See comment above explaining conditional type +type __EventTarget = typeof globalThis extends { onmessage: any; EventTarget: any } ? {} + : { + /** + * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value. + * + * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched. + * + * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification. + * Specifically, the `capture` option is used as part of the key when registering a `listener`. + * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. + */ + addEventListener( + type: string, + listener: EventListener | EventListenerObject, + options?: AddEventListenerOptions | boolean, + ): void; + /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ + dispatchEvent(event: Event): boolean; + /** Removes the event listener in target's event listener list with the same type, callback, and options. */ + removeEventListener( + type: string, + listener: EventListener | EventListenerObject, + options?: EventListenerOptions | boolean, + ): void; + }; + +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; + composed?: boolean; +} + +interface EventListenerOptions { + /** Not directly used by Node.js. Added for API completeness. Default: `false`. */ + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */ + once?: boolean; + /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */ + passive?: boolean; +} + +interface EventListener { + (evt: Event): void; +} + +interface EventListenerObject { + handleEvent(object: Event): void; +} + +import {} from "events"; // Make this an ambient declaration +declare global { + /** An event which takes place in the DOM. */ + interface Event extends __Event {} + var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T + : { + prototype: __Event; + new(type: string, eventInitDict?: EventInit): __Event; + }; + + /** + * EventTarget is a DOM interface implemented by objects that can + * receive events and may have listeners for them. + */ + interface EventTarget extends __EventTarget {} + var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T + : { + prototype: __EventTarget; + new(): __EventTarget; + }; +} diff --git a/node_modules/@types/node/domain.d.ts b/node_modules/@types/node/domain.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..72f17bd801e745a3697e684826345fee0d998fcb --- /dev/null +++ b/node_modules/@types/node/domain.d.ts @@ -0,0 +1,170 @@ +/** + * **This module is pending deprecation.** Once a replacement API has been + * finalized, this module will be fully deprecated. Most developers should + * **not** have cause to use this module. Users who absolutely must have + * the functionality that domains provide may rely on it for the time being + * but should expect to have to migrate to a different solution + * in the future. + * + * Domains provide a way to handle multiple different IO operations as a + * single group. If any of the event emitters or callbacks registered to a + * domain emit an `'error'` event, or throw an error, then the domain object + * will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to + * exit immediately with an error code. + * @deprecated Since v1.4.2 - Deprecated + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/domain.js) + */ +declare module "domain" { + import EventEmitter = require("node:events"); + /** + * The `Domain` class encapsulates the functionality of routing errors and + * uncaught exceptions to the active `Domain` object. + * + * To handle the errors that it catches, listen to its `'error'` event. + */ + class Domain extends EventEmitter { + /** + * An array of timers and event emitters that have been explicitly added + * to the domain. + */ + members: Array; + /** + * The `enter()` method is plumbing used by the `run()`, `bind()`, and`intercept()` methods to set the active domain. It sets `domain.active` and`process.domain` to the domain, and implicitly + * pushes the domain onto the domain + * stack managed by the domain module (see {@link exit} for details on the + * domain stack). The call to `enter()` delimits the beginning of a chain of + * asynchronous calls and I/O operations bound to a domain. + * + * Calling `enter()` changes only the active domain, and does not alter the domain + * itself. `enter()` and `exit()` can be called an arbitrary number of times on a + * single domain. + */ + enter(): void; + /** + * The `exit()` method exits the current domain, popping it off the domain stack. + * Any time execution is going to switch to the context of a different chain of + * asynchronous calls, it's important to ensure that the current domain is exited. + * The call to `exit()` delimits either the end of or an interruption to the chain + * of asynchronous calls and I/O operations bound to a domain. + * + * If there are multiple, nested domains bound to the current execution context,`exit()` will exit any domains nested within this domain. + * + * Calling `exit()` changes only the active domain, and does not alter the domain + * itself. `enter()` and `exit()` can be called an arbitrary number of times on a + * single domain. + */ + exit(): void; + /** + * Run the supplied function in the context of the domain, implicitly + * binding all event emitters, timers, and low-level requests that are + * created in that context. Optionally, arguments can be passed to + * the function. + * + * This is the most basic way to use a domain. + * + * ```js + * const domain = require('node:domain'); + * const fs = require('node:fs'); + * const d = domain.create(); + * d.on('error', (er) => { + * console.error('Caught error!', er); + * }); + * d.run(() => { + * process.nextTick(() => { + * setTimeout(() => { // Simulating some various async stuff + * fs.open('non-existent file', 'r', (er, fd) => { + * if (er) throw er; + * // proceed... + * }); + * }, 100); + * }); + * }); + * ``` + * + * In this example, the `d.on('error')` handler will be triggered, rather + * than crashing the program. + */ + run(fn: (...args: any[]) => T, ...args: any[]): T; + /** + * Explicitly adds an emitter to the domain. If any event handlers called by + * the emitter throw an error, or if the emitter emits an `'error'` event, it + * will be routed to the domain's `'error'` event, just like with implicit + * binding. + * + * This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by + * the domain `'error'` handler. + * + * If the Timer or `EventEmitter` was already bound to a domain, it is removed + * from that one, and bound to this one instead. + * @param emitter emitter or timer to be added to the domain + */ + add(emitter: EventEmitter | NodeJS.Timer): void; + /** + * The opposite of {@link add}. Removes domain handling from the + * specified emitter. + * @param emitter emitter or timer to be removed from the domain + */ + remove(emitter: EventEmitter | NodeJS.Timer): void; + /** + * The returned function will be a wrapper around the supplied callback + * function. When the returned function is called, any errors that are + * thrown will be routed to the domain's `'error'` event. + * + * ```js + * const d = domain.create(); + * + * function readSomeFile(filename, cb) { + * fs.readFile(filename, 'utf8', d.bind((er, data) => { + * // If this throws, it will also be passed to the domain. + * return cb(er, data ? JSON.parse(data) : null); + * })); + * } + * + * d.on('error', (er) => { + * // An error occurred somewhere. If we throw it now, it will crash the program + * // with the normal line number and stack message. + * }); + * ``` + * @param callback The callback function + * @return The bound function + */ + bind(callback: T): T; + /** + * This method is almost identical to {@link bind}. However, in + * addition to catching thrown errors, it will also intercept `Error` objects sent as the first argument to the function. + * + * In this way, the common `if (err) return callback(err);` pattern can be replaced + * with a single error handler in a single place. + * + * ```js + * const d = domain.create(); + * + * function readSomeFile(filename, cb) { + * fs.readFile(filename, 'utf8', d.intercept((data) => { + * // Note, the first argument is never passed to the + * // callback since it is assumed to be the 'Error' argument + * // and thus intercepted by the domain. + * + * // If this throws, it will also be passed to the domain + * // so the error-handling logic can be moved to the 'error' + * // event on the domain instead of being repeated throughout + * // the program. + * return cb(null, JSON.parse(data)); + * })); + * } + * + * d.on('error', (er) => { + * // An error occurred somewhere. If we throw it now, it will crash the program + * // with the normal line number and stack message. + * }); + * ``` + * @param callback The callback function + * @return The intercepted function + */ + intercept(callback: T): T; + } + function create(): Domain; +} +declare module "node:domain" { + export * from "domain"; +} diff --git a/node_modules/@types/node/events.d.ts b/node_modules/@types/node/events.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ed47c53aa9c2a5d6d4d146aaff9855135036631 --- /dev/null +++ b/node_modules/@types/node/events.d.ts @@ -0,0 +1,879 @@ +/** + * Much of the Node.js core API is built around an idiomatic asynchronous + * event-driven architecture in which certain kinds of objects (called "emitters") + * emit named events that cause `Function` objects ("listeners") to be called. + * + * For instance: a `net.Server` object emits an event each time a peer + * connects to it; a `fs.ReadStream` emits an event when the file is opened; + * a `stream` emits an event whenever data is available to be read. + * + * All objects that emit events are instances of the `EventEmitter` class. These + * objects expose an `eventEmitter.on()` function that allows one or more + * functions to be attached to named events emitted by the object. Typically, + * event names are camel-cased strings but any valid JavaScript property key + * can be used. + * + * When the `EventEmitter` object emits an event, all of the functions attached + * to that specific event are called _synchronously_. Any values returned by the + * called listeners are _ignored_ and discarded. + * + * The following example shows a simple `EventEmitter` instance with a single + * listener. The `eventEmitter.on()` method is used to register listeners, while + * the `eventEmitter.emit()` method is used to trigger the event. + * + * ```js + * import { EventEmitter } from 'node:events'; + * + * class MyEmitter extends EventEmitter {} + * + * const myEmitter = new MyEmitter(); + * myEmitter.on('event', () => { + * console.log('an event occurred!'); + * }); + * myEmitter.emit('event'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/events.js) + */ +declare module "events" { + import { AsyncResource, AsyncResourceOptions } from "node:async_hooks"; + // NOTE: This class is in the docs but is **not actually exported** by Node. + // If https://github.com/nodejs/node/issues/39903 gets resolved and Node + // actually starts exporting the class, uncomment below. + // import { EventListener, EventListenerObject } from '__dom-events'; + // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */ + // interface NodeEventTarget extends EventTarget { + // /** + // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API. + // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget. + // */ + // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this; + // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */ + // eventNames(): string[]; + // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */ + // listenerCount(type: string): number; + // /** Node.js-specific alias for `eventTarget.removeListener()`. */ + // off(type: string, listener: EventListener | EventListenerObject): this; + // /** Node.js-specific alias for `eventTarget.addListener()`. */ + // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this; + // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */ + // once(type: string, listener: EventListener | EventListenerObject): this; + // /** + // * Node.js-specific extension to the `EventTarget` class. + // * If `type` is specified, removes all registered listeners for `type`, + // * otherwise removes all registered listeners. + // */ + // removeAllListeners(type: string): this; + // /** + // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`. + // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`. + // */ + // removeListener(type: string, listener: EventListener | EventListenerObject): this; + // } + interface EventEmitterOptions { + /** + * Enables automatic capturing of promise rejection. + */ + captureRejections?: boolean | undefined; + } + // Any EventTarget with a Node-style `once` function + interface _NodeEventTarget { + once(eventName: string | symbol, listener: (...args: any[]) => void): this; + } + // Any EventTarget with a DOM-style `addEventListener` + interface _DOMEventTarget { + addEventListener( + eventName: string, + listener: (...args: any[]) => void, + opts?: { + once: boolean; + }, + ): any; + } + interface StaticEventEmitterOptions { + signal?: AbortSignal | undefined; + } + interface EventEmitter extends NodeJS.EventEmitter {} + /** + * The `EventEmitter` class is defined and exposed by the `node:events` module: + * + * ```js + * import { EventEmitter } from 'node:events'; + * ``` + * + * All `EventEmitter`s emit the event `'newListener'` when new listeners are + * added and `'removeListener'` when existing listeners are removed. + * + * It supports the following option: + * @since v0.1.26 + */ + class EventEmitter { + constructor(options?: EventEmitterOptions); + + [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void; + + /** + * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given + * event or that is rejected if the `EventEmitter` emits `'error'` while waiting. + * The `Promise` will resolve with an array of all the arguments emitted to the + * given event. + * + * This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event + * semantics and does not listen to the `'error'` event. + * + * ```js + * import { once, EventEmitter } from 'node:events'; + * import process from 'node:process'; + * + * const ee = new EventEmitter(); + * + * process.nextTick(() => { + * ee.emit('myevent', 42); + * }); + * + * const [value] = await once(ee, 'myevent'); + * console.log(value); + * + * const err = new Error('kaboom'); + * process.nextTick(() => { + * ee.emit('error', err); + * }); + * + * try { + * await once(ee, 'myevent'); + * } catch (err) { + * console.error('error happened', err); + * } + * ``` + * + * The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the + * '`error'` event itself, then it is treated as any other kind of event without + * special handling: + * + * ```js + * import { EventEmitter, once } from 'node:events'; + * + * const ee = new EventEmitter(); + * + * once(ee, 'error') + * .then(([err]) => console.log('ok', err.message)) + * .catch((err) => console.error('error', err.message)); + * + * ee.emit('error', new Error('boom')); + * + * // Prints: ok boom + * ``` + * + * An `AbortSignal` can be used to cancel waiting for the event: + * + * ```js + * import { EventEmitter, once } from 'node:events'; + * + * const ee = new EventEmitter(); + * const ac = new AbortController(); + * + * async function foo(emitter, event, signal) { + * try { + * await once(emitter, event, { signal }); + * console.log('event emitted!'); + * } catch (error) { + * if (error.name === 'AbortError') { + * console.error('Waiting for the event was canceled!'); + * } else { + * console.error('There was an error', error.message); + * } + * } + * } + * + * foo(ee, 'foo', ac.signal); + * ac.abort(); // Abort waiting for the event + * ee.emit('foo'); // Prints: Waiting for the event was canceled! + * ``` + * @since v11.13.0, v10.16.0 + */ + static once( + emitter: _NodeEventTarget, + eventName: string | symbol, + options?: StaticEventEmitterOptions, + ): Promise; + static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise; + /** + * ```js + * import { on, EventEmitter } from 'node:events'; + * import process from 'node:process'; + * + * const ee = new EventEmitter(); + * + * // Emit later on + * process.nextTick(() => { + * ee.emit('foo', 'bar'); + * ee.emit('foo', 42); + * }); + * + * for await (const event of on(ee, 'foo')) { + * // The execution of this inner block is synchronous and it + * // processes one event at a time (even with await). Do not use + * // if concurrent execution is required. + * console.log(event); // prints ['bar'] [42] + * } + * // Unreachable here + * ``` + * + * Returns an `AsyncIterator` that iterates `eventName` events. It will throw + * if the `EventEmitter` emits `'error'`. It removes all listeners when + * exiting the loop. The `value` returned by each iteration is an array + * composed of the emitted event arguments. + * + * An `AbortSignal` can be used to cancel waiting on events: + * + * ```js + * import { on, EventEmitter } from 'node:events'; + * import process from 'node:process'; + * + * const ac = new AbortController(); + * + * (async () => { + * const ee = new EventEmitter(); + * + * // Emit later on + * process.nextTick(() => { + * ee.emit('foo', 'bar'); + * ee.emit('foo', 42); + * }); + * + * for await (const event of on(ee, 'foo', { signal: ac.signal })) { + * // The execution of this inner block is synchronous and it + * // processes one event at a time (even with await). Do not use + * // if concurrent execution is required. + * console.log(event); // prints ['bar'] [42] + * } + * // Unreachable here + * })(); + * + * process.nextTick(() => ac.abort()); + * ``` + * @since v13.6.0, v12.16.0 + * @param eventName The name of the event being listened for + * @return that iterates `eventName` events emitted by the `emitter` + */ + static on( + emitter: NodeJS.EventEmitter, + eventName: string, + options?: StaticEventEmitterOptions, + ): AsyncIterableIterator; + /** + * A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`. + * + * ```js + * import { EventEmitter, listenerCount } from 'node:events'; + * + * const myEmitter = new EventEmitter(); + * myEmitter.on('event', () => {}); + * myEmitter.on('event', () => {}); + * console.log(listenerCount(myEmitter, 'event')); + * // Prints: 2 + * ``` + * @since v0.9.12 + * @deprecated Since v3.2.0 - Use `listenerCount` instead. + * @param emitter The emitter to query + * @param eventName The event name + */ + static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number; + /** + * Returns a copy of the array of listeners for the event named `eventName`. + * + * For `EventEmitter`s this behaves exactly the same as calling `.listeners` on + * the emitter. + * + * For `EventTarget`s this is the only way to get the event listeners for the + * event target. This is useful for debugging and diagnostic purposes. + * + * ```js + * import { getEventListeners, EventEmitter } from 'node:events'; + * + * { + * const ee = new EventEmitter(); + * const listener = () => console.log('Events are fun'); + * ee.on('foo', listener); + * console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ] + * } + * { + * const et = new EventTarget(); + * const listener = () => console.log('Events are fun'); + * et.addEventListener('foo', listener); + * console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ] + * } + * ``` + * @since v15.2.0, v14.17.0 + */ + static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[]; + /** + * Returns the currently set max amount of listeners. + * + * For `EventEmitter`s this behaves exactly the same as calling `.getMaxListeners` on + * the emitter. + * + * For `EventTarget`s this is the only way to get the max event listeners for the + * event target. If the number of event handlers on a single EventTarget exceeds + * the max set, the EventTarget will print a warning. + * + * ```js + * import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events'; + * + * { + * const ee = new EventEmitter(); + * console.log(getMaxListeners(ee)); // 10 + * setMaxListeners(11, ee); + * console.log(getMaxListeners(ee)); // 11 + * } + * { + * const et = new EventTarget(); + * console.log(getMaxListeners(et)); // 10 + * setMaxListeners(11, et); + * console.log(getMaxListeners(et)); // 11 + * } + * ``` + * @since v19.9.0 + */ + static getMaxListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter): number; + /** + * ```js + * import { setMaxListeners, EventEmitter } from 'node:events'; + * + * const target = new EventTarget(); + * const emitter = new EventEmitter(); + * + * setMaxListeners(5, target, emitter); + * ``` + * @since v15.4.0 + * @param n A non-negative number. The maximum number of listeners per `EventTarget` event. + * @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter} + * objects. + */ + static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void; + /** + * Listens once to the `abort` event on the provided `signal`. + * + * Listening to the `abort` event on abort signals is unsafe and may + * lead to resource leaks since another third party with the signal can + * call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change + * this since it would violate the web standard. Additionally, the original + * API makes it easy to forget to remove listeners. + * + * This API allows safely using `AbortSignal`s in Node.js APIs by solving these + * two issues by listening to the event such that `stopImmediatePropagation` does + * not prevent the listener from running. + * + * Returns a disposable so that it may be unsubscribed from more easily. + * + * ```js + * import { addAbortListener } from 'node:events'; + * + * function example(signal) { + * let disposable; + * try { + * signal.addEventListener('abort', (e) => e.stopImmediatePropagation()); + * disposable = addAbortListener(signal, (e) => { + * // Do something when signal is aborted. + * }); + * } finally { + * disposable?.[Symbol.dispose](); + * } + * } + * ``` + * @since v20.5.0 + * @experimental + * @return Disposable that removes the `abort` listener. + */ + static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable; + /** + * This symbol shall be used to install a listener for only monitoring `'error'`events. Listeners installed using this symbol are called before the regular`'error'` listeners are called. + * + * Installing a listener using this symbol does not change the behavior once an`'error'` event is emitted. Therefore, the process will still crash if no + * regular `'error'` listener is installed. + * @since v13.6.0, v12.17.0 + */ + static readonly errorMonitor: unique symbol; + /** + * Value: `Symbol.for('nodejs.rejection')` + * + * See how to write a custom `rejection handler`. + * @since v13.4.0, v12.16.0 + */ + static readonly captureRejectionSymbol: unique symbol; + /** + * Value: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) + * + * Change the default `captureRejections` option on all new `EventEmitter` objects. + * @since v13.4.0, v12.16.0 + */ + static captureRejections: boolean; + /** + * By default, a maximum of `10` listeners can be registered for any single + * event. This limit can be changed for individual `EventEmitter` instances + * using the `emitter.setMaxListeners(n)` method. To change the default + * for _all_`EventEmitter` instances, the `events.defaultMaxListeners`property can be used. If this value is not a positive number, a `RangeError`is thrown. + * + * Take caution when setting the `events.defaultMaxListeners` because the + * change affects _all_`EventEmitter` instances, including those created before + * the change is made. However, calling `emitter.setMaxListeners(n)` still has + * precedence over `events.defaultMaxListeners`. + * + * This is not a hard limit. The `EventEmitter` instance will allow + * more listeners to be added but will output a trace warning to stderr indicating + * that a "possible EventEmitter memory leak" has been detected. For any single`EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()`methods can be used to + * temporarily avoid this warning: + * + * ```js + * import { EventEmitter } from 'node:events'; + * const emitter = new EventEmitter(); + * emitter.setMaxListeners(emitter.getMaxListeners() + 1); + * emitter.once('event', () => { + * // do stuff + * emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0)); + * }); + * ``` + * + * The `--trace-warnings` command-line flag can be used to display the + * stack trace for such warnings. + * + * The emitted warning can be inspected with `process.on('warning')` and will + * have the additional `emitter`, `type`, and `count` properties, referring to + * the event emitter instance, the event's name and the number of attached + * listeners, respectively. + * Its `name` property is set to `'MaxListenersExceededWarning'`. + * @since v0.11.2 + */ + static defaultMaxListeners: number; + } + import internal = require("node:events"); + namespace EventEmitter { + // Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4 + export { internal as EventEmitter }; + export interface Abortable { + /** + * When provided the corresponding `AbortController` can be used to cancel an asynchronous action. + */ + signal?: AbortSignal | undefined; + } + + export interface EventEmitterReferencingAsyncResource extends AsyncResource { + readonly eventEmitter: EventEmitterAsyncResource; + } + + export interface EventEmitterAsyncResourceOptions extends AsyncResourceOptions, EventEmitterOptions { + /** + * The type of async event, this is required when instantiating `EventEmitterAsyncResource` + * directly rather than as a child class. + * @default new.target.name if instantiated as a child class. + */ + name?: string; + } + + /** + * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that + * require manual async tracking. Specifically, all events emitted by instances + * of `events.EventEmitterAsyncResource` will run within its `async context`. + * + * ```js + * import { EventEmitterAsyncResource, EventEmitter } from 'node:events'; + * import { notStrictEqual, strictEqual } from 'node:assert'; + * import { executionAsyncId, triggerAsyncId } from 'node:async_hooks'; + * + * // Async tracking tooling will identify this as 'Q'. + * const ee1 = new EventEmitterAsyncResource({ name: 'Q' }); + * + * // 'foo' listeners will run in the EventEmitters async context. + * ee1.on('foo', () => { + * strictEqual(executionAsyncId(), ee1.asyncId); + * strictEqual(triggerAsyncId(), ee1.triggerAsyncId); + * }); + * + * const ee2 = new EventEmitter(); + * + * // 'foo' listeners on ordinary EventEmitters that do not track async + * // context, however, run in the same async context as the emit(). + * ee2.on('foo', () => { + * notStrictEqual(executionAsyncId(), ee2.asyncId); + * notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId); + * }); + * + * Promise.resolve().then(() => { + * ee1.emit('foo'); + * ee2.emit('foo'); + * }); + * ``` + * + * The `EventEmitterAsyncResource` class has the same methods and takes the + * same options as `EventEmitter` and `AsyncResource` themselves. + * @since v17.4.0, v16.14.0 + */ + export class EventEmitterAsyncResource extends EventEmitter { + /** + * @param options Only optional in child class. + */ + constructor(options?: EventEmitterAsyncResourceOptions); + /** + * Call all `destroy` hooks. This should only ever be called once. An error will + * be thrown if it is called more than once. This **must** be manually called. If + * the resource is left to be collected by the GC then the `destroy` hooks will + * never be called. + */ + emitDestroy(): void; + /** + * The unique `asyncId` assigned to the resource. + */ + readonly asyncId: number; + /** + * The same triggerAsyncId that is passed to the AsyncResource constructor. + */ + readonly triggerAsyncId: number; + /** + * The returned `AsyncResource` object has an additional `eventEmitter` property + * that provides a reference to this `EventEmitterAsyncResource`. + */ + readonly asyncResource: EventEmitterReferencingAsyncResource; + } + } + global { + namespace NodeJS { + interface EventEmitter { + [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void; + /** + * Alias for `emitter.on(eventName, listener)`. + * @since v0.1.26 + */ + addListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Adds the `listener` function to the end of the listeners array for the + * event named `eventName`. No checks are made to see if the `listener` has + * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple + * times. + * + * ```js + * server.on('connection', (stream) => { + * console.log('someone connected!'); + * }); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * + * By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the + * event listener to the beginning of the listeners array. + * + * ```js + * import { EventEmitter } from 'node:events'; + * const myEE = new EventEmitter(); + * myEE.on('foo', () => console.log('a')); + * myEE.prependListener('foo', () => console.log('b')); + * myEE.emit('foo'); + * // Prints: + * // b + * // a + * ``` + * @since v0.1.101 + * @param eventName The name of the event. + * @param listener The callback function + */ + on(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Adds a **one-time**`listener` function for the event named `eventName`. The + * next time `eventName` is triggered, this listener is removed and then invoked. + * + * ```js + * server.once('connection', (stream) => { + * console.log('Ah, we have our first user!'); + * }); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * + * By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the + * event listener to the beginning of the listeners array. + * + * ```js + * import { EventEmitter } from 'node:events'; + * const myEE = new EventEmitter(); + * myEE.once('foo', () => console.log('a')); + * myEE.prependOnceListener('foo', () => console.log('b')); + * myEE.emit('foo'); + * // Prints: + * // b + * // a + * ``` + * @since v0.3.0 + * @param eventName The name of the event. + * @param listener The callback function + */ + once(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Removes the specified `listener` from the listener array for the event named`eventName`. + * + * ```js + * const callback = (stream) => { + * console.log('someone connected!'); + * }; + * server.on('connection', callback); + * // ... + * server.removeListener('connection', callback); + * ``` + * + * `removeListener()` will remove, at most, one instance of a listener from the + * listener array. If any single listener has been added multiple times to the + * listener array for the specified `eventName`, then `removeListener()` must be + * called multiple times to remove each instance. + * + * Once an event is emitted, all listeners attached to it at the + * time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution + * will not remove them from`emit()` in progress. Subsequent events behave as expected. + * + * ```js + * import { EventEmitter } from 'node:events'; + * class MyEmitter extends EventEmitter {} + * const myEmitter = new MyEmitter(); + * + * const callbackA = () => { + * console.log('A'); + * myEmitter.removeListener('event', callbackB); + * }; + * + * const callbackB = () => { + * console.log('B'); + * }; + * + * myEmitter.on('event', callbackA); + * + * myEmitter.on('event', callbackB); + * + * // callbackA removes listener callbackB but it will still be called. + * // Internal listener array at time of emit [callbackA, callbackB] + * myEmitter.emit('event'); + * // Prints: + * // A + * // B + * + * // callbackB is now removed. + * // Internal listener array [callbackA] + * myEmitter.emit('event'); + * // Prints: + * // A + * ``` + * + * Because listeners are managed using an internal array, calling this will + * change the position indices of any listener registered _after_ the listener + * being removed. This will not impact the order in which listeners are called, + * but it means that any copies of the listener array as returned by + * the `emitter.listeners()` method will need to be recreated. + * + * When a single function has been added as a handler multiple times for a single + * event (as in the example below), `removeListener()` will remove the most + * recently added instance. In the example the `once('ping')`listener is removed: + * + * ```js + * import { EventEmitter } from 'node:events'; + * const ee = new EventEmitter(); + * + * function pong() { + * console.log('pong'); + * } + * + * ee.on('ping', pong); + * ee.once('ping', pong); + * ee.removeListener('ping', pong); + * + * ee.emit('ping'); + * ee.emit('ping'); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v0.1.26 + */ + removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Alias for `emitter.removeListener()`. + * @since v10.0.0 + */ + off(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Removes all listeners, or those of the specified `eventName`. + * + * It is bad practice to remove listeners added elsewhere in the code, + * particularly when the `EventEmitter` instance was created by some other + * component or module (e.g. sockets or file streams). + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v0.1.26 + */ + removeAllListeners(event?: string | symbol): this; + /** + * By default `EventEmitter`s will print a warning if more than `10` listeners are + * added for a particular event. This is a useful default that helps finding + * memory leaks. The `emitter.setMaxListeners()` method allows the limit to be + * modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners. + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v0.3.5 + */ + setMaxListeners(n: number): this; + /** + * Returns the current max listener value for the `EventEmitter` which is either + * set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}. + * @since v1.0.0 + */ + getMaxListeners(): number; + /** + * Returns a copy of the array of listeners for the event named `eventName`. + * + * ```js + * server.on('connection', (stream) => { + * console.log('someone connected!'); + * }); + * console.log(util.inspect(server.listeners('connection'))); + * // Prints: [ [Function] ] + * ``` + * @since v0.1.26 + */ + listeners(eventName: string | symbol): Function[]; + /** + * Returns a copy of the array of listeners for the event named `eventName`, + * including any wrappers (such as those created by `.once()`). + * + * ```js + * import { EventEmitter } from 'node:events'; + * const emitter = new EventEmitter(); + * emitter.once('log', () => console.log('log once')); + * + * // Returns a new Array with a function `onceWrapper` which has a property + * // `listener` which contains the original listener bound above + * const listeners = emitter.rawListeners('log'); + * const logFnWrapper = listeners[0]; + * + * // Logs "log once" to the console and does not unbind the `once` event + * logFnWrapper.listener(); + * + * // Logs "log once" to the console and removes the listener + * logFnWrapper(); + * + * emitter.on('log', () => console.log('log persistently')); + * // Will return a new Array with a single function bound by `.on()` above + * const newListeners = emitter.rawListeners('log'); + * + * // Logs "log persistently" twice + * newListeners[0](); + * emitter.emit('log'); + * ``` + * @since v9.4.0 + */ + rawListeners(eventName: string | symbol): Function[]; + /** + * Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments + * to each. + * + * Returns `true` if the event had listeners, `false` otherwise. + * + * ```js + * import { EventEmitter } from 'node:events'; + * const myEmitter = new EventEmitter(); + * + * // First listener + * myEmitter.on('event', function firstListener() { + * console.log('Helloooo! first listener'); + * }); + * // Second listener + * myEmitter.on('event', function secondListener(arg1, arg2) { + * console.log(`event with parameters ${arg1}, ${arg2} in second listener`); + * }); + * // Third listener + * myEmitter.on('event', function thirdListener(...args) { + * const parameters = args.join(', '); + * console.log(`event with parameters ${parameters} in third listener`); + * }); + * + * console.log(myEmitter.listeners('event')); + * + * myEmitter.emit('event', 1, 2, 3, 4, 5); + * + * // Prints: + * // [ + * // [Function: firstListener], + * // [Function: secondListener], + * // [Function: thirdListener] + * // ] + * // Helloooo! first listener + * // event with parameters 1, 2 in second listener + * // event with parameters 1, 2, 3, 4, 5 in third listener + * ``` + * @since v0.1.26 + */ + emit(eventName: string | symbol, ...args: any[]): boolean; + /** + * Returns the number of listeners listening for the event named `eventName`. + * If `listener` is provided, it will return how many times the listener is found + * in the list of the listeners of the event. + * @since v3.2.0 + * @param eventName The name of the event being listened for + * @param listener The event handler function + */ + listenerCount(eventName: string | symbol, listener?: Function): number; + /** + * Adds the `listener` function to the _beginning_ of the listeners array for the + * event named `eventName`. No checks are made to see if the `listener` has + * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple + * times. + * + * ```js + * server.prependListener('connection', (stream) => { + * console.log('someone connected!'); + * }); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v6.0.0 + * @param eventName The name of the event. + * @param listener The callback function + */ + prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Adds a **one-time**`listener` function for the event named `eventName` to the _beginning_ of the listeners array. The next time `eventName` is triggered, this + * listener is removed, and then invoked. + * + * ```js + * server.prependOnceListener('connection', (stream) => { + * console.log('Ah, we have our first user!'); + * }); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v6.0.0 + * @param eventName The name of the event. + * @param listener The callback function + */ + prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Returns an array listing the events for which the emitter has registered + * listeners. The values in the array are strings or `Symbol`s. + * + * ```js + * import { EventEmitter } from 'node:events'; + * + * const myEE = new EventEmitter(); + * myEE.on('foo', () => {}); + * myEE.on('bar', () => {}); + * + * const sym = Symbol('symbol'); + * myEE.on(sym, () => {}); + * + * console.log(myEE.eventNames()); + * // Prints: [ 'foo', 'bar', Symbol(symbol) ] + * ``` + * @since v6.0.0 + */ + eventNames(): Array; + } + } + } + export = EventEmitter; +} +declare module "node:events" { + import events = require("events"); + export = events; +} diff --git a/node_modules/@types/node/fs.d.ts b/node_modules/@types/node/fs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f98453a53dad6e01f91b39890dfbb938a181604b --- /dev/null +++ b/node_modules/@types/node/fs.d.ts @@ -0,0 +1,4291 @@ +/** + * The `node:fs` module enables interacting with the file system in a + * way modeled on standard POSIX functions. + * + * To use the promise-based APIs: + * + * ```js + * import * as fs from 'node:fs/promises'; + * ``` + * + * To use the callback and sync APIs: + * + * ```js + * import * as fs from 'node:fs'; + * ``` + * + * All file system operations have synchronous, callback, and promise-based + * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM). + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/fs.js) + */ +declare module "fs" { + import * as stream from "node:stream"; + import { Abortable, EventEmitter } from "node:events"; + import { URL } from "node:url"; + import * as promises from "node:fs/promises"; + export { promises }; + /** + * Valid types for path values in "fs". + */ + export type PathLike = string | Buffer | URL; + export type PathOrFileDescriptor = PathLike | number; + export type TimeLike = string | number | Date; + export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void; + export type BufferEncodingOption = + | "buffer" + | { + encoding: "buffer"; + }; + export interface ObjectEncodingOptions { + encoding?: BufferEncoding | null | undefined; + } + export type EncodingOption = ObjectEncodingOptions | BufferEncoding | undefined | null; + export type OpenMode = number | string; + export type Mode = number | string; + export interface StatsBase { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + dev: T; + ino: T; + mode: T; + nlink: T; + uid: T; + gid: T; + rdev: T; + size: T; + blksize: T; + blocks: T; + atimeMs: T; + mtimeMs: T; + ctimeMs: T; + birthtimeMs: T; + atime: Date; + mtime: Date; + ctime: Date; + birthtime: Date; + } + export interface Stats extends StatsBase {} + /** + * A `fs.Stats` object provides information about a file. + * + * Objects returned from {@link stat}, {@link lstat}, {@link fstat}, and + * their synchronous counterparts are of this type. + * If `bigint` in the `options` passed to those methods is true, the numeric values + * will be `bigint` instead of `number`, and the object will contain additional + * nanosecond-precision properties suffixed with `Ns`. + * + * ```console + * Stats { + * dev: 2114, + * ino: 48064969, + * mode: 33188, + * nlink: 1, + * uid: 85, + * gid: 100, + * rdev: 0, + * size: 527, + * blksize: 4096, + * blocks: 8, + * atimeMs: 1318289051000.1, + * mtimeMs: 1318289051000.1, + * ctimeMs: 1318289051000.1, + * birthtimeMs: 1318289051000.1, + * atime: Mon, 10 Oct 2011 23:24:11 GMT, + * mtime: Mon, 10 Oct 2011 23:24:11 GMT, + * ctime: Mon, 10 Oct 2011 23:24:11 GMT, + * birthtime: Mon, 10 Oct 2011 23:24:11 GMT } + * ``` + * + * `bigint` version: + * + * ```console + * BigIntStats { + * dev: 2114n, + * ino: 48064969n, + * mode: 33188n, + * nlink: 1n, + * uid: 85n, + * gid: 100n, + * rdev: 0n, + * size: 527n, + * blksize: 4096n, + * blocks: 8n, + * atimeMs: 1318289051000n, + * mtimeMs: 1318289051000n, + * ctimeMs: 1318289051000n, + * birthtimeMs: 1318289051000n, + * atimeNs: 1318289051000000000n, + * mtimeNs: 1318289051000000000n, + * ctimeNs: 1318289051000000000n, + * birthtimeNs: 1318289051000000000n, + * atime: Mon, 10 Oct 2011 23:24:11 GMT, + * mtime: Mon, 10 Oct 2011 23:24:11 GMT, + * ctime: Mon, 10 Oct 2011 23:24:11 GMT, + * birthtime: Mon, 10 Oct 2011 23:24:11 GMT } + * ``` + * @since v0.1.21 + */ + export class Stats {} + export interface StatsFsBase { + /** Type of file system. */ + type: T; + /** Optimal transfer block size. */ + bsize: T; + /** Total data blocks in file system. */ + blocks: T; + /** Free blocks in file system. */ + bfree: T; + /** Available blocks for unprivileged users */ + bavail: T; + /** Total file nodes in file system. */ + files: T; + /** Free file nodes in file system. */ + ffree: T; + } + export interface StatsFs extends StatsFsBase {} + /** + * Provides information about a mounted file system. + * + * Objects returned from {@link statfs} and its synchronous counterpart are of + * this type. If `bigint` in the `options` passed to those methods is `true`, the + * numeric values will be `bigint` instead of `number`. + * + * ```console + * StatFs { + * type: 1397114950, + * bsize: 4096, + * blocks: 121938943, + * bfree: 61058895, + * bavail: 61058895, + * files: 999, + * ffree: 1000000 + * } + * ``` + * + * `bigint` version: + * + * ```console + * StatFs { + * type: 1397114950n, + * bsize: 4096n, + * blocks: 121938943n, + * bfree: 61058895n, + * bavail: 61058895n, + * files: 999n, + * ffree: 1000000n + * } + * ``` + * @since v19.6.0, v18.15.0 + */ + export class StatsFs {} + export interface BigIntStatsFs extends StatsFsBase {} + export interface StatFsOptions { + bigint?: boolean | undefined; + } + /** + * A representation of a directory entry, which can be a file or a subdirectory + * within the directory, as returned by reading from an `fs.Dir`. The + * directory entry is a combination of the file name and file type pairs. + * + * Additionally, when {@link readdir} or {@link readdirSync} is called with + * the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s. + * @since v10.10.0 + */ + export class Dirent { + /** + * Returns `true` if the `fs.Dirent` object describes a regular file. + * @since v10.10.0 + */ + isFile(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a file system + * directory. + * @since v10.10.0 + */ + isDirectory(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a block device. + * @since v10.10.0 + */ + isBlockDevice(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a character device. + * @since v10.10.0 + */ + isCharacterDevice(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a symbolic link. + * @since v10.10.0 + */ + isSymbolicLink(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a first-in-first-out + * (FIFO) pipe. + * @since v10.10.0 + */ + isFIFO(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a socket. + * @since v10.10.0 + */ + isSocket(): boolean; + /** + * The file name that this `fs.Dirent` object refers to. The type of this + * value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}. + * @since v10.10.0 + */ + name: string; + /** + * The base path that this `fs.Dirent` object refers to. + * @since v20.1.0 + */ + path: string; + } + /** + * A class representing a directory stream. + * + * Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`. + * + * ```js + * import { opendir } from 'node:fs/promises'; + * + * try { + * const dir = await opendir('./'); + * for await (const dirent of dir) + * console.log(dirent.name); + * } catch (err) { + * console.error(err); + * } + * ``` + * + * When using the async iterator, the `fs.Dir` object will be automatically + * closed after the iterator exits. + * @since v12.12.0 + */ + export class Dir implements AsyncIterable { + /** + * The read-only path of this directory as was provided to {@link opendir},{@link opendirSync}, or `fsPromises.opendir()`. + * @since v12.12.0 + */ + readonly path: string; + /** + * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read. + */ + [Symbol.asyncIterator](): AsyncIterableIterator; + /** + * Asynchronously close the directory's underlying resource handle. + * Subsequent reads will result in errors. + * + * A promise is returned that will be resolved after the resource has been + * closed. + * @since v12.12.0 + */ + close(): Promise; + close(cb: NoParamCallback): void; + /** + * Synchronously close the directory's underlying resource handle. + * Subsequent reads will result in errors. + * @since v12.12.0 + */ + closeSync(): void; + /** + * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`. + * + * A promise is returned that will be resolved with an `fs.Dirent`, or `null`if there are no more directory entries to read. + * + * Directory entries returned by this function are in no particular order as + * provided by the operating system's underlying directory mechanisms. + * Entries added or removed while iterating over the directory might not be + * included in the iteration results. + * @since v12.12.0 + * @return containing {fs.Dirent|null} + */ + read(): Promise; + read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void; + /** + * Synchronously read the next directory entry as an `fs.Dirent`. See the + * POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail. + * + * If there are no more directory entries to read, `null` will be returned. + * + * Directory entries returned by this function are in no particular order as + * provided by the operating system's underlying directory mechanisms. + * Entries added or removed while iterating over the directory might not be + * included in the iteration results. + * @since v12.12.0 + */ + readSync(): Dirent | null; + } + /** + * Class: fs.StatWatcher + * @since v14.3.0, v12.20.0 + * Extends `EventEmitter` + * A successful call to {@link watchFile} method will return a new fs.StatWatcher object. + */ + export interface StatWatcher extends EventEmitter { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the `fs.StatWatcher` is active. Calling `watcher.ref()` multiple times will have + * no effect. + * + * By default, all `fs.StatWatcher` objects are "ref'ed", making it normally + * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been + * called previously. + * @since v14.3.0, v12.20.0 + */ + ref(): this; + /** + * When called, the active `fs.StatWatcher` object will not require the Node.js + * event loop to remain active. If there is no other activity keeping the + * event loop running, the process may exit before the `fs.StatWatcher` object's + * callback is invoked. Calling `watcher.unref()` multiple times will have + * no effect. + * @since v14.3.0, v12.20.0 + */ + unref(): this; + } + export interface FSWatcher extends EventEmitter { + /** + * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable. + * @since v0.5.8 + */ + close(): void; + /** + * events.EventEmitter + * 1. change + * 2. error + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + addListener(event: "error", listener: (error: Error) => void): this; + addListener(event: "close", listener: () => void): this; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "close", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + once(event: "error", listener: (error: Error) => void): this; + once(event: "close", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + prependListener(event: "error", listener: (error: Error) => void): this; + prependListener(event: "close", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + prependOnceListener(event: "error", listener: (error: Error) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + } + /** + * Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function. + * @since v0.1.93 + */ + export class ReadStream extends stream.Readable { + close(callback?: (err?: NodeJS.ErrnoException | null) => void): void; + /** + * The number of bytes that have been read so far. + * @since v6.4.0 + */ + bytesRead: number; + /** + * The path to the file the stream is reading from as specified in the first + * argument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a + * `Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`. + * @since v0.1.93 + */ + path: string | Buffer; + /** + * This property is `true` if the underlying file has not been opened yet, + * i.e. before the `'ready'` event is emitted. + * @since v11.2.0, v10.16.0 + */ + pending: boolean; + /** + * events.EventEmitter + * 1. open + * 2. close + * 3. ready + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: Buffer | string) => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "open", listener: (fd: number) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "ready", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: Buffer | string) => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "open", listener: (fd: number) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "readable", listener: () => void): this; + on(event: "ready", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: Buffer | string) => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "open", listener: (fd: number) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "readable", listener: () => void): this; + once(event: "ready", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "open", listener: (fd: number) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "ready", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "open", listener: (fd: number) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "ready", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * * Extends `stream.Writable` + * + * Instances of `fs.WriteStream` are created and returned using the {@link createWriteStream} function. + * @since v0.1.93 + */ + export class WriteStream extends stream.Writable { + /** + * Closes `writeStream`. Optionally accepts a + * callback that will be executed once the `writeStream`is closed. + * @since v0.9.4 + */ + close(callback?: (err?: NodeJS.ErrnoException | null) => void): void; + /** + * The number of bytes written so far. Does not include data that is still queued + * for writing. + * @since v0.4.7 + */ + bytesWritten: number; + /** + * The path to the file the stream is writing to as specified in the first + * argument to {@link createWriteStream}. If `path` is passed as a string, then`writeStream.path` will be a string. If `path` is passed as a `Buffer`, then`writeStream.path` will be a + * `Buffer`. + * @since v0.1.93 + */ + path: string | Buffer; + /** + * This property is `true` if the underlying file has not been opened yet, + * i.e. before the `'ready'` event is emitted. + * @since v11.2.0 + */ + pending: boolean; + /** + * events.EventEmitter + * 1. open + * 2. close + * 3. ready + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "open", listener: (fd: number) => void): this; + addListener(event: "pipe", listener: (src: stream.Readable) => void): this; + addListener(event: "ready", listener: () => void): this; + addListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "open", listener: (fd: number) => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + on(event: "ready", listener: () => void): this; + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "open", listener: (fd: number) => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + once(event: "ready", listener: () => void): this; + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "open", listener: (fd: number) => void): this; + prependListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "ready", listener: () => void): this; + prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "open", listener: (fd: number) => void): this; + prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "ready", listener: () => void): this; + prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * Asynchronously rename file at `oldPath` to the pathname provided + * as `newPath`. In the case that `newPath` already exists, it will + * be overwritten. If there is a directory at `newPath`, an error will + * be raised instead. No arguments other than a possible exception are + * given to the completion callback. + * + * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html). + * + * ```js + * import { rename } from 'node:fs'; + * + * rename('oldFile.txt', 'newFile.txt', (err) => { + * if (err) throw err; + * console.log('Rename complete!'); + * }); + * ``` + * @since v0.0.2 + */ + export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void; + export namespace rename { + /** + * Asynchronous rename(2) - Change the name or location of a file or directory. + * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + */ + function __promisify__(oldPath: PathLike, newPath: PathLike): Promise; + } + /** + * Renames the file from `oldPath` to `newPath`. Returns `undefined`. + * + * See the POSIX [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html) documentation for more details. + * @since v0.1.21 + */ + export function renameSync(oldPath: PathLike, newPath: PathLike): void; + /** + * Truncates the file. No arguments other than a possible exception are + * given to the completion callback. A file descriptor can also be passed as the + * first argument. In this case, `fs.ftruncate()` is called. + * + * ```js + * import { truncate } from 'node:fs'; + * // Assuming that 'path/file.txt' is a regular file. + * truncate('path/file.txt', (err) => { + * if (err) throw err; + * console.log('path/file.txt was truncated'); + * }); + * ``` + * + * Passing a file descriptor is deprecated and may result in an error being thrown + * in the future. + * + * See the POSIX [`truncate(2)`](http://man7.org/linux/man-pages/man2/truncate.2.html) documentation for more details. + * @since v0.8.6 + * @param [len=0] + */ + export function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void; + /** + * Asynchronous truncate(2) - Truncate a file to a specified length. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function truncate(path: PathLike, callback: NoParamCallback): void; + export namespace truncate { + /** + * Asynchronous truncate(2) - Truncate a file to a specified length. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param len If not specified, defaults to `0`. + */ + function __promisify__(path: PathLike, len?: number | null): Promise; + } + /** + * Truncates the file. Returns `undefined`. A file descriptor can also be + * passed as the first argument. In this case, `fs.ftruncateSync()` is called. + * + * Passing a file descriptor is deprecated and may result in an error being thrown + * in the future. + * @since v0.8.6 + * @param [len=0] + */ + export function truncateSync(path: PathLike, len?: number | null): void; + /** + * Truncates the file descriptor. No arguments other than a possible exception are + * given to the completion callback. + * + * See the POSIX [`ftruncate(2)`](http://man7.org/linux/man-pages/man2/ftruncate.2.html) documentation for more detail. + * + * If the file referred to by the file descriptor was larger than `len` bytes, only + * the first `len` bytes will be retained in the file. + * + * For example, the following program retains only the first four bytes of the + * file: + * + * ```js + * import { open, close, ftruncate } from 'node:fs'; + * + * function closeFd(fd) { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * + * open('temp.txt', 'r+', (err, fd) => { + * if (err) throw err; + * + * try { + * ftruncate(fd, 4, (err) => { + * closeFd(fd); + * if (err) throw err; + * }); + * } catch (err) { + * closeFd(fd); + * if (err) throw err; + * } + * }); + * ``` + * + * If the file previously was shorter than `len` bytes, it is extended, and the + * extended part is filled with null bytes (`'\0'`): + * + * If `len` is negative then `0` will be used. + * @since v0.8.6 + * @param [len=0] + */ + export function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void; + /** + * Asynchronous ftruncate(2) - Truncate a file to a specified length. + * @param fd A file descriptor. + */ + export function ftruncate(fd: number, callback: NoParamCallback): void; + export namespace ftruncate { + /** + * Asynchronous ftruncate(2) - Truncate a file to a specified length. + * @param fd A file descriptor. + * @param len If not specified, defaults to `0`. + */ + function __promisify__(fd: number, len?: number | null): Promise; + } + /** + * Truncates the file descriptor. Returns `undefined`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link ftruncate}. + * @since v0.8.6 + * @param [len=0] + */ + export function ftruncateSync(fd: number, len?: number | null): void; + /** + * Asynchronously changes owner and group of a file. No arguments other than a + * possible exception are given to the completion callback. + * + * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail. + * @since v0.1.97 + */ + export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void; + export namespace chown { + /** + * Asynchronous chown(2) - Change ownership of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(path: PathLike, uid: number, gid: number): Promise; + } + /** + * Synchronously changes owner and group of a file. Returns `undefined`. + * This is the synchronous version of {@link chown}. + * + * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail. + * @since v0.1.97 + */ + export function chownSync(path: PathLike, uid: number, gid: number): void; + /** + * Sets the owner of the file. No arguments other than a possible exception are + * given to the completion callback. + * + * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail. + * @since v0.4.7 + */ + export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void; + export namespace fchown { + /** + * Asynchronous fchown(2) - Change ownership of a file. + * @param fd A file descriptor. + */ + function __promisify__(fd: number, uid: number, gid: number): Promise; + } + /** + * Sets the owner of the file. Returns `undefined`. + * + * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail. + * @since v0.4.7 + * @param uid The file's new owner's user id. + * @param gid The file's new group's group id. + */ + export function fchownSync(fd: number, uid: number, gid: number): void; + /** + * Set the owner of the symbolic link. No arguments other than a possible + * exception are given to the completion callback. + * + * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more detail. + */ + export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void; + export namespace lchown { + /** + * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(path: PathLike, uid: number, gid: number): Promise; + } + /** + * Set the owner for the path. Returns `undefined`. + * + * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more details. + * @param uid The file's new owner's user id. + * @param gid The file's new group's group id. + */ + export function lchownSync(path: PathLike, uid: number, gid: number): void; + /** + * Changes the access and modification times of a file in the same way as {@link utimes}, with the difference that if the path refers to a symbolic + * link, then the link is not dereferenced: instead, the timestamps of the + * symbolic link itself are changed. + * + * No arguments other than a possible exception are given to the completion + * callback. + * @since v14.5.0, v12.19.0 + */ + export function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void; + export namespace lutimes { + /** + * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, + * with the difference that if the path refers to a symbolic link, then the link is not + * dereferenced: instead, the timestamps of the symbolic link itself are changed. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param atime The last access time. If a string is provided, it will be coerced to number. + * @param mtime The last modified time. If a string is provided, it will be coerced to number. + */ + function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise; + } + /** + * Change the file system timestamps of the symbolic link referenced by `path`. + * Returns `undefined`, or throws an exception when parameters are incorrect or + * the operation fails. This is the synchronous version of {@link lutimes}. + * @since v14.5.0, v12.19.0 + */ + export function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void; + /** + * Asynchronously changes the permissions of a file. No arguments other than a + * possible exception are given to the completion callback. + * + * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail. + * + * ```js + * import { chmod } from 'node:fs'; + * + * chmod('my_file.txt', 0o775, (err) => { + * if (err) throw err; + * console.log('The permissions for file "my_file.txt" have been changed!'); + * }); + * ``` + * @since v0.1.30 + */ + export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void; + export namespace chmod { + /** + * Asynchronous chmod(2) - Change permissions of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param mode A file mode. If a string is passed, it is parsed as an octal integer. + */ + function __promisify__(path: PathLike, mode: Mode): Promise; + } + /** + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link chmod}. + * + * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail. + * @since v0.6.7 + */ + export function chmodSync(path: PathLike, mode: Mode): void; + /** + * Sets the permissions on the file. No arguments other than a possible exception + * are given to the completion callback. + * + * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail. + * @since v0.4.7 + */ + export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void; + export namespace fchmod { + /** + * Asynchronous fchmod(2) - Change permissions of a file. + * @param fd A file descriptor. + * @param mode A file mode. If a string is passed, it is parsed as an octal integer. + */ + function __promisify__(fd: number, mode: Mode): Promise; + } + /** + * Sets the permissions on the file. Returns `undefined`. + * + * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail. + * @since v0.4.7 + */ + export function fchmodSync(fd: number, mode: Mode): void; + /** + * Changes the permissions on a symbolic link. No arguments other than a possible + * exception are given to the completion callback. + * + * This method is only implemented on macOS. + * + * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail. + * @deprecated Since v0.4.7 + */ + export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void; + /** @deprecated */ + export namespace lchmod { + /** + * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param mode A file mode. If a string is passed, it is parsed as an octal integer. + */ + function __promisify__(path: PathLike, mode: Mode): Promise; + } + /** + * Changes the permissions on a symbolic link. Returns `undefined`. + * + * This method is only implemented on macOS. + * + * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail. + * @deprecated Since v0.4.7 + */ + export function lchmodSync(path: PathLike, mode: Mode): void; + /** + * Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `fs.Stats` object. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * + * {@link stat} follows symbolic links. Use {@link lstat} to look at the + * links themselves. + * + * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. + * Instead, user code should open/read/write the file directly and handle the + * error raised if the file is not available. + * + * To check if a file exists without manipulating it afterwards, {@link access} is recommended. + * + * For example, given the following directory structure: + * + * ```text + * - txtDir + * -- file.txt + * - app.js + * ``` + * + * The next program will check for the stats of the given paths: + * + * ```js + * import { stat } from 'node:fs'; + * + * const pathsToCheck = ['./txtDir', './txtDir/file.txt']; + * + * for (let i = 0; i < pathsToCheck.length; i++) { + * stat(pathsToCheck[i], (err, stats) => { + * console.log(stats.isDirectory()); + * console.log(stats); + * }); + * } + * ``` + * + * The resulting output will resemble: + * + * ```console + * true + * Stats { + * dev: 16777220, + * mode: 16877, + * nlink: 3, + * uid: 501, + * gid: 20, + * rdev: 0, + * blksize: 4096, + * ino: 14214262, + * size: 96, + * blocks: 0, + * atimeMs: 1561174653071.963, + * mtimeMs: 1561174614583.3518, + * ctimeMs: 1561174626623.5366, + * birthtimeMs: 1561174126937.2893, + * atime: 2019-06-22T03:37:33.072Z, + * mtime: 2019-06-22T03:36:54.583Z, + * ctime: 2019-06-22T03:37:06.624Z, + * birthtime: 2019-06-22T03:28:46.937Z + * } + * false + * Stats { + * dev: 16777220, + * mode: 33188, + * nlink: 1, + * uid: 501, + * gid: 20, + * rdev: 0, + * blksize: 4096, + * ino: 14214074, + * size: 8, + * blocks: 8, + * atimeMs: 1561174616618.8555, + * mtimeMs: 1561174614584, + * ctimeMs: 1561174614583.8145, + * birthtimeMs: 1561174007710.7478, + * atime: 2019-06-22T03:36:56.619Z, + * mtime: 2019-06-22T03:36:54.584Z, + * ctime: 2019-06-22T03:36:54.584Z, + * birthtime: 2019-06-22T03:26:47.711Z + * } + * ``` + * @since v0.0.2 + */ + export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + export function stat( + path: PathLike, + options: + | (StatOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void, + ): void; + export function stat( + path: PathLike, + options: StatOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void, + ): void; + export function stat( + path: PathLike, + options: StatOptions | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void, + ): void; + export namespace stat { + /** + * Asynchronous stat(2) - Get file status. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__( + path: PathLike, + options?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function __promisify__( + path: PathLike, + options: StatOptions & { + bigint: true; + }, + ): Promise; + function __promisify__(path: PathLike, options?: StatOptions): Promise; + } + export interface StatSyncFn extends Function { + (path: PathLike, options?: undefined): Stats; + ( + path: PathLike, + options?: StatSyncOptions & { + bigint?: false | undefined; + throwIfNoEntry: false; + }, + ): Stats | undefined; + ( + path: PathLike, + options: StatSyncOptions & { + bigint: true; + throwIfNoEntry: false; + }, + ): BigIntStats | undefined; + ( + path: PathLike, + options?: StatSyncOptions & { + bigint?: false | undefined; + }, + ): Stats; + ( + path: PathLike, + options: StatSyncOptions & { + bigint: true; + }, + ): BigIntStats; + ( + path: PathLike, + options: StatSyncOptions & { + bigint: boolean; + throwIfNoEntry?: false | undefined; + }, + ): Stats | BigIntStats; + (path: PathLike, options?: StatSyncOptions): Stats | BigIntStats | undefined; + } + /** + * Synchronous stat(2) - Get file status. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export const statSync: StatSyncFn; + /** + * Invokes the callback with the `fs.Stats` for the file descriptor. + * + * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail. + * @since v0.1.95 + */ + export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + export function fstat( + fd: number, + options: + | (StatOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void, + ): void; + export function fstat( + fd: number, + options: StatOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void, + ): void; + export function fstat( + fd: number, + options: StatOptions | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void, + ): void; + export namespace fstat { + /** + * Asynchronous fstat(2) - Get file status. + * @param fd A file descriptor. + */ + function __promisify__( + fd: number, + options?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function __promisify__( + fd: number, + options: StatOptions & { + bigint: true; + }, + ): Promise; + function __promisify__(fd: number, options?: StatOptions): Promise; + } + /** + * Retrieves the `fs.Stats` for the file descriptor. + * + * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail. + * @since v0.1.95 + */ + export function fstatSync( + fd: number, + options?: StatOptions & { + bigint?: false | undefined; + }, + ): Stats; + export function fstatSync( + fd: number, + options: StatOptions & { + bigint: true; + }, + ): BigIntStats; + export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats; + /** + * Retrieves the `fs.Stats` for the symbolic link referred to by the path. + * The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic + * link, then the link itself is stat-ed, not the file that it refers to. + * + * See the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details. + * @since v0.1.30 + */ + export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + export function lstat( + path: PathLike, + options: + | (StatOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void, + ): void; + export function lstat( + path: PathLike, + options: StatOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void, + ): void; + export function lstat( + path: PathLike, + options: StatOptions | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void, + ): void; + export namespace lstat { + /** + * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__( + path: PathLike, + options?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function __promisify__( + path: PathLike, + options: StatOptions & { + bigint: true; + }, + ): Promise; + function __promisify__(path: PathLike, options?: StatOptions): Promise; + } + /** + * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which + * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * @since v19.6.0, v18.15.0 + * @param path A path to an existing file or directory on the file system to be queried. + */ + export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void; + export function statfs( + path: PathLike, + options: + | (StatFsOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void, + ): void; + export function statfs( + path: PathLike, + options: StatFsOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void, + ): void; + export function statfs( + path: PathLike, + options: StatFsOptions | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void, + ): void; + export namespace statfs { + /** + * Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an object. + * @param path A path to an existing file or directory on the file system to be queried. + */ + function __promisify__( + path: PathLike, + options?: StatFsOptions & { + bigint?: false | undefined; + }, + ): Promise; + function __promisify__( + path: PathLike, + options: StatFsOptions & { + bigint: true; + }, + ): Promise; + function __promisify__(path: PathLike, options?: StatFsOptions): Promise; + } + /** + * Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which + * contains `path`. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * @since v19.6.0, v18.15.0 + * @param path A path to an existing file or directory on the file system to be queried. + */ + export function statfsSync( + path: PathLike, + options?: StatFsOptions & { + bigint?: false | undefined; + }, + ): StatsFs; + export function statfsSync( + path: PathLike, + options: StatFsOptions & { + bigint: true; + }, + ): BigIntStatsFs; + export function statfsSync(path: PathLike, options?: StatFsOptions): StatsFs | BigIntStatsFs; + /** + * Synchronous lstat(2) - Get file status. Does not dereference symbolic links. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export const lstatSync: StatSyncFn; + /** + * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. No arguments other than + * a possible + * exception are given to the completion callback. + * @since v0.1.31 + */ + export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void; + export namespace link { + /** + * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file. + * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(existingPath: PathLike, newPath: PathLike): Promise; + } + /** + * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. Returns `undefined`. + * @since v0.1.31 + */ + export function linkSync(existingPath: PathLike, newPath: PathLike): void; + /** + * Creates the link called `path` pointing to `target`. No arguments other than a + * possible exception are given to the completion callback. + * + * See the POSIX [`symlink(2)`](http://man7.org/linux/man-pages/man2/symlink.2.html) documentation for more details. + * + * The `type` argument is only available on Windows and ignored on other platforms. + * It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is + * not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`. + * If the `target` does not exist, `'file'` will be used. Windows junction points + * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path. Junction + * points on NTFS volumes can only point to directories. + * + * Relative targets are relative to the link's parent directory. + * + * ```js + * import { symlink } from 'node:fs'; + * + * symlink('./mew', './mewtwo', callback); + * ``` + * + * The above example creates a symbolic link `mewtwo` which points to `mew` in the + * same directory: + * + * ```bash + * $ tree . + * . + * ├── mew + * └── mewtwo -> ./mew + * ``` + * @since v0.1.31 + * @param [type='null'] + */ + export function symlink( + target: PathLike, + path: PathLike, + type: symlink.Type | undefined | null, + callback: NoParamCallback, + ): void; + /** + * Asynchronous symlink(2) - Create a new symbolic link to an existing file. + * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol. + * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol. + */ + export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void; + export namespace symlink { + /** + * Asynchronous symlink(2) - Create a new symbolic link to an existing file. + * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol. + * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol. + * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). + * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. + */ + function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise; + type Type = "dir" | "file" | "junction"; + } + /** + * Returns `undefined`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link symlink}. + * @since v0.1.31 + * @param [type='null'] + */ + export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void; + /** + * Reads the contents of the symbolic link referred to by `path`. The callback gets + * two arguments `(err, linkString)`. + * + * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the link path passed to the callback. If the `encoding` is set to `'buffer'`, + * the link path returned will be passed as a `Buffer` object. + * @since v0.1.31 + */ + export function readlink( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, linkString: string) => void, + ): void; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readlink( + path: PathLike, + options: BufferEncodingOption, + callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void, + ): void; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readlink( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void, + ): void; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function readlink( + path: PathLike, + callback: (err: NodeJS.ErrnoException | null, linkString: string) => void, + ): void; + export namespace readlink { + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options?: EncodingOption): Promise; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options: BufferEncodingOption): Promise; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options?: EncodingOption): Promise; + } + /** + * Returns the symbolic link's string value. + * + * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the link path returned. If the `encoding` is set to `'buffer'`, + * the link path returned will be passed as a `Buffer` object. + * @since v0.1.31 + */ + export function readlinkSync(path: PathLike, options?: EncodingOption): string; + /** + * Synchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer; + /** + * Synchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer; + /** + * Asynchronously computes the canonical pathname by resolving `.`, `..`, and + * symbolic links. + * + * A canonical pathname is not necessarily unique. Hard links and bind mounts can + * expose a file system entity through many pathnames. + * + * This function behaves like [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html), with some exceptions: + * + * 1. No case conversion is performed on case-insensitive file systems. + * 2. The maximum number of symbolic links is platform-independent and generally + * (much) higher than what the native [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html) implementation supports. + * + * The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`to resolve relative paths. + * + * Only paths that can be converted to UTF8 strings are supported. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the path passed to the callback. If the `encoding` is set to `'buffer'`, + * the path returned will be passed as a `Buffer` object. + * + * If `path` resolves to a socket or a pipe, the function will return a system + * dependent name for that object. + * @since v0.1.31 + */ + export function realpath( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void, + ): void; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function realpath( + path: PathLike, + options: BufferEncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void, + ): void; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function realpath( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void, + ): void; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function realpath( + path: PathLike, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void, + ): void; + export namespace realpath { + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options?: EncodingOption): Promise; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options: BufferEncodingOption): Promise; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options?: EncodingOption): Promise; + /** + * Asynchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html). + * + * The `callback` gets two arguments `(err, resolvedPath)`. + * + * Only paths that can be converted to UTF8 strings are supported. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the path passed to the callback. If the `encoding` is set to `'buffer'`, + * the path returned will be passed as a `Buffer` object. + * + * On Linux, when Node.js is linked against musl libc, the procfs file system must + * be mounted on `/proc` in order for this function to work. Glibc does not have + * this restriction. + * @since v9.2.0 + */ + function native( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void, + ): void; + function native( + path: PathLike, + options: BufferEncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void, + ): void; + function native( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void, + ): void; + function native( + path: PathLike, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void, + ): void; + } + /** + * Returns the resolved pathname. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link realpath}. + * @since v0.1.31 + */ + export function realpathSync(path: PathLike, options?: EncodingOption): string; + /** + * Synchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer; + /** + * Synchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function realpathSync(path: PathLike, options?: EncodingOption): string | Buffer; + export namespace realpathSync { + function native(path: PathLike, options?: EncodingOption): string; + function native(path: PathLike, options: BufferEncodingOption): Buffer; + function native(path: PathLike, options?: EncodingOption): string | Buffer; + } + /** + * Asynchronously removes a file or symbolic link. No arguments other than a + * possible exception are given to the completion callback. + * + * ```js + * import { unlink } from 'node:fs'; + * // Assuming that 'path/file.txt' is a regular file. + * unlink('path/file.txt', (err) => { + * if (err) throw err; + * console.log('path/file.txt was deleted'); + * }); + * ``` + * + * `fs.unlink()` will not work on a directory, empty or otherwise. To remove a + * directory, use {@link rmdir}. + * + * See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more details. + * @since v0.0.2 + */ + export function unlink(path: PathLike, callback: NoParamCallback): void; + export namespace unlink { + /** + * Asynchronous unlink(2) - delete a name and possibly the file it refers to. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(path: PathLike): Promise; + } + /** + * Synchronous [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html). Returns `undefined`. + * @since v0.1.21 + */ + export function unlinkSync(path: PathLike): void; + export interface RmDirOptions { + /** + * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or + * `EPERM` error is encountered, Node.js will retry the operation with a linear + * backoff wait of `retryDelay` ms longer on each try. This option represents the + * number of retries. This option is ignored if the `recursive` option is not + * `true`. + * @default 0 + */ + maxRetries?: number | undefined; + /** + * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning + * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file. + * Use `fs.rm(path, { recursive: true, force: true })` instead. + * + * If `true`, perform a recursive directory removal. In + * recursive mode, operations are retried on failure. + * @default false + */ + recursive?: boolean | undefined; + /** + * The amount of time in milliseconds to wait between retries. + * This option is ignored if the `recursive` option is not `true`. + * @default 100 + */ + retryDelay?: number | undefined; + } + /** + * Asynchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). No arguments other than a possible exception are given + * to the completion callback. + * + * Using `fs.rmdir()` on a file (not a directory) results in an `ENOENT` error on + * Windows and an `ENOTDIR` error on POSIX. + * + * To get a behavior similar to the `rm -rf` Unix command, use {@link rm} with options `{ recursive: true, force: true }`. + * @since v0.0.2 + */ + export function rmdir(path: PathLike, callback: NoParamCallback): void; + export function rmdir(path: PathLike, options: RmDirOptions, callback: NoParamCallback): void; + export namespace rmdir { + /** + * Asynchronous rmdir(2) - delete a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(path: PathLike, options?: RmDirOptions): Promise; + } + /** + * Synchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). Returns `undefined`. + * + * Using `fs.rmdirSync()` on a file (not a directory) results in an `ENOENT` error + * on Windows and an `ENOTDIR` error on POSIX. + * + * To get a behavior similar to the `rm -rf` Unix command, use {@link rmSync} with options `{ recursive: true, force: true }`. + * @since v0.1.21 + */ + export function rmdirSync(path: PathLike, options?: RmDirOptions): void; + export interface RmOptions { + /** + * When `true`, exceptions will be ignored if `path` does not exist. + * @default false + */ + force?: boolean | undefined; + /** + * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or + * `EPERM` error is encountered, Node.js will retry the operation with a linear + * backoff wait of `retryDelay` ms longer on each try. This option represents the + * number of retries. This option is ignored if the `recursive` option is not + * `true`. + * @default 0 + */ + maxRetries?: number | undefined; + /** + * If `true`, perform a recursive directory removal. In + * recursive mode, operations are retried on failure. + * @default false + */ + recursive?: boolean | undefined; + /** + * The amount of time in milliseconds to wait between retries. + * This option is ignored if the `recursive` option is not `true`. + * @default 100 + */ + retryDelay?: number | undefined; + } + /** + * Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the + * completion callback. + * @since v14.14.0 + */ + export function rm(path: PathLike, callback: NoParamCallback): void; + export function rm(path: PathLike, options: RmOptions, callback: NoParamCallback): void; + export namespace rm { + /** + * Asynchronously removes files and directories (modeled on the standard POSIX `rm` utility). + */ + function __promisify__(path: PathLike, options?: RmOptions): Promise; + } + /** + * Synchronously removes files and directories (modeled on the standard POSIX `rm`utility). Returns `undefined`. + * @since v14.14.0 + */ + export function rmSync(path: PathLike, options?: RmOptions): void; + export interface MakeDirectoryOptions { + /** + * Indicates whether parent folders should be created. + * If a folder was created, the path to the first created folder will be returned. + * @default false + */ + recursive?: boolean | undefined; + /** + * A file mode. If a string is passed, it is parsed as an octal integer. If not specified + * @default 0o777 + */ + mode?: Mode | undefined; + } + /** + * Asynchronously creates a directory. + * + * The callback is given a possible exception and, if `recursive` is `true`, the + * first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was + * created (for instance, if it was previously created). + * + * The optional `options` argument can be an integer specifying `mode` (permission + * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that + * exists results in an error only + * when `recursive` is false. If `recursive` is false and the directory exists, + * an `EEXIST` error occurs. + * + * ```js + * import { mkdir } from 'node:fs'; + * + * // Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist. + * mkdir('./tmp/a/apple', { recursive: true }, (err) => { + * if (err) throw err; + * }); + * ``` + * + * On Windows, using `fs.mkdir()` on the root directory even with recursion will + * result in an error: + * + * ```js + * import { mkdir } from 'node:fs'; + * + * mkdir('/', { recursive: true }, (err) => { + * // => [Error: EPERM: operation not permitted, mkdir 'C:\'] + * }); + * ``` + * + * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details. + * @since v0.1.8 + */ + export function mkdir( + path: PathLike, + options: MakeDirectoryOptions & { + recursive: true; + }, + callback: (err: NodeJS.ErrnoException | null, path?: string) => void, + ): void; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + export function mkdir( + path: PathLike, + options: + | Mode + | (MakeDirectoryOptions & { + recursive?: false | undefined; + }) + | null + | undefined, + callback: NoParamCallback, + ): void; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + export function mkdir( + path: PathLike, + options: Mode | MakeDirectoryOptions | null | undefined, + callback: (err: NodeJS.ErrnoException | null, path?: string) => void, + ): void; + /** + * Asynchronous mkdir(2) - create a directory with a mode of `0o777`. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function mkdir(path: PathLike, callback: NoParamCallback): void; + export namespace mkdir { + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function __promisify__( + path: PathLike, + options: MakeDirectoryOptions & { + recursive: true; + }, + ): Promise; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function __promisify__( + path: PathLike, + options?: + | Mode + | (MakeDirectoryOptions & { + recursive?: false | undefined; + }) + | null, + ): Promise; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function __promisify__( + path: PathLike, + options?: Mode | MakeDirectoryOptions | null, + ): Promise; + } + /** + * Synchronously creates a directory. Returns `undefined`, or if `recursive` is`true`, the first directory path created. + * This is the synchronous version of {@link mkdir}. + * + * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details. + * @since v0.1.21 + */ + export function mkdirSync( + path: PathLike, + options: MakeDirectoryOptions & { + recursive: true; + }, + ): string | undefined; + /** + * Synchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + export function mkdirSync( + path: PathLike, + options?: + | Mode + | (MakeDirectoryOptions & { + recursive?: false | undefined; + }) + | null, + ): void; + /** + * Synchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined; + /** + * Creates a unique temporary directory. + * + * Generates six random characters to be appended behind a required`prefix` to create a unique temporary directory. Due to platform + * inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms, + * notably the BSDs, can return more than six random characters, and replace + * trailing `X` characters in `prefix` with random characters. + * + * The created directory path is passed as a string to the callback's second + * parameter. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use. + * + * ```js + * import { mkdtemp } from 'node:fs'; + * import { join } from 'node:path'; + * import { tmpdir } from 'node:os'; + * + * mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => { + * if (err) throw err; + * console.log(directory); + * // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2 + * }); + * ``` + * + * The `fs.mkdtemp()` method will append the six randomly selected characters + * directly to the `prefix` string. For instance, given a directory `/tmp`, if the + * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator + * (`require('node:path').sep`). + * + * ```js + * import { tmpdir } from 'node:os'; + * import { mkdtemp } from 'node:fs'; + * + * // The parent directory for the new temporary directory + * const tmpDir = tmpdir(); + * + * // This method is *INCORRECT*: + * mkdtemp(tmpDir, (err, directory) => { + * if (err) throw err; + * console.log(directory); + * // Will print something similar to `/tmpabc123`. + * // A new temporary directory is created at the file system root + * // rather than *within* the /tmp directory. + * }); + * + * // This method is *CORRECT*: + * import { sep } from 'node:path'; + * mkdtemp(`${tmpDir}${sep}`, (err, directory) => { + * if (err) throw err; + * console.log(directory); + * // Will print something similar to `/tmp/abc123`. + * // A new temporary directory is created within + * // the /tmp directory. + * }); + * ``` + * @since v5.10.0 + */ + export function mkdtemp( + prefix: string, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, folder: string) => void, + ): void; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function mkdtemp( + prefix: string, + options: + | "buffer" + | { + encoding: "buffer"; + }, + callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void, + ): void; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function mkdtemp( + prefix: string, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void, + ): void; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + */ + export function mkdtemp( + prefix: string, + callback: (err: NodeJS.ErrnoException | null, folder: string) => void, + ): void; + export namespace mkdtemp { + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(prefix: string, options?: EncodingOption): Promise; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(prefix: string, options: BufferEncodingOption): Promise; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(prefix: string, options?: EncodingOption): Promise; + } + /** + * Returns the created directory path. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link mkdtemp}. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use. + * @since v5.10.0 + */ + export function mkdtempSync(prefix: string, options?: EncodingOption): string; + /** + * Synchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer; + /** + * Synchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer; + /** + * Reads the contents of a directory. The callback gets two arguments `(err, files)`where `files` is an array of the names of the files in the directory excluding`'.'` and `'..'`. + * + * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the filenames passed to the callback. If the `encoding` is set to `'buffer'`, + * the filenames returned will be passed as `Buffer` objects. + * + * If `options.withFileTypes` is set to `true`, the `files` array will contain `fs.Dirent` objects. + * @since v0.1.8 + */ + export function readdir( + path: PathLike, + options: + | { + encoding: BufferEncoding | null; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | BufferEncoding + | undefined + | null, + callback: (err: NodeJS.ErrnoException | null, files: string[]) => void, + ): void; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readdir( + path: PathLike, + options: + | { + encoding: "buffer"; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | "buffer", + callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void, + ): void; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readdir( + path: PathLike, + options: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | undefined + | null, + callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void, + ): void; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function readdir( + path: PathLike, + callback: (err: NodeJS.ErrnoException | null, files: string[]) => void, + ): void; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options If called with `withFileTypes: true` the result data will be an array of Dirent. + */ + export function readdir( + path: PathLike, + options: ObjectEncodingOptions & { + withFileTypes: true; + recursive?: boolean | undefined; + }, + callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void, + ): void; + export namespace readdir { + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__( + path: PathLike, + options?: + | { + encoding: BufferEncoding | null; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__( + path: PathLike, + options: + | "buffer" + | { + encoding: "buffer"; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__( + path: PathLike, + options?: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options If called with `withFileTypes: true` the result data will be an array of Dirent + */ + function __promisify__( + path: PathLike, + options: ObjectEncodingOptions & { + withFileTypes: true; + recursive?: boolean | undefined; + }, + ): Promise; + } + /** + * Reads the contents of the directory. + * + * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the filenames returned. If the `encoding` is set to `'buffer'`, + * the filenames returned will be passed as `Buffer` objects. + * + * If `options.withFileTypes` is set to `true`, the result will contain `fs.Dirent` objects. + * @since v0.1.21 + */ + export function readdirSync( + path: PathLike, + options?: + | { + encoding: BufferEncoding | null; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | BufferEncoding + | null, + ): string[]; + /** + * Synchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readdirSync( + path: PathLike, + options: + | { + encoding: "buffer"; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | "buffer", + ): Buffer[]; + /** + * Synchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readdirSync( + path: PathLike, + options?: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | null, + ): string[] | Buffer[]; + /** + * Synchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options If called with `withFileTypes: true` the result data will be an array of Dirent. + */ + export function readdirSync( + path: PathLike, + options: ObjectEncodingOptions & { + withFileTypes: true; + recursive?: boolean | undefined; + }, + ): Dirent[]; + /** + * Closes the file descriptor. No arguments other than a possible exception are + * given to the completion callback. + * + * Calling `fs.close()` on any file descriptor (`fd`) that is currently in use + * through any other `fs` operation may lead to undefined behavior. + * + * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail. + * @since v0.0.2 + */ + export function close(fd: number, callback?: NoParamCallback): void; + export namespace close { + /** + * Asynchronous close(2) - close a file descriptor. + * @param fd A file descriptor. + */ + function __promisify__(fd: number): Promise; + } + /** + * Closes the file descriptor. Returns `undefined`. + * + * Calling `fs.closeSync()` on any file descriptor (`fd`) that is currently in use + * through any other `fs` operation may lead to undefined behavior. + * + * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail. + * @since v0.1.21 + */ + export function closeSync(fd: number): void; + /** + * Asynchronous file open. See the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more details. + * + * `mode` sets the file mode (permission and sticky bits), but only if the file was + * created. On Windows, only the write permission can be manipulated; see {@link chmod}. + * + * The callback gets two arguments `(err, fd)`. + * + * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented + * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains + * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams). + * + * Functions based on `fs.open()` exhibit this behavior as well:`fs.writeFile()`, `fs.readFile()`, etc. + * @since v0.0.2 + * @param [flags='r'] See `support of file system `flags``. + * @param [mode=0o666] + */ + export function open( + path: PathLike, + flags: OpenMode | undefined, + mode: Mode | undefined | null, + callback: (err: NodeJS.ErrnoException | null, fd: number) => void, + ): void; + /** + * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param [flags='r'] See `support of file system `flags``. + */ + export function open( + path: PathLike, + flags: OpenMode | undefined, + callback: (err: NodeJS.ErrnoException | null, fd: number) => void, + ): void; + /** + * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; + export namespace open { + /** + * Asynchronous open(2) - open and possibly create a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`. + */ + function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise; + } + /** + * Returns an integer representing the file descriptor. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link open}. + * @since v0.1.21 + * @param [flags='r'] + * @param [mode=0o666] + */ + export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number; + /** + * Change the file system timestamps of the object referenced by `path`. + * + * The `atime` and `mtime` arguments follow these rules: + * + * * Values can be either numbers representing Unix epoch time in seconds,`Date`s, or a numeric string like `'123456789.0'`. + * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown. + * @since v0.4.2 + */ + export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void; + export namespace utimes { + /** + * Asynchronously change file timestamps of the file referenced by the supplied path. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param atime The last access time. If a string is provided, it will be coerced to number. + * @param mtime The last modified time. If a string is provided, it will be coerced to number. + */ + function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise; + } + /** + * Returns `undefined`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link utimes}. + * @since v0.4.2 + */ + export function utimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void; + /** + * Change the file system timestamps of the object referenced by the supplied file + * descriptor. See {@link utimes}. + * @since v0.4.2 + */ + export function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void; + export namespace futimes { + /** + * Asynchronously change file timestamps of the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param atime The last access time. If a string is provided, it will be coerced to number. + * @param mtime The last modified time. If a string is provided, it will be coerced to number. + */ + function __promisify__(fd: number, atime: TimeLike, mtime: TimeLike): Promise; + } + /** + * Synchronous version of {@link futimes}. Returns `undefined`. + * @since v0.4.2 + */ + export function futimesSync(fd: number, atime: TimeLike, mtime: TimeLike): void; + /** + * Request that all data for the open file descriptor is flushed to the storage + * device. The specific implementation is operating system and device specific. + * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. No arguments other + * than a possible exception are given to the completion callback. + * @since v0.1.96 + */ + export function fsync(fd: number, callback: NoParamCallback): void; + export namespace fsync { + /** + * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device. + * @param fd A file descriptor. + */ + function __promisify__(fd: number): Promise; + } + /** + * Request that all data for the open file descriptor is flushed to the storage + * device. The specific implementation is operating system and device specific. + * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. Returns `undefined`. + * @since v0.1.96 + */ + export function fsyncSync(fd: number): void; + /** + * Write `buffer` to the file specified by `fd`. + * + * `offset` determines the part of the buffer to be written, and `length` is + * an integer specifying the number of bytes to write. + * + * `position` refers to the offset from the beginning of the file where this data + * should be written. If `typeof position !== 'number'`, the data will be written + * at the current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html). + * + * The callback will be given three arguments `(err, bytesWritten, buffer)` where`bytesWritten` specifies how many _bytes_ were written from `buffer`. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a promise for an `Object` with `bytesWritten` and `buffer` properties. + * + * It is unsafe to use `fs.write()` multiple times on the same file without waiting + * for the callback. For this scenario, {@link createWriteStream} is + * recommended. + * + * On Linux, positional writes don't work when the file is opened in append mode. + * The kernel ignores the position argument and always appends the data to + * the end of the file. + * @since v0.0.2 + * @param [offset=0] + * @param [length=buffer.byteLength - offset] + * @param [position='null'] + */ + export function write( + fd: number, + buffer: TBuffer, + offset: number | undefined | null, + length: number | undefined | null, + position: number | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, + ): void; + /** + * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param offset The part of the buffer to be written. If not supplied, defaults to `0`. + * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`. + */ + export function write( + fd: number, + buffer: TBuffer, + offset: number | undefined | null, + length: number | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, + ): void; + /** + * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param offset The part of the buffer to be written. If not supplied, defaults to `0`. + */ + export function write( + fd: number, + buffer: TBuffer, + offset: number | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, + ): void; + /** + * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + */ + export function write( + fd: number, + buffer: TBuffer, + callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, + ): void; + /** + * Asynchronously writes `string` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param string A string to write. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + * @param encoding The expected string encoding. + */ + export function write( + fd: number, + string: string, + position: number | undefined | null, + encoding: BufferEncoding | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void, + ): void; + /** + * Asynchronously writes `string` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param string A string to write. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + */ + export function write( + fd: number, + string: string, + position: number | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void, + ): void; + /** + * Asynchronously writes `string` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param string A string to write. + */ + export function write( + fd: number, + string: string, + callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void, + ): void; + export namespace write { + /** + * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param offset The part of the buffer to be written. If not supplied, defaults to `0`. + * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + */ + function __promisify__( + fd: number, + buffer?: TBuffer, + offset?: number, + length?: number, + position?: number | null, + ): Promise<{ + bytesWritten: number; + buffer: TBuffer; + }>; + /** + * Asynchronously writes `string` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param string A string to write. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + * @param encoding The expected string encoding. + */ + function __promisify__( + fd: number, + string: string, + position?: number | null, + encoding?: BufferEncoding | null, + ): Promise<{ + bytesWritten: number; + buffer: string; + }>; + } + /** + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link write}. + * @since v0.1.21 + * @param [offset=0] + * @param [length=buffer.byteLength - offset] + * @param [position='null'] + * @return The number of bytes written. + */ + export function writeSync( + fd: number, + buffer: NodeJS.ArrayBufferView, + offset?: number | null, + length?: number | null, + position?: number | null, + ): number; + /** + * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written. + * @param fd A file descriptor. + * @param string A string to write. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + * @param encoding The expected string encoding. + */ + export function writeSync( + fd: number, + string: string, + position?: number | null, + encoding?: BufferEncoding | null, + ): number; + export type ReadPosition = number | bigint; + export interface ReadSyncOptions { + /** + * @default 0 + */ + offset?: number | undefined; + /** + * @default `length of buffer` + */ + length?: number | undefined; + /** + * @default null + */ + position?: ReadPosition | null | undefined; + } + export interface ReadAsyncOptions extends ReadSyncOptions { + buffer?: TBuffer; + } + /** + * Read data from the file specified by `fd`. + * + * The callback is given the three arguments, `(err, bytesRead, buffer)`. + * + * If the file is not modified concurrently, the end-of-file is reached when the + * number of bytes read is zero. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a promise for an `Object` with `bytesRead` and `buffer` properties. + * @since v0.0.2 + * @param buffer The buffer that the data will be written to. + * @param offset The position in `buffer` to write the data to. + * @param length The number of bytes to read. + * @param position Specifies where to begin reading from in the file. If `position` is `null` or `-1 `, data will be read from the current file position, and the file position will be updated. If + * `position` is an integer, the file position will be unchanged. + */ + export function read( + fd: number, + buffer: TBuffer, + offset: number, + length: number, + position: ReadPosition | null, + callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void, + ): void; + /** + * Similar to the above `fs.read` function, this version takes an optional `options` object. + * If not otherwise specified in an `options` object, + * `buffer` defaults to `Buffer.alloc(16384)`, + * `offset` defaults to `0`, + * `length` defaults to `buffer.byteLength`, `- offset` as of Node 17.6.0 + * `position` defaults to `null` + * @since v12.17.0, 13.11.0 + */ + export function read( + fd: number, + options: ReadAsyncOptions, + callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void, + ): void; + export function read( + fd: number, + callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void, + ): void; + export namespace read { + /** + * @param fd A file descriptor. + * @param buffer The buffer that the data will be written to. + * @param offset The offset in the buffer at which to start writing. + * @param length The number of bytes to read. + * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position. + */ + function __promisify__( + fd: number, + buffer: TBuffer, + offset: number, + length: number, + position: number | null, + ): Promise<{ + bytesRead: number; + buffer: TBuffer; + }>; + function __promisify__( + fd: number, + options: ReadAsyncOptions, + ): Promise<{ + bytesRead: number; + buffer: TBuffer; + }>; + function __promisify__(fd: number): Promise<{ + bytesRead: number; + buffer: NodeJS.ArrayBufferView; + }>; + } + /** + * Returns the number of `bytesRead`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link read}. + * @since v0.1.21 + * @param [position='null'] + */ + export function readSync( + fd: number, + buffer: NodeJS.ArrayBufferView, + offset: number, + length: number, + position: ReadPosition | null, + ): number; + /** + * Similar to the above `fs.readSync` function, this version takes an optional `options` object. + * If no `options` object is specified, it will default with the above values. + */ + export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number; + /** + * Asynchronously reads the entire contents of a file. + * + * ```js + * import { readFile } from 'node:fs'; + * + * readFile('/etc/passwd', (err, data) => { + * if (err) throw err; + * console.log(data); + * }); + * ``` + * + * The callback is passed two arguments `(err, data)`, where `data` is the + * contents of the file. + * + * If no encoding is specified, then the raw buffer is returned. + * + * If `options` is a string, then it specifies the encoding: + * + * ```js + * import { readFile } from 'node:fs'; + * + * readFile('/etc/passwd', 'utf8', callback); + * ``` + * + * When the path is a directory, the behavior of `fs.readFile()` and {@link readFileSync} is platform-specific. On macOS, Linux, and Windows, an + * error will be returned. On FreeBSD, a representation of the directory's contents + * will be returned. + * + * ```js + * import { readFile } from 'node:fs'; + * + * // macOS, Linux, and Windows + * readFile('', (err, data) => { + * // => [Error: EISDIR: illegal operation on a directory, read ] + * }); + * + * // FreeBSD + * readFile('', (err, data) => { + * // => null, + * }); + * ``` + * + * It is possible to abort an ongoing request using an `AbortSignal`. If a + * request is aborted the callback is called with an `AbortError`: + * + * ```js + * import { readFile } from 'node:fs'; + * + * const controller = new AbortController(); + * const signal = controller.signal; + * readFile(fileInfo[0].name, { signal }, (err, buf) => { + * // ... + * }); + * // When you want to abort the request + * controller.abort(); + * ``` + * + * The `fs.readFile()` function buffers the entire file. To minimize memory costs, + * when possible prefer streaming via `fs.createReadStream()`. + * + * Aborting an ongoing request does not abort individual operating + * system requests but rather the internal buffering `fs.readFile` performs. + * @since v0.1.29 + * @param path filename or file descriptor + */ + export function readFile( + path: PathOrFileDescriptor, + options: + | ({ + encoding?: null | undefined; + flag?: string | undefined; + } & Abortable) + | undefined + | null, + callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void, + ): void; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + export function readFile( + path: PathOrFileDescriptor, + options: + | ({ + encoding: BufferEncoding; + flag?: string | undefined; + } & Abortable) + | BufferEncoding, + callback: (err: NodeJS.ErrnoException | null, data: string) => void, + ): void; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + export function readFile( + path: PathOrFileDescriptor, + options: + | (ObjectEncodingOptions & { + flag?: string | undefined; + } & Abortable) + | BufferEncoding + | undefined + | null, + callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void, + ): void; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + */ + export function readFile( + path: PathOrFileDescriptor, + callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void, + ): void; + export namespace readFile { + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function __promisify__( + path: PathOrFileDescriptor, + options?: { + encoding?: null | undefined; + flag?: string | undefined; + } | null, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function __promisify__( + path: PathOrFileDescriptor, + options: + | { + encoding: BufferEncoding; + flag?: string | undefined; + } + | BufferEncoding, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function __promisify__( + path: PathOrFileDescriptor, + options?: + | (ObjectEncodingOptions & { + flag?: string | undefined; + }) + | BufferEncoding + | null, + ): Promise; + } + /** + * Returns the contents of the `path`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link readFile}. + * + * If the `encoding` option is specified then this function returns a + * string. Otherwise it returns a buffer. + * + * Similar to {@link readFile}, when the path is a directory, the behavior of`fs.readFileSync()` is platform-specific. + * + * ```js + * import { readFileSync } from 'node:fs'; + * + * // macOS, Linux, and Windows + * readFileSync(''); + * // => [Error: EISDIR: illegal operation on a directory, read ] + * + * // FreeBSD + * readFileSync(''); // => + * ``` + * @since v0.1.8 + * @param path filename or file descriptor + */ + export function readFileSync( + path: PathOrFileDescriptor, + options?: { + encoding?: null | undefined; + flag?: string | undefined; + } | null, + ): Buffer; + /** + * Synchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + export function readFileSync( + path: PathOrFileDescriptor, + options: + | { + encoding: BufferEncoding; + flag?: string | undefined; + } + | BufferEncoding, + ): string; + /** + * Synchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + export function readFileSync( + path: PathOrFileDescriptor, + options?: + | (ObjectEncodingOptions & { + flag?: string | undefined; + }) + | BufferEncoding + | null, + ): string | Buffer; + export type WriteFileOptions = + | ( + & ObjectEncodingOptions + & Abortable + & { + mode?: Mode | undefined; + flag?: string | undefined; + flush?: boolean | undefined; + } + ) + | BufferEncoding + | null; + /** + * When `file` is a filename, asynchronously writes data to the file, replacing the + * file if it already exists. `data` can be a string or a buffer. + * + * When `file` is a file descriptor, the behavior is similar to calling`fs.write()` directly (which is recommended). See the notes below on using + * a file descriptor. + * + * The `encoding` option is ignored if `data` is a buffer. + * + * The `mode` option only affects the newly created file. See {@link open} for more details. + * + * ```js + * import { writeFile } from 'node:fs'; + * import { Buffer } from 'node:buffer'; + * + * const data = new Uint8Array(Buffer.from('Hello Node.js')); + * writeFile('message.txt', data, (err) => { + * if (err) throw err; + * console.log('The file has been saved!'); + * }); + * ``` + * + * If `options` is a string, then it specifies the encoding: + * + * ```js + * import { writeFile } from 'node:fs'; + * + * writeFile('message.txt', 'Hello Node.js', 'utf8', callback); + * ``` + * + * It is unsafe to use `fs.writeFile()` multiple times on the same file without + * waiting for the callback. For this scenario, {@link createWriteStream} is + * recommended. + * + * Similarly to `fs.readFile` \- `fs.writeFile` is a convenience method that + * performs multiple `write` calls internally to write the buffer passed to it. + * For performance sensitive code consider using {@link createWriteStream}. + * + * It is possible to use an `AbortSignal` to cancel an `fs.writeFile()`. + * Cancelation is "best effort", and some amount of data is likely still + * to be written. + * + * ```js + * import { writeFile } from 'node:fs'; + * import { Buffer } from 'node:buffer'; + * + * const controller = new AbortController(); + * const { signal } = controller; + * const data = new Uint8Array(Buffer.from('Hello Node.js')); + * writeFile('message.txt', data, { signal }, (err) => { + * // When a request is aborted - the callback is called with an AbortError + * }); + * // When the request should be aborted + * controller.abort(); + * ``` + * + * Aborting an ongoing request does not abort individual operating + * system requests but rather the internal buffering `fs.writeFile` performs. + * @since v0.1.29 + * @param file filename or file descriptor + */ + export function writeFile( + file: PathOrFileDescriptor, + data: string | NodeJS.ArrayBufferView, + options: WriteFileOptions, + callback: NoParamCallback, + ): void; + /** + * Asynchronously writes data to a file, replacing the file if it already exists. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. + */ + export function writeFile( + path: PathOrFileDescriptor, + data: string | NodeJS.ArrayBufferView, + callback: NoParamCallback, + ): void; + export namespace writeFile { + /** + * Asynchronously writes data to a file, replacing the file if it already exists. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. + * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `mode` is not supplied, the default of `0o666` is used. + * If `mode` is a string, it is parsed as an octal integer. + * If `flag` is not supplied, the default of `'w'` is used. + */ + function __promisify__( + path: PathOrFileDescriptor, + data: string | NodeJS.ArrayBufferView, + options?: WriteFileOptions, + ): Promise; + } + /** + * Returns `undefined`. + * + * The `mode` option only affects the newly created file. See {@link open} for more details. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link writeFile}. + * @since v0.1.29 + * @param file filename or file descriptor + */ + export function writeFileSync( + file: PathOrFileDescriptor, + data: string | NodeJS.ArrayBufferView, + options?: WriteFileOptions, + ): void; + /** + * Asynchronously append data to a file, creating the file if it does not yet + * exist. `data` can be a string or a `Buffer`. + * + * The `mode` option only affects the newly created file. See {@link open} for more details. + * + * ```js + * import { appendFile } from 'node:fs'; + * + * appendFile('message.txt', 'data to append', (err) => { + * if (err) throw err; + * console.log('The "data to append" was appended to file!'); + * }); + * ``` + * + * If `options` is a string, then it specifies the encoding: + * + * ```js + * import { appendFile } from 'node:fs'; + * + * appendFile('message.txt', 'data to append', 'utf8', callback); + * ``` + * + * The `path` may be specified as a numeric file descriptor that has been opened + * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will + * not be closed automatically. + * + * ```js + * import { open, close, appendFile } from 'node:fs'; + * + * function closeFd(fd) { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * + * open('message.txt', 'a', (err, fd) => { + * if (err) throw err; + * + * try { + * appendFile(fd, 'data to append', 'utf8', (err) => { + * closeFd(fd); + * if (err) throw err; + * }); + * } catch (err) { + * closeFd(fd); + * throw err; + * } + * }); + * ``` + * @since v0.6.7 + * @param path filename or file descriptor + */ + export function appendFile( + path: PathOrFileDescriptor, + data: string | Uint8Array, + options: WriteFileOptions, + callback: NoParamCallback, + ): void; + /** + * Asynchronously append data to a file, creating the file if it does not exist. + * @param file A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. + */ + export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void; + export namespace appendFile { + /** + * Asynchronously append data to a file, creating the file if it does not exist. + * @param file A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. + * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `mode` is not supplied, the default of `0o666` is used. + * If `mode` is a string, it is parsed as an octal integer. + * If `flag` is not supplied, the default of `'a'` is used. + */ + function __promisify__( + file: PathOrFileDescriptor, + data: string | Uint8Array, + options?: WriteFileOptions, + ): Promise; + } + /** + * Synchronously append data to a file, creating the file if it does not yet + * exist. `data` can be a string or a `Buffer`. + * + * The `mode` option only affects the newly created file. See {@link open} for more details. + * + * ```js + * import { appendFileSync } from 'node:fs'; + * + * try { + * appendFileSync('message.txt', 'data to append'); + * console.log('The "data to append" was appended to file!'); + * } catch (err) { + * // Handle the error + * } + * ``` + * + * If `options` is a string, then it specifies the encoding: + * + * ```js + * import { appendFileSync } from 'node:fs'; + * + * appendFileSync('message.txt', 'data to append', 'utf8'); + * ``` + * + * The `path` may be specified as a numeric file descriptor that has been opened + * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will + * not be closed automatically. + * + * ```js + * import { openSync, closeSync, appendFileSync } from 'node:fs'; + * + * let fd; + * + * try { + * fd = openSync('message.txt', 'a'); + * appendFileSync(fd, 'data to append', 'utf8'); + * } catch (err) { + * // Handle the error + * } finally { + * if (fd !== undefined) + * closeSync(fd); + * } + * ``` + * @since v0.6.7 + * @param path filename or file descriptor + */ + export function appendFileSync( + path: PathOrFileDescriptor, + data: string | Uint8Array, + options?: WriteFileOptions, + ): void; + /** + * Watch for changes on `filename`. The callback `listener` will be called each + * time the file is accessed. + * + * The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates + * whether the process should continue to run as long as files are being watched. + * The `options` object may specify an `interval` property indicating how often the + * target should be polled in milliseconds. + * + * The `listener` gets two arguments the current stat object and the previous + * stat object: + * + * ```js + * import { watchFile } from 'fs'; + * + * watchFile('message.text', (curr, prev) => { + * console.log(`the current mtime is: ${curr.mtime}`); + * console.log(`the previous mtime was: ${prev.mtime}`); + * }); + * ``` + * + * These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`, + * the numeric values in these objects are specified as `BigInt`s. + * + * To be notified when the file was modified, not just accessed, it is necessary + * to compare `curr.mtimeMs` and `prev.mtimeMs`. + * + * When an `fs.watchFile` operation results in an `ENOENT` error, it + * will invoke the listener once, with all the fields zeroed (or, for dates, the + * Unix Epoch). If the file is created later on, the listener will be called + * again, with the latest stat objects. This is a change in functionality since + * v0.10. + * + * Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible. + * + * When a file being watched by `fs.watchFile()` disappears and reappears, + * then the contents of `previous` in the second callback event (the file's + * reappearance) will be the same as the contents of `previous` in the first + * callback event (its disappearance). + * + * This happens when: + * + * * the file is deleted, followed by a restore + * * the file is renamed and then renamed a second time back to its original name + * @since v0.1.31 + */ + export interface WatchFileOptions { + bigint?: boolean | undefined; + persistent?: boolean | undefined; + interval?: number | undefined; + } + /** + * Watch for changes on `filename`. The callback `listener` will be called each + * time the file is accessed. + * + * The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates + * whether the process should continue to run as long as files are being watched. + * The `options` object may specify an `interval` property indicating how often the + * target should be polled in milliseconds. + * + * The `listener` gets two arguments the current stat object and the previous + * stat object: + * + * ```js + * import { watchFile } from 'node:fs'; + * + * watchFile('message.text', (curr, prev) => { + * console.log(`the current mtime is: ${curr.mtime}`); + * console.log(`the previous mtime was: ${prev.mtime}`); + * }); + * ``` + * + * These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`, + * the numeric values in these objects are specified as `BigInt`s. + * + * To be notified when the file was modified, not just accessed, it is necessary + * to compare `curr.mtimeMs` and `prev.mtimeMs`. + * + * When an `fs.watchFile` operation results in an `ENOENT` error, it + * will invoke the listener once, with all the fields zeroed (or, for dates, the + * Unix Epoch). If the file is created later on, the listener will be called + * again, with the latest stat objects. This is a change in functionality since + * v0.10. + * + * Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible. + * + * When a file being watched by `fs.watchFile()` disappears and reappears, + * then the contents of `previous` in the second callback event (the file's + * reappearance) will be the same as the contents of `previous` in the first + * callback event (its disappearance). + * + * This happens when: + * + * * the file is deleted, followed by a restore + * * the file is renamed and then renamed a second time back to its original name + * @since v0.1.31 + */ + export function watchFile( + filename: PathLike, + options: + | (WatchFileOptions & { + bigint?: false | undefined; + }) + | undefined, + listener: StatsListener, + ): StatWatcher; + export function watchFile( + filename: PathLike, + options: + | (WatchFileOptions & { + bigint: true; + }) + | undefined, + listener: BigIntStatsListener, + ): StatWatcher; + /** + * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + export function watchFile(filename: PathLike, listener: StatsListener): StatWatcher; + /** + * Stop watching for changes on `filename`. If `listener` is specified, only that + * particular listener is removed. Otherwise, _all_ listeners are removed, + * effectively stopping watching of `filename`. + * + * Calling `fs.unwatchFile()` with a filename that is not being watched is a + * no-op, not an error. + * + * Using {@link watch} is more efficient than `fs.watchFile()` and`fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()`and `fs.unwatchFile()` when possible. + * @since v0.1.31 + * @param listener Optional, a listener previously attached using `fs.watchFile()` + */ + export function unwatchFile(filename: PathLike, listener?: StatsListener): void; + export function unwatchFile(filename: PathLike, listener?: BigIntStatsListener): void; + export interface WatchOptions extends Abortable { + encoding?: BufferEncoding | "buffer" | undefined; + persistent?: boolean | undefined; + recursive?: boolean | undefined; + } + export type WatchEventType = "rename" | "change"; + export type WatchListener = (event: WatchEventType, filename: T | null) => void; + export type StatsListener = (curr: Stats, prev: Stats) => void; + export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void; + /** + * Watch for changes on `filename`, where `filename` is either a file or a + * directory. + * + * The second argument is optional. If `options` is provided as a string, it + * specifies the `encoding`. Otherwise `options` should be passed as an object. + * + * The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'` or `'change'`, and `filename` is the name of the file + * which triggered the event. + * + * On most platforms, `'rename'` is emitted whenever a filename appears or + * disappears in the directory. + * + * The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`. + * + * If a `signal` is passed, aborting the corresponding AbortController will close + * the returned `fs.FSWatcher`. + * @since v0.5.10 + * @param listener + */ + export function watch( + filename: PathLike, + options: + | (WatchOptions & { + encoding: "buffer"; + }) + | "buffer", + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + export function watch( + filename: PathLike, + options?: WatchOptions | BufferEncoding | null, + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + export function watch( + filename: PathLike, + options: WatchOptions | string, + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + export function watch(filename: PathLike, listener?: WatchListener): FSWatcher; + /** + * Test whether or not the given path exists by checking with the file system. + * Then call the `callback` argument with either true or false: + * + * ```js + * import { exists } from 'node:fs'; + * + * exists('/etc/passwd', (e) => { + * console.log(e ? 'it exists' : 'no passwd!'); + * }); + * ``` + * + * **The parameters for this callback are not consistent with other Node.js** + * **callbacks.** Normally, the first parameter to a Node.js callback is an `err`parameter, optionally followed by other parameters. The `fs.exists()` callback + * has only one boolean parameter. This is one reason `fs.access()` is recommended + * instead of `fs.exists()`. + * + * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing + * so introduces a race condition, since other processes may change the file's + * state between the two calls. Instead, user code should open/read/write the + * file directly and handle the error raised if the file does not exist. + * + * **write (NOT RECOMMENDED)** + * + * ```js + * import { exists, open, close } from 'node:fs'; + * + * exists('myfile', (e) => { + * if (e) { + * console.error('myfile already exists'); + * } else { + * open('myfile', 'wx', (err, fd) => { + * if (err) throw err; + * + * try { + * writeMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * } + * }); + * ``` + * + * **write (RECOMMENDED)** + * + * ```js + * import { open, close } from 'node:fs'; + * open('myfile', 'wx', (err, fd) => { + * if (err) { + * if (err.code === 'EEXIST') { + * console.error('myfile already exists'); + * return; + * } + * + * throw err; + * } + * + * try { + * writeMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * ``` + * + * **read (NOT RECOMMENDED)** + * + * ```js + * import { open, close, exists } from 'node:fs'; + * + * exists('myfile', (e) => { + * if (e) { + * open('myfile', 'r', (err, fd) => { + * if (err) throw err; + * + * try { + * readMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * } else { + * console.error('myfile does not exist'); + * } + * }); + * ``` + * + * **read (RECOMMENDED)** + * + * ```js + * import { open, close } from 'node:fs'; + * + * open('myfile', 'r', (err, fd) => { + * if (err) { + * if (err.code === 'ENOENT') { + * console.error('myfile does not exist'); + * return; + * } + * + * throw err; + * } + * + * try { + * readMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * ``` + * + * The "not recommended" examples above check for existence and then use the + * file; the "recommended" examples are better because they use the file directly + * and handle the error, if any. + * + * In general, check for the existence of a file only if the file won't be + * used directly, for example when its existence is a signal from another + * process. + * @since v0.0.2 + * @deprecated Since v1.0.0 - Use {@link stat} or {@link access} instead. + */ + export function exists(path: PathLike, callback: (exists: boolean) => void): void; + /** @deprecated */ + export namespace exists { + /** + * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + */ + function __promisify__(path: PathLike): Promise; + } + /** + * Returns `true` if the path exists, `false` otherwise. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link exists}. + * + * `fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback`parameter to `fs.exists()` accepts parameters that are inconsistent with other + * Node.js callbacks. `fs.existsSync()` does not use a callback. + * + * ```js + * import { existsSync } from 'node:fs'; + * + * if (existsSync('/etc/passwd')) + * console.log('The path exists.'); + * ``` + * @since v0.1.21 + */ + export function existsSync(path: PathLike): boolean; + export namespace constants { + // File Access Constants + /** Constant for fs.access(). File is visible to the calling process. */ + const F_OK: number; + /** Constant for fs.access(). File can be read by the calling process. */ + const R_OK: number; + /** Constant for fs.access(). File can be written by the calling process. */ + const W_OK: number; + /** Constant for fs.access(). File can be executed by the calling process. */ + const X_OK: number; + // File Copy Constants + /** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */ + const COPYFILE_EXCL: number; + /** + * Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink. + * If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used. + */ + const COPYFILE_FICLONE: number; + /** + * Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink. + * If the underlying platform does not support copy-on-write, then the operation will fail with an error. + */ + const COPYFILE_FICLONE_FORCE: number; + // File Open Constants + /** Constant for fs.open(). Flag indicating to open a file for read-only access. */ + const O_RDONLY: number; + /** Constant for fs.open(). Flag indicating to open a file for write-only access. */ + const O_WRONLY: number; + /** Constant for fs.open(). Flag indicating to open a file for read-write access. */ + const O_RDWR: number; + /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */ + const O_CREAT: number; + /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */ + const O_EXCL: number; + /** + * Constant for fs.open(). Flag indicating that if path identifies a terminal device, + * opening the path shall not cause that terminal to become the controlling terminal for the process + * (if the process does not already have one). + */ + const O_NOCTTY: number; + /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */ + const O_TRUNC: number; + /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */ + const O_APPEND: number; + /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */ + const O_DIRECTORY: number; + /** + * constant for fs.open(). + * Flag indicating reading accesses to the file system will no longer result in + * an update to the atime information associated with the file. + * This flag is available on Linux operating systems only. + */ + const O_NOATIME: number; + /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */ + const O_NOFOLLOW: number; + /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */ + const O_SYNC: number; + /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */ + const O_DSYNC: number; + /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */ + const O_SYMLINK: number; + /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */ + const O_DIRECT: number; + /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */ + const O_NONBLOCK: number; + // File Type Constants + /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */ + const S_IFMT: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */ + const S_IFREG: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */ + const S_IFDIR: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */ + const S_IFCHR: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */ + const S_IFBLK: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */ + const S_IFIFO: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */ + const S_IFLNK: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */ + const S_IFSOCK: number; + // File Mode Constants + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */ + const S_IRWXU: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */ + const S_IRUSR: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */ + const S_IWUSR: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */ + const S_IXUSR: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */ + const S_IRWXG: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */ + const S_IRGRP: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */ + const S_IWGRP: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */ + const S_IXGRP: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */ + const S_IRWXO: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */ + const S_IROTH: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */ + const S_IWOTH: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */ + const S_IXOTH: number; + /** + * When set, a memory file mapping is used to access the file. This flag + * is available on Windows operating systems only. On other operating systems, + * this flag is ignored. + */ + const UV_FS_O_FILEMAP: number; + } + /** + * Tests a user's permissions for the file or directory specified by `path`. + * The `mode` argument is an optional integer that specifies the accessibility + * checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK` + * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for + * possible values of `mode`. + * + * The final argument, `callback`, is a callback function that is invoked with + * a possible error argument. If any of the accessibility checks fail, the error + * argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable. + * + * ```js + * import { access, constants } from 'node:fs'; + * + * const file = 'package.json'; + * + * // Check if the file exists in the current directory. + * access(file, constants.F_OK, (err) => { + * console.log(`${file} ${err ? 'does not exist' : 'exists'}`); + * }); + * + * // Check if the file is readable. + * access(file, constants.R_OK, (err) => { + * console.log(`${file} ${err ? 'is not readable' : 'is readable'}`); + * }); + * + * // Check if the file is writable. + * access(file, constants.W_OK, (err) => { + * console.log(`${file} ${err ? 'is not writable' : 'is writable'}`); + * }); + * + * // Check if the file is readable and writable. + * access(file, constants.R_OK | constants.W_OK, (err) => { + * console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`); + * }); + * ``` + * + * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing + * so introduces a race condition, since other processes may change the file's + * state between the two calls. Instead, user code should open/read/write the + * file directly and handle the error raised if the file is not accessible. + * + * **write (NOT RECOMMENDED)** + * + * ```js + * import { access, open, close } from 'node:fs'; + * + * access('myfile', (err) => { + * if (!err) { + * console.error('myfile already exists'); + * return; + * } + * + * open('myfile', 'wx', (err, fd) => { + * if (err) throw err; + * + * try { + * writeMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * }); + * ``` + * + * **write (RECOMMENDED)** + * + * ```js + * import { open, close } from 'node:fs'; + * + * open('myfile', 'wx', (err, fd) => { + * if (err) { + * if (err.code === 'EEXIST') { + * console.error('myfile already exists'); + * return; + * } + * + * throw err; + * } + * + * try { + * writeMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * ``` + * + * **read (NOT RECOMMENDED)** + * + * ```js + * import { access, open, close } from 'node:fs'; + * access('myfile', (err) => { + * if (err) { + * if (err.code === 'ENOENT') { + * console.error('myfile does not exist'); + * return; + * } + * + * throw err; + * } + * + * open('myfile', 'r', (err, fd) => { + * if (err) throw err; + * + * try { + * readMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * }); + * ``` + * + * **read (RECOMMENDED)** + * + * ```js + * import { open, close } from 'node:fs'; + * + * open('myfile', 'r', (err, fd) => { + * if (err) { + * if (err.code === 'ENOENT') { + * console.error('myfile does not exist'); + * return; + * } + * + * throw err; + * } + * + * try { + * readMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * ``` + * + * The "not recommended" examples above check for accessibility and then use the + * file; the "recommended" examples are better because they use the file directly + * and handle the error, if any. + * + * In general, check for the accessibility of a file only if the file will not be + * used directly, for example when its accessibility is a signal from another + * process. + * + * On Windows, access-control policies (ACLs) on a directory may limit access to + * a file or directory. The `fs.access()` function, however, does not check the + * ACL and therefore may report that a path is accessible even if the ACL restricts + * the user from reading or writing to it. + * @since v0.11.15 + * @param [mode=fs.constants.F_OK] + */ + export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void; + /** + * Asynchronously tests a user's permissions for the file specified by path. + * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + export function access(path: PathLike, callback: NoParamCallback): void; + export namespace access { + /** + * Asynchronously tests a user's permissions for the file specified by path. + * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + */ + function __promisify__(path: PathLike, mode?: number): Promise; + } + /** + * Synchronously tests a user's permissions for the file or directory specified + * by `path`. The `mode` argument is an optional integer that specifies the + * accessibility checks to be performed. `mode` should be either the value`fs.constants.F_OK` or a mask consisting of the bitwise OR of any of`fs.constants.R_OK`, `fs.constants.W_OK`, and + * `fs.constants.X_OK` (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for + * possible values of `mode`. + * + * If any of the accessibility checks fail, an `Error` will be thrown. Otherwise, + * the method will return `undefined`. + * + * ```js + * import { accessSync, constants } from 'node:fs'; + * + * try { + * accessSync('etc/passwd', constants.R_OK | constants.W_OK); + * console.log('can read/write'); + * } catch (err) { + * console.error('no access!'); + * } + * ``` + * @since v0.11.15 + * @param [mode=fs.constants.F_OK] + */ + export function accessSync(path: PathLike, mode?: number): void; + interface StreamOptions { + flags?: string | undefined; + encoding?: BufferEncoding | undefined; + fd?: number | promises.FileHandle | undefined; + mode?: number | undefined; + autoClose?: boolean | undefined; + emitClose?: boolean | undefined; + start?: number | undefined; + signal?: AbortSignal | null | undefined; + highWaterMark?: number | undefined; + } + interface FSImplementation { + open?: (...args: any[]) => any; + close?: (...args: any[]) => any; + } + interface CreateReadStreamFSImplementation extends FSImplementation { + read: (...args: any[]) => any; + } + interface CreateWriteStreamFSImplementation extends FSImplementation { + write: (...args: any[]) => any; + writev?: (...args: any[]) => any; + } + interface ReadStreamOptions extends StreamOptions { + fs?: CreateReadStreamFSImplementation | null | undefined; + end?: number | undefined; + } + interface WriteStreamOptions extends StreamOptions { + fs?: CreateWriteStreamFSImplementation | null | undefined; + flush?: boolean | undefined; + } + /** + * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream + * returned by this method has a default `highWaterMark` of 64 KiB. + * + * `options` can include `start` and `end` values to read a range of bytes from + * the file instead of the entire file. Both `start` and `end` are inclusive and + * start counting at 0, allowed values are in the + * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `fd` is specified and `start` is + * omitted or `undefined`, `fs.createReadStream()` reads sequentially from the + * current file position. The `encoding` can be any one of those accepted by `Buffer`. + * + * If `fd` is specified, `ReadStream` will ignore the `path` argument and will use + * the specified file descriptor. This means that no `'open'` event will be + * emitted. `fd` should be blocking; non-blocking `fd`s should be passed to `net.Socket`. + * + * If `fd` points to a character device that only supports blocking reads + * (such as keyboard or sound card), read operations do not finish until data is + * available. This can prevent the process from exiting and the stream from + * closing naturally. + * + * By default, the stream will emit a `'close'` event after it has been + * destroyed. Set the `emitClose` option to `false` to change this behavior. + * + * By providing the `fs` option, it is possible to override the corresponding `fs`implementations for `open`, `read`, and `close`. When providing the `fs` option, + * an override for `read` is required. If no `fd` is provided, an override for`open` is also required. If `autoClose` is `true`, an override for `close` is + * also required. + * + * ```js + * import { createReadStream } from 'node:fs'; + * + * // Create a stream from some character device. + * const stream = createReadStream('/dev/input/event0'); + * setTimeout(() => { + * stream.close(); // This may not close the stream. + * // Artificially marking end-of-stream, as if the underlying resource had + * // indicated end-of-file by itself, allows the stream to close. + * // This does not cancel pending read operations, and if there is such an + * // operation, the process may still not be able to exit successfully + * // until it finishes. + * stream.push(null); + * stream.read(0); + * }, 100); + * ``` + * + * If `autoClose` is false, then the file descriptor won't be closed, even if + * there's an error. It is the application's responsibility to close it and make + * sure there's no file descriptor leak. If `autoClose` is set to true (default + * behavior), on `'error'` or `'end'` the file descriptor will be closed + * automatically. + * + * `mode` sets the file mode (permission and sticky bits), but only if the + * file was created. + * + * An example to read the last 10 bytes of a file which is 100 bytes long: + * + * ```js + * import { createReadStream } from 'node:fs'; + * + * createReadStream('sample.txt', { start: 90, end: 99 }); + * ``` + * + * If `options` is a string, then it specifies the encoding. + * @since v0.1.31 + */ + export function createReadStream(path: PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream; + /** + * `options` may also include a `start` option to allow writing data at some + * position past the beginning of the file, allowed values are in the + * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than + * replacing it may require the `flags` option to be set to `r+` rather than the + * default `w`. The `encoding` can be any one of those accepted by `Buffer`. + * + * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false, + * then the file descriptor won't be closed, even if there's an error. + * It is the application's responsibility to close it and make sure there's no + * file descriptor leak. + * + * By default, the stream will emit a `'close'` event after it has been + * destroyed. Set the `emitClose` option to `false` to change this behavior. + * + * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev`, and `close`. Overriding `write()`without `writev()` can reduce + * performance as some optimizations (`_writev()`) + * will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override + * for `open` is also required. If `autoClose` is `true`, an override for `close`is also required. + * + * Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the`path` argument and will use the specified file descriptor. This means that no`'open'` event will be + * emitted. `fd` should be blocking; non-blocking `fd`s + * should be passed to `net.Socket`. + * + * If `options` is a string, then it specifies the encoding. + * @since v0.1.31 + */ + export function createWriteStream(path: PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream; + /** + * Forces all currently queued I/O operations associated with the file to the + * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. No arguments other + * than a possible + * exception are given to the completion callback. + * @since v0.1.96 + */ + export function fdatasync(fd: number, callback: NoParamCallback): void; + export namespace fdatasync { + /** + * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device. + * @param fd A file descriptor. + */ + function __promisify__(fd: number): Promise; + } + /** + * Forces all currently queued I/O operations associated with the file to the + * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. Returns `undefined`. + * @since v0.1.96 + */ + export function fdatasyncSync(fd: number): void; + /** + * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it + * already exists. No arguments other than a possible exception are given to the + * callback function. Node.js makes no guarantees about the atomicity of the copy + * operation. If an error occurs after the destination file has been opened for + * writing, Node.js will attempt to remove the destination. + * + * `mode` is an optional integer that specifies the behavior + * of the copy operation. It is possible to create a mask consisting of the bitwise + * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`). + * + * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already + * exists. + * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a + * copy-on-write reflink. If the platform does not support copy-on-write, then a + * fallback copy mechanism is used. + * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to + * create a copy-on-write reflink. If the platform does not support + * copy-on-write, then the operation will fail. + * + * ```js + * import { copyFile, constants } from 'node:fs'; + * + * function callback(err) { + * if (err) throw err; + * console.log('source.txt was copied to destination.txt'); + * } + * + * // destination.txt will be created or overwritten by default. + * copyFile('source.txt', 'destination.txt', callback); + * + * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists. + * copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback); + * ``` + * @since v8.5.0 + * @param src source filename to copy + * @param dest destination filename of the copy operation + * @param [mode=0] modifiers for copy operation. + */ + export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void; + export function copyFile(src: PathLike, dest: PathLike, mode: number, callback: NoParamCallback): void; + export namespace copyFile { + function __promisify__(src: PathLike, dst: PathLike, mode?: number): Promise; + } + /** + * Synchronously copies `src` to `dest`. By default, `dest` is overwritten if it + * already exists. Returns `undefined`. Node.js makes no guarantees about the + * atomicity of the copy operation. If an error occurs after the destination file + * has been opened for writing, Node.js will attempt to remove the destination. + * + * `mode` is an optional integer that specifies the behavior + * of the copy operation. It is possible to create a mask consisting of the bitwise + * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`). + * + * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already + * exists. + * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a + * copy-on-write reflink. If the platform does not support copy-on-write, then a + * fallback copy mechanism is used. + * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to + * create a copy-on-write reflink. If the platform does not support + * copy-on-write, then the operation will fail. + * + * ```js + * import { copyFileSync, constants } from 'node:fs'; + * + * // destination.txt will be created or overwritten by default. + * copyFileSync('source.txt', 'destination.txt'); + * console.log('source.txt was copied to destination.txt'); + * + * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists. + * copyFileSync('source.txt', 'destination.txt', constants.COPYFILE_EXCL); + * ``` + * @since v8.5.0 + * @param src source filename to copy + * @param dest destination filename of the copy operation + * @param [mode=0] modifiers for copy operation. + */ + export function copyFileSync(src: PathLike, dest: PathLike, mode?: number): void; + /** + * Write an array of `ArrayBufferView`s to the file specified by `fd` using`writev()`. + * + * `position` is the offset from the beginning of the file where this data + * should be written. If `typeof position !== 'number'`, the data will be written + * at the current position. + * + * The callback will be given three arguments: `err`, `bytesWritten`, and`buffers`. `bytesWritten` is how many bytes were written from `buffers`. + * + * If this method is `util.promisify()` ed, it returns a promise for an`Object` with `bytesWritten` and `buffers` properties. + * + * It is unsafe to use `fs.writev()` multiple times on the same file without + * waiting for the callback. For this scenario, use {@link createWriteStream}. + * + * On Linux, positional writes don't work when the file is opened in append mode. + * The kernel ignores the position argument and always appends the data to + * the end of the file. + * @since v12.9.0 + * @param [position='null'] + */ + export function writev( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void, + ): void; + export function writev( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + position: number, + cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void, + ): void; + export interface WriteVResult { + bytesWritten: number; + buffers: NodeJS.ArrayBufferView[]; + } + export namespace writev { + function __promisify__( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + position?: number, + ): Promise; + } + /** + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link writev}. + * @since v12.9.0 + * @param [position='null'] + * @return The number of bytes written. + */ + export function writevSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number; + /** + * Read from a file specified by `fd` and write to an array of `ArrayBufferView`s + * using `readv()`. + * + * `position` is the offset from the beginning of the file from where data + * should be read. If `typeof position !== 'number'`, the data will be read + * from the current position. + * + * The callback will be given three arguments: `err`, `bytesRead`, and`buffers`. `bytesRead` is how many bytes were read from the file. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a promise for an `Object` with `bytesRead` and `buffers` properties. + * @since v13.13.0, v12.17.0 + * @param [position='null'] + */ + export function readv( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void, + ): void; + export function readv( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + position: number, + cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void, + ): void; + export interface ReadVResult { + bytesRead: number; + buffers: NodeJS.ArrayBufferView[]; + } + export namespace readv { + function __promisify__( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + position?: number, + ): Promise; + } + /** + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link readv}. + * @since v13.13.0, v12.17.0 + * @param [position='null'] + * @return The number of bytes read. + */ + export function readvSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number; + + export interface OpenAsBlobOptions { + /** + * An optional mime type for the blob. + * + * @default 'undefined' + */ + type?: string | undefined; + } + + /** + * Returns a `Blob` whose data is backed by the given file. + * + * The file must not be modified after the `Blob` is created. Any modifications + * will cause reading the `Blob` data to fail with a `DOMException` error. + * Synchronous stat operations on the file when the `Blob` is created, and before + * each read in order to detect whether the file data has been modified on disk. + * + * ```js + * import { openAsBlob } from 'node:fs'; + * + * const blob = await openAsBlob('the.file.txt'); + * const ab = await blob.arrayBuffer(); + * blob.stream(); + * ``` + * @since v19.8.0 + * @experimental + */ + export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise; + + export interface OpenDirOptions { + /** + * @default 'utf8' + */ + encoding?: BufferEncoding | undefined; + /** + * Number of directory entries that are buffered + * internally when reading from the directory. Higher values lead to better + * performance but higher memory usage. + * @default 32 + */ + bufferSize?: number | undefined; + /** + * @default false + */ + recursive?: boolean; + } + /** + * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html). + * + * Creates an `fs.Dir`, which contains all further functions for reading from + * and cleaning up the directory. + * + * The `encoding` option sets the encoding for the `path` while opening the + * directory and subsequent read operations. + * @since v12.12.0 + */ + export function opendirSync(path: PathLike, options?: OpenDirOptions): Dir; + /** + * Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for + * more details. + * + * Creates an `fs.Dir`, which contains all further functions for reading from + * and cleaning up the directory. + * + * The `encoding` option sets the encoding for the `path` while opening the + * directory and subsequent read operations. + * @since v12.12.0 + */ + export function opendir(path: PathLike, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void; + export function opendir( + path: PathLike, + options: OpenDirOptions, + cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void, + ): void; + export namespace opendir { + function __promisify__(path: PathLike, options?: OpenDirOptions): Promise; + } + export interface BigIntStats extends StatsBase { + atimeNs: bigint; + mtimeNs: bigint; + ctimeNs: bigint; + birthtimeNs: bigint; + } + export interface BigIntOptions { + bigint: true; + } + export interface StatOptions { + bigint?: boolean | undefined; + } + export interface StatSyncOptions extends StatOptions { + throwIfNoEntry?: boolean | undefined; + } + interface CopyOptionsBase { + /** + * Dereference symlinks + * @default false + */ + dereference?: boolean; + /** + * When `force` is `false`, and the destination + * exists, throw an error. + * @default false + */ + errorOnExist?: boolean; + /** + * Overwrite existing file or directory. _The copy + * operation will ignore errors if you set this to false and the destination + * exists. Use the `errorOnExist` option to change this behavior. + * @default true + */ + force?: boolean; + /** + * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()} + */ + mode?: number; + /** + * When `true` timestamps from `src` will + * be preserved. + * @default false + */ + preserveTimestamps?: boolean; + /** + * Copy directories recursively. + * @default false + */ + recursive?: boolean; + /** + * When true, path resolution for symlinks will be skipped + * @default false + */ + verbatimSymlinks?: boolean; + } + export interface CopyOptions extends CopyOptionsBase { + /** + * Function to filter copied files/directories. Return + * `true` to copy the item, `false` to ignore it. + */ + filter?(source: string, destination: string): boolean | Promise; + } + export interface CopySyncOptions extends CopyOptionsBase { + /** + * Function to filter copied files/directories. Return + * `true` to copy the item, `false` to ignore it. + */ + filter?(source: string, destination: string): boolean; + } + /** + * Asynchronously copies the entire directory structure from `src` to `dest`, + * including subdirectories and files. + * + * When copying a directory to another directory, globs are not supported and + * behavior is similar to `cp dir1/ dir2/`. + * @since v16.7.0 + * @experimental + * @param src source path to copy. + * @param dest destination path to copy to. + */ + export function cp( + source: string | URL, + destination: string | URL, + callback: (err: NodeJS.ErrnoException | null) => void, + ): void; + export function cp( + source: string | URL, + destination: string | URL, + opts: CopyOptions, + callback: (err: NodeJS.ErrnoException | null) => void, + ): void; + /** + * Synchronously copies the entire directory structure from `src` to `dest`, + * including subdirectories and files. + * + * When copying a directory to another directory, globs are not supported and + * behavior is similar to `cp dir1/ dir2/`. + * @since v16.7.0 + * @experimental + * @param src source path to copy. + * @param dest destination path to copy to. + */ + export function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void; +} +declare module "node:fs" { + export * from "fs"; +} diff --git a/node_modules/@types/node/fs/promises.d.ts b/node_modules/@types/node/fs/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..88a9fc33e91344c14cf676cb9317eda1f1cb96f7 --- /dev/null +++ b/node_modules/@types/node/fs/promises.d.ts @@ -0,0 +1,1239 @@ +/** + * The `fs/promises` API provides asynchronous file system methods that return + * promises. + * + * The promise APIs use the underlying Node.js threadpool to perform file + * system operations off the event loop thread. These operations are not + * synchronized or threadsafe. Care must be taken when performing multiple + * concurrent modifications on the same file or data corruption may occur. + * @since v10.0.0 + */ +declare module "fs/promises" { + import { Abortable } from "node:events"; + import { Stream } from "node:stream"; + import { ReadableStream } from "node:stream/web"; + import { + BigIntStats, + BigIntStatsFs, + BufferEncodingOption, + constants as fsConstants, + CopyOptions, + Dir, + Dirent, + MakeDirectoryOptions, + Mode, + ObjectEncodingOptions, + OpenDirOptions, + OpenMode, + PathLike, + ReadStream, + ReadVResult, + RmDirOptions, + RmOptions, + StatFsOptions, + StatOptions, + Stats, + StatsFs, + TimeLike, + WatchEventType, + WatchOptions, + WriteStream, + WriteVResult, + } from "node:fs"; + import { Interface as ReadlineInterface } from "node:readline"; + interface FileChangeInfo { + eventType: WatchEventType; + filename: T | null; + } + interface FlagAndOpenMode { + mode?: Mode | undefined; + flag?: OpenMode | undefined; + } + interface FileReadResult { + bytesRead: number; + buffer: T; + } + interface FileReadOptions { + /** + * @default `Buffer.alloc(0xffff)` + */ + buffer?: T; + /** + * @default 0 + */ + offset?: number | null; + /** + * @default `buffer.byteLength` + */ + length?: number | null; + position?: number | null; + } + interface CreateReadStreamOptions { + encoding?: BufferEncoding | null | undefined; + autoClose?: boolean | undefined; + emitClose?: boolean | undefined; + start?: number | undefined; + end?: number | undefined; + highWaterMark?: number | undefined; + } + interface CreateWriteStreamOptions { + encoding?: BufferEncoding | null | undefined; + autoClose?: boolean | undefined; + emitClose?: boolean | undefined; + start?: number | undefined; + highWaterMark?: number | undefined; + flush?: boolean | undefined; + } + interface ReadableWebStreamOptions { + /** + * Whether to open a normal or a `'bytes'` stream. + * @since v20.0.0 + */ + type?: "bytes" | undefined; + } + // TODO: Add `EventEmitter` close + interface FileHandle { + /** + * The numeric file descriptor managed by the {FileHandle} object. + * @since v10.0.0 + */ + readonly fd: number; + /** + * Alias of `filehandle.writeFile()`. + * + * When operating on file handles, the mode cannot be changed from what it was set + * to with `fsPromises.open()`. Therefore, this is equivalent to `filehandle.writeFile()`. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + appendFile( + data: string | Uint8Array, + options?: + | (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) + | BufferEncoding + | null, + ): Promise; + /** + * Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html). + * @since v10.0.0 + * @param uid The file's new owner's user id. + * @param gid The file's new group's group id. + * @return Fulfills with `undefined` upon success. + */ + chown(uid: number, gid: number): Promise; + /** + * Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html). + * @since v10.0.0 + * @param mode the file mode bit mask. + * @return Fulfills with `undefined` upon success. + */ + chmod(mode: Mode): Promise; + /** + * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream + * returned by this method has a default `highWaterMark` of 64 KiB. + * + * `options` can include `start` and `end` values to read a range of bytes from + * the file instead of the entire file. Both `start` and `end` are inclusive and + * start counting at 0, allowed values are in the + * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `start` is + * omitted or `undefined`, `filehandle.createReadStream()` reads sequentially from + * the current file position. The `encoding` can be any one of those accepted by `Buffer`. + * + * If the `FileHandle` points to a character device that only supports blocking + * reads (such as keyboard or sound card), read operations do not finish until data + * is available. This can prevent the process from exiting and the stream from + * closing naturally. + * + * By default, the stream will emit a `'close'` event after it has been + * destroyed. Set the `emitClose` option to `false` to change this behavior. + * + * ```js + * import { open } from 'node:fs/promises'; + * + * const fd = await open('/dev/input/event0'); + * // Create a stream from some character device. + * const stream = fd.createReadStream(); + * setTimeout(() => { + * stream.close(); // This may not close the stream. + * // Artificially marking end-of-stream, as if the underlying resource had + * // indicated end-of-file by itself, allows the stream to close. + * // This does not cancel pending read operations, and if there is such an + * // operation, the process may still not be able to exit successfully + * // until it finishes. + * stream.push(null); + * stream.read(0); + * }, 100); + * ``` + * + * If `autoClose` is false, then the file descriptor won't be closed, even if + * there's an error. It is the application's responsibility to close it and make + * sure there's no file descriptor leak. If `autoClose` is set to true (default + * behavior), on `'error'` or `'end'` the file descriptor will be closed + * automatically. + * + * An example to read the last 10 bytes of a file which is 100 bytes long: + * + * ```js + * import { open } from 'node:fs/promises'; + * + * const fd = await open('sample.txt'); + * fd.createReadStream({ start: 90, end: 99 }); + * ``` + * @since v16.11.0 + */ + createReadStream(options?: CreateReadStreamOptions): ReadStream; + /** + * `options` may also include a `start` option to allow writing data at some + * position past the beginning of the file, allowed values are in the + * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than + * replacing it may require the `flags` `open` option to be set to `r+` rather than + * the default `r`. The `encoding` can be any one of those accepted by `Buffer`. + * + * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false, + * then the file descriptor won't be closed, even if there's an error. + * It is the application's responsibility to close it and make sure there's no + * file descriptor leak. + * + * By default, the stream will emit a `'close'` event after it has been + * destroyed. Set the `emitClose` option to `false` to change this behavior. + * @since v16.11.0 + */ + createWriteStream(options?: CreateWriteStreamOptions): WriteStream; + /** + * Forces all currently queued I/O operations associated with the file to the + * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. + * + * Unlike `filehandle.sync` this method does not flush modified metadata. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + datasync(): Promise; + /** + * Request that all data for the open file descriptor is flushed to the storage + * device. The specific implementation is operating system and device specific. + * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + sync(): Promise; + /** + * Reads data from the file and stores that in the given buffer. + * + * If the file is not modified concurrently, the end-of-file is reached when the + * number of bytes read is zero. + * @since v10.0.0 + * @param buffer A buffer that will be filled with the file data read. + * @param offset The location in the buffer at which to start filling. + * @param length The number of bytes to read. + * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an + * integer, the current file position will remain unchanged. + * @return Fulfills upon success with an object with two properties: + */ + read( + buffer: T, + offset?: number | null, + length?: number | null, + position?: number | null, + ): Promise>; + read(options?: FileReadOptions): Promise>; + /** + * Returns a `ReadableStream` that may be used to read the files data. + * + * An error will be thrown if this method is called more than once or is called + * after the `FileHandle` is closed or closing. + * + * ```js + * import { + * open, + * } from 'node:fs/promises'; + * + * const file = await open('./some/file/to/read'); + * + * for await (const chunk of file.readableWebStream()) + * console.log(chunk); + * + * await file.close(); + * ``` + * + * While the `ReadableStream` will read the file to completion, it will not + * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method. + * @since v17.0.0 + * @experimental + */ + readableWebStream(options?: ReadableWebStreamOptions): ReadableStream; + /** + * Asynchronously reads the entire contents of a file. + * + * If `options` is a string, then it specifies the `encoding`. + * + * The `FileHandle` has to support reading. + * + * If one or more `filehandle.read()` calls are made on a file handle and then a`filehandle.readFile()` call is made, the data will be read from the current + * position till the end of the file. It doesn't always read from the beginning + * of the file. + * @since v10.0.0 + * @return Fulfills upon a successful read with the contents of the file. If no encoding is specified (using `options.encoding`), the data is returned as a {Buffer} object. Otherwise, the + * data will be a string. + */ + readFile( + options?: { + encoding?: null | undefined; + flag?: OpenMode | undefined; + } | null, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically. + * The `FileHandle` must have been opened for reading. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + readFile( + options: + | { + encoding: BufferEncoding; + flag?: OpenMode | undefined; + } + | BufferEncoding, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically. + * The `FileHandle` must have been opened for reading. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + readFile( + options?: + | (ObjectEncodingOptions & { + flag?: OpenMode | undefined; + }) + | BufferEncoding + | null, + ): Promise; + /** + * Convenience method to create a `readline` interface and stream over the file. + * See `filehandle.createReadStream()` for the options. + * + * ```js + * import { open } from 'node:fs/promises'; + * + * const file = await open('./some/file/to/read'); + * + * for await (const line of file.readLines()) { + * console.log(line); + * } + * ``` + * @since v18.11.0 + */ + readLines(options?: CreateReadStreamOptions): ReadlineInterface; + /** + * @since v10.0.0 + * @return Fulfills with an {fs.Stats} for the file. + */ + stat( + opts?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + stat( + opts: StatOptions & { + bigint: true; + }, + ): Promise; + stat(opts?: StatOptions): Promise; + /** + * Truncates the file. + * + * If the file was larger than `len` bytes, only the first `len` bytes will be + * retained in the file. + * + * The following example retains only the first four bytes of the file: + * + * ```js + * import { open } from 'node:fs/promises'; + * + * let filehandle = null; + * try { + * filehandle = await open('temp.txt', 'r+'); + * await filehandle.truncate(4); + * } finally { + * await filehandle?.close(); + * } + * ``` + * + * If the file previously was shorter than `len` bytes, it is extended, and the + * extended part is filled with null bytes (`'\0'`): + * + * If `len` is negative then `0` will be used. + * @since v10.0.0 + * @param [len=0] + * @return Fulfills with `undefined` upon success. + */ + truncate(len?: number): Promise; + /** + * Change the file system timestamps of the object referenced by the `FileHandle` then fulfills the promise with no arguments upon success. + * @since v10.0.0 + */ + utimes(atime: TimeLike, mtime: TimeLike): Promise; + /** + * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an + * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an + * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object. + * The promise is fulfilled with no arguments upon success. + * + * If `options` is a string, then it specifies the `encoding`. + * + * The `FileHandle` has to support writing. + * + * It is unsafe to use `filehandle.writeFile()` multiple times on the same file + * without waiting for the promise to be fulfilled (or rejected). + * + * If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the + * current position till the end of the file. It doesn't always write from the + * beginning of the file. + * @since v10.0.0 + */ + writeFile( + data: string | Uint8Array, + options?: + | (ObjectEncodingOptions & FlagAndOpenMode & Abortable & { flush?: boolean | undefined }) + | BufferEncoding + | null, + ): Promise; + /** + * Write `buffer` to the file. + * + * The promise is fulfilled with an object containing two properties: + * + * It is unsafe to use `filehandle.write()` multiple times on the same file + * without waiting for the promise to be fulfilled (or rejected). For this + * scenario, use `filehandle.createWriteStream()`. + * + * On Linux, positional writes do not work when the file is opened in append mode. + * The kernel ignores the position argument and always appends the data to + * the end of the file. + * @since v10.0.0 + * @param offset The start position from within `buffer` where the data to write begins. + * @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write. + * @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current + * position. See the POSIX pwrite(2) documentation for more detail. + */ + write( + buffer: TBuffer, + offset?: number | null, + length?: number | null, + position?: number | null, + ): Promise<{ + bytesWritten: number; + buffer: TBuffer; + }>; + write( + data: string, + position?: number | null, + encoding?: BufferEncoding | null, + ): Promise<{ + bytesWritten: number; + buffer: string; + }>; + /** + * Write an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s to the file. + * + * The promise is fulfilled with an object containing a two properties: + * + * It is unsafe to call `writev()` multiple times on the same file without waiting + * for the promise to be fulfilled (or rejected). + * + * On Linux, positional writes don't work when the file is opened in append mode. + * The kernel ignores the position argument and always appends the data to + * the end of the file. + * @since v12.9.0 + * @param [position='null'] The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current + * position. + */ + writev(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise; + /** + * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s + * @since v13.13.0, v12.17.0 + * @param [position='null'] The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position. + * @return Fulfills upon success an object containing two properties: + */ + readv(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise; + /** + * Closes the file handle after waiting for any pending operation on the handle to + * complete. + * + * ```js + * import { open } from 'node:fs/promises'; + * + * let filehandle; + * try { + * filehandle = await open('thefile.txt', 'r'); + * } finally { + * await filehandle?.close(); + * } + * ``` + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + close(): Promise; + /** + * An alias for {@link FileHandle.close()}. + * @since v20.4.0 + */ + [Symbol.asyncDispose](): Promise; + } + const constants: typeof fsConstants; + /** + * Tests a user's permissions for the file or directory specified by `path`. + * The `mode` argument is an optional integer that specifies the accessibility + * checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK` + * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for + * possible values of `mode`. + * + * If the accessibility check is successful, the promise is fulfilled with no + * value. If any of the accessibility checks fail, the promise is rejected + * with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and + * written by the current process. + * + * ```js + * import { access, constants } from 'node:fs/promises'; + * + * try { + * await access('/etc/passwd', constants.R_OK | constants.W_OK); + * console.log('can access'); + * } catch { + * console.error('cannot access'); + * } + * ``` + * + * Using `fsPromises.access()` to check for the accessibility of a file before + * calling `fsPromises.open()` is not recommended. Doing so introduces a race + * condition, since other processes may change the file's state between the two + * calls. Instead, user code should open/read/write the file directly and handle + * the error raised if the file is not accessible. + * @since v10.0.0 + * @param [mode=fs.constants.F_OK] + * @return Fulfills with `undefined` upon success. + */ + function access(path: PathLike, mode?: number): Promise; + /** + * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it + * already exists. + * + * No guarantees are made about the atomicity of the copy operation. If an + * error occurs after the destination file has been opened for writing, an attempt + * will be made to remove the destination. + * + * ```js + * import { copyFile, constants } from 'node:fs/promises'; + * + * try { + * await copyFile('source.txt', 'destination.txt'); + * console.log('source.txt was copied to destination.txt'); + * } catch { + * console.error('The file could not be copied'); + * } + * + * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists. + * try { + * await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL); + * console.log('source.txt was copied to destination.txt'); + * } catch { + * console.error('The file could not be copied'); + * } + * ``` + * @since v10.0.0 + * @param src source filename to copy + * @param dest destination filename of the copy operation + * @param [mode=0] Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. + * `fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`) + * @return Fulfills with `undefined` upon success. + */ + function copyFile(src: PathLike, dest: PathLike, mode?: number): Promise; + /** + * Opens a `FileHandle`. + * + * Refer to the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more detail. + * + * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented + * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains + * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams). + * @since v10.0.0 + * @param [flags='r'] See `support of file system `flags``. + * @param [mode=0o666] Sets the file mode (permission and sticky bits) if the file is created. + * @return Fulfills with a {FileHandle} object. + */ + function open(path: PathLike, flags?: string | number, mode?: Mode): Promise; + /** + * Renames `oldPath` to `newPath`. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function rename(oldPath: PathLike, newPath: PathLike): Promise; + /** + * Truncates (shortens or extends the length) of the content at `path` to `len`bytes. + * @since v10.0.0 + * @param [len=0] + * @return Fulfills with `undefined` upon success. + */ + function truncate(path: PathLike, len?: number): Promise; + /** + * Removes the directory identified by `path`. + * + * Using `fsPromises.rmdir()` on a file (not a directory) results in the + * promise being rejected with an `ENOENT` error on Windows and an `ENOTDIR`error on POSIX. + * + * To get a behavior similar to the `rm -rf` Unix command, use `fsPromises.rm()` with options `{ recursive: true, force: true }`. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function rmdir(path: PathLike, options?: RmDirOptions): Promise; + /** + * Removes files and directories (modeled on the standard POSIX `rm` utility). + * @since v14.14.0 + * @return Fulfills with `undefined` upon success. + */ + function rm(path: PathLike, options?: RmOptions): Promise; + /** + * Asynchronously creates a directory. + * + * The optional `options` argument can be an integer specifying `mode` (permission + * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fsPromises.mkdir()` when `path` is a directory + * that exists results in a + * rejection only when `recursive` is false. + * + * ```js + * import { mkdir } from 'node:fs/promises'; + * + * try { + * const projectFolder = new URL('./test/project/', import.meta.url); + * const createDir = await mkdir(projectFolder, { recursive: true }); + * + * console.log(`created ${createDir}`); + * } catch (err) { + * console.error(err.message); + * } + * ``` + * @since v10.0.0 + * @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`. + */ + function mkdir( + path: PathLike, + options: MakeDirectoryOptions & { + recursive: true; + }, + ): Promise; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function mkdir( + path: PathLike, + options?: + | Mode + | (MakeDirectoryOptions & { + recursive?: false | undefined; + }) + | null, + ): Promise; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function mkdir(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise; + /** + * Reads the contents of a directory. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the filenames. If the `encoding` is set to `'buffer'`, the filenames returned + * will be passed as `Buffer` objects. + * + * If `options.withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects. + * + * ```js + * import { readdir } from 'node:fs/promises'; + * + * try { + * const files = await readdir(path); + * for (const file of files) + * console.log(file); + * } catch (err) { + * console.error(err); + * } + * ``` + * @since v10.0.0 + * @return Fulfills with an array of the names of the files in the directory excluding `'.'` and `'..'`. + */ + function readdir( + path: PathLike, + options?: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function readdir( + path: PathLike, + options: + | { + encoding: "buffer"; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | "buffer", + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function readdir( + path: PathLike, + options?: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options If called with `withFileTypes: true` the result data will be an array of Dirent. + */ + function readdir( + path: PathLike, + options: ObjectEncodingOptions & { + withFileTypes: true; + recursive?: boolean | undefined; + }, + ): Promise; + /** + * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is + * fulfilled with the`linkString` upon success. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the link path returned. If the `encoding` is set to `'buffer'`, the link path + * returned will be passed as a `Buffer` object. + * @since v10.0.0 + * @return Fulfills with the `linkString` upon success. + */ + function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function readlink(path: PathLike, options: BufferEncodingOption): Promise; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise; + /** + * Creates a symbolic link. + * + * The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. If the `type` argument is not a string, Node.js will + * autodetect `target` type and use `'file'` or `'dir'`. If the `target` does not + * exist, `'file'` will be used. Windows junction points require the destination + * path to be absolute. When using `'junction'`, the `target` argument will + * automatically be normalized to absolute path. Junction points on NTFS volumes + * can only point to directories. + * @since v10.0.0 + * @param [type='null'] + * @return Fulfills with `undefined` upon success. + */ + function symlink(target: PathLike, path: PathLike, type?: string | null): Promise; + /** + * Equivalent to `fsPromises.stat()` unless `path` refers to a symbolic link, + * in which case the link itself is stat-ed, not the file that it refers to. + * Refer to the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) document for more detail. + * @since v10.0.0 + * @return Fulfills with the {fs.Stats} object for the given symbolic link `path`. + */ + function lstat( + path: PathLike, + opts?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function lstat( + path: PathLike, + opts: StatOptions & { + bigint: true; + }, + ): Promise; + function lstat(path: PathLike, opts?: StatOptions): Promise; + /** + * @since v10.0.0 + * @return Fulfills with the {fs.Stats} object for the given `path`. + */ + function stat( + path: PathLike, + opts?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function stat( + path: PathLike, + opts: StatOptions & { + bigint: true; + }, + ): Promise; + function stat(path: PathLike, opts?: StatOptions): Promise; + /** + * @since v19.6.0, v18.15.0 + * @return Fulfills with the {fs.StatFs} object for the given `path`. + */ + function statfs( + path: PathLike, + opts?: StatFsOptions & { + bigint?: false | undefined; + }, + ): Promise; + function statfs( + path: PathLike, + opts: StatFsOptions & { + bigint: true; + }, + ): Promise; + function statfs(path: PathLike, opts?: StatFsOptions): Promise; + /** + * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function link(existingPath: PathLike, newPath: PathLike): Promise; + /** + * If `path` refers to a symbolic link, then the link is removed without affecting + * the file or directory to which that link refers. If the `path` refers to a file + * path that is not a symbolic link, the file is deleted. See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more detail. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function unlink(path: PathLike): Promise; + /** + * Changes the permissions of a file. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function chmod(path: PathLike, mode: Mode): Promise; + /** + * Changes the permissions on a symbolic link. + * + * This method is only implemented on macOS. + * @deprecated Since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function lchmod(path: PathLike, mode: Mode): Promise; + /** + * Changes the ownership on a symbolic link. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function lchown(path: PathLike, uid: number, gid: number): Promise; + /** + * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, with the difference that if the path refers to a + * symbolic link, then the link is not dereferenced: instead, the timestamps of + * the symbolic link itself are changed. + * @since v14.5.0, v12.19.0 + * @return Fulfills with `undefined` upon success. + */ + function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise; + /** + * Changes the ownership of a file. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function chown(path: PathLike, uid: number, gid: number): Promise; + /** + * Change the file system timestamps of the object referenced by `path`. + * + * The `atime` and `mtime` arguments follow these rules: + * + * * Values can be either numbers representing Unix epoch time, `Date`s, or a + * numeric string like `'123456789.0'`. + * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise; + /** + * Determines the actual location of `path` using the same semantics as the`fs.realpath.native()` function. + * + * Only paths that can be converted to UTF8 strings are supported. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the path. If the `encoding` is set to `'buffer'`, the path returned will be + * passed as a `Buffer` object. + * + * On Linux, when Node.js is linked against musl libc, the procfs file system must + * be mounted on `/proc` in order for this function to work. Glibc does not have + * this restriction. + * @since v10.0.0 + * @return Fulfills with the resolved path upon success. + */ + function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function realpath(path: PathLike, options: BufferEncodingOption): Promise; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function realpath( + path: PathLike, + options?: ObjectEncodingOptions | BufferEncoding | null, + ): Promise; + /** + * Creates a unique temporary directory. A unique directory name is generated by + * appending six random characters to the end of the provided `prefix`. Due to + * platform inconsistencies, avoid trailing `X` characters in `prefix`. Some + * platforms, notably the BSDs, can return more than six random characters, and + * replace trailing `X` characters in `prefix` with random characters. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use. + * + * ```js + * import { mkdtemp } from 'node:fs/promises'; + * import { join } from 'node:path'; + * import { tmpdir } from 'node:os'; + * + * try { + * await mkdtemp(join(tmpdir(), 'foo-')); + * } catch (err) { + * console.error(err); + * } + * ``` + * + * The `fsPromises.mkdtemp()` method will append the six randomly selected + * characters directly to the `prefix` string. For instance, given a directory`/tmp`, if the intention is to create a temporary directory _within_`/tmp`, the`prefix` must end with a trailing + * platform-specific path separator + * (`require('node:path').sep`). + * @since v10.0.0 + * @return Fulfills with a string containing the file system path of the newly created temporary directory. + */ + function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function mkdtemp(prefix: string, options: BufferEncodingOption): Promise; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; + /** + * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an + * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an + * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object. + * + * The `encoding` option is ignored if `data` is a buffer. + * + * If `options` is a string, then it specifies the encoding. + * + * The `mode` option only affects the newly created file. See `fs.open()` for more details. + * + * Any specified `FileHandle` has to support writing. + * + * It is unsafe to use `fsPromises.writeFile()` multiple times on the same file + * without waiting for the promise to be settled. + * + * Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience + * method that performs multiple `write` calls internally to write the buffer + * passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`. + * + * It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`. + * Cancelation is "best effort", and some amount of data is likely still + * to be written. + * + * ```js + * import { writeFile } from 'node:fs/promises'; + * import { Buffer } from 'node:buffer'; + * + * try { + * const controller = new AbortController(); + * const { signal } = controller; + * const data = new Uint8Array(Buffer.from('Hello Node.js')); + * const promise = writeFile('message.txt', data, { signal }); + * + * // Abort the request before the promise settles. + * controller.abort(); + * + * await promise; + * } catch (err) { + * // When a request is aborted - err is an AbortError + * console.error(err); + * } + * ``` + * + * Aborting an ongoing request does not abort individual operating + * system requests but rather the internal buffering `fs.writeFile` performs. + * @since v10.0.0 + * @param file filename or `FileHandle` + * @return Fulfills with `undefined` upon success. + */ + function writeFile( + file: PathLike | FileHandle, + data: + | string + | NodeJS.ArrayBufferView + | Iterable + | AsyncIterable + | Stream, + options?: + | (ObjectEncodingOptions & { + mode?: Mode | undefined; + flag?: OpenMode | undefined; + } & Abortable) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronously append data to a file, creating the file if it does not yet + * exist. `data` can be a string or a `Buffer`. + * + * If `options` is a string, then it specifies the `encoding`. + * + * The `mode` option only affects the newly created file. See `fs.open()` for more details. + * + * The `path` may be specified as a `FileHandle` that has been opened + * for appending (using `fsPromises.open()`). + * @since v10.0.0 + * @param path filename or {FileHandle} + * @return Fulfills with `undefined` upon success. + */ + function appendFile( + path: PathLike | FileHandle, + data: string | Uint8Array, + options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * + * If no encoding is specified (using `options.encoding`), the data is returned + * as a `Buffer` object. Otherwise, the data will be a string. + * + * If `options` is a string, then it specifies the encoding. + * + * When the `path` is a directory, the behavior of `fsPromises.readFile()` is + * platform-specific. On macOS, Linux, and Windows, the promise will be rejected + * with an error. On FreeBSD, a representation of the directory's contents will be + * returned. + * + * An example of reading a `package.json` file located in the same directory of the + * running code: + * + * ```js + * import { readFile } from 'node:fs/promises'; + * try { + * const filePath = new URL('./package.json', import.meta.url); + * const contents = await readFile(filePath, { encoding: 'utf8' }); + * console.log(contents); + * } catch (err) { + * console.error(err.message); + * } + * ``` + * + * It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a + * request is aborted the promise returned is rejected with an `AbortError`: + * + * ```js + * import { readFile } from 'node:fs/promises'; + * + * try { + * const controller = new AbortController(); + * const { signal } = controller; + * const promise = readFile(fileName, { signal }); + * + * // Abort the request before the promise settles. + * controller.abort(); + * + * await promise; + * } catch (err) { + * // When a request is aborted - err is an AbortError + * console.error(err); + * } + * ``` + * + * Aborting an ongoing request does not abort individual operating + * system requests but rather the internal buffering `fs.readFile` performs. + * + * Any specified `FileHandle` has to support reading. + * @since v10.0.0 + * @param path filename or `FileHandle` + * @return Fulfills with the contents of the file. + */ + function readFile( + path: PathLike | FileHandle, + options?: + | ({ + encoding?: null | undefined; + flag?: OpenMode | undefined; + } & Abortable) + | null, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function readFile( + path: PathLike | FileHandle, + options: + | ({ + encoding: BufferEncoding; + flag?: OpenMode | undefined; + } & Abortable) + | BufferEncoding, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function readFile( + path: PathLike | FileHandle, + options?: + | ( + & ObjectEncodingOptions + & Abortable + & { + flag?: OpenMode | undefined; + } + ) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail. + * + * Creates an `fs.Dir`, which contains all further functions for reading from + * and cleaning up the directory. + * + * The `encoding` option sets the encoding for the `path` while opening the + * directory and subsequent read operations. + * + * Example using async iteration: + * + * ```js + * import { opendir } from 'node:fs/promises'; + * + * try { + * const dir = await opendir('./'); + * for await (const dirent of dir) + * console.log(dirent.name); + * } catch (err) { + * console.error(err); + * } + * ``` + * + * When using the async iterator, the `fs.Dir` object will be automatically + * closed after the iterator exits. + * @since v12.12.0 + * @return Fulfills with an {fs.Dir}. + */ + function opendir(path: PathLike, options?: OpenDirOptions): Promise; + /** + * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory. + * + * ```js + * const { watch } = require('node:fs/promises'); + * + * const ac = new AbortController(); + * const { signal } = ac; + * setTimeout(() => ac.abort(), 10000); + * + * (async () => { + * try { + * const watcher = watch(__filename, { signal }); + * for await (const event of watcher) + * console.log(event); + * } catch (err) { + * if (err.name === 'AbortError') + * return; + * throw err; + * } + * })(); + * ``` + * + * On most platforms, `'rename'` is emitted whenever a filename appears or + * disappears in the directory. + * + * All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`. + * @since v15.9.0, v14.18.0 + * @return of objects with the properties: + */ + function watch( + filename: PathLike, + options: + | (WatchOptions & { + encoding: "buffer"; + }) + | "buffer", + ): AsyncIterable>; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable>; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + function watch( + filename: PathLike, + options: WatchOptions | string, + ): AsyncIterable> | AsyncIterable>; + /** + * Asynchronously copies the entire directory structure from `src` to `dest`, + * including subdirectories and files. + * + * When copying a directory to another directory, globs are not supported and + * behavior is similar to `cp dir1/ dir2/`. + * @since v16.7.0 + * @experimental + * @param src source path to copy. + * @param dest destination path to copy to. + * @return Fulfills with `undefined` upon success. + */ + function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise; +} +declare module "node:fs/promises" { + export * from "fs/promises"; +} diff --git a/node_modules/@types/node/globals.d.ts b/node_modules/@types/node/globals.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a449e4c73abc04042bf8c29c49b74d21d53967d --- /dev/null +++ b/node_modules/@types/node/globals.d.ts @@ -0,0 +1,381 @@ +// Declare "static" methods in Error +interface ErrorConstructor { + /** Create .stack property on a target object */ + captureStackTrace(targetObject: object, constructorOpt?: Function): void; + + /** + * Optional override for formatting stack traces + * + * @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces + */ + prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined; + + stackTraceLimit: number; +} + +/*-----------------------------------------------* + * * + * GLOBAL * + * * + ------------------------------------------------*/ + +// For backwards compability +interface NodeRequire extends NodeJS.Require {} +interface RequireResolve extends NodeJS.RequireResolve {} +interface NodeModule extends NodeJS.Module {} + +declare var process: NodeJS.Process; +declare var console: Console; + +declare var __filename: string; +declare var __dirname: string; + +declare var require: NodeRequire; +declare var module: NodeModule; + +// Same as module.exports +declare var exports: any; + +/** + * Only available if `--expose-gc` is passed to the process. + */ +declare var gc: undefined | (() => void); + +// #region borrowed +// from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib +/** A controller object that allows you to abort one or more DOM requests as and when desired. */ +interface AbortController { + /** + * Returns the AbortSignal object associated with this object. + */ + + readonly signal: AbortSignal; + /** + * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. + */ + abort(reason?: any): void; +} + +/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */ +interface AbortSignal extends EventTarget { + /** + * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. + */ + readonly aborted: boolean; + readonly reason: any; + onabort: null | ((this: AbortSignal, event: Event) => any); + throwIfAborted(): void; +} + +declare var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T + : { + prototype: AbortController; + new(): AbortController; + }; + +declare var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T + : { + prototype: AbortSignal; + new(): AbortSignal; + abort(reason?: any): AbortSignal; + timeout(milliseconds: number): AbortSignal; + }; +// #endregion borrowed + +// #region Disposable +interface SymbolConstructor { + /** + * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + */ + readonly dispose: unique symbol; + + /** + * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement. + */ + readonly asyncDispose: unique symbol; +} + +interface Disposable { + [Symbol.dispose](): void; +} + +interface AsyncDisposable { + [Symbol.asyncDispose](): PromiseLike; +} +// #endregion Disposable + +// #region ArrayLike.at() +interface RelativeIndexable { + /** + * Takes an integer value and returns the item at that index, + * allowing for positive and negative integers. + * Negative integers count back from the last item in the array. + */ + at(index: number): T | undefined; +} +interface String extends RelativeIndexable {} +interface Array extends RelativeIndexable {} +interface ReadonlyArray extends RelativeIndexable {} +interface Int8Array extends RelativeIndexable {} +interface Uint8Array extends RelativeIndexable {} +interface Uint8ClampedArray extends RelativeIndexable {} +interface Int16Array extends RelativeIndexable {} +interface Uint16Array extends RelativeIndexable {} +interface Int32Array extends RelativeIndexable {} +interface Uint32Array extends RelativeIndexable {} +interface Float32Array extends RelativeIndexable {} +interface Float64Array extends RelativeIndexable {} +interface BigInt64Array extends RelativeIndexable {} +interface BigUint64Array extends RelativeIndexable {} +// #endregion ArrayLike.at() end + +/** + * @since v17.0.0 + * + * Creates a deep clone of an object. + */ +declare function structuredClone( + value: T, + transfer?: { transfer: ReadonlyArray }, +): T; + +/*----------------------------------------------* +* * +* GLOBAL INTERFACES * +* * +*-----------------------------------------------*/ +declare namespace NodeJS { + interface CallSite { + /** + * Value of "this" + */ + getThis(): unknown; + + /** + * Type of "this" as a string. + * This is the name of the function stored in the constructor field of + * "this", if available. Otherwise the object's [[Class]] internal + * property. + */ + getTypeName(): string | null; + + /** + * Current function + */ + getFunction(): Function | undefined; + + /** + * Name of the current function, typically its name property. + * If a name property is not available an attempt will be made to try + * to infer a name from the function's context. + */ + getFunctionName(): string | null; + + /** + * Name of the property [of "this" or one of its prototypes] that holds + * the current function + */ + getMethodName(): string | null; + + /** + * Name of the script [if this function was defined in a script] + */ + getFileName(): string | undefined; + + /** + * Current line number [if this function was defined in a script] + */ + getLineNumber(): number | null; + + /** + * Current column number [if this function was defined in a script] + */ + getColumnNumber(): number | null; + + /** + * A call site object representing the location where eval was called + * [if this function was created using a call to eval] + */ + getEvalOrigin(): string | undefined; + + /** + * Is this a toplevel invocation, that is, is "this" the global object? + */ + isToplevel(): boolean; + + /** + * Does this call take place in code defined by a call to eval? + */ + isEval(): boolean; + + /** + * Is this call in native V8 code? + */ + isNative(): boolean; + + /** + * Is this a constructor call? + */ + isConstructor(): boolean; + } + + interface ErrnoException extends Error { + errno?: number | undefined; + code?: string | undefined; + path?: string | undefined; + syscall?: string | undefined; + } + + interface ReadableStream extends EventEmitter { + readable: boolean; + read(size?: number): string | Buffer; + setEncoding(encoding: BufferEncoding): this; + pause(): this; + resume(): this; + isPaused(): boolean; + pipe(destination: T, options?: { end?: boolean | undefined }): T; + unpipe(destination?: WritableStream): this; + unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void; + wrap(oldStream: ReadableStream): this; + [Symbol.asyncIterator](): AsyncIterableIterator; + } + + interface WritableStream extends EventEmitter { + writable: boolean; + write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean; + write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean; + end(cb?: () => void): this; + end(data: string | Uint8Array, cb?: () => void): this; + end(str: string, encoding?: BufferEncoding, cb?: () => void): this; + } + + interface ReadWriteStream extends ReadableStream, WritableStream {} + + interface RefCounted { + ref(): this; + unref(): this; + } + + type TypedArray = + | Uint8Array + | Uint8ClampedArray + | Uint16Array + | Uint32Array + | Int8Array + | Int16Array + | Int32Array + | BigUint64Array + | BigInt64Array + | Float32Array + | Float64Array; + type ArrayBufferView = TypedArray | DataView; + + interface Require { + (id: string): any; + resolve: RequireResolve; + cache: Dict; + /** + * @deprecated + */ + extensions: RequireExtensions; + main: Module | undefined; + } + + interface RequireResolve { + (id: string, options?: { paths?: string[] | undefined }): string; + paths(request: string): string[] | null; + } + + interface RequireExtensions extends Dict<(m: Module, filename: string) => any> { + ".js": (m: Module, filename: string) => any; + ".json": (m: Module, filename: string) => any; + ".node": (m: Module, filename: string) => any; + } + interface Module { + /** + * `true` if the module is running during the Node.js preload + */ + isPreloading: boolean; + exports: any; + require: Require; + id: string; + filename: string; + loaded: boolean; + /** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */ + parent: Module | null | undefined; + children: Module[]; + /** + * @since v11.14.0 + * + * The directory name of the module. This is usually the same as the path.dirname() of the module.id. + */ + path: string; + paths: string[]; + } + + interface Dict { + [key: string]: T | undefined; + } + + interface ReadOnlyDict { + readonly [key: string]: T | undefined; + } + + namespace fetch { + type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request; + type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response; + type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData; + type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers; + type _RequestInit = typeof globalThis extends { onmessage: any } ? {} + : import("undici-types").RequestInit; + type Request = globalThis.Request; + type Response = globalThis.Response; + type Headers = globalThis.Headers; + type FormData = globalThis.FormData; + type RequestInit = globalThis.RequestInit; + type RequestInfo = import("undici-types").RequestInfo; + type HeadersInit = import("undici-types").HeadersInit; + type BodyInit = import("undici-types").BodyInit; + type RequestRedirect = import("undici-types").RequestRedirect; + type RequestCredentials = import("undici-types").RequestCredentials; + type RequestMode = import("undici-types").RequestMode; + type ReferrerPolicy = import("undici-types").ReferrerPolicy; + type Dispatcher = import("undici-types").Dispatcher; + type RequestDuplex = import("undici-types").RequestDuplex; + } +} + +interface RequestInit extends NodeJS.fetch._RequestInit {} + +declare function fetch( + input: NodeJS.fetch.RequestInfo, + init?: RequestInit, +): Promise; + +interface Request extends NodeJS.fetch._Request {} +declare var Request: typeof globalThis extends { + onmessage: any; + Request: infer T; +} ? T + : typeof import("undici-types").Request; + +interface Response extends NodeJS.fetch._Response {} +declare var Response: typeof globalThis extends { + onmessage: any; + Response: infer T; +} ? T + : typeof import("undici-types").Response; + +interface FormData extends NodeJS.fetch._FormData {} +declare var FormData: typeof globalThis extends { + onmessage: any; + FormData: infer T; +} ? T + : typeof import("undici-types").FormData; + +interface Headers extends NodeJS.fetch._Headers {} +declare var Headers: typeof globalThis extends { + onmessage: any; + Headers: infer T; +} ? T + : typeof import("undici-types").Headers; diff --git a/node_modules/@types/node/globals.global.d.ts b/node_modules/@types/node/globals.global.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef1198c05024940c44e3c1a6429c26091fe2a94f --- /dev/null +++ b/node_modules/@types/node/globals.global.d.ts @@ -0,0 +1 @@ +declare var global: typeof globalThis; diff --git a/node_modules/@types/node/http.d.ts b/node_modules/@types/node/http.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b2c3c2c6be6cdd67b5f1f53c70a55a880ee376f --- /dev/null +++ b/node_modules/@types/node/http.d.ts @@ -0,0 +1,1888 @@ +/** + * To use the HTTP server and client one must `require('node:http')`. + * + * The HTTP interfaces in Node.js are designed to support many features + * of the protocol which have been traditionally difficult to use. + * In particular, large, possibly chunk-encoded, messages. The interface is + * careful to never buffer entire requests or responses, so the + * user is able to stream data. + * + * HTTP message headers are represented by an object like this: + * + * ```js + * { 'content-length': '123', + * 'content-type': 'text/plain', + * 'connection': 'keep-alive', + * 'host': 'example.com', + * 'accept': '*' } + * ``` + * + * Keys are lowercased. Values are not modified. + * + * In order to support the full spectrum of possible HTTP applications, the Node.js + * HTTP API is very low-level. It deals with stream handling and message + * parsing only. It parses a message into headers and body but it does not + * parse the actual headers or the body. + * + * See `message.headers` for details on how duplicate headers are handled. + * + * The raw headers as they were received are retained in the `rawHeaders`property, which is an array of `[key, value, key2, value2, ...]`. For + * example, the previous message header object might have a `rawHeaders`list like the following: + * + * ```js + * [ 'ConTent-Length', '123456', + * 'content-LENGTH', '123', + * 'content-type', 'text/plain', + * 'CONNECTION', 'keep-alive', + * 'Host', 'example.com', + * 'accepT', '*' ] + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http.js) + */ +declare module "http" { + import * as stream from "node:stream"; + import { URL } from "node:url"; + import { LookupOptions } from "node:dns"; + import { EventEmitter } from "node:events"; + import { LookupFunction, Server as NetServer, Socket, TcpSocketConnectOpts } from "node:net"; + // incoming headers will never contain number + interface IncomingHttpHeaders extends NodeJS.Dict { + accept?: string | undefined; + "accept-language"?: string | undefined; + "accept-patch"?: string | undefined; + "accept-ranges"?: string | undefined; + "access-control-allow-credentials"?: string | undefined; + "access-control-allow-headers"?: string | undefined; + "access-control-allow-methods"?: string | undefined; + "access-control-allow-origin"?: string | undefined; + "access-control-expose-headers"?: string | undefined; + "access-control-max-age"?: string | undefined; + "access-control-request-headers"?: string | undefined; + "access-control-request-method"?: string | undefined; + age?: string | undefined; + allow?: string | undefined; + "alt-svc"?: string | undefined; + authorization?: string | undefined; + "cache-control"?: string | undefined; + connection?: string | undefined; + "content-disposition"?: string | undefined; + "content-encoding"?: string | undefined; + "content-language"?: string | undefined; + "content-length"?: string | undefined; + "content-location"?: string | undefined; + "content-range"?: string | undefined; + "content-type"?: string | undefined; + cookie?: string | undefined; + date?: string | undefined; + etag?: string | undefined; + expect?: string | undefined; + expires?: string | undefined; + forwarded?: string | undefined; + from?: string | undefined; + host?: string | undefined; + "if-match"?: string | undefined; + "if-modified-since"?: string | undefined; + "if-none-match"?: string | undefined; + "if-unmodified-since"?: string | undefined; + "last-modified"?: string | undefined; + location?: string | undefined; + origin?: string | undefined; + pragma?: string | undefined; + "proxy-authenticate"?: string | undefined; + "proxy-authorization"?: string | undefined; + "public-key-pins"?: string | undefined; + range?: string | undefined; + referer?: string | undefined; + "retry-after"?: string | undefined; + "sec-websocket-accept"?: string | undefined; + "sec-websocket-extensions"?: string | undefined; + "sec-websocket-key"?: string | undefined; + "sec-websocket-protocol"?: string | undefined; + "sec-websocket-version"?: string | undefined; + "set-cookie"?: string[] | undefined; + "strict-transport-security"?: string | undefined; + tk?: string | undefined; + trailer?: string | undefined; + "transfer-encoding"?: string | undefined; + upgrade?: string | undefined; + "user-agent"?: string | undefined; + vary?: string | undefined; + via?: string | undefined; + warning?: string | undefined; + "www-authenticate"?: string | undefined; + } + // outgoing headers allows numbers (as they are converted internally to strings) + type OutgoingHttpHeader = number | string | string[]; + interface OutgoingHttpHeaders extends NodeJS.Dict { + accept?: string | string[] | undefined; + "accept-charset"?: string | string[] | undefined; + "accept-encoding"?: string | string[] | undefined; + "accept-language"?: string | string[] | undefined; + "accept-ranges"?: string | undefined; + "access-control-allow-credentials"?: string | undefined; + "access-control-allow-headers"?: string | undefined; + "access-control-allow-methods"?: string | undefined; + "access-control-allow-origin"?: string | undefined; + "access-control-expose-headers"?: string | undefined; + "access-control-max-age"?: string | undefined; + "access-control-request-headers"?: string | undefined; + "access-control-request-method"?: string | undefined; + age?: string | undefined; + allow?: string | undefined; + authorization?: string | undefined; + "cache-control"?: string | undefined; + "cdn-cache-control"?: string | undefined; + connection?: string | string[] | undefined; + "content-disposition"?: string | undefined; + "content-encoding"?: string | undefined; + "content-language"?: string | undefined; + "content-length"?: string | number | undefined; + "content-location"?: string | undefined; + "content-range"?: string | undefined; + "content-security-policy"?: string | undefined; + "content-security-policy-report-only"?: string | undefined; + cookie?: string | string[] | undefined; + dav?: string | string[] | undefined; + dnt?: string | undefined; + date?: string | undefined; + etag?: string | undefined; + expect?: string | undefined; + expires?: string | undefined; + forwarded?: string | undefined; + from?: string | undefined; + host?: string | undefined; + "if-match"?: string | undefined; + "if-modified-since"?: string | undefined; + "if-none-match"?: string | undefined; + "if-range"?: string | undefined; + "if-unmodified-since"?: string | undefined; + "last-modified"?: string | undefined; + link?: string | string[] | undefined; + location?: string | undefined; + "max-forwards"?: string | undefined; + origin?: string | undefined; + prgama?: string | string[] | undefined; + "proxy-authenticate"?: string | string[] | undefined; + "proxy-authorization"?: string | undefined; + "public-key-pins"?: string | undefined; + "public-key-pins-report-only"?: string | undefined; + range?: string | undefined; + referer?: string | undefined; + "referrer-policy"?: string | undefined; + refresh?: string | undefined; + "retry-after"?: string | undefined; + "sec-websocket-accept"?: string | undefined; + "sec-websocket-extensions"?: string | string[] | undefined; + "sec-websocket-key"?: string | undefined; + "sec-websocket-protocol"?: string | string[] | undefined; + "sec-websocket-version"?: string | undefined; + server?: string | undefined; + "set-cookie"?: string | string[] | undefined; + "strict-transport-security"?: string | undefined; + te?: string | undefined; + trailer?: string | undefined; + "transfer-encoding"?: string | undefined; + "user-agent"?: string | undefined; + upgrade?: string | undefined; + "upgrade-insecure-requests"?: string | undefined; + vary?: string | undefined; + via?: string | string[] | undefined; + warning?: string | undefined; + "www-authenticate"?: string | string[] | undefined; + "x-content-type-options"?: string | undefined; + "x-dns-prefetch-control"?: string | undefined; + "x-frame-options"?: string | undefined; + "x-xss-protection"?: string | undefined; + } + interface ClientRequestArgs { + _defaultAgent?: Agent | undefined; + agent?: Agent | boolean | undefined; + auth?: string | null | undefined; + // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278 + createConnection?: + | ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket) + | undefined; + defaultPort?: number | string | undefined; + family?: number | undefined; + headers?: OutgoingHttpHeaders | undefined; + hints?: LookupOptions["hints"]; + host?: string | null | undefined; + hostname?: string | null | undefined; + insecureHTTPParser?: boolean | undefined; + localAddress?: string | undefined; + localPort?: number | undefined; + lookup?: LookupFunction | undefined; + /** + * @default 16384 + */ + maxHeaderSize?: number | undefined; + method?: string | undefined; + path?: string | null | undefined; + port?: number | string | null | undefined; + protocol?: string | null | undefined; + setHost?: boolean | undefined; + signal?: AbortSignal | undefined; + socketPath?: string | undefined; + timeout?: number | undefined; + uniqueHeaders?: Array | undefined; + joinDuplicateHeaders?: boolean; + } + interface ServerOptions< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + > { + /** + * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`. + */ + IncomingMessage?: Request | undefined; + /** + * Specifies the `ServerResponse` class to be used. Useful for extending the original `ServerResponse`. + */ + ServerResponse?: Response | undefined; + /** + * Sets the timeout value in milliseconds for receiving the entire request from the client. + * @see Server.requestTimeout for more information. + * @default 300000 + * @since v18.0.0 + */ + requestTimeout?: number | undefined; + /** + * It joins the field line values of multiple headers in a request with `, ` instead of discarding the duplicates. + * @default false + * @since v18.14.0 + */ + joinDuplicateHeaders?: boolean; + /** + * The number of milliseconds of inactivity a server needs to wait for additional incoming data, + * after it has finished writing the last response, before a socket will be destroyed. + * @see Server.keepAliveTimeout for more information. + * @default 5000 + * @since v18.0.0 + */ + keepAliveTimeout?: number | undefined; + /** + * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests. + * @default 30000 + */ + connectionsCheckingInterval?: number | undefined; + /** + * Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`. + * This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`. + * Default: @see stream.getDefaultHighWaterMark(). + * @since v20.1.0 + */ + highWaterMark?: number | undefined; + /** + * Use an insecure HTTP parser that accepts invalid HTTP headers when `true`. + * Using the insecure parser should be avoided. + * See --insecure-http-parser for more information. + * @default false + */ + insecureHTTPParser?: boolean | undefined; + /** + * Optionally overrides the value of + * `--max-http-header-size` for requests received by this server, i.e. + * the maximum length of request headers in bytes. + * @default 16384 + * @since v13.3.0 + */ + maxHeaderSize?: number | undefined; + /** + * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received. + * @default true + * @since v16.5.0 + */ + noDelay?: boolean | undefined; + /** + * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received, + * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`. + * @default false + * @since v16.5.0 + */ + keepAlive?: boolean | undefined; + /** + * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket. + * @default 0 + * @since v16.5.0 + */ + keepAliveInitialDelay?: number | undefined; + /** + * A list of response headers that should be sent only once. + * If the header's value is an array, the items will be joined using `; `. + */ + uniqueHeaders?: Array | undefined; + } + type RequestListener< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + > = (req: InstanceType, res: InstanceType & { req: InstanceType }) => void; + /** + * @since v0.1.17 + */ + class Server< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + > extends NetServer { + constructor(requestListener?: RequestListener); + constructor(options: ServerOptions, requestListener?: RequestListener); + /** + * Sets the timeout value for sockets, and emits a `'timeout'` event on + * the Server object, passing the socket as an argument, if a timeout + * occurs. + * + * If there is a `'timeout'` event listener on the Server object, then it + * will be called with the timed-out socket as an argument. + * + * By default, the Server does not timeout sockets. However, if a callback + * is assigned to the Server's `'timeout'` event, timeouts must be handled + * explicitly. + * @since v0.9.12 + * @param [msecs=0 (no timeout)] + */ + setTimeout(msecs?: number, callback?: () => void): this; + setTimeout(callback: () => void): this; + /** + * Limits maximum incoming headers count. If set to 0, no limit will be applied. + * @since v0.7.0 + */ + maxHeadersCount: number | null; + /** + * The maximum number of requests socket can handle + * before closing keep alive connection. + * + * A value of `0` will disable the limit. + * + * When the limit is reached it will set the `Connection` header value to `close`, + * but will not actually close the connection, subsequent requests sent + * after the limit is reached will get `503 Service Unavailable` as a response. + * @since v16.10.0 + */ + maxRequestsPerSocket: number | null; + /** + * The number of milliseconds of inactivity before a socket is presumed + * to have timed out. + * + * A value of `0` will disable the timeout behavior on incoming connections. + * + * The socket timeout logic is set up on connection, so changing this + * value only affects new connections to the server, not any existing connections. + * @since v0.9.12 + */ + timeout: number; + /** + * Limit the amount of time the parser will wait to receive the complete HTTP + * headers. + * + * If the timeout expires, the server responds with status 408 without + * forwarding the request to the request listener and then closes the connection. + * + * It must be set to a non-zero value (e.g. 120 seconds) to protect against + * potential Denial-of-Service attacks in case the server is deployed without a + * reverse proxy in front. + * @since v11.3.0, v10.14.0 + */ + headersTimeout: number; + /** + * The number of milliseconds of inactivity a server needs to wait for additional + * incoming data, after it has finished writing the last response, before a socket + * will be destroyed. If the server receives new data before the keep-alive + * timeout has fired, it will reset the regular inactivity timeout, i.e.,`server.timeout`. + * + * A value of `0` will disable the keep-alive timeout behavior on incoming + * connections. + * A value of `0` makes the http server behave similarly to Node.js versions prior + * to 8.0.0, which did not have a keep-alive timeout. + * + * The socket timeout logic is set up on connection, so changing this value only + * affects new connections to the server, not any existing connections. + * @since v8.0.0 + */ + keepAliveTimeout: number; + /** + * Sets the timeout value in milliseconds for receiving the entire request from + * the client. + * + * If the timeout expires, the server responds with status 408 without + * forwarding the request to the request listener and then closes the connection. + * + * It must be set to a non-zero value (e.g. 120 seconds) to protect against + * potential Denial-of-Service attacks in case the server is deployed without a + * reverse proxy in front. + * @since v14.11.0 + */ + requestTimeout: number; + /** + * Closes all connections connected to this server. + * @since v18.2.0 + */ + closeAllConnections(): void; + /** + * Closes all connections connected to this server which are not sending a request + * or waiting for a response. + * @since v18.2.0 + */ + closeIdleConnections(): void; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connection", listener: (socket: Socket) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "checkContinue", listener: RequestListener): this; + addListener(event: "checkExpectation", listener: RequestListener): this; + addListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + addListener( + event: "connect", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + addListener(event: "dropRequest", listener: (req: InstanceType, socket: stream.Duplex) => void): this; + addListener(event: "request", listener: RequestListener): this; + addListener( + event: "upgrade", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + emit(event: string, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "connection", socket: Socket): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit( + event: "checkContinue", + req: InstanceType, + res: InstanceType & { req: InstanceType }, + ): boolean; + emit( + event: "checkExpectation", + req: InstanceType, + res: InstanceType & { req: InstanceType }, + ): boolean; + emit(event: "clientError", err: Error, socket: stream.Duplex): boolean; + emit(event: "connect", req: InstanceType, socket: stream.Duplex, head: Buffer): boolean; + emit(event: "dropRequest", req: InstanceType, socket: stream.Duplex): boolean; + emit( + event: "request", + req: InstanceType, + res: InstanceType & { req: InstanceType }, + ): boolean; + emit(event: "upgrade", req: InstanceType, socket: stream.Duplex, head: Buffer): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connection", listener: (socket: Socket) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "checkContinue", listener: RequestListener): this; + on(event: "checkExpectation", listener: RequestListener): this; + on(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + on(event: "connect", listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + on(event: "dropRequest", listener: (req: InstanceType, socket: stream.Duplex) => void): this; + on(event: "request", listener: RequestListener): this; + on(event: "upgrade", listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connection", listener: (socket: Socket) => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "checkContinue", listener: RequestListener): this; + once(event: "checkExpectation", listener: RequestListener): this; + once(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + once( + event: "connect", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + once(event: "dropRequest", listener: (req: InstanceType, socket: stream.Duplex) => void): this; + once(event: "request", listener: RequestListener): this; + once( + event: "upgrade", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connection", listener: (socket: Socket) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "checkContinue", listener: RequestListener): this; + prependListener(event: "checkExpectation", listener: RequestListener): this; + prependListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + prependListener( + event: "connect", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + prependListener( + event: "dropRequest", + listener: (req: InstanceType, socket: stream.Duplex) => void, + ): this; + prependListener(event: "request", listener: RequestListener): this; + prependListener( + event: "upgrade", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "checkContinue", listener: RequestListener): this; + prependOnceListener(event: "checkExpectation", listener: RequestListener): this; + prependOnceListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + prependOnceListener( + event: "connect", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + prependOnceListener( + event: "dropRequest", + listener: (req: InstanceType, socket: stream.Duplex) => void, + ): this; + prependOnceListener(event: "request", listener: RequestListener): this; + prependOnceListener( + event: "upgrade", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + } + /** + * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from + * the perspective of the participants of an HTTP transaction. + * @since v0.1.17 + */ + class OutgoingMessage extends stream.Writable { + readonly req: Request; + chunkedEncoding: boolean; + shouldKeepAlive: boolean; + useChunkedEncodingByDefault: boolean; + sendDate: boolean; + /** + * @deprecated Use `writableEnded` instead. + */ + finished: boolean; + /** + * Read-only. `true` if the headers were sent, otherwise `false`. + * @since v0.9.3 + */ + readonly headersSent: boolean; + /** + * Alias of `outgoingMessage.socket`. + * @since v0.3.0 + * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead. + */ + readonly connection: Socket | null; + /** + * Reference to the underlying socket. Usually, users will not want to access + * this property. + * + * After calling `outgoingMessage.end()`, this property will be nulled. + * @since v0.3.0 + */ + readonly socket: Socket | null; + constructor(); + /** + * Once a socket is associated with the message and is connected,`socket.setTimeout()` will be called with `msecs` as the first parameter. + * @since v0.9.12 + * @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event. + */ + setTimeout(msecs: number, callback?: () => void): this; + /** + * Sets a single header value. If the header already exists in the to-be-sent + * headers, its value will be replaced. Use an array of strings to send multiple + * headers with the same name. + * @since v0.4.0 + * @param name Header name + * @param value Header value + */ + setHeader(name: string, value: number | string | readonly string[]): this; + /** + * Append a single header value for the header object. + * + * If the value is an array, this is equivalent of calling this method multiple + * times. + * + * If there were no previous value for the header, this is equivalent of calling `outgoingMessage.setHeader(name, value)`. + * + * Depending of the value of `options.uniqueHeaders` when the client request or the + * server were created, this will end up in the header being sent multiple times or + * a single time with values joined using `; `. + * @since v18.3.0, v16.17.0 + * @param name Header name + * @param value Header value + */ + appendHeader(name: string, value: string | readonly string[]): this; + /** + * Gets the value of the HTTP header with the given name. If that header is not + * set, the returned value will be `undefined`. + * @since v0.4.0 + * @param name Name of header + */ + getHeader(name: string): number | string | string[] | undefined; + /** + * Returns a shallow copy of the current outgoing headers. Since a shallow + * copy is used, array values may be mutated without additional calls to + * various header-related HTTP module methods. The keys of the returned + * object are the header names and the values are the respective header + * values. All header names are lowercase. + * + * The object returned by the `outgoingMessage.getHeaders()` method does + * not prototypically inherit from the JavaScript `Object`. This means that + * typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`, + * and others are not defined and will not work. + * + * ```js + * outgoingMessage.setHeader('Foo', 'bar'); + * outgoingMessage.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); + * + * const headers = outgoingMessage.getHeaders(); + * // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] } + * ``` + * @since v7.7.0 + */ + getHeaders(): OutgoingHttpHeaders; + /** + * Returns an array containing the unique names of the current outgoing headers. + * All names are lowercase. + * @since v7.7.0 + */ + getHeaderNames(): string[]; + /** + * Returns `true` if the header identified by `name` is currently set in the + * outgoing headers. The header name is case-insensitive. + * + * ```js + * const hasContentType = outgoingMessage.hasHeader('content-type'); + * ``` + * @since v7.7.0 + */ + hasHeader(name: string): boolean; + /** + * Removes a header that is queued for implicit sending. + * + * ```js + * outgoingMessage.removeHeader('Content-Encoding'); + * ``` + * @since v0.4.0 + * @param name Header name + */ + removeHeader(name: string): void; + /** + * Adds HTTP trailers (headers but at the end of the message) to the message. + * + * Trailers will **only** be emitted if the message is chunked encoded. If not, + * the trailers will be silently discarded. + * + * HTTP requires the `Trailer` header to be sent to emit trailers, + * with a list of header field names in its value, e.g. + * + * ```js + * message.writeHead(200, { 'Content-Type': 'text/plain', + * 'Trailer': 'Content-MD5' }); + * message.write(fileData); + * message.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' }); + * message.end(); + * ``` + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a `TypeError` being thrown. + * @since v0.3.0 + */ + addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void; + /** + * Flushes the message headers. + * + * For efficiency reason, Node.js normally buffers the message headers + * until `outgoingMessage.end()` is called or the first chunk of message data + * is written. It then tries to pack the headers and data into a single TCP + * packet. + * + * It is usually desired (it saves a TCP round-trip), but not when the first + * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message. + * @since v1.6.0 + */ + flushHeaders(): void; + } + /** + * This object is created internally by an HTTP server, not by the user. It is + * passed as the second parameter to the `'request'` event. + * @since v0.1.17 + */ + class ServerResponse extends OutgoingMessage { + /** + * When using implicit headers (not calling `response.writeHead()` explicitly), + * this property controls the status code that will be sent to the client when + * the headers get flushed. + * + * ```js + * response.statusCode = 404; + * ``` + * + * After response header was sent to the client, this property indicates the + * status code which was sent out. + * @since v0.4.0 + */ + statusCode: number; + /** + * When using implicit headers (not calling `response.writeHead()` explicitly), + * this property controls the status message that will be sent to the client when + * the headers get flushed. If this is left as `undefined` then the standard + * message for the status code will be used. + * + * ```js + * response.statusMessage = 'Not found'; + * ``` + * + * After response header was sent to the client, this property indicates the + * status message which was sent out. + * @since v0.11.8 + */ + statusMessage: string; + /** + * If set to `true`, Node.js will check whether the `Content-Length`header value and the size of the body, in bytes, are equal. + * Mismatching the `Content-Length` header value will result + * in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`. + * @since v18.10.0, v16.18.0 + */ + strictContentLength: boolean; + constructor(req: Request); + assignSocket(socket: Socket): void; + detachSocket(socket: Socket): void; + /** + * Sends an HTTP/1.1 100 Continue message to the client, indicating that + * the request body should be sent. See the `'checkContinue'` event on`Server`. + * @since v0.3.0 + */ + writeContinue(callback?: () => void): void; + /** + * Sends an HTTP/1.1 103 Early Hints message to the client with a Link header, + * indicating that the user agent can preload/preconnect the linked resources. + * The `hints` is an object containing the values of headers to be sent with + * early hints message. The optional `callback` argument will be called when + * the response message has been written. + * + * **Example** + * + * ```js + * const earlyHintsLink = '; rel=preload; as=style'; + * response.writeEarlyHints({ + * 'link': earlyHintsLink, + * }); + * + * const earlyHintsLinks = [ + * '; rel=preload; as=style', + * '; rel=preload; as=script', + * ]; + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * 'x-trace-id': 'id for diagnostics', + * }); + * + * const earlyHintsCallback = () => console.log('early hints message sent'); + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * }, earlyHintsCallback); + * ``` + * @since v18.11.0 + * @param hints An object containing the values of headers + * @param callback Will be called when the response message has been written + */ + writeEarlyHints(hints: Record, callback?: () => void): void; + /** + * Sends a response header to the request. The status code is a 3-digit HTTP + * status code, like `404`. The last argument, `headers`, are the response headers. + * Optionally one can give a human-readable `statusMessage` as the second + * argument. + * + * `headers` may be an `Array` where the keys and values are in the same list. + * It is _not_ a list of tuples. So, the even-numbered offsets are key values, + * and the odd-numbered offsets are the associated values. The array is in the same + * format as `request.rawHeaders`. + * + * Returns a reference to the `ServerResponse`, so that calls can be chained. + * + * ```js + * const body = 'hello world'; + * response + * .writeHead(200, { + * 'Content-Length': Buffer.byteLength(body), + * 'Content-Type': 'text/plain', + * }) + * .end(body); + * ``` + * + * This method must only be called once on a message and it must + * be called before `response.end()` is called. + * + * If `response.write()` or `response.end()` are called before calling + * this, the implicit/mutable headers will be calculated and call this function. + * + * When headers have been set with `response.setHeader()`, they will be merged + * with any headers passed to `response.writeHead()`, with the headers passed + * to `response.writeHead()` given precedence. + * + * If this method is called and `response.setHeader()` has not been called, + * it will directly write the supplied header values onto the network channel + * without caching internally, and the `response.getHeader()` on the header + * will not yield the expected result. If progressive population of headers is + * desired with potential future retrieval and modification, use `response.setHeader()` instead. + * + * ```js + * // Returns content-type = text/plain + * const server = http.createServer((req, res) => { + * res.setHeader('Content-Type', 'text/html'); + * res.setHeader('X-Foo', 'bar'); + * res.writeHead(200, { 'Content-Type': 'text/plain' }); + * res.end('ok'); + * }); + * ``` + * + * `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js + * will check whether `Content-Length` and the length of the body which has + * been transmitted are equal or not. + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a \[`Error`\]\[\] being thrown. + * @since v0.1.30 + */ + writeHead( + statusCode: number, + statusMessage?: string, + headers?: OutgoingHttpHeaders | OutgoingHttpHeader[], + ): this; + writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this; + /** + * Sends a HTTP/1.1 102 Processing message to the client, indicating that + * the request body should be sent. + * @since v10.0.0 + */ + writeProcessing(): void; + } + interface InformationEvent { + statusCode: number; + statusMessage: string; + httpVersion: string; + httpVersionMajor: number; + httpVersionMinor: number; + headers: IncomingHttpHeaders; + rawHeaders: string[]; + } + /** + * This object is created internally and returned from {@link request}. It + * represents an _in-progress_ request whose header has already been queued. The + * header is still mutable using the `setHeader(name, value)`,`getHeader(name)`, `removeHeader(name)` API. The actual header will + * be sent along with the first data chunk or when calling `request.end()`. + * + * To get the response, add a listener for `'response'` to the request object.`'response'` will be emitted from the request object when the response + * headers have been received. The `'response'` event is executed with one + * argument which is an instance of {@link IncomingMessage}. + * + * During the `'response'` event, one can add listeners to the + * response object; particularly to listen for the `'data'` event. + * + * If no `'response'` handler is added, then the response will be + * entirely discarded. However, if a `'response'` event handler is added, + * then the data from the response object **must** be consumed, either by + * calling `response.read()` whenever there is a `'readable'` event, or + * by adding a `'data'` handler, or by calling the `.resume()` method. + * Until the data is consumed, the `'end'` event will not fire. Also, until + * the data is read it will consume memory that can eventually lead to a + * 'process out of memory' error. + * + * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered. + * + * Set `Content-Length` header to limit the response body size. + * If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown, + * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`. + * + * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. + * @since v0.1.17 + */ + class ClientRequest extends OutgoingMessage { + /** + * The `request.aborted` property will be `true` if the request has + * been aborted. + * @since v0.11.14 + * @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead. + */ + aborted: boolean; + /** + * The request host. + * @since v14.5.0, v12.19.0 + */ + host: string; + /** + * The request protocol. + * @since v14.5.0, v12.19.0 + */ + protocol: string; + /** + * When sending request through a keep-alive enabled agent, the underlying socket + * might be reused. But if server closes connection at unfortunate time, client + * may run into a 'ECONNRESET' error. + * + * ```js + * import http from 'node:http'; + * + * // Server has a 5 seconds keep-alive timeout by default + * http + * .createServer((req, res) => { + * res.write('hello\n'); + * res.end(); + * }) + * .listen(3000); + * + * setInterval(() => { + * // Adapting a keep-alive agent + * http.get('http://localhost:3000', { agent }, (res) => { + * res.on('data', (data) => { + * // Do nothing + * }); + * }); + * }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout + * ``` + * + * By marking a request whether it reused socket or not, we can do + * automatic error retry base on it. + * + * ```js + * import http from 'node:http'; + * const agent = new http.Agent({ keepAlive: true }); + * + * function retriableRequest() { + * const req = http + * .get('http://localhost:3000', { agent }, (res) => { + * // ... + * }) + * .on('error', (err) => { + * // Check if retry is needed + * if (req.reusedSocket && err.code === 'ECONNRESET') { + * retriableRequest(); + * } + * }); + * } + * + * retriableRequest(); + * ``` + * @since v13.0.0, v12.16.0 + */ + reusedSocket: boolean; + /** + * Limits maximum response headers count. If set to 0, no limit will be applied. + */ + maxHeadersCount: number; + constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void); + /** + * The request method. + * @since v0.1.97 + */ + method: string; + /** + * The request path. + * @since v0.4.0 + */ + path: string; + /** + * Marks the request as aborting. Calling this will cause remaining data + * in the response to be dropped and the socket to be destroyed. + * @since v0.3.8 + * @deprecated Since v14.1.0,v13.14.0 - Use `destroy` instead. + */ + abort(): void; + onSocket(socket: Socket): void; + /** + * Once a socket is assigned to this request and is connected `socket.setTimeout()` will be called. + * @since v0.5.9 + * @param timeout Milliseconds before a request times out. + * @param callback Optional function to be called when a timeout occurs. Same as binding to the `'timeout'` event. + */ + setTimeout(timeout: number, callback?: () => void): this; + /** + * Once a socket is assigned to this request and is connected `socket.setNoDelay()` will be called. + * @since v0.5.9 + */ + setNoDelay(noDelay?: boolean): void; + /** + * Once a socket is assigned to this request and is connected `socket.setKeepAlive()` will be called. + * @since v0.5.9 + */ + setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; + /** + * Returns an array containing the unique names of the current outgoing raw + * headers. Header names are returned with their exact casing being set. + * + * ```js + * request.setHeader('Foo', 'bar'); + * request.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); + * + * const headerNames = request.getRawHeaderNames(); + * // headerNames === ['Foo', 'Set-Cookie'] + * ``` + * @since v15.13.0, v14.17.0 + */ + getRawHeaderNames(): string[]; + /** + * @deprecated + */ + addListener(event: "abort", listener: () => void): this; + addListener( + event: "connect", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + addListener(event: "continue", listener: () => void): this; + addListener(event: "information", listener: (info: InformationEvent) => void): this; + addListener(event: "response", listener: (response: IncomingMessage) => void): this; + addListener(event: "socket", listener: (socket: Socket) => void): this; + addListener(event: "timeout", listener: () => void): this; + addListener( + event: "upgrade", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pipe", listener: (src: stream.Readable) => void): this; + addListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + /** + * @deprecated + */ + on(event: "abort", listener: () => void): this; + on(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; + on(event: "continue", listener: () => void): this; + on(event: "information", listener: (info: InformationEvent) => void): this; + on(event: "response", listener: (response: IncomingMessage) => void): this; + on(event: "socket", listener: (socket: Socket) => void): this; + on(event: "timeout", listener: () => void): this; + on(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + /** + * @deprecated + */ + once(event: "abort", listener: () => void): this; + once(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; + once(event: "continue", listener: () => void): this; + once(event: "information", listener: (info: InformationEvent) => void): this; + once(event: "response", listener: (response: IncomingMessage) => void): this; + once(event: "socket", listener: (socket: Socket) => void): this; + once(event: "timeout", listener: () => void): this; + once(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + /** + * @deprecated + */ + prependListener(event: "abort", listener: () => void): this; + prependListener( + event: "connect", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + prependListener(event: "continue", listener: () => void): this; + prependListener(event: "information", listener: (info: InformationEvent) => void): this; + prependListener(event: "response", listener: (response: IncomingMessage) => void): this; + prependListener(event: "socket", listener: (socket: Socket) => void): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener( + event: "upgrade", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + /** + * @deprecated + */ + prependOnceListener(event: "abort", listener: () => void): this; + prependOnceListener( + event: "connect", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + prependOnceListener(event: "continue", listener: () => void): this; + prependOnceListener(event: "information", listener: (info: InformationEvent) => void): this; + prependOnceListener(event: "response", listener: (response: IncomingMessage) => void): this; + prependOnceListener(event: "socket", listener: (socket: Socket) => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener( + event: "upgrade", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to + * access response + * status, headers, and data. + * + * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to + * parse and emit the incoming HTTP headers and payload, as the underlying socket + * may be reused multiple times in case of keep-alive. + * @since v0.1.17 + */ + class IncomingMessage extends stream.Readable { + constructor(socket: Socket); + /** + * The `message.aborted` property will be `true` if the request has + * been aborted. + * @since v10.1.0 + * @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from stream.Readable. + */ + aborted: boolean; + /** + * In case of server request, the HTTP version sent by the client. In the case of + * client response, the HTTP version of the connected-to server. + * Probably either `'1.1'` or `'1.0'`. + * + * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second. + * @since v0.1.1 + */ + httpVersion: string; + httpVersionMajor: number; + httpVersionMinor: number; + /** + * The `message.complete` property will be `true` if a complete HTTP message has + * been received and successfully parsed. + * + * This property is particularly useful as a means of determining if a client or + * server fully transmitted a message before a connection was terminated: + * + * ```js + * const req = http.request({ + * host: '127.0.0.1', + * port: 8080, + * method: 'POST', + * }, (res) => { + * res.resume(); + * res.on('end', () => { + * if (!res.complete) + * console.error( + * 'The connection was terminated while the message was still being sent'); + * }); + * }); + * ``` + * @since v0.3.0 + */ + complete: boolean; + /** + * Alias for `message.socket`. + * @since v0.1.90 + * @deprecated Since v16.0.0 - Use `socket`. + */ + connection: Socket; + /** + * The `net.Socket` object associated with the connection. + * + * With HTTPS support, use `request.socket.getPeerCertificate()` to obtain the + * client's authentication details. + * + * This property is guaranteed to be an instance of the `net.Socket` class, + * a subclass of `stream.Duplex`, unless the user specified a socket + * type other than `net.Socket` or internally nulled. + * @since v0.3.0 + */ + socket: Socket; + /** + * The request/response headers object. + * + * Key-value pairs of header names and values. Header names are lower-cased. + * + * ```js + * // Prints something like: + * // + * // { 'user-agent': 'curl/7.22.0', + * // host: '127.0.0.1:8000', + * // accept: '*' } + * console.log(request.headers); + * ``` + * + * Duplicates in raw headers are handled in the following ways, depending on the + * header name: + * + * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`, + * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded. + * To allow duplicate values of the headers listed above to be joined, + * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more + * information. + * * `set-cookie` is always an array. Duplicates are added to the array. + * * For duplicate `cookie` headers, the values are joined together with `; `. + * * For all other headers, the values are joined together with `, `. + * @since v0.1.5 + */ + headers: IncomingHttpHeaders; + /** + * Similar to `message.headers`, but there is no join logic and the values are + * always arrays of strings, even for headers received just once. + * + * ```js + * // Prints something like: + * // + * // { 'user-agent': ['curl/7.22.0'], + * // host: ['127.0.0.1:8000'], + * // accept: ['*'] } + * console.log(request.headersDistinct); + * ``` + * @since v18.3.0, v16.17.0 + */ + headersDistinct: NodeJS.Dict; + /** + * The raw request/response headers list exactly as they were received. + * + * The keys and values are in the same list. It is _not_ a + * list of tuples. So, the even-numbered offsets are key values, and the + * odd-numbered offsets are the associated values. + * + * Header names are not lowercased, and duplicates are not merged. + * + * ```js + * // Prints something like: + * // + * // [ 'user-agent', + * // 'this is invalid because there can be only one', + * // 'User-Agent', + * // 'curl/7.22.0', + * // 'Host', + * // '127.0.0.1:8000', + * // 'ACCEPT', + * // '*' ] + * console.log(request.rawHeaders); + * ``` + * @since v0.11.6 + */ + rawHeaders: string[]; + /** + * The request/response trailers object. Only populated at the `'end'` event. + * @since v0.3.0 + */ + trailers: NodeJS.Dict; + /** + * Similar to `message.trailers`, but there is no join logic and the values are + * always arrays of strings, even for headers received just once. + * Only populated at the `'end'` event. + * @since v18.3.0, v16.17.0 + */ + trailersDistinct: NodeJS.Dict; + /** + * The raw request/response trailer keys and values exactly as they were + * received. Only populated at the `'end'` event. + * @since v0.11.6 + */ + rawTrailers: string[]; + /** + * Calls `message.socket.setTimeout(msecs, callback)`. + * @since v0.5.9 + */ + setTimeout(msecs: number, callback?: () => void): this; + /** + * **Only valid for request obtained from {@link Server}.** + * + * The request method as a string. Read only. Examples: `'GET'`, `'DELETE'`. + * @since v0.1.1 + */ + method?: string | undefined; + /** + * **Only valid for request obtained from {@link Server}.** + * + * Request URL string. This contains only the URL that is present in the actual + * HTTP request. Take the following request: + * + * ```http + * GET /status?name=ryan HTTP/1.1 + * Accept: text/plain + * ``` + * + * To parse the URL into its parts: + * + * ```js + * new URL(request.url, `http://${request.headers.host}`); + * ``` + * + * When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`: + * + * ```console + * $ node + * > new URL(request.url, `http://${request.headers.host}`) + * URL { + * href: 'http://localhost:3000/status?name=ryan', + * origin: 'http://localhost:3000', + * protocol: 'http:', + * username: '', + * password: '', + * host: 'localhost:3000', + * hostname: 'localhost', + * port: '3000', + * pathname: '/status', + * search: '?name=ryan', + * searchParams: URLSearchParams { 'name' => 'ryan' }, + * hash: '' + * } + * ``` + * @since v0.1.90 + */ + url?: string | undefined; + /** + * **Only valid for response obtained from {@link ClientRequest}.** + * + * The 3-digit HTTP response status code. E.G. `404`. + * @since v0.1.1 + */ + statusCode?: number | undefined; + /** + * **Only valid for response obtained from {@link ClientRequest}.** + * + * The HTTP response status message (reason phrase). E.G. `OK` or `Internal Server Error`. + * @since v0.11.10 + */ + statusMessage?: string | undefined; + /** + * Calls `destroy()` on the socket that received the `IncomingMessage`. If `error`is provided, an `'error'` event is emitted on the socket and `error` is passed + * as an argument to any listeners on the event. + * @since v0.3.0 + */ + destroy(error?: Error): this; + } + interface AgentOptions extends Partial { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean | undefined; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number | undefined; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number | undefined; + /** + * Maximum number of sockets allowed for all hosts in total. Each request will use a new socket until the maximum is reached. Default: Infinity. + */ + maxTotalSockets?: number | undefined; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number | undefined; + /** + * Socket timeout in milliseconds. This will set the timeout after the socket is connected. + */ + timeout?: number | undefined; + /** + * Scheduling strategy to apply when picking the next free socket to use. + * @default `lifo` + */ + scheduling?: "fifo" | "lifo" | undefined; + } + /** + * An `Agent` is responsible for managing connection persistence + * and reuse for HTTP clients. It maintains a queue of pending requests + * for a given host and port, reusing a single socket connection for each + * until the queue is empty, at which time the socket is either destroyed + * or put into a pool where it is kept to be used again for requests to the + * same host and port. Whether it is destroyed or pooled depends on the`keepAlive` `option`. + * + * Pooled connections have TCP Keep-Alive enabled for them, but servers may + * still close idle connections, in which case they will be removed from the + * pool and a new connection will be made when a new HTTP request is made for + * that host and port. Servers may also refuse to allow multiple requests + * over the same connection, in which case the connection will have to be + * remade for every request and cannot be pooled. The `Agent` will still make + * the requests to that server, but each one will occur over a new connection. + * + * When a connection is closed by the client or the server, it is removed + * from the pool. Any unused sockets in the pool will be unrefed so as not + * to keep the Node.js process running when there are no outstanding requests. + * (see `socket.unref()`). + * + * It is good practice, to `destroy()` an `Agent` instance when it is no + * longer in use, because unused sockets consume OS resources. + * + * Sockets are removed from an agent when the socket emits either + * a `'close'` event or an `'agentRemove'` event. When intending to keep one + * HTTP request open for a long time without keeping it in the agent, something + * like the following may be done: + * + * ```js + * http.get(options, (res) => { + * // Do stuff + * }).on('socket', (socket) => { + * socket.emit('agentRemove'); + * }); + * ``` + * + * An agent may also be used for an individual request. By providing`{agent: false}` as an option to the `http.get()` or `http.request()`functions, a one-time use `Agent` with default options + * will be used + * for the client connection. + * + * `agent:false`: + * + * ```js + * http.get({ + * hostname: 'localhost', + * port: 80, + * path: '/', + * agent: false, // Create a new agent just for this one request + * }, (res) => { + * // Do stuff with response + * }); + * ``` + * @since v0.3.4 + */ + class Agent extends EventEmitter { + /** + * By default set to 256. For agents with `keepAlive` enabled, this + * sets the maximum number of sockets that will be left open in the free + * state. + * @since v0.11.7 + */ + maxFreeSockets: number; + /** + * By default set to `Infinity`. Determines how many concurrent sockets the agent + * can have open per origin. Origin is the returned value of `agent.getName()`. + * @since v0.3.6 + */ + maxSockets: number; + /** + * By default set to `Infinity`. Determines how many concurrent sockets the agent + * can have open. Unlike `maxSockets`, this parameter applies across all origins. + * @since v14.5.0, v12.19.0 + */ + maxTotalSockets: number; + /** + * An object which contains arrays of sockets currently awaiting use by + * the agent when `keepAlive` is enabled. Do not modify. + * + * Sockets in the `freeSockets` list will be automatically destroyed and + * removed from the array on `'timeout'`. + * @since v0.11.4 + */ + readonly freeSockets: NodeJS.ReadOnlyDict; + /** + * An object which contains arrays of sockets currently in use by the + * agent. Do not modify. + * @since v0.3.6 + */ + readonly sockets: NodeJS.ReadOnlyDict; + /** + * An object which contains queues of requests that have not yet been assigned to + * sockets. Do not modify. + * @since v0.5.9 + */ + readonly requests: NodeJS.ReadOnlyDict; + constructor(opts?: AgentOptions); + /** + * Destroy any sockets that are currently in use by the agent. + * + * It is usually not necessary to do this. However, if using an + * agent with `keepAlive` enabled, then it is best to explicitly shut down + * the agent when it is no longer needed. Otherwise, + * sockets might stay open for quite a long time before the server + * terminates them. + * @since v0.11.4 + */ + destroy(): void; + } + const METHODS: string[]; + const STATUS_CODES: { + [errorCode: number]: string | undefined; + [errorCode: string]: string | undefined; + }; + /** + * Returns a new instance of {@link Server}. + * + * The `requestListener` is a function which is automatically + * added to the `'request'` event. + * + * ```js + * import http from 'node:http'; + * + * // Create a local server to receive data from + * const server = http.createServer((req, res) => { + * res.writeHead(200, { 'Content-Type': 'application/json' }); + * res.end(JSON.stringify({ + * data: 'Hello World!', + * })); + * }); + * + * server.listen(8000); + * ``` + * + * ```js + * import http from 'node:http'; + * + * // Create a local server to receive data from + * const server = http.createServer(); + * + * // Listen to the request event + * server.on('request', (request, res) => { + * res.writeHead(200, { 'Content-Type': 'application/json' }); + * res.end(JSON.stringify({ + * data: 'Hello World!', + * })); + * }); + * + * server.listen(8000); + * ``` + * @since v0.1.13 + */ + function createServer< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + >(requestListener?: RequestListener): Server; + function createServer< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + >( + options: ServerOptions, + requestListener?: RequestListener, + ): Server; + // although RequestOptions are passed as ClientRequestArgs to ClientRequest directly, + // create interface RequestOptions would make the naming more clear to developers + interface RequestOptions extends ClientRequestArgs {} + /** + * `options` in `socket.connect()` are also supported. + * + * Node.js maintains several connections per server to make HTTP requests. + * This function allows one to transparently issue requests. + * + * `url` can be a string or a `URL` object. If `url` is a + * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object. + * + * If both `url` and `options` are specified, the objects are merged, with the`options` properties taking precedence. + * + * The optional `callback` parameter will be added as a one-time listener for + * the `'response'` event. + * + * `http.request()` returns an instance of the {@link ClientRequest} class. The `ClientRequest` instance is a writable stream. If one needs to + * upload a file with a POST request, then write to the `ClientRequest` object. + * + * ```js + * import http from 'node:http'; + * import { Buffer } from 'node:buffer'; + * + * const postData = JSON.stringify({ + * 'msg': 'Hello World!', + * }); + * + * const options = { + * hostname: 'www.google.com', + * port: 80, + * path: '/upload', + * method: 'POST', + * headers: { + * 'Content-Type': 'application/json', + * 'Content-Length': Buffer.byteLength(postData), + * }, + * }; + * + * const req = http.request(options, (res) => { + * console.log(`STATUS: ${res.statusCode}`); + * console.log(`HEADERS: ${JSON.stringify(res.headers)}`); + * res.setEncoding('utf8'); + * res.on('data', (chunk) => { + * console.log(`BODY: ${chunk}`); + * }); + * res.on('end', () => { + * console.log('No more data in response.'); + * }); + * }); + * + * req.on('error', (e) => { + * console.error(`problem with request: ${e.message}`); + * }); + * + * // Write data to request body + * req.write(postData); + * req.end(); + * ``` + * + * In the example `req.end()` was called. With `http.request()` one + * must always call `req.end()` to signify the end of the request - + * even if there is no data being written to the request body. + * + * If any error is encountered during the request (be that with DNS resolution, + * TCP level errors, or actual HTTP parse errors) an `'error'` event is emitted + * on the returned request object. As with all `'error'` events, if no listeners + * are registered the error will be thrown. + * + * There are a few special headers that should be noted. + * + * * Sending a 'Connection: keep-alive' will notify Node.js that the connection to + * the server should be persisted until the next request. + * * Sending a 'Content-Length' header will disable the default chunked encoding. + * * Sending an 'Expect' header will immediately send the request headers. + * Usually, when sending 'Expect: 100-continue', both a timeout and a listener + * for the `'continue'` event should be set. See RFC 2616 Section 8.2.3 for more + * information. + * * Sending an Authorization header will override using the `auth` option + * to compute basic authentication. + * + * Example using a `URL` as `options`: + * + * ```js + * const options = new URL('http://abc:xyz@example.com'); + * + * const req = http.request(options, (res) => { + * // ... + * }); + * ``` + * + * In a successful request, the following events will be emitted in the following + * order: + * + * * `'socket'` + * * `'response'` + * * `'data'` any number of times, on the `res` object + * (`'data'` will not be emitted at all if the response body is empty, for + * instance, in most redirects) + * * `'end'` on the `res` object + * * `'close'` + * + * In the case of a connection error, the following events will be emitted: + * + * * `'socket'` + * * `'error'` + * * `'close'` + * + * In the case of a premature connection close before the response is received, + * the following events will be emitted in the following order: + * + * * `'socket'` + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'` + * * `'close'` + * + * In the case of a premature connection close after the response is received, + * the following events will be emitted in the following order: + * + * * `'socket'` + * * `'response'` + * * `'data'` any number of times, on the `res` object + * * (connection closed here) + * * `'aborted'` on the `res` object + * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'` + * * `'close'` + * * `'close'` on the `res` object + * + * If `req.destroy()` is called before a socket is assigned, the following + * events will be emitted in the following order: + * + * * (`req.destroy()` called here) + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called + * * `'close'` + * + * If `req.destroy()` is called before the connection succeeds, the following + * events will be emitted in the following order: + * + * * `'socket'` + * * (`req.destroy()` called here) + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called + * * `'close'` + * + * If `req.destroy()` is called after the response is received, the following + * events will be emitted in the following order: + * + * * `'socket'` + * * `'response'` + * * `'data'` any number of times, on the `res` object + * * (`req.destroy()` called here) + * * `'aborted'` on the `res` object + * * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called + * * `'close'` + * * `'close'` on the `res` object + * + * If `req.abort()` is called before a socket is assigned, the following + * events will be emitted in the following order: + * + * * (`req.abort()` called here) + * * `'abort'` + * * `'close'` + * + * If `req.abort()` is called before the connection succeeds, the following + * events will be emitted in the following order: + * + * * `'socket'` + * * (`req.abort()` called here) + * * `'abort'` + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'` + * * `'close'` + * + * If `req.abort()` is called after the response is received, the following + * events will be emitted in the following order: + * + * * `'socket'` + * * `'response'` + * * `'data'` any number of times, on the `res` object + * * (`req.abort()` called here) + * * `'abort'` + * * `'aborted'` on the `res` object + * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`. + * * `'close'` + * * `'close'` on the `res` object + * + * Setting the `timeout` option or using the `setTimeout()` function will + * not abort the request or do anything besides add a `'timeout'` event. + * + * Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the + * request. Specifically, the `'error'` event will be emitted with an error with + * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided. + * @since v0.3.6 + */ + function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; + function request( + url: string | URL, + options: RequestOptions, + callback?: (res: IncomingMessage) => void, + ): ClientRequest; + /** + * Since most requests are GET requests without bodies, Node.js provides this + * convenience method. The only difference between this method and {@link request} is that it sets the method to GET by default and calls `req.end()`automatically. The callback must take care to + * consume the response + * data for reasons stated in {@link ClientRequest} section. + * + * The `callback` is invoked with a single argument that is an instance of {@link IncomingMessage}. + * + * JSON fetching example: + * + * ```js + * http.get('http://localhost:8000/', (res) => { + * const { statusCode } = res; + * const contentType = res.headers['content-type']; + * + * let error; + * // Any 2xx status code signals a successful response but + * // here we're only checking for 200. + * if (statusCode !== 200) { + * error = new Error('Request Failed.\n' + + * `Status Code: ${statusCode}`); + * } else if (!/^application\/json/.test(contentType)) { + * error = new Error('Invalid content-type.\n' + + * `Expected application/json but received ${contentType}`); + * } + * if (error) { + * console.error(error.message); + * // Consume response data to free up memory + * res.resume(); + * return; + * } + * + * res.setEncoding('utf8'); + * let rawData = ''; + * res.on('data', (chunk) => { rawData += chunk; }); + * res.on('end', () => { + * try { + * const parsedData = JSON.parse(rawData); + * console.log(parsedData); + * } catch (e) { + * console.error(e.message); + * } + * }); + * }).on('error', (e) => { + * console.error(`Got error: ${e.message}`); + * }); + * + * // Create a local server to receive data from + * const server = http.createServer((req, res) => { + * res.writeHead(200, { 'Content-Type': 'application/json' }); + * res.end(JSON.stringify({ + * data: 'Hello World!', + * })); + * }); + * + * server.listen(8000); + * ``` + * @since v0.3.6 + * @param options Accepts the same `options` as {@link request}, with the method set to GET by default. + */ + function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; + function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + /** + * Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called. + * + * Passing illegal value as `name` will result in a `TypeError` being thrown, + * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`. + * + * It is not necessary to use this method before passing headers to an HTTP request + * or response. The HTTP module will automatically validate such headers. + * Examples: + * + * Example: + * + * ```js + * import { validateHeaderName } from 'node:http'; + * + * try { + * validateHeaderName(''); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN' + * console.error(err.message); // --> 'Header name must be a valid HTTP token [""]' + * } + * ``` + * @since v14.3.0 + * @param [label='Header name'] Label for error message. + */ + function validateHeaderName(name: string): void; + /** + * Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called. + * + * Passing illegal value as `value` will result in a `TypeError` being thrown. + * + * * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`. + * * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`. + * + * It is not necessary to use this method before passing headers to an HTTP request + * or response. The HTTP module will automatically validate such headers. + * + * Examples: + * + * ```js + * import { validateHeaderValue } from 'node:http'; + * + * try { + * validateHeaderValue('x-my-header', undefined); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true + * console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"' + * } + * + * try { + * validateHeaderValue('x-my-header', 'oʊmɪɡə'); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code === 'ERR_INVALID_CHAR'); // --> true + * console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]' + * } + * ``` + * @since v14.3.0 + * @param name Header name + * @param value Header value + */ + function validateHeaderValue(name: string, value: string): void; + /** + * Set the maximum number of idle HTTP parsers. + * @since v18.8.0, v16.18.0 + * @param [max=1000] + */ + function setMaxIdleHTTPParsers(max: number): void; + let globalAgent: Agent; + /** + * Read-only property specifying the maximum allowed size of HTTP headers in bytes. + * Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option. + */ + const maxHeaderSize: number; +} +declare module "node:http" { + export * from "http"; +} diff --git a/node_modules/@types/node/http2.d.ts b/node_modules/@types/node/http2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3b3e8ec4fe80a643325e3b37c287bcdb4c9e2f5 --- /dev/null +++ b/node_modules/@types/node/http2.d.ts @@ -0,0 +1,2382 @@ +/** + * The `node:http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. + * It can be accessed using: + * + * ```js + * const http2 = require('node:http2'); + * ``` + * @since v8.4.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http2.js) + */ +declare module "http2" { + import EventEmitter = require("node:events"); + import * as fs from "node:fs"; + import * as net from "node:net"; + import * as stream from "node:stream"; + import * as tls from "node:tls"; + import * as url from "node:url"; + import { + IncomingHttpHeaders as Http1IncomingHttpHeaders, + IncomingMessage, + OutgoingHttpHeaders, + ServerResponse, + } from "node:http"; + export { OutgoingHttpHeaders } from "node:http"; + export interface IncomingHttpStatusHeader { + ":status"?: number | undefined; + } + export interface IncomingHttpHeaders extends Http1IncomingHttpHeaders { + ":path"?: string | undefined; + ":method"?: string | undefined; + ":authority"?: string | undefined; + ":scheme"?: string | undefined; + } + // Http2Stream + export interface StreamPriorityOptions { + exclusive?: boolean | undefined; + parent?: number | undefined; + weight?: number | undefined; + silent?: boolean | undefined; + } + export interface StreamState { + localWindowSize?: number | undefined; + state?: number | undefined; + localClose?: number | undefined; + remoteClose?: number | undefined; + sumDependencyWeight?: number | undefined; + weight?: number | undefined; + } + export interface ServerStreamResponseOptions { + endStream?: boolean | undefined; + waitForTrailers?: boolean | undefined; + } + export interface StatOptions { + offset: number; + length: number; + } + export interface ServerStreamFileResponseOptions { + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + statCheck?(stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions): void | boolean; + waitForTrailers?: boolean | undefined; + offset?: number | undefined; + length?: number | undefined; + } + export interface ServerStreamFileResponseOptionsWithError extends ServerStreamFileResponseOptions { + onError?(err: NodeJS.ErrnoException): void; + } + export interface Http2Stream extends stream.Duplex { + /** + * Set to `true` if the `Http2Stream` instance was aborted abnormally. When set, + * the `'aborted'` event will have been emitted. + * @since v8.4.0 + */ + readonly aborted: boolean; + /** + * This property shows the number of characters currently buffered to be written. + * See `net.Socket.bufferSize` for details. + * @since v11.2.0, v10.16.0 + */ + readonly bufferSize: number; + /** + * Set to `true` if the `Http2Stream` instance has been closed. + * @since v9.4.0 + */ + readonly closed: boolean; + /** + * Set to `true` if the `Http2Stream` instance has been destroyed and is no longer + * usable. + * @since v8.4.0 + */ + readonly destroyed: boolean; + /** + * Set to `true` if the `END_STREAM` flag was set in the request or response + * HEADERS frame received, indicating that no additional data should be received + * and the readable side of the `Http2Stream` will be closed. + * @since v10.11.0 + */ + readonly endAfterHeaders: boolean; + /** + * The numeric stream identifier of this `Http2Stream` instance. Set to `undefined`if the stream identifier has not yet been assigned. + * @since v8.4.0 + */ + readonly id?: number | undefined; + /** + * Set to `true` if the `Http2Stream` instance has not yet been assigned a + * numeric stream identifier. + * @since v9.4.0 + */ + readonly pending: boolean; + /** + * Set to the `RST_STREAM` `error code` reported when the `Http2Stream` is + * destroyed after either receiving an `RST_STREAM` frame from the connected peer, + * calling `http2stream.close()`, or `http2stream.destroy()`. Will be`undefined` if the `Http2Stream` has not been closed. + * @since v8.4.0 + */ + readonly rstCode: number; + /** + * An object containing the outbound headers sent for this `Http2Stream`. + * @since v9.5.0 + */ + readonly sentHeaders: OutgoingHttpHeaders; + /** + * An array of objects containing the outbound informational (additional) headers + * sent for this `Http2Stream`. + * @since v9.5.0 + */ + readonly sentInfoHeaders?: OutgoingHttpHeaders[] | undefined; + /** + * An object containing the outbound trailers sent for this `HttpStream`. + * @since v9.5.0 + */ + readonly sentTrailers?: OutgoingHttpHeaders | undefined; + /** + * A reference to the `Http2Session` instance that owns this `Http2Stream`. The + * value will be `undefined` after the `Http2Stream` instance is destroyed. + * @since v8.4.0 + */ + readonly session: Http2Session | undefined; + /** + * Provides miscellaneous information about the current state of the`Http2Stream`. + * + * A current state of this `Http2Stream`. + * @since v8.4.0 + */ + readonly state: StreamState; + /** + * Closes the `Http2Stream` instance by sending an `RST_STREAM` frame to the + * connected HTTP/2 peer. + * @since v8.4.0 + * @param [code=http2.constants.NGHTTP2_NO_ERROR] Unsigned 32-bit integer identifying the error code. + * @param callback An optional function registered to listen for the `'close'` event. + */ + close(code?: number, callback?: () => void): void; + /** + * Updates the priority for this `Http2Stream` instance. + * @since v8.4.0 + */ + priority(options: StreamPriorityOptions): void; + /** + * ```js + * const http2 = require('node:http2'); + * const client = http2.connect('http://example.org:8000'); + * const { NGHTTP2_CANCEL } = http2.constants; + * const req = client.request({ ':path': '/' }); + * + * // Cancel the stream if there's no activity after 5 seconds + * req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL)); + * ``` + * @since v8.4.0 + */ + setTimeout(msecs: number, callback?: () => void): void; + /** + * Sends a trailing `HEADERS` frame to the connected HTTP/2 peer. This method + * will cause the `Http2Stream` to be immediately closed and must only be + * called after the `'wantTrailers'` event has been emitted. When sending a + * request or sending a response, the `options.waitForTrailers` option must be set + * in order to keep the `Http2Stream` open after the final `DATA` frame so that + * trailers can be sent. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respond(undefined, { waitForTrailers: true }); + * stream.on('wantTrailers', () => { + * stream.sendTrailers({ xyz: 'abc' }); + * }); + * stream.end('Hello World'); + * }); + * ``` + * + * The HTTP/1 specification forbids trailers from containing HTTP/2 pseudo-header + * fields (e.g. `':method'`, `':path'`, etc). + * @since v10.0.0 + */ + sendTrailers(headers: OutgoingHttpHeaders): void; + addListener(event: "aborted", listener: () => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: Buffer | string) => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + addListener(event: "pipe", listener: (src: stream.Readable) => void): this; + addListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + addListener(event: "streamClosed", listener: (code: number) => void): this; + addListener(event: "timeout", listener: () => void): this; + addListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + addListener(event: "wantTrailers", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "aborted"): boolean; + emit(event: "close"): boolean; + emit(event: "data", chunk: Buffer | string): boolean; + emit(event: "drain"): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "frameError", frameType: number, errorCode: number): boolean; + emit(event: "pipe", src: stream.Readable): boolean; + emit(event: "unpipe", src: stream.Readable): boolean; + emit(event: "streamClosed", code: number): boolean; + emit(event: "timeout"): boolean; + emit(event: "trailers", trailers: IncomingHttpHeaders, flags: number): boolean; + emit(event: "wantTrailers"): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "aborted", listener: () => void): this; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: Buffer | string) => void): this; + on(event: "drain", listener: () => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + on(event: "streamClosed", listener: (code: number) => void): this; + on(event: "timeout", listener: () => void): this; + on(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + on(event: "wantTrailers", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "aborted", listener: () => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: Buffer | string) => void): this; + once(event: "drain", listener: () => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + once(event: "streamClosed", listener: (code: number) => void): this; + once(event: "timeout", listener: () => void): this; + once(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + once(event: "wantTrailers", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "aborted", listener: () => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + prependListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "streamClosed", listener: (code: number) => void): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + prependListener(event: "wantTrailers", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "aborted", listener: () => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "streamClosed", listener: (code: number) => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + prependOnceListener(event: "wantTrailers", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface ClientHttp2Stream extends Http2Stream { + addListener(event: "continue", listener: () => {}): this; + addListener( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + addListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + addListener( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "continue"): boolean; + emit(event: "headers", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean; + emit(event: "push", headers: IncomingHttpHeaders, flags: number): boolean; + emit(event: "response", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "continue", listener: () => {}): this; + on( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + on( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "continue", listener: () => {}): this; + once( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + once( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "continue", listener: () => {}): this; + prependListener( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + prependListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + prependListener( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "continue", listener: () => {}): this; + prependOnceListener( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + prependOnceListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + prependOnceListener( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface ServerHttp2Stream extends Http2Stream { + /** + * True if headers were sent, false otherwise (read-only). + * @since v8.4.0 + */ + readonly headersSent: boolean; + /** + * Read-only property mapped to the `SETTINGS_ENABLE_PUSH` flag of the remote + * client's most recent `SETTINGS` frame. Will be `true` if the remote peer + * accepts push streams, `false` otherwise. Settings are the same for every`Http2Stream` in the same `Http2Session`. + * @since v8.4.0 + */ + readonly pushAllowed: boolean; + /** + * Sends an additional informational `HEADERS` frame to the connected HTTP/2 peer. + * @since v8.4.0 + */ + additionalHeaders(headers: OutgoingHttpHeaders): void; + /** + * Initiates a push stream. The callback is invoked with the new `Http2Stream`instance created for the push stream passed as the second argument, or an`Error` passed as the first argument. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respond({ ':status': 200 }); + * stream.pushStream({ ':path': '/' }, (err, pushStream, headers) => { + * if (err) throw err; + * pushStream.respond({ ':status': 200 }); + * pushStream.end('some pushed data'); + * }); + * stream.end('some data'); + * }); + * ``` + * + * Setting the weight of a push stream is not allowed in the `HEADERS` frame. Pass + * a `weight` value to `http2stream.priority` with the `silent` option set to`true` to enable server-side bandwidth balancing between concurrent streams. + * + * Calling `http2stream.pushStream()` from within a pushed stream is not permitted + * and will throw an error. + * @since v8.4.0 + * @param callback Callback that is called once the push stream has been initiated. + */ + pushStream( + headers: OutgoingHttpHeaders, + callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void, + ): void; + pushStream( + headers: OutgoingHttpHeaders, + options?: StreamPriorityOptions, + callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void, + ): void; + /** + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respond({ ':status': 200 }); + * stream.end('some data'); + * }); + * ``` + * + * Initiates a response. When the `options.waitForTrailers` option is set, the`'wantTrailers'` event will be emitted immediately after queuing the last chunk + * of payload data to be sent. The `http2stream.sendTrailers()` method can then be + * used to sent trailing header fields to the peer. + * + * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically + * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respond({ ':status': 200 }, { waitForTrailers: true }); + * stream.on('wantTrailers', () => { + * stream.sendTrailers({ ABC: 'some value to send' }); + * }); + * stream.end('some data'); + * }); + * ``` + * @since v8.4.0 + */ + respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void; + /** + * Initiates a response whose data is read from the given file descriptor. No + * validation is performed on the given file descriptor. If an error occurs while + * attempting to read data using the file descriptor, the `Http2Stream` will be + * closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR` code. + * + * When used, the `Http2Stream` object's `Duplex` interface will be closed + * automatically. + * + * ```js + * const http2 = require('node:http2'); + * const fs = require('node:fs'); + * + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * const fd = fs.openSync('/some/file', 'r'); + * + * const stat = fs.fstatSync(fd); + * const headers = { + * 'content-length': stat.size, + * 'last-modified': stat.mtime.toUTCString(), + * 'content-type': 'text/plain; charset=utf-8', + * }; + * stream.respondWithFD(fd, headers); + * stream.on('close', () => fs.closeSync(fd)); + * }); + * ``` + * + * The optional `options.statCheck` function may be specified to give user code + * an opportunity to set additional content headers based on the `fs.Stat` details + * of the given fd. If the `statCheck` function is provided, the`http2stream.respondWithFD()` method will perform an `fs.fstat()` call to + * collect details on the provided file descriptor. + * + * The `offset` and `length` options may be used to limit the response to a + * specific range subset. This can be used, for instance, to support HTTP Range + * requests. + * + * The file descriptor or `FileHandle` is not closed when the stream is closed, + * so it will need to be closed manually once it is no longer needed. + * Using the same file descriptor concurrently for multiple streams + * is not supported and may result in data loss. Re-using a file descriptor + * after a stream has finished is supported. + * + * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event + * will be emitted immediately after queuing the last chunk of payload data to be + * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing + * header fields to the peer. + * + * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically + * close when the final `DATA` frame is transmitted. User code _must_ call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. + * + * ```js + * const http2 = require('node:http2'); + * const fs = require('node:fs'); + * + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * const fd = fs.openSync('/some/file', 'r'); + * + * const stat = fs.fstatSync(fd); + * const headers = { + * 'content-length': stat.size, + * 'last-modified': stat.mtime.toUTCString(), + * 'content-type': 'text/plain; charset=utf-8', + * }; + * stream.respondWithFD(fd, headers, { waitForTrailers: true }); + * stream.on('wantTrailers', () => { + * stream.sendTrailers({ ABC: 'some value to send' }); + * }); + * + * stream.on('close', () => fs.closeSync(fd)); + * }); + * ``` + * @since v8.4.0 + * @param fd A readable file descriptor. + */ + respondWithFD( + fd: number | fs.promises.FileHandle, + headers?: OutgoingHttpHeaders, + options?: ServerStreamFileResponseOptions, + ): void; + /** + * Sends a regular file as the response. The `path` must specify a regular file + * or an `'error'` event will be emitted on the `Http2Stream` object. + * + * When used, the `Http2Stream` object's `Duplex` interface will be closed + * automatically. + * + * The optional `options.statCheck` function may be specified to give user code + * an opportunity to set additional content headers based on the `fs.Stat` details + * of the given file: + * + * If an error occurs while attempting to read the file data, the `Http2Stream`will be closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR`code. If the `onError` callback is + * defined, then it will be called. Otherwise + * the stream will be destroyed. + * + * Example using a file path: + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * function statCheck(stat, headers) { + * headers['last-modified'] = stat.mtime.toUTCString(); + * } + * + * function onError(err) { + * // stream.respond() can throw if the stream has been destroyed by + * // the other side. + * try { + * if (err.code === 'ENOENT') { + * stream.respond({ ':status': 404 }); + * } else { + * stream.respond({ ':status': 500 }); + * } + * } catch (err) { + * // Perform actual error handling. + * console.error(err); + * } + * stream.end(); + * } + * + * stream.respondWithFile('/some/file', + * { 'content-type': 'text/plain; charset=utf-8' }, + * { statCheck, onError }); + * }); + * ``` + * + * The `options.statCheck` function may also be used to cancel the send operation + * by returning `false`. For instance, a conditional request may check the stat + * results to determine if the file has been modified to return an appropriate`304` response: + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * function statCheck(stat, headers) { + * // Check the stat here... + * stream.respond({ ':status': 304 }); + * return false; // Cancel the send operation + * } + * stream.respondWithFile('/some/file', + * { 'content-type': 'text/plain; charset=utf-8' }, + * { statCheck }); + * }); + * ``` + * + * The `content-length` header field will be automatically set. + * + * The `offset` and `length` options may be used to limit the response to a + * specific range subset. This can be used, for instance, to support HTTP Range + * requests. + * + * The `options.onError` function may also be used to handle all the errors + * that could happen before the delivery of the file is initiated. The + * default behavior is to destroy the stream. + * + * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event + * will be emitted immediately after queuing the last chunk of payload data to be + * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing + * header fields to the peer. + * + * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically + * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respondWithFile('/some/file', + * { 'content-type': 'text/plain; charset=utf-8' }, + * { waitForTrailers: true }); + * stream.on('wantTrailers', () => { + * stream.sendTrailers({ ABC: 'some value to send' }); + * }); + * }); + * ``` + * @since v8.4.0 + */ + respondWithFile( + path: string, + headers?: OutgoingHttpHeaders, + options?: ServerStreamFileResponseOptionsWithError, + ): void; + } + // Http2Session + export interface Settings { + headerTableSize?: number | undefined; + enablePush?: boolean | undefined; + initialWindowSize?: number | undefined; + maxFrameSize?: number | undefined; + maxConcurrentStreams?: number | undefined; + maxHeaderListSize?: number | undefined; + enableConnectProtocol?: boolean | undefined; + } + export interface ClientSessionRequestOptions { + endStream?: boolean | undefined; + exclusive?: boolean | undefined; + parent?: number | undefined; + weight?: number | undefined; + waitForTrailers?: boolean | undefined; + signal?: AbortSignal | undefined; + } + export interface SessionState { + effectiveLocalWindowSize?: number | undefined; + effectiveRecvDataLength?: number | undefined; + nextStreamID?: number | undefined; + localWindowSize?: number | undefined; + lastProcStreamID?: number | undefined; + remoteWindowSize?: number | undefined; + outboundQueueSize?: number | undefined; + deflateDynamicTableSize?: number | undefined; + inflateDynamicTableSize?: number | undefined; + } + export interface Http2Session extends EventEmitter { + /** + * Value will be `undefined` if the `Http2Session` is not yet connected to a + * socket, `h2c` if the `Http2Session` is not connected to a `TLSSocket`, or + * will return the value of the connected `TLSSocket`'s own `alpnProtocol`property. + * @since v9.4.0 + */ + readonly alpnProtocol?: string | undefined; + /** + * Will be `true` if this `Http2Session` instance has been closed, otherwise`false`. + * @since v9.4.0 + */ + readonly closed: boolean; + /** + * Will be `true` if this `Http2Session` instance is still connecting, will be set + * to `false` before emitting `connect` event and/or calling the `http2.connect`callback. + * @since v10.0.0 + */ + readonly connecting: boolean; + /** + * Will be `true` if this `Http2Session` instance has been destroyed and must no + * longer be used, otherwise `false`. + * @since v8.4.0 + */ + readonly destroyed: boolean; + /** + * Value is `undefined` if the `Http2Session` session socket has not yet been + * connected, `true` if the `Http2Session` is connected with a `TLSSocket`, + * and `false` if the `Http2Session` is connected to any other kind of socket + * or stream. + * @since v9.4.0 + */ + readonly encrypted?: boolean | undefined; + /** + * A prototype-less object describing the current local settings of this`Http2Session`. The local settings are local to _this_`Http2Session` instance. + * @since v8.4.0 + */ + readonly localSettings: Settings; + /** + * If the `Http2Session` is connected to a `TLSSocket`, the `originSet` property + * will return an `Array` of origins for which the `Http2Session` may be + * considered authoritative. + * + * The `originSet` property is only available when using a secure TLS connection. + * @since v9.4.0 + */ + readonly originSet?: string[] | undefined; + /** + * Indicates whether the `Http2Session` is currently waiting for acknowledgment of + * a sent `SETTINGS` frame. Will be `true` after calling the`http2session.settings()` method. Will be `false` once all sent `SETTINGS`frames have been acknowledged. + * @since v8.4.0 + */ + readonly pendingSettingsAck: boolean; + /** + * A prototype-less object describing the current remote settings of this`Http2Session`. The remote settings are set by the _connected_ HTTP/2 peer. + * @since v8.4.0 + */ + readonly remoteSettings: Settings; + /** + * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but + * limits available methods to ones safe to use with HTTP/2. + * + * `destroy`, `emit`, `end`, `pause`, `read`, `resume`, and `write` will throw + * an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for more information. + * + * `setTimeout` method will be called on this `Http2Session`. + * + * All other interactions will be routed directly to the socket. + * @since v8.4.0 + */ + readonly socket: net.Socket | tls.TLSSocket; + /** + * Provides miscellaneous information about the current state of the`Http2Session`. + * + * An object describing the current status of this `Http2Session`. + * @since v8.4.0 + */ + readonly state: SessionState; + /** + * The `http2session.type` will be equal to`http2.constants.NGHTTP2_SESSION_SERVER` if this `Http2Session` instance is a + * server, and `http2.constants.NGHTTP2_SESSION_CLIENT` if the instance is a + * client. + * @since v8.4.0 + */ + readonly type: number; + /** + * Gracefully closes the `Http2Session`, allowing any existing streams to + * complete on their own and preventing new `Http2Stream` instances from being + * created. Once closed, `http2session.destroy()`_might_ be called if there + * are no open `Http2Stream` instances. + * + * If specified, the `callback` function is registered as a handler for the`'close'` event. + * @since v9.4.0 + */ + close(callback?: () => void): void; + /** + * Immediately terminates the `Http2Session` and the associated `net.Socket` or`tls.TLSSocket`. + * + * Once destroyed, the `Http2Session` will emit the `'close'` event. If `error`is not undefined, an `'error'` event will be emitted immediately before the`'close'` event. + * + * If there are any remaining open `Http2Streams` associated with the`Http2Session`, those will also be destroyed. + * @since v8.4.0 + * @param error An `Error` object if the `Http2Session` is being destroyed due to an error. + * @param code The HTTP/2 error code to send in the final `GOAWAY` frame. If unspecified, and `error` is not undefined, the default is `INTERNAL_ERROR`, otherwise defaults to `NO_ERROR`. + */ + destroy(error?: Error, code?: number): void; + /** + * Transmits a `GOAWAY` frame to the connected peer _without_ shutting down the`Http2Session`. + * @since v9.4.0 + * @param code An HTTP/2 error code + * @param lastStreamID The numeric ID of the last processed `Http2Stream` + * @param opaqueData A `TypedArray` or `DataView` instance containing additional data to be carried within the `GOAWAY` frame. + */ + goaway(code?: number, lastStreamID?: number, opaqueData?: NodeJS.ArrayBufferView): void; + /** + * Sends a `PING` frame to the connected HTTP/2 peer. A `callback` function must + * be provided. The method will return `true` if the `PING` was sent, `false`otherwise. + * + * The maximum number of outstanding (unacknowledged) pings is determined by the`maxOutstandingPings` configuration option. The default maximum is 10. + * + * If provided, the `payload` must be a `Buffer`, `TypedArray`, or `DataView`containing 8 bytes of data that will be transmitted with the `PING` and + * returned with the ping acknowledgment. + * + * The callback will be invoked with three arguments: an error argument that will + * be `null` if the `PING` was successfully acknowledged, a `duration` argument + * that reports the number of milliseconds elapsed since the ping was sent and the + * acknowledgment was received, and a `Buffer` containing the 8-byte `PING`payload. + * + * ```js + * session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => { + * if (!err) { + * console.log(`Ping acknowledged in ${duration} milliseconds`); + * console.log(`With payload '${payload.toString()}'`); + * } + * }); + * ``` + * + * If the `payload` argument is not specified, the default payload will be the + * 64-bit timestamp (little endian) marking the start of the `PING` duration. + * @since v8.9.3 + * @param payload Optional ping payload. + */ + ping(callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean; + ping( + payload: NodeJS.ArrayBufferView, + callback: (err: Error | null, duration: number, payload: Buffer) => void, + ): boolean; + /** + * Calls `ref()` on this `Http2Session`instance's underlying `net.Socket`. + * @since v9.4.0 + */ + ref(): void; + /** + * Sets the local endpoint's window size. + * The `windowSize` is the total window size to set, not + * the delta. + * + * ```js + * const http2 = require('node:http2'); + * + * const server = http2.createServer(); + * const expectedWindowSize = 2 ** 20; + * server.on('connect', (session) => { + * + * // Set local window size to be 2 ** 20 + * session.setLocalWindowSize(expectedWindowSize); + * }); + * ``` + * @since v15.3.0, v14.18.0 + */ + setLocalWindowSize(windowSize: number): void; + /** + * Used to set a callback function that is called when there is no activity on + * the `Http2Session` after `msecs` milliseconds. The given `callback` is + * registered as a listener on the `'timeout'` event. + * @since v8.4.0 + */ + setTimeout(msecs: number, callback?: () => void): void; + /** + * Updates the current local settings for this `Http2Session` and sends a new`SETTINGS` frame to the connected HTTP/2 peer. + * + * Once called, the `http2session.pendingSettingsAck` property will be `true`while the session is waiting for the remote peer to acknowledge the new + * settings. + * + * The new settings will not become effective until the `SETTINGS` acknowledgment + * is received and the `'localSettings'` event is emitted. It is possible to send + * multiple `SETTINGS` frames while acknowledgment is still pending. + * @since v8.4.0 + * @param callback Callback that is called once the session is connected or right away if the session is already connected. + */ + settings( + settings: Settings, + callback?: (err: Error | null, settings: Settings, duration: number) => void, + ): void; + /** + * Calls `unref()` on this `Http2Session`instance's underlying `net.Socket`. + * @since v9.4.0 + */ + unref(): void; + addListener(event: "close", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener( + event: "frameError", + listener: (frameType: number, errorCode: number, streamID: number) => void, + ): this; + addListener( + event: "goaway", + listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void, + ): this; + addListener(event: "localSettings", listener: (settings: Settings) => void): this; + addListener(event: "ping", listener: () => void): this; + addListener(event: "remoteSettings", listener: (settings: Settings) => void): this; + addListener(event: "timeout", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "frameError", frameType: number, errorCode: number, streamID: number): boolean; + emit(event: "goaway", errorCode: number, lastStreamID: number, opaqueData?: Buffer): boolean; + emit(event: "localSettings", settings: Settings): boolean; + emit(event: "ping"): boolean; + emit(event: "remoteSettings", settings: Settings): boolean; + emit(event: "timeout"): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this; + on(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void): this; + on(event: "localSettings", listener: (settings: Settings) => void): this; + on(event: "ping", listener: () => void): this; + on(event: "remoteSettings", listener: (settings: Settings) => void): this; + on(event: "timeout", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this; + once(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void): this; + once(event: "localSettings", listener: (settings: Settings) => void): this; + once(event: "ping", listener: () => void): this; + once(event: "remoteSettings", listener: (settings: Settings) => void): this; + once(event: "timeout", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener( + event: "frameError", + listener: (frameType: number, errorCode: number, streamID: number) => void, + ): this; + prependListener( + event: "goaway", + listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void, + ): this; + prependListener(event: "localSettings", listener: (settings: Settings) => void): this; + prependListener(event: "ping", listener: () => void): this; + prependListener(event: "remoteSettings", listener: (settings: Settings) => void): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener( + event: "frameError", + listener: (frameType: number, errorCode: number, streamID: number) => void, + ): this; + prependOnceListener( + event: "goaway", + listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void, + ): this; + prependOnceListener(event: "localSettings", listener: (settings: Settings) => void): this; + prependOnceListener(event: "ping", listener: () => void): this; + prependOnceListener(event: "remoteSettings", listener: (settings: Settings) => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface ClientHttp2Session extends Http2Session { + /** + * For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`creates and returns an `Http2Stream` instance that can be used to send an + * HTTP/2 request to the connected server. + * + * When a `ClientHttp2Session` is first created, the socket may not yet be + * connected. if `clienthttp2session.request()` is called during this time, the + * actual request will be deferred until the socket is ready to go. + * If the `session` is closed before the actual request be executed, an`ERR_HTTP2_GOAWAY_SESSION` is thrown. + * + * This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`. + * + * ```js + * const http2 = require('node:http2'); + * const clientSession = http2.connect('https://localhost:1234'); + * const { + * HTTP2_HEADER_PATH, + * HTTP2_HEADER_STATUS, + * } = http2.constants; + * + * const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' }); + * req.on('response', (headers) => { + * console.log(headers[HTTP2_HEADER_STATUS]); + * req.on('data', (chunk) => { // .. }); + * req.on('end', () => { // .. }); + * }); + * ``` + * + * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event + * is emitted immediately after queuing the last chunk of payload data to be sent. + * The `http2stream.sendTrailers()` method can then be called to send trailing + * headers to the peer. + * + * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically + * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. + * + * When `options.signal` is set with an `AbortSignal` and then `abort` on the + * corresponding `AbortController` is called, the request will emit an `'error'`event with an `AbortError` error. + * + * The `:method` and `:path` pseudo-headers are not specified within `headers`, + * they respectively default to: + * + * * `:method` \= `'GET'` + * * `:path` \= `/` + * @since v8.4.0 + */ + request(headers?: OutgoingHttpHeaders, options?: ClientSessionRequestOptions): ClientHttp2Stream; + addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + addListener(event: "origin", listener: (origins: string[]) => void): this; + addListener( + event: "connect", + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + addListener( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "altsvc", alt: string, origin: string, stream: number): boolean; + emit(event: "origin", origins: readonly string[]): boolean; + emit(event: "connect", session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket): boolean; + emit( + event: "stream", + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + on(event: "origin", listener: (origins: string[]) => void): this; + on(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this; + on( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + once(event: "origin", listener: (origins: string[]) => void): this; + once( + event: "connect", + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + once( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + prependListener(event: "origin", listener: (origins: string[]) => void): this; + prependListener( + event: "connect", + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + prependListener( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + prependOnceListener(event: "origin", listener: (origins: string[]) => void): this; + prependOnceListener( + event: "connect", + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + prependOnceListener( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface AlternativeServiceOptions { + origin: number | string | url.URL; + } + export interface ServerHttp2Session extends Http2Session { + readonly server: Http2Server | Http2SecureServer; + /** + * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client. + * + * ```js + * const http2 = require('node:http2'); + * + * const server = http2.createServer(); + * server.on('session', (session) => { + * // Set altsvc for origin https://example.org:80 + * session.altsvc('h2=":8000"', 'https://example.org:80'); + * }); + * + * server.on('stream', (stream) => { + * // Set altsvc for a specific stream + * stream.session.altsvc('h2=":8000"', stream.id); + * }); + * ``` + * + * Sending an `ALTSVC` frame with a specific stream ID indicates that the alternate + * service is associated with the origin of the given `Http2Stream`. + * + * The `alt` and origin string _must_ contain only ASCII bytes and are + * strictly interpreted as a sequence of ASCII bytes. The special value `'clear'`may be passed to clear any previously set alternative service for a given + * domain. + * + * When a string is passed for the `originOrStream` argument, it will be parsed as + * a URL and the origin will be derived. For instance, the origin for the + * HTTP URL `'https://example.org/foo/bar'` is the ASCII string`'https://example.org'`. An error will be thrown if either the given string + * cannot be parsed as a URL or if a valid origin cannot be derived. + * + * A `URL` object, or any object with an `origin` property, may be passed as`originOrStream`, in which case the value of the `origin` property will be + * used. The value of the `origin` property _must_ be a properly serialized + * ASCII origin. + * @since v9.4.0 + * @param alt A description of the alternative service configuration as defined by `RFC 7838`. + * @param originOrStream Either a URL string specifying the origin (or an `Object` with an `origin` property) or the numeric identifier of an active `Http2Stream` as given by the + * `http2stream.id` property. + */ + altsvc(alt: string, originOrStream: number | string | url.URL | AlternativeServiceOptions): void; + /** + * Submits an `ORIGIN` frame (as defined by [RFC 8336](https://tools.ietf.org/html/rfc8336)) to the connected client + * to advertise the set of origins for which the server is capable of providing + * authoritative responses. + * + * ```js + * const http2 = require('node:http2'); + * const options = getSecureOptionsSomehow(); + * const server = http2.createSecureServer(options); + * server.on('stream', (stream) => { + * stream.respond(); + * stream.end('ok'); + * }); + * server.on('session', (session) => { + * session.origin('https://example.com', 'https://example.org'); + * }); + * ``` + * + * When a string is passed as an `origin`, it will be parsed as a URL and the + * origin will be derived. For instance, the origin for the HTTP URL`'https://example.org/foo/bar'` is the ASCII string`'https://example.org'`. An error will be thrown if either the given + * string + * cannot be parsed as a URL or if a valid origin cannot be derived. + * + * A `URL` object, or any object with an `origin` property, may be passed as + * an `origin`, in which case the value of the `origin` property will be + * used. The value of the `origin` property _must_ be a properly serialized + * ASCII origin. + * + * Alternatively, the `origins` option may be used when creating a new HTTP/2 + * server using the `http2.createSecureServer()` method: + * + * ```js + * const http2 = require('node:http2'); + * const options = getSecureOptionsSomehow(); + * options.origins = ['https://example.com', 'https://example.org']; + * const server = http2.createSecureServer(options); + * server.on('stream', (stream) => { + * stream.respond(); + * stream.end('ok'); + * }); + * ``` + * @since v10.12.0 + * @param origins One or more URL Strings passed as separate arguments. + */ + origin( + ...origins: Array< + | string + | url.URL + | { + origin: string; + } + > + ): void; + addListener( + event: "connect", + listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + addListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean; + emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this; + on( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once( + event: "connect", + listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + once( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener( + event: "connect", + listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + prependListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener( + event: "connect", + listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + prependOnceListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + // Http2Server + export interface SessionOptions { + maxDeflateDynamicTableSize?: number | undefined; + maxSessionMemory?: number | undefined; + maxHeaderListPairs?: number | undefined; + maxOutstandingPings?: number | undefined; + maxSendHeaderBlockLength?: number | undefined; + paddingStrategy?: number | undefined; + peerMaxConcurrentStreams?: number | undefined; + settings?: Settings | undefined; + /** + * Specifies a timeout in milliseconds that + * a server should wait when an [`'unknownProtocol'`][] is emitted. If the + * socket has not been destroyed by that time the server will destroy it. + * @default 100000 + */ + unknownProtocolTimeout?: number | undefined; + selectPadding?(frameLen: number, maxFrameLen: number): number; + } + export interface ClientSessionOptions extends SessionOptions { + maxReservedRemoteStreams?: number | undefined; + createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined; + protocol?: "http:" | "https:" | undefined; + } + export interface ServerSessionOptions extends SessionOptions { + Http1IncomingMessage?: typeof IncomingMessage | undefined; + Http1ServerResponse?: typeof ServerResponse | undefined; + Http2ServerRequest?: typeof Http2ServerRequest | undefined; + Http2ServerResponse?: typeof Http2ServerResponse | undefined; + } + export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions {} + export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions {} + export interface ServerOptions extends ServerSessionOptions {} + export interface SecureServerOptions extends SecureServerSessionOptions { + allowHTTP1?: boolean | undefined; + origins?: string[] | undefined; + } + interface HTTP2ServerCommon { + setTimeout(msec?: number, callback?: () => void): this; + /** + * Throws ERR_HTTP2_INVALID_SETTING_VALUE for invalid settings values. + * Throws ERR_INVALID_ARG_TYPE for invalid settings argument. + */ + updateSettings(settings: Settings): void; + } + export interface Http2Server extends net.Server, HTTP2ServerCommon { + addListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + addListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + addListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + addListener(event: "sessionError", listener: (err: Error) => void): this; + addListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + addListener(event: "timeout", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean; + emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean; + emit(event: "session", session: ServerHttp2Session): boolean; + emit(event: "sessionError", err: Error): boolean; + emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean; + emit(event: "timeout"): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this; + on(event: "session", listener: (session: ServerHttp2Session) => void): this; + on(event: "sessionError", listener: (err: Error) => void): this; + on( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + on(event: "timeout", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this; + once(event: "session", listener: (session: ServerHttp2Session) => void): this; + once(event: "sessionError", listener: (err: Error) => void): this; + once( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + once(event: "timeout", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + prependListener(event: "sessionError", listener: (err: Error) => void): this; + prependListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependOnceListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + prependOnceListener(event: "sessionError", listener: (err: Error) => void): this; + prependOnceListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon { + addListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + addListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + addListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + addListener(event: "sessionError", listener: (err: Error) => void): this; + addListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + addListener(event: "timeout", listener: () => void): this; + addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean; + emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean; + emit(event: "session", session: ServerHttp2Session): boolean; + emit(event: "sessionError", err: Error): boolean; + emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean; + emit(event: "timeout"): boolean; + emit(event: "unknownProtocol", socket: tls.TLSSocket): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this; + on(event: "session", listener: (session: ServerHttp2Session) => void): this; + on(event: "sessionError", listener: (err: Error) => void): this; + on( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + on(event: "timeout", listener: () => void): this; + on(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this; + once(event: "session", listener: (session: ServerHttp2Session) => void): this; + once(event: "sessionError", listener: (err: Error) => void): this; + once( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + once(event: "timeout", listener: () => void): this; + once(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + prependListener(event: "sessionError", listener: (err: Error) => void): this; + prependListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependOnceListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + prependOnceListener(event: "sessionError", listener: (err: Error) => void): this; + prependOnceListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * A `Http2ServerRequest` object is created by {@link Server} or {@link SecureServer} and passed as the first argument to the `'request'` event. It may be used to access a request status, + * headers, and + * data. + * @since v8.4.0 + */ + export class Http2ServerRequest extends stream.Readable { + constructor( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + options: stream.ReadableOptions, + rawHeaders: readonly string[], + ); + /** + * The `request.aborted` property will be `true` if the request has + * been aborted. + * @since v10.1.0 + */ + readonly aborted: boolean; + /** + * The request authority pseudo header field. Because HTTP/2 allows requests + * to set either `:authority` or `host`, this value is derived from`req.headers[':authority']` if present. Otherwise, it is derived from`req.headers['host']`. + * @since v8.4.0 + */ + readonly authority: string; + /** + * See `request.socket`. + * @since v8.4.0 + * @deprecated Since v13.0.0 - Use `socket`. + */ + readonly connection: net.Socket | tls.TLSSocket; + /** + * The `request.complete` property will be `true` if the request has + * been completed, aborted, or destroyed. + * @since v12.10.0 + */ + readonly complete: boolean; + /** + * The request/response headers object. + * + * Key-value pairs of header names and values. Header names are lower-cased. + * + * ```js + * // Prints something like: + * // + * // { 'user-agent': 'curl/7.22.0', + * // host: '127.0.0.1:8000', + * // accept: '*' } + * console.log(request.headers); + * ``` + * + * See `HTTP/2 Headers Object`. + * + * In HTTP/2, the request path, host name, protocol, and method are represented as + * special headers prefixed with the `:` character (e.g. `':path'`). These special + * headers will be included in the `request.headers` object. Care must be taken not + * to inadvertently modify these special headers or errors may occur. For instance, + * removing all headers from the request will cause errors to occur: + * + * ```js + * removeAllHeaders(request.headers); + * assert(request.url); // Fails because the :path header has been removed + * ``` + * @since v8.4.0 + */ + readonly headers: IncomingHttpHeaders; + /** + * In case of server request, the HTTP version sent by the client. In the case of + * client response, the HTTP version of the connected-to server. Returns`'2.0'`. + * + * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second. + * @since v8.4.0 + */ + readonly httpVersion: string; + readonly httpVersionMinor: number; + readonly httpVersionMajor: number; + /** + * The request method as a string. Read-only. Examples: `'GET'`, `'DELETE'`. + * @since v8.4.0 + */ + readonly method: string; + /** + * The raw request/response headers list exactly as they were received. + * + * The keys and values are in the same list. It is _not_ a + * list of tuples. So, the even-numbered offsets are key values, and the + * odd-numbered offsets are the associated values. + * + * Header names are not lowercased, and duplicates are not merged. + * + * ```js + * // Prints something like: + * // + * // [ 'user-agent', + * // 'this is invalid because there can be only one', + * // 'User-Agent', + * // 'curl/7.22.0', + * // 'Host', + * // '127.0.0.1:8000', + * // 'ACCEPT', + * // '*' ] + * console.log(request.rawHeaders); + * ``` + * @since v8.4.0 + */ + readonly rawHeaders: string[]; + /** + * The raw request/response trailer keys and values exactly as they were + * received. Only populated at the `'end'` event. + * @since v8.4.0 + */ + readonly rawTrailers: string[]; + /** + * The request scheme pseudo header field indicating the scheme + * portion of the target URL. + * @since v8.4.0 + */ + readonly scheme: string; + /** + * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but + * applies getters, setters, and methods based on HTTP/2 logic. + * + * `destroyed`, `readable`, and `writable` properties will be retrieved from and + * set on `request.stream`. + * + * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`request.stream`. + * + * `setTimeout` method will be called on `request.stream.session`. + * + * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for + * more information. + * + * All other interactions will be routed directly to the socket. With TLS support, + * use `request.socket.getPeerCertificate()` to obtain the client's + * authentication details. + * @since v8.4.0 + */ + readonly socket: net.Socket | tls.TLSSocket; + /** + * The `Http2Stream` object backing the request. + * @since v8.4.0 + */ + readonly stream: ServerHttp2Stream; + /** + * The request/response trailers object. Only populated at the `'end'` event. + * @since v8.4.0 + */ + readonly trailers: IncomingHttpHeaders; + /** + * Request URL string. This contains only the URL that is present in the actual + * HTTP request. If the request is: + * + * ```http + * GET /status?name=ryan HTTP/1.1 + * Accept: text/plain + * ``` + * + * Then `request.url` will be: + * + * ```js + * '/status?name=ryan' + * ``` + * + * To parse the url into its parts, `new URL()` can be used: + * + * ```console + * $ node + * > new URL('/status?name=ryan', 'http://example.com') + * URL { + * href: 'http://example.com/status?name=ryan', + * origin: 'http://example.com', + * protocol: 'http:', + * username: '', + * password: '', + * host: 'example.com', + * hostname: 'example.com', + * port: '', + * pathname: '/status', + * search: '?name=ryan', + * searchParams: URLSearchParams { 'name' => 'ryan' }, + * hash: '' + * } + * ``` + * @since v8.4.0 + */ + url: string; + /** + * Sets the `Http2Stream`'s timeout value to `msecs`. If a callback is + * provided, then it is added as a listener on the `'timeout'` event on + * the response object. + * + * If no `'timeout'` listener is added to the request, the response, or + * the server, then `Http2Stream` s are destroyed when they time out. If a + * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly. + * @since v8.4.0 + */ + setTimeout(msecs: number, callback?: () => void): void; + read(size?: number): Buffer | string | null; + addListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: Buffer | string) => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "aborted", hadError: boolean, code: number): boolean; + emit(event: "close"): boolean; + emit(event: "data", chunk: Buffer | string): boolean; + emit(event: "end"): boolean; + emit(event: "readable"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: Buffer | string) => void): this; + on(event: "end", listener: () => void): this; + on(event: "readable", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: Buffer | string) => void): this; + once(event: "end", listener: () => void): this; + once(event: "readable", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * This object is created internally by an HTTP server, not by the user. It is + * passed as the second parameter to the `'request'` event. + * @since v8.4.0 + */ + export class Http2ServerResponse extends stream.Writable { + constructor(stream: ServerHttp2Stream); + /** + * See `response.socket`. + * @since v8.4.0 + * @deprecated Since v13.0.0 - Use `socket`. + */ + readonly connection: net.Socket | tls.TLSSocket; + /** + * Boolean value that indicates whether the response has completed. Starts + * as `false`. After `response.end()` executes, the value will be `true`. + * @since v8.4.0 + * @deprecated Since v13.4.0,v12.16.0 - Use `writableEnded`. + */ + readonly finished: boolean; + /** + * True if headers were sent, false otherwise (read-only). + * @since v8.4.0 + */ + readonly headersSent: boolean; + /** + * A reference to the original HTTP2 `request` object. + * @since v15.7.0 + */ + readonly req: Http2ServerRequest; + /** + * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but + * applies getters, setters, and methods based on HTTP/2 logic. + * + * `destroyed`, `readable`, and `writable` properties will be retrieved from and + * set on `response.stream`. + * + * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`response.stream`. + * + * `setTimeout` method will be called on `response.stream.session`. + * + * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for + * more information. + * + * All other interactions will be routed directly to the socket. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer((req, res) => { + * const ip = req.socket.remoteAddress; + * const port = req.socket.remotePort; + * res.end(`Your IP address is ${ip} and your source port is ${port}.`); + * }).listen(3000); + * ``` + * @since v8.4.0 + */ + readonly socket: net.Socket | tls.TLSSocket; + /** + * The `Http2Stream` object backing the response. + * @since v8.4.0 + */ + readonly stream: ServerHttp2Stream; + /** + * When true, the Date header will be automatically generated and sent in + * the response if it is not already present in the headers. Defaults to true. + * + * This should only be disabled for testing; HTTP requires the Date header + * in responses. + * @since v8.4.0 + */ + sendDate: boolean; + /** + * When using implicit headers (not calling `response.writeHead()` explicitly), + * this property controls the status code that will be sent to the client when + * the headers get flushed. + * + * ```js + * response.statusCode = 404; + * ``` + * + * After response header was sent to the client, this property indicates the + * status code which was sent out. + * @since v8.4.0 + */ + statusCode: number; + /** + * Status message is not supported by HTTP/2 (RFC 7540 8.1.2.4). It returns + * an empty string. + * @since v8.4.0 + */ + statusMessage: ""; + /** + * This method adds HTTP trailing headers (a header but at the end of the + * message) to the response. + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a `TypeError` being thrown. + * @since v8.4.0 + */ + addTrailers(trailers: OutgoingHttpHeaders): void; + /** + * This method signals to the server that all of the response headers and body + * have been sent; that server should consider this message complete. + * The method, `response.end()`, MUST be called on each response. + * + * If `data` is specified, it is equivalent to calling `response.write(data, encoding)` followed by `response.end(callback)`. + * + * If `callback` is specified, it will be called when the response stream + * is finished. + * @since v8.4.0 + */ + end(callback?: () => void): this; + end(data: string | Uint8Array, callback?: () => void): this; + end(data: string | Uint8Array, encoding: BufferEncoding, callback?: () => void): this; + /** + * Reads out a header that has already been queued but not sent to the client. + * The name is case-insensitive. + * + * ```js + * const contentType = response.getHeader('content-type'); + * ``` + * @since v8.4.0 + */ + getHeader(name: string): string; + /** + * Returns an array containing the unique names of the current outgoing headers. + * All header names are lowercase. + * + * ```js + * response.setHeader('Foo', 'bar'); + * response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); + * + * const headerNames = response.getHeaderNames(); + * // headerNames === ['foo', 'set-cookie'] + * ``` + * @since v8.4.0 + */ + getHeaderNames(): string[]; + /** + * Returns a shallow copy of the current outgoing headers. Since a shallow copy + * is used, array values may be mutated without additional calls to various + * header-related http module methods. The keys of the returned object are the + * header names and the values are the respective header values. All header names + * are lowercase. + * + * The object returned by the `response.getHeaders()` method _does not_prototypically inherit from the JavaScript `Object`. This means that typical`Object` methods such as `obj.toString()`, + * `obj.hasOwnProperty()`, and others + * are not defined and _will not work_. + * + * ```js + * response.setHeader('Foo', 'bar'); + * response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); + * + * const headers = response.getHeaders(); + * // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] } + * ``` + * @since v8.4.0 + */ + getHeaders(): OutgoingHttpHeaders; + /** + * Returns `true` if the header identified by `name` is currently set in the + * outgoing headers. The header name matching is case-insensitive. + * + * ```js + * const hasContentType = response.hasHeader('content-type'); + * ``` + * @since v8.4.0 + */ + hasHeader(name: string): boolean; + /** + * Removes a header that has been queued for implicit sending. + * + * ```js + * response.removeHeader('Content-Encoding'); + * ``` + * @since v8.4.0 + */ + removeHeader(name: string): void; + /** + * Sets a single header value for implicit headers. If this header already exists + * in the to-be-sent headers, its value will be replaced. Use an array of strings + * here to send multiple headers with the same name. + * + * ```js + * response.setHeader('Content-Type', 'text/html; charset=utf-8'); + * ``` + * + * or + * + * ```js + * response.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']); + * ``` + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a `TypeError` being thrown. + * + * When headers have been set with `response.setHeader()`, they will be merged + * with any headers passed to `response.writeHead()`, with the headers passed + * to `response.writeHead()` given precedence. + * + * ```js + * // Returns content-type = text/plain + * const server = http2.createServer((req, res) => { + * res.setHeader('Content-Type', 'text/html; charset=utf-8'); + * res.setHeader('X-Foo', 'bar'); + * res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' }); + * res.end('ok'); + * }); + * ``` + * @since v8.4.0 + */ + setHeader(name: string, value: number | string | readonly string[]): void; + /** + * Sets the `Http2Stream`'s timeout value to `msecs`. If a callback is + * provided, then it is added as a listener on the `'timeout'` event on + * the response object. + * + * If no `'timeout'` listener is added to the request, the response, or + * the server, then `Http2Stream` s are destroyed when they time out. If a + * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly. + * @since v8.4.0 + */ + setTimeout(msecs: number, callback?: () => void): void; + /** + * If this method is called and `response.writeHead()` has not been called, + * it will switch to implicit header mode and flush the implicit headers. + * + * This sends a chunk of the response body. This method may + * be called multiple times to provide successive parts of the body. + * + * In the `node:http` module, the response body is omitted when the + * request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body. + * + * `chunk` can be a string or a buffer. If `chunk` is a string, + * the second parameter specifies how to encode it into a byte stream. + * By default the `encoding` is `'utf8'`. `callback` will be called when this chunk + * of data is flushed. + * + * This is the raw HTTP body and has nothing to do with higher-level multi-part + * body encodings that may be used. + * + * The first time `response.write()` is called, it will send the buffered + * header information and the first chunk of the body to the client. The second + * time `response.write()` is called, Node.js assumes data will be streamed, + * and sends the new data separately. That is, the response is buffered up to the + * first chunk of the body. + * + * Returns `true` if the entire data was flushed successfully to the kernel + * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is free again. + * @since v8.4.0 + */ + write(chunk: string | Uint8Array, callback?: (err: Error) => void): boolean; + write(chunk: string | Uint8Array, encoding: BufferEncoding, callback?: (err: Error) => void): boolean; + /** + * Sends a status `100 Continue` to the client, indicating that the request body + * should be sent. See the `'checkContinue'` event on `Http2Server` and`Http2SecureServer`. + * @since v8.4.0 + */ + writeContinue(): void; + /** + * Sends a status `103 Early Hints` to the client with a Link header, + * indicating that the user agent can preload/preconnect the linked resources. + * The `hints` is an object containing the values of headers to be sent with + * early hints message. + * + * **Example** + * + * ```js + * const earlyHintsLink = '; rel=preload; as=style'; + * response.writeEarlyHints({ + * 'link': earlyHintsLink, + * }); + * + * const earlyHintsLinks = [ + * '; rel=preload; as=style', + * '; rel=preload; as=script', + * ]; + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * }); + * ``` + * @since v18.11.0 + */ + writeEarlyHints(hints: Record): void; + /** + * Sends a response header to the request. The status code is a 3-digit HTTP + * status code, like `404`. The last argument, `headers`, are the response headers. + * + * Returns a reference to the `Http2ServerResponse`, so that calls can be chained. + * + * For compatibility with `HTTP/1`, a human-readable `statusMessage` may be + * passed as the second argument. However, because the `statusMessage` has no + * meaning within HTTP/2, the argument will have no effect and a process warning + * will be emitted. + * + * ```js + * const body = 'hello world'; + * response.writeHead(200, { + * 'Content-Length': Buffer.byteLength(body), + * 'Content-Type': 'text/plain; charset=utf-8', + * }); + * ``` + * + * `Content-Length` is given in bytes not characters. The`Buffer.byteLength()` API may be used to determine the number of bytes in a + * given encoding. On outbound messages, Node.js does not check if Content-Length + * and the length of the body being transmitted are equal or not. However, when + * receiving messages, Node.js will automatically reject messages when the`Content-Length` does not match the actual payload size. + * + * This method may be called at most one time on a message before `response.end()` is called. + * + * If `response.write()` or `response.end()` are called before calling + * this, the implicit/mutable headers will be calculated and call this function. + * + * When headers have been set with `response.setHeader()`, they will be merged + * with any headers passed to `response.writeHead()`, with the headers passed + * to `response.writeHead()` given precedence. + * + * ```js + * // Returns content-type = text/plain + * const server = http2.createServer((req, res) => { + * res.setHeader('Content-Type', 'text/html; charset=utf-8'); + * res.setHeader('X-Foo', 'bar'); + * res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' }); + * res.end('ok'); + * }); + * ``` + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a `TypeError` being thrown. + * @since v8.4.0 + */ + writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this; + writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders): this; + /** + * Call `http2stream.pushStream()` with the given headers, and wrap the + * given `Http2Stream` on a newly created `Http2ServerResponse` as the callback + * parameter if successful. When `Http2ServerRequest` is closed, the callback is + * called with an error `ERR_HTTP2_INVALID_STREAM`. + * @since v8.4.0 + * @param headers An object describing the headers + * @param callback Called once `http2stream.pushStream()` is finished, or either when the attempt to create the pushed `Http2Stream` has failed or has been rejected, or the state of + * `Http2ServerRequest` is closed prior to calling the `http2stream.pushStream()` method + */ + createPushResponse( + headers: OutgoingHttpHeaders, + callback: (err: Error | null, res: Http2ServerResponse) => void, + ): void; + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (error: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pipe", listener: (src: stream.Readable) => void): this; + addListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "drain"): boolean; + emit(event: "error", error: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "pipe", src: stream.Readable): boolean; + emit(event: "unpipe", src: stream.Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (error: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (error: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (error: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export namespace constants { + const NGHTTP2_SESSION_SERVER: number; + const NGHTTP2_SESSION_CLIENT: number; + const NGHTTP2_STREAM_STATE_IDLE: number; + const NGHTTP2_STREAM_STATE_OPEN: number; + const NGHTTP2_STREAM_STATE_RESERVED_LOCAL: number; + const NGHTTP2_STREAM_STATE_RESERVED_REMOTE: number; + const NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: number; + const NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: number; + const NGHTTP2_STREAM_STATE_CLOSED: number; + const NGHTTP2_NO_ERROR: number; + const NGHTTP2_PROTOCOL_ERROR: number; + const NGHTTP2_INTERNAL_ERROR: number; + const NGHTTP2_FLOW_CONTROL_ERROR: number; + const NGHTTP2_SETTINGS_TIMEOUT: number; + const NGHTTP2_STREAM_CLOSED: number; + const NGHTTP2_FRAME_SIZE_ERROR: number; + const NGHTTP2_REFUSED_STREAM: number; + const NGHTTP2_CANCEL: number; + const NGHTTP2_COMPRESSION_ERROR: number; + const NGHTTP2_CONNECT_ERROR: number; + const NGHTTP2_ENHANCE_YOUR_CALM: number; + const NGHTTP2_INADEQUATE_SECURITY: number; + const NGHTTP2_HTTP_1_1_REQUIRED: number; + const NGHTTP2_ERR_FRAME_SIZE_ERROR: number; + const NGHTTP2_FLAG_NONE: number; + const NGHTTP2_FLAG_END_STREAM: number; + const NGHTTP2_FLAG_END_HEADERS: number; + const NGHTTP2_FLAG_ACK: number; + const NGHTTP2_FLAG_PADDED: number; + const NGHTTP2_FLAG_PRIORITY: number; + const DEFAULT_SETTINGS_HEADER_TABLE_SIZE: number; + const DEFAULT_SETTINGS_ENABLE_PUSH: number; + const DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: number; + const DEFAULT_SETTINGS_MAX_FRAME_SIZE: number; + const MAX_MAX_FRAME_SIZE: number; + const MIN_MAX_FRAME_SIZE: number; + const MAX_INITIAL_WINDOW_SIZE: number; + const NGHTTP2_DEFAULT_WEIGHT: number; + const NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: number; + const NGHTTP2_SETTINGS_ENABLE_PUSH: number; + const NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: number; + const NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: number; + const NGHTTP2_SETTINGS_MAX_FRAME_SIZE: number; + const NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: number; + const PADDING_STRATEGY_NONE: number; + const PADDING_STRATEGY_MAX: number; + const PADDING_STRATEGY_CALLBACK: number; + const HTTP2_HEADER_STATUS: string; + const HTTP2_HEADER_METHOD: string; + const HTTP2_HEADER_AUTHORITY: string; + const HTTP2_HEADER_SCHEME: string; + const HTTP2_HEADER_PATH: string; + const HTTP2_HEADER_ACCEPT_CHARSET: string; + const HTTP2_HEADER_ACCEPT_ENCODING: string; + const HTTP2_HEADER_ACCEPT_LANGUAGE: string; + const HTTP2_HEADER_ACCEPT_RANGES: string; + const HTTP2_HEADER_ACCEPT: string; + const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: string; + const HTTP2_HEADER_AGE: string; + const HTTP2_HEADER_ALLOW: string; + const HTTP2_HEADER_AUTHORIZATION: string; + const HTTP2_HEADER_CACHE_CONTROL: string; + const HTTP2_HEADER_CONNECTION: string; + const HTTP2_HEADER_CONTENT_DISPOSITION: string; + const HTTP2_HEADER_CONTENT_ENCODING: string; + const HTTP2_HEADER_CONTENT_LANGUAGE: string; + const HTTP2_HEADER_CONTENT_LENGTH: string; + const HTTP2_HEADER_CONTENT_LOCATION: string; + const HTTP2_HEADER_CONTENT_MD5: string; + const HTTP2_HEADER_CONTENT_RANGE: string; + const HTTP2_HEADER_CONTENT_TYPE: string; + const HTTP2_HEADER_COOKIE: string; + const HTTP2_HEADER_DATE: string; + const HTTP2_HEADER_ETAG: string; + const HTTP2_HEADER_EXPECT: string; + const HTTP2_HEADER_EXPIRES: string; + const HTTP2_HEADER_FROM: string; + const HTTP2_HEADER_HOST: string; + const HTTP2_HEADER_IF_MATCH: string; + const HTTP2_HEADER_IF_MODIFIED_SINCE: string; + const HTTP2_HEADER_IF_NONE_MATCH: string; + const HTTP2_HEADER_IF_RANGE: string; + const HTTP2_HEADER_IF_UNMODIFIED_SINCE: string; + const HTTP2_HEADER_LAST_MODIFIED: string; + const HTTP2_HEADER_LINK: string; + const HTTP2_HEADER_LOCATION: string; + const HTTP2_HEADER_MAX_FORWARDS: string; + const HTTP2_HEADER_PREFER: string; + const HTTP2_HEADER_PROXY_AUTHENTICATE: string; + const HTTP2_HEADER_PROXY_AUTHORIZATION: string; + const HTTP2_HEADER_RANGE: string; + const HTTP2_HEADER_REFERER: string; + const HTTP2_HEADER_REFRESH: string; + const HTTP2_HEADER_RETRY_AFTER: string; + const HTTP2_HEADER_SERVER: string; + const HTTP2_HEADER_SET_COOKIE: string; + const HTTP2_HEADER_STRICT_TRANSPORT_SECURITY: string; + const HTTP2_HEADER_TRANSFER_ENCODING: string; + const HTTP2_HEADER_TE: string; + const HTTP2_HEADER_UPGRADE: string; + const HTTP2_HEADER_USER_AGENT: string; + const HTTP2_HEADER_VARY: string; + const HTTP2_HEADER_VIA: string; + const HTTP2_HEADER_WWW_AUTHENTICATE: string; + const HTTP2_HEADER_HTTP2_SETTINGS: string; + const HTTP2_HEADER_KEEP_ALIVE: string; + const HTTP2_HEADER_PROXY_CONNECTION: string; + const HTTP2_METHOD_ACL: string; + const HTTP2_METHOD_BASELINE_CONTROL: string; + const HTTP2_METHOD_BIND: string; + const HTTP2_METHOD_CHECKIN: string; + const HTTP2_METHOD_CHECKOUT: string; + const HTTP2_METHOD_CONNECT: string; + const HTTP2_METHOD_COPY: string; + const HTTP2_METHOD_DELETE: string; + const HTTP2_METHOD_GET: string; + const HTTP2_METHOD_HEAD: string; + const HTTP2_METHOD_LABEL: string; + const HTTP2_METHOD_LINK: string; + const HTTP2_METHOD_LOCK: string; + const HTTP2_METHOD_MERGE: string; + const HTTP2_METHOD_MKACTIVITY: string; + const HTTP2_METHOD_MKCALENDAR: string; + const HTTP2_METHOD_MKCOL: string; + const HTTP2_METHOD_MKREDIRECTREF: string; + const HTTP2_METHOD_MKWORKSPACE: string; + const HTTP2_METHOD_MOVE: string; + const HTTP2_METHOD_OPTIONS: string; + const HTTP2_METHOD_ORDERPATCH: string; + const HTTP2_METHOD_PATCH: string; + const HTTP2_METHOD_POST: string; + const HTTP2_METHOD_PRI: string; + const HTTP2_METHOD_PROPFIND: string; + const HTTP2_METHOD_PROPPATCH: string; + const HTTP2_METHOD_PUT: string; + const HTTP2_METHOD_REBIND: string; + const HTTP2_METHOD_REPORT: string; + const HTTP2_METHOD_SEARCH: string; + const HTTP2_METHOD_TRACE: string; + const HTTP2_METHOD_UNBIND: string; + const HTTP2_METHOD_UNCHECKOUT: string; + const HTTP2_METHOD_UNLINK: string; + const HTTP2_METHOD_UNLOCK: string; + const HTTP2_METHOD_UPDATE: string; + const HTTP2_METHOD_UPDATEREDIRECTREF: string; + const HTTP2_METHOD_VERSION_CONTROL: string; + const HTTP_STATUS_CONTINUE: number; + const HTTP_STATUS_SWITCHING_PROTOCOLS: number; + const HTTP_STATUS_PROCESSING: number; + const HTTP_STATUS_OK: number; + const HTTP_STATUS_CREATED: number; + const HTTP_STATUS_ACCEPTED: number; + const HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: number; + const HTTP_STATUS_NO_CONTENT: number; + const HTTP_STATUS_RESET_CONTENT: number; + const HTTP_STATUS_PARTIAL_CONTENT: number; + const HTTP_STATUS_MULTI_STATUS: number; + const HTTP_STATUS_ALREADY_REPORTED: number; + const HTTP_STATUS_IM_USED: number; + const HTTP_STATUS_MULTIPLE_CHOICES: number; + const HTTP_STATUS_MOVED_PERMANENTLY: number; + const HTTP_STATUS_FOUND: number; + const HTTP_STATUS_SEE_OTHER: number; + const HTTP_STATUS_NOT_MODIFIED: number; + const HTTP_STATUS_USE_PROXY: number; + const HTTP_STATUS_TEMPORARY_REDIRECT: number; + const HTTP_STATUS_PERMANENT_REDIRECT: number; + const HTTP_STATUS_BAD_REQUEST: number; + const HTTP_STATUS_UNAUTHORIZED: number; + const HTTP_STATUS_PAYMENT_REQUIRED: number; + const HTTP_STATUS_FORBIDDEN: number; + const HTTP_STATUS_NOT_FOUND: number; + const HTTP_STATUS_METHOD_NOT_ALLOWED: number; + const HTTP_STATUS_NOT_ACCEPTABLE: number; + const HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED: number; + const HTTP_STATUS_REQUEST_TIMEOUT: number; + const HTTP_STATUS_CONFLICT: number; + const HTTP_STATUS_GONE: number; + const HTTP_STATUS_LENGTH_REQUIRED: number; + const HTTP_STATUS_PRECONDITION_FAILED: number; + const HTTP_STATUS_PAYLOAD_TOO_LARGE: number; + const HTTP_STATUS_URI_TOO_LONG: number; + const HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE: number; + const HTTP_STATUS_RANGE_NOT_SATISFIABLE: number; + const HTTP_STATUS_EXPECTATION_FAILED: number; + const HTTP_STATUS_TEAPOT: number; + const HTTP_STATUS_MISDIRECTED_REQUEST: number; + const HTTP_STATUS_UNPROCESSABLE_ENTITY: number; + const HTTP_STATUS_LOCKED: number; + const HTTP_STATUS_FAILED_DEPENDENCY: number; + const HTTP_STATUS_UNORDERED_COLLECTION: number; + const HTTP_STATUS_UPGRADE_REQUIRED: number; + const HTTP_STATUS_PRECONDITION_REQUIRED: number; + const HTTP_STATUS_TOO_MANY_REQUESTS: number; + const HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: number; + const HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: number; + const HTTP_STATUS_INTERNAL_SERVER_ERROR: number; + const HTTP_STATUS_NOT_IMPLEMENTED: number; + const HTTP_STATUS_BAD_GATEWAY: number; + const HTTP_STATUS_SERVICE_UNAVAILABLE: number; + const HTTP_STATUS_GATEWAY_TIMEOUT: number; + const HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED: number; + const HTTP_STATUS_VARIANT_ALSO_NEGOTIATES: number; + const HTTP_STATUS_INSUFFICIENT_STORAGE: number; + const HTTP_STATUS_LOOP_DETECTED: number; + const HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED: number; + const HTTP_STATUS_NOT_EXTENDED: number; + const HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED: number; + } + /** + * This symbol can be set as a property on the HTTP/2 headers object with + * an array value in order to provide a list of headers considered sensitive. + */ + export const sensitiveHeaders: symbol; + /** + * Returns an object containing the default settings for an `Http2Session`instance. This method returns a new object instance every time it is called + * so instances returned may be safely modified for use. + * @since v8.4.0 + */ + export function getDefaultSettings(): Settings; + /** + * Returns a `Buffer` instance containing serialized representation of the given + * HTTP/2 settings as specified in the [HTTP/2](https://tools.ietf.org/html/rfc7540) specification. This is intended + * for use with the `HTTP2-Settings` header field. + * + * ```js + * const http2 = require('node:http2'); + * + * const packed = http2.getPackedSettings({ enablePush: false }); + * + * console.log(packed.toString('base64')); + * // Prints: AAIAAAAA + * ``` + * @since v8.4.0 + */ + export function getPackedSettings(settings: Settings): Buffer; + /** + * Returns a `HTTP/2 Settings Object` containing the deserialized settings from + * the given `Buffer` as generated by `http2.getPackedSettings()`. + * @since v8.4.0 + * @param buf The packed settings. + */ + export function getUnpackedSettings(buf: Uint8Array): Settings; + /** + * Returns a `net.Server` instance that creates and manages `Http2Session`instances. + * + * Since there are no browsers known that support [unencrypted HTTP/2](https://http2.github.io/faq/#does-http2-require-encryption), the use of {@link createSecureServer} is necessary when + * communicating + * with browser clients. + * + * ```js + * const http2 = require('node:http2'); + * + * // Create an unencrypted HTTP/2 server. + * // Since there are no browsers known that support + * // unencrypted HTTP/2, the use of `http2.createSecureServer()` + * // is necessary when communicating with browser clients. + * const server = http2.createServer(); + * + * server.on('stream', (stream, headers) => { + * stream.respond({ + * 'content-type': 'text/html; charset=utf-8', + * ':status': 200, + * }); + * stream.end('

Hello World

'); + * }); + * + * server.listen(8000); + * ``` + * @since v8.4.0 + * @param onRequestHandler See `Compatibility API` + */ + export function createServer( + onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): Http2Server; + export function createServer( + options: ServerOptions, + onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): Http2Server; + /** + * Returns a `tls.Server` instance that creates and manages `Http2Session`instances. + * + * ```js + * const http2 = require('node:http2'); + * const fs = require('node:fs'); + * + * const options = { + * key: fs.readFileSync('server-key.pem'), + * cert: fs.readFileSync('server-cert.pem'), + * }; + * + * // Create a secure HTTP/2 server + * const server = http2.createSecureServer(options); + * + * server.on('stream', (stream, headers) => { + * stream.respond({ + * 'content-type': 'text/html; charset=utf-8', + * ':status': 200, + * }); + * stream.end('

Hello World

'); + * }); + * + * server.listen(8443); + * ``` + * @since v8.4.0 + * @param onRequestHandler See `Compatibility API` + */ + export function createSecureServer( + onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): Http2SecureServer; + export function createSecureServer( + options: SecureServerOptions, + onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): Http2SecureServer; + /** + * Returns a `ClientHttp2Session` instance. + * + * ```js + * const http2 = require('node:http2'); + * const client = http2.connect('https://localhost:1234'); + * + * // Use the client + * + * client.close(); + * ``` + * @since v8.4.0 + * @param authority The remote HTTP/2 server to connect to. This must be in the form of a minimal, valid URL with the `http://` or `https://` prefix, host name, and IP port (if a non-default port + * is used). Userinfo (user ID and password), path, querystring, and fragment details in the URL will be ignored. + * @param listener Will be registered as a one-time listener of the {@link 'connect'} event. + */ + export function connect( + authority: string | url.URL, + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): ClientHttp2Session; + export function connect( + authority: string | url.URL, + options?: ClientSessionOptions | SecureClientSessionOptions, + listener?: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): ClientHttp2Session; +} +declare module "node:http2" { + export * from "http2"; +} diff --git a/node_modules/@types/node/https.d.ts b/node_modules/@types/node/https.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..36ae5b2f52eb9b643b32e59346df07b40758cd1f --- /dev/null +++ b/node_modules/@types/node/https.d.ts @@ -0,0 +1,550 @@ +/** + * HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a + * separate module. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/https.js) + */ +declare module "https" { + import { Duplex } from "node:stream"; + import * as tls from "node:tls"; + import * as http from "node:http"; + import { URL } from "node:url"; + type ServerOptions< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions; + type RequestOptions = + & http.RequestOptions + & tls.SecureContextOptions + & { + checkServerIdentity?: typeof tls.checkServerIdentity | undefined; + rejectUnauthorized?: boolean | undefined; // Defaults to true + servername?: string | undefined; // SNI TLS Extension + }; + interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { + rejectUnauthorized?: boolean | undefined; + maxCachedSessions?: number | undefined; + } + /** + * An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information. + * @since v0.4.5 + */ + class Agent extends http.Agent { + constructor(options?: AgentOptions); + options: AgentOptions; + } + interface Server< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + > extends http.Server {} + /** + * See `http.Server` for more information. + * @since v0.3.4 + */ + class Server< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + > extends tls.Server { + constructor(requestListener?: http.RequestListener); + constructor( + options: ServerOptions, + requestListener?: http.RequestListener, + ); + /** + * Closes all connections connected to this server. + * @since v18.2.0 + */ + closeAllConnections(): void; + /** + * Closes all connections connected to this server which are not sending a request or waiting for a response. + * @since v18.2.0 + */ + closeIdleConnections(): void; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + addListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + addListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + addListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + addListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connection", listener: (socket: Duplex) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "checkContinue", listener: http.RequestListener): this; + addListener(event: "checkExpectation", listener: http.RequestListener): this; + addListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + addListener( + event: "connect", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + addListener(event: "request", listener: http.RequestListener): this; + addListener( + event: "upgrade", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + emit(event: string, ...args: any[]): boolean; + emit(event: "keylog", line: Buffer, tlsSocket: tls.TLSSocket): boolean; + emit( + event: "newSession", + sessionId: Buffer, + sessionData: Buffer, + callback: (err: Error, resp: Buffer) => void, + ): boolean; + emit( + event: "OCSPRequest", + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ): boolean; + emit(event: "resumeSession", sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean; + emit(event: "secureConnection", tlsSocket: tls.TLSSocket): boolean; + emit(event: "tlsClientError", err: Error, tlsSocket: tls.TLSSocket): boolean; + emit(event: "close"): boolean; + emit(event: "connection", socket: Duplex): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit( + event: "checkContinue", + req: InstanceType, + res: InstanceType & { + req: InstanceType; + }, + ): boolean; + emit( + event: "checkExpectation", + req: InstanceType, + res: InstanceType & { + req: InstanceType; + }, + ): boolean; + emit(event: "clientError", err: Error, socket: Duplex): boolean; + emit(event: "connect", req: InstanceType, socket: Duplex, head: Buffer): boolean; + emit( + event: "request", + req: InstanceType, + res: InstanceType & { + req: InstanceType; + }, + ): boolean; + emit(event: "upgrade", req: InstanceType, socket: Duplex, head: Buffer): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + on( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + on( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + on( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + on(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + on(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connection", listener: (socket: Duplex) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "checkContinue", listener: http.RequestListener): this; + on(event: "checkExpectation", listener: http.RequestListener): this; + on(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + on(event: "connect", listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; + on(event: "request", listener: http.RequestListener): this; + on(event: "upgrade", listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + once( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + once( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + once( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + once(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + once(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connection", listener: (socket: Duplex) => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "checkContinue", listener: http.RequestListener): this; + once(event: "checkExpectation", listener: http.RequestListener): this; + once(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + once(event: "connect", listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; + once(event: "request", listener: http.RequestListener): this; + once(event: "upgrade", listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + prependListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + prependListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + prependListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + prependListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connection", listener: (socket: Duplex) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "checkContinue", listener: http.RequestListener): this; + prependListener(event: "checkExpectation", listener: http.RequestListener): this; + prependListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + prependListener( + event: "connect", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + prependListener(event: "request", listener: http.RequestListener): this; + prependListener( + event: "upgrade", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + prependOnceListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + prependOnceListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + prependOnceListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + prependOnceListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connection", listener: (socket: Duplex) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "checkContinue", listener: http.RequestListener): this; + prependOnceListener(event: "checkExpectation", listener: http.RequestListener): this; + prependOnceListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + prependOnceListener( + event: "connect", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + prependOnceListener(event: "request", listener: http.RequestListener): this; + prependOnceListener( + event: "upgrade", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + } + /** + * ```js + * // curl -k https://localhost:8000/ + * const https = require('node:https'); + * const fs = require('node:fs'); + * + * const options = { + * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), + * }; + * + * https.createServer(options, (req, res) => { + * res.writeHead(200); + * res.end('hello world\n'); + * }).listen(8000); + * ``` + * + * Or + * + * ```js + * const https = require('node:https'); + * const fs = require('node:fs'); + * + * const options = { + * pfx: fs.readFileSync('test/fixtures/test_cert.pfx'), + * passphrase: 'sample', + * }; + * + * https.createServer(options, (req, res) => { + * res.writeHead(200); + * res.end('hello world\n'); + * }).listen(8000); + * ``` + * @since v0.3.4 + * @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`. + * @param requestListener A listener to be added to the `'request'` event. + */ + function createServer< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + >(requestListener?: http.RequestListener): Server; + function createServer< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + >( + options: ServerOptions, + requestListener?: http.RequestListener, + ): Server; + /** + * Makes a request to a secure web server. + * + * The following additional `options` from `tls.connect()` are also accepted:`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,`honorCipherOrder`, `key`, `passphrase`, + * `pfx`, `rejectUnauthorized`,`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`,`highWaterMark`. + * + * `options` can be an object, a string, or a `URL` object. If `options` is a + * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object. + * + * `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to + * upload a file with a POST request, then write to the `ClientRequest` object. + * + * ```js + * const https = require('node:https'); + * + * const options = { + * hostname: 'encrypted.google.com', + * port: 443, + * path: '/', + * method: 'GET', + * }; + * + * const req = https.request(options, (res) => { + * console.log('statusCode:', res.statusCode); + * console.log('headers:', res.headers); + * + * res.on('data', (d) => { + * process.stdout.write(d); + * }); + * }); + * + * req.on('error', (e) => { + * console.error(e); + * }); + * req.end(); + * ``` + * + * Example using options from `tls.connect()`: + * + * ```js + * const options = { + * hostname: 'encrypted.google.com', + * port: 443, + * path: '/', + * method: 'GET', + * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), + * }; + * options.agent = new https.Agent(options); + * + * const req = https.request(options, (res) => { + * // ... + * }); + * ``` + * + * Alternatively, opt out of connection pooling by not using an `Agent`. + * + * ```js + * const options = { + * hostname: 'encrypted.google.com', + * port: 443, + * path: '/', + * method: 'GET', + * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), + * agent: false, + * }; + * + * const req = https.request(options, (res) => { + * // ... + * }); + * ``` + * + * Example using a `URL` as `options`: + * + * ```js + * const options = new URL('https://abc:xyz@example.com'); + * + * const req = https.request(options, (res) => { + * // ... + * }); + * ``` + * + * Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`): + * + * ```js + * const tls = require('node:tls'); + * const https = require('node:https'); + * const crypto = require('node:crypto'); + * + * function sha256(s) { + * return crypto.createHash('sha256').update(s).digest('base64'); + * } + * const options = { + * hostname: 'github.com', + * port: 443, + * path: '/', + * method: 'GET', + * checkServerIdentity: function(host, cert) { + * // Make sure the certificate is issued to the host we are connected to + * const err = tls.checkServerIdentity(host, cert); + * if (err) { + * return err; + * } + * + * // Pin the public key, similar to HPKP pin-sha256 pinning + * const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU='; + * if (sha256(cert.pubkey) !== pubkey256) { + * const msg = 'Certificate verification error: ' + + * `The public key of '${cert.subject.CN}' ` + + * 'does not match our pinned fingerprint'; + * return new Error(msg); + * } + * + * // Pin the exact certificate, rather than the pub key + * const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' + + * 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16'; + * if (cert.fingerprint256 !== cert256) { + * const msg = 'Certificate verification error: ' + + * `The certificate of '${cert.subject.CN}' ` + + * 'does not match our pinned fingerprint'; + * return new Error(msg); + * } + * + * // This loop is informational only. + * // Print the certificate and public key fingerprints of all certs in the + * // chain. Its common to pin the public key of the issuer on the public + * // internet, while pinning the public key of the service in sensitive + * // environments. + * do { + * console.log('Subject Common Name:', cert.subject.CN); + * console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256); + * + * hash = crypto.createHash('sha256'); + * console.log(' Public key ping-sha256:', sha256(cert.pubkey)); + * + * lastprint256 = cert.fingerprint256; + * cert = cert.issuerCertificate; + * } while (cert.fingerprint256 !== lastprint256); + * + * }, + * }; + * + * options.agent = new https.Agent(options); + * const req = https.request(options, (res) => { + * console.log('All OK. Server matched our pinned cert or public key'); + * console.log('statusCode:', res.statusCode); + * // Print the HPKP values + * console.log('headers:', res.headers['public-key-pins']); + * + * res.on('data', (d) => {}); + * }); + * + * req.on('error', (e) => { + * console.error(e.message); + * }); + * req.end(); + * ``` + * + * Outputs for example: + * + * ```text + * Subject Common Name: github.com + * Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16 + * Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU= + * Subject Common Name: DigiCert SHA2 Extended Validation Server CA + * Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A + * Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho= + * Subject Common Name: DigiCert High Assurance EV Root CA + * Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF + * Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18= + * All OK. Server matched our pinned cert or public key + * statusCode: 200 + * headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho="; + * pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4="; + * pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains + * ``` + * @since v0.3.6 + * @param options Accepts all `options` from `request`, with some differences in default values: + */ + function request( + options: RequestOptions | string | URL, + callback?: (res: http.IncomingMessage) => void, + ): http.ClientRequest; + function request( + url: string | URL, + options: RequestOptions, + callback?: (res: http.IncomingMessage) => void, + ): http.ClientRequest; + /** + * Like `http.get()` but for HTTPS. + * + * `options` can be an object, a string, or a `URL` object. If `options` is a + * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object. + * + * ```js + * const https = require('node:https'); + * + * https.get('https://encrypted.google.com/', (res) => { + * console.log('statusCode:', res.statusCode); + * console.log('headers:', res.headers); + * + * res.on('data', (d) => { + * process.stdout.write(d); + * }); + * + * }).on('error', (e) => { + * console.error(e); + * }); + * ``` + * @since v0.3.6 + * @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`. + */ + function get( + options: RequestOptions | string | URL, + callback?: (res: http.IncomingMessage) => void, + ): http.ClientRequest; + function get( + url: string | URL, + options: RequestOptions, + callback?: (res: http.IncomingMessage) => void, + ): http.ClientRequest; + let globalAgent: Agent; +} +declare module "node:https" { + export * from "https"; +} diff --git a/node_modules/@types/node/index.d.ts b/node_modules/@types/node/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a596cad0219b59bd4a762eec62f85818b94409dd --- /dev/null +++ b/node_modules/@types/node/index.d.ts @@ -0,0 +1,88 @@ +/** + * License for programmatically and manually incorporated + * documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc + * + * Copyright Node.js contributors. All rights reserved. + * 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. + */ + +// NOTE: These definitions support NodeJS and TypeScript 4.9+. + +// Reference required types from the default lib: +/// +/// +/// +/// + +// Base definitions for all NodeJS modules that are not specific to any version of TypeScript: +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// + +/// diff --git a/node_modules/@types/node/inspector.d.ts b/node_modules/@types/node/inspector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3927b81603d1ed6b7185b943e8cef65102f8dfca --- /dev/null +++ b/node_modules/@types/node/inspector.d.ts @@ -0,0 +1,2747 @@ +// Type definitions for inspector + +// These definitions are auto-generated. +// Please see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/19330 +// for more information. + + +/** + * The `node:inspector` module provides an API for interacting with the V8 + * inspector. + * + * It can be accessed using: + * + * ```js + * import * as inspector from 'node:inspector/promises'; + * ``` + * + * or + * + * ```js + * import * as inspector from 'node:inspector'; + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/inspector.js) + */ +declare module 'inspector' { + import EventEmitter = require('node:events'); + interface InspectorNotification { + method: string; + params: T; + } + namespace Schema { + /** + * Description of the protocol domain. + */ + interface Domain { + /** + * Domain name. + */ + name: string; + /** + * Domain version. + */ + version: string; + } + interface GetDomainsReturnType { + /** + * List of supported domains. + */ + domains: Domain[]; + } + } + namespace Runtime { + /** + * Unique script identifier. + */ + type ScriptId = string; + /** + * Unique object identifier. + */ + type RemoteObjectId = string; + /** + * Primitive value which cannot be JSON-stringified. + */ + type UnserializableValue = string; + /** + * Mirror object referencing original JavaScript object. + */ + interface RemoteObject { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * Object class (constructor) name. Specified for object type values only. + */ + className?: string | undefined; + /** + * Remote object value in case of primitive values or JSON values (if it was requested). + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified does not have value, but gets this property. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * Unique object identifier (for non-primitive values). + */ + objectId?: RemoteObjectId | undefined; + /** + * Preview containing abbreviated property values. Specified for object type values only. + * @experimental + */ + preview?: ObjectPreview | undefined; + /** + * @experimental + */ + customPreview?: CustomPreview | undefined; + } + /** + * @experimental + */ + interface CustomPreview { + header: string; + hasBody: boolean; + formatterObjectId: RemoteObjectId; + bindRemoteObjectFunctionId: RemoteObjectId; + configObjectId?: RemoteObjectId | undefined; + } + /** + * Object containing abbreviated remote object value. + * @experimental + */ + interface ObjectPreview { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * True iff some of the properties or entries of the original object did not fit. + */ + overflow: boolean; + /** + * List of the properties. + */ + properties: PropertyPreview[]; + /** + * List of the entries. Specified for map and set subtype values only. + */ + entries?: EntryPreview[] | undefined; + } + /** + * @experimental + */ + interface PropertyPreview { + /** + * Property name. + */ + name: string; + /** + * Object type. Accessor means that the property itself is an accessor property. + */ + type: string; + /** + * User-friendly property value string. + */ + value?: string | undefined; + /** + * Nested value preview. + */ + valuePreview?: ObjectPreview | undefined; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + } + /** + * @experimental + */ + interface EntryPreview { + /** + * Preview of the key. Specified for map-like collection entries. + */ + key?: ObjectPreview | undefined; + /** + * Preview of the value. + */ + value: ObjectPreview; + } + /** + * Object property descriptor. + */ + interface PropertyDescriptor { + /** + * Property name or symbol description. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + /** + * True if the value associated with the property may be changed (data descriptors only). + */ + writable?: boolean | undefined; + /** + * A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only). + */ + get?: RemoteObject | undefined; + /** + * A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only). + */ + set?: RemoteObject | undefined; + /** + * True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. + */ + configurable: boolean; + /** + * True if this property shows up during enumeration of the properties on the corresponding object. + */ + enumerable: boolean; + /** + * True if the result was thrown during the evaluation. + */ + wasThrown?: boolean | undefined; + /** + * True if the property is owned for the object. + */ + isOwn?: boolean | undefined; + /** + * Property symbol object, if the property is of the symbol type. + */ + symbol?: RemoteObject | undefined; + } + /** + * Object internal property descriptor. This property isn't normally visible in JavaScript code. + */ + interface InternalPropertyDescriptor { + /** + * Conventional property name. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + } + /** + * Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified. + */ + interface CallArgument { + /** + * Primitive value or serializable javascript object. + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * Remote object handle. + */ + objectId?: RemoteObjectId | undefined; + } + /** + * Id of an execution context. + */ + type ExecutionContextId = number; + /** + * Description of an isolated world. + */ + interface ExecutionContextDescription { + /** + * Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed. + */ + id: ExecutionContextId; + /** + * Execution context origin. + */ + origin: string; + /** + * Human readable name describing given context. + */ + name: string; + /** + * Embedder-specific auxiliary data. + */ + auxData?: {} | undefined; + } + /** + * Detailed information about exception (or error) that was thrown during script compilation or execution. + */ + interface ExceptionDetails { + /** + * Exception id. + */ + exceptionId: number; + /** + * Exception text, which should be used together with exception object when available. + */ + text: string; + /** + * Line number of the exception location (0-based). + */ + lineNumber: number; + /** + * Column number of the exception location (0-based). + */ + columnNumber: number; + /** + * Script ID of the exception location. + */ + scriptId?: ScriptId | undefined; + /** + * URL of the exception location, to be used when the script was not reported. + */ + url?: string | undefined; + /** + * JavaScript stack trace if available. + */ + stackTrace?: StackTrace | undefined; + /** + * Exception object if available. + */ + exception?: RemoteObject | undefined; + /** + * Identifier of the context where exception happened. + */ + executionContextId?: ExecutionContextId | undefined; + } + /** + * Number of milliseconds since epoch. + */ + type Timestamp = number; + /** + * Stack entry for runtime errors and assertions. + */ + interface CallFrame { + /** + * JavaScript function name. + */ + functionName: string; + /** + * JavaScript script id. + */ + scriptId: ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * JavaScript script line number (0-based). + */ + lineNumber: number; + /** + * JavaScript script column number (0-based). + */ + columnNumber: number; + } + /** + * Call frames for assertions or error messages. + */ + interface StackTrace { + /** + * String label of this stack trace. For async traces this may be a name of the function that initiated the async call. + */ + description?: string | undefined; + /** + * JavaScript function name. + */ + callFrames: CallFrame[]; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + */ + parent?: StackTrace | undefined; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + * @experimental + */ + parentId?: StackTraceId | undefined; + } + /** + * Unique identifier of current debugger. + * @experimental + */ + type UniqueDebuggerId = string; + /** + * If debuggerId is set stack trace comes from another debugger and can be resolved there. This allows to track cross-debugger calls. See Runtime.StackTrace and Debugger.paused for usages. + * @experimental + */ + interface StackTraceId { + id: string; + debuggerId?: UniqueDebuggerId | undefined; + } + interface EvaluateParameterType { + /** + * Expression to evaluate. + */ + expression: string; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + contextId?: ExecutionContextId | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface AwaitPromiseParameterType { + /** + * Identifier of the promise. + */ + promiseObjectId: RemoteObjectId; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + } + interface CallFunctionOnParameterType { + /** + * Declaration of the function to call. + */ + functionDeclaration: string; + /** + * Identifier of the object to call function on. Either objectId or executionContextId should be specified. + */ + objectId?: RemoteObjectId | undefined; + /** + * Call arguments. All call arguments must belong to the same JavaScript world as the target object. + */ + arguments?: CallArgument[] | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + /** + * Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object. + */ + objectGroup?: string | undefined; + } + interface GetPropertiesParameterType { + /** + * Identifier of the object to return properties for. + */ + objectId: RemoteObjectId; + /** + * If true, returns properties belonging only to the element itself, not to its prototype chain. + */ + ownProperties?: boolean | undefined; + /** + * If true, returns accessor properties (with getter/setter) only; internal properties are not returned either. + * @experimental + */ + accessorPropertiesOnly?: boolean | undefined; + /** + * Whether preview should be generated for the results. + * @experimental + */ + generatePreview?: boolean | undefined; + } + interface ReleaseObjectParameterType { + /** + * Identifier of the object to release. + */ + objectId: RemoteObjectId; + } + interface ReleaseObjectGroupParameterType { + /** + * Symbolic object group name. + */ + objectGroup: string; + } + interface SetCustomObjectFormatterEnabledParameterType { + enabled: boolean; + } + interface CompileScriptParameterType { + /** + * Expression to compile. + */ + expression: string; + /** + * Source url to be set for the script. + */ + sourceURL: string; + /** + * Specifies whether the compiled script should be persisted. + */ + persistScript: boolean; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface RunScriptParameterType { + /** + * Id of the script to run. + */ + scriptId: ScriptId; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface QueryObjectsParameterType { + /** + * Identifier of the prototype to return objects for. + */ + prototypeObjectId: RemoteObjectId; + } + interface GlobalLexicalScopeNamesParameterType { + /** + * Specifies in which execution context to lookup global scope variables. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface EvaluateReturnType { + /** + * Evaluation result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface AwaitPromiseReturnType { + /** + * Promise result. Will contain rejected value if promise was rejected. + */ + result: RemoteObject; + /** + * Exception details if stack strace is available. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CallFunctionOnReturnType { + /** + * Call result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface GetPropertiesReturnType { + /** + * Object properties. + */ + result: PropertyDescriptor[]; + /** + * Internal object properties (only of the element itself). + */ + internalProperties?: InternalPropertyDescriptor[] | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CompileScriptReturnType { + /** + * Id of the script. + */ + scriptId?: ScriptId | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface RunScriptReturnType { + /** + * Run result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface QueryObjectsReturnType { + /** + * Array with objects. + */ + objects: RemoteObject; + } + interface GlobalLexicalScopeNamesReturnType { + names: string[]; + } + interface ExecutionContextCreatedEventDataType { + /** + * A newly created execution context. + */ + context: ExecutionContextDescription; + } + interface ExecutionContextDestroyedEventDataType { + /** + * Id of the destroyed context + */ + executionContextId: ExecutionContextId; + } + interface ExceptionThrownEventDataType { + /** + * Timestamp of the exception. + */ + timestamp: Timestamp; + exceptionDetails: ExceptionDetails; + } + interface ExceptionRevokedEventDataType { + /** + * Reason describing why exception was revoked. + */ + reason: string; + /** + * The id of revoked exception, as reported in exceptionThrown. + */ + exceptionId: number; + } + interface ConsoleAPICalledEventDataType { + /** + * Type of the call. + */ + type: string; + /** + * Call arguments. + */ + args: RemoteObject[]; + /** + * Identifier of the context where the call was made. + */ + executionContextId: ExecutionContextId; + /** + * Call timestamp. + */ + timestamp: Timestamp; + /** + * Stack trace captured when the call was made. + */ + stackTrace?: StackTrace | undefined; + /** + * Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context. + * @experimental + */ + context?: string | undefined; + } + interface InspectRequestedEventDataType { + object: RemoteObject; + hints: {}; + } + } + namespace Debugger { + /** + * Breakpoint identifier. + */ + type BreakpointId = string; + /** + * Call frame identifier. + */ + type CallFrameId = string; + /** + * Location in the source code. + */ + interface Location { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + } + /** + * Location in the source code. + * @experimental + */ + interface ScriptPosition { + lineNumber: number; + columnNumber: number; + } + /** + * JavaScript call frame. Array of call frames form the call stack. + */ + interface CallFrame { + /** + * Call frame identifier. This identifier is only valid while the virtual machine is paused. + */ + callFrameId: CallFrameId; + /** + * Name of the JavaScript function called on this call frame. + */ + functionName: string; + /** + * Location in the source code. + */ + functionLocation?: Location | undefined; + /** + * Location in the source code. + */ + location: Location; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Scope chain for this call frame. + */ + scopeChain: Scope[]; + /** + * this object for this call frame. + */ + this: Runtime.RemoteObject; + /** + * The value being returned, if the function is at return point. + */ + returnValue?: Runtime.RemoteObject | undefined; + } + /** + * Scope description. + */ + interface Scope { + /** + * Scope type. + */ + type: string; + /** + * Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties. + */ + object: Runtime.RemoteObject; + name?: string | undefined; + /** + * Location in the source code where scope starts + */ + startLocation?: Location | undefined; + /** + * Location in the source code where scope ends + */ + endLocation?: Location | undefined; + } + /** + * Search match for resource. + */ + interface SearchMatch { + /** + * Line number in resource content. + */ + lineNumber: number; + /** + * Line with match content. + */ + lineContent: string; + } + interface BreakLocation { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + type?: string | undefined; + } + interface SetBreakpointsActiveParameterType { + /** + * New value for breakpoints active state. + */ + active: boolean; + } + interface SetSkipAllPausesParameterType { + /** + * New value for skip pauses state. + */ + skip: boolean; + } + interface SetBreakpointByUrlParameterType { + /** + * Line number to set breakpoint at. + */ + lineNumber: number; + /** + * URL of the resources to set breakpoint on. + */ + url?: string | undefined; + /** + * Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. + */ + urlRegex?: string | undefined; + /** + * Script hash of the resources to set breakpoint on. + */ + scriptHash?: string | undefined; + /** + * Offset in the line to set breakpoint at. + */ + columnNumber?: number | undefined; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface SetBreakpointParameterType { + /** + * Location to set breakpoint in. + */ + location: Location; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface RemoveBreakpointParameterType { + breakpointId: BreakpointId; + } + interface GetPossibleBreakpointsParameterType { + /** + * Start of range to search possible breakpoint locations in. + */ + start: Location; + /** + * End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. + */ + end?: Location | undefined; + /** + * Only consider locations which are in the same (non-nested) function as start. + */ + restrictToFunction?: boolean | undefined; + } + interface ContinueToLocationParameterType { + /** + * Location to continue to. + */ + location: Location; + targetCallFrames?: string | undefined; + } + interface PauseOnAsyncCallParameterType { + /** + * Debugger will pause when async call with given stack trace is started. + */ + parentStackTraceId: Runtime.StackTraceId; + } + interface StepIntoParameterType { + /** + * Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause. + * @experimental + */ + breakOnAsyncCall?: boolean | undefined; + } + interface GetStackTraceParameterType { + stackTraceId: Runtime.StackTraceId; + } + interface SearchInContentParameterType { + /** + * Id of the script to search in. + */ + scriptId: Runtime.ScriptId; + /** + * String to search for. + */ + query: string; + /** + * If true, search is case sensitive. + */ + caseSensitive?: boolean | undefined; + /** + * If true, treats string parameter as regex. + */ + isRegex?: boolean | undefined; + } + interface SetScriptSourceParameterType { + /** + * Id of the script to edit. + */ + scriptId: Runtime.ScriptId; + /** + * New content of the script. + */ + scriptSource: string; + /** + * If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code. + */ + dryRun?: boolean | undefined; + } + interface RestartFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + } + interface GetScriptSourceParameterType { + /** + * Id of the script to get source for. + */ + scriptId: Runtime.ScriptId; + } + interface SetPauseOnExceptionsParameterType { + /** + * Pause on exceptions mode. + */ + state: string; + } + interface EvaluateOnCallFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + /** + * Expression to evaluate. + */ + expression: string; + /** + * String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup). + */ + objectGroup?: string | undefined; + /** + * Specifies whether command line API should be available to the evaluated expression, defaults to false. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether to throw an exception if side effect cannot be ruled out during evaluation. + */ + throwOnSideEffect?: boolean | undefined; + } + interface SetVariableValueParameterType { + /** + * 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. + */ + scopeNumber: number; + /** + * Variable name. + */ + variableName: string; + /** + * New variable value. + */ + newValue: Runtime.CallArgument; + /** + * Id of callframe that holds variable. + */ + callFrameId: CallFrameId; + } + interface SetReturnValueParameterType { + /** + * New return value. + */ + newValue: Runtime.CallArgument; + } + interface SetAsyncCallStackDepthParameterType { + /** + * Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default). + */ + maxDepth: number; + } + interface SetBlackboxPatternsParameterType { + /** + * Array of regexps that will be used to check script url for blackbox state. + */ + patterns: string[]; + } + interface SetBlackboxedRangesParameterType { + /** + * Id of the script. + */ + scriptId: Runtime.ScriptId; + positions: ScriptPosition[]; + } + interface EnableReturnType { + /** + * Unique identifier of the debugger. + * @experimental + */ + debuggerId: Runtime.UniqueDebuggerId; + } + interface SetBreakpointByUrlReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * List of the locations this breakpoint resolved into upon addition. + */ + locations: Location[]; + } + interface SetBreakpointReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * Location this breakpoint resolved into. + */ + actualLocation: Location; + } + interface GetPossibleBreakpointsReturnType { + /** + * List of the possible breakpoint locations. + */ + locations: BreakLocation[]; + } + interface GetStackTraceReturnType { + stackTrace: Runtime.StackTrace; + } + interface SearchInContentReturnType { + /** + * List of search matches. + */ + result: SearchMatch[]; + } + interface SetScriptSourceReturnType { + /** + * New stack trace in case editing has happened while VM was stopped. + */ + callFrames?: CallFrame[] | undefined; + /** + * Whether current call stack was modified after applying the changes. + */ + stackChanged?: boolean | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Exception details if any. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface RestartFrameReturnType { + /** + * New stack trace. + */ + callFrames: CallFrame[]; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + } + interface GetScriptSourceReturnType { + /** + * Script source. + */ + scriptSource: string; + } + interface EvaluateOnCallFrameReturnType { + /** + * Object wrapper for the evaluation result. + */ + result: Runtime.RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface ScriptParsedEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * True, if this script is generated as a result of the live edit operation. + * @experimental + */ + isLiveEdit?: boolean | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface ScriptFailedToParseEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface BreakpointResolvedEventDataType { + /** + * Breakpoint unique identifier. + */ + breakpointId: BreakpointId; + /** + * Actual breakpoint location. + */ + location: Location; + } + interface PausedEventDataType { + /** + * Call stack the virtual machine stopped on. + */ + callFrames: CallFrame[]; + /** + * Pause reason. + */ + reason: string; + /** + * Object containing break-specific auxiliary properties. + */ + data?: {} | undefined; + /** + * Hit breakpoints IDs + */ + hitBreakpoints?: string[] | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Just scheduled async call will have this stack trace as parent stack during async execution. This field is available only after Debugger.stepInto call with breakOnAsynCall flag. + * @experimental + */ + asyncCallStackTraceId?: Runtime.StackTraceId | undefined; + } + } + namespace Console { + /** + * Console message. + */ + interface ConsoleMessage { + /** + * Message source. + */ + source: string; + /** + * Message severity. + */ + level: string; + /** + * Message text. + */ + text: string; + /** + * URL of the message origin. + */ + url?: string | undefined; + /** + * Line number in the resource that generated this message (1-based). + */ + line?: number | undefined; + /** + * Column number in the resource that generated this message (1-based). + */ + column?: number | undefined; + } + interface MessageAddedEventDataType { + /** + * Console message that has been added. + */ + message: ConsoleMessage; + } + } + namespace Profiler { + /** + * Profile node. Holds callsite information, execution statistics and child nodes. + */ + interface ProfileNode { + /** + * Unique id of the node. + */ + id: number; + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Number of samples where this node was on top of the call stack. + */ + hitCount?: number | undefined; + /** + * Child node ids. + */ + children?: number[] | undefined; + /** + * The reason of being not optimized. The function may be deoptimized or marked as don't optimize. + */ + deoptReason?: string | undefined; + /** + * An array of source position ticks. + */ + positionTicks?: PositionTickInfo[] | undefined; + } + /** + * Profile. + */ + interface Profile { + /** + * The list of profile nodes. First item is the root node. + */ + nodes: ProfileNode[]; + /** + * Profiling start timestamp in microseconds. + */ + startTime: number; + /** + * Profiling end timestamp in microseconds. + */ + endTime: number; + /** + * Ids of samples top nodes. + */ + samples?: number[] | undefined; + /** + * Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime. + */ + timeDeltas?: number[] | undefined; + } + /** + * Specifies a number of samples attributed to a certain source position. + */ + interface PositionTickInfo { + /** + * Source line number (1-based). + */ + line: number; + /** + * Number of samples attributed to the source line. + */ + ticks: number; + } + /** + * Coverage data for a source range. + */ + interface CoverageRange { + /** + * JavaScript script source offset for the range start. + */ + startOffset: number; + /** + * JavaScript script source offset for the range end. + */ + endOffset: number; + /** + * Collected execution count of the source range. + */ + count: number; + } + /** + * Coverage data for a JavaScript function. + */ + interface FunctionCoverage { + /** + * JavaScript function name. + */ + functionName: string; + /** + * Source ranges inside the function with coverage data. + */ + ranges: CoverageRange[]; + /** + * Whether coverage data for this function has block granularity. + */ + isBlockCoverage: boolean; + } + /** + * Coverage data for a JavaScript script. + */ + interface ScriptCoverage { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Functions contained in the script that has coverage data. + */ + functions: FunctionCoverage[]; + } + /** + * Describes a type collected during runtime. + * @experimental + */ + interface TypeObject { + /** + * Name of a type collected with type profiling. + */ + name: string; + } + /** + * Source offset and types for a parameter or return value. + * @experimental + */ + interface TypeProfileEntry { + /** + * Source offset of the parameter or end of function for return values. + */ + offset: number; + /** + * The types for this parameter or return value. + */ + types: TypeObject[]; + } + /** + * Type profile data collected during runtime for a JavaScript script. + * @experimental + */ + interface ScriptTypeProfile { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Type profile entries for parameters and return values of the functions in the script. + */ + entries: TypeProfileEntry[]; + } + interface SetSamplingIntervalParameterType { + /** + * New sampling interval in microseconds. + */ + interval: number; + } + interface StartPreciseCoverageParameterType { + /** + * Collect accurate call counts beyond simple 'covered' or 'not covered'. + */ + callCount?: boolean | undefined; + /** + * Collect block-based coverage. + */ + detailed?: boolean | undefined; + } + interface StopReturnType { + /** + * Recorded profile. + */ + profile: Profile; + } + interface TakePreciseCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface GetBestEffortCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface TakeTypeProfileReturnType { + /** + * Type profile for all scripts since startTypeProfile() was turned on. + */ + result: ScriptTypeProfile[]; + } + interface ConsoleProfileStartedEventDataType { + id: string; + /** + * Location of console.profile(). + */ + location: Debugger.Location; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + interface ConsoleProfileFinishedEventDataType { + id: string; + /** + * Location of console.profileEnd(). + */ + location: Debugger.Location; + profile: Profile; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + } + namespace HeapProfiler { + /** + * Heap snapshot object id. + */ + type HeapSnapshotObjectId = string; + /** + * Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes. + */ + interface SamplingHeapProfileNode { + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Allocations size in bytes for the node excluding children. + */ + selfSize: number; + /** + * Child nodes. + */ + children: SamplingHeapProfileNode[]; + } + /** + * Profile. + */ + interface SamplingHeapProfile { + head: SamplingHeapProfileNode; + } + interface StartTrackingHeapObjectsParameterType { + trackAllocations?: boolean | undefined; + } + interface StopTrackingHeapObjectsParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped. + */ + reportProgress?: boolean | undefined; + } + interface TakeHeapSnapshotParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. + */ + reportProgress?: boolean | undefined; + } + interface GetObjectByHeapObjectIdParameterType { + objectId: HeapSnapshotObjectId; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + } + interface AddInspectedHeapObjectParameterType { + /** + * Heap snapshot object id to be accessible by means of $x command line API. + */ + heapObjectId: HeapSnapshotObjectId; + } + interface GetHeapObjectIdParameterType { + /** + * Identifier of the object to get heap object id for. + */ + objectId: Runtime.RemoteObjectId; + } + interface StartSamplingParameterType { + /** + * Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. + */ + samplingInterval?: number | undefined; + } + interface GetObjectByHeapObjectIdReturnType { + /** + * Evaluation result. + */ + result: Runtime.RemoteObject; + } + interface GetHeapObjectIdReturnType { + /** + * Id of the heap snapshot object corresponding to the passed remote object id. + */ + heapSnapshotObjectId: HeapSnapshotObjectId; + } + interface StopSamplingReturnType { + /** + * Recorded sampling heap profile. + */ + profile: SamplingHeapProfile; + } + interface GetSamplingProfileReturnType { + /** + * Return the sampling profile being collected. + */ + profile: SamplingHeapProfile; + } + interface AddHeapSnapshotChunkEventDataType { + chunk: string; + } + interface ReportHeapSnapshotProgressEventDataType { + done: number; + total: number; + finished?: boolean | undefined; + } + interface LastSeenObjectIdEventDataType { + lastSeenObjectId: number; + timestamp: number; + } + interface HeapStatsUpdateEventDataType { + /** + * An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment. + */ + statsUpdate: number[]; + } + } + namespace NodeTracing { + interface TraceConfig { + /** + * Controls how the trace buffer stores data. + */ + recordMode?: string | undefined; + /** + * Included category filters. + */ + includedCategories: string[]; + } + interface StartParameterType { + traceConfig: TraceConfig; + } + interface GetCategoriesReturnType { + /** + * A list of supported tracing categories. + */ + categories: string[]; + } + interface DataCollectedEventDataType { + value: Array<{}>; + } + } + namespace NodeWorker { + type WorkerID = string; + /** + * Unique identifier of attached debugging session. + */ + type SessionID = string; + interface WorkerInfo { + workerId: WorkerID; + type: string; + title: string; + url: string; + } + interface SendMessageToWorkerParameterType { + message: string; + /** + * Identifier of the session. + */ + sessionId: SessionID; + } + interface EnableParameterType { + /** + * Whether to new workers should be paused until the frontend sends `Runtime.runIfWaitingForDebugger` + * message to run them. + */ + waitForDebuggerOnStart: boolean; + } + interface DetachParameterType { + sessionId: SessionID; + } + interface AttachedToWorkerEventDataType { + /** + * Identifier assigned to the session used to send/receive messages. + */ + sessionId: SessionID; + workerInfo: WorkerInfo; + waitingForDebugger: boolean; + } + interface DetachedFromWorkerEventDataType { + /** + * Detached session identifier. + */ + sessionId: SessionID; + } + interface ReceivedMessageFromWorkerEventDataType { + /** + * Identifier of a session which sends a message. + */ + sessionId: SessionID; + message: string; + } + } + namespace NodeRuntime { + interface NotifyWhenWaitingForDisconnectParameterType { + enabled: boolean; + } + } + /** + * The `inspector.Session` is used for dispatching messages to the V8 inspector + * back-end and receiving message responses and notifications. + */ + class Session extends EventEmitter { + /** + * Create a new instance of the inspector.Session class. + * The inspector session needs to be connected through session.connect() before the messages can be dispatched to the inspector backend. + */ + constructor(); + /** + * Connects a session to the inspector back-end. + * @since v8.0.0 + */ + connect(): void; + /** + * Immediately close the session. All pending message callbacks will be called + * with an error. `session.connect()` will need to be called to be able to send + * messages again. Reconnected session will lose all inspector state, such as + * enabled agents or configured breakpoints. + * @since v8.0.0 + */ + disconnect(): void; + /** + * Posts a message to the inspector back-end. `callback` will be notified when + * a response is received. `callback` is a function that accepts two optional + * arguments: error and message-specific result. + * + * ```js + * session.post('Runtime.evaluate', { expression: '2 + 2' }, + * (error, { result }) => console.log(result)); + * // Output: { type: 'number', value: 4, description: '4' } + * ``` + * + * The latest version of the V8 inspector protocol is published on the [Chrome DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/v8/). + * + * Node.js inspector supports all the Chrome DevTools Protocol domains declared + * by V8\. Chrome DevTools Protocol domain provides an interface for interacting + * with one of the runtime agents used to inspect the application state and listen + * to the run-time events. + * + * ## Example usage + * + * Apart from the debugger, various V8 Profilers are available through the DevTools + * protocol. + * @since v8.0.0 + */ + post(method: string, params?: {}, callback?: (err: Error | null, params?: {}) => void): void; + post(method: string, callback?: (err: Error | null, params?: {}) => void): void; + /** + * Returns supported domains. + */ + post(method: 'Schema.getDomains', callback?: (err: Error | null, params: Schema.GetDomainsReturnType) => void): void; + /** + * Evaluates expression on global object. + */ + post(method: 'Runtime.evaluate', params?: Runtime.EvaluateParameterType, callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void): void; + post(method: 'Runtime.evaluate', callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void): void; + /** + * Add handler to promise with given promise object id. + */ + post(method: 'Runtime.awaitPromise', params?: Runtime.AwaitPromiseParameterType, callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void): void; + post(method: 'Runtime.awaitPromise', callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void): void; + /** + * Calls function with given declaration on the given object. Object group of the result is inherited from the target object. + */ + post(method: 'Runtime.callFunctionOn', params?: Runtime.CallFunctionOnParameterType, callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void): void; + post(method: 'Runtime.callFunctionOn', callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void): void; + /** + * Returns properties of a given object. Object group of the result is inherited from the target object. + */ + post(method: 'Runtime.getProperties', params?: Runtime.GetPropertiesParameterType, callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void): void; + post(method: 'Runtime.getProperties', callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void): void; + /** + * Releases remote object with given id. + */ + post(method: 'Runtime.releaseObject', params?: Runtime.ReleaseObjectParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Runtime.releaseObject', callback?: (err: Error | null) => void): void; + /** + * Releases all remote objects that belong to a given group. + */ + post(method: 'Runtime.releaseObjectGroup', params?: Runtime.ReleaseObjectGroupParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Runtime.releaseObjectGroup', callback?: (err: Error | null) => void): void; + /** + * Tells inspected instance to run if it was waiting for debugger to attach. + */ + post(method: 'Runtime.runIfWaitingForDebugger', callback?: (err: Error | null) => void): void; + /** + * Enables reporting of execution contexts creation by means of executionContextCreated event. When the reporting gets enabled the event will be sent immediately for each existing execution context. + */ + post(method: 'Runtime.enable', callback?: (err: Error | null) => void): void; + /** + * Disables reporting of execution contexts creation. + */ + post(method: 'Runtime.disable', callback?: (err: Error | null) => void): void; + /** + * Discards collected exceptions and console API calls. + */ + post(method: 'Runtime.discardConsoleEntries', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post(method: 'Runtime.setCustomObjectFormatterEnabled', params?: Runtime.SetCustomObjectFormatterEnabledParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Runtime.setCustomObjectFormatterEnabled', callback?: (err: Error | null) => void): void; + /** + * Compiles expression. + */ + post(method: 'Runtime.compileScript', params?: Runtime.CompileScriptParameterType, callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void): void; + post(method: 'Runtime.compileScript', callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void): void; + /** + * Runs script with given id in a given context. + */ + post(method: 'Runtime.runScript', params?: Runtime.RunScriptParameterType, callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void): void; + post(method: 'Runtime.runScript', callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void): void; + post(method: 'Runtime.queryObjects', params?: Runtime.QueryObjectsParameterType, callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void): void; + post(method: 'Runtime.queryObjects', callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void): void; + /** + * Returns all let, const and class variables from global scope. + */ + post( + method: 'Runtime.globalLexicalScopeNames', + params?: Runtime.GlobalLexicalScopeNamesParameterType, + callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void + ): void; + post(method: 'Runtime.globalLexicalScopeNames', callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void): void; + /** + * Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received. + */ + post(method: 'Debugger.enable', callback?: (err: Error | null, params: Debugger.EnableReturnType) => void): void; + /** + * Disables debugger for given page. + */ + post(method: 'Debugger.disable', callback?: (err: Error | null) => void): void; + /** + * Activates / deactivates all breakpoints on the page. + */ + post(method: 'Debugger.setBreakpointsActive', params?: Debugger.SetBreakpointsActiveParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setBreakpointsActive', callback?: (err: Error | null) => void): void; + /** + * Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). + */ + post(method: 'Debugger.setSkipAllPauses', params?: Debugger.SetSkipAllPausesParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setSkipAllPauses', callback?: (err: Error | null) => void): void; + /** + * Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads. + */ + post(method: 'Debugger.setBreakpointByUrl', params?: Debugger.SetBreakpointByUrlParameterType, callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void): void; + post(method: 'Debugger.setBreakpointByUrl', callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void): void; + /** + * Sets JavaScript breakpoint at a given location. + */ + post(method: 'Debugger.setBreakpoint', params?: Debugger.SetBreakpointParameterType, callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void): void; + post(method: 'Debugger.setBreakpoint', callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void): void; + /** + * Removes JavaScript breakpoint. + */ + post(method: 'Debugger.removeBreakpoint', params?: Debugger.RemoveBreakpointParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.removeBreakpoint', callback?: (err: Error | null) => void): void; + /** + * Returns possible locations for breakpoint. scriptId in start and end range locations should be the same. + */ + post( + method: 'Debugger.getPossibleBreakpoints', + params?: Debugger.GetPossibleBreakpointsParameterType, + callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void + ): void; + post(method: 'Debugger.getPossibleBreakpoints', callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void): void; + /** + * Continues execution until specific location is reached. + */ + post(method: 'Debugger.continueToLocation', params?: Debugger.ContinueToLocationParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.continueToLocation', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post(method: 'Debugger.pauseOnAsyncCall', params?: Debugger.PauseOnAsyncCallParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.pauseOnAsyncCall', callback?: (err: Error | null) => void): void; + /** + * Steps over the statement. + */ + post(method: 'Debugger.stepOver', callback?: (err: Error | null) => void): void; + /** + * Steps into the function call. + */ + post(method: 'Debugger.stepInto', params?: Debugger.StepIntoParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.stepInto', callback?: (err: Error | null) => void): void; + /** + * Steps out of the function call. + */ + post(method: 'Debugger.stepOut', callback?: (err: Error | null) => void): void; + /** + * Stops on the next JavaScript statement. + */ + post(method: 'Debugger.pause', callback?: (err: Error | null) => void): void; + /** + * This method is deprecated - use Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next scheduled async task if any is scheduled before next pause. Returns success when async task is actually scheduled, returns error if no task were scheduled or another scheduleStepIntoAsync was called. + * @experimental + */ + post(method: 'Debugger.scheduleStepIntoAsync', callback?: (err: Error | null) => void): void; + /** + * Resumes JavaScript execution. + */ + post(method: 'Debugger.resume', callback?: (err: Error | null) => void): void; + /** + * Returns stack trace with given stackTraceId. + * @experimental + */ + post(method: 'Debugger.getStackTrace', params?: Debugger.GetStackTraceParameterType, callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void): void; + post(method: 'Debugger.getStackTrace', callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void): void; + /** + * Searches for given string in script content. + */ + post(method: 'Debugger.searchInContent', params?: Debugger.SearchInContentParameterType, callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void): void; + post(method: 'Debugger.searchInContent', callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void): void; + /** + * Edits JavaScript source live. + */ + post(method: 'Debugger.setScriptSource', params?: Debugger.SetScriptSourceParameterType, callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void): void; + post(method: 'Debugger.setScriptSource', callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void): void; + /** + * Restarts particular call frame from the beginning. + */ + post(method: 'Debugger.restartFrame', params?: Debugger.RestartFrameParameterType, callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void): void; + post(method: 'Debugger.restartFrame', callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void): void; + /** + * Returns source for the script with given id. + */ + post(method: 'Debugger.getScriptSource', params?: Debugger.GetScriptSourceParameterType, callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void): void; + post(method: 'Debugger.getScriptSource', callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void): void; + /** + * Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none. + */ + post(method: 'Debugger.setPauseOnExceptions', params?: Debugger.SetPauseOnExceptionsParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setPauseOnExceptions', callback?: (err: Error | null) => void): void; + /** + * Evaluates expression on a given call frame. + */ + post(method: 'Debugger.evaluateOnCallFrame', params?: Debugger.EvaluateOnCallFrameParameterType, callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void): void; + post(method: 'Debugger.evaluateOnCallFrame', callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void): void; + /** + * Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually. + */ + post(method: 'Debugger.setVariableValue', params?: Debugger.SetVariableValueParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setVariableValue', callback?: (err: Error | null) => void): void; + /** + * Changes return value in top frame. Available only at return break position. + * @experimental + */ + post(method: 'Debugger.setReturnValue', params?: Debugger.SetReturnValueParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setReturnValue', callback?: (err: Error | null) => void): void; + /** + * Enables or disables async call stacks tracking. + */ + post(method: 'Debugger.setAsyncCallStackDepth', params?: Debugger.SetAsyncCallStackDepthParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setAsyncCallStackDepth', callback?: (err: Error | null) => void): void; + /** + * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. + * @experimental + */ + post(method: 'Debugger.setBlackboxPatterns', params?: Debugger.SetBlackboxPatternsParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setBlackboxPatterns', callback?: (err: Error | null) => void): void; + /** + * Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted. + * @experimental + */ + post(method: 'Debugger.setBlackboxedRanges', params?: Debugger.SetBlackboxedRangesParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setBlackboxedRanges', callback?: (err: Error | null) => void): void; + /** + * Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification. + */ + post(method: 'Console.enable', callback?: (err: Error | null) => void): void; + /** + * Disables console domain, prevents further console messages from being reported to the client. + */ + post(method: 'Console.disable', callback?: (err: Error | null) => void): void; + /** + * Does nothing. + */ + post(method: 'Console.clearMessages', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.disable', callback?: (err: Error | null) => void): void; + /** + * Changes CPU profiler sampling interval. Must be called before CPU profiles recording started. + */ + post(method: 'Profiler.setSamplingInterval', params?: Profiler.SetSamplingIntervalParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Profiler.setSamplingInterval', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.start', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.stop', callback?: (err: Error | null, params: Profiler.StopReturnType) => void): void; + /** + * Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters. + */ + post(method: 'Profiler.startPreciseCoverage', params?: Profiler.StartPreciseCoverageParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Profiler.startPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code. + */ + post(method: 'Profiler.stopPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started. + */ + post(method: 'Profiler.takePreciseCoverage', callback?: (err: Error | null, params: Profiler.TakePreciseCoverageReturnType) => void): void; + /** + * Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection. + */ + post(method: 'Profiler.getBestEffortCoverage', callback?: (err: Error | null, params: Profiler.GetBestEffortCoverageReturnType) => void): void; + /** + * Enable type profile. + * @experimental + */ + post(method: 'Profiler.startTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Disable type profile. Disabling releases type profile data collected so far. + * @experimental + */ + post(method: 'Profiler.stopTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Collect type profile. + * @experimental + */ + post(method: 'Profiler.takeTypeProfile', callback?: (err: Error | null, params: Profiler.TakeTypeProfileReturnType) => void): void; + post(method: 'HeapProfiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.disable', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.startTrackingHeapObjects', params?: HeapProfiler.StartTrackingHeapObjectsParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.startTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.stopTrackingHeapObjects', params?: HeapProfiler.StopTrackingHeapObjectsParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.stopTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.takeHeapSnapshot', params?: HeapProfiler.TakeHeapSnapshotParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.takeHeapSnapshot', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.collectGarbage', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.getObjectByHeapObjectId', + params?: HeapProfiler.GetObjectByHeapObjectIdParameterType, + callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void + ): void; + post(method: 'HeapProfiler.getObjectByHeapObjectId', callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void): void; + /** + * Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions). + */ + post(method: 'HeapProfiler.addInspectedHeapObject', params?: HeapProfiler.AddInspectedHeapObjectParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.addInspectedHeapObject', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.getHeapObjectId', params?: HeapProfiler.GetHeapObjectIdParameterType, callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void): void; + post(method: 'HeapProfiler.getHeapObjectId', callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void): void; + post(method: 'HeapProfiler.startSampling', params?: HeapProfiler.StartSamplingParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.startSampling', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.stopSampling', callback?: (err: Error | null, params: HeapProfiler.StopSamplingReturnType) => void): void; + post(method: 'HeapProfiler.getSamplingProfile', callback?: (err: Error | null, params: HeapProfiler.GetSamplingProfileReturnType) => void): void; + /** + * Gets supported tracing categories. + */ + post(method: 'NodeTracing.getCategories', callback?: (err: Error | null, params: NodeTracing.GetCategoriesReturnType) => void): void; + /** + * Start trace events collection. + */ + post(method: 'NodeTracing.start', params?: NodeTracing.StartParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeTracing.start', callback?: (err: Error | null) => void): void; + /** + * Stop trace events collection. Remaining collected events will be sent as a sequence of + * dataCollected events followed by tracingComplete event. + */ + post(method: 'NodeTracing.stop', callback?: (err: Error | null) => void): void; + /** + * Sends protocol message over session with given id. + */ + post(method: 'NodeWorker.sendMessageToWorker', params?: NodeWorker.SendMessageToWorkerParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeWorker.sendMessageToWorker', callback?: (err: Error | null) => void): void; + /** + * Instructs the inspector to attach to running workers. Will also attach to new workers + * as they start + */ + post(method: 'NodeWorker.enable', params?: NodeWorker.EnableParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeWorker.enable', callback?: (err: Error | null) => void): void; + /** + * Detaches from all running workers and disables attaching to new workers as they are started. + */ + post(method: 'NodeWorker.disable', callback?: (err: Error | null) => void): void; + /** + * Detached from the worker with given sessionId. + */ + post(method: 'NodeWorker.detach', params?: NodeWorker.DetachParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeWorker.detach', callback?: (err: Error | null) => void): void; + /** + * Enable the `NodeRuntime.waitingForDisconnect`. + */ + post(method: 'NodeRuntime.notifyWhenWaitingForDisconnect', params?: NodeRuntime.NotifyWhenWaitingForDisconnectParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeRuntime.notifyWhenWaitingForDisconnect', callback?: (err: Error | null) => void): void; + // Events + addListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + addListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + addListener(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + addListener(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + addListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + addListener(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + addListener(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + addListener(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + addListener(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + addListener(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + addListener(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + addListener(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + addListener(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + addListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + addListener(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + addListener(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + addListener(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + addListener(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + addListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + addListener(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + addListener(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + addListener(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + addListener(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + addListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + addListener(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + addListener(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + addListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + addListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: 'inspectorNotification', message: InspectorNotification<{}>): boolean; + emit(event: 'Runtime.executionContextCreated', message: InspectorNotification): boolean; + emit(event: 'Runtime.executionContextDestroyed', message: InspectorNotification): boolean; + emit(event: 'Runtime.executionContextsCleared'): boolean; + emit(event: 'Runtime.exceptionThrown', message: InspectorNotification): boolean; + emit(event: 'Runtime.exceptionRevoked', message: InspectorNotification): boolean; + emit(event: 'Runtime.consoleAPICalled', message: InspectorNotification): boolean; + emit(event: 'Runtime.inspectRequested', message: InspectorNotification): boolean; + emit(event: 'Debugger.scriptParsed', message: InspectorNotification): boolean; + emit(event: 'Debugger.scriptFailedToParse', message: InspectorNotification): boolean; + emit(event: 'Debugger.breakpointResolved', message: InspectorNotification): boolean; + emit(event: 'Debugger.paused', message: InspectorNotification): boolean; + emit(event: 'Debugger.resumed'): boolean; + emit(event: 'Console.messageAdded', message: InspectorNotification): boolean; + emit(event: 'Profiler.consoleProfileStarted', message: InspectorNotification): boolean; + emit(event: 'Profiler.consoleProfileFinished', message: InspectorNotification): boolean; + emit(event: 'HeapProfiler.addHeapSnapshotChunk', message: InspectorNotification): boolean; + emit(event: 'HeapProfiler.resetProfiles'): boolean; + emit(event: 'HeapProfiler.reportHeapSnapshotProgress', message: InspectorNotification): boolean; + emit(event: 'HeapProfiler.lastSeenObjectId', message: InspectorNotification): boolean; + emit(event: 'HeapProfiler.heapStatsUpdate', message: InspectorNotification): boolean; + emit(event: 'NodeTracing.dataCollected', message: InspectorNotification): boolean; + emit(event: 'NodeTracing.tracingComplete'): boolean; + emit(event: 'NodeWorker.attachedToWorker', message: InspectorNotification): boolean; + emit(event: 'NodeWorker.detachedFromWorker', message: InspectorNotification): boolean; + emit(event: 'NodeWorker.receivedMessageFromWorker', message: InspectorNotification): boolean; + emit(event: 'NodeRuntime.waitingForDisconnect'): boolean; + on(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + on(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + on(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + on(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + on(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + on(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + on(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + on(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + on(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + on(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + on(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + on(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + on(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + on(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + on(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + on(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + on(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + on(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + on(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + on(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + on(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + on(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + on(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + on(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + on(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + on(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + on(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + on(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + once(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + once(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + once(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + once(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + once(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + once(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + once(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + once(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + once(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + once(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + once(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + once(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + once(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + once(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + once(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + once(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + once(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + once(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + once(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + once(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + once(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + once(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + once(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + once(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + once(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + once(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + once(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependListener(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + prependListener(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependListener(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + prependListener(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + prependListener(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependListener(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependListener(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependListener(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependListener(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependListener(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependListener(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependListener(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + prependListener(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + prependListener(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + prependListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependListener(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependListener(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependListener(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + prependListener(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependListener(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + prependListener(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependOnceListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependOnceListener(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + prependOnceListener(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependOnceListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependOnceListener(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + prependOnceListener(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + prependOnceListener(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependOnceListener(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependOnceListener(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependOnceListener(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependOnceListener(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependOnceListener(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependOnceListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependOnceListener(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependOnceListener(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + prependOnceListener(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + prependOnceListener(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + prependOnceListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependOnceListener(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependOnceListener(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependOnceListener(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + prependOnceListener(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependOnceListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependOnceListener(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + prependOnceListener(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependOnceListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependOnceListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + } + /** + * Activate inspector on host and port. Equivalent to`node --inspect=[[host:]port]`, but can be done programmatically after node has + * started. + * + * If wait is `true`, will block until a client has connected to the inspect port + * and flow control has been passed to the debugger client. + * + * See the `security warning` regarding the `host`parameter usage. + * @param [port='what was specified on the CLI'] Port to listen on for inspector connections. Optional. + * @param [host='what was specified on the CLI'] Host to listen on for inspector connections. Optional. + * @param [wait=false] Block until a client has connected. Optional. + * @returns Disposable that calls `inspector.close()`. + */ + function open(port?: number, host?: string, wait?: boolean): Disposable; + /** + * Deactivate the inspector. Blocks until there are no active connections. + */ + function close(): void; + /** + * Return the URL of the active inspector, or `undefined` if there is none. + * + * ```console + * $ node --inspect -p 'inspector.url()' + * Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * For help, see: https://nodejs.org/en/docs/inspector + * ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * + * $ node --inspect=localhost:3000 -p 'inspector.url()' + * Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * For help, see: https://nodejs.org/en/docs/inspector + * ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * + * $ node -p 'inspector.url()' + * undefined + * ``` + */ + function url(): string | undefined; + /** + * Blocks until a client (existing or connected later) has sent`Runtime.runIfWaitingForDebugger` command. + * + * An exception will be thrown if there is no active inspector. + * @since v12.7.0 + */ + function waitForDebugger(): void; +} +/** + * The inspector module provides an API for interacting with the V8 inspector. + */ +declare module 'node:inspector' { + import inspector = require('inspector'); + export = inspector; +} diff --git a/node_modules/@types/node/module.d.ts b/node_modules/@types/node/module.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..68d59c7737bda512502cf2d3ec9c48483c56295e --- /dev/null +++ b/node_modules/@types/node/module.d.ts @@ -0,0 +1,301 @@ +/** + * @since v0.3.7 + * @experimental + */ +declare module "module" { + import { URL } from "node:url"; + import { MessagePort } from "node:worker_threads"; + namespace Module { + /** + * The `module.syncBuiltinESMExports()` method updates all the live bindings for + * builtin `ES Modules` to match the properties of the `CommonJS` exports. It + * does not add or remove exported names from the `ES Modules`. + * + * ```js + * const fs = require('node:fs'); + * const assert = require('node:assert'); + * const { syncBuiltinESMExports } = require('node:module'); + * + * fs.readFile = newAPI; + * + * delete fs.readFileSync; + * + * function newAPI() { + * // ... + * } + * + * fs.newAPI = newAPI; + * + * syncBuiltinESMExports(); + * + * import('node:fs').then((esmFS) => { + * // It syncs the existing readFile property with the new value + * assert.strictEqual(esmFS.readFile, newAPI); + * // readFileSync has been deleted from the required fs + * assert.strictEqual('readFileSync' in fs, false); + * // syncBuiltinESMExports() does not remove readFileSync from esmFS + * assert.strictEqual('readFileSync' in esmFS, true); + * // syncBuiltinESMExports() does not add names + * assert.strictEqual(esmFS.newAPI, undefined); + * }); + * ``` + * @since v12.12.0 + */ + function syncBuiltinESMExports(): void; + /** + * `path` is the resolved path for the file for which a corresponding source map + * should be fetched. + * @since v13.7.0, v12.17.0 + * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. + */ + function findSourceMap(path: string, error?: Error): SourceMap; + interface SourceMapPayload { + file: string; + version: number; + sources: string[]; + sourcesContent: string[]; + names: string[]; + mappings: string; + sourceRoot: string; + } + interface SourceMapping { + generatedLine: number; + generatedColumn: number; + originalSource: string; + originalLine: number; + originalColumn: number; + } + interface SourceOrigin { + /** + * The name of the range in the source map, if one was provided + */ + name?: string; + /** + * The file name of the original source, as reported in the SourceMap + */ + fileName: string; + /** + * The 1-indexed lineNumber of the corresponding call site in the original source + */ + lineNumber: number; + /** + * The 1-indexed columnNumber of the corresponding call site in the original source + */ + columnNumber: number; + } + /** + * @since v13.7.0, v12.17.0 + */ + class SourceMap { + /** + * Getter for the payload used to construct the `SourceMap` instance. + */ + readonly payload: SourceMapPayload; + constructor(payload: SourceMapPayload); + /** + * Given a line offset and column offset in the generated source + * file, returns an object representing the SourceMap range in the + * original file if found, or an empty object if not. + * + * The object returned contains the following keys: + * + * The returned value represents the raw range as it appears in the + * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and + * column numbers as they appear in Error messages and CallSite + * objects. + * + * To get the corresponding 1-indexed line and column numbers from a + * lineNumber and columnNumber as they are reported by Error stacks + * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)` + * @param lineOffset The zero-indexed line number offset in the generated source + * @param columnOffset The zero-indexed column number offset in the generated source + */ + findEntry(lineOffset: number, columnOffset: number): SourceMapping; + /** + * Given a 1-indexed `lineNumber` and `columnNumber` from a call site in the generated source, + * find the corresponding call site location in the original source. + * + * If the `lineNumber` and `columnNumber` provided are not found in any source map, + * then an empty object is returned. + * @param lineNumber The 1-indexed line number of the call site in the generated source + * @param columnNumber The 1-indexed column number of the call site in the generated source + */ + findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {}; + } + /** @deprecated Use `ImportAttributes` instead */ + interface ImportAssertions extends ImportAttributes {} + interface ImportAttributes extends NodeJS.Dict { + type?: string | undefined; + } + type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm"; + type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray; + interface GlobalPreloadContext { + port: MessagePort; + } + /** + * @deprecated This hook will be removed in a future version. + * Use `initialize` instead. When a loader has an `initialize` export, `globalPreload` will be ignored. + * + * Sometimes it might be necessary to run some code inside of the same global scope that the application runs in. + * This hook allows the return of a string that is run as a sloppy-mode script on startup. + * + * @param context Information to assist the preload code + * @return Code to run before application startup + */ + type GlobalPreloadHook = (context: GlobalPreloadContext) => string; + /** + * The `initialize` hook provides a way to define a custom function that runs in the hooks thread + * when the hooks module is initialized. Initialization happens when the hooks module is registered via `register`. + * + * This hook can receive data from a `register` invocation, including ports and other transferrable objects. + * The return value of `initialize` can be a `Promise`, in which case it will be awaited before the main application thread execution resumes. + */ + type InitializeHook = (data: Data) => void | Promise; + interface ResolveHookContext { + /** + * Export conditions of the relevant `package.json` + */ + conditions: string[]; + /** + * @deprecated Use `importAttributes` instead + */ + importAssertions: ImportAttributes; + /** + * An object whose key-value pairs represent the assertions for the module to import + */ + importAttributes: ImportAttributes; + /** + * The module importing this one, or undefined if this is the Node.js entry point + */ + parentURL: string | undefined; + } + interface ResolveFnOutput { + /** + * A hint to the load hook (it might be ignored) + */ + format?: ModuleFormat | null | undefined; + /** + * @deprecated Use `importAttributes` instead + */ + importAssertions?: ImportAttributes | undefined; + /** + * The import attributes to use when caching the module (optional; if excluded the input will be used) + */ + importAttributes?: ImportAttributes | undefined; + /** + * A signal that this hook intends to terminate the chain of `resolve` hooks. + * @default false + */ + shortCircuit?: boolean | undefined; + /** + * The absolute URL to which this input resolves + */ + url: string; + } + /** + * The `resolve` hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as `'module'`) as a hint to the `load` hook. + * If a format is specified, the load hook is ultimately responsible for providing the final `format` value (and it is free to ignore the hint provided by `resolve`); + * if `resolve` provides a format, a custom `load` hook is required even if only to pass the value to the Node.js default `load` hook. + * + * @param specifier The specified URL path of the module to be resolved + * @param context + * @param nextResolve The subsequent `resolve` hook in the chain, or the Node.js default `resolve` hook after the last user-supplied resolve hook + */ + type ResolveHook = ( + specifier: string, + context: ResolveHookContext, + nextResolve: ( + specifier: string, + context?: ResolveHookContext, + ) => ResolveFnOutput | Promise, + ) => ResolveFnOutput | Promise; + interface LoadHookContext { + /** + * Export conditions of the relevant `package.json` + */ + conditions: string[]; + /** + * The format optionally supplied by the `resolve` hook chain + */ + format: ModuleFormat; + /** + * @deprecated Use `importAttributes` instead + */ + importAssertions: ImportAttributes; + /** + * An object whose key-value pairs represent the assertions for the module to import + */ + importAttributes: ImportAttributes; + } + interface LoadFnOutput { + format: ModuleFormat; + /** + * A signal that this hook intends to terminate the chain of `resolve` hooks. + * @default false + */ + shortCircuit?: boolean | undefined; + /** + * The source for Node.js to evaluate + */ + source?: ModuleSource; + } + /** + * The `load` hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed. + * It is also in charge of validating the import assertion. + * + * @param url The URL/path of the module to be loaded + * @param context Metadata about the module + * @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook + */ + type LoadHook = ( + url: string, + context: LoadHookContext, + nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise, + ) => LoadFnOutput | Promise; + } + interface RegisterOptions { + parentURL: string | URL; + data?: Data | undefined; + transferList?: any[] | undefined; + } + interface Module extends NodeModule {} + class Module { + static runMain(): void; + static wrap(code: string): string; + static createRequire(path: string | URL): NodeRequire; + static builtinModules: string[]; + static isBuiltin(moduleName: string): boolean; + static Module: typeof Module; + static register( + specifier: string | URL, + parentURL?: string | URL, + options?: RegisterOptions, + ): void; + static register(specifier: string | URL, options?: RegisterOptions): void; + constructor(id: string, parent?: Module); + } + global { + interface ImportMeta { + url: string; + /** + * Provides a module-relative resolution function scoped to each module, returning + * the URL string. + * + * Second `parent` parameter is only used when the `--experimental-import-meta-resolve` + * command flag enabled. + * + * @since v20.6.0 + * + * @param specifier The module specifier to resolve relative to `parent`. + * @param parent The absolute parent module URL to resolve from. + * @returns The absolute (`file:`) URL string for the resolved module. + */ + resolve(specifier: string, parent?: string | URL | undefined): string; + } + } + export = Module; +} +declare module "node:module" { + import module = require("module"); + export = module; +} diff --git a/node_modules/@types/node/net.d.ts b/node_modules/@types/node/net.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..70789e1ba1c71d917006acfa4cca7769ea1c705e --- /dev/null +++ b/node_modules/@types/node/net.d.ts @@ -0,0 +1,949 @@ +/** + * > Stability: 2 - Stable + * + * The `node:net` module provides an asynchronous network API for creating stream-based + * TCP or `IPC` servers ({@link createServer}) and clients + * ({@link createConnection}). + * + * It can be accessed using: + * + * ```js + * const net = require('node:net'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/net.js) + */ +declare module "net" { + import * as stream from "node:stream"; + import { Abortable, EventEmitter } from "node:events"; + import * as dns from "node:dns"; + type LookupFunction = ( + hostname: string, + options: dns.LookupAllOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void, + ) => void; + interface AddressInfo { + address: string; + family: string; + port: number; + } + interface SocketConstructorOpts { + fd?: number | undefined; + allowHalfOpen?: boolean | undefined; + readable?: boolean | undefined; + writable?: boolean | undefined; + signal?: AbortSignal; + } + interface OnReadOpts { + buffer: Uint8Array | (() => Uint8Array); + /** + * This function is called for every chunk of incoming data. + * Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer. + * Return false from this function to implicitly pause() the socket. + */ + callback(bytesWritten: number, buf: Uint8Array): boolean; + } + interface ConnectOpts { + /** + * If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket. + * Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will + * still be emitted as normal and methods like pause() and resume() will also behave as expected. + */ + onread?: OnReadOpts | undefined; + } + interface TcpSocketConnectOpts extends ConnectOpts { + port: number; + host?: string | undefined; + localAddress?: string | undefined; + localPort?: number | undefined; + hints?: number | undefined; + family?: number | undefined; + lookup?: LookupFunction | undefined; + noDelay?: boolean | undefined; + keepAlive?: boolean | undefined; + keepAliveInitialDelay?: number | undefined; + /** + * @since v18.13.0 + */ + autoSelectFamily?: boolean | undefined; + /** + * @since v18.13.0 + */ + autoSelectFamilyAttemptTimeout?: number | undefined; + } + interface IpcSocketConnectOpts extends ConnectOpts { + path: string; + } + type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts; + type SocketReadyState = "opening" | "open" | "readOnly" | "writeOnly" | "closed"; + /** + * This class is an abstraction of a TCP socket or a streaming `IPC` endpoint + * (uses named pipes on Windows, and Unix domain sockets otherwise). It is also + * an `EventEmitter`. + * + * A `net.Socket` can be created by the user and used directly to interact with + * a server. For example, it is returned by {@link createConnection}, + * so the user can use it to talk to the server. + * + * It can also be created by Node.js and passed to the user when a connection + * is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use + * it to interact with the client. + * @since v0.3.4 + */ + class Socket extends stream.Duplex { + constructor(options?: SocketConstructorOpts); + /** + * Destroys the socket after all data is written. If the `finish` event was already emitted the socket is destroyed immediately. + * If the socket is still writable it implicitly calls `socket.end()`. + * @since v0.3.4 + */ + destroySoon(): void; + /** + * Sends data on the socket. The second parameter specifies the encoding in the + * case of a string. It defaults to UTF8 encoding. + * + * Returns `true` if the entire data was flushed successfully to the kernel + * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free. + * + * The optional `callback` parameter will be executed when the data is finally + * written out, which may not be immediately. + * + * See `Writable` stream `write()` method for more + * information. + * @since v0.1.90 + * @param [encoding='utf8'] Only used when data is `string`. + */ + write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean; + write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean; + /** + * Initiate a connection on a given socket. + * + * Possible signatures: + * + * * `socket.connect(options[, connectListener])` + * * `socket.connect(path[, connectListener])` for `IPC` connections. + * * `socket.connect(port[, host][, connectListener])` for TCP connections. + * * Returns: `net.Socket` The socket itself. + * + * This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting, + * instead of a `'connect'` event, an `'error'` event will be emitted with + * the error passed to the `'error'` listener. + * The last parameter `connectListener`, if supplied, will be added as a listener + * for the `'connect'` event **once**. + * + * This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined + * behavior. + */ + connect(options: SocketConnectOpts, connectionListener?: () => void): this; + connect(port: number, host: string, connectionListener?: () => void): this; + connect(port: number, connectionListener?: () => void): this; + connect(path: string, connectionListener?: () => void): this; + /** + * Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information. + * @since v0.1.90 + * @return The socket itself. + */ + setEncoding(encoding?: BufferEncoding): this; + /** + * Pauses the reading of data. That is, `'data'` events will not be emitted. + * Useful to throttle back an upload. + * @return The socket itself. + */ + pause(): this; + /** + * Close the TCP connection by sending an RST packet and destroy the stream. + * If this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected. + * Otherwise, it will call `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. + * If this is not a TCP socket (for example, a pipe), calling this method will immediately throw an `ERR_INVALID_HANDLE_TYPE` Error. + * @since v18.3.0, v16.17.0 + */ + resetAndDestroy(): this; + /** + * Resumes reading after a call to `socket.pause()`. + * @return The socket itself. + */ + resume(): this; + /** + * Sets the socket to timeout after `timeout` milliseconds of inactivity on + * the socket. By default `net.Socket` do not have a timeout. + * + * When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to + * end the connection. + * + * ```js + * socket.setTimeout(3000); + * socket.on('timeout', () => { + * console.log('socket timeout'); + * socket.end(); + * }); + * ``` + * + * If `timeout` is 0, then the existing idle timeout is disabled. + * + * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event. + * @since v0.1.90 + * @return The socket itself. + */ + setTimeout(timeout: number, callback?: () => void): this; + /** + * Enable/disable the use of Nagle's algorithm. + * + * When a TCP connection is created, it will have Nagle's algorithm enabled. + * + * Nagle's algorithm delays data before it is sent via the network. It attempts + * to optimize throughput at the expense of latency. + * + * Passing `true` for `noDelay` or not passing an argument will disable Nagle's + * algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's + * algorithm. + * @since v0.1.90 + * @param [noDelay=true] + * @return The socket itself. + */ + setNoDelay(noDelay?: boolean): this; + /** + * Enable/disable keep-alive functionality, and optionally set the initial + * delay before the first keepalive probe is sent on an idle socket. + * + * Set `initialDelay` (in milliseconds) to set the delay between the last + * data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default + * (or previous) setting. + * + * Enabling the keep-alive functionality will set the following socket options: + * + * * `SO_KEEPALIVE=1` + * * `TCP_KEEPIDLE=initialDelay` + * * `TCP_KEEPCNT=10` + * * `TCP_KEEPINTVL=1` + * @since v0.1.92 + * @param [enable=false] + * @param [initialDelay=0] + * @return The socket itself. + */ + setKeepAlive(enable?: boolean, initialDelay?: number): this; + /** + * Returns the bound `address`, the address `family` name and `port` of the + * socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }` + * @since v0.1.90 + */ + address(): AddressInfo | {}; + /** + * Calling `unref()` on a socket will allow the program to exit if this is the only + * active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect. + * @since v0.9.1 + * @return The socket itself. + */ + unref(): this; + /** + * Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will _not_ let the program exit if it's the only socket left (the default behavior). + * If the socket is `ref`ed calling `ref` again will have no effect. + * @since v0.9.1 + * @return The socket itself. + */ + ref(): this; + /** + * This property is only present if the family autoselection algorithm is enabled in `socket.connect(options)` + * and it is an array of the addresses that have been attempted. + * + * Each address is a string in the form of `$IP:$PORT`. + * If the connection was successful, then the last address is the one that the socket is currently connected to. + * @since v19.4.0 + */ + readonly autoSelectFamilyAttemptedAddresses: string[]; + /** + * This property shows the number of characters buffered for writing. The buffer + * may contain strings whose length after encoding is not yet known. So this number + * is only an approximation of the number of bytes in the buffer. + * + * `net.Socket` has the property that `socket.write()` always works. This is to + * help users get up and running quickly. The computer cannot always keep up + * with the amount of data that is written to a socket. The network connection + * simply might be too slow. Node.js will internally queue up the data written to a + * socket and send it out over the wire when it is possible. + * + * The consequence of this internal buffering is that memory may grow. + * Users who experience large or growing `bufferSize` should attempt to + * "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`. + * @since v0.3.8 + * @deprecated Since v14.6.0 - Use `writableLength` instead. + */ + readonly bufferSize: number; + /** + * The amount of received bytes. + * @since v0.5.3 + */ + readonly bytesRead: number; + /** + * The amount of bytes sent. + * @since v0.5.3 + */ + readonly bytesWritten: number; + /** + * If `true`,`socket.connect(options[, connectListener])` was + * called and has not yet finished. It will stay `true` until the socket becomes + * connected, then it is set to `false` and the `'connect'` event is emitted. Note + * that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event. + * @since v6.1.0 + */ + readonly connecting: boolean; + /** + * This is `true` if the socket is not connected yet, either because `.connect()`has not yet been called or because it is still in the process of connecting + * (see `socket.connecting`). + * @since v11.2.0, v10.16.0 + */ + readonly pending: boolean; + /** + * See `writable.destroyed` for further details. + */ + readonly destroyed: boolean; + /** + * The string representation of the local IP address the remote client is + * connecting on. For example, in a server listening on `'0.0.0.0'`, if a client + * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`. + * @since v0.9.6 + */ + readonly localAddress?: string; + /** + * The numeric representation of the local port. For example, `80` or `21`. + * @since v0.9.6 + */ + readonly localPort?: number; + /** + * The string representation of the local IP family. `'IPv4'` or `'IPv6'`. + * @since v18.8.0, v16.18.0 + */ + readonly localFamily?: string; + /** + * This property represents the state of the connection as a string. + * + * * If the stream is connecting `socket.readyState` is `opening`. + * * If the stream is readable and writable, it is `open`. + * * If the stream is readable and not writable, it is `readOnly`. + * * If the stream is not readable and writable, it is `writeOnly`. + * @since v0.5.0 + */ + readonly readyState: SocketReadyState; + /** + * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if + * the socket is destroyed (for example, if the client disconnected). + * @since v0.5.10 + */ + readonly remoteAddress?: string | undefined; + /** + * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if + * the socket is destroyed (for example, if the client disconnected). + * @since v0.11.14 + */ + readonly remoteFamily?: string | undefined; + /** + * The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if + * the socket is destroyed (for example, if the client disconnected). + * @since v0.5.10 + */ + readonly remotePort?: number | undefined; + /** + * The socket timeout in milliseconds as set by `socket.setTimeout()`. + * It is `undefined` if a timeout has not been set. + * @since v10.7.0 + */ + readonly timeout?: number | undefined; + /** + * Half-closes the socket. i.e., it sends a FIN packet. It is possible the + * server will still send some data. + * + * See `writable.end()` for further details. + * @since v0.1.90 + * @param [encoding='utf8'] Only used when data is `string`. + * @param callback Optional callback for when the socket is finished. + * @return The socket itself. + */ + end(callback?: () => void): this; + end(buffer: Uint8Array | string, callback?: () => void): this; + end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this; + /** + * events.EventEmitter + * 1. close + * 2. connect + * 3. data + * 4. drain + * 5. end + * 6. error + * 7. lookup + * 8. ready + * 9. timeout + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: (hadError: boolean) => void): this; + addListener(event: "connect", listener: () => void): this; + addListener(event: "data", listener: (data: Buffer) => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + addListener(event: "ready", listener: () => void): this; + addListener(event: "timeout", listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close", hadError: boolean): boolean; + emit(event: "connect"): boolean; + emit(event: "data", data: Buffer): boolean; + emit(event: "drain"): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; + emit(event: "ready"): boolean; + emit(event: "timeout"): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: (hadError: boolean) => void): this; + on(event: "connect", listener: () => void): this; + on(event: "data", listener: (data: Buffer) => void): this; + on(event: "drain", listener: () => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + on(event: "ready", listener: () => void): this; + on(event: "timeout", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: (hadError: boolean) => void): this; + once(event: "connect", listener: () => void): this; + once(event: "data", listener: (data: Buffer) => void): this; + once(event: "drain", listener: () => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + once(event: "ready", listener: () => void): this; + once(event: "timeout", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: (hadError: boolean) => void): this; + prependListener(event: "connect", listener: () => void): this; + prependListener(event: "data", listener: (data: Buffer) => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + prependListener(event: "ready", listener: () => void): this; + prependListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: (hadError: boolean) => void): this; + prependOnceListener(event: "connect", listener: () => void): this; + prependOnceListener(event: "data", listener: (data: Buffer) => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + prependOnceListener(event: "ready", listener: () => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + } + interface ListenOptions extends Abortable { + port?: number | undefined; + host?: string | undefined; + backlog?: number | undefined; + path?: string | undefined; + exclusive?: boolean | undefined; + readableAll?: boolean | undefined; + writableAll?: boolean | undefined; + /** + * @default false + */ + ipv6Only?: boolean | undefined; + } + interface ServerOpts { + /** + * Indicates whether half-opened TCP connections are allowed. + * @default false + */ + allowHalfOpen?: boolean | undefined; + /** + * Indicates whether the socket should be paused on incoming connections. + * @default false + */ + pauseOnConnect?: boolean | undefined; + /** + * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received. + * @default false + * @since v16.5.0 + */ + noDelay?: boolean | undefined; + /** + * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received, + * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`. + * @default false + * @since v16.5.0 + */ + keepAlive?: boolean | undefined; + /** + * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket. + * @default 0 + * @since v16.5.0 + */ + keepAliveInitialDelay?: number | undefined; + } + interface DropArgument { + localAddress?: string; + localPort?: number; + localFamily?: string; + remoteAddress?: string; + remotePort?: number; + remoteFamily?: string; + } + /** + * This class is used to create a TCP or `IPC` server. + * @since v0.1.90 + */ + class Server extends EventEmitter { + constructor(connectionListener?: (socket: Socket) => void); + constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void); + /** + * Start a server listening for connections. A `net.Server` can be a TCP or + * an `IPC` server depending on what it listens to. + * + * Possible signatures: + * + * * `server.listen(handle[, backlog][, callback])` + * * `server.listen(options[, callback])` + * * `server.listen(path[, backlog][, callback])` for `IPC` servers + * * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers + * + * This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'` + * event. + * + * All `listen()` methods can take a `backlog` parameter to specify the maximum + * length of the queue of pending connections. The actual length will be determined + * by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512). + * + * All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for + * details). + * + * The `server.listen()` method can be called again if and only if there was an + * error during the first `server.listen()` call or `server.close()` has been + * called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown. + * + * One of the most common errors raised when listening is `EADDRINUSE`. + * This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry + * after a certain amount of time: + * + * ```js + * server.on('error', (e) => { + * if (e.code === 'EADDRINUSE') { + * console.error('Address in use, retrying...'); + * setTimeout(() => { + * server.close(); + * server.listen(PORT, HOST); + * }, 1000); + * } + * }); + * ``` + */ + listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this; + listen(port?: number, hostname?: string, listeningListener?: () => void): this; + listen(port?: number, backlog?: number, listeningListener?: () => void): this; + listen(port?: number, listeningListener?: () => void): this; + listen(path: string, backlog?: number, listeningListener?: () => void): this; + listen(path: string, listeningListener?: () => void): this; + listen(options: ListenOptions, listeningListener?: () => void): this; + listen(handle: any, backlog?: number, listeningListener?: () => void): this; + listen(handle: any, listeningListener?: () => void): this; + /** + * Stops the server from accepting new connections and keeps existing + * connections. This function is asynchronous, the server is finally closed + * when all connections are ended and the server emits a `'close'` event. + * The optional `callback` will be called once the `'close'` event occurs. Unlike + * that event, it will be called with an `Error` as its only argument if the server + * was not open when it was closed. + * @since v0.1.90 + * @param callback Called when the server is closed. + */ + close(callback?: (err?: Error) => void): this; + /** + * Returns the bound `address`, the address `family` name, and `port` of the server + * as reported by the operating system if listening on an IP socket + * (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`. + * + * For a server listening on a pipe or Unix domain socket, the name is returned + * as a string. + * + * ```js + * const server = net.createServer((socket) => { + * socket.end('goodbye\n'); + * }).on('error', (err) => { + * // Handle errors here. + * throw err; + * }); + * + * // Grab an arbitrary unused port. + * server.listen(() => { + * console.log('opened server on', server.address()); + * }); + * ``` + * + * `server.address()` returns `null` before the `'listening'` event has been + * emitted or after calling `server.close()`. + * @since v0.1.90 + */ + address(): AddressInfo | string | null; + /** + * Asynchronously get the number of concurrent connections on the server. Works + * when sockets were sent to forks. + * + * Callback should take two arguments `err` and `count`. + * @since v0.9.7 + */ + getConnections(cb: (error: Error | null, count: number) => void): void; + /** + * Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will _not_ let the program exit if it's the only server left (the default behavior). + * If the server is `ref`ed calling `ref()` again will have no effect. + * @since v0.9.1 + */ + ref(): this; + /** + * Calling `unref()` on a server will allow the program to exit if this is the only + * active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect. + * @since v0.9.1 + */ + unref(): this; + /** + * Set this property to reject connections when the server's connection count gets + * high. + * + * It is not recommended to use this option once a socket has been sent to a child + * with `child_process.fork()`. + * @since v0.2.0 + */ + maxConnections: number; + connections: number; + /** + * Indicates whether or not the server is listening for connections. + * @since v5.7.0 + */ + listening: boolean; + /** + * events.EventEmitter + * 1. close + * 2. connection + * 3. error + * 4. listening + * 5. drop + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connection", listener: (socket: Socket) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "drop", listener: (data?: DropArgument) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "connection", socket: Socket): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit(event: "drop", data?: DropArgument): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connection", listener: (socket: Socket) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "drop", listener: (data?: DropArgument) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connection", listener: (socket: Socket) => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "drop", listener: (data?: DropArgument) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connection", listener: (socket: Socket) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "drop", listener: (data?: DropArgument) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "drop", listener: (data?: DropArgument) => void): this; + /** + * Calls {@link Server.close()} and returns a promise that fulfills when the server has closed. + * @since v20.5.0 + */ + [Symbol.asyncDispose](): Promise; + } + type IPVersion = "ipv4" | "ipv6"; + /** + * The `BlockList` object can be used with some network APIs to specify rules for + * disabling inbound or outbound access to specific IP addresses, IP ranges, or + * IP subnets. + * @since v15.0.0, v14.18.0 + */ + class BlockList { + /** + * Adds a rule to block the given IP address. + * @since v15.0.0, v14.18.0 + * @param address An IPv4 or IPv6 address. + * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. + */ + addAddress(address: string, type?: IPVersion): void; + addAddress(address: SocketAddress): void; + /** + * Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive). + * @since v15.0.0, v14.18.0 + * @param start The starting IPv4 or IPv6 address in the range. + * @param end The ending IPv4 or IPv6 address in the range. + * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. + */ + addRange(start: string, end: string, type?: IPVersion): void; + addRange(start: SocketAddress, end: SocketAddress): void; + /** + * Adds a rule to block a range of IP addresses specified as a subnet mask. + * @since v15.0.0, v14.18.0 + * @param net The network IPv4 or IPv6 address. + * @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`. + * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. + */ + addSubnet(net: SocketAddress, prefix: number): void; + addSubnet(net: string, prefix: number, type?: IPVersion): void; + /** + * Returns `true` if the given IP address matches any of the rules added to the`BlockList`. + * + * ```js + * const blockList = new net.BlockList(); + * blockList.addAddress('123.123.123.123'); + * blockList.addRange('10.0.0.1', '10.0.0.10'); + * blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6'); + * + * console.log(blockList.check('123.123.123.123')); // Prints: true + * console.log(blockList.check('10.0.0.3')); // Prints: true + * console.log(blockList.check('222.111.111.222')); // Prints: false + * + * // IPv6 notation for IPv4 addresses works: + * console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true + * console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true + * ``` + * @since v15.0.0, v14.18.0 + * @param address The IP address to check + * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. + */ + check(address: SocketAddress): boolean; + check(address: string, type?: IPVersion): boolean; + } + interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts { + timeout?: number | undefined; + } + interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts { + timeout?: number | undefined; + } + type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts; + /** + * Creates a new TCP or `IPC` server. + * + * If `allowHalfOpen` is set to `true`, when the other end of the socket + * signals the end of transmission, the server will only send back the end of + * transmission when `socket.end()` is explicitly called. For example, in the + * context of TCP, when a FIN packed is received, a FIN packed is sent + * back only when `socket.end()` is explicitly called. Until then the + * connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information. + * + * If `pauseOnConnect` is set to `true`, then the socket associated with each + * incoming connection will be paused, and no data will be read from its handle. + * This allows connections to be passed between processes without any data being + * read by the original process. To begin reading data from a paused socket, call `socket.resume()`. + * + * The server can be a TCP server or an `IPC` server, depending on what it `listen()` to. + * + * Here is an example of a TCP echo server which listens for connections + * on port 8124: + * + * ```js + * const net = require('node:net'); + * const server = net.createServer((c) => { + * // 'connection' listener. + * console.log('client connected'); + * c.on('end', () => { + * console.log('client disconnected'); + * }); + * c.write('hello\r\n'); + * c.pipe(c); + * }); + * server.on('error', (err) => { + * throw err; + * }); + * server.listen(8124, () => { + * console.log('server bound'); + * }); + * ``` + * + * Test this by using `telnet`: + * + * ```bash + * telnet localhost 8124 + * ``` + * + * To listen on the socket `/tmp/echo.sock`: + * + * ```js + * server.listen('/tmp/echo.sock', () => { + * console.log('server bound'); + * }); + * ``` + * + * Use `nc` to connect to a Unix domain socket server: + * + * ```bash + * nc -U /tmp/echo.sock + * ``` + * @since v0.5.0 + * @param connectionListener Automatically set as a listener for the {@link 'connection'} event. + */ + function createServer(connectionListener?: (socket: Socket) => void): Server; + function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server; + /** + * Aliases to {@link createConnection}. + * + * Possible signatures: + * + * * {@link connect} + * * {@link connect} for `IPC` connections. + * * {@link connect} for TCP connections. + */ + function connect(options: NetConnectOpts, connectionListener?: () => void): Socket; + function connect(port: number, host?: string, connectionListener?: () => void): Socket; + function connect(path: string, connectionListener?: () => void): Socket; + /** + * A factory function, which creates a new {@link Socket}, + * immediately initiates connection with `socket.connect()`, + * then returns the `net.Socket` that starts the connection. + * + * When the connection is established, a `'connect'` event will be emitted + * on the returned socket. The last parameter `connectListener`, if supplied, + * will be added as a listener for the `'connect'` event **once**. + * + * Possible signatures: + * + * * {@link createConnection} + * * {@link createConnection} for `IPC` connections. + * * {@link createConnection} for TCP connections. + * + * The {@link connect} function is an alias to this function. + */ + function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket; + function createConnection(port: number, host?: string, connectionListener?: () => void): Socket; + function createConnection(path: string, connectionListener?: () => void): Socket; + /** + * Gets the current default value of the `autoSelectFamily` option of `socket.connect(options)`. + * The initial default value is `true`, unless the command line option`--no-network-family-autoselection` is provided. + * @since v19.4.0 + */ + function getDefaultAutoSelectFamily(): boolean; + /** + * Sets the default value of the `autoSelectFamily` option of `socket.connect(options)`. + * @since v19.4.0 + */ + function setDefaultAutoSelectFamily(value: boolean): void; + /** + * Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`. + * The initial default value is `250`. + * @since v19.8.0 + */ + function getDefaultAutoSelectFamilyAttemptTimeout(): number; + /** + * Sets the default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`. + * @since v19.8.0 + */ + function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void; + /** + * Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4 + * address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`. + * + * ```js + * net.isIP('::1'); // returns 6 + * net.isIP('127.0.0.1'); // returns 4 + * net.isIP('127.000.000.001'); // returns 0 + * net.isIP('127.0.0.1/24'); // returns 0 + * net.isIP('fhqwhgads'); // returns 0 + * ``` + * @since v0.3.0 + */ + function isIP(input: string): number; + /** + * Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no + * leading zeroes. Otherwise, returns `false`. + * + * ```js + * net.isIPv4('127.0.0.1'); // returns true + * net.isIPv4('127.000.000.001'); // returns false + * net.isIPv4('127.0.0.1/24'); // returns false + * net.isIPv4('fhqwhgads'); // returns false + * ``` + * @since v0.3.0 + */ + function isIPv4(input: string): boolean; + /** + * Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`. + * + * ```js + * net.isIPv6('::1'); // returns true + * net.isIPv6('fhqwhgads'); // returns false + * ``` + * @since v0.3.0 + */ + function isIPv6(input: string): boolean; + interface SocketAddressInitOptions { + /** + * The network address as either an IPv4 or IPv6 string. + * @default 127.0.0.1 + */ + address?: string | undefined; + /** + * @default `'ipv4'` + */ + family?: IPVersion | undefined; + /** + * An IPv6 flow-label used only if `family` is `'ipv6'`. + * @default 0 + */ + flowlabel?: number | undefined; + /** + * An IP port. + * @default 0 + */ + port?: number | undefined; + } + /** + * @since v15.14.0, v14.18.0 + */ + class SocketAddress { + constructor(options: SocketAddressInitOptions); + /** + * Either \`'ipv4'\` or \`'ipv6'\`. + * @since v15.14.0, v14.18.0 + */ + readonly address: string; + /** + * Either \`'ipv4'\` or \`'ipv6'\`. + * @since v15.14.0, v14.18.0 + */ + readonly family: IPVersion; + /** + * @since v15.14.0, v14.18.0 + */ + readonly port: number; + /** + * @since v15.14.0, v14.18.0 + */ + readonly flowlabel: number; + } +} +declare module "node:net" { + export * from "net"; +} diff --git a/node_modules/@types/node/os.d.ts b/node_modules/@types/node/os.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39a33f7fd5b960970c3eb3946ceea8766eb1989d --- /dev/null +++ b/node_modules/@types/node/os.d.ts @@ -0,0 +1,478 @@ +/** + * The `node:os` module provides operating system-related utility methods and + * properties. It can be accessed using: + * + * ```js + * const os = require('node:os'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/os.js) + */ +declare module "os" { + interface CpuInfo { + model: string; + speed: number; + times: { + user: number; + nice: number; + sys: number; + idle: number; + irq: number; + }; + } + interface NetworkInterfaceBase { + address: string; + netmask: string; + mac: string; + internal: boolean; + cidr: string | null; + } + interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase { + family: "IPv4"; + scopeid?: undefined; + } + interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase { + family: "IPv6"; + scopeid: number; + } + interface UserInfo { + username: T; + uid: number; + gid: number; + shell: T | null; + homedir: T; + } + type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6; + /** + * Returns the host name of the operating system as a string. + * @since v0.3.3 + */ + function hostname(): string; + /** + * Returns an array containing the 1, 5, and 15 minute load averages. + * + * The load average is a measure of system activity calculated by the operating + * system and expressed as a fractional number. + * + * The load average is a Unix-specific concept. On Windows, the return value is + * always `[0, 0, 0]`. + * @since v0.3.3 + */ + function loadavg(): number[]; + /** + * Returns the system uptime in number of seconds. + * @since v0.3.3 + */ + function uptime(): number; + /** + * Returns the amount of free system memory in bytes as an integer. + * @since v0.3.3 + */ + function freemem(): number; + /** + * Returns the total amount of system memory in bytes as an integer. + * @since v0.3.3 + */ + function totalmem(): number; + /** + * Returns an array of objects containing information about each logical CPU core. + * The array will be empty if no CPU information is available, such as if the`/proc` file system is unavailable. + * + * The properties included on each object include: + * + * ```js + * [ + * { + * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', + * speed: 2926, + * times: { + * user: 252020, + * nice: 0, + * sys: 30340, + * idle: 1070356870, + * irq: 0, + * }, + * }, + * { + * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', + * speed: 2926, + * times: { + * user: 306960, + * nice: 0, + * sys: 26980, + * idle: 1071569080, + * irq: 0, + * }, + * }, + * { + * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', + * speed: 2926, + * times: { + * user: 248450, + * nice: 0, + * sys: 21750, + * idle: 1070919370, + * irq: 0, + * }, + * }, + * { + * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', + * speed: 2926, + * times: { + * user: 256880, + * nice: 0, + * sys: 19430, + * idle: 1070905480, + * irq: 20, + * }, + * }, + * ] + * ``` + * + * `nice` values are POSIX-only. On Windows, the `nice` values of all processors + * are always 0. + * + * `os.cpus().length` should not be used to calculate the amount of parallelism + * available to an application. Use {@link availableParallelism} for this purpose. + * @since v0.3.3 + */ + function cpus(): CpuInfo[]; + /** + * Returns an estimate of the default amount of parallelism a program should use. + * Always returns a value greater than zero. + * + * This function is a small wrapper about libuv's [`uv_available_parallelism()`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_available_parallelism). + * @since v19.4.0, v18.14.0 + */ + function availableParallelism(): number; + /** + * Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it + * returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows. + * + * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information + * about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems. + * @since v0.3.3 + */ + function type(): string; + /** + * Returns the operating system as a string. + * + * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `GetVersionExW()` is used. See + * [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. + * @since v0.3.3 + */ + function release(): string; + /** + * Returns an object containing network interfaces that have been assigned a + * network address. + * + * Each key on the returned object identifies a network interface. The associated + * value is an array of objects that each describe an assigned network address. + * + * The properties available on the assigned network address object include: + * + * ```js + * { + * lo: [ + * { + * address: '127.0.0.1', + * netmask: '255.0.0.0', + * family: 'IPv4', + * mac: '00:00:00:00:00:00', + * internal: true, + * cidr: '127.0.0.1/8' + * }, + * { + * address: '::1', + * netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', + * family: 'IPv6', + * mac: '00:00:00:00:00:00', + * scopeid: 0, + * internal: true, + * cidr: '::1/128' + * } + * ], + * eth0: [ + * { + * address: '192.168.1.108', + * netmask: '255.255.255.0', + * family: 'IPv4', + * mac: '01:02:03:0a:0b:0c', + * internal: false, + * cidr: '192.168.1.108/24' + * }, + * { + * address: 'fe80::a00:27ff:fe4e:66a1', + * netmask: 'ffff:ffff:ffff:ffff::', + * family: 'IPv6', + * mac: '01:02:03:0a:0b:0c', + * scopeid: 1, + * internal: false, + * cidr: 'fe80::a00:27ff:fe4e:66a1/64' + * } + * ] + * } + * ``` + * @since v0.6.0 + */ + function networkInterfaces(): NodeJS.Dict; + /** + * Returns the string path of the current user's home directory. + * + * On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it + * uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory. + * + * On Windows, it uses the `USERPROFILE` environment variable if defined. + * Otherwise it uses the path to the profile directory of the current user. + * @since v2.3.0 + */ + function homedir(): string; + /** + * Returns information about the currently effective user. On POSIX platforms, + * this is typically a subset of the password file. The returned object includes + * the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and`gid` fields are `-1`, and `shell` is `null`. + * + * The value of `homedir` returned by `os.userInfo()` is provided by the operating + * system. This differs from the result of `os.homedir()`, which queries + * environment variables for the home directory before falling back to the + * operating system response. + * + * Throws a `SystemError` if a user has no `username` or `homedir`. + * @since v6.0.0 + */ + function userInfo(options: { encoding: "buffer" }): UserInfo; + function userInfo(options?: { encoding: BufferEncoding }): UserInfo; + type SignalConstants = { + [key in NodeJS.Signals]: number; + }; + namespace constants { + const UV_UDP_REUSEADDR: number; + namespace signals {} + const signals: SignalConstants; + namespace errno { + const E2BIG: number; + const EACCES: number; + const EADDRINUSE: number; + const EADDRNOTAVAIL: number; + const EAFNOSUPPORT: number; + const EAGAIN: number; + const EALREADY: number; + const EBADF: number; + const EBADMSG: number; + const EBUSY: number; + const ECANCELED: number; + const ECHILD: number; + const ECONNABORTED: number; + const ECONNREFUSED: number; + const ECONNRESET: number; + const EDEADLK: number; + const EDESTADDRREQ: number; + const EDOM: number; + const EDQUOT: number; + const EEXIST: number; + const EFAULT: number; + const EFBIG: number; + const EHOSTUNREACH: number; + const EIDRM: number; + const EILSEQ: number; + const EINPROGRESS: number; + const EINTR: number; + const EINVAL: number; + const EIO: number; + const EISCONN: number; + const EISDIR: number; + const ELOOP: number; + const EMFILE: number; + const EMLINK: number; + const EMSGSIZE: number; + const EMULTIHOP: number; + const ENAMETOOLONG: number; + const ENETDOWN: number; + const ENETRESET: number; + const ENETUNREACH: number; + const ENFILE: number; + const ENOBUFS: number; + const ENODATA: number; + const ENODEV: number; + const ENOENT: number; + const ENOEXEC: number; + const ENOLCK: number; + const ENOLINK: number; + const ENOMEM: number; + const ENOMSG: number; + const ENOPROTOOPT: number; + const ENOSPC: number; + const ENOSR: number; + const ENOSTR: number; + const ENOSYS: number; + const ENOTCONN: number; + const ENOTDIR: number; + const ENOTEMPTY: number; + const ENOTSOCK: number; + const ENOTSUP: number; + const ENOTTY: number; + const ENXIO: number; + const EOPNOTSUPP: number; + const EOVERFLOW: number; + const EPERM: number; + const EPIPE: number; + const EPROTO: number; + const EPROTONOSUPPORT: number; + const EPROTOTYPE: number; + const ERANGE: number; + const EROFS: number; + const ESPIPE: number; + const ESRCH: number; + const ESTALE: number; + const ETIME: number; + const ETIMEDOUT: number; + const ETXTBSY: number; + const EWOULDBLOCK: number; + const EXDEV: number; + const WSAEINTR: number; + const WSAEBADF: number; + const WSAEACCES: number; + const WSAEFAULT: number; + const WSAEINVAL: number; + const WSAEMFILE: number; + const WSAEWOULDBLOCK: number; + const WSAEINPROGRESS: number; + const WSAEALREADY: number; + const WSAENOTSOCK: number; + const WSAEDESTADDRREQ: number; + const WSAEMSGSIZE: number; + const WSAEPROTOTYPE: number; + const WSAENOPROTOOPT: number; + const WSAEPROTONOSUPPORT: number; + const WSAESOCKTNOSUPPORT: number; + const WSAEOPNOTSUPP: number; + const WSAEPFNOSUPPORT: number; + const WSAEAFNOSUPPORT: number; + const WSAEADDRINUSE: number; + const WSAEADDRNOTAVAIL: number; + const WSAENETDOWN: number; + const WSAENETUNREACH: number; + const WSAENETRESET: number; + const WSAECONNABORTED: number; + const WSAECONNRESET: number; + const WSAENOBUFS: number; + const WSAEISCONN: number; + const WSAENOTCONN: number; + const WSAESHUTDOWN: number; + const WSAETOOMANYREFS: number; + const WSAETIMEDOUT: number; + const WSAECONNREFUSED: number; + const WSAELOOP: number; + const WSAENAMETOOLONG: number; + const WSAEHOSTDOWN: number; + const WSAEHOSTUNREACH: number; + const WSAENOTEMPTY: number; + const WSAEPROCLIM: number; + const WSAEUSERS: number; + const WSAEDQUOT: number; + const WSAESTALE: number; + const WSAEREMOTE: number; + const WSASYSNOTREADY: number; + const WSAVERNOTSUPPORTED: number; + const WSANOTINITIALISED: number; + const WSAEDISCON: number; + const WSAENOMORE: number; + const WSAECANCELLED: number; + const WSAEINVALIDPROCTABLE: number; + const WSAEINVALIDPROVIDER: number; + const WSAEPROVIDERFAILEDINIT: number; + const WSASYSCALLFAILURE: number; + const WSASERVICE_NOT_FOUND: number; + const WSATYPE_NOT_FOUND: number; + const WSA_E_NO_MORE: number; + const WSA_E_CANCELLED: number; + const WSAEREFUSED: number; + } + namespace priority { + const PRIORITY_LOW: number; + const PRIORITY_BELOW_NORMAL: number; + const PRIORITY_NORMAL: number; + const PRIORITY_ABOVE_NORMAL: number; + const PRIORITY_HIGH: number; + const PRIORITY_HIGHEST: number; + } + } + const devNull: string; + const EOL: string; + /** + * Returns the operating system CPU architecture for which the Node.js binary was + * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`,`'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, + * and `'x64'`. + * + * The return value is equivalent to `process.arch`. + * @since v0.5.0 + */ + function arch(): string; + /** + * Returns a string identifying the kernel version. + * + * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not + * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. + * @since v13.11.0, v12.17.0 + */ + function version(): string; + /** + * Returns a string identifying the operating system platform for which + * the Node.js binary was compiled. The value is set at compile time. + * Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`,`'openbsd'`, `'sunos'`, and `'win32'`. + * + * The return value is equivalent to `process.platform`. + * + * The value `'android'` may also be returned if Node.js is built on the Android + * operating system. [Android support is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os). + * @since v0.5.0 + */ + function platform(): NodeJS.Platform; + /** + * Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`,`mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`. + * + * On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not + * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. + * @since v18.9.0, v16.18.0 + */ + function machine(): string; + /** + * Returns the operating system's default directory for temporary files as a + * string. + * @since v0.9.9 + */ + function tmpdir(): string; + /** + * Returns a string identifying the endianness of the CPU for which the Node.js + * binary was compiled. + * + * Possible values are `'BE'` for big endian and `'LE'` for little endian. + * @since v0.9.4 + */ + function endianness(): "BE" | "LE"; + /** + * Returns the scheduling priority for the process specified by `pid`. If `pid` is + * not provided or is `0`, the priority of the current process is returned. + * @since v10.10.0 + * @param [pid=0] The process ID to retrieve scheduling priority for. + */ + function getPriority(pid?: number): number; + /** + * Attempts to set the scheduling priority for the process specified by `pid`. If`pid` is not provided or is `0`, the process ID of the current process is used. + * + * The `priority` input must be an integer between `-20` (high priority) and `19`(low priority). Due to differences between Unix priority levels and Windows + * priority classes, `priority` is mapped to one of six priority constants in`os.constants.priority`. When retrieving a process priority level, this range + * mapping may cause the return value to be slightly different on Windows. To avoid + * confusion, set `priority` to one of the priority constants. + * + * On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user + * privileges. Otherwise the set priority will be silently reduced to`PRIORITY_HIGH`. + * @since v10.10.0 + * @param [pid=0] The process ID to set scheduling priority for. + * @param priority The scheduling priority to assign to the process. + */ + function setPriority(priority: number): void; + function setPriority(pid: number, priority: number): void; +} +declare module "node:os" { + export * from "os"; +} diff --git a/node_modules/@types/node/package.json b/node_modules/@types/node/package.json new file mode 100644 index 0000000000000000000000000000000000000000..21628d208fcb3dc000d3343b56ae0d84b87ae6f5 --- /dev/null +++ b/node_modules/@types/node/package.json @@ -0,0 +1,230 @@ +{ + "name": "@types/node", + "version": "20.10.1", + "description": "TypeScript definitions for node", + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node", + "license": "MIT", + "contributors": [ + { + "name": "Microsoft TypeScript", + "githubUsername": "Microsoft", + "url": "https://github.com/Microsoft" + }, + { + "name": "Alberto Schiabel", + "githubUsername": "jkomyno", + "url": "https://github.com/jkomyno" + }, + { + "name": "Alvis HT Tang", + "githubUsername": "alvis", + "url": "https://github.com/alvis" + }, + { + "name": "Andrew Makarov", + "githubUsername": "r3nya", + "url": "https://github.com/r3nya" + }, + { + "name": "Benjamin Toueg", + "githubUsername": "btoueg", + "url": "https://github.com/btoueg" + }, + { + "name": "Chigozirim C.", + "githubUsername": "smac89", + "url": "https://github.com/smac89" + }, + { + "name": "David Junger", + "githubUsername": "touffy", + "url": "https://github.com/touffy" + }, + { + "name": "Deividas Bakanas", + "githubUsername": "DeividasBakanas", + "url": "https://github.com/DeividasBakanas" + }, + { + "name": "Eugene Y. Q. Shen", + "githubUsername": "eyqs", + "url": "https://github.com/eyqs" + }, + { + "name": "Hannes Magnusson", + "githubUsername": "Hannes-Magnusson-CK", + "url": "https://github.com/Hannes-Magnusson-CK" + }, + { + "name": "Huw", + "githubUsername": "hoo29", + "url": "https://github.com/hoo29" + }, + { + "name": "Kelvin Jin", + "githubUsername": "kjin", + "url": "https://github.com/kjin" + }, + { + "name": "Klaus Meinhardt", + "githubUsername": "ajafff", + "url": "https://github.com/ajafff" + }, + { + "name": "Lishude", + "githubUsername": "islishude", + "url": "https://github.com/islishude" + }, + { + "name": "Mariusz Wiktorczyk", + "githubUsername": "mwiktorczyk", + "url": "https://github.com/mwiktorczyk" + }, + { + "name": "Mohsen Azimi", + "githubUsername": "mohsen1", + "url": "https://github.com/mohsen1" + }, + { + "name": "Nicolas Even", + "githubUsername": "n-e", + "url": "https://github.com/n-e" + }, + { + "name": "Nikita Galkin", + "githubUsername": "galkin", + "url": "https://github.com/galkin" + }, + { + "name": "Parambir Singh", + "githubUsername": "parambirs", + "url": "https://github.com/parambirs" + }, + { + "name": "Sebastian Silbermann", + "githubUsername": "eps1lon", + "url": "https://github.com/eps1lon" + }, + { + "name": "Thomas den Hollander", + "githubUsername": "ThomasdenH", + "url": "https://github.com/ThomasdenH" + }, + { + "name": "Wilco Bakker", + "githubUsername": "WilcoBakker", + "url": "https://github.com/WilcoBakker" + }, + { + "name": "wwwy3y3", + "githubUsername": "wwwy3y3", + "url": "https://github.com/wwwy3y3" + }, + { + "name": "Samuel Ainsworth", + "githubUsername": "samuela", + "url": "https://github.com/samuela" + }, + { + "name": "Kyle Uehlein", + "githubUsername": "kuehlein", + "url": "https://github.com/kuehlein" + }, + { + "name": "Thanik Bhongbhibhat", + "githubUsername": "bhongy", + "url": "https://github.com/bhongy" + }, + { + "name": "Marcin Kopacz", + "githubUsername": "chyzwar", + "url": "https://github.com/chyzwar" + }, + { + "name": "Trivikram Kamat", + "githubUsername": "trivikr", + "url": "https://github.com/trivikr" + }, + { + "name": "Junxiao Shi", + "githubUsername": "yoursunny", + "url": "https://github.com/yoursunny" + }, + { + "name": "Ilia Baryshnikov", + "githubUsername": "qwelias", + "url": "https://github.com/qwelias" + }, + { + "name": "ExE Boss", + "githubUsername": "ExE-Boss", + "url": "https://github.com/ExE-Boss" + }, + { + "name": "Piotr Błażejewicz", + "githubUsername": "peterblazejewicz", + "url": "https://github.com/peterblazejewicz" + }, + { + "name": "Anna Henningsen", + "githubUsername": "addaleax", + "url": "https://github.com/addaleax" + }, + { + "name": "Victor Perin", + "githubUsername": "victorperin", + "url": "https://github.com/victorperin" + }, + { + "name": "Yongsheng Zhang", + "githubUsername": "ZYSzys", + "url": "https://github.com/ZYSzys" + }, + { + "name": "NodeJS Contributors", + "githubUsername": "NodeJS", + "url": "https://github.com/NodeJS" + }, + { + "name": "Linus Unnebäck", + "githubUsername": "LinusU", + "url": "https://github.com/LinusU" + }, + { + "name": "wafuwafu13", + "githubUsername": "wafuwafu13", + "url": "https://github.com/wafuwafu13" + }, + { + "name": "Matteo Collina", + "githubUsername": "mcollina", + "url": "https://github.com/mcollina" + }, + { + "name": "Dmitry Semigradsky", + "githubUsername": "Semigradsky", + "url": "https://github.com/Semigradsky" + } + ], + "main": "", + "types": "index.d.ts", + "typesVersions": { + "<=4.8": { + "*": [ + "ts4.8/*" + ] + } + }, + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "directory": "types/node" + }, + "scripts": {}, + "dependencies": { + "undici-types": "~5.26.4" + }, + "typesPublisherContentHash": "0b15d1ef7892c4399bd0b2f190b187e4127a3f86fbd7ce440409b864961cdc93", + "typeScriptVersion": "4.6", + "nonNpm": true +} \ No newline at end of file diff --git a/node_modules/@types/node/path.d.ts b/node_modules/@types/node/path.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f07681ac6460e05a2b23515d13d45e1a0714b6c --- /dev/null +++ b/node_modules/@types/node/path.d.ts @@ -0,0 +1,191 @@ +declare module "path/posix" { + import path = require("path"); + export = path; +} +declare module "path/win32" { + import path = require("path"); + export = path; +} +/** + * The `node:path` module provides utilities for working with file and directory + * paths. It can be accessed using: + * + * ```js + * const path = require('node:path'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/path.js) + */ +declare module "path" { + namespace path { + /** + * A parsed path object generated by path.parse() or consumed by path.format(). + */ + interface ParsedPath { + /** + * The root of the path such as '/' or 'c:\' + */ + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; + } + interface FormatInputPathObject { + /** + * The root of the path such as '/' or 'c:\' + */ + root?: string | undefined; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir?: string | undefined; + /** + * The file name including extension (if any) such as 'index.html' + */ + base?: string | undefined; + /** + * The file extension (if any) such as '.html' + */ + ext?: string | undefined; + /** + * The file name without extension (if any) such as 'index' + */ + name?: string | undefined; + } + interface PlatformPath { + /** + * Normalize a string path, reducing '..' and '.' parts. + * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. + * + * @param path string path to normalize. + * @throws {TypeError} if `path` is not a string. + */ + normalize(path: string): string; + /** + * Join all arguments together and normalize the resulting path. + * + * @param paths paths to join. + * @throws {TypeError} if any of the path segments is not a string. + */ + join(...paths: string[]): string; + /** + * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. + * + * Starting from leftmost {from} parameter, resolves {to} to an absolute path. + * + * If {to} isn't already absolute, {from} arguments are prepended in right to left order, + * until an absolute path is found. If after using all {from} paths still no absolute path is found, + * the current working directory is used as well. The resulting path is normalized, + * and trailing slashes are removed unless the path gets resolved to the root directory. + * + * @param paths A sequence of paths or path segments. + * @throws {TypeError} if any of the arguments is not a string. + */ + resolve(...paths: string[]): string; + /** + * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. + * + * If the given {path} is a zero-length string, `false` will be returned. + * + * @param path path to test. + * @throws {TypeError} if `path` is not a string. + */ + isAbsolute(path: string): boolean; + /** + * Solve the relative path from {from} to {to} based on the current working directory. + * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. + * + * @throws {TypeError} if either `from` or `to` is not a string. + */ + relative(from: string, to: string): string; + /** + * Return the directory name of a path. Similar to the Unix dirname command. + * + * @param path the path to evaluate. + * @throws {TypeError} if `path` is not a string. + */ + dirname(path: string): string; + /** + * Return the last portion of a path. Similar to the Unix basename command. + * Often used to extract the file name from a fully qualified path. + * + * @param path the path to evaluate. + * @param suffix optionally, an extension to remove from the result. + * @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string. + */ + basename(path: string, suffix?: string): string; + /** + * Return the extension of the path, from the last '.' to end of string in the last portion of the path. + * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string. + * + * @param path the path to evaluate. + * @throws {TypeError} if `path` is not a string. + */ + extname(path: string): string; + /** + * The platform-specific file separator. '\\' or '/'. + */ + readonly sep: "\\" | "/"; + /** + * The platform-specific file delimiter. ';' or ':'. + */ + readonly delimiter: ";" | ":"; + /** + * Returns an object from a path string - the opposite of format(). + * + * @param path path to evaluate. + * @throws {TypeError} if `path` is not a string. + */ + parse(path: string): ParsedPath; + /** + * Returns a path string from an object - the opposite of parse(). + * + * @param pathObject path to evaluate. + */ + format(pathObject: FormatInputPathObject): string; + /** + * On Windows systems only, returns an equivalent namespace-prefixed path for the given path. + * If path is not a string, path will be returned without modifications. + * This method is meaningful only on Windows system. + * On POSIX systems, the method is non-operational and always returns path without modifications. + */ + toNamespacedPath(path: string): string; + /** + * Posix specific pathing. + * Same as parent object on posix. + */ + readonly posix: PlatformPath; + /** + * Windows specific pathing. + * Same as parent object on windows + */ + readonly win32: PlatformPath; + } + } + const path: path.PlatformPath; + export = path; +} +declare module "node:path" { + import path = require("path"); + export = path; +} +declare module "node:path/posix" { + import path = require("path/posix"); + export = path; +} +declare module "node:path/win32" { + import path = require("path/win32"); + export = path; +} diff --git a/node_modules/@types/node/perf_hooks.d.ts b/node_modules/@types/node/perf_hooks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b369bb6944cb61fc4c907783f2dfdbd7576f9896 --- /dev/null +++ b/node_modules/@types/node/perf_hooks.d.ts @@ -0,0 +1,639 @@ +/** + * This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for + * Node.js-specific performance measurements. + * + * Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/): + * + * * [High Resolution Time](https://www.w3.org/TR/hr-time-2) + * * [Performance Timeline](https://w3c.github.io/performance-timeline/) + * * [User Timing](https://www.w3.org/TR/user-timing/) + * * [Resource Timing](https://www.w3.org/TR/resource-timing-2/) + * + * ```js + * const { PerformanceObserver, performance } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((items) => { + * console.log(items.getEntries()[0].duration); + * performance.clearMarks(); + * }); + * obs.observe({ type: 'measure' }); + * performance.measure('Start to Now'); + * + * performance.mark('A'); + * doSomeLongRunningProcess(() => { + * performance.measure('A to Now', 'A'); + * + * performance.mark('B'); + * performance.measure('A to B', 'A', 'B'); + * }); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/perf_hooks.js) + */ +declare module "perf_hooks" { + import { AsyncResource } from "node:async_hooks"; + type EntryType = "node" | "mark" | "measure" | "gc" | "function" | "http2" | "http" | "dns" | "net"; + interface NodeGCPerformanceDetail { + /** + * When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies + * the type of garbage collection operation that occurred. + * See perf_hooks.constants for valid values. + */ + readonly kind?: number | undefined; + /** + * When `performanceEntry.entryType` is equal to 'gc', the `performance.flags` + * property contains additional information about garbage collection operation. + * See perf_hooks.constants for valid values. + */ + readonly flags?: number | undefined; + } + /** + * The constructor of this class is not exposed to users directly. + * @since v8.5.0 + */ + class PerformanceEntry { + protected constructor(); + /** + * The total number of milliseconds elapsed for this entry. This value will not + * be meaningful for all Performance Entry types. + * @since v8.5.0 + */ + readonly duration: number; + /** + * The name of the performance entry. + * @since v8.5.0 + */ + readonly name: string; + /** + * The high resolution millisecond timestamp marking the starting time of the + * Performance Entry. + * @since v8.5.0 + */ + readonly startTime: number; + /** + * The type of the performance entry. It may be one of: + * + * * `'node'` (Node.js only) + * * `'mark'` (available on the Web) + * * `'measure'` (available on the Web) + * * `'gc'` (Node.js only) + * * `'function'` (Node.js only) + * * `'http2'` (Node.js only) + * * `'http'` (Node.js only) + * @since v8.5.0 + */ + readonly entryType: EntryType; + /** + * Additional detail specific to the `entryType`. + * @since v16.0.0 + */ + readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type. + toJSON(): any; + } + /** + * Exposes marks created via the `Performance.mark()` method. + * @since v18.2.0, v16.17.0 + */ + class PerformanceMark extends PerformanceEntry { + readonly duration: 0; + readonly entryType: "mark"; + } + /** + * Exposes measures created via the `Performance.measure()` method. + * + * The constructor of this class is not exposed to users directly. + * @since v18.2.0, v16.17.0 + */ + class PerformanceMeasure extends PerformanceEntry { + readonly entryType: "measure"; + } + /** + * _This property is an extension by Node.js. It is not available in Web browsers._ + * + * Provides timing details for Node.js itself. The constructor of this class + * is not exposed to users. + * @since v8.5.0 + */ + class PerformanceNodeTiming extends PerformanceEntry { + /** + * The high resolution millisecond timestamp at which the Node.js process + * completed bootstrapping. If bootstrapping has not yet finished, the property + * has the value of -1. + * @since v8.5.0 + */ + readonly bootstrapComplete: number; + /** + * The high resolution millisecond timestamp at which the Node.js environment was + * initialized. + * @since v8.5.0 + */ + readonly environment: number; + /** + * The high resolution millisecond timestamp of the amount of time the event loop + * has been idle within the event loop's event provider (e.g. `epoll_wait`). This + * does not take CPU usage into consideration. If the event loop has not yet + * started (e.g., in the first tick of the main script), the property has the + * value of 0. + * @since v14.10.0, v12.19.0 + */ + readonly idleTime: number; + /** + * The high resolution millisecond timestamp at which the Node.js event loop + * exited. If the event loop has not yet exited, the property has the value of -1\. + * It can only have a value of not -1 in a handler of the `'exit'` event. + * @since v8.5.0 + */ + readonly loopExit: number; + /** + * The high resolution millisecond timestamp at which the Node.js event loop + * started. If the event loop has not yet started (e.g., in the first tick of the + * main script), the property has the value of -1. + * @since v8.5.0 + */ + readonly loopStart: number; + /** + * The high resolution millisecond timestamp at which the V8 platform was + * initialized. + * @since v8.5.0 + */ + readonly v8Start: number; + } + interface EventLoopUtilization { + idle: number; + active: number; + utilization: number; + } + /** + * @param util1 The result of a previous call to eventLoopUtilization() + * @param util2 The result of a previous call to eventLoopUtilization() prior to util1 + */ + type EventLoopUtilityFunction = ( + util1?: EventLoopUtilization, + util2?: EventLoopUtilization, + ) => EventLoopUtilization; + interface MarkOptions { + /** + * Additional optional detail to include with the mark. + */ + detail?: unknown | undefined; + /** + * An optional timestamp to be used as the mark time. + * @default `performance.now()`. + */ + startTime?: number | undefined; + } + interface MeasureOptions { + /** + * Additional optional detail to include with the mark. + */ + detail?: unknown | undefined; + /** + * Duration between start and end times. + */ + duration?: number | undefined; + /** + * Timestamp to be used as the end time, or a string identifying a previously recorded mark. + */ + end?: number | string | undefined; + /** + * Timestamp to be used as the start time, or a string identifying a previously recorded mark. + */ + start?: number | string | undefined; + } + interface TimerifyOptions { + /** + * A histogram object created using + * `perf_hooks.createHistogram()` that will record runtime durations in + * nanoseconds. + */ + histogram?: RecordableHistogram | undefined; + } + interface Performance { + /** + * If name is not provided, removes all PerformanceMark objects from the Performance Timeline. + * If name is provided, removes only the named mark. + * @param name + */ + clearMarks(name?: string): void; + /** + * If name is not provided, removes all PerformanceMeasure objects from the Performance Timeline. + * If name is provided, removes only the named measure. + * @param name + * @since v16.7.0 + */ + clearMeasures(name?: string): void; + /** + * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`. + * If you are only interested in performance entries of certain types or that have certain names, see + * `performance.getEntriesByType()` and `performance.getEntriesByName()`. + * @since v16.7.0 + */ + getEntries(): PerformanceEntry[]; + /** + * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime` + * whose `performanceEntry.name` is equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to `type`. + * @param name + * @param type + * @since v16.7.0 + */ + getEntriesByName(name: string, type?: EntryType): PerformanceEntry[]; + /** + * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime` + * whose `performanceEntry.entryType` is equal to `type`. + * @param type + * @since v16.7.0 + */ + getEntriesByType(type: EntryType): PerformanceEntry[]; + /** + * Creates a new PerformanceMark entry in the Performance Timeline. + * A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark', + * and whose performanceEntry.duration is always 0. + * Performance marks are used to mark specific significant moments in the Performance Timeline. + * @param name + * @return The PerformanceMark entry that was created + */ + mark(name?: string, options?: MarkOptions): PerformanceMark; + /** + * Creates a new PerformanceMeasure entry in the Performance Timeline. + * A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure', + * and whose performanceEntry.duration measures the number of milliseconds elapsed since startMark and endMark. + * + * The startMark argument may identify any existing PerformanceMark in the the Performance Timeline, or may identify + * any of the timestamp properties provided by the PerformanceNodeTiming class. If the named startMark does not exist, + * then startMark is set to timeOrigin by default. + * + * The endMark argument must identify any existing PerformanceMark in the the Performance Timeline or any of the timestamp + * properties provided by the PerformanceNodeTiming class. If the named endMark does not exist, an error will be thrown. + * @param name + * @param startMark + * @param endMark + * @return The PerformanceMeasure entry that was created + */ + measure(name: string, startMark?: string, endMark?: string): PerformanceMeasure; + measure(name: string, options: MeasureOptions): PerformanceMeasure; + /** + * An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones. + */ + readonly nodeTiming: PerformanceNodeTiming; + /** + * @return the current high resolution millisecond timestamp + */ + now(): number; + /** + * The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured. + */ + readonly timeOrigin: number; + /** + * Wraps a function within a new function that measures the running time of the wrapped function. + * A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed. + * @param fn + */ + timerify any>(fn: T, options?: TimerifyOptions): T; + /** + * eventLoopUtilization is similar to CPU utilization except that it is calculated using high precision wall-clock time. + * It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait). + * No other CPU idle time is taken into consideration. + */ + eventLoopUtilization: EventLoopUtilityFunction; + } + interface PerformanceObserverEntryList { + /** + * Returns a list of `PerformanceEntry` objects in chronological order + * with respect to `performanceEntry.startTime`. + * + * ```js + * const { + * performance, + * PerformanceObserver, + * } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((perfObserverList, observer) => { + * console.log(perfObserverList.getEntries()); + * + * * [ + * * PerformanceEntry { + * * name: 'test', + * * entryType: 'mark', + * * startTime: 81.465639, + * * duration: 0 + * * }, + * * PerformanceEntry { + * * name: 'meow', + * * entryType: 'mark', + * * startTime: 81.860064, + * * duration: 0 + * * } + * * ] + * + * performance.clearMarks(); + * performance.clearMeasures(); + * observer.disconnect(); + * }); + * obs.observe({ type: 'mark' }); + * + * performance.mark('test'); + * performance.mark('meow'); + * ``` + * @since v8.5.0 + */ + getEntries(): PerformanceEntry[]; + /** + * Returns a list of `PerformanceEntry` objects in chronological order + * with respect to `performanceEntry.startTime` whose `performanceEntry.name` is + * equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`. + * + * ```js + * const { + * performance, + * PerformanceObserver, + * } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((perfObserverList, observer) => { + * console.log(perfObserverList.getEntriesByName('meow')); + * + * * [ + * * PerformanceEntry { + * * name: 'meow', + * * entryType: 'mark', + * * startTime: 98.545991, + * * duration: 0 + * * } + * * ] + * + * console.log(perfObserverList.getEntriesByName('nope')); // [] + * + * console.log(perfObserverList.getEntriesByName('test', 'mark')); + * + * * [ + * * PerformanceEntry { + * * name: 'test', + * * entryType: 'mark', + * * startTime: 63.518931, + * * duration: 0 + * * } + * * ] + * + * console.log(perfObserverList.getEntriesByName('test', 'measure')); // [] + * + * performance.clearMarks(); + * performance.clearMeasures(); + * observer.disconnect(); + * }); + * obs.observe({ entryTypes: ['mark', 'measure'] }); + * + * performance.mark('test'); + * performance.mark('meow'); + * ``` + * @since v8.5.0 + */ + getEntriesByName(name: string, type?: EntryType): PerformanceEntry[]; + /** + * Returns a list of `PerformanceEntry` objects in chronological order + * with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`is equal to `type`. + * + * ```js + * const { + * performance, + * PerformanceObserver, + * } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((perfObserverList, observer) => { + * console.log(perfObserverList.getEntriesByType('mark')); + * + * * [ + * * PerformanceEntry { + * * name: 'test', + * * entryType: 'mark', + * * startTime: 55.897834, + * * duration: 0 + * * }, + * * PerformanceEntry { + * * name: 'meow', + * * entryType: 'mark', + * * startTime: 56.350146, + * * duration: 0 + * * } + * * ] + * + * performance.clearMarks(); + * performance.clearMeasures(); + * observer.disconnect(); + * }); + * obs.observe({ type: 'mark' }); + * + * performance.mark('test'); + * performance.mark('meow'); + * ``` + * @since v8.5.0 + */ + getEntriesByType(type: EntryType): PerformanceEntry[]; + } + type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void; + /** + * @since v8.5.0 + */ + class PerformanceObserver extends AsyncResource { + constructor(callback: PerformanceObserverCallback); + /** + * Disconnects the `PerformanceObserver` instance from all notifications. + * @since v8.5.0 + */ + disconnect(): void; + /** + * Subscribes the `PerformanceObserver` instance to notifications of new `PerformanceEntry` instances identified either by `options.entryTypes`or `options.type`: + * + * ```js + * const { + * performance, + * PerformanceObserver, + * } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((list, observer) => { + * // Called once asynchronously. `list` contains three items. + * }); + * obs.observe({ type: 'mark' }); + * + * for (let n = 0; n < 3; n++) + * performance.mark(`test${n}`); + * ``` + * @since v8.5.0 + */ + observe( + options: + | { + entryTypes: readonly EntryType[]; + buffered?: boolean | undefined; + } + | { + type: EntryType; + buffered?: boolean | undefined; + }, + ): void; + } + namespace constants { + const NODE_PERFORMANCE_GC_MAJOR: number; + const NODE_PERFORMANCE_GC_MINOR: number; + const NODE_PERFORMANCE_GC_INCREMENTAL: number; + const NODE_PERFORMANCE_GC_WEAKCB: number; + const NODE_PERFORMANCE_GC_FLAGS_NO: number; + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; + } + const performance: Performance; + interface EventLoopMonitorOptions { + /** + * The sampling rate in milliseconds. + * Must be greater than zero. + * @default 10 + */ + resolution?: number | undefined; + } + interface Histogram { + /** + * Returns a `Map` object detailing the accumulated percentile distribution. + * @since v11.10.0 + */ + readonly percentiles: Map; + /** + * The number of times the event loop delay exceeded the maximum 1 hour event + * loop delay threshold. + * @since v11.10.0 + */ + readonly exceeds: number; + /** + * The minimum recorded event loop delay. + * @since v11.10.0 + */ + readonly min: number; + /** + * The maximum recorded event loop delay. + * @since v11.10.0 + */ + readonly max: number; + /** + * The mean of the recorded event loop delays. + * @since v11.10.0 + */ + readonly mean: number; + /** + * The standard deviation of the recorded event loop delays. + * @since v11.10.0 + */ + readonly stddev: number; + /** + * Resets the collected histogram data. + * @since v11.10.0 + */ + reset(): void; + /** + * Returns the value at the given percentile. + * @since v11.10.0 + * @param percentile A percentile value in the range (0, 100]. + */ + percentile(percentile: number): number; + } + interface IntervalHistogram extends Histogram { + /** + * Enables the update interval timer. Returns `true` if the timer was + * started, `false` if it was already started. + * @since v11.10.0 + */ + enable(): boolean; + /** + * Disables the update interval timer. Returns `true` if the timer was + * stopped, `false` if it was already stopped. + * @since v11.10.0 + */ + disable(): boolean; + } + interface RecordableHistogram extends Histogram { + /** + * @since v15.9.0, v14.18.0 + * @param val The amount to record in the histogram. + */ + record(val: number | bigint): void; + /** + * Calculates the amount of time (in nanoseconds) that has passed since the + * previous call to `recordDelta()` and records that amount in the histogram. + * + * ## Examples + * @since v15.9.0, v14.18.0 + */ + recordDelta(): void; + /** + * Adds the values from `other` to this histogram. + * @since v17.4.0, v16.14.0 + */ + add(other: RecordableHistogram): void; + } + /** + * _This property is an extension by Node.js. It is not available in Web browsers._ + * + * Creates an `IntervalHistogram` object that samples and reports the event loop + * delay over time. The delays will be reported in nanoseconds. + * + * Using a timer to detect approximate event loop delay works because the + * execution of timers is tied specifically to the lifecycle of the libuv + * event loop. That is, a delay in the loop will cause a delay in the execution + * of the timer, and those delays are specifically what this API is intended to + * detect. + * + * ```js + * const { monitorEventLoopDelay } = require('node:perf_hooks'); + * const h = monitorEventLoopDelay({ resolution: 20 }); + * h.enable(); + * // Do something. + * h.disable(); + * console.log(h.min); + * console.log(h.max); + * console.log(h.mean); + * console.log(h.stddev); + * console.log(h.percentiles); + * console.log(h.percentile(50)); + * console.log(h.percentile(99)); + * ``` + * @since v11.10.0 + */ + function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram; + interface CreateHistogramOptions { + /** + * The minimum recordable value. Must be an integer value greater than 0. + * @default 1 + */ + min?: number | bigint | undefined; + /** + * The maximum recordable value. Must be an integer value greater than min. + * @default Number.MAX_SAFE_INTEGER + */ + max?: number | bigint | undefined; + /** + * The number of accuracy digits. Must be a number between 1 and 5. + * @default 3 + */ + figures?: number | undefined; + } + /** + * Returns a `RecordableHistogram`. + * @since v15.9.0, v14.18.0 + */ + function createHistogram(options?: CreateHistogramOptions): RecordableHistogram; + import { performance as _performance } from "perf_hooks"; + global { + /** + * `performance` is a global reference for `require('perf_hooks').performance` + * https://nodejs.org/api/globals.html#performance + * @since v16.0.0 + */ + var performance: typeof globalThis extends { + onmessage: any; + performance: infer T; + } ? T + : typeof _performance; + } +} +declare module "node:perf_hooks" { + export * from "perf_hooks"; +} diff --git a/node_modules/@types/node/process.d.ts b/node_modules/@types/node/process.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e2747376fc359a4cbf94dbffc73779f6eb43e04 --- /dev/null +++ b/node_modules/@types/node/process.d.ts @@ -0,0 +1,1539 @@ +declare module "process" { + import * as tty from "node:tty"; + import { Worker } from "node:worker_threads"; + global { + var process: NodeJS.Process; + namespace NodeJS { + // this namespace merge is here because these are specifically used + // as the type for process.stdin, process.stdout, and process.stderr. + // they can't live in tty.d.ts because we need to disambiguate the imported name. + interface ReadStream extends tty.ReadStream {} + interface WriteStream extends tty.WriteStream {} + interface MemoryUsageFn { + /** + * The `process.memoryUsage()` method iterate over each page to gather informations about memory + * usage which can be slow depending on the program memory allocations. + */ + (): MemoryUsage; + /** + * method returns an integer representing the Resident Set Size (RSS) in bytes. + */ + rss(): number; + } + interface MemoryUsage { + rss: number; + heapTotal: number; + heapUsed: number; + external: number; + arrayBuffers: number; + } + interface CpuUsage { + user: number; + system: number; + } + interface ProcessRelease { + name: string; + sourceUrl?: string | undefined; + headersUrl?: string | undefined; + libUrl?: string | undefined; + lts?: string | undefined; + } + interface ProcessVersions extends Dict { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + modules: string; + openssl: string; + } + type Platform = + | "aix" + | "android" + | "darwin" + | "freebsd" + | "haiku" + | "linux" + | "openbsd" + | "sunos" + | "win32" + | "cygwin" + | "netbsd"; + type Architecture = + | "arm" + | "arm64" + | "ia32" + | "mips" + | "mipsel" + | "ppc" + | "ppc64" + | "riscv64" + | "s390" + | "s390x" + | "x64"; + type Signals = + | "SIGABRT" + | "SIGALRM" + | "SIGBUS" + | "SIGCHLD" + | "SIGCONT" + | "SIGFPE" + | "SIGHUP" + | "SIGILL" + | "SIGINT" + | "SIGIO" + | "SIGIOT" + | "SIGKILL" + | "SIGPIPE" + | "SIGPOLL" + | "SIGPROF" + | "SIGPWR" + | "SIGQUIT" + | "SIGSEGV" + | "SIGSTKFLT" + | "SIGSTOP" + | "SIGSYS" + | "SIGTERM" + | "SIGTRAP" + | "SIGTSTP" + | "SIGTTIN" + | "SIGTTOU" + | "SIGUNUSED" + | "SIGURG" + | "SIGUSR1" + | "SIGUSR2" + | "SIGVTALRM" + | "SIGWINCH" + | "SIGXCPU" + | "SIGXFSZ" + | "SIGBREAK" + | "SIGLOST" + | "SIGINFO"; + type UncaughtExceptionOrigin = "uncaughtException" | "unhandledRejection"; + type MultipleResolveType = "resolve" | "reject"; + type BeforeExitListener = (code: number) => void; + type DisconnectListener = () => void; + type ExitListener = (code: number) => void; + type RejectionHandledListener = (promise: Promise) => void; + type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void; + /** + * Most of the time the unhandledRejection will be an Error, but this should not be relied upon + * as *anything* can be thrown/rejected, it is therefore unsafe to assume that the value is an Error. + */ + type UnhandledRejectionListener = (reason: unknown, promise: Promise) => void; + type WarningListener = (warning: Error) => void; + type MessageListener = (message: unknown, sendHandle: unknown) => void; + type SignalsListener = (signal: Signals) => void; + type MultipleResolveListener = ( + type: MultipleResolveType, + promise: Promise, + value: unknown, + ) => void; + type WorkerListener = (worker: Worker) => void; + interface Socket extends ReadWriteStream { + isTTY?: true | undefined; + } + // Alias for compatibility + interface ProcessEnv extends Dict { + /** + * Can be used to change the default timezone at runtime + */ + TZ?: string; + } + interface HRTime { + (time?: [number, number]): [number, number]; + bigint(): bigint; + } + interface ProcessReport { + /** + * Directory where the report is written. + * working directory of the Node.js process. + * @default '' indicating that reports are written to the current + */ + directory: string; + /** + * Filename where the report is written. + * The default value is the empty string. + * @default '' the output filename will be comprised of a timestamp, + * PID, and sequence number. + */ + filename: string; + /** + * Returns a JSON-formatted diagnostic report for the running process. + * The report's JavaScript stack trace is taken from err, if present. + */ + getReport(err?: Error): string; + /** + * If true, a diagnostic report is generated on fatal errors, + * such as out of memory errors or failed C++ assertions. + * @default false + */ + reportOnFatalError: boolean; + /** + * If true, a diagnostic report is generated when the process + * receives the signal specified by process.report.signal. + * @default false + */ + reportOnSignal: boolean; + /** + * If true, a diagnostic report is generated on uncaught exception. + * @default false + */ + reportOnUncaughtException: boolean; + /** + * The signal used to trigger the creation of a diagnostic report. + * @default 'SIGUSR2' + */ + signal: Signals; + /** + * Writes a diagnostic report to a file. If filename is not provided, the default filename + * includes the date, time, PID, and a sequence number. + * The report's JavaScript stack trace is taken from err, if present. + * + * @param fileName Name of the file where the report is written. + * This should be a relative path, that will be appended to the directory specified in + * `process.report.directory`, or the current working directory of the Node.js process, + * if unspecified. + * @param error A custom error used for reporting the JavaScript stack. + * @return Filename of the generated report. + */ + writeReport(fileName?: string): string; + writeReport(error?: Error): string; + writeReport(fileName?: string, err?: Error): string; + } + interface ResourceUsage { + fsRead: number; + fsWrite: number; + involuntaryContextSwitches: number; + ipcReceived: number; + ipcSent: number; + majorPageFault: number; + maxRSS: number; + minorPageFault: number; + sharedMemorySize: number; + signalsCount: number; + swappedOut: number; + systemCPUTime: number; + unsharedDataSize: number; + unsharedStackSize: number; + userCPUTime: number; + voluntaryContextSwitches: number; + } + interface EmitWarningOptions { + /** + * When `warning` is a `string`, `type` is the name to use for the _type_ of warning being emitted. + * + * @default 'Warning' + */ + type?: string | undefined; + /** + * A unique identifier for the warning instance being emitted. + */ + code?: string | undefined; + /** + * When `warning` is a `string`, `ctor` is an optional function used to limit the generated stack trace. + * + * @default process.emitWarning + */ + ctor?: Function | undefined; + /** + * Additional text to include with the error. + */ + detail?: string | undefined; + } + interface ProcessConfig { + readonly target_defaults: { + readonly cflags: any[]; + readonly default_configuration: string; + readonly defines: string[]; + readonly include_dirs: string[]; + readonly libraries: string[]; + }; + readonly variables: { + readonly clang: number; + readonly host_arch: string; + readonly node_install_npm: boolean; + readonly node_install_waf: boolean; + readonly node_prefix: string; + readonly node_shared_openssl: boolean; + readonly node_shared_v8: boolean; + readonly node_shared_zlib: boolean; + readonly node_use_dtrace: boolean; + readonly node_use_etw: boolean; + readonly node_use_openssl: boolean; + readonly target_arch: string; + readonly v8_no_strict_aliasing: number; + readonly v8_use_snapshot: boolean; + readonly visibility: string; + }; + } + interface Process extends EventEmitter { + /** + * The `process.stdout` property returns a stream connected to`stdout` (fd `1`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `1` refers to a file, in which case it is + * a `Writable` stream. + * + * For example, to copy `process.stdin` to `process.stdout`: + * + * ```js + * import { stdin, stdout } from 'node:process'; + * + * stdin.pipe(stdout); + * ``` + * + * `process.stdout` differs from other Node.js streams in important ways. See `note on process I/O` for more information. + */ + stdout: WriteStream & { + fd: 1; + }; + /** + * The `process.stderr` property returns a stream connected to`stderr` (fd `2`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `2` refers to a file, in which case it is + * a `Writable` stream. + * + * `process.stderr` differs from other Node.js streams in important ways. See `note on process I/O` for more information. + */ + stderr: WriteStream & { + fd: 2; + }; + /** + * The `process.stdin` property returns a stream connected to`stdin` (fd `0`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `0` refers to a file, in which case it is + * a `Readable` stream. + * + * For details of how to read from `stdin` see `readable.read()`. + * + * As a `Duplex` stream, `process.stdin` can also be used in "old" mode that + * is compatible with scripts written for Node.js prior to v0.10\. + * For more information see `Stream compatibility`. + * + * In "old" streams mode the `stdin` stream is paused by default, so one + * must call `process.stdin.resume()` to read from it. Note also that calling`process.stdin.resume()` itself would switch stream to "old" mode. + */ + stdin: ReadStream & { + fd: 0; + }; + openStdin(): Socket; + /** + * The `process.argv` property returns an array containing the command-line + * arguments passed when the Node.js process was launched. The first element will + * be {@link execPath}. See `process.argv0` if access to the original value + * of `argv[0]` is needed. The second element will be the path to the JavaScript + * file being executed. The remaining elements will be any additional command-line + * arguments. + * + * For example, assuming the following script for `process-args.js`: + * + * ```js + * import { argv } from 'node:process'; + * + * // print process.argv + * argv.forEach((val, index) => { + * console.log(`${index}: ${val}`); + * }); + * ``` + * + * Launching the Node.js process as: + * + * ```bash + * node process-args.js one two=three four + * ``` + * + * Would generate the output: + * + * ```text + * 0: /usr/local/bin/node + * 1: /Users/mjr/work/node/process-args.js + * 2: one + * 3: two=three + * 4: four + * ``` + * @since v0.1.27 + */ + argv: string[]; + /** + * The `process.argv0` property stores a read-only copy of the original value of`argv[0]` passed when Node.js starts. + * + * ```console + * $ bash -c 'exec -a customArgv0 ./node' + * > process.argv[0] + * '/Volumes/code/external/node/out/Release/node' + * > process.argv0 + * 'customArgv0' + * ``` + * @since v6.4.0 + */ + argv0: string; + /** + * The `process.execArgv` property returns the set of Node.js-specific command-line + * options passed when the Node.js process was launched. These options do not + * appear in the array returned by the {@link argv} property, and do not + * include the Node.js executable, the name of the script, or any options following + * the script name. These options are useful in order to spawn child processes with + * the same execution environment as the parent. + * + * ```bash + * node --harmony script.js --version + * ``` + * + * Results in `process.execArgv`: + * + * ```js + * ['--harmony'] + * ``` + * + * And `process.argv`: + * + * ```js + * ['/usr/local/bin/node', 'script.js', '--version'] + * ``` + * + * Refer to `Worker constructor` for the detailed behavior of worker + * threads with this property. + * @since v0.7.7 + */ + execArgv: string[]; + /** + * The `process.execPath` property returns the absolute pathname of the executable + * that started the Node.js process. Symbolic links, if any, are resolved. + * + * ```js + * '/usr/local/bin/node' + * ``` + * @since v0.1.100 + */ + execPath: string; + /** + * The `process.abort()` method causes the Node.js process to exit immediately and + * generate a core file. + * + * This feature is not available in `Worker` threads. + * @since v0.7.0 + */ + abort(): never; + /** + * The `process.chdir()` method changes the current working directory of the + * Node.js process or throws an exception if doing so fails (for instance, if + * the specified `directory` does not exist). + * + * ```js + * import { chdir, cwd } from 'node:process'; + * + * console.log(`Starting directory: ${cwd()}`); + * try { + * chdir('/tmp'); + * console.log(`New directory: ${cwd()}`); + * } catch (err) { + * console.error(`chdir: ${err}`); + * } + * ``` + * + * This feature is not available in `Worker` threads. + * @since v0.1.17 + */ + chdir(directory: string): void; + /** + * The `process.cwd()` method returns the current working directory of the Node.js + * process. + * + * ```js + * import { cwd } from 'node:process'; + * + * console.log(`Current directory: ${cwd()}`); + * ``` + * @since v0.1.8 + */ + cwd(): string; + /** + * The port used by the Node.js debugger when enabled. + * + * ```js + * import process from 'node:process'; + * + * process.debugPort = 5858; + * ``` + * @since v0.7.2 + */ + debugPort: number; + /** + * The `process.emitWarning()` method can be used to emit custom or application + * specific process warnings. These can be listened for by adding a handler to the `'warning'` event. + * + * ```js + * import { emitWarning } from 'node:process'; + * + * // Emit a warning with a code and additional detail. + * emitWarning('Something happened!', { + * code: 'MY_WARNING', + * detail: 'This is some additional information', + * }); + * // Emits: + * // (node:56338) [MY_WARNING] Warning: Something happened! + * // This is some additional information + * ``` + * + * In this example, an `Error` object is generated internally by`process.emitWarning()` and passed through to the `'warning'` handler. + * + * ```js + * import process from 'node:process'; + * + * process.on('warning', (warning) => { + * console.warn(warning.name); // 'Warning' + * console.warn(warning.message); // 'Something happened!' + * console.warn(warning.code); // 'MY_WARNING' + * console.warn(warning.stack); // Stack trace + * console.warn(warning.detail); // 'This is some additional information' + * }); + * ``` + * + * If `warning` is passed as an `Error` object, the `options` argument is ignored. + * @since v8.0.0 + * @param warning The warning to emit. + */ + emitWarning(warning: string | Error, ctor?: Function): void; + emitWarning(warning: string | Error, type?: string, ctor?: Function): void; + emitWarning(warning: string | Error, type?: string, code?: string, ctor?: Function): void; + emitWarning(warning: string | Error, options?: EmitWarningOptions): void; + /** + * The `process.env` property returns an object containing the user environment. + * See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). + * + * An example of this object looks like: + * + * ```js + * { + * TERM: 'xterm-256color', + * SHELL: '/usr/local/bin/bash', + * USER: 'maciej', + * PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', + * PWD: '/Users/maciej', + * EDITOR: 'vim', + * SHLVL: '1', + * HOME: '/Users/maciej', + * LOGNAME: 'maciej', + * _: '/usr/local/bin/node' + * } + * ``` + * + * It is possible to modify this object, but such modifications will not be + * reflected outside the Node.js process, or (unless explicitly requested) + * to other `Worker` threads. + * In other words, the following example would not work: + * + * ```bash + * node -e 'process.env.foo = "bar"' && echo $foo + * ``` + * + * While the following will: + * + * ```js + * import { env } from 'node:process'; + * + * env.foo = 'bar'; + * console.log(env.foo); + * ``` + * + * Assigning a property on `process.env` will implicitly convert the value + * to a string. **This behavior is deprecated.** Future versions of Node.js may + * throw an error when the value is not a string, number, or boolean. + * + * ```js + * import { env } from 'node:process'; + * + * env.test = null; + * console.log(env.test); + * // => 'null' + * env.test = undefined; + * console.log(env.test); + * // => 'undefined' + * ``` + * + * Use `delete` to delete a property from `process.env`. + * + * ```js + * import { env } from 'node:process'; + * + * env.TEST = 1; + * delete env.TEST; + * console.log(env.TEST); + * // => undefined + * ``` + * + * On Windows operating systems, environment variables are case-insensitive. + * + * ```js + * import { env } from 'node:process'; + * + * env.TEST = 1; + * console.log(env.test); + * // => 1 + * ``` + * + * Unless explicitly specified when creating a `Worker` instance, + * each `Worker` thread has its own copy of `process.env`, based on its + * parent thread's `process.env`, or whatever was specified as the `env` option + * to the `Worker` constructor. Changes to `process.env` will not be visible + * across `Worker` threads, and only the main thread can make changes that + * are visible to the operating system or to native add-ons. On Windows, a copy of`process.env` on a `Worker` instance operates in a case-sensitive manner + * unlike the main thread. + * @since v0.1.27 + */ + env: ProcessEnv; + /** + * The `process.exit()` method instructs Node.js to terminate the process + * synchronously with an exit status of `code`. If `code` is omitted, exit uses + * either the 'success' code `0` or the value of `process.exitCode` if it has been + * set. Node.js will not terminate until all the `'exit'` event listeners are + * called. + * + * To exit with a 'failure' code: + * + * ```js + * import { exit } from 'node:process'; + * + * exit(1); + * ``` + * + * The shell that executed Node.js should see the exit code as `1`. + * + * Calling `process.exit()` will force the process to exit as quickly as possible + * even if there are still asynchronous operations pending that have not yet + * completed fully, including I/O operations to `process.stdout` and`process.stderr`. + * + * In most situations, it is not actually necessary to call `process.exit()`explicitly. The Node.js process will exit on its own _if there is no additional_ + * _work pending_ in the event loop. The `process.exitCode` property can be set to + * tell the process which exit code to use when the process exits gracefully. + * + * For instance, the following example illustrates a _misuse_ of the`process.exit()` method that could lead to data printed to stdout being + * truncated and lost: + * + * ```js + * import { exit } from 'node:process'; + * + * // This is an example of what *not* to do: + * if (someConditionNotMet()) { + * printUsageToStdout(); + * exit(1); + * } + * ``` + * + * The reason this is problematic is because writes to `process.stdout` in Node.js + * are sometimes _asynchronous_ and may occur over multiple ticks of the Node.js + * event loop. Calling `process.exit()`, however, forces the process to exit _before_ those additional writes to `stdout` can be performed. + * + * Rather than calling `process.exit()` directly, the code _should_ set the`process.exitCode` and allow the process to exit naturally by avoiding + * scheduling any additional work for the event loop: + * + * ```js + * import process from 'node:process'; + * + * // How to properly set the exit code while letting + * // the process exit gracefully. + * if (someConditionNotMet()) { + * printUsageToStdout(); + * process.exitCode = 1; + * } + * ``` + * + * If it is necessary to terminate the Node.js process due to an error condition, + * throwing an _uncaught_ error and allowing the process to terminate accordingly + * is safer than calling `process.exit()`. + * + * In `Worker` threads, this function stops the current thread rather + * than the current process. + * @since v0.1.13 + * @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed. + */ + exit(code?: number): never; + /** + * A number which will be the process exit code, when the process either + * exits gracefully, or is exited via {@link exit} without specifying + * a code. + * + * Specifying a code to {@link exit} will override any + * previous setting of `process.exitCode`. + * @since v0.11.8 + */ + exitCode?: number | undefined; + /** + * The `process.getgid()` method returns the numerical group identity of the + * process. (See [`getgid(2)`](http://man7.org/linux/man-pages/man2/getgid.2.html).) + * + * ```js + * import process from 'process'; + * + * if (process.getgid) { + * console.log(`Current gid: ${process.getgid()}`); + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v0.1.31 + */ + getgid?: () => number; + /** + * The `process.setgid()` method sets the group identity of the process. (See [`setgid(2)`](http://man7.org/linux/man-pages/man2/setgid.2.html).) The `id` can be passed as either a + * numeric ID or a group name + * string. If a group name is specified, this method blocks while resolving the + * associated numeric ID. + * + * ```js + * import process from 'process'; + * + * if (process.getgid && process.setgid) { + * console.log(`Current gid: ${process.getgid()}`); + * try { + * process.setgid(501); + * console.log(`New gid: ${process.getgid()}`); + * } catch (err) { + * console.log(`Failed to set gid: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v0.1.31 + * @param id The group name or ID + */ + setgid?: (id: number | string) => void; + /** + * The `process.getuid()` method returns the numeric user identity of the process. + * (See [`getuid(2)`](http://man7.org/linux/man-pages/man2/getuid.2.html).) + * + * ```js + * import process from 'process'; + * + * if (process.getuid) { + * console.log(`Current uid: ${process.getuid()}`); + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v0.1.28 + */ + getuid?: () => number; + /** + * The `process.setuid(id)` method sets the user identity of the process. (See [`setuid(2)`](http://man7.org/linux/man-pages/man2/setuid.2.html).) The `id` can be passed as either a + * numeric ID or a username string. + * If a username is specified, the method blocks while resolving the associated + * numeric ID. + * + * ```js + * import process from 'process'; + * + * if (process.getuid && process.setuid) { + * console.log(`Current uid: ${process.getuid()}`); + * try { + * process.setuid(501); + * console.log(`New uid: ${process.getuid()}`); + * } catch (err) { + * console.log(`Failed to set uid: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v0.1.28 + */ + setuid?: (id: number | string) => void; + /** + * The `process.geteuid()` method returns the numerical effective user identity of + * the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).) + * + * ```js + * import process from 'process'; + * + * if (process.geteuid) { + * console.log(`Current uid: ${process.geteuid()}`); + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v2.0.0 + */ + geteuid?: () => number; + /** + * The `process.seteuid()` method sets the effective user identity of the process. + * (See [`seteuid(2)`](http://man7.org/linux/man-pages/man2/seteuid.2.html).) The `id` can be passed as either a numeric ID or a username + * string. If a username is specified, the method blocks while resolving the + * associated numeric ID. + * + * ```js + * import process from 'process'; + * + * if (process.geteuid && process.seteuid) { + * console.log(`Current uid: ${process.geteuid()}`); + * try { + * process.seteuid(501); + * console.log(`New uid: ${process.geteuid()}`); + * } catch (err) { + * console.log(`Failed to set uid: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v2.0.0 + * @param id A user name or ID + */ + seteuid?: (id: number | string) => void; + /** + * The `process.getegid()` method returns the numerical effective group identity + * of the Node.js process. (See [`getegid(2)`](http://man7.org/linux/man-pages/man2/getegid.2.html).) + * + * ```js + * import process from 'process'; + * + * if (process.getegid) { + * console.log(`Current gid: ${process.getegid()}`); + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v2.0.0 + */ + getegid?: () => number; + /** + * The `process.setegid()` method sets the effective group identity of the process. + * (See [`setegid(2)`](http://man7.org/linux/man-pages/man2/setegid.2.html).) The `id` can be passed as either a numeric ID or a group + * name string. If a group name is specified, this method blocks while resolving + * the associated a numeric ID. + * + * ```js + * import process from 'process'; + * + * if (process.getegid && process.setegid) { + * console.log(`Current gid: ${process.getegid()}`); + * try { + * process.setegid(501); + * console.log(`New gid: ${process.getegid()}`); + * } catch (err) { + * console.log(`Failed to set gid: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v2.0.0 + * @param id A group name or ID + */ + setegid?: (id: number | string) => void; + /** + * The `process.getgroups()` method returns an array with the supplementary group + * IDs. POSIX leaves it unspecified if the effective group ID is included but + * Node.js ensures it always is. + * + * ```js + * import process from 'process'; + * + * if (process.getgroups) { + * console.log(process.getgroups()); // [ 16, 21, 297 ] + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v0.9.4 + */ + getgroups?: () => number[]; + /** + * The `process.setgroups()` method sets the supplementary group IDs for the + * Node.js process. This is a privileged operation that requires the Node.js + * process to have `root` or the `CAP_SETGID` capability. + * + * The `groups` array can contain numeric group IDs, group names, or both. + * + * ```js + * import process from 'process'; + * + * if (process.getgroups && process.setgroups) { + * try { + * process.setgroups([501]); + * console.log(process.getgroups()); // new groups + * } catch (err) { + * console.log(`Failed to set groups: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v0.9.4 + */ + setgroups?: (groups: ReadonlyArray) => void; + /** + * The `process.setUncaughtExceptionCaptureCallback()` function sets a function + * that will be invoked when an uncaught exception occurs, which will receive the + * exception value itself as its first argument. + * + * If such a function is set, the `'uncaughtException'` event will + * not be emitted. If `--abort-on-uncaught-exception` was passed from the + * command line or set through `v8.setFlagsFromString()`, the process will + * not abort. Actions configured to take place on exceptions such as report + * generations will be affected too + * + * To unset the capture function,`process.setUncaughtExceptionCaptureCallback(null)` may be used. Calling this + * method with a non-`null` argument while another capture function is set will + * throw an error. + * + * Using this function is mutually exclusive with using the deprecated `domain` built-in module. + * @since v9.3.0 + */ + setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void; + /** + * Indicates whether a callback has been set using {@link setUncaughtExceptionCaptureCallback}. + * @since v9.3.0 + */ + hasUncaughtExceptionCaptureCallback(): boolean; + /** + * The `process.sourceMapsEnabled` property returns whether the [Source Map v3](https://sourcemaps.info/spec.html) support for stack traces is enabled. + * @since v20.7.0 + * @experimental + */ + readonly sourceMapsEnabled: boolean; + /** + * This function enables or disables the Source Map v3 support for stack traces. + * It provides same features as launching Node.js process with commandline options --enable-source-maps. + * @since v16.6.0 + * @experimental + */ + setSourceMapsEnabled(value: boolean): void; + /** + * The `process.version` property contains the Node.js version string. + * + * ```js + * import { version } from 'node:process'; + * + * console.log(`Version: ${version}`); + * // Version: v14.8.0 + * ``` + * + * To get the version string without the prepended _v_, use`process.versions.node`. + * @since v0.1.3 + */ + readonly version: string; + /** + * The `process.versions` property returns an object listing the version strings of + * Node.js and its dependencies. `process.versions.modules` indicates the current + * ABI version, which is increased whenever a C++ API changes. Node.js will refuse + * to load modules that were compiled against a different module ABI version. + * + * ```js + * import { versions } from 'node:process'; + * + * console.log(versions); + * ``` + * + * Will generate an object similar to: + * + * ```console + * { node: '20.2.0', + * acorn: '8.8.2', + * ada: '2.4.0', + * ares: '1.19.0', + * base64: '0.5.0', + * brotli: '1.0.9', + * cjs_module_lexer: '1.2.2', + * cldr: '43.0', + * icu: '73.1', + * llhttp: '8.1.0', + * modules: '115', + * napi: '8', + * nghttp2: '1.52.0', + * nghttp3: '0.7.0', + * ngtcp2: '0.8.1', + * openssl: '3.0.8+quic', + * simdutf: '3.2.9', + * tz: '2023c', + * undici: '5.22.0', + * unicode: '15.0', + * uv: '1.44.2', + * uvwasi: '0.0.16', + * v8: '11.3.244.8-node.9', + * zlib: '1.2.13' } + * ``` + * @since v0.2.0 + */ + readonly versions: ProcessVersions; + /** + * The `process.config` property returns a frozen `Object` containing the + * JavaScript representation of the configure options used to compile the current + * Node.js executable. This is the same as the `config.gypi` file that was produced + * when running the `./configure` script. + * + * An example of the possible output looks like: + * + * ```js + * { + * target_defaults: + * { cflags: [], + * default_configuration: 'Release', + * defines: [], + * include_dirs: [], + * libraries: [] }, + * variables: + * { + * host_arch: 'x64', + * napi_build_version: 5, + * node_install_npm: 'true', + * node_prefix: '', + * node_shared_cares: 'false', + * node_shared_http_parser: 'false', + * node_shared_libuv: 'false', + * node_shared_zlib: 'false', + * node_use_openssl: 'true', + * node_shared_openssl: 'false', + * strict_aliasing: 'true', + * target_arch: 'x64', + * v8_use_snapshot: 1 + * } + * } + * ``` + * @since v0.7.7 + */ + readonly config: ProcessConfig; + /** + * The `process.kill()` method sends the `signal` to the process identified by`pid`. + * + * Signal names are strings such as `'SIGINT'` or `'SIGHUP'`. See `Signal Events` and [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for more information. + * + * This method will throw an error if the target `pid` does not exist. As a special + * case, a signal of `0` can be used to test for the existence of a process. + * Windows platforms will throw an error if the `pid` is used to kill a process + * group. + * + * Even though the name of this function is `process.kill()`, it is really just a + * signal sender, like the `kill` system call. The signal sent may do something + * other than kill the target process. + * + * ```js + * import process, { kill } from 'node:process'; + * + * process.on('SIGHUP', () => { + * console.log('Got SIGHUP signal.'); + * }); + * + * setTimeout(() => { + * console.log('Exiting.'); + * process.exit(0); + * }, 100); + * + * kill(process.pid, 'SIGHUP'); + * ``` + * + * When `SIGUSR1` is received by a Node.js process, Node.js will start the + * debugger. See `Signal Events`. + * @since v0.0.6 + * @param pid A process ID + * @param [signal='SIGTERM'] The signal to send, either as a string or number. + */ + kill(pid: number, signal?: string | number): true; + /** + * The `process.pid` property returns the PID of the process. + * + * ```js + * import { pid } from 'node:process'; + * + * console.log(`This process is pid ${pid}`); + * ``` + * @since v0.1.15 + */ + readonly pid: number; + /** + * The `process.ppid` property returns the PID of the parent of the + * current process. + * + * ```js + * import { ppid } from 'node:process'; + * + * console.log(`The parent process is pid ${ppid}`); + * ``` + * @since v9.2.0, v8.10.0, v6.13.0 + */ + readonly ppid: number; + /** + * The `process.title` property returns the current process title (i.e. returns + * the current value of `ps`). Assigning a new value to `process.title` modifies + * the current value of `ps`. + * + * When a new value is assigned, different platforms will impose different maximum + * length restrictions on the title. Usually such restrictions are quite limited. + * For instance, on Linux and macOS, `process.title` is limited to the size of the + * binary name plus the length of the command-line arguments because setting the`process.title` overwrites the `argv` memory of the process. Node.js v0.8 + * allowed for longer process title strings by also overwriting the `environ`memory but that was potentially insecure and confusing in some (rather obscure) + * cases. + * + * Assigning a value to `process.title` might not result in an accurate label + * within process manager applications such as macOS Activity Monitor or Windows + * Services Manager. + * @since v0.1.104 + */ + title: string; + /** + * The operating system CPU architecture for which the Node.js binary was compiled. + * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`. + * + * ```js + * import { arch } from 'node:process'; + * + * console.log(`This processor architecture is ${arch}`); + * ``` + * @since v0.5.0 + */ + readonly arch: Architecture; + /** + * The `process.platform` property returns a string identifying the operating + * system platform for which the Node.js binary was compiled. + * + * Currently possible values are: + * + * * `'aix'` + * * `'darwin'` + * * `'freebsd'` + * * `'linux'` + * * `'openbsd'` + * * `'sunos'` + * * `'win32'` + * + * ```js + * import { platform } from 'node:process'; + * + * console.log(`This platform is ${platform}`); + * ``` + * + * The value `'android'` may also be returned if the Node.js is built on the + * Android operating system. However, Android support in Node.js [is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os). + * @since v0.1.16 + */ + readonly platform: Platform; + /** + * The `process.mainModule` property provides an alternative way of retrieving `require.main`. The difference is that if the main module changes at + * runtime, `require.main` may still refer to the original main module in + * modules that were required before the change occurred. Generally, it's + * safe to assume that the two refer to the same module. + * + * As with `require.main`, `process.mainModule` will be `undefined` if there + * is no entry script. + * @since v0.1.17 + * @deprecated Since v14.0.0 - Use `main` instead. + */ + mainModule?: Module | undefined; + memoryUsage: MemoryUsageFn; + /** + * Gets the amount of memory available to the process (in bytes) based on + * limits imposed by the OS. If there is no such constraint, or the constraint + * is unknown, `undefined` is returned. + * + * See [`uv_get_constrained_memory`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_get_constrained_memory) for more + * information. + * @since v19.6.0, v18.15.0 + * @experimental + */ + constrainedMemory(): number | undefined; + /** + * The `process.cpuUsage()` method returns the user and system CPU time usage of + * the current process, in an object with properties `user` and `system`, whose + * values are microsecond values (millionth of a second). These values measure time + * spent in user and system code respectively, and may end up being greater than + * actual elapsed time if multiple CPU cores are performing work for this process. + * + * The result of a previous call to `process.cpuUsage()` can be passed as the + * argument to the function, to get a diff reading. + * + * ```js + * import { cpuUsage } from 'node:process'; + * + * const startUsage = cpuUsage(); + * // { user: 38579, system: 6986 } + * + * // spin the CPU for 500 milliseconds + * const now = Date.now(); + * while (Date.now() - now < 500); + * + * console.log(cpuUsage(startUsage)); + * // { user: 514883, system: 11226 } + * ``` + * @since v6.1.0 + * @param previousValue A previous return value from calling `process.cpuUsage()` + */ + cpuUsage(previousValue?: CpuUsage): CpuUsage; + /** + * `process.nextTick()` adds `callback` to the "next tick queue". This queue is + * fully drained after the current operation on the JavaScript stack runs to + * completion and before the event loop is allowed to continue. It's possible to + * create an infinite loop if one were to recursively call `process.nextTick()`. + * See the [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick) guide for more background. + * + * ```js + * import { nextTick } from 'node:process'; + * + * console.log('start'); + * nextTick(() => { + * console.log('nextTick callback'); + * }); + * console.log('scheduled'); + * // Output: + * // start + * // scheduled + * // nextTick callback + * ``` + * + * This is important when developing APIs in order to give users the opportunity + * to assign event handlers _after_ an object has been constructed but before any + * I/O has occurred: + * + * ```js + * import { nextTick } from 'node:process'; + * + * function MyThing(options) { + * this.setupOptions(options); + * + * nextTick(() => { + * this.startDoingStuff(); + * }); + * } + * + * const thing = new MyThing(); + * thing.getReadyForStuff(); + * + * // thing.startDoingStuff() gets called now, not before. + * ``` + * + * It is very important for APIs to be either 100% synchronous or 100% + * asynchronous. Consider this example: + * + * ```js + * // WARNING! DO NOT USE! BAD UNSAFE HAZARD! + * function maybeSync(arg, cb) { + * if (arg) { + * cb(); + * return; + * } + * + * fs.stat('file', cb); + * } + * ``` + * + * This API is hazardous because in the following case: + * + * ```js + * const maybeTrue = Math.random() > 0.5; + * + * maybeSync(maybeTrue, () => { + * foo(); + * }); + * + * bar(); + * ``` + * + * It is not clear whether `foo()` or `bar()` will be called first. + * + * The following approach is much better: + * + * ```js + * import { nextTick } from 'node:process'; + * + * function definitelyAsync(arg, cb) { + * if (arg) { + * nextTick(cb); + * return; + * } + * + * fs.stat('file', cb); + * } + * ``` + * @since v0.1.26 + * @param args Additional arguments to pass when invoking the `callback` + */ + nextTick(callback: Function, ...args: any[]): void; + /** + * The `process.release` property returns an `Object` containing metadata related + * to the current release, including URLs for the source tarball and headers-only + * tarball. + * + * `process.release` contains the following properties: + * + * ```js + * { + * name: 'node', + * lts: 'Hydrogen', + * sourceUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz', + * headersUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz', + * libUrl: 'https://nodejs.org/download/release/v18.12.0/win-x64/node.lib' + * } + * ``` + * + * In custom builds from non-release versions of the source tree, only the`name` property may be present. The additional properties should not be + * relied upon to exist. + * @since v3.0.0 + */ + readonly release: ProcessRelease; + features: { + inspector: boolean; + debug: boolean; + uv: boolean; + ipv6: boolean; + tls_alpn: boolean; + tls_sni: boolean; + tls_ocsp: boolean; + tls: boolean; + }; + /** + * `process.umask()` returns the Node.js process's file mode creation mask. Child + * processes inherit the mask from the parent process. + * @since v0.1.19 + * @deprecated Calling `process.umask()` with no argument causes the process-wide umask to be written twice. This introduces a race condition between threads, and is a potential * + * security vulnerability. There is no safe, cross-platform alternative API. + */ + umask(): number; + /** + * Can only be set if not in worker thread. + */ + umask(mask: string | number): number; + /** + * The `process.uptime()` method returns the number of seconds the current Node.js + * process has been running. + * + * The return value includes fractions of a second. Use `Math.floor()` to get whole + * seconds. + * @since v0.5.0 + */ + uptime(): number; + hrtime: HRTime; + /** + * If Node.js is spawned with an IPC channel, the `process.send()` method can be + * used to send messages to the parent process. Messages will be received as a `'message'` event on the parent's `ChildProcess` object. + * + * If Node.js was not spawned with an IPC channel, `process.send` will be `undefined`. + * + * The message goes through serialization and parsing. The resulting message might + * not be the same as what is originally sent. + * @since v0.5.9 + * @param options used to parameterize the sending of certain types of handles.`options` supports the following properties: + */ + send?( + message: any, + sendHandle?: any, + options?: { + swallowErrors?: boolean | undefined; + }, + callback?: (error: Error | null) => void, + ): boolean; + /** + * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.disconnect()` method will close the + * IPC channel to the parent process, allowing the child process to exit gracefully + * once there are no other connections keeping it alive. + * + * The effect of calling `process.disconnect()` is the same as calling `ChildProcess.disconnect()` from the parent process. + * + * If the Node.js process was not spawned with an IPC channel,`process.disconnect()` will be `undefined`. + * @since v0.7.2 + */ + disconnect(): void; + /** + * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.connected` property will return`true` so long as the IPC + * channel is connected and will return `false` after`process.disconnect()` is called. + * + * Once `process.connected` is `false`, it is no longer possible to send messages + * over the IPC channel using `process.send()`. + * @since v0.7.2 + */ + connected: boolean; + /** + * The `process.allowedNodeEnvironmentFlags` property is a special, + * read-only `Set` of flags allowable within the `NODE_OPTIONS` environment variable. + * + * `process.allowedNodeEnvironmentFlags` extends `Set`, but overrides`Set.prototype.has` to recognize several different possible flag + * representations. `process.allowedNodeEnvironmentFlags.has()` will + * return `true` in the following cases: + * + * * Flags may omit leading single (`-`) or double (`--`) dashes; e.g.,`inspect-brk` for `--inspect-brk`, or `r` for `-r`. + * * Flags passed through to V8 (as listed in `--v8-options`) may replace + * one or more _non-leading_ dashes for an underscore, or vice-versa; + * e.g., `--perf_basic_prof`, `--perf-basic-prof`, `--perf_basic-prof`, + * etc. + * * Flags may contain one or more equals (`=`) characters; all + * characters after and including the first equals will be ignored; + * e.g., `--stack-trace-limit=100`. + * * Flags _must_ be allowable within `NODE_OPTIONS`. + * + * When iterating over `process.allowedNodeEnvironmentFlags`, flags will + * appear only _once_; each will begin with one or more dashes. Flags + * passed through to V8 will contain underscores instead of non-leading + * dashes: + * + * ```js + * import { allowedNodeEnvironmentFlags } from 'node:process'; + * + * allowedNodeEnvironmentFlags.forEach((flag) => { + * // -r + * // --inspect-brk + * // --abort_on_uncaught_exception + * // ... + * }); + * ``` + * + * The methods `add()`, `clear()`, and `delete()` of`process.allowedNodeEnvironmentFlags` do nothing, and will fail + * silently. + * + * If Node.js was compiled _without_ `NODE_OPTIONS` support (shown in {@link config}), `process.allowedNodeEnvironmentFlags` will + * contain what _would have_ been allowable. + * @since v10.10.0 + */ + allowedNodeEnvironmentFlags: ReadonlySet; + /** + * `process.report` is an object whose methods are used to generate diagnostic + * reports for the current process. Additional documentation is available in the `report documentation`. + * @since v11.8.0 + */ + report?: ProcessReport | undefined; + /** + * ```js + * import { resourceUsage } from 'node:process'; + * + * console.log(resourceUsage()); + * /* + * Will output: + * { + * userCPUTime: 82872, + * systemCPUTime: 4143, + * maxRSS: 33164, + * sharedMemorySize: 0, + * unsharedDataSize: 0, + * unsharedStackSize: 0, + * minorPageFault: 2469, + * majorPageFault: 0, + * swappedOut: 0, + * fsRead: 0, + * fsWrite: 8, + * ipcSent: 0, + * ipcReceived: 0, + * signalsCount: 0, + * voluntaryContextSwitches: 79, + * involuntaryContextSwitches: 1 + * } + * + * ``` + * @since v12.6.0 + * @return the resource usage for the current process. All of these values come from the `uv_getrusage` call which returns a [`uv_rusage_t` struct][uv_rusage_t]. + */ + resourceUsage(): ResourceUsage; + /** + * The `process.traceDeprecation` property indicates whether the`--trace-deprecation` flag is set on the current Node.js process. See the + * documentation for the `'warning' event` and the `emitWarning() method` for more information about this + * flag's behavior. + * @since v0.8.0 + */ + traceDeprecation: boolean; + /* EventEmitter */ + addListener(event: "beforeExit", listener: BeforeExitListener): this; + addListener(event: "disconnect", listener: DisconnectListener): this; + addListener(event: "exit", listener: ExitListener): this; + addListener(event: "rejectionHandled", listener: RejectionHandledListener): this; + addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + addListener(event: "warning", listener: WarningListener): this; + addListener(event: "message", listener: MessageListener): this; + addListener(event: Signals, listener: SignalsListener): this; + addListener(event: "multipleResolves", listener: MultipleResolveListener): this; + addListener(event: "worker", listener: WorkerListener): this; + emit(event: "beforeExit", code: number): boolean; + emit(event: "disconnect"): boolean; + emit(event: "exit", code: number): boolean; + emit(event: "rejectionHandled", promise: Promise): boolean; + emit(event: "uncaughtException", error: Error): boolean; + emit(event: "uncaughtExceptionMonitor", error: Error): boolean; + emit(event: "unhandledRejection", reason: unknown, promise: Promise): boolean; + emit(event: "warning", warning: Error): boolean; + emit(event: "message", message: unknown, sendHandle: unknown): this; + emit(event: Signals, signal?: Signals): boolean; + emit( + event: "multipleResolves", + type: MultipleResolveType, + promise: Promise, + value: unknown, + ): this; + emit(event: "worker", listener: WorkerListener): this; + on(event: "beforeExit", listener: BeforeExitListener): this; + on(event: "disconnect", listener: DisconnectListener): this; + on(event: "exit", listener: ExitListener): this; + on(event: "rejectionHandled", listener: RejectionHandledListener): this; + on(event: "uncaughtException", listener: UncaughtExceptionListener): this; + on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + on(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + on(event: "warning", listener: WarningListener): this; + on(event: "message", listener: MessageListener): this; + on(event: Signals, listener: SignalsListener): this; + on(event: "multipleResolves", listener: MultipleResolveListener): this; + on(event: "worker", listener: WorkerListener): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "beforeExit", listener: BeforeExitListener): this; + once(event: "disconnect", listener: DisconnectListener): this; + once(event: "exit", listener: ExitListener): this; + once(event: "rejectionHandled", listener: RejectionHandledListener): this; + once(event: "uncaughtException", listener: UncaughtExceptionListener): this; + once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + once(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + once(event: "warning", listener: WarningListener): this; + once(event: "message", listener: MessageListener): this; + once(event: Signals, listener: SignalsListener): this; + once(event: "multipleResolves", listener: MultipleResolveListener): this; + once(event: "worker", listener: WorkerListener): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "beforeExit", listener: BeforeExitListener): this; + prependListener(event: "disconnect", listener: DisconnectListener): this; + prependListener(event: "exit", listener: ExitListener): this; + prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this; + prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + prependListener(event: "warning", listener: WarningListener): this; + prependListener(event: "message", listener: MessageListener): this; + prependListener(event: Signals, listener: SignalsListener): this; + prependListener(event: "multipleResolves", listener: MultipleResolveListener): this; + prependListener(event: "worker", listener: WorkerListener): this; + prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this; + prependOnceListener(event: "disconnect", listener: DisconnectListener): this; + prependOnceListener(event: "exit", listener: ExitListener): this; + prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this; + prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + prependOnceListener(event: "warning", listener: WarningListener): this; + prependOnceListener(event: "message", listener: MessageListener): this; + prependOnceListener(event: Signals, listener: SignalsListener): this; + prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this; + prependOnceListener(event: "worker", listener: WorkerListener): this; + listeners(event: "beforeExit"): BeforeExitListener[]; + listeners(event: "disconnect"): DisconnectListener[]; + listeners(event: "exit"): ExitListener[]; + listeners(event: "rejectionHandled"): RejectionHandledListener[]; + listeners(event: "uncaughtException"): UncaughtExceptionListener[]; + listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[]; + listeners(event: "unhandledRejection"): UnhandledRejectionListener[]; + listeners(event: "warning"): WarningListener[]; + listeners(event: "message"): MessageListener[]; + listeners(event: Signals): SignalsListener[]; + listeners(event: "multipleResolves"): MultipleResolveListener[]; + listeners(event: "worker"): WorkerListener[]; + } + } + } + export = process; +} +declare module "node:process" { + import process = require("process"); + export = process; +} diff --git a/node_modules/@types/node/punycode.d.ts b/node_modules/@types/node/punycode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2fc9f9a8ffbcffd5d9e966ef1d2b75fce902017 --- /dev/null +++ b/node_modules/@types/node/punycode.d.ts @@ -0,0 +1,117 @@ +/** + * **The version of the punycode module bundled in Node.js is being deprecated.**In a future major version of Node.js this module will be removed. Users + * currently depending on the `punycode` module should switch to using the + * userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL + * encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`. + * + * The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It + * can be accessed using: + * + * ```js + * const punycode = require('punycode'); + * ``` + * + * [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is + * primarily intended for use in Internationalized Domain Names. Because host + * names in URLs are limited to ASCII characters only, Domain Names that contain + * non-ASCII characters must be converted into ASCII using the Punycode scheme. + * For instance, the Japanese character that translates into the English word,`'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent + * to `'example.com'`) is represented by Punycode as the ASCII string`'xn--fsq.com'`. + * + * The `punycode` module provides a simple implementation of the Punycode standard. + * + * The `punycode` module is a third-party dependency used by Node.js and + * made available to developers as a convenience. Fixes or other modifications to + * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project. + * @deprecated Since v7.0.0 - Deprecated + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js) + */ +declare module "punycode" { + /** + * The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only + * characters to the equivalent string of Unicode codepoints. + * + * ```js + * punycode.decode('maana-pta'); // 'mañana' + * punycode.decode('--dqo34k'); // '☃-⌘' + * ``` + * @since v0.5.1 + */ + function decode(string: string): string; + /** + * The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters. + * + * ```js + * punycode.encode('mañana'); // 'maana-pta' + * punycode.encode('☃-⌘'); // '--dqo34k' + * ``` + * @since v0.5.1 + */ + function encode(string: string): string; + /** + * The `punycode.toUnicode()` method converts a string representing a domain name + * containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be + * converted. + * + * ```js + * // decode domain names + * punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com' + * punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' + * punycode.toUnicode('example.com'); // 'example.com' + * ``` + * @since v0.6.1 + */ + function toUnicode(domain: string): string; + /** + * The `punycode.toASCII()` method converts a Unicode string representing an + * Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the + * domain name will be converted. Calling `punycode.toASCII()` on a string that + * already only contains ASCII characters will have no effect. + * + * ```js + * // encode domain names + * punycode.toASCII('mañana.com'); // 'xn--maana-pta.com' + * punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' + * punycode.toASCII('example.com'); // 'example.com' + * ``` + * @since v0.6.1 + */ + function toASCII(domain: string): string; + /** + * @deprecated since v7.0.0 + * The version of the punycode module bundled in Node.js is being deprecated. + * In a future major version of Node.js this module will be removed. + * Users currently depending on the punycode module should switch to using + * the userland-provided Punycode.js module instead. + */ + const ucs2: ucs2; + interface ucs2 { + /** + * @deprecated since v7.0.0 + * The version of the punycode module bundled in Node.js is being deprecated. + * In a future major version of Node.js this module will be removed. + * Users currently depending on the punycode module should switch to using + * the userland-provided Punycode.js module instead. + */ + decode(string: string): number[]; + /** + * @deprecated since v7.0.0 + * The version of the punycode module bundled in Node.js is being deprecated. + * In a future major version of Node.js this module will be removed. + * Users currently depending on the punycode module should switch to using + * the userland-provided Punycode.js module instead. + */ + encode(codePoints: readonly number[]): string; + } + /** + * @deprecated since v7.0.0 + * The version of the punycode module bundled in Node.js is being deprecated. + * In a future major version of Node.js this module will be removed. + * Users currently depending on the punycode module should switch to using + * the userland-provided Punycode.js module instead. + */ + const version: string; +} +declare module "node:punycode" { + export * from "punycode"; +} diff --git a/node_modules/@types/node/querystring.d.ts b/node_modules/@types/node/querystring.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..54ecc967fff6e684451fc221d54f408576ac6852 --- /dev/null +++ b/node_modules/@types/node/querystring.d.ts @@ -0,0 +1,141 @@ +/** + * The `node:querystring` module provides utilities for parsing and formatting URL + * query strings. It can be accessed using: + * + * ```js + * const querystring = require('node:querystring'); + * ``` + * + * `querystring` is more performant than `URLSearchParams` but is not a + * standardized API. Use `URLSearchParams` when performance is not critical or + * when compatibility with browser code is desirable. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/querystring.js) + */ +declare module "querystring" { + interface StringifyOptions { + encodeURIComponent?: ((str: string) => string) | undefined; + } + interface ParseOptions { + maxKeys?: number | undefined; + decodeURIComponent?: ((str: string) => string) | undefined; + } + interface ParsedUrlQuery extends NodeJS.Dict {} + interface ParsedUrlQueryInput extends + NodeJS.Dict< + | string + | number + | boolean + | readonly string[] + | readonly number[] + | readonly boolean[] + | null + > + {} + /** + * The `querystring.stringify()` method produces a URL query string from a + * given `obj` by iterating through the object's "own properties". + * + * It serializes the following types of values passed in `obj`:[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | + * [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) | + * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) | + * [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) | + * [string\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | + * [number\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) | + * [bigint\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) | + * [boolean\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) The numeric values must be finite. Any other input values will be coerced to + * empty strings. + * + * ```js + * querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' }); + * // Returns 'foo=bar&baz=qux&baz=quux&corge=' + * + * querystring.stringify({ foo: 'bar', baz: 'qux' }, ';', ':'); + * // Returns 'foo:bar;baz:qux' + * ``` + * + * By default, characters requiring percent-encoding within the query string will + * be encoded as UTF-8\. If an alternative encoding is required, then an alternative`encodeURIComponent` option will need to be specified: + * + * ```js + * // Assuming gbkEncodeURIComponent function already exists, + * + * querystring.stringify({ w: '中文', foo: 'bar' }, null, null, + * { encodeURIComponent: gbkEncodeURIComponent }); + * ``` + * @since v0.1.25 + * @param obj The object to serialize into a URL query string + * @param [sep='&'] The substring used to delimit key and value pairs in the query string. + * @param [eq='='] . The substring used to delimit keys and values in the query string. + */ + function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string; + /** + * The `querystring.parse()` method parses a URL query string (`str`) into a + * collection of key and value pairs. + * + * For example, the query string `'foo=bar&abc=xyz&abc=123'` is parsed into: + * + * ```js + * { + * foo: 'bar', + * abc: ['xyz', '123'] + * } + * ``` + * + * The object returned by the `querystring.parse()` method _does not_prototypically inherit from the JavaScript `Object`. This means that typical`Object` methods such as `obj.toString()`, + * `obj.hasOwnProperty()`, and others + * are not defined and _will not work_. + * + * By default, percent-encoded characters within the query string will be assumed + * to use UTF-8 encoding. If an alternative character encoding is used, then an + * alternative `decodeURIComponent` option will need to be specified: + * + * ```js + * // Assuming gbkDecodeURIComponent function already exists... + * + * querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null, + * { decodeURIComponent: gbkDecodeURIComponent }); + * ``` + * @since v0.1.25 + * @param str The URL query string to parse + * @param [sep='&'] The substring used to delimit key and value pairs in the query string. + * @param [eq='='] . The substring used to delimit keys and values in the query string. + */ + function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery; + /** + * The querystring.encode() function is an alias for querystring.stringify(). + */ + const encode: typeof stringify; + /** + * The querystring.decode() function is an alias for querystring.parse(). + */ + const decode: typeof parse; + /** + * The `querystring.escape()` method performs URL percent-encoding on the given`str` in a manner that is optimized for the specific requirements of URL + * query strings. + * + * The `querystring.escape()` method is used by `querystring.stringify()` and is + * generally not expected to be used directly. It is exported primarily to allow + * application code to provide a replacement percent-encoding implementation if + * necessary by assigning `querystring.escape` to an alternative function. + * @since v0.1.25 + */ + function escape(str: string): string; + /** + * The `querystring.unescape()` method performs decoding of URL percent-encoded + * characters on the given `str`. + * + * The `querystring.unescape()` method is used by `querystring.parse()` and is + * generally not expected to be used directly. It is exported primarily to allow + * application code to provide a replacement decoding implementation if + * necessary by assigning `querystring.unescape` to an alternative function. + * + * By default, the `querystring.unescape()` method will attempt to use the + * JavaScript built-in `decodeURIComponent()` method to decode. If that fails, + * a safer equivalent that does not throw on malformed URLs will be used. + * @since v0.1.25 + */ + function unescape(str: string): string; +} +declare module "node:querystring" { + export * from "querystring"; +} diff --git a/node_modules/@types/node/readline.d.ts b/node_modules/@types/node/readline.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b06d58b85e62c03ff7d388177c9dce7bdde86569 --- /dev/null +++ b/node_modules/@types/node/readline.d.ts @@ -0,0 +1,539 @@ +/** + * The `node:readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time. + * + * To use the promise-based APIs: + * + * ```js + * import * as readline from 'node:readline/promises'; + * ``` + * + * To use the callback and sync APIs: + * + * ```js + * import * as readline from 'node:readline'; + * ``` + * + * The following simple example illustrates the basic use of the `node:readline`module. + * + * ```js + * import * as readline from 'node:readline/promises'; + * import { stdin as input, stdout as output } from 'node:process'; + * + * const rl = readline.createInterface({ input, output }); + * + * const answer = await rl.question('What do you think of Node.js? '); + * + * console.log(`Thank you for your valuable feedback: ${answer}`); + * + * rl.close(); + * ``` + * + * Once this code is invoked, the Node.js application will not terminate until the`readline.Interface` is closed because the interface waits for data to be + * received on the `input` stream. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/readline.js) + */ +declare module "readline" { + import { Abortable, EventEmitter } from "node:events"; + import * as promises from "node:readline/promises"; + export { promises }; + export interface Key { + sequence?: string | undefined; + name?: string | undefined; + ctrl?: boolean | undefined; + meta?: boolean | undefined; + shift?: boolean | undefined; + } + /** + * Instances of the `readline.Interface` class are constructed using the`readline.createInterface()` method. Every instance is associated with a + * single `input` `Readable` stream and a single `output` `Writable` stream. + * The `output` stream is used to print prompts for user input that arrives on, + * and is read from, the `input` stream. + * @since v0.1.104 + */ + export class Interface extends EventEmitter { + readonly terminal: boolean; + /** + * The current input data being processed by node. + * + * This can be used when collecting input from a TTY stream to retrieve the + * current value that has been processed thus far, prior to the `line` event + * being emitted. Once the `line` event has been emitted, this property will + * be an empty string. + * + * Be aware that modifying the value during the instance runtime may have + * unintended consequences if `rl.cursor` is not also controlled. + * + * **If not using a TTY stream for input, use the `'line'` event.** + * + * One possible use case would be as follows: + * + * ```js + * const values = ['lorem ipsum', 'dolor sit amet']; + * const rl = readline.createInterface(process.stdin); + * const showResults = debounce(() => { + * console.log( + * '\n', + * values.filter((val) => val.startsWith(rl.line)).join(' '), + * ); + * }, 300); + * process.stdin.on('keypress', (c, k) => { + * showResults(); + * }); + * ``` + * @since v0.1.98 + */ + readonly line: string; + /** + * The cursor position relative to `rl.line`. + * + * This will track where the current cursor lands in the input string, when + * reading input from a TTY stream. The position of cursor determines the + * portion of the input string that will be modified as input is processed, + * as well as the column where the terminal caret will be rendered. + * @since v0.1.98 + */ + readonly cursor: number; + /** + * NOTE: According to the documentation: + * + * > Instances of the `readline.Interface` class are constructed using the + * > `readline.createInterface()` method. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor + */ + protected constructor( + input: NodeJS.ReadableStream, + output?: NodeJS.WritableStream, + completer?: Completer | AsyncCompleter, + terminal?: boolean, + ); + /** + * NOTE: According to the documentation: + * + * > Instances of the `readline.Interface` class are constructed using the + * > `readline.createInterface()` method. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor + */ + protected constructor(options: ReadLineOptions); + /** + * The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`. + * @since v15.3.0, v14.17.0 + * @return the current prompt string + */ + getPrompt(): string; + /** + * The `rl.setPrompt()` method sets the prompt that will be written to `output`whenever `rl.prompt()` is called. + * @since v0.1.98 + */ + setPrompt(prompt: string): void; + /** + * The `rl.prompt()` method writes the `Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new + * location at which to provide input. + * + * When called, `rl.prompt()` will resume the `input` stream if it has been + * paused. + * + * If the `Interface` was created with `output` set to `null` or`undefined` the prompt is not written. + * @since v0.1.98 + * @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`. + */ + prompt(preserveCursor?: boolean): void; + /** + * The `rl.question()` method displays the `query` by writing it to the `output`, + * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument. + * + * When called, `rl.question()` will resume the `input` stream if it has been + * paused. + * + * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. + * + * The `callback` function passed to `rl.question()` does not follow the typical + * pattern of accepting an `Error` object or `null` as the first argument. + * The `callback` is called with the provided answer as the only argument. + * + * An error will be thrown if calling `rl.question()` after `rl.close()`. + * + * Example usage: + * + * ```js + * rl.question('What is your favorite food? ', (answer) => { + * console.log(`Oh, so your favorite food is ${answer}`); + * }); + * ``` + * + * Using an `AbortController` to cancel a question. + * + * ```js + * const ac = new AbortController(); + * const signal = ac.signal; + * + * rl.question('What is your favorite food? ', { signal }, (answer) => { + * console.log(`Oh, so your favorite food is ${answer}`); + * }); + * + * signal.addEventListener('abort', () => { + * console.log('The food question timed out'); + * }, { once: true }); + * + * setTimeout(() => ac.abort(), 10000); + * ``` + * @since v0.3.3 + * @param query A statement or query to write to `output`, prepended to the prompt. + * @param callback A callback function that is invoked with the user's input in response to the `query`. + */ + question(query: string, callback: (answer: string) => void): void; + question(query: string, options: Abortable, callback: (answer: string) => void): void; + /** + * The `rl.pause()` method pauses the `input` stream, allowing it to be resumed + * later if necessary. + * + * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `Interface` instance. + * @since v0.3.4 + */ + pause(): this; + /** + * The `rl.resume()` method resumes the `input` stream if it has been paused. + * @since v0.3.4 + */ + resume(): this; + /** + * The `rl.close()` method closes the `Interface` instance and + * relinquishes control over the `input` and `output` streams. When called, + * the `'close'` event will be emitted. + * + * Calling `rl.close()` does not immediately stop other events (including `'line'`) + * from being emitted by the `Interface` instance. + * @since v0.1.98 + */ + close(): void; + /** + * The `rl.write()` method will write either `data` or a key sequence identified + * by `key` to the `output`. The `key` argument is supported only if `output` is + * a `TTY` text terminal. See `TTY keybindings` for a list of key + * combinations. + * + * If `key` is specified, `data` is ignored. + * + * When called, `rl.write()` will resume the `input` stream if it has been + * paused. + * + * If the `Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written. + * + * ```js + * rl.write('Delete this!'); + * // Simulate Ctrl+U to delete the line written previously + * rl.write(null, { ctrl: true, name: 'u' }); + * ``` + * + * The `rl.write()` method will write the data to the `readline` `Interface`'s`input`_as if it were provided by the user_. + * @since v0.1.98 + */ + write(data: string | Buffer, key?: Key): void; + write(data: undefined | null | string | Buffer, key: Key): void; + /** + * Returns the real position of the cursor in relation to the input + * prompt + string. Long input (wrapping) strings, as well as multiple + * line prompts are included in the calculations. + * @since v13.5.0, v12.16.0 + */ + getCursorPos(): CursorPos; + /** + * events.EventEmitter + * 1. close + * 2. line + * 3. pause + * 4. resume + * 5. SIGCONT + * 6. SIGINT + * 7. SIGTSTP + * 8. history + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "line", listener: (input: string) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: "SIGCONT", listener: () => void): this; + addListener(event: "SIGINT", listener: () => void): this; + addListener(event: "SIGTSTP", listener: () => void): this; + addListener(event: "history", listener: (history: string[]) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "line", input: string): boolean; + emit(event: "pause"): boolean; + emit(event: "resume"): boolean; + emit(event: "SIGCONT"): boolean; + emit(event: "SIGINT"): boolean; + emit(event: "SIGTSTP"): boolean; + emit(event: "history", history: string[]): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "line", listener: (input: string) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: "SIGCONT", listener: () => void): this; + on(event: "SIGINT", listener: () => void): this; + on(event: "SIGTSTP", listener: () => void): this; + on(event: "history", listener: (history: string[]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "line", listener: (input: string) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: "SIGCONT", listener: () => void): this; + once(event: "SIGINT", listener: () => void): this; + once(event: "SIGTSTP", listener: () => void): this; + once(event: "history", listener: (history: string[]) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "line", listener: (input: string) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: "SIGCONT", listener: () => void): this; + prependListener(event: "SIGINT", listener: () => void): this; + prependListener(event: "SIGTSTP", listener: () => void): this; + prependListener(event: "history", listener: (history: string[]) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "line", listener: (input: string) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: "SIGCONT", listener: () => void): this; + prependOnceListener(event: "SIGINT", listener: () => void): this; + prependOnceListener(event: "SIGTSTP", listener: () => void): this; + prependOnceListener(event: "history", listener: (history: string[]) => void): this; + [Symbol.asyncIterator](): AsyncIterableIterator; + } + export type ReadLine = Interface; // type forwarded for backwards compatibility + export type Completer = (line: string) => CompleterResult; + export type AsyncCompleter = ( + line: string, + callback: (err?: null | Error, result?: CompleterResult) => void, + ) => void; + export type CompleterResult = [string[], string]; + export interface ReadLineOptions { + input: NodeJS.ReadableStream; + output?: NodeJS.WritableStream | undefined; + completer?: Completer | AsyncCompleter | undefined; + terminal?: boolean | undefined; + /** + * Initial list of history lines. This option makes sense + * only if `terminal` is set to `true` by the user or by an internal `output` + * check, otherwise the history caching mechanism is not initialized at all. + * @default [] + */ + history?: string[] | undefined; + historySize?: number | undefined; + prompt?: string | undefined; + crlfDelay?: number | undefined; + /** + * If `true`, when a new input line added + * to the history list duplicates an older one, this removes the older line + * from the list. + * @default false + */ + removeHistoryDuplicates?: boolean | undefined; + escapeCodeTimeout?: number | undefined; + tabSize?: number | undefined; + } + /** + * The `readline.createInterface()` method creates a new `readline.Interface`instance. + * + * ```js + * const readline = require('node:readline'); + * const rl = readline.createInterface({ + * input: process.stdin, + * output: process.stdout, + * }); + * ``` + * + * Once the `readline.Interface` instance is created, the most common case is to + * listen for the `'line'` event: + * + * ```js + * rl.on('line', (line) => { + * console.log(`Received: ${line}`); + * }); + * ``` + * + * If `terminal` is `true` for this instance then the `output` stream will get + * the best compatibility if it defines an `output.columns` property and emits + * a `'resize'` event on the `output` if or when the columns ever change + * (`process.stdout` does this automatically when it is a TTY). + * + * When creating a `readline.Interface` using `stdin` as input, the program + * will not terminate until it receives an [EOF character](https://en.wikipedia.org/wiki/End-of-file#EOF_character). To exit without + * waiting for user input, call `process.stdin.unref()`. + * @since v0.1.98 + */ + export function createInterface( + input: NodeJS.ReadableStream, + output?: NodeJS.WritableStream, + completer?: Completer | AsyncCompleter, + terminal?: boolean, + ): Interface; + export function createInterface(options: ReadLineOptions): Interface; + /** + * The `readline.emitKeypressEvents()` method causes the given `Readable` stream to begin emitting `'keypress'` events corresponding to received input. + * + * Optionally, `interface` specifies a `readline.Interface` instance for which + * autocompletion is disabled when copy-pasted input is detected. + * + * If the `stream` is a `TTY`, then it must be in raw mode. + * + * This is automatically called by any readline instance on its `input` if the`input` is a terminal. Closing the `readline` instance does not stop + * the `input` from emitting `'keypress'` events. + * + * ```js + * readline.emitKeypressEvents(process.stdin); + * if (process.stdin.isTTY) + * process.stdin.setRawMode(true); + * ``` + * + * ## Example: Tiny CLI + * + * The following example illustrates the use of `readline.Interface` class to + * implement a small command-line interface: + * + * ```js + * const readline = require('node:readline'); + * const rl = readline.createInterface({ + * input: process.stdin, + * output: process.stdout, + * prompt: 'OHAI> ', + * }); + * + * rl.prompt(); + * + * rl.on('line', (line) => { + * switch (line.trim()) { + * case 'hello': + * console.log('world!'); + * break; + * default: + * console.log(`Say what? I might have heard '${line.trim()}'`); + * break; + * } + * rl.prompt(); + * }).on('close', () => { + * console.log('Have a great day!'); + * process.exit(0); + * }); + * ``` + * + * ## Example: Read file stream line-by-Line + * + * A common use case for `readline` is to consume an input file one line at a + * time. The easiest way to do so is leveraging the `fs.ReadStream` API as + * well as a `for await...of` loop: + * + * ```js + * const fs = require('node:fs'); + * const readline = require('node:readline'); + * + * async function processLineByLine() { + * const fileStream = fs.createReadStream('input.txt'); + * + * const rl = readline.createInterface({ + * input: fileStream, + * crlfDelay: Infinity, + * }); + * // Note: we use the crlfDelay option to recognize all instances of CR LF + * // ('\r\n') in input.txt as a single line break. + * + * for await (const line of rl) { + * // Each line in input.txt will be successively available here as `line`. + * console.log(`Line from file: ${line}`); + * } + * } + * + * processLineByLine(); + * ``` + * + * Alternatively, one could use the `'line'` event: + * + * ```js + * const fs = require('node:fs'); + * const readline = require('node:readline'); + * + * const rl = readline.createInterface({ + * input: fs.createReadStream('sample.txt'), + * crlfDelay: Infinity, + * }); + * + * rl.on('line', (line) => { + * console.log(`Line from file: ${line}`); + * }); + * ``` + * + * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied: + * + * ```js + * const { once } = require('node:events'); + * const { createReadStream } = require('node:fs'); + * const { createInterface } = require('node:readline'); + * + * (async function processLineByLine() { + * try { + * const rl = createInterface({ + * input: createReadStream('big-file.txt'), + * crlfDelay: Infinity, + * }); + * + * rl.on('line', (line) => { + * // Process the line. + * }); + * + * await once(rl, 'close'); + * + * console.log('File processed.'); + * } catch (err) { + * console.error(err); + * } + * })(); + * ``` + * @since v0.7.7 + */ + export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void; + export type Direction = -1 | 0 | 1; + export interface CursorPos { + rows: number; + cols: number; + } + /** + * The `readline.clearLine()` method clears current line of given `TTY` stream + * in a specified direction identified by `dir`. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean; + /** + * The `readline.clearScreenDown()` method clears the given `TTY` stream from + * the current position of the cursor down. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean; + /** + * The `readline.cursorTo()` method moves cursor to the specified position in a + * given `TTY` `stream`. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean; + /** + * The `readline.moveCursor()` method moves the cursor _relative_ to its current + * position in a given `TTY` `stream`. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + export function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean; +} +declare module "node:readline" { + export * from "readline"; +} diff --git a/node_modules/@types/node/readline/promises.d.ts b/node_modules/@types/node/readline/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..73fb1115d50096f9e6bcadf04943a597c5146312 --- /dev/null +++ b/node_modules/@types/node/readline/promises.d.ts @@ -0,0 +1,150 @@ +/** + * @since v17.0.0 + * @experimental + */ +declare module "readline/promises" { + import { AsyncCompleter, Completer, Direction, Interface as _Interface, ReadLineOptions } from "node:readline"; + import { Abortable } from "node:events"; + /** + * Instances of the `readlinePromises.Interface` class are constructed using the`readlinePromises.createInterface()` method. Every instance is associated with a + * single `input` `Readable` stream and a single `output` `Writable` stream. + * The `output` stream is used to print prompts for user input that arrives on, + * and is read from, the `input` stream. + * @since v17.0.0 + */ + class Interface extends _Interface { + /** + * The `rl.question()` method displays the `query` by writing it to the `output`, + * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument. + * + * When called, `rl.question()` will resume the `input` stream if it has been + * paused. + * + * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. + * + * If the question is called after `rl.close()`, it returns a rejected promise. + * + * Example usage: + * + * ```js + * const answer = await rl.question('What is your favorite food? '); + * console.log(`Oh, so your favorite food is ${answer}`); + * ``` + * + * Using an `AbortSignal` to cancel a question. + * + * ```js + * const signal = AbortSignal.timeout(10_000); + * + * signal.addEventListener('abort', () => { + * console.log('The food question timed out'); + * }, { once: true }); + * + * const answer = await rl.question('What is your favorite food? ', { signal }); + * console.log(`Oh, so your favorite food is ${answer}`); + * ``` + * @since v17.0.0 + * @param query A statement or query to write to `output`, prepended to the prompt. + * @return A promise that is fulfilled with the user's input in response to the `query`. + */ + question(query: string): Promise; + question(query: string, options: Abortable): Promise; + } + /** + * @since v17.0.0 + */ + class Readline { + /** + * @param stream A TTY stream. + */ + constructor( + stream: NodeJS.WritableStream, + options?: { + autoCommit?: boolean; + }, + ); + /** + * The `rl.clearLine()` method adds to the internal list of pending action an + * action that clears current line of the associated `stream` in a specified + * direction identified by `dir`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this + */ + clearLine(dir: Direction): this; + /** + * The `rl.clearScreenDown()` method adds to the internal list of pending action an + * action that clears the associated stream from the current position of the + * cursor down. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this + */ + clearScreenDown(): this; + /** + * The `rl.commit()` method sends all the pending actions to the associated`stream` and clears the internal list of pending actions. + * @since v17.0.0 + */ + commit(): Promise; + /** + * The `rl.cursorTo()` method adds to the internal list of pending action an action + * that moves cursor to the specified position in the associated `stream`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this + */ + cursorTo(x: number, y?: number): this; + /** + * The `rl.moveCursor()` method adds to the internal list of pending action an + * action that moves the cursor _relative_ to its current position in the + * associated `stream`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this + */ + moveCursor(dx: number, dy: number): this; + /** + * The `rl.rollback` methods clears the internal list of pending actions without + * sending it to the associated `stream`. + * @since v17.0.0 + * @return this + */ + rollback(): this; + } + /** + * The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface`instance. + * + * ```js + * const readlinePromises = require('node:readline/promises'); + * const rl = readlinePromises.createInterface({ + * input: process.stdin, + * output: process.stdout, + * }); + * ``` + * + * Once the `readlinePromises.Interface` instance is created, the most common case + * is to listen for the `'line'` event: + * + * ```js + * rl.on('line', (line) => { + * console.log(`Received: ${line}`); + * }); + * ``` + * + * If `terminal` is `true` for this instance then the `output` stream will get + * the best compatibility if it defines an `output.columns` property and emits + * a `'resize'` event on the `output` if or when the columns ever change + * (`process.stdout` does this automatically when it is a TTY). + * @since v17.0.0 + */ + function createInterface( + input: NodeJS.ReadableStream, + output?: NodeJS.WritableStream, + completer?: Completer | AsyncCompleter, + terminal?: boolean, + ): Interface; + function createInterface(options: ReadLineOptions): Interface; +} +declare module "node:readline/promises" { + export * from "readline/promises"; +} diff --git a/node_modules/@types/node/repl.d.ts b/node_modules/@types/node/repl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c5f81b399df50506180bd8d271840029659572b --- /dev/null +++ b/node_modules/@types/node/repl.d.ts @@ -0,0 +1,430 @@ +/** + * The `node:repl` module provides a Read-Eval-Print-Loop (REPL) implementation + * that is available both as a standalone program or includible in other + * applications. It can be accessed using: + * + * ```js + * const repl = require('node:repl'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/repl.js) + */ +declare module "repl" { + import { AsyncCompleter, Completer, Interface } from "node:readline"; + import { Context } from "node:vm"; + import { InspectOptions } from "node:util"; + interface ReplOptions { + /** + * The input prompt to display. + * @default "> " + */ + prompt?: string | undefined; + /** + * The `Readable` stream from which REPL input will be read. + * @default process.stdin + */ + input?: NodeJS.ReadableStream | undefined; + /** + * The `Writable` stream to which REPL output will be written. + * @default process.stdout + */ + output?: NodeJS.WritableStream | undefined; + /** + * If `true`, specifies that the output should be treated as a TTY terminal, and have + * ANSI/VT100 escape codes written to it. + * Default: checking the value of the `isTTY` property on the output stream upon + * instantiation. + */ + terminal?: boolean | undefined; + /** + * The function to be used when evaluating each given line of input. + * Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can + * error with `repl.Recoverable` to indicate the input was incomplete and prompt for + * additional lines. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_default_evaluation + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_custom_evaluation_functions + */ + eval?: REPLEval | undefined; + /** + * Defines if the repl prints output previews or not. + * @default `true` Always `false` in case `terminal` is falsy. + */ + preview?: boolean | undefined; + /** + * If `true`, specifies that the default `writer` function should include ANSI color + * styling to REPL output. If a custom `writer` function is provided then this has no + * effect. + * Default: the REPL instance's `terminal` value. + */ + useColors?: boolean | undefined; + /** + * If `true`, specifies that the default evaluation function will use the JavaScript + * `global` as the context as opposed to creating a new separate context for the REPL + * instance. The node CLI REPL sets this value to `true`. + * Default: `false`. + */ + useGlobal?: boolean | undefined; + /** + * If `true`, specifies that the default writer will not output the return value of a + * command if it evaluates to `undefined`. + * Default: `false`. + */ + ignoreUndefined?: boolean | undefined; + /** + * The function to invoke to format the output of each command before writing to `output`. + * Default: a wrapper for `util.inspect`. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_customizing_repl_output + */ + writer?: REPLWriter | undefined; + /** + * An optional function used for custom Tab auto completion. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#readline_use_of_the_completer_function + */ + completer?: Completer | AsyncCompleter | undefined; + /** + * A flag that specifies whether the default evaluator executes all JavaScript commands in + * strict mode or default (sloppy) mode. + * Accepted values are: + * - `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode. + * - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to + * prefacing every repl statement with `'use strict'`. + */ + replMode?: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT | undefined; + /** + * Stop evaluating the current piece of code when `SIGINT` is received, i.e. `Ctrl+C` is + * pressed. This cannot be used together with a custom `eval` function. + * Default: `false`. + */ + breakEvalOnSigint?: boolean | undefined; + } + type REPLEval = ( + this: REPLServer, + evalCmd: string, + context: Context, + file: string, + cb: (err: Error | null, result: any) => void, + ) => void; + type REPLWriter = (this: REPLServer, obj: any) => string; + /** + * This is the default "writer" value, if none is passed in the REPL options, + * and it can be overridden by custom print functions. + */ + const writer: REPLWriter & { + options: InspectOptions; + }; + type REPLCommandAction = (this: REPLServer, text: string) => void; + interface REPLCommand { + /** + * Help text to be displayed when `.help` is entered. + */ + help?: string | undefined; + /** + * The function to execute, optionally accepting a single string argument. + */ + action: REPLCommandAction; + } + /** + * Instances of `repl.REPLServer` are created using the {@link start} method + * or directly using the JavaScript `new` keyword. + * + * ```js + * const repl = require('node:repl'); + * + * const options = { useColors: true }; + * + * const firstInstance = repl.start(options); + * const secondInstance = new repl.REPLServer(options); + * ``` + * @since v0.1.91 + */ + class REPLServer extends Interface { + /** + * The `vm.Context` provided to the `eval` function to be used for JavaScript + * evaluation. + */ + readonly context: Context; + /** + * @deprecated since v14.3.0 - Use `input` instead. + */ + readonly inputStream: NodeJS.ReadableStream; + /** + * @deprecated since v14.3.0 - Use `output` instead. + */ + readonly outputStream: NodeJS.WritableStream; + /** + * The `Readable` stream from which REPL input will be read. + */ + readonly input: NodeJS.ReadableStream; + /** + * The `Writable` stream to which REPL output will be written. + */ + readonly output: NodeJS.WritableStream; + /** + * The commands registered via `replServer.defineCommand()`. + */ + readonly commands: NodeJS.ReadOnlyDict; + /** + * A value indicating whether the REPL is currently in "editor mode". + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_commands_and_special_keys + */ + readonly editorMode: boolean; + /** + * A value indicating whether the `_` variable has been assigned. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + */ + readonly underscoreAssigned: boolean; + /** + * The last evaluation result from the REPL (assigned to the `_` variable inside of the REPL). + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + */ + readonly last: any; + /** + * A value indicating whether the `_error` variable has been assigned. + * + * @since v9.8.0 + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + */ + readonly underscoreErrAssigned: boolean; + /** + * The last error raised inside the REPL (assigned to the `_error` variable inside of the REPL). + * + * @since v9.8.0 + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + */ + readonly lastError: any; + /** + * Specified in the REPL options, this is the function to be used when evaluating each + * given line of input. If not specified in the REPL options, this is an async wrapper + * for the JavaScript `eval()` function. + */ + readonly eval: REPLEval; + /** + * Specified in the REPL options, this is a value indicating whether the default + * `writer` function should include ANSI color styling to REPL output. + */ + readonly useColors: boolean; + /** + * Specified in the REPL options, this is a value indicating whether the default `eval` + * function will use the JavaScript `global` as the context as opposed to creating a new + * separate context for the REPL instance. + */ + readonly useGlobal: boolean; + /** + * Specified in the REPL options, this is a value indicating whether the default `writer` + * function should output the result of a command if it evaluates to `undefined`. + */ + readonly ignoreUndefined: boolean; + /** + * Specified in the REPL options, this is the function to invoke to format the output of + * each command before writing to `outputStream`. If not specified in the REPL options, + * this will be a wrapper for `util.inspect`. + */ + readonly writer: REPLWriter; + /** + * Specified in the REPL options, this is the function to use for custom Tab auto-completion. + */ + readonly completer: Completer | AsyncCompleter; + /** + * Specified in the REPL options, this is a flag that specifies whether the default `eval` + * function should execute all JavaScript commands in strict mode or default (sloppy) mode. + * Possible values are: + * - `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode. + * - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to + * prefacing every repl statement with `'use strict'`. + */ + readonly replMode: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT; + /** + * NOTE: According to the documentation: + * + * > Instances of `repl.REPLServer` are created using the `repl.start()` method and + * > _should not_ be created directly using the JavaScript `new` keyword. + * + * `REPLServer` cannot be subclassed due to implementation specifics in NodeJS. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_class_replserver + */ + private constructor(); + /** + * The `replServer.defineCommand()` method is used to add new `.`\-prefixed commands + * to the REPL instance. Such commands are invoked by typing a `.` followed by the`keyword`. The `cmd` is either a `Function` or an `Object` with the following + * properties: + * + * The following example shows two new commands added to the REPL instance: + * + * ```js + * const repl = require('node:repl'); + * + * const replServer = repl.start({ prompt: '> ' }); + * replServer.defineCommand('sayhello', { + * help: 'Say hello', + * action(name) { + * this.clearBufferedCommand(); + * console.log(`Hello, ${name}!`); + * this.displayPrompt(); + * }, + * }); + * replServer.defineCommand('saybye', function saybye() { + * console.log('Goodbye!'); + * this.close(); + * }); + * ``` + * + * The new commands can then be used from within the REPL instance: + * + * ```console + * > .sayhello Node.js User + * Hello, Node.js User! + * > .saybye + * Goodbye! + * ``` + * @since v0.3.0 + * @param keyword The command keyword (_without_ a leading `.` character). + * @param cmd The function to invoke when the command is processed. + */ + defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void; + /** + * The `replServer.displayPrompt()` method readies the REPL instance for input + * from the user, printing the configured `prompt` to a new line in the `output`and resuming the `input` to accept new input. + * + * When multi-line input is being entered, an ellipsis is printed rather than the + * 'prompt'. + * + * When `preserveCursor` is `true`, the cursor placement will not be reset to `0`. + * + * The `replServer.displayPrompt` method is primarily intended to be called from + * within the action function for commands registered using the`replServer.defineCommand()` method. + * @since v0.1.91 + */ + displayPrompt(preserveCursor?: boolean): void; + /** + * The `replServer.clearBufferedCommand()` method clears any command that has been + * buffered but not yet executed. This method is primarily intended to be + * called from within the action function for commands registered using the`replServer.defineCommand()` method. + * @since v9.0.0 + */ + clearBufferedCommand(): void; + /** + * Initializes a history log file for the REPL instance. When executing the + * Node.js binary and using the command-line REPL, a history file is initialized + * by default. However, this is not the case when creating a REPL + * programmatically. Use this method to initialize a history log file when working + * with REPL instances programmatically. + * @since v11.10.0 + * @param historyPath the path to the history file + * @param callback called when history writes are ready or upon error + */ + setupHistory(path: string, callback: (err: Error | null, repl: this) => void): void; + /** + * events.EventEmitter + * 1. close - inherited from `readline.Interface` + * 2. line - inherited from `readline.Interface` + * 3. pause - inherited from `readline.Interface` + * 4. resume - inherited from `readline.Interface` + * 5. SIGCONT - inherited from `readline.Interface` + * 6. SIGINT - inherited from `readline.Interface` + * 7. SIGTSTP - inherited from `readline.Interface` + * 8. exit + * 9. reset + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "line", listener: (input: string) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: "SIGCONT", listener: () => void): this; + addListener(event: "SIGINT", listener: () => void): this; + addListener(event: "SIGTSTP", listener: () => void): this; + addListener(event: "exit", listener: () => void): this; + addListener(event: "reset", listener: (context: Context) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "line", input: string): boolean; + emit(event: "pause"): boolean; + emit(event: "resume"): boolean; + emit(event: "SIGCONT"): boolean; + emit(event: "SIGINT"): boolean; + emit(event: "SIGTSTP"): boolean; + emit(event: "exit"): boolean; + emit(event: "reset", context: Context): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "line", listener: (input: string) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: "SIGCONT", listener: () => void): this; + on(event: "SIGINT", listener: () => void): this; + on(event: "SIGTSTP", listener: () => void): this; + on(event: "exit", listener: () => void): this; + on(event: "reset", listener: (context: Context) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "line", listener: (input: string) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: "SIGCONT", listener: () => void): this; + once(event: "SIGINT", listener: () => void): this; + once(event: "SIGTSTP", listener: () => void): this; + once(event: "exit", listener: () => void): this; + once(event: "reset", listener: (context: Context) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "line", listener: (input: string) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: "SIGCONT", listener: () => void): this; + prependListener(event: "SIGINT", listener: () => void): this; + prependListener(event: "SIGTSTP", listener: () => void): this; + prependListener(event: "exit", listener: () => void): this; + prependListener(event: "reset", listener: (context: Context) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "line", listener: (input: string) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: "SIGCONT", listener: () => void): this; + prependOnceListener(event: "SIGINT", listener: () => void): this; + prependOnceListener(event: "SIGTSTP", listener: () => void): this; + prependOnceListener(event: "exit", listener: () => void): this; + prependOnceListener(event: "reset", listener: (context: Context) => void): this; + } + /** + * A flag passed in the REPL options. Evaluates expressions in sloppy mode. + */ + const REPL_MODE_SLOPPY: unique symbol; + /** + * A flag passed in the REPL options. Evaluates expressions in strict mode. + * This is equivalent to prefacing every repl statement with `'use strict'`. + */ + const REPL_MODE_STRICT: unique symbol; + /** + * The `repl.start()` method creates and starts a {@link REPLServer} instance. + * + * If `options` is a string, then it specifies the input prompt: + * + * ```js + * const repl = require('node:repl'); + * + * // a Unix style prompt + * repl.start('$ '); + * ``` + * @since v0.1.91 + */ + function start(options?: string | ReplOptions): REPLServer; + /** + * Indicates a recoverable error that a `REPLServer` can use to support multi-line input. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_recoverable_errors + */ + class Recoverable extends SyntaxError { + err: Error; + constructor(err: Error); + } +} +declare module "node:repl" { + export * from "repl"; +} diff --git a/node_modules/@types/node/stream.d.ts b/node_modules/@types/node/stream.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..15c633fcf55f300809d5681a1c0aa9ba4728ea32 --- /dev/null +++ b/node_modules/@types/node/stream.d.ts @@ -0,0 +1,1701 @@ +/** + * A stream is an abstract interface for working with streaming data in Node.js. + * The `node:stream` module provides an API for implementing the stream interface. + * + * There are many stream objects provided by Node.js. For instance, a `request to an HTTP server` and `process.stdout` are both stream instances. + * + * Streams can be readable, writable, or both. All streams are instances of `EventEmitter`. + * + * To access the `node:stream` module: + * + * ```js + * const stream = require('node:stream'); + * ``` + * + * The `node:stream` module is useful for creating new types of stream instances. + * It is usually not necessary to use the `node:stream` module to consume streams. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/stream.js) + */ +declare module "stream" { + import { Abortable, EventEmitter } from "node:events"; + import { Blob as NodeBlob } from "node:buffer"; + import * as streamPromises from "node:stream/promises"; + import * as streamConsumers from "node:stream/consumers"; + import * as streamWeb from "node:stream/web"; + + type ComposeFnParam = (source: any) => void; + + class internal extends EventEmitter { + pipe( + destination: T, + options?: { + end?: boolean | undefined; + }, + ): T; + compose( + stream: T | ComposeFnParam | Iterable | AsyncIterable, + options?: { signal: AbortSignal }, + ): T; + } + import Stream = internal.Stream; + import Readable = internal.Readable; + import ReadableOptions = internal.ReadableOptions; + interface ArrayOptions { + /** the maximum concurrent invocations of `fn` to call on the stream at once. **Default: 1**. */ + concurrency?: number; + /** allows destroying the stream if the signal is aborted. */ + signal?: AbortSignal; + } + class ReadableBase extends Stream implements NodeJS.ReadableStream { + /** + * A utility method for creating Readable Streams out of iterators. + */ + static from(iterable: Iterable | AsyncIterable, options?: ReadableOptions): Readable; + /** + * Returns whether the stream has been read from or cancelled. + * @since v16.8.0 + */ + static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean; + /** + * Returns whether the stream was destroyed or errored before emitting `'end'`. + * @since v16.8.0 + * @experimental + */ + readonly readableAborted: boolean; + /** + * Is `true` if it is safe to call `readable.read()`, which means + * the stream has not been destroyed or emitted `'error'` or `'end'`. + * @since v11.4.0 + */ + readable: boolean; + /** + * Returns whether `'data'` has been emitted. + * @since v16.7.0, v14.18.0 + * @experimental + */ + readonly readableDidRead: boolean; + /** + * Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method. + * @since v12.7.0 + */ + readonly readableEncoding: BufferEncoding | null; + /** + * Becomes `true` when `'end'` event is emitted. + * @since v12.9.0 + */ + readonly readableEnded: boolean; + /** + * This property reflects the current state of a `Readable` stream as described + * in the `Three states` section. + * @since v9.4.0 + */ + readonly readableFlowing: boolean | null; + /** + * Returns the value of `highWaterMark` passed when creating this `Readable`. + * @since v9.3.0 + */ + readonly readableHighWaterMark: number; + /** + * This property contains the number of bytes (or objects) in the queue + * ready to be read. The value provides introspection data regarding + * the status of the `highWaterMark`. + * @since v9.4.0 + */ + readonly readableLength: number; + /** + * Getter for the property `objectMode` of a given `Readable` stream. + * @since v12.3.0 + */ + readonly readableObjectMode: boolean; + /** + * Is `true` after `readable.destroy()` has been called. + * @since v8.0.0 + */ + destroyed: boolean; + /** + * Is `true` after `'close'` has been emitted. + * @since v18.0.0 + */ + readonly closed: boolean; + /** + * Returns error if the stream has been destroyed with an error. + * @since v18.0.0 + */ + readonly errored: Error | null; + constructor(opts?: ReadableOptions); + _construct?(callback: (error?: Error | null) => void): void; + _read(size: number): void; + /** + * The `readable.read()` method reads data out of the internal buffer and + * returns it. If no data is available to be read, `null` is returned. By default, + * the data is returned as a `Buffer` object unless an encoding has been + * specified using the `readable.setEncoding()` method or the stream is operating + * in object mode. + * + * The optional `size` argument specifies a specific number of bytes to read. If`size` bytes are not available to be read, `null` will be returned _unless_the stream has ended, in which + * case all of the data remaining in the internal + * buffer will be returned. + * + * If the `size` argument is not specified, all of the data contained in the + * internal buffer will be returned. + * + * The `size` argument must be less than or equal to 1 GiB. + * + * The `readable.read()` method should only be called on `Readable` streams + * operating in paused mode. In flowing mode, `readable.read()` is called + * automatically until the internal buffer is fully drained. + * + * ```js + * const readable = getReadableStreamSomehow(); + * + * // 'readable' may be triggered multiple times as data is buffered in + * readable.on('readable', () => { + * let chunk; + * console.log('Stream is readable (new data received in buffer)'); + * // Use a loop to make sure we read all currently available data + * while (null !== (chunk = readable.read())) { + * console.log(`Read ${chunk.length} bytes of data...`); + * } + * }); + * + * // 'end' will be triggered once when there is no more data available + * readable.on('end', () => { + * console.log('Reached end of stream.'); + * }); + * ``` + * + * Each call to `readable.read()` returns a chunk of data, or `null`. The chunks + * are not concatenated. A `while` loop is necessary to consume all data + * currently in the buffer. When reading a large file `.read()` may return `null`, + * having consumed all buffered content so far, but there is still more data to + * come not yet buffered. In this case a new `'readable'` event will be emitted + * when there is more data in the buffer. Finally the `'end'` event will be + * emitted when there is no more data to come. + * + * Therefore to read a file's whole contents from a `readable`, it is necessary + * to collect chunks across multiple `'readable'` events: + * + * ```js + * const chunks = []; + * + * readable.on('readable', () => { + * let chunk; + * while (null !== (chunk = readable.read())) { + * chunks.push(chunk); + * } + * }); + * + * readable.on('end', () => { + * const content = chunks.join(''); + * }); + * ``` + * + * A `Readable` stream in object mode will always return a single item from + * a call to `readable.read(size)`, regardless of the value of the`size` argument. + * + * If the `readable.read()` method returns a chunk of data, a `'data'` event will + * also be emitted. + * + * Calling {@link read} after the `'end'` event has + * been emitted will return `null`. No runtime error will be raised. + * @since v0.9.4 + * @param size Optional argument to specify how much data to read. + */ + read(size?: number): any; + /** + * The `readable.setEncoding()` method sets the character encoding for + * data read from the `Readable` stream. + * + * By default, no encoding is assigned and stream data will be returned as`Buffer` objects. Setting an encoding causes the stream data + * to be returned as strings of the specified encoding rather than as `Buffer`objects. For instance, calling `readable.setEncoding('utf8')` will cause the + * output data to be interpreted as UTF-8 data, and passed as strings. Calling`readable.setEncoding('hex')` will cause the data to be encoded in hexadecimal + * string format. + * + * The `Readable` stream will properly handle multi-byte characters delivered + * through the stream that would otherwise become improperly decoded if simply + * pulled from the stream as `Buffer` objects. + * + * ```js + * const readable = getReadableStreamSomehow(); + * readable.setEncoding('utf8'); + * readable.on('data', (chunk) => { + * assert.equal(typeof chunk, 'string'); + * console.log('Got %d characters of string data:', chunk.length); + * }); + * ``` + * @since v0.9.4 + * @param encoding The encoding to use. + */ + setEncoding(encoding: BufferEncoding): this; + /** + * The `readable.pause()` method will cause a stream in flowing mode to stop + * emitting `'data'` events, switching out of flowing mode. Any data that + * becomes available will remain in the internal buffer. + * + * ```js + * const readable = getReadableStreamSomehow(); + * readable.on('data', (chunk) => { + * console.log(`Received ${chunk.length} bytes of data.`); + * readable.pause(); + * console.log('There will be no additional data for 1 second.'); + * setTimeout(() => { + * console.log('Now data will start flowing again.'); + * readable.resume(); + * }, 1000); + * }); + * ``` + * + * The `readable.pause()` method has no effect if there is a `'readable'`event listener. + * @since v0.9.4 + */ + pause(): this; + /** + * The `readable.resume()` method causes an explicitly paused `Readable` stream to + * resume emitting `'data'` events, switching the stream into flowing mode. + * + * The `readable.resume()` method can be used to fully consume the data from a + * stream without actually processing any of that data: + * + * ```js + * getReadableStreamSomehow() + * .resume() + * .on('end', () => { + * console.log('Reached the end, but did not read anything.'); + * }); + * ``` + * + * The `readable.resume()` method has no effect if there is a `'readable'`event listener. + * @since v0.9.4 + */ + resume(): this; + /** + * The `readable.isPaused()` method returns the current operating state of the`Readable`. This is used primarily by the mechanism that underlies the`readable.pipe()` method. In most + * typical cases, there will be no reason to + * use this method directly. + * + * ```js + * const readable = new stream.Readable(); + * + * readable.isPaused(); // === false + * readable.pause(); + * readable.isPaused(); // === true + * readable.resume(); + * readable.isPaused(); // === false + * ``` + * @since v0.11.14 + */ + isPaused(): boolean; + /** + * The `readable.unpipe()` method detaches a `Writable` stream previously attached + * using the {@link pipe} method. + * + * If the `destination` is not specified, then _all_ pipes are detached. + * + * If the `destination` is specified, but no pipe is set up for it, then + * the method does nothing. + * + * ```js + * const fs = require('node:fs'); + * const readable = getReadableStreamSomehow(); + * const writable = fs.createWriteStream('file.txt'); + * // All the data from readable goes into 'file.txt', + * // but only for the first second. + * readable.pipe(writable); + * setTimeout(() => { + * console.log('Stop writing to file.txt.'); + * readable.unpipe(writable); + * console.log('Manually close the file stream.'); + * writable.end(); + * }, 1000); + * ``` + * @since v0.9.4 + * @param destination Optional specific stream to unpipe + */ + unpipe(destination?: NodeJS.WritableStream): this; + /** + * Passing `chunk` as `null` signals the end of the stream (EOF) and behaves the + * same as `readable.push(null)`, after which no more data can be written. The EOF + * signal is put at the end of the buffer and any buffered data will still be + * flushed. + * + * The `readable.unshift()` method pushes a chunk of data back into the internal + * buffer. This is useful in certain situations where a stream is being consumed by + * code that needs to "un-consume" some amount of data that it has optimistically + * pulled out of the source, so that the data can be passed on to some other party. + * + * The `stream.unshift(chunk)` method cannot be called after the `'end'` event + * has been emitted or a runtime error will be thrown. + * + * Developers using `stream.unshift()` often should consider switching to + * use of a `Transform` stream instead. See the `API for stream implementers` section for more information. + * + * ```js + * // Pull off a header delimited by \n\n. + * // Use unshift() if we get too much. + * // Call the callback with (error, header, stream). + * const { StringDecoder } = require('node:string_decoder'); + * function parseHeader(stream, callback) { + * stream.on('error', callback); + * stream.on('readable', onReadable); + * const decoder = new StringDecoder('utf8'); + * let header = ''; + * function onReadable() { + * let chunk; + * while (null !== (chunk = stream.read())) { + * const str = decoder.write(chunk); + * if (str.includes('\n\n')) { + * // Found the header boundary. + * const split = str.split(/\n\n/); + * header += split.shift(); + * const remaining = split.join('\n\n'); + * const buf = Buffer.from(remaining, 'utf8'); + * stream.removeListener('error', callback); + * // Remove the 'readable' listener before unshifting. + * stream.removeListener('readable', onReadable); + * if (buf.length) + * stream.unshift(buf); + * // Now the body of the message can be read from the stream. + * callback(null, header, stream); + * return; + * } + * // Still reading the header. + * header += str; + * } + * } + * } + * ``` + * + * Unlike {@link push}, `stream.unshift(chunk)` will not + * end the reading process by resetting the internal reading state of the stream. + * This can cause unexpected results if `readable.unshift()` is called during a + * read (i.e. from within a {@link _read} implementation on a + * custom stream). Following the call to `readable.unshift()` with an immediate {@link push} will reset the reading state appropriately, + * however it is best to simply avoid calling `readable.unshift()` while in the + * process of performing a read. + * @since v0.9.11 + * @param chunk Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a string, `Buffer`, `Uint8Array`, or `null`. For object mode + * streams, `chunk` may be any JavaScript value. + * @param encoding Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`. + */ + unshift(chunk: any, encoding?: BufferEncoding): void; + /** + * Prior to Node.js 0.10, streams did not implement the entire `node:stream`module API as it is currently defined. (See `Compatibility` for more + * information.) + * + * When using an older Node.js library that emits `'data'` events and has a {@link pause} method that is advisory only, the`readable.wrap()` method can be used to create a `Readable` + * stream that uses + * the old stream as its data source. + * + * It will rarely be necessary to use `readable.wrap()` but the method has been + * provided as a convenience for interacting with older Node.js applications and + * libraries. + * + * ```js + * const { OldReader } = require('./old-api-module.js'); + * const { Readable } = require('node:stream'); + * const oreader = new OldReader(); + * const myReader = new Readable().wrap(oreader); + * + * myReader.on('readable', () => { + * myReader.read(); // etc. + * }); + * ``` + * @since v0.9.4 + * @param stream An "old style" readable stream + */ + wrap(stream: NodeJS.ReadableStream): this; + push(chunk: any, encoding?: BufferEncoding): boolean; + /** + * The iterator created by this method gives users the option to cancel the destruction + * of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`, + * or if the iterator should destroy the stream if the stream emitted an error during iteration. + * @since v16.3.0 + * @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator, + * or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream. + * **Default: `true`**. + */ + iterator(options?: { destroyOnReturn?: boolean }): AsyncIterableIterator; + /** + * This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream. + * If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream. + * @since v17.4.0, v16.14.0 + * @param fn a function to map over every chunk in the stream. Async or not. + * @returns a stream mapped with the function *fn*. + */ + map(fn: (data: any, options?: Pick) => any, options?: ArrayOptions): Readable; + /** + * This method allows filtering the stream. For each chunk in the stream the *fn* function will be called + * and if it returns a truthy value, the chunk will be passed to the result stream. + * If the *fn* function returns a promise - that promise will be `await`ed. + * @since v17.4.0, v16.14.0 + * @param fn a function to filter chunks from the stream. Async or not. + * @returns a stream filtered with the predicate *fn*. + */ + filter( + fn: (data: any, options?: Pick) => boolean | Promise, + options?: ArrayOptions, + ): Readable; + /** + * This method allows iterating a stream. For each chunk in the stream the *fn* function will be called. + * If the *fn* function returns a promise - that promise will be `await`ed. + * + * This method is different from `for await...of` loops in that it can optionally process chunks concurrently. + * In addition, a `forEach` iteration can only be stopped by having passed a `signal` option + * and aborting the related AbortController while `for await...of` can be stopped with `break` or `return`. + * In either case the stream will be destroyed. + * + * This method is different from listening to the `'data'` event in that it uses the `readable` event + * in the underlying machinary and can limit the number of concurrent *fn* calls. + * @since v17.5.0 + * @param fn a function to call on each chunk of the stream. Async or not. + * @returns a promise for when the stream has finished. + */ + forEach( + fn: (data: any, options?: Pick) => void | Promise, + options?: ArrayOptions, + ): Promise; + /** + * This method allows easily obtaining the contents of a stream. + * + * As this method reads the entire stream into memory, it negates the benefits of streams. It's intended + * for interoperability and convenience, not as the primary way to consume streams. + * @since v17.5.0 + * @returns a promise containing an array with the contents of the stream. + */ + toArray(options?: Pick): Promise; + /** + * This method is similar to `Array.prototype.some` and calls *fn* on each chunk in the stream + * until the awaited return value is `true` (or any truthy value). Once an *fn* call on a chunk + * `await`ed return value is truthy, the stream is destroyed and the promise is fulfilled with `true`. + * If none of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `false`. + * @since v17.5.0 + * @param fn a function to call on each chunk of the stream. Async or not. + * @returns a promise evaluating to `true` if *fn* returned a truthy value for at least one of the chunks. + */ + some( + fn: (data: any, options?: Pick) => boolean | Promise, + options?: ArrayOptions, + ): Promise; + /** + * This method is similar to `Array.prototype.find` and calls *fn* on each chunk in the stream + * to find a chunk with a truthy value for *fn*. Once an *fn* call's awaited return value is truthy, + * the stream is destroyed and the promise is fulfilled with value for which *fn* returned a truthy value. + * If all of the *fn* calls on the chunks return a falsy value, the promise is fulfilled with `undefined`. + * @since v17.5.0 + * @param fn a function to call on each chunk of the stream. Async or not. + * @returns a promise evaluating to the first chunk for which *fn* evaluated with a truthy value, + * or `undefined` if no element was found. + */ + find( + fn: (data: any, options?: Pick) => data is T, + options?: ArrayOptions, + ): Promise; + find( + fn: (data: any, options?: Pick) => boolean | Promise, + options?: ArrayOptions, + ): Promise; + /** + * This method is similar to `Array.prototype.every` and calls *fn* on each chunk in the stream + * to check if all awaited return values are truthy value for *fn*. Once an *fn* call on a chunk + * `await`ed return value is falsy, the stream is destroyed and the promise is fulfilled with `false`. + * If all of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `true`. + * @since v17.5.0 + * @param fn a function to call on each chunk of the stream. Async or not. + * @returns a promise evaluating to `true` if *fn* returned a truthy value for every one of the chunks. + */ + every( + fn: (data: any, options?: Pick) => boolean | Promise, + options?: ArrayOptions, + ): Promise; + /** + * This method returns a new stream by applying the given callback to each chunk of the stream + * and then flattening the result. + * + * It is possible to return a stream or another iterable or async iterable from *fn* and the result streams + * will be merged (flattened) into the returned stream. + * @since v17.5.0 + * @param fn a function to map over every chunk in the stream. May be async. May be a stream or generator. + * @returns a stream flat-mapped with the function *fn*. + */ + flatMap(fn: (data: any, options?: Pick) => any, options?: ArrayOptions): Readable; + /** + * This method returns a new stream with the first *limit* chunks dropped from the start. + * @since v17.5.0 + * @param limit the number of chunks to drop from the readable. + * @returns a stream with *limit* chunks dropped from the start. + */ + drop(limit: number, options?: Pick): Readable; + /** + * This method returns a new stream with the first *limit* chunks. + * @since v17.5.0 + * @param limit the number of chunks to take from the readable. + * @returns a stream with *limit* chunks taken. + */ + take(limit: number, options?: Pick): Readable; + /** + * This method returns a new stream with chunks of the underlying stream paired with a counter + * in the form `[index, chunk]`. The first index value is `0` and it increases by 1 for each chunk produced. + * @since v17.5.0 + * @returns a stream of indexed pairs. + */ + asIndexedPairs(options?: Pick): Readable; + /** + * This method calls *fn* on each chunk of the stream in order, passing it the result from the calculation + * on the previous element. It returns a promise for the final value of the reduction. + * + * If no *initial* value is supplied the first chunk of the stream is used as the initial value. + * If the stream is empty, the promise is rejected with a `TypeError` with the `ERR_INVALID_ARGS` code property. + * + * The reducer function iterates the stream element-by-element which means that there is no *concurrency* parameter + * or parallelism. To perform a reduce concurrently, you can extract the async function to `readable.map` method. + * @since v17.5.0 + * @param fn a reducer function to call over every chunk in the stream. Async or not. + * @param initial the initial value to use in the reduction. + * @returns a promise for the final value of the reduction. + */ + reduce( + fn: (previous: any, data: any, options?: Pick) => T, + initial?: undefined, + options?: Pick, + ): Promise; + reduce( + fn: (previous: T, data: any, options?: Pick) => T, + initial: T, + options?: Pick, + ): Promise; + _destroy(error: Error | null, callback: (error?: Error | null) => void): void; + /** + * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable + * stream will release any internal resources and subsequent calls to `push()`will be ignored. + * + * Once `destroy()` has been called any further calls will be a no-op and no + * further errors except from `_destroy()` may be emitted as `'error'`. + * + * Implementors should not override this method, but instead implement `readable._destroy()`. + * @since v8.0.0 + * @param error Error which will be passed as payload in `'error'` event + */ + destroy(error?: Error): this; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. data + * 3. end + * 4. error + * 5. pause + * 6. readable + * 7. resume + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: any) => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "data", chunk: any): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "pause"): boolean; + emit(event: "readable"): boolean; + emit(event: "resume"): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: any) => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "readable", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: any) => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "readable", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: any) => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: any) => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: "close", listener: () => void): this; + removeListener(event: "data", listener: (chunk: any) => void): this; + removeListener(event: "end", listener: () => void): this; + removeListener(event: "error", listener: (err: Error) => void): this; + removeListener(event: "pause", listener: () => void): this; + removeListener(event: "readable", listener: () => void): this; + removeListener(event: "resume", listener: () => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + [Symbol.asyncIterator](): AsyncIterableIterator; + /** + * Calls `readable.destroy()` with an `AbortError` and returns a promise that fulfills when the stream is finished. + * @since v20.4.0 + */ + [Symbol.asyncDispose](): Promise; + } + import WritableOptions = internal.WritableOptions; + class WritableBase extends Stream implements NodeJS.WritableStream { + /** + * Is `true` if it is safe to call `writable.write()`, which means + * the stream has not been destroyed, errored, or ended. + * @since v11.4.0 + */ + readonly writable: boolean; + /** + * Is `true` after `writable.end()` has been called. This property + * does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead. + * @since v12.9.0 + */ + readonly writableEnded: boolean; + /** + * Is set to `true` immediately before the `'finish'` event is emitted. + * @since v12.6.0 + */ + readonly writableFinished: boolean; + /** + * Return the value of `highWaterMark` passed when creating this `Writable`. + * @since v9.3.0 + */ + readonly writableHighWaterMark: number; + /** + * This property contains the number of bytes (or objects) in the queue + * ready to be written. The value provides introspection data regarding + * the status of the `highWaterMark`. + * @since v9.4.0 + */ + readonly writableLength: number; + /** + * Getter for the property `objectMode` of a given `Writable` stream. + * @since v12.3.0 + */ + readonly writableObjectMode: boolean; + /** + * Number of times `writable.uncork()` needs to be + * called in order to fully uncork the stream. + * @since v13.2.0, v12.16.0 + */ + readonly writableCorked: number; + /** + * Is `true` after `writable.destroy()` has been called. + * @since v8.0.0 + */ + destroyed: boolean; + /** + * Is `true` after `'close'` has been emitted. + * @since v18.0.0 + */ + readonly closed: boolean; + /** + * Returns error if the stream has been destroyed with an error. + * @since v18.0.0 + */ + readonly errored: Error | null; + /** + * Is `true` if the stream's buffer has been full and stream will emit `'drain'`. + * @since v15.2.0, v14.17.0 + */ + readonly writableNeedDrain: boolean; + constructor(opts?: WritableOptions); + _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; + _writev?( + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + _construct?(callback: (error?: Error | null) => void): void; + _destroy(error: Error | null, callback: (error?: Error | null) => void): void; + _final(callback: (error?: Error | null) => void): void; + /** + * The `writable.write()` method writes some data to the stream, and calls the + * supplied `callback` once the data has been fully handled. If an error + * occurs, the `callback` will be called with the error as its + * first argument. The `callback` is called asynchronously and before `'error'` is + * emitted. + * + * The return value is `true` if the internal buffer is less than the`highWaterMark` configured when the stream was created after admitting `chunk`. + * If `false` is returned, further attempts to write data to the stream should + * stop until the `'drain'` event is emitted. + * + * While a stream is not draining, calls to `write()` will buffer `chunk`, and + * return false. Once all currently buffered chunks are drained (accepted for + * delivery by the operating system), the `'drain'` event will be emitted. + * Once `write()` returns false, do not write more chunks + * until the `'drain'` event is emitted. While calling `write()` on a stream that + * is not draining is allowed, Node.js will buffer all written chunks until + * maximum memory usage occurs, at which point it will abort unconditionally. + * Even before it aborts, high memory usage will cause poor garbage collector + * performance and high RSS (which is not typically released back to the system, + * even after the memory is no longer required). Since TCP sockets may never + * drain if the remote peer does not read the data, writing a socket that is + * not draining may lead to a remotely exploitable vulnerability. + * + * Writing data while the stream is not draining is particularly + * problematic for a `Transform`, because the `Transform` streams are paused + * by default until they are piped or a `'data'` or `'readable'` event handler + * is added. + * + * If the data to be written can be generated or fetched on demand, it is + * recommended to encapsulate the logic into a `Readable` and use {@link pipe}. However, if calling `write()` is preferred, it is + * possible to respect backpressure and avoid memory issues using the `'drain'` event: + * + * ```js + * function write(data, cb) { + * if (!stream.write(data)) { + * stream.once('drain', cb); + * } else { + * process.nextTick(cb); + * } + * } + * + * // Wait for cb to be called before doing any other write. + * write('hello', () => { + * console.log('Write completed, do more writes now.'); + * }); + * ``` + * + * A `Writable` stream in object mode will always ignore the `encoding` argument. + * @since v0.9.4 + * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any + * JavaScript value other than `null`. + * @param [encoding='utf8'] The encoding, if `chunk` is a string. + * @param callback Callback for when this chunk of data is flushed. + * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean; + write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean; + /** + * The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream. + * @since v0.11.15 + * @param encoding The new default encoding + */ + setDefaultEncoding(encoding: BufferEncoding): this; + /** + * Calling the `writable.end()` method signals that no more data will be written + * to the `Writable`. The optional `chunk` and `encoding` arguments allow one + * final additional chunk of data to be written immediately before closing the + * stream. + * + * Calling the {@link write} method after calling {@link end} will raise an error. + * + * ```js + * // Write 'hello, ' and then end with 'world!'. + * const fs = require('node:fs'); + * const file = fs.createWriteStream('example.txt'); + * file.write('hello, '); + * file.end('world!'); + * // Writing more now is not allowed! + * ``` + * @since v0.9.4 + * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any + * JavaScript value other than `null`. + * @param encoding The encoding if `chunk` is a string + * @param callback Callback for when the stream is finished. + */ + end(cb?: () => void): this; + end(chunk: any, cb?: () => void): this; + end(chunk: any, encoding: BufferEncoding, cb?: () => void): this; + /** + * The `writable.cork()` method forces all written data to be buffered in memory. + * The buffered data will be flushed when either the {@link uncork} or {@link end} methods are called. + * + * The primary intent of `writable.cork()` is to accommodate a situation in which + * several small chunks are written to the stream in rapid succession. Instead of + * immediately forwarding them to the underlying destination, `writable.cork()`buffers all the chunks until `writable.uncork()` is called, which will pass them + * all to `writable._writev()`, if present. This prevents a head-of-line blocking + * situation where data is being buffered while waiting for the first small chunk + * to be processed. However, use of `writable.cork()` without implementing`writable._writev()` may have an adverse effect on throughput. + * + * See also: `writable.uncork()`, `writable._writev()`. + * @since v0.11.2 + */ + cork(): void; + /** + * The `writable.uncork()` method flushes all data buffered since {@link cork} was called. + * + * When using `writable.cork()` and `writable.uncork()` to manage the buffering + * of writes to a stream, defer calls to `writable.uncork()` using`process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event + * loop phase. + * + * ```js + * stream.cork(); + * stream.write('some '); + * stream.write('data '); + * process.nextTick(() => stream.uncork()); + * ``` + * + * If the `writable.cork()` method is called multiple times on a stream, the + * same number of calls to `writable.uncork()` must be called to flush the buffered + * data. + * + * ```js + * stream.cork(); + * stream.write('some '); + * stream.cork(); + * stream.write('data '); + * process.nextTick(() => { + * stream.uncork(); + * // The data will not be flushed until uncork() is called a second time. + * stream.uncork(); + * }); + * ``` + * + * See also: `writable.cork()`. + * @since v0.11.2 + */ + uncork(): void; + /** + * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the writable + * stream has ended and subsequent calls to `write()` or `end()` will result in + * an `ERR_STREAM_DESTROYED` error. + * This is a destructive and immediate way to destroy a stream. Previous calls to`write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error. + * Use `end()` instead of destroy if data should flush before close, or wait for + * the `'drain'` event before destroying the stream. + * + * Once `destroy()` has been called any further calls will be a no-op and no + * further errors except from `_destroy()` may be emitted as `'error'`. + * + * Implementors should not override this method, + * but instead implement `writable._destroy()`. + * @since v8.0.0 + * @param error Optional, an error to emit with `'error'` event. + */ + destroy(error?: Error): this; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. drain + * 3. error + * 4. finish + * 5. pipe + * 6. unpipe + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pipe", listener: (src: Readable) => void): this; + addListener(event: "unpipe", listener: (src: Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "drain"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "pipe", src: Readable): boolean; + emit(event: "unpipe", src: Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: Readable) => void): this; + on(event: "unpipe", listener: (src: Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: Readable) => void): this; + once(event: "unpipe", listener: (src: Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pipe", listener: (src: Readable) => void): this; + prependListener(event: "unpipe", listener: (src: Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: "close", listener: () => void): this; + removeListener(event: "drain", listener: () => void): this; + removeListener(event: "error", listener: (err: Error) => void): this; + removeListener(event: "finish", listener: () => void): this; + removeListener(event: "pipe", listener: (src: Readable) => void): this; + removeListener(event: "unpipe", listener: (src: Readable) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + namespace internal { + class Stream extends internal { + constructor(opts?: ReadableOptions); + } + interface StreamOptions extends Abortable { + emitClose?: boolean | undefined; + highWaterMark?: number | undefined; + objectMode?: boolean | undefined; + construct?(this: T, callback: (error?: Error | null) => void): void; + destroy?(this: T, error: Error | null, callback: (error: Error | null) => void): void; + autoDestroy?: boolean | undefined; + } + interface ReadableOptions extends StreamOptions { + encoding?: BufferEncoding | undefined; + read?(this: Readable, size: number): void; + } + /** + * @since v0.9.4 + */ + class Readable extends ReadableBase { + /** + * A utility method for creating a `Readable` from a web `ReadableStream`. + * @since v17.0.0 + * @experimental + */ + static fromWeb( + readableStream: streamWeb.ReadableStream, + options?: Pick, + ): Readable; + /** + * A utility method for creating a web `ReadableStream` from a `Readable`. + * @since v17.0.0 + * @experimental + */ + static toWeb(streamReadable: Readable): streamWeb.ReadableStream; + } + interface WritableOptions extends StreamOptions { + decodeStrings?: boolean | undefined; + defaultEncoding?: BufferEncoding | undefined; + write?( + this: Writable, + chunk: any, + encoding: BufferEncoding, + callback: (error?: Error | null) => void, + ): void; + writev?( + this: Writable, + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + final?(this: Writable, callback: (error?: Error | null) => void): void; + } + /** + * @since v0.9.4 + */ + class Writable extends WritableBase { + /** + * A utility method for creating a `Writable` from a web `WritableStream`. + * @since v17.0.0 + * @experimental + */ + static fromWeb( + writableStream: streamWeb.WritableStream, + options?: Pick, + ): Writable; + /** + * A utility method for creating a web `WritableStream` from a `Writable`. + * @since v17.0.0 + * @experimental + */ + static toWeb(streamWritable: Writable): streamWeb.WritableStream; + } + interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean | undefined; + readableObjectMode?: boolean | undefined; + writableObjectMode?: boolean | undefined; + readableHighWaterMark?: number | undefined; + writableHighWaterMark?: number | undefined; + writableCorked?: number | undefined; + construct?(this: Duplex, callback: (error?: Error | null) => void): void; + read?(this: Duplex, size: number): void; + write?(this: Duplex, chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; + writev?( + this: Duplex, + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + final?(this: Duplex, callback: (error?: Error | null) => void): void; + destroy?(this: Duplex, error: Error | null, callback: (error: Error | null) => void): void; + } + /** + * Duplex streams are streams that implement both the `Readable` and `Writable` interfaces. + * + * Examples of `Duplex` streams include: + * + * * `TCP sockets` + * * `zlib streams` + * * `crypto streams` + * @since v0.9.4 + */ + class Duplex extends ReadableBase implements WritableBase { + readonly writable: boolean; + readonly writableEnded: boolean; + readonly writableFinished: boolean; + readonly writableHighWaterMark: number; + readonly writableLength: number; + readonly writableObjectMode: boolean; + readonly writableCorked: number; + readonly writableNeedDrain: boolean; + readonly closed: boolean; + readonly errored: Error | null; + /** + * If `false` then the stream will automatically end the writable side when the + * readable side ends. Set initially by the `allowHalfOpen` constructor option, + * which defaults to `true`. + * + * This can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is + * emitted. + * @since v0.9.4 + */ + allowHalfOpen: boolean; + constructor(opts?: DuplexOptions); + /** + * A utility method for creating duplex streams. + * + * - `Stream` converts writable stream into writable `Duplex` and readable stream + * to `Duplex`. + * - `Blob` converts into readable `Duplex`. + * - `string` converts into readable `Duplex`. + * - `ArrayBuffer` converts into readable `Duplex`. + * - `AsyncIterable` converts into a readable `Duplex`. Cannot yield `null`. + * - `AsyncGeneratorFunction` converts into a readable/writable transform + * `Duplex`. Must take a source `AsyncIterable` as first parameter. Cannot yield + * `null`. + * - `AsyncFunction` converts into a writable `Duplex`. Must return + * either `null` or `undefined` + * - `Object ({ writable, readable })` converts `readable` and + * `writable` into `Stream` and then combines them into `Duplex` where the + * `Duplex` will write to the `writable` and read from the `readable`. + * - `Promise` converts into readable `Duplex`. Value `null` is ignored. + * + * @since v16.8.0 + */ + static from( + src: + | Stream + | NodeBlob + | ArrayBuffer + | string + | Iterable + | AsyncIterable + | AsyncGeneratorFunction + | Promise + | Object, + ): Duplex; + _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; + _writev?( + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + _destroy(error: Error | null, callback: (error: Error | null) => void): void; + _final(callback: (error?: Error | null) => void): void; + write(chunk: any, encoding?: BufferEncoding, cb?: (error: Error | null | undefined) => void): boolean; + write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean; + setDefaultEncoding(encoding: BufferEncoding): this; + end(cb?: () => void): this; + end(chunk: any, cb?: () => void): this; + end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this; + cork(): void; + uncork(): void; + /** + * A utility method for creating a web `ReadableStream` and `WritableStream` from a `Duplex`. + * @since v17.0.0 + * @experimental + */ + static toWeb(streamDuplex: Duplex): { + readable: streamWeb.ReadableStream; + writable: streamWeb.WritableStream; + }; + /** + * A utility method for creating a `Duplex` from a web `ReadableStream` and `WritableStream`. + * @since v17.0.0 + * @experimental + */ + static fromWeb( + duplexStream: { + readable: streamWeb.ReadableStream; + writable: streamWeb.WritableStream; + }, + options?: Pick< + DuplexOptions, + "allowHalfOpen" | "decodeStrings" | "encoding" | "highWaterMark" | "objectMode" | "signal" + >, + ): Duplex; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. data + * 3. drain + * 4. end + * 5. error + * 6. finish + * 7. pause + * 8. pipe + * 9. readable + * 10. resume + * 11. unpipe + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: any) => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "pipe", listener: (src: Readable) => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: "unpipe", listener: (src: Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "data", chunk: any): boolean; + emit(event: "drain"): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "pause"): boolean; + emit(event: "pipe", src: Readable): boolean; + emit(event: "readable"): boolean; + emit(event: "resume"): boolean; + emit(event: "unpipe", src: Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: any) => void): this; + on(event: "drain", listener: () => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pause", listener: () => void): this; + on(event: "pipe", listener: (src: Readable) => void): this; + on(event: "readable", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: "unpipe", listener: (src: Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: any) => void): this; + once(event: "drain", listener: () => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pause", listener: () => void): this; + once(event: "pipe", listener: (src: Readable) => void): this; + once(event: "readable", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: "unpipe", listener: (src: Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: any) => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "pipe", listener: (src: Readable) => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: "unpipe", listener: (src: Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: any) => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: "close", listener: () => void): this; + removeListener(event: "data", listener: (chunk: any) => void): this; + removeListener(event: "drain", listener: () => void): this; + removeListener(event: "end", listener: () => void): this; + removeListener(event: "error", listener: (err: Error) => void): this; + removeListener(event: "finish", listener: () => void): this; + removeListener(event: "pause", listener: () => void): this; + removeListener(event: "pipe", listener: (src: Readable) => void): this; + removeListener(event: "readable", listener: () => void): this; + removeListener(event: "resume", listener: () => void): this; + removeListener(event: "unpipe", listener: (src: Readable) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + type TransformCallback = (error?: Error | null, data?: any) => void; + interface TransformOptions extends DuplexOptions { + construct?(this: Transform, callback: (error?: Error | null) => void): void; + read?(this: Transform, size: number): void; + write?( + this: Transform, + chunk: any, + encoding: BufferEncoding, + callback: (error?: Error | null) => void, + ): void; + writev?( + this: Transform, + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + final?(this: Transform, callback: (error?: Error | null) => void): void; + destroy?(this: Transform, error: Error | null, callback: (error: Error | null) => void): void; + transform?(this: Transform, chunk: any, encoding: BufferEncoding, callback: TransformCallback): void; + flush?(this: Transform, callback: TransformCallback): void; + } + /** + * Transform streams are `Duplex` streams where the output is in some way + * related to the input. Like all `Duplex` streams, `Transform` streams + * implement both the `Readable` and `Writable` interfaces. + * + * Examples of `Transform` streams include: + * + * * `zlib streams` + * * `crypto streams` + * @since v0.9.4 + */ + class Transform extends Duplex { + constructor(opts?: TransformOptions); + _transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void; + _flush(callback: TransformCallback): void; + } + /** + * The `stream.PassThrough` class is a trivial implementation of a `Transform` stream that simply passes the input bytes across to the output. Its purpose is + * primarily for examples and testing, but there are some use cases where`stream.PassThrough` is useful as a building block for novel sorts of streams. + */ + class PassThrough extends Transform {} + /** + * A stream to attach a signal to. + * + * Attaches an AbortSignal to a readable or writeable stream. This lets code + * control stream destruction using an `AbortController`. + * + * Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream, and `controller.error(new + * AbortError())` for webstreams. + * + * ```js + * const fs = require('node:fs'); + * + * const controller = new AbortController(); + * const read = addAbortSignal( + * controller.signal, + * fs.createReadStream(('object.json')), + * ); + * // Later, abort the operation closing the stream + * controller.abort(); + * ``` + * + * Or using an `AbortSignal` with a readable stream as an async iterable: + * + * ```js + * const controller = new AbortController(); + * setTimeout(() => controller.abort(), 10_000); // set a timeout + * const stream = addAbortSignal( + * controller.signal, + * fs.createReadStream(('object.json')), + * ); + * (async () => { + * try { + * for await (const chunk of stream) { + * await process(chunk); + * } + * } catch (e) { + * if (e.name === 'AbortError') { + * // The operation was cancelled + * } else { + * throw e; + * } + * } + * })(); + * ``` + * + * Or using an `AbortSignal` with a ReadableStream: + * + * ```js + * const controller = new AbortController(); + * const rs = new ReadableStream({ + * start(controller) { + * controller.enqueue('hello'); + * controller.enqueue('world'); + * controller.close(); + * }, + * }); + * + * addAbortSignal(controller.signal, rs); + * + * finished(rs, (err) => { + * if (err) { + * if (err.name === 'AbortError') { + * // The operation was cancelled + * } + * } + * }); + * + * const reader = rs.getReader(); + * + * reader.read().then(({ value, done }) => { + * console.log(value); // hello + * console.log(done); // false + * controller.abort(); + * }); + * ``` + * @since v15.4.0 + * @param signal A signal representing possible cancellation + * @param stream a stream to attach a signal to + */ + function addAbortSignal(signal: AbortSignal, stream: T): T; + /** + * Returns the default highWaterMark used by streams. + * Defaults to `16384` (16 KiB), or `16` for `objectMode`. + * @since v19.9.0 + * @param objectMode + */ + function getDefaultHighWaterMark(objectMode: boolean): number; + /** + * Sets the default highWaterMark used by streams. + * @since v19.9.0 + * @param objectMode + * @param value highWaterMark value + */ + function setDefaultHighWaterMark(objectMode: boolean, value: number): void; + interface FinishedOptions extends Abortable { + error?: boolean | undefined; + readable?: boolean | undefined; + writable?: boolean | undefined; + } + /** + * A readable and/or writable stream/webstream. + * + * A function to get notified when a stream is no longer readable, writable + * or has experienced an error or a premature close event. + * + * ```js + * const { finished } = require('node:stream'); + * const fs = require('node:fs'); + * + * const rs = fs.createReadStream('archive.tar'); + * + * finished(rs, (err) => { + * if (err) { + * console.error('Stream failed.', err); + * } else { + * console.log('Stream is done reading.'); + * } + * }); + * + * rs.resume(); // Drain the stream. + * ``` + * + * Especially useful in error handling scenarios where a stream is destroyed + * prematurely (like an aborted HTTP request), and will not emit `'end'`or `'finish'`. + * + * The `finished` API provides `promise version`. + * + * `stream.finished()` leaves dangling event listeners (in particular`'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been + * invoked. The reason for this is so that unexpected `'error'` events (due to + * incorrect stream implementations) do not cause unexpected crashes. + * If this is unwanted behavior then the returned cleanup function needs to be + * invoked in the callback: + * + * ```js + * const cleanup = finished(rs, (err) => { + * cleanup(); + * // ... + * }); + * ``` + * @since v10.0.0 + * @param stream A readable and/or writable stream. + * @param callback A callback function that takes an optional error argument. + * @return A cleanup function which removes all registered listeners. + */ + function finished( + stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, + options: FinishedOptions, + callback: (err?: NodeJS.ErrnoException | null) => void, + ): () => void; + function finished( + stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, + callback: (err?: NodeJS.ErrnoException | null) => void, + ): () => void; + namespace finished { + function __promisify__( + stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, + options?: FinishedOptions, + ): Promise; + } + type PipelineSourceFunction = () => Iterable | AsyncIterable; + type PipelineSource = Iterable | AsyncIterable | NodeJS.ReadableStream | PipelineSourceFunction; + type PipelineTransform, U> = + | NodeJS.ReadWriteStream + | (( + source: S extends (...args: any[]) => Iterable | AsyncIterable ? AsyncIterable + : S, + ) => AsyncIterable); + type PipelineTransformSource = PipelineSource | PipelineTransform; + type PipelineDestinationIterableFunction = (source: AsyncIterable) => AsyncIterable; + type PipelineDestinationPromiseFunction = (source: AsyncIterable) => Promise

; + type PipelineDestination, P> = S extends + PipelineTransformSource ? + | NodeJS.WritableStream + | PipelineDestinationIterableFunction + | PipelineDestinationPromiseFunction + : never; + type PipelineCallback> = S extends + PipelineDestinationPromiseFunction ? (err: NodeJS.ErrnoException | null, value: P) => void + : (err: NodeJS.ErrnoException | null) => void; + type PipelinePromise> = S extends + PipelineDestinationPromiseFunction ? Promise

: Promise; + interface PipelineOptions { + signal?: AbortSignal | undefined; + end?: boolean | undefined; + } + /** + * A module method to pipe between streams and generators forwarding errors and + * properly cleaning up and provide a callback when the pipeline is complete. + * + * ```js + * const { pipeline } = require('node:stream'); + * const fs = require('node:fs'); + * const zlib = require('node:zlib'); + * + * // Use the pipeline API to easily pipe a series of streams + * // together and get notified when the pipeline is fully done. + * + * // A pipeline to gzip a potentially huge tar file efficiently: + * + * pipeline( + * fs.createReadStream('archive.tar'), + * zlib.createGzip(), + * fs.createWriteStream('archive.tar.gz'), + * (err) => { + * if (err) { + * console.error('Pipeline failed.', err); + * } else { + * console.log('Pipeline succeeded.'); + * } + * }, + * ); + * ``` + * + * The `pipeline` API provides a `promise version`. + * + * `stream.pipeline()` will call `stream.destroy(err)` on all streams except: + * + * * `Readable` streams which have emitted `'end'` or `'close'`. + * * `Writable` streams which have emitted `'finish'` or `'close'`. + * + * `stream.pipeline()` leaves dangling event listeners on the streams + * after the `callback` has been invoked. In the case of reuse of streams after + * failure, this can cause event listener leaks and swallowed errors. If the last + * stream is readable, dangling event listeners will be removed so that the last + * stream can be consumed later. + * + * `stream.pipeline()` closes all the streams when an error is raised. + * The `IncomingRequest` usage with `pipeline` could lead to an unexpected behavior + * once it would destroy the socket without sending the expected response. + * See the example below: + * + * ```js + * const fs = require('node:fs'); + * const http = require('node:http'); + * const { pipeline } = require('node:stream'); + * + * const server = http.createServer((req, res) => { + * const fileStream = fs.createReadStream('./fileNotExist.txt'); + * pipeline(fileStream, res, (err) => { + * if (err) { + * console.log(err); // No such file + * // this message can't be sent once `pipeline` already destroyed the socket + * return res.end('error!!!'); + * } + * }); + * }); + * ``` + * @since v10.0.0 + * @param callback Called when the pipeline is fully done. + */ + function pipeline, B extends PipelineDestination>( + source: A, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + T4 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + transform4: T4, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline( + streams: ReadonlyArray, + callback?: (err: NodeJS.ErrnoException | null) => void, + ): NodeJS.WritableStream; + function pipeline( + stream1: NodeJS.ReadableStream, + stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, + ...streams: Array< + NodeJS.ReadWriteStream | NodeJS.WritableStream | ((err: NodeJS.ErrnoException | null) => void) + > + ): NodeJS.WritableStream; + namespace pipeline { + function __promisify__, B extends PipelineDestination>( + source: A, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__< + A extends PipelineSource, + T1 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + T4 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + transform4: T4, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__( + streams: ReadonlyArray, + options?: PipelineOptions, + ): Promise; + function __promisify__( + stream1: NodeJS.ReadableStream, + stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, + ...streams: Array + ): Promise; + } + interface Pipe { + close(): void; + hasRef(): boolean; + ref(): void; + unref(): void; + } + /** + * Returns whether the stream has encountered an error. + * @since v17.3.0, v16.14.0 + * @experimental + */ + function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean; + /** + * Returns whether the stream is readable. + * @since v17.4.0, v16.14.0 + * @experimental + */ + function isReadable(stream: Readable | NodeJS.ReadableStream): boolean; + const promises: typeof streamPromises; + const consumers: typeof streamConsumers; + } + export = internal; +} +declare module "node:stream" { + import stream = require("stream"); + export = stream; +} diff --git a/node_modules/@types/node/stream/consumers.d.ts b/node_modules/@types/node/stream/consumers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ad9cbab98829fd66db9effa031b885647ba251c --- /dev/null +++ b/node_modules/@types/node/stream/consumers.d.ts @@ -0,0 +1,12 @@ +declare module "stream/consumers" { + import { Blob as NodeBlob } from "node:buffer"; + import { Readable } from "node:stream"; + function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; + function text(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; + function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; + function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; + function json(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; +} +declare module "node:stream/consumers" { + export * from "stream/consumers"; +} diff --git a/node_modules/@types/node/stream/promises.d.ts b/node_modules/@types/node/stream/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6eac5b7156a6b0cecea5c24cd8037a0a75af42eb --- /dev/null +++ b/node_modules/@types/node/stream/promises.d.ts @@ -0,0 +1,83 @@ +declare module "stream/promises" { + import { + FinishedOptions, + PipelineDestination, + PipelineOptions, + PipelinePromise, + PipelineSource, + PipelineTransform, + } from "node:stream"; + function finished( + stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, + options?: FinishedOptions, + ): Promise; + function pipeline, B extends PipelineDestination>( + source: A, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + T4 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + transform4: T4, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline( + streams: ReadonlyArray, + options?: PipelineOptions, + ): Promise; + function pipeline( + stream1: NodeJS.ReadableStream, + stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, + ...streams: Array + ): Promise; +} +declare module "node:stream/promises" { + export * from "stream/promises"; +} diff --git a/node_modules/@types/node/stream/web.d.ts b/node_modules/@types/node/stream/web.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d9161375e1fbcf245594bb4c0b061779a9de916 --- /dev/null +++ b/node_modules/@types/node/stream/web.d.ts @@ -0,0 +1,350 @@ +declare module "stream/web" { + // stub module, pending copy&paste from .d.ts or manual impl + // copy from lib.dom.d.ts + interface ReadableWritablePair { + readable: ReadableStream; + /** + * Provides a convenient, chainable way of piping this readable stream + * through a transform stream (or any other { writable, readable } + * pair). It simply pipes the stream into the writable side of the + * supplied pair, and returns the readable side for further use. + * + * Piping a stream will lock it for the duration of the pipe, preventing + * any other consumer from acquiring a reader. + */ + writable: WritableStream; + } + interface StreamPipeOptions { + preventAbort?: boolean; + preventCancel?: boolean; + /** + * Pipes this readable stream to a given writable stream destination. + * The way in which the piping process behaves under various error + * conditions can be customized with a number of passed options. It + * returns a promise that fulfills when the piping process completes + * successfully, or rejects if any errors were encountered. + * + * Piping a stream will lock it for the duration of the pipe, preventing + * any other consumer from acquiring a reader. + * + * Errors and closures of the source and destination streams propagate + * as follows: + * + * An error in this source readable stream will abort destination, + * unless preventAbort is truthy. The returned promise will be rejected + * with the source's error, or with any error that occurs during + * aborting the destination. + * + * An error in destination will cancel this source readable stream, + * unless preventCancel is truthy. The returned promise will be rejected + * with the destination's error, or with any error that occurs during + * canceling the source. + * + * When this source readable stream closes, destination will be closed, + * unless preventClose is truthy. The returned promise will be fulfilled + * once this process completes, unless an error is encountered while + * closing the destination, in which case it will be rejected with that + * error. + * + * If destination starts out closed or closing, this source readable + * stream will be canceled, unless preventCancel is true. The returned + * promise will be rejected with an error indicating piping to a closed + * stream failed, or with any error that occurs during canceling the + * source. + * + * The signal option can be set to an AbortSignal to allow aborting an + * ongoing pipe operation via the corresponding AbortController. In this + * case, this source readable stream will be canceled, and destination + * aborted, unless the respective options preventCancel or preventAbort + * are set. + */ + preventClose?: boolean; + signal?: AbortSignal; + } + interface ReadableStreamGenericReader { + readonly closed: Promise; + cancel(reason?: any): Promise; + } + interface ReadableStreamDefaultReadValueResult { + done: false; + value: T; + } + interface ReadableStreamDefaultReadDoneResult { + done: true; + value?: undefined; + } + type ReadableStreamController = ReadableStreamDefaultController; + type ReadableStreamDefaultReadResult = + | ReadableStreamDefaultReadValueResult + | ReadableStreamDefaultReadDoneResult; + interface ReadableStreamReadValueResult { + done: false; + value: T; + } + interface ReadableStreamReadDoneResult { + done: true; + value?: T; + } + type ReadableStreamReadResult = ReadableStreamReadValueResult | ReadableStreamReadDoneResult; + interface ReadableByteStreamControllerCallback { + (controller: ReadableByteStreamController): void | PromiseLike; + } + interface UnderlyingSinkAbortCallback { + (reason?: any): void | PromiseLike; + } + interface UnderlyingSinkCloseCallback { + (): void | PromiseLike; + } + interface UnderlyingSinkStartCallback { + (controller: WritableStreamDefaultController): any; + } + interface UnderlyingSinkWriteCallback { + (chunk: W, controller: WritableStreamDefaultController): void | PromiseLike; + } + interface UnderlyingSourceCancelCallback { + (reason?: any): void | PromiseLike; + } + interface UnderlyingSourcePullCallback { + (controller: ReadableStreamController): void | PromiseLike; + } + interface UnderlyingSourceStartCallback { + (controller: ReadableStreamController): any; + } + interface TransformerFlushCallback { + (controller: TransformStreamDefaultController): void | PromiseLike; + } + interface TransformerStartCallback { + (controller: TransformStreamDefaultController): any; + } + interface TransformerTransformCallback { + (chunk: I, controller: TransformStreamDefaultController): void | PromiseLike; + } + interface UnderlyingByteSource { + autoAllocateChunkSize?: number; + cancel?: ReadableStreamErrorCallback; + pull?: ReadableByteStreamControllerCallback; + start?: ReadableByteStreamControllerCallback; + type: "bytes"; + } + interface UnderlyingSource { + cancel?: UnderlyingSourceCancelCallback; + pull?: UnderlyingSourcePullCallback; + start?: UnderlyingSourceStartCallback; + type?: undefined; + } + interface UnderlyingSink { + abort?: UnderlyingSinkAbortCallback; + close?: UnderlyingSinkCloseCallback; + start?: UnderlyingSinkStartCallback; + type?: undefined; + write?: UnderlyingSinkWriteCallback; + } + interface ReadableStreamErrorCallback { + (reason: any): void | PromiseLike; + } + /** This Streams API interface represents a readable stream of byte data. */ + interface ReadableStream { + readonly locked: boolean; + cancel(reason?: any): Promise; + getReader(): ReadableStreamDefaultReader; + getReader(options: { mode: "byob" }): ReadableStreamBYOBReader; + pipeThrough(transform: ReadableWritablePair, options?: StreamPipeOptions): ReadableStream; + pipeTo(destination: WritableStream, options?: StreamPipeOptions): Promise; + tee(): [ReadableStream, ReadableStream]; + values(options?: { preventCancel?: boolean }): AsyncIterableIterator; + [Symbol.asyncIterator](): AsyncIterableIterator; + } + const ReadableStream: { + prototype: ReadableStream; + new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy): ReadableStream; + new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; + }; + interface ReadableStreamDefaultReader extends ReadableStreamGenericReader { + read(): Promise>; + releaseLock(): void; + } + interface ReadableStreamBYOBReader extends ReadableStreamGenericReader { + read(view: T): Promise>; + releaseLock(): void; + } + const ReadableStreamDefaultReader: { + prototype: ReadableStreamDefaultReader; + new(stream: ReadableStream): ReadableStreamDefaultReader; + }; + const ReadableStreamBYOBReader: any; + const ReadableStreamBYOBRequest: any; + interface ReadableByteStreamController { + readonly byobRequest: undefined; + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: ArrayBufferView): void; + error(error?: any): void; + } + const ReadableByteStreamController: { + prototype: ReadableByteStreamController; + new(): ReadableByteStreamController; + }; + interface ReadableStreamDefaultController { + readonly desiredSize: number | null; + close(): void; + enqueue(chunk?: R): void; + error(e?: any): void; + } + const ReadableStreamDefaultController: { + prototype: ReadableStreamDefaultController; + new(): ReadableStreamDefaultController; + }; + interface Transformer { + flush?: TransformerFlushCallback; + readableType?: undefined; + start?: TransformerStartCallback; + transform?: TransformerTransformCallback; + writableType?: undefined; + } + interface TransformStream { + readonly readable: ReadableStream; + readonly writable: WritableStream; + } + const TransformStream: { + prototype: TransformStream; + new( + transformer?: Transformer, + writableStrategy?: QueuingStrategy, + readableStrategy?: QueuingStrategy, + ): TransformStream; + }; + interface TransformStreamDefaultController { + readonly desiredSize: number | null; + enqueue(chunk?: O): void; + error(reason?: any): void; + terminate(): void; + } + const TransformStreamDefaultController: { + prototype: TransformStreamDefaultController; + new(): TransformStreamDefaultController; + }; + /** + * This Streams API interface provides a standard abstraction for writing + * streaming data to a destination, known as a sink. This object comes with + * built-in back pressure and queuing. + */ + interface WritableStream { + readonly locked: boolean; + abort(reason?: any): Promise; + close(): Promise; + getWriter(): WritableStreamDefaultWriter; + } + const WritableStream: { + prototype: WritableStream; + new(underlyingSink?: UnderlyingSink, strategy?: QueuingStrategy): WritableStream; + }; + /** + * This Streams API interface is the object returned by + * WritableStream.getWriter() and once created locks the < writer to the + * WritableStream ensuring that no other streams can write to the underlying + * sink. + */ + interface WritableStreamDefaultWriter { + readonly closed: Promise; + readonly desiredSize: number | null; + readonly ready: Promise; + abort(reason?: any): Promise; + close(): Promise; + releaseLock(): void; + write(chunk?: W): Promise; + } + const WritableStreamDefaultWriter: { + prototype: WritableStreamDefaultWriter; + new(stream: WritableStream): WritableStreamDefaultWriter; + }; + /** + * This Streams API interface represents a controller allowing control of a + * WritableStream's state. When constructing a WritableStream, the + * underlying sink is given a corresponding WritableStreamDefaultController + * instance to manipulate. + */ + interface WritableStreamDefaultController { + error(e?: any): void; + } + const WritableStreamDefaultController: { + prototype: WritableStreamDefaultController; + new(): WritableStreamDefaultController; + }; + interface QueuingStrategy { + highWaterMark?: number; + size?: QueuingStrategySize; + } + interface QueuingStrategySize { + (chunk?: T): number; + } + interface QueuingStrategyInit { + /** + * Creates a new ByteLengthQueuingStrategy with the provided high water + * mark. + * + * Note that the provided high water mark will not be validated ahead of + * time. Instead, if it is negative, NaN, or not a number, the resulting + * ByteLengthQueuingStrategy will cause the corresponding stream + * constructor to throw. + */ + highWaterMark: number; + } + /** + * This Streams API interface provides a built-in byte length queuing + * strategy that can be used when constructing streams. + */ + interface ByteLengthQueuingStrategy extends QueuingStrategy { + readonly highWaterMark: number; + readonly size: QueuingStrategySize; + } + const ByteLengthQueuingStrategy: { + prototype: ByteLengthQueuingStrategy; + new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; + }; + /** + * This Streams API interface provides a built-in byte length queuing + * strategy that can be used when constructing streams. + */ + interface CountQueuingStrategy extends QueuingStrategy { + readonly highWaterMark: number; + readonly size: QueuingStrategySize; + } + const CountQueuingStrategy: { + prototype: CountQueuingStrategy; + new(init: QueuingStrategyInit): CountQueuingStrategy; + }; + interface TextEncoderStream { + /** Returns "utf-8". */ + readonly encoding: "utf-8"; + readonly readable: ReadableStream; + readonly writable: WritableStream; + readonly [Symbol.toStringTag]: string; + } + const TextEncoderStream: { + prototype: TextEncoderStream; + new(): TextEncoderStream; + }; + interface TextDecoderOptions { + fatal?: boolean; + ignoreBOM?: boolean; + } + type BufferSource = ArrayBufferView | ArrayBuffer; + interface TextDecoderStream { + /** Returns encoding's name, lower cased. */ + readonly encoding: string; + /** Returns `true` if error mode is "fatal", and `false` otherwise. */ + readonly fatal: boolean; + /** Returns `true` if ignore BOM flag is set, and `false` otherwise. */ + readonly ignoreBOM: boolean; + readonly readable: ReadableStream; + readonly writable: WritableStream; + readonly [Symbol.toStringTag]: string; + } + const TextDecoderStream: { + prototype: TextDecoderStream; + new(label?: string, options?: TextDecoderOptions): TextDecoderStream; + }; +} +declare module "node:stream/web" { + export * from "stream/web"; +} diff --git a/node_modules/@types/node/string_decoder.d.ts b/node_modules/@types/node/string_decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b8691e1f060076e08ed0f023889adef0f2e8fb4e --- /dev/null +++ b/node_modules/@types/node/string_decoder.d.ts @@ -0,0 +1,67 @@ +/** + * The `node:string_decoder` module provides an API for decoding `Buffer` objects + * into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 + * characters. It can be accessed using: + * + * ```js + * const { StringDecoder } = require('node:string_decoder'); + * ``` + * + * The following example shows the basic use of the `StringDecoder` class. + * + * ```js + * const { StringDecoder } = require('node:string_decoder'); + * const decoder = new StringDecoder('utf8'); + * + * const cent = Buffer.from([0xC2, 0xA2]); + * console.log(decoder.write(cent)); // Prints: ¢ + * + * const euro = Buffer.from([0xE2, 0x82, 0xAC]); + * console.log(decoder.write(euro)); // Prints: € + * ``` + * + * When a `Buffer` instance is written to the `StringDecoder` instance, an + * internal buffer is used to ensure that the decoded string does not contain + * any incomplete multibyte characters. These are held in the buffer until the + * next call to `stringDecoder.write()` or until `stringDecoder.end()` is called. + * + * In the following example, the three UTF-8 encoded bytes of the European Euro + * symbol (`€`) are written over three separate operations: + * + * ```js + * const { StringDecoder } = require('node:string_decoder'); + * const decoder = new StringDecoder('utf8'); + * + * decoder.write(Buffer.from([0xE2])); + * decoder.write(Buffer.from([0x82])); + * console.log(decoder.end(Buffer.from([0xAC]))); // Prints: € + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js) + */ +declare module "string_decoder" { + class StringDecoder { + constructor(encoding?: BufferEncoding); + /** + * Returns a decoded string, ensuring that any incomplete multibyte characters at + * the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the + * returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`. + * @since v0.1.99 + * @param buffer The bytes to decode. + */ + write(buffer: Buffer): string; + /** + * Returns any remaining input stored in the internal buffer as a string. Bytes + * representing incomplete UTF-8 and UTF-16 characters will be replaced with + * substitution characters appropriate for the character encoding. + * + * If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input. + * After `end()` is called, the `stringDecoder` object can be reused for new input. + * @since v0.9.3 + * @param buffer The bytes to decode. + */ + end(buffer?: Buffer): string; + } +} +declare module "node:string_decoder" { + export * from "string_decoder"; +} diff --git a/node_modules/@types/node/test.d.ts b/node_modules/@types/node/test.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..44b6a96408bf8ffbb6f4072309fd1cfa7030ade5 --- /dev/null +++ b/node_modules/@types/node/test.d.ts @@ -0,0 +1,1382 @@ +/** + * The `node:test` module facilitates the creation of JavaScript tests. + * To access it: + * + * ```js + * import test from 'node:test'; + * ``` + * + * This module is only available under the `node:` scheme. The following will not + * work: + * + * ```js + * import test from 'test'; + * ``` + * + * Tests created via the `test` module consist of a single function that is + * processed in one of three ways: + * + * 1. A synchronous function that is considered failing if it throws an exception, + * and is considered passing otherwise. + * 2. A function that returns a `Promise` that is considered failing if the`Promise` rejects, and is considered passing if the `Promise` fulfills. + * 3. A function that receives a callback function. If the callback receives any + * truthy value as its first argument, the test is considered failing. If a + * falsy value is passed as the first argument to the callback, the test is + * considered passing. If the test function receives a callback function and + * also returns a `Promise`, the test will fail. + * + * The following example illustrates how tests are written using the`test` module. + * + * ```js + * test('synchronous passing test', (t) => { + * // This test passes because it does not throw an exception. + * assert.strictEqual(1, 1); + * }); + * + * test('synchronous failing test', (t) => { + * // This test fails because it throws an exception. + * assert.strictEqual(1, 2); + * }); + * + * test('asynchronous passing test', async (t) => { + * // This test passes because the Promise returned by the async + * // function is settled and not rejected. + * assert.strictEqual(1, 1); + * }); + * + * test('asynchronous failing test', async (t) => { + * // This test fails because the Promise returned by the async + * // function is rejected. + * assert.strictEqual(1, 2); + * }); + * + * test('failing test using Promises', (t) => { + * // Promises can be used directly as well. + * return new Promise((resolve, reject) => { + * setImmediate(() => { + * reject(new Error('this will cause the test to fail')); + * }); + * }); + * }); + * + * test('callback passing test', (t, done) => { + * // done() is the callback function. When the setImmediate() runs, it invokes + * // done() with no arguments. + * setImmediate(done); + * }); + * + * test('callback failing test', (t, done) => { + * // When the setImmediate() runs, done() is invoked with an Error object and + * // the test fails. + * setImmediate(() => { + * done(new Error('callback failure')); + * }); + * }); + * ``` + * + * If any tests fail, the process exit code is set to `1`. + * @since v18.0.0, v16.17.0 + * @see [source](https://github.com/nodejs/node/blob/v20.4.0/lib/test.js) + */ +declare module "node:test" { + import { Readable } from "node:stream"; + import { AsyncResource } from "node:async_hooks"; + /** + * ```js + * import { tap } from 'node:test/reporters'; + * import { run } from 'node:test'; + * import process from 'node:process'; + * import path from 'node:path'; + * + * run({ files: [path.resolve('./tests/test.js')] }) + * .compose(tap) + * .pipe(process.stdout); + * ``` + * @since v18.9.0, v16.19.0 + * @param options Configuration options for running tests. The following properties are supported: + */ + function run(options?: RunOptions): TestsStream; + /** + * The `test()` function is the value imported from the `test` module. Each + * invocation of this function results in reporting the test to the `TestsStream`. + * + * The `TestContext` object passed to the `fn` argument can be used to perform + * actions related to the current test. Examples include skipping the test, adding + * additional diagnostic information, or creating subtests. + * + * `test()` returns a `Promise` that fulfills once the test completes. + * if `test()` is called within a `describe()` block, it fulfills immediately. + * The return value can usually be discarded for top level tests. + * However, the return value from subtests should be used to prevent the parent + * test from finishing first and cancelling the subtest + * as shown in the following example. + * + * ```js + * test('top level test', async (t) => { + * // The setTimeout() in the following subtest would cause it to outlive its + * // parent test if 'await' is removed on the next line. Once the parent test + * // completes, it will cancel any outstanding subtests. + * await t.test('longer running subtest', async (t) => { + * return new Promise((resolve, reject) => { + * setTimeout(resolve, 1000); + * }); + * }); + * }); + * ``` + * + * The `timeout` option can be used to fail the test if it takes longer than`timeout` milliseconds to complete. However, it is not a reliable mechanism for + * canceling tests because a running test might block the application thread and + * thus prevent the scheduled cancellation. + * @since v18.0.0, v16.17.0 + * @param [name='The name'] The name of the test, which is displayed when reporting test results. + * @param options Configuration options for the test. The following properties are supported: + * @param [fn='A no-op function'] The function under test. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the callback function is passed as the + * second argument. + * @return Fulfilled with `undefined` once the test completes, or immediately if the test runs within {@link describe}. + */ + function test(name?: string, fn?: TestFn): Promise; + function test(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function test(options?: TestOptions, fn?: TestFn): Promise; + function test(fn?: TestFn): Promise; + namespace test { + export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, test, todo }; + } + /** + * The `describe()` function imported from the `node:test` module. Each + * invocation of this function results in the creation of a Subtest. + * After invocation of top level `describe` functions, + * all top level tests and suites will execute. + * @param [name='The name'] The name of the suite, which is displayed when reporting test results. + * @param options Configuration options for the suite. supports the same options as `test([name][, options][, fn])`. + * @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object. + * @return Immediately fulfilled with `undefined`. + */ + function describe(name?: string, options?: TestOptions, fn?: SuiteFn): Promise; + function describe(name?: string, fn?: SuiteFn): Promise; + function describe(options?: TestOptions, fn?: SuiteFn): Promise; + function describe(fn?: SuiteFn): Promise; + namespace describe { + /** + * Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`. + */ + function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise; + function skip(name?: string, fn?: SuiteFn): Promise; + function skip(options?: TestOptions, fn?: SuiteFn): Promise; + function skip(fn?: SuiteFn): Promise; + /** + * Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`. + */ + function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise; + function todo(name?: string, fn?: SuiteFn): Promise; + function todo(options?: TestOptions, fn?: SuiteFn): Promise; + function todo(fn?: SuiteFn): Promise; + /** + * Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`. + * @since v18.15.0 + */ + function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise; + function only(name?: string, fn?: SuiteFn): Promise; + function only(options?: TestOptions, fn?: SuiteFn): Promise; + function only(fn?: SuiteFn): Promise; + } + /** + * Shorthand for `test()`. + * + * The `it()` function is imported from the `node:test` module. + * @since v18.6.0, v16.17.0 + */ + function it(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function it(name?: string, fn?: TestFn): Promise; + function it(options?: TestOptions, fn?: TestFn): Promise; + function it(fn?: TestFn): Promise; + namespace it { + /** + * Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`. + */ + function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function skip(name?: string, fn?: TestFn): Promise; + function skip(options?: TestOptions, fn?: TestFn): Promise; + function skip(fn?: TestFn): Promise; + /** + * Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`. + */ + function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function todo(name?: string, fn?: TestFn): Promise; + function todo(options?: TestOptions, fn?: TestFn): Promise; + function todo(fn?: TestFn): Promise; + /** + * Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`. + * @since v18.15.0 + */ + function only(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function only(name?: string, fn?: TestFn): Promise; + function only(options?: TestOptions, fn?: TestFn): Promise; + function only(fn?: TestFn): Promise; + } + /** + * Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`. + * @since v20.2.0 + */ + function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function skip(name?: string, fn?: TestFn): Promise; + function skip(options?: TestOptions, fn?: TestFn): Promise; + function skip(fn?: TestFn): Promise; + /** + * Shorthand for marking a test as `TODO`, same as `test([name], { todo: true }[, fn])`. + * @since v20.2.0 + */ + function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function todo(name?: string, fn?: TestFn): Promise; + function todo(options?: TestOptions, fn?: TestFn): Promise; + function todo(fn?: TestFn): Promise; + /** + * Shorthand for marking a test as `only`, same as `test([name], { only: true }[, fn])`. + * @since v20.2.0 + */ + function only(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function only(name?: string, fn?: TestFn): Promise; + function only(options?: TestOptions, fn?: TestFn): Promise; + function only(fn?: TestFn): Promise; + /** + * The type of a function under test. The first argument to this function is a + * {@link TestContext} object. If the test uses callbacks, the callback function is passed as + * the second argument. + */ + type TestFn = (t: TestContext, done: (result?: any) => void) => void | Promise; + /** + * The type of a function under Suite. + */ + type SuiteFn = (s: SuiteContext) => void | Promise; + interface TestShard { + /** + * A positive integer between 1 and `` that specifies the index of the shard to run. + */ + index: number; + /** + * A positive integer that specifies the total number of shards to split the test files to. + */ + total: number; + } + interface RunOptions { + /** + * If a number is provided, then that many files would run in parallel. + * If truthy, it would run (number of cpu cores - 1) files in parallel. + * If falsy, it would only run one file at a time. + * If unspecified, subtests inherit this value from their parent. + * @default true + */ + concurrency?: number | boolean | undefined; + /** + * An array containing the list of files to run. + * If unspecified, the test runner execution model will be used. + */ + files?: readonly string[] | undefined; + /** + * Allows aborting an in-progress test execution. + * @default undefined + */ + signal?: AbortSignal | undefined; + /** + * A number of milliseconds the test will fail after. + * If unspecified, subtests inherit this value from their parent. + * @default Infinity + */ + timeout?: number | undefined; + /** + * Sets inspector port of test child process. + * If a nullish value is provided, each process gets its own port, + * incremented from the primary's `process.debugPort`. + */ + inspectPort?: number | (() => number) | undefined; + /** + * That can be used to only run tests whose name matches the provided pattern. + * Test name patterns are interpreted as JavaScript regular expressions. + * For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run. + */ + testNamePatterns?: string | RegExp | string[] | RegExp[]; + /** + * If truthy, the test context will only run tests that have the `only` option set + */ + only?: boolean; + /** + * A function that accepts the TestsStream instance and can be used to setup listeners before any tests are run. + */ + setup?: (root: Test) => void | Promise; + /** + * Whether to run in watch mode or not. + * @default false + */ + watch?: boolean | undefined; + /** + * Running tests in a specific shard. + * @default undefined + */ + shard?: TestShard | undefined; + } + class Test extends AsyncResource { + concurrency: number; + nesting: number; + only: boolean; + reporter: TestsStream; + runOnlySubtests: boolean; + testNumber: number; + timeout: number | null; + } + /** + * A successful call to `run()` method will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.`TestsStream` will emit events, in the + * order of the tests definition + * @since v18.9.0, v16.19.0 + */ + class TestsStream extends Readable implements NodeJS.ReadableStream { + addListener(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + addListener(event: "test:fail", listener: (data: TestFail) => void): this; + addListener(event: "test:pass", listener: (data: TestPass) => void): this; + addListener(event: "test:plan", listener: (data: TestPlan) => void): this; + addListener(event: "test:start", listener: (data: TestStart) => void): this; + addListener(event: "test:stderr", listener: (data: TestStderr) => void): this; + addListener(event: "test:stdout", listener: (data: TestStdout) => void): this; + addListener(event: string, listener: (...args: any[]) => void): this; + emit(event: "test:diagnostic", data: DiagnosticData): boolean; + emit(event: "test:fail", data: TestFail): boolean; + emit(event: "test:pass", data: TestPass): boolean; + emit(event: "test:plan", data: TestPlan): boolean; + emit(event: "test:start", data: TestStart): boolean; + emit(event: "test:stderr", data: TestStderr): boolean; + emit(event: "test:stdout", data: TestStdout): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + on(event: "test:fail", listener: (data: TestFail) => void): this; + on(event: "test:pass", listener: (data: TestPass) => void): this; + on(event: "test:plan", listener: (data: TestPlan) => void): this; + on(event: "test:start", listener: (data: TestStart) => void): this; + on(event: "test:stderr", listener: (data: TestStderr) => void): this; + on(event: "test:stdout", listener: (data: TestStdout) => void): this; + on(event: string, listener: (...args: any[]) => void): this; + once(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + once(event: "test:fail", listener: (data: TestFail) => void): this; + once(event: "test:pass", listener: (data: TestPass) => void): this; + once(event: "test:plan", listener: (data: TestPlan) => void): this; + once(event: "test:start", listener: (data: TestStart) => void): this; + once(event: "test:stderr", listener: (data: TestStderr) => void): this; + once(event: "test:stdout", listener: (data: TestStdout) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + prependListener(event: "test:fail", listener: (data: TestFail) => void): this; + prependListener(event: "test:pass", listener: (data: TestPass) => void): this; + prependListener(event: "test:plan", listener: (data: TestPlan) => void): this; + prependListener(event: "test:start", listener: (data: TestStart) => void): this; + prependListener(event: "test:stderr", listener: (data: TestStderr) => void): this; + prependListener(event: "test:stdout", listener: (data: TestStdout) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + prependOnceListener(event: "test:fail", listener: (data: TestFail) => void): this; + prependOnceListener(event: "test:pass", listener: (data: TestPass) => void): this; + prependOnceListener(event: "test:plan", listener: (data: TestPlan) => void): this; + prependOnceListener(event: "test:start", listener: (data: TestStart) => void): this; + prependOnceListener(event: "test:stderr", listener: (data: TestStderr) => void): this; + prependOnceListener(event: "test:stdout", listener: (data: TestStdout) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + } + /** + * An instance of `TestContext` is passed to each test function in order to + * interact with the test runner. However, the `TestContext` constructor is not + * exposed as part of the API. + * @since v18.0.0, v16.17.0 + */ + class TestContext { + /** + * This function is used to create a hook running before subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v20.1.0 + */ + before: typeof before; + /** + * This function is used to create a hook running before each subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.8.0 + */ + beforeEach: typeof beforeEach; + /** + * This function is used to create a hook that runs after the current test finishes. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.13.0 + */ + after: typeof after; + /** + * This function is used to create a hook running after each subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.8.0 + */ + afterEach: typeof afterEach; + /** + * This function is used to write diagnostics to the output. Any diagnostic + * information is included at the end of the test's results. This function does + * not return a value. + * + * ```js + * test('top level test', (t) => { + * t.diagnostic('A diagnostic message'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Message to be reported. + */ + diagnostic(message: string): void; + /** + * The name of the test. + * @since v18.8.0, v16.18.0 + */ + readonly name: string; + /** + * If `shouldRunOnlyTests` is truthy, the test context will only run tests that + * have the `only` option set. Otherwise, all tests are run. If Node.js was not + * started with the `--test-only` command-line option, this function is a + * no-op. + * + * ```js + * test('top level test', (t) => { + * // The test context can be set to run subtests with the 'only' option. + * t.runOnly(true); + * return Promise.all([ + * t.test('this subtest is now skipped'), + * t.test('this subtest is run', { only: true }), + * ]); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param shouldRunOnlyTests Whether or not to run `only` tests. + */ + runOnly(shouldRunOnlyTests: boolean): void; + /** + * ```js + * test('top level test', async (t) => { + * await fetch('some/uri', { signal: t.signal }); + * }); + * ``` + * @since v18.7.0, v16.17.0 + */ + readonly signal: AbortSignal; + /** + * This function causes the test's output to indicate the test as skipped. If`message` is provided, it is included in the output. Calling `skip()` does + * not terminate execution of the test function. This function does not return a + * value. + * + * ```js + * test('top level test', (t) => { + * // Make sure to return here as well if the test contains additional logic. + * t.skip('this is skipped'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Optional skip message. + */ + skip(message?: string): void; + /** + * This function adds a `TODO` directive to the test's output. If `message` is + * provided, it is included in the output. Calling `todo()` does not terminate + * execution of the test function. This function does not return a value. + * + * ```js + * test('top level test', (t) => { + * // This test is marked as `TODO` + * t.todo('this is a todo'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Optional `TODO` message. + */ + todo(message?: string): void; + /** + * This function is used to create subtests under the current test. This function behaves in + * the same fashion as the top level {@link test} function. + * @since v18.0.0 + * @param name The name of the test, which is displayed when reporting test results. + * Default: The `name` property of fn, or `''` if `fn` does not have a name. + * @param options Configuration options for the test + * @param fn The function under test. This first argument to this function is a + * {@link TestContext} object. If the test uses callbacks, the callback function is + * passed as the second argument. Default: A no-op function. + * @returns A {@link Promise} resolved with `undefined` once the test completes. + */ + test: typeof test; + /** + * Each test provides its own MockTracker instance. + */ + readonly mock: MockTracker; + } + /** + * An instance of `SuiteContext` is passed to each suite function in order to + * interact with the test runner. However, the `SuiteContext` constructor is not + * exposed as part of the API. + * @since v18.7.0, v16.17.0 + */ + class SuiteContext { + /** + * The name of the suite. + * @since v18.8.0, v16.18.0 + */ + readonly name: string; + /** + * Can be used to abort test subtasks when the test has been aborted. + * @since v18.7.0, v16.17.0 + */ + readonly signal: AbortSignal; + } + interface TestOptions { + /** + * If a number is provided, then that many tests would run in parallel. + * If truthy, it would run (number of cpu cores - 1) tests in parallel. + * For subtests, it will be `Infinity` tests in parallel. + * If falsy, it would only run one test at a time. + * If unspecified, subtests inherit this value from their parent. + * @default false + */ + concurrency?: number | boolean | undefined; + /** + * If truthy, and the test context is configured to run `only` tests, then this test will be + * run. Otherwise, the test is skipped. + * @default false + */ + only?: boolean | undefined; + /** + * Allows aborting an in-progress test. + * @since v18.8.0 + */ + signal?: AbortSignal | undefined; + /** + * If truthy, the test is skipped. If a string is provided, that string is displayed in the + * test results as the reason for skipping the test. + * @default false + */ + skip?: boolean | string | undefined; + /** + * A number of milliseconds the test will fail after. If unspecified, subtests inherit this + * value from their parent. + * @default Infinity + * @since v18.7.0 + */ + timeout?: number | undefined; + /** + * If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in + * the test results as the reason why the test is `TODO`. + * @default false + */ + todo?: boolean | string | undefined; + } + /** + * This function is used to create a hook running before running a suite. + * + * ```js + * describe('tests', async () => { + * before(() => console.log('about to run some test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function before(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running after running a suite. + * + * ```js + * describe('tests', async () => { + * after(() => console.log('finished running tests')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function after(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running + * before each subtest of the current suite. + * + * ```js + * describe('tests', async () => { + * beforeEach(() => console.log('about to run a test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function beforeEach(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running + * after each subtest of the current test. + * + * ```js + * describe('tests', async () => { + * afterEach(() => console.log('finished running a test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function afterEach(fn?: HookFn, options?: HookOptions): void; + /** + * The hook function. If the hook uses callbacks, the callback function is passed as the + * second argument. + */ + type HookFn = (s: SuiteContext, done: (result?: any) => void) => any; + /** + * Configuration options for hooks. + * @since v18.8.0 + */ + interface HookOptions { + /** + * Allows aborting an in-progress hook. + */ + signal?: AbortSignal | undefined; + /** + * A number of milliseconds the hook will fail after. If unspecified, subtests inherit this + * value from their parent. + * @default Infinity + */ + timeout?: number | undefined; + } + interface MockFunctionOptions { + /** + * The number of times that the mock will use the behavior of `implementation`. + * Once the mock function has been called `times` times, + * it will automatically restore the behavior of `original`. + * This value must be an integer greater than zero. + * @default Infinity + */ + times?: number | undefined; + } + interface MockMethodOptions extends MockFunctionOptions { + /** + * If `true`, `object[methodName]` is treated as a getter. + * This option cannot be used with the `setter` option. + */ + getter?: boolean | undefined; + /** + * If `true`, `object[methodName]` is treated as a setter. + * This option cannot be used with the `getter` option. + */ + setter?: boolean | undefined; + } + type Mock = F & { + mock: MockFunctionContext; + }; + type NoOpFunction = (...args: any[]) => undefined; + type FunctionPropertyNames = { + [K in keyof T]: T[K] extends Function ? K : never; + }[keyof T]; + /** + * The `MockTracker` class is used to manage mocking functionality. The test runner + * module provides a top level `mock` export which is a `MockTracker` instance. + * Each test also provides its own `MockTracker` instance via the test context's`mock` property. + * @since v19.1.0, v18.13.0 + */ + class MockTracker { + /** + * This function is used to create a mock function. + * + * The following example creates a mock function that increments a counter by one + * on each invocation. The `times` option is used to modify the mock behavior such + * that the first two invocations add two to the counter instead of one. + * + * ```js + * test('mocks a counting function', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne, addTwo, { times: 2 }); + * + * assert.strictEqual(fn(), 2); + * assert.strictEqual(fn(), 4); + * assert.strictEqual(fn(), 5); + * assert.strictEqual(fn(), 6); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param [original='A no-op function'] An optional function to create a mock on. + * @param implementation An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and + * then restore the behavior of `original`. + * @param options Optional configuration options for the mock function. The following properties are supported: + * @return The mocked function. The mocked function contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the + * behavior of the mocked function. + */ + fn(original?: F, options?: MockFunctionOptions): Mock; + fn( + original?: F, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock; + /** + * This function is used to create a mock on an existing object method. The + * following example demonstrates how a mock is created on an existing object + * method. + * + * ```js + * test('spies on an object method', (t) => { + * const number = { + * value: 5, + * subtract(a) { + * return this.value - a; + * }, + * }; + * + * t.mock.method(number, 'subtract'); + * assert.strictEqual(number.subtract.mock.calls.length, 0); + * assert.strictEqual(number.subtract(3), 2); + * assert.strictEqual(number.subtract.mock.calls.length, 1); + * + * const call = number.subtract.mock.calls[0]; + * + * assert.deepStrictEqual(call.arguments, [3]); + * assert.strictEqual(call.result, 2); + * assert.strictEqual(call.error, undefined); + * assert.strictEqual(call.target, undefined); + * assert.strictEqual(call.this, number); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param object The object whose method is being mocked. + * @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown. + * @param implementation An optional function used as the mock implementation for `object[methodName]`. + * @param options Optional configuration options for the mock method. The following properties are supported: + * @return The mocked method. The mocked method contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the + * behavior of the mocked method. + */ + method< + MockedObject extends object, + MethodName extends FunctionPropertyNames, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): MockedObject[MethodName] extends Function ? Mock + : never; + method< + MockedObject extends object, + MethodName extends FunctionPropertyNames, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation: Implementation, + options?: MockFunctionOptions, + ): MockedObject[MethodName] extends Function ? Mock + : never; + method( + object: MockedObject, + methodName: keyof MockedObject, + options: MockMethodOptions, + ): Mock; + method( + object: MockedObject, + methodName: keyof MockedObject, + implementation: Function, + options: MockMethodOptions, + ): Mock; + + /** + * This function is syntax sugar for `MockTracker.method` with `options.getter`set to `true`. + * @since v19.3.0, v18.13.0 + */ + getter< + MockedObject extends object, + MethodName extends keyof MockedObject, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): Mock<() => MockedObject[MethodName]>; + getter< + MockedObject extends object, + MethodName extends keyof MockedObject, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock<(() => MockedObject[MethodName]) | Implementation>; + /** + * This function is syntax sugar for `MockTracker.method` with `options.setter`set to `true`. + * @since v19.3.0, v18.13.0 + */ + setter< + MockedObject extends object, + MethodName extends keyof MockedObject, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): Mock<(value: MockedObject[MethodName]) => void>; + setter< + MockedObject extends object, + MethodName extends keyof MockedObject, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock<((value: MockedObject[MethodName]) => void) | Implementation>; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTracker` and disassociates the mocks from the`MockTracker` instance. Once disassociated, the mocks can still be used, but the`MockTracker` instance can no longer be + * used to reset their behavior or + * otherwise interact with them. + * + * After each test completes, this function is called on the test context's`MockTracker`. If the global `MockTracker` is used extensively, calling this + * function manually is recommended. + * @since v19.1.0, v18.13.0 + */ + reset(): void; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTracker`. Unlike `mock.reset()`, `mock.restoreAll()` does + * not disassociate the mocks from the `MockTracker` instance. + * @since v19.1.0, v18.13.0 + */ + restoreAll(): void; + timers: MockTimers; + } + const mock: MockTracker; + interface MockFunctionCall< + F extends Function, + ReturnType = F extends (...args: any) => infer T ? T + : F extends abstract new(...args: any) => infer T ? T + : unknown, + Args = F extends (...args: infer Y) => any ? Y + : F extends abstract new(...args: infer Y) => any ? Y + : unknown[], + > { + /** + * An array of the arguments passed to the mock function. + */ + arguments: Args; + /** + * If the mocked function threw then this property contains the thrown value. + */ + error: unknown | undefined; + /** + * The value returned by the mocked function. + * + * If the mocked function threw, it will be `undefined`. + */ + result: ReturnType | undefined; + /** + * An `Error` object whose stack can be used to determine the callsite of the mocked function invocation. + */ + stack: Error; + /** + * If the mocked function is a constructor, this field contains the class being constructed. + * Otherwise this will be `undefined`. + */ + target: F extends abstract new(...args: any) => any ? F : undefined; + /** + * The mocked function's `this` value. + */ + this: unknown; + } + /** + * The `MockFunctionContext` class is used to inspect or manipulate the behavior of + * mocks created via the `MockTracker` APIs. + * @since v19.1.0, v18.13.0 + */ + class MockFunctionContext { + /** + * A getter that returns a copy of the internal array used to track calls to the + * mock. Each entry in the array is an object with the following properties. + * @since v19.1.0, v18.13.0 + */ + readonly calls: Array>; + /** + * This function returns the number of times that this mock has been invoked. This + * function is more efficient than checking `ctx.calls.length` because `ctx.calls`is a getter that creates a copy of the internal call tracking array. + * @since v19.1.0, v18.13.0 + * @return The number of times that this mock has been invoked. + */ + callCount(): number; + /** + * This function is used to change the behavior of an existing mock. + * + * The following example creates a mock function using `t.mock.fn()`, calls the + * mock function, and then changes the mock implementation to a different function. + * + * ```js + * test('changes a mock behavior', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne); + * + * assert.strictEqual(fn(), 1); + * fn.mock.mockImplementation(addTwo); + * assert.strictEqual(fn(), 3); + * assert.strictEqual(fn(), 5); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param implementation The function to be used as the mock's new implementation. + */ + mockImplementation(implementation: Function): void; + /** + * This function is used to change the behavior of an existing mock for a single + * invocation. Once invocation `onCall` has occurred, the mock will revert to + * whatever behavior it would have used had `mockImplementationOnce()` not been + * called. + * + * The following example creates a mock function using `t.mock.fn()`, calls the + * mock function, changes the mock implementation to a different function for the + * next invocation, and then resumes its previous behavior. + * + * ```js + * test('changes a mock behavior once', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne); + * + * assert.strictEqual(fn(), 1); + * fn.mock.mockImplementationOnce(addTwo); + * assert.strictEqual(fn(), 3); + * assert.strictEqual(fn(), 4); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`. + * @param onCall The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown. + */ + mockImplementationOnce(implementation: Function, onCall?: number): void; + /** + * Resets the call history of the mock function. + * @since v19.3.0, v18.13.0 + */ + resetCalls(): void; + /** + * Resets the implementation of the mock function to its original behavior. The + * mock can still be used after calling this function. + * @since v19.1.0, v18.13.0 + */ + restore(): void; + } + type Timer = "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout"; + /** + * Mocking timers is a technique commonly used in software testing to simulate and + * control the behavior of timers, such as `setInterval` and `setTimeout`, + * without actually waiting for the specified time intervals. + * + * The `MockTracker` provides a top-level `timers` export + * which is a `MockTimers` instance. + * @since v20.4.0 + * @experimental + */ + class MockTimers { + /** + * Enables timer mocking for the specified timers. + * + * **Note:** When you enable mocking for a specific timer, its associated + * clear function will also be implicitly mocked. + * + * Example usage: + * + * ```js + * import { mock } from 'node:test'; + * mock.timers.enable(['setInterval']); + * ``` + * + * The above example enables mocking for the `setInterval` timer and + * implicitly mocks the `clearInterval` function. Only the `setInterval`and `clearInterval` functions from `node:timers`,`node:timers/promises`, and`globalThis` will be mocked. + * + * Alternatively, if you call `mock.timers.enable()` without any parameters: + * + * All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`) + * will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`, + * and `globalThis` will be mocked. + * @since v20.4.0 + */ + enable(timers?: Timer[]): void; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTimers` instance and disassociates the mocks + * from the `MockTracker` instance. + * + * **Note:** After each test completes, this function is called on + * the test context's `MockTracker`. + * + * ```js + * import { mock } from 'node:test'; + * mock.timers.reset(); + * ``` + * @since v20.4.0 + */ + reset(): void; + /** + * Advances time for all mocked timers. + * + * **Note:** This diverges from how `setTimeout` in Node.js behaves and accepts + * only positive numbers. In Node.js, `setTimeout` with negative numbers is + * only supported for web compatibility reasons. + * + * The following example mocks a `setTimeout` function and + * by using `.tick` advances in + * time triggering all pending timers. + * + * ```js + * import assert from 'node:assert'; + * import { test } from 'node:test'; + * + * test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => { + * const fn = context.mock.fn(); + * + * context.mock.timers.enable(['setTimeout']); + * + * setTimeout(fn, 9999); + * + * assert.strictEqual(fn.mock.callCount(), 0); + * + * // Advance in time + * context.mock.timers.tick(9999); + * + * assert.strictEqual(fn.mock.callCount(), 1); + * }); + * ``` + * + * Alternativelly, the `.tick` function can be called many times + * + * ```js + * import assert from 'node:assert'; + * import { test } from 'node:test'; + * + * test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => { + * const fn = context.mock.fn(); + * context.mock.timers.enable(['setTimeout']); + * const nineSecs = 9000; + * setTimeout(fn, nineSecs); + * + * const twoSeconds = 3000; + * context.mock.timers.tick(twoSeconds); + * context.mock.timers.tick(twoSeconds); + * context.mock.timers.tick(twoSeconds); + * + * assert.strictEqual(fn.mock.callCount(), 1); + * }); + * ``` + * @since v20.4.0 + */ + tick(milliseconds: number): void; + /** + * Triggers all pending mocked timers immediately. + * + * The example below triggers all pending timers immediately, + * causing them to execute without any delay. + * + * ```js + * import assert from 'node:assert'; + * import { test } from 'node:test'; + * + * test('runAll functions following the given order', (context) => { + * context.mock.timers.enable(['setTimeout']); + * const results = []; + * setTimeout(() => results.push(1), 9999); + * + * // Notice that if both timers have the same timeout, + * // the order of execution is guaranteed + * setTimeout(() => results.push(3), 8888); + * setTimeout(() => results.push(2), 8888); + * + * assert.deepStrictEqual(results, []); + * + * context.mock.timers.runAll(); + * + * assert.deepStrictEqual(results, [3, 2, 1]); + * }); + * ``` + * + * **Note:** The `runAll()` function is specifically designed for + * triggering timers in the context of timer mocking. + * It does not have any effect on real-time system + * clocks or actual timers outside of the mocking environment. + * @since v20.4.0 + */ + runAll(): void; + /** + * Calls {@link MockTimers.reset()}. + */ + [Symbol.dispose](): void; + } + export { + after, + afterEach, + before, + beforeEach, + describe, + it, + Mock, + mock, + only, + run, + skip, + test, + test as default, + todo, + }; +} + +interface TestLocationInfo { + /** + * The column number where the test is defined, or + * `undefined` if the test was run through the REPL. + */ + column?: number; + /** + * The path of the test file, `undefined` if test is not ran through a file. + */ + file?: string; + /** + * The line number where the test is defined, or + * `undefined` if the test was run through the REPL. + */ + line?: number; +} +interface DiagnosticData extends TestLocationInfo { + /** + * The diagnostic message. + */ + message: string; + /** + * The nesting level of the test. + */ + nesting: number; +} +interface TestFail extends TestLocationInfo { + /** + * Additional execution metadata. + */ + details: { + /** + * The duration of the test in milliseconds. + */ + duration_ms: number; + /** + * The error thrown by the test. + */ + error: Error; + /** + * The type of the test, used to denote whether this is a suite. + * @since 20.0.0, 19.9.0, 18.17.0 + */ + type?: "suite"; + }; + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The ordinal number of the test. + */ + testNumber: number; + /** + * Present if `context.todo` is called. + */ + todo?: string | boolean; + /** + * Present if `context.skip` is called. + */ + skip?: string | boolean; +} +interface TestPass extends TestLocationInfo { + /** + * Additional execution metadata. + */ + details: { + /** + * The duration of the test in milliseconds. + */ + duration_ms: number; + /** + * The type of the test, used to denote whether this is a suite. + * @since 20.0.0, 19.9.0, 18.17.0 + */ + type?: "suite"; + }; + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The ordinal number of the test. + */ + testNumber: number; + /** + * Present if `context.todo` is called. + */ + todo?: string | boolean; + /** + * Present if `context.skip` is called. + */ + skip?: string | boolean; +} +interface TestPlan extends TestLocationInfo { + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The number of subtests that have ran. + */ + count: number; +} +interface TestStart extends TestLocationInfo { + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; +} +interface TestStderr extends TestLocationInfo { + /** + * The message written to `stderr` + */ + message: string; +} +interface TestStdout extends TestLocationInfo { + /** + * The message written to `stdout` + */ + message: string; +} +interface TestEnqueue extends TestLocationInfo { + /** + * The test name + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; +} +interface TestDequeue extends TestLocationInfo { + /** + * The test name + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; +} + +/** + * The `node:test/reporters` module exposes the builtin-reporters for `node:test`. + * To access it: + * + * ```js + * import test from 'node:test/reporters'; + * ``` + * + * This module is only available under the `node:` scheme. The following will not + * work: + * + * ```js + * import test from 'test/reporters'; + * ``` + * @since v19.9.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/test/reporters.js) + */ +declare module "node:test/reporters" { + import { Transform } from "node:stream"; + + type TestEvent = + | { type: "test:diagnostic"; data: DiagnosticData } + | { type: "test:fail"; data: TestFail } + | { type: "test:pass"; data: TestPass } + | { type: "test:plan"; data: TestPlan } + | { type: "test:start"; data: TestStart } + | { type: "test:stderr"; data: TestStderr } + | { type: "test:stdout"; data: TestStdout } + | { type: "test:enqueue"; data: TestEnqueue } + | { type: "test:dequeue"; data: TestDequeue } + | { type: "test:watch:drained" }; + type TestEventGenerator = AsyncGenerator; + + /** + * The `dot` reporter outputs the test results in a compact format, + * where each passing test is represented by a `.`, + * and each failing test is represented by a `X`. + */ + function dot(source: TestEventGenerator): AsyncGenerator<"\n" | "." | "X", void>; + /** + * The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format. + */ + function tap(source: TestEventGenerator): AsyncGenerator; + /** + * The `spec` reporter outputs the test results in a human-readable format. + */ + class Spec extends Transform { + constructor(); + } + /** + * The `junit` reporter outputs test results in a jUnit XML format + */ + function junit(source: TestEventGenerator): AsyncGenerator; + export { dot, junit, Spec as spec, tap, TestEvent }; +} diff --git a/node_modules/@types/node/timers.d.ts b/node_modules/@types/node/timers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..039f31f7ad0e07c4a455b0db6204648fe0e3e8b4 --- /dev/null +++ b/node_modules/@types/node/timers.d.ts @@ -0,0 +1,240 @@ +/** + * The `timer` module exposes a global API for scheduling functions to + * be called at some future period of time. Because the timer functions are + * globals, there is no need to call `require('node:timers')` to use the API. + * + * The timer functions within Node.js implement a similar API as the timers API + * provided by Web Browsers but use a different internal implementation that is + * built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout). + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/timers.js) + */ +declare module "timers" { + import { Abortable } from "node:events"; + import { + setImmediate as setImmediatePromise, + setInterval as setIntervalPromise, + setTimeout as setTimeoutPromise, + } from "node:timers/promises"; + interface TimerOptions extends Abortable { + /** + * Set to `false` to indicate that the scheduled `Timeout` + * should not require the Node.js event loop to remain active. + * @default true + */ + ref?: boolean | undefined; + } + let setTimeout: typeof global.setTimeout; + let clearTimeout: typeof global.clearTimeout; + let setInterval: typeof global.setInterval; + let clearInterval: typeof global.clearInterval; + let setImmediate: typeof global.setImmediate; + let clearImmediate: typeof global.clearImmediate; + global { + namespace NodeJS { + // compatibility with older typings + interface Timer extends RefCounted { + hasRef(): boolean; + refresh(): this; + [Symbol.toPrimitive](): number; + } + /** + * This object is created internally and is returned from `setImmediate()`. It + * can be passed to `clearImmediate()` in order to cancel the scheduled + * actions. + * + * By default, when an immediate is scheduled, the Node.js event loop will continue + * running as long as the immediate is active. The `Immediate` object returned by `setImmediate()` exports both `immediate.ref()` and `immediate.unref()`functions that can be used to + * control this default behavior. + */ + class Immediate implements RefCounted { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the`Immediate` is active. Calling `immediate.ref()` multiple times will have no + * effect. + * + * By default, all `Immediate` objects are "ref'ed", making it normally unnecessary + * to call `immediate.ref()` unless `immediate.unref()` had been called previously. + * @since v9.7.0 + * @return a reference to `immediate` + */ + ref(): this; + /** + * When called, the active `Immediate` object will not require the Node.js event + * loop to remain active. If there is no other activity keeping the event loop + * running, the process may exit before the `Immediate` object's callback is + * invoked. Calling `immediate.unref()` multiple times will have no effect. + * @since v9.7.0 + * @return a reference to `immediate` + */ + unref(): this; + /** + * If true, the `Immediate` object will keep the Node.js event loop active. + * @since v11.0.0 + */ + hasRef(): boolean; + _onImmediate: Function; // to distinguish it from the Timeout class + /** + * Cancels the immediate. This is similar to calling `clearImmediate()`. + * @since v20.5.0 + */ + [Symbol.dispose](): void; + } + /** + * This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the + * scheduled actions. + * + * By default, when a timer is scheduled using either `setTimeout()` or `setInterval()`, the Node.js event loop will continue running as long as the + * timer is active. Each of the `Timeout` objects returned by these functions + * export both `timeout.ref()` and `timeout.unref()` functions that can be used to + * control this default behavior. + */ + class Timeout implements Timer { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the`Timeout` is active. Calling `timeout.ref()` multiple times will have no effect. + * + * By default, all `Timeout` objects are "ref'ed", making it normally unnecessary + * to call `timeout.ref()` unless `timeout.unref()` had been called previously. + * @since v0.9.1 + * @return a reference to `timeout` + */ + ref(): this; + /** + * When called, the active `Timeout` object will not require the Node.js event loop + * to remain active. If there is no other activity keeping the event loop running, + * the process may exit before the `Timeout` object's callback is invoked. Calling`timeout.unref()` multiple times will have no effect. + * @since v0.9.1 + * @return a reference to `timeout` + */ + unref(): this; + /** + * If true, the `Timeout` object will keep the Node.js event loop active. + * @since v11.0.0 + */ + hasRef(): boolean; + /** + * Sets the timer's start time to the current time, and reschedules the timer to + * call its callback at the previously specified duration adjusted to the current + * time. This is useful for refreshing a timer without allocating a new + * JavaScript object. + * + * Using this on a timer that has already called its callback will reactivate the + * timer. + * @since v10.2.0 + * @return a reference to `timeout` + */ + refresh(): this; + [Symbol.toPrimitive](): number; + /** + * Cancels the timeout. + * @since v20.5.0 + */ + [Symbol.dispose](): void; + } + } + /** + * Schedules execution of a one-time `callback` after `delay` milliseconds. + * + * The `callback` will likely not be invoked in precisely `delay` milliseconds. + * Node.js makes no guarantees about the exact timing of when callbacks will fire, + * nor of their ordering. The callback will be called as close as possible to the + * time specified. + * + * When `delay` is larger than `2147483647` or less than `1`, the `delay`will be set to `1`. Non-integer delays are truncated to an integer. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setTimeout()`. + * @since v0.0.1 + * @param callback The function to call when the timer elapses. + * @param [delay=1] The number of milliseconds to wait before calling the `callback`. + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearTimeout} + */ + function setTimeout( + callback: (...args: TArgs) => void, + ms?: number, + ...args: TArgs + ): NodeJS.Timeout; + // util.promisify no rest args compability + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + function setTimeout(callback: (args: void) => void, ms?: number): NodeJS.Timeout; + namespace setTimeout { + const __promisify__: typeof setTimeoutPromise; + } + /** + * Cancels a `Timeout` object created by `setTimeout()`. + * @since v0.0.1 + * @param timeout A `Timeout` object as returned by {@link setTimeout} or the `primitive` of the `Timeout` object as a string or a number. + */ + function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void; + /** + * Schedules repeated execution of `callback` every `delay` milliseconds. + * + * When `delay` is larger than `2147483647` or less than `1`, the `delay` will be + * set to `1`. Non-integer delays are truncated to an integer. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setInterval()`. + * @since v0.0.1 + * @param callback The function to call when the timer elapses. + * @param [delay=1] The number of milliseconds to wait before calling the `callback`. + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearInterval} + */ + function setInterval( + callback: (...args: TArgs) => void, + ms?: number, + ...args: TArgs + ): NodeJS.Timeout; + // util.promisify no rest args compability + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout; + namespace setInterval { + const __promisify__: typeof setIntervalPromise; + } + /** + * Cancels a `Timeout` object created by `setInterval()`. + * @since v0.0.1 + * @param timeout A `Timeout` object as returned by {@link setInterval} or the `primitive` of the `Timeout` object as a string or a number. + */ + function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void; + /** + * Schedules the "immediate" execution of the `callback` after I/O events' + * callbacks. + * + * When multiple calls to `setImmediate()` are made, the `callback` functions are + * queued for execution in the order in which they are created. The entire callback + * queue is processed every event loop iteration. If an immediate timer is queued + * from inside an executing callback, that timer will not be triggered until the + * next event loop iteration. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setImmediate()`. + * @since v0.9.1 + * @param callback The function to call at the end of this turn of the Node.js `Event Loop` + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearImmediate} + */ + function setImmediate( + callback: (...args: TArgs) => void, + ...args: TArgs + ): NodeJS.Immediate; + // util.promisify no rest args compability + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + function setImmediate(callback: (args: void) => void): NodeJS.Immediate; + namespace setImmediate { + const __promisify__: typeof setImmediatePromise; + } + /** + * Cancels an `Immediate` object created by `setImmediate()`. + * @since v0.9.1 + * @param immediate An `Immediate` object as returned by {@link setImmediate}. + */ + function clearImmediate(immediateId: NodeJS.Immediate | undefined): void; + function queueMicrotask(callback: () => void): void; + } +} +declare module "node:timers" { + export * from "timers"; +} diff --git a/node_modules/@types/node/timers/promises.d.ts b/node_modules/@types/node/timers/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a54dc772dcbdb9974966bc3c5072a3e8636c0d4 --- /dev/null +++ b/node_modules/@types/node/timers/promises.d.ts @@ -0,0 +1,93 @@ +/** + * The `timers/promises` API provides an alternative set of timer functions + * that return `Promise` objects. The API is accessible via`require('node:timers/promises')`. + * + * ```js + * import { + * setTimeout, + * setImmediate, + * setInterval, + * } from 'timers/promises'; + * ``` + * @since v15.0.0 + */ +declare module "timers/promises" { + import { TimerOptions } from "node:timers"; + /** + * ```js + * import { + * setTimeout, + * } from 'timers/promises'; + * + * const res = await setTimeout(100, 'result'); + * + * console.log(res); // Prints 'result' + * ``` + * @since v15.0.0 + * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. + * @param value A value with which the promise is fulfilled. + */ + function setTimeout(delay?: number, value?: T, options?: TimerOptions): Promise; + /** + * ```js + * import { + * setImmediate, + * } from 'timers/promises'; + * + * const res = await setImmediate('result'); + * + * console.log(res); // Prints 'result' + * ``` + * @since v15.0.0 + * @param value A value with which the promise is fulfilled. + */ + function setImmediate(value?: T, options?: TimerOptions): Promise; + /** + * Returns an async iterator that generates values in an interval of `delay` ms. + * If `ref` is `true`, you need to call `next()` of async iterator explicitly + * or implicitly to keep the event loop alive. + * + * ```js + * import { + * setInterval, + * } from 'timers/promises'; + * + * const interval = 100; + * for await (const startTime of setInterval(interval, Date.now())) { + * const now = Date.now(); + * console.log(now); + * if ((now - startTime) > 1000) + * break; + * } + * console.log(Date.now()); + * ``` + * @since v15.9.0 + */ + function setInterval(delay?: number, value?: T, options?: TimerOptions): AsyncIterable; + interface Scheduler { + /** + * ```js + * import { scheduler } from 'node:timers/promises'; + * + * await scheduler.wait(1000); // Wait one second before continuing + * ``` + * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. + * Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported. + * @since v16.14.0 + * @experimental + * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. + */ + wait: (delay?: number, options?: TimerOptions) => Promise; + /** + * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. + * Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments. + * @since v16.14.0 + * @experimental + */ + yield: () => Promise; + } + const scheduler: Scheduler; +} +declare module "node:timers/promises" { + export * from "timers/promises"; +} diff --git a/node_modules/@types/node/tls.d.ts b/node_modules/@types/node/tls.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b289e841c3ce3e1e60b02eb607db1f3978358a83 --- /dev/null +++ b/node_modules/@types/node/tls.d.ts @@ -0,0 +1,1210 @@ +/** + * The `node:tls` module provides an implementation of the Transport Layer Security + * (TLS) and Secure Socket Layer (SSL) protocols that is built on top of OpenSSL. + * The module can be accessed using: + * + * ```js + * const tls = require('node:tls'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tls.js) + */ +declare module "tls" { + import { X509Certificate } from "node:crypto"; + import * as net from "node:net"; + import * as stream from "stream"; + const CLIENT_RENEG_LIMIT: number; + const CLIENT_RENEG_WINDOW: number; + interface Certificate { + /** + * Country code. + */ + C: string; + /** + * Street. + */ + ST: string; + /** + * Locality. + */ + L: string; + /** + * Organization. + */ + O: string; + /** + * Organizational unit. + */ + OU: string; + /** + * Common name. + */ + CN: string; + } + interface PeerCertificate { + /** + * `true` if a Certificate Authority (CA), `false` otherwise. + * @since v18.13.0 + */ + ca: boolean; + /** + * The DER encoded X.509 certificate data. + */ + raw: Buffer; + /** + * The certificate subject. + */ + subject: Certificate; + /** + * The certificate issuer, described in the same terms as the `subject`. + */ + issuer: Certificate; + /** + * The date-time the certificate is valid from. + */ + valid_from: string; + /** + * The date-time the certificate is valid to. + */ + valid_to: string; + /** + * The certificate serial number, as a hex string. + */ + serialNumber: string; + /** + * The SHA-1 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ + fingerprint: string; + /** + * The SHA-256 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ + fingerprint256: string; + /** + * The SHA-512 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ + fingerprint512: string; + /** + * The extended key usage, a set of OIDs. + */ + ext_key_usage?: string[]; + /** + * A string containing concatenated names for the subject, + * an alternative to the `subject` names. + */ + subjectaltname?: string; + /** + * An array describing the AuthorityInfoAccess, used with OCSP. + */ + infoAccess?: NodeJS.Dict; + /** + * For RSA keys: The RSA bit size. + * + * For EC keys: The key size in bits. + */ + bits?: number; + /** + * The RSA exponent, as a string in hexadecimal number notation. + */ + exponent?: string; + /** + * The RSA modulus, as a hexadecimal string. + */ + modulus?: string; + /** + * The public key. + */ + pubkey?: Buffer; + /** + * The ASN.1 name of the OID of the elliptic curve. + * Well-known curves are identified by an OID. + * While it is unusual, it is possible that the curve + * is identified by its mathematical properties, + * in which case it will not have an OID. + */ + asn1Curve?: string; + /** + * The NIST name for the elliptic curve,if it has one + * (not all well-known curves have been assigned names by NIST). + */ + nistCurve?: string; + } + interface DetailedPeerCertificate extends PeerCertificate { + /** + * The issuer certificate object. + * For self-signed certificates, this may be a circular reference. + */ + issuerCertificate: DetailedPeerCertificate; + } + interface CipherNameAndProtocol { + /** + * The cipher name. + */ + name: string; + /** + * SSL/TLS protocol version. + */ + version: string; + /** + * IETF name for the cipher suite. + */ + standardName: string; + } + interface EphemeralKeyInfo { + /** + * The supported types are 'DH' and 'ECDH'. + */ + type: string; + /** + * The name property is available only when type is 'ECDH'. + */ + name?: string | undefined; + /** + * The size of parameter of an ephemeral key exchange. + */ + size: number; + } + interface KeyObject { + /** + * Private keys in PEM format. + */ + pem: string | Buffer; + /** + * Optional passphrase. + */ + passphrase?: string | undefined; + } + interface PxfObject { + /** + * PFX or PKCS12 encoded private key and certificate chain. + */ + buf: string | Buffer; + /** + * Optional passphrase. + */ + passphrase?: string | undefined; + } + interface TLSSocketOptions extends SecureContextOptions, CommonConnectionOptions { + /** + * If true the TLS socket will be instantiated in server-mode. + * Defaults to false. + */ + isServer?: boolean | undefined; + /** + * An optional net.Server instance. + */ + server?: net.Server | undefined; + /** + * An optional Buffer instance containing a TLS session. + */ + session?: Buffer | undefined; + /** + * If true, specifies that the OCSP status request extension will be + * added to the client hello and an 'OCSPResponse' event will be + * emitted on the socket before establishing a secure communication + */ + requestOCSP?: boolean | undefined; + } + /** + * Performs transparent encryption of written data and all required TLS + * negotiation. + * + * Instances of `tls.TLSSocket` implement the duplex `Stream` interface. + * + * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate}) will only return data while the + * connection is open. + * @since v0.11.4 + */ + class TLSSocket extends net.Socket { + /** + * Construct a new tls.TLSSocket object from an existing TCP socket. + */ + constructor(socket: net.Socket, options?: TLSSocketOptions); + /** + * This property is `true` if the peer certificate was signed by one of the CAs + * specified when creating the `tls.TLSSocket` instance, otherwise `false`. + * @since v0.11.4 + */ + authorized: boolean; + /** + * Returns the reason why the peer's certificate was not been verified. This + * property is set only when `tlsSocket.authorized === false`. + * @since v0.11.4 + */ + authorizationError: Error; + /** + * Always returns `true`. This may be used to distinguish TLS sockets from regular`net.Socket` instances. + * @since v0.11.4 + */ + encrypted: true; + /** + * String containing the selected ALPN protocol. + * Before a handshake has completed, this value is always null. + * When a handshake is completed but not ALPN protocol was selected, tlsSocket.alpnProtocol equals false. + */ + alpnProtocol: string | false | null; + /** + * Returns an object representing the local certificate. The returned object has + * some properties corresponding to the fields of the certificate. + * + * See {@link TLSSocket.getPeerCertificate} for an example of the certificate + * structure. + * + * If there is no local certificate, an empty object will be returned. If the + * socket has been destroyed, `null` will be returned. + * @since v11.2.0 + */ + getCertificate(): PeerCertificate | object | null; + /** + * Returns an object containing information on the negotiated cipher suite. + * + * For example, a TLSv1.2 protocol with AES256-SHA cipher: + * + * ```json + * { + * "name": "AES256-SHA", + * "standardName": "TLS_RSA_WITH_AES_256_CBC_SHA", + * "version": "SSLv3" + * } + * ``` + * + * See [SSL\_CIPHER\_get\_name](https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html) for more information. + * @since v0.11.4 + */ + getCipher(): CipherNameAndProtocol; + /** + * Returns an object representing the type, name, and size of parameter of + * an ephemeral key exchange in `perfect forward secrecy` on a client + * connection. It returns an empty object when the key exchange is not + * ephemeral. As this is only supported on a client socket; `null` is returned + * if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The`name` property is available only when type is `'ECDH'`. + * + * For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`. + * @since v5.0.0 + */ + getEphemeralKeyInfo(): EphemeralKeyInfo | object | null; + /** + * As the `Finished` messages are message digests of the complete handshake + * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can + * be used for external authentication procedures when the authentication + * provided by SSL/TLS is not desired or is not enough. + * + * Corresponds to the `SSL_get_finished` routine in OpenSSL and may be used + * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929). + * @since v9.9.0 + * @return The latest `Finished` message that has been sent to the socket as part of a SSL/TLS handshake, or `undefined` if no `Finished` message has been sent yet. + */ + getFinished(): Buffer | undefined; + /** + * Returns an object representing the peer's certificate. If the peer does not + * provide a certificate, an empty object will be returned. If the socket has been + * destroyed, `null` will be returned. + * + * If the full certificate chain was requested, each certificate will include an`issuerCertificate` property containing an object representing its issuer's + * certificate. + * @since v0.11.4 + * @param detailed Include the full certificate chain if `true`, otherwise include just the peer's certificate. + * @return A certificate object. + */ + getPeerCertificate(detailed: true): DetailedPeerCertificate; + getPeerCertificate(detailed?: false): PeerCertificate; + getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate; + /** + * As the `Finished` messages are message digests of the complete handshake + * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can + * be used for external authentication procedures when the authentication + * provided by SSL/TLS is not desired or is not enough. + * + * Corresponds to the `SSL_get_peer_finished` routine in OpenSSL and may be used + * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929). + * @since v9.9.0 + * @return The latest `Finished` message that is expected or has actually been received from the socket as part of a SSL/TLS handshake, or `undefined` if there is no `Finished` message so + * far. + */ + getPeerFinished(): Buffer | undefined; + /** + * Returns a string containing the negotiated SSL/TLS protocol version of the + * current connection. The value `'unknown'` will be returned for connected + * sockets that have not completed the handshaking process. The value `null` will + * be returned for server sockets or disconnected client sockets. + * + * Protocol versions are: + * + * * `'SSLv3'` + * * `'TLSv1'` + * * `'TLSv1.1'` + * * `'TLSv1.2'` + * * `'TLSv1.3'` + * + * See the OpenSSL [`SSL_get_version`](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html) documentation for more information. + * @since v5.7.0 + */ + getProtocol(): string | null; + /** + * Returns the TLS session data or `undefined` if no session was + * negotiated. On the client, the data can be provided to the `session` option of {@link connect} to resume the connection. On the server, it may be useful + * for debugging. + * + * See `Session Resumption` for more information. + * + * Note: `getSession()` works only for TLSv1.2 and below. For TLSv1.3, applications + * must use the `'session'` event (it also works for TLSv1.2 and below). + * @since v0.11.4 + */ + getSession(): Buffer | undefined; + /** + * See [SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html) for more information. + * @since v12.11.0 + * @return List of signature algorithms shared between the server and the client in the order of decreasing preference. + */ + getSharedSigalgs(): string[]; + /** + * For a client, returns the TLS session ticket if one is available, or`undefined`. For a server, always returns `undefined`. + * + * It may be useful for debugging. + * + * See `Session Resumption` for more information. + * @since v0.11.4 + */ + getTLSTicket(): Buffer | undefined; + /** + * See `Session Resumption` for more information. + * @since v0.5.6 + * @return `true` if the session was reused, `false` otherwise. + */ + isSessionReused(): boolean; + /** + * The `tlsSocket.renegotiate()` method initiates a TLS renegotiation process. + * Upon completion, the `callback` function will be passed a single argument + * that is either an `Error` (if the request failed) or `null`. + * + * This method can be used to request a peer's certificate after the secure + * connection has been established. + * + * When running as the server, the socket will be destroyed with an error after`handshakeTimeout` timeout. + * + * For TLSv1.3, renegotiation cannot be initiated, it is not supported by the + * protocol. + * @since v0.11.8 + * @param callback If `renegotiate()` returned `true`, callback is attached once to the `'secure'` event. If `renegotiate()` returned `false`, `callback` will be called in the next tick with + * an error, unless the `tlsSocket` has been destroyed, in which case `callback` will not be called at all. + * @return `true` if renegotiation was initiated, `false` otherwise. + */ + renegotiate( + options: { + rejectUnauthorized?: boolean | undefined; + requestCert?: boolean | undefined; + }, + callback: (err: Error | null) => void, + ): undefined | boolean; + /** + * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size. + * Returns `true` if setting the limit succeeded; `false` otherwise. + * + * Smaller fragment sizes decrease the buffering latency on the client: larger + * fragments are buffered by the TLS layer until the entire fragment is received + * and its integrity is verified; large fragments can span multiple roundtrips + * and their processing can be delayed due to packet loss or reordering. However, + * smaller fragments add extra TLS framing bytes and CPU overhead, which may + * decrease overall server throughput. + * @since v0.11.11 + * @param [size=16384] The maximum TLS fragment size. The maximum value is `16384`. + */ + setMaxSendFragment(size: number): boolean; + /** + * Disables TLS renegotiation for this `TLSSocket` instance. Once called, attempts + * to renegotiate will trigger an `'error'` event on the `TLSSocket`. + * @since v8.4.0 + */ + disableRenegotiation(): void; + /** + * When enabled, TLS packet trace information is written to `stderr`. This can be + * used to debug TLS connection problems. + * + * The format of the output is identical to the output of`openssl s_client -trace` or `openssl s_server -trace`. While it is produced by + * OpenSSL's `SSL_trace()` function, the format is undocumented, can change + * without notice, and should not be relied on. + * @since v12.2.0 + */ + enableTrace(): void; + /** + * Returns the peer certificate as an `X509Certificate` object. + * + * If there is no peer certificate, or the socket has been destroyed,`undefined` will be returned. + * @since v15.9.0 + */ + getPeerX509Certificate(): X509Certificate | undefined; + /** + * Returns the local certificate as an `X509Certificate` object. + * + * If there is no local certificate, or the socket has been destroyed,`undefined` will be returned. + * @since v15.9.0 + */ + getX509Certificate(): X509Certificate | undefined; + /** + * Keying material is used for validations to prevent different kind of attacks in + * network protocols, for example in the specifications of IEEE 802.1X. + * + * Example + * + * ```js + * const keyingMaterial = tlsSocket.exportKeyingMaterial( + * 128, + * 'client finished'); + * + * /* + * Example return value of keyingMaterial: + * + * + * ``` + * + * See the OpenSSL [`SSL_export_keying_material`](https://www.openssl.org/docs/man1.1.1/man3/SSL_export_keying_material.html) documentation for more + * information. + * @since v13.10.0, v12.17.0 + * @param length number of bytes to retrieve from keying material + * @param label an application specific label, typically this will be a value from the [IANA Exporter Label + * Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels). + * @param context Optionally provide a context. + * @return requested bytes of the keying material + */ + exportKeyingMaterial(length: number, label: string, context: Buffer): Buffer; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + addListener(event: "secureConnect", listener: () => void): this; + addListener(event: "session", listener: (session: Buffer) => void): this; + addListener(event: "keylog", listener: (line: Buffer) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "OCSPResponse", response: Buffer): boolean; + emit(event: "secureConnect"): boolean; + emit(event: "session", session: Buffer): boolean; + emit(event: "keylog", line: Buffer): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "OCSPResponse", listener: (response: Buffer) => void): this; + on(event: "secureConnect", listener: () => void): this; + on(event: "session", listener: (session: Buffer) => void): this; + on(event: "keylog", listener: (line: Buffer) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "OCSPResponse", listener: (response: Buffer) => void): this; + once(event: "secureConnect", listener: () => void): this; + once(event: "session", listener: (session: Buffer) => void): this; + once(event: "keylog", listener: (line: Buffer) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + prependListener(event: "secureConnect", listener: () => void): this; + prependListener(event: "session", listener: (session: Buffer) => void): this; + prependListener(event: "keylog", listener: (line: Buffer) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + prependOnceListener(event: "secureConnect", listener: () => void): this; + prependOnceListener(event: "session", listener: (session: Buffer) => void): this; + prependOnceListener(event: "keylog", listener: (line: Buffer) => void): this; + } + interface CommonConnectionOptions { + /** + * An optional TLS context object from tls.createSecureContext() + */ + secureContext?: SecureContext | undefined; + /** + * When enabled, TLS packet trace information is written to `stderr`. This can be + * used to debug TLS connection problems. + * @default false + */ + enableTrace?: boolean | undefined; + /** + * If true the server will request a certificate from clients that + * connect and attempt to verify that certificate. Defaults to + * false. + */ + requestCert?: boolean | undefined; + /** + * An array of strings or a Buffer naming possible ALPN protocols. + * (Protocols should be ordered by their priority.) + */ + ALPNProtocols?: string[] | Uint8Array[] | Uint8Array | undefined; + /** + * SNICallback(servername, cb) A function that will be + * called if the client supports SNI TLS extension. Two arguments + * will be passed when called: servername and cb. SNICallback should + * invoke cb(null, ctx), where ctx is a SecureContext instance. + * (tls.createSecureContext(...) can be used to get a proper + * SecureContext.) If SNICallback wasn't provided the default callback + * with high-level API will be used (see below). + */ + SNICallback?: ((servername: string, cb: (err: Error | null, ctx?: SecureContext) => void) => void) | undefined; + /** + * If true the server will reject any connection which is not + * authorized with the list of supplied CAs. This option only has an + * effect if requestCert is true. + * @default true + */ + rejectUnauthorized?: boolean | undefined; + } + interface TlsOptions extends SecureContextOptions, CommonConnectionOptions, net.ServerOpts { + /** + * Abort the connection if the SSL/TLS handshake does not finish in the + * specified number of milliseconds. A 'tlsClientError' is emitted on + * the tls.Server object whenever a handshake times out. Default: + * 120000 (120 seconds). + */ + handshakeTimeout?: number | undefined; + /** + * The number of seconds after which a TLS session created by the + * server will no longer be resumable. See Session Resumption for more + * information. Default: 300. + */ + sessionTimeout?: number | undefined; + /** + * 48-bytes of cryptographically strong pseudo-random data. + */ + ticketKeys?: Buffer | undefined; + /** + * @param socket + * @param identity identity parameter sent from the client. + * @return pre-shared key that must either be + * a buffer or `null` to stop the negotiation process. Returned PSK must be + * compatible with the selected cipher's digest. + * + * When negotiating TLS-PSK (pre-shared keys), this function is called + * with the identity provided by the client. + * If the return value is `null` the negotiation process will stop and an + * "unknown_psk_identity" alert message will be sent to the other party. + * If the server wishes to hide the fact that the PSK identity was not known, + * the callback must provide some random data as `psk` to make the connection + * fail with "decrypt_error" before negotiation is finished. + * PSK ciphers are disabled by default, and using TLS-PSK thus + * requires explicitly specifying a cipher suite with the `ciphers` option. + * More information can be found in the RFC 4279. + */ + pskCallback?(socket: TLSSocket, identity: string): DataView | NodeJS.TypedArray | null; + /** + * hint to send to a client to help + * with selecting the identity during TLS-PSK negotiation. Will be ignored + * in TLS 1.3. Upon failing to set pskIdentityHint `tlsClientError` will be + * emitted with `ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED` code. + */ + pskIdentityHint?: string | undefined; + } + interface PSKCallbackNegotation { + psk: DataView | NodeJS.TypedArray; + identity: string; + } + interface ConnectionOptions extends SecureContextOptions, CommonConnectionOptions { + host?: string | undefined; + port?: number | undefined; + path?: string | undefined; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored. + socket?: stream.Duplex | undefined; // Establish secure connection on a given socket rather than creating a new socket + checkServerIdentity?: typeof checkServerIdentity | undefined; + servername?: string | undefined; // SNI TLS Extension + session?: Buffer | undefined; + minDHSize?: number | undefined; + lookup?: net.LookupFunction | undefined; + timeout?: number | undefined; + /** + * When negotiating TLS-PSK (pre-shared keys), this function is called + * with optional identity `hint` provided by the server or `null` + * in case of TLS 1.3 where `hint` was removed. + * It will be necessary to provide a custom `tls.checkServerIdentity()` + * for the connection as the default one will try to check hostname/IP + * of the server against the certificate but that's not applicable for PSK + * because there won't be a certificate present. + * More information can be found in the RFC 4279. + * + * @param hint message sent from the server to help client + * decide which identity to use during negotiation. + * Always `null` if TLS 1.3 is used. + * @returns Return `null` to stop the negotiation process. `psk` must be + * compatible with the selected cipher's digest. + * `identity` must use UTF-8 encoding. + */ + pskCallback?(hint: string | null): PSKCallbackNegotation | null; + } + /** + * Accepts encrypted connections using TLS or SSL. + * @since v0.3.2 + */ + class Server extends net.Server { + constructor(secureConnectionListener?: (socket: TLSSocket) => void); + constructor(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void); + /** + * The `server.addContext()` method adds a secure context that will be used if + * the client request's SNI name matches the supplied `hostname` (or wildcard). + * + * When there are multiple matching contexts, the most recently added one is + * used. + * @since v0.5.3 + * @param hostname A SNI host name or wildcard (e.g. `'*'`) + * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created + * with {@link createSecureContext} itself. + */ + addContext(hostname: string, context: SecureContextOptions): void; + /** + * Returns the session ticket keys. + * + * See `Session Resumption` for more information. + * @since v3.0.0 + * @return A 48-byte buffer containing the session ticket keys. + */ + getTicketKeys(): Buffer; + /** + * The `server.setSecureContext()` method replaces the secure context of an + * existing server. Existing connections to the server are not interrupted. + * @since v11.0.0 + * @param options An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc). + */ + setSecureContext(options: SecureContextOptions): void; + /** + * Sets the session ticket keys. + * + * Changes to the ticket keys are effective only for future server connections. + * Existing or currently pending server connections will use the previous keys. + * + * See `Session Resumption` for more information. + * @since v3.0.0 + * @param keys A 48-byte buffer containing the session ticket keys. + */ + setTicketKeys(keys: Buffer): void; + /** + * events.EventEmitter + * 1. tlsClientError + * 2. newSession + * 3. OCSPRequest + * 4. resumeSession + * 5. secureConnection + * 6. keylog + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + addListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void, + ): this; + addListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + addListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + addListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean; + emit(event: "newSession", sessionId: Buffer, sessionData: Buffer, callback: () => void): boolean; + emit( + event: "OCSPRequest", + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ): boolean; + emit( + event: "resumeSession", + sessionId: Buffer, + callback: (err: Error | null, sessionData: Buffer | null) => void, + ): boolean; + emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; + emit(event: "keylog", line: Buffer, tlsSocket: TLSSocket): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + on(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this; + on( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + on( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + on(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + once( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void, + ): this; + once( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + once( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + once(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + prependListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void, + ): this; + prependListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + prependListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + prependOnceListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void, + ): this; + prependOnceListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + prependOnceListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + } + /** + * @deprecated since v0.11.3 Use `tls.TLSSocket` instead. + */ + interface SecurePair { + encrypted: TLSSocket; + cleartext: TLSSocket; + } + type SecureVersion = "TLSv1.3" | "TLSv1.2" | "TLSv1.1" | "TLSv1"; + interface SecureContextOptions { + /** + * If set, this will be called when a client opens a connection using the ALPN extension. + * One argument will be passed to the callback: an object containing `servername` and `protocols` fields, + * respectively containing the server name from the SNI extension (if any) and an array of + * ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`, + * which will be returned to the client as the selected ALPN protocol, or `undefined`, + * to reject the connection with a fatal alert. If a string is returned that does not match one of + * the client's ALPN protocols, an error will be thrown. + * This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error. + */ + ALPNCallback?: ((arg: { servername: string; protocols: string[] }) => string | undefined) | undefined; + /** + * Optionally override the trusted CA certificates. Default is to trust + * the well-known CAs curated by Mozilla. Mozilla's CAs are completely + * replaced when CAs are explicitly specified using this option. + */ + ca?: string | Buffer | Array | undefined; + /** + * Cert chains in PEM format. One cert chain should be provided per + * private key. Each cert chain should consist of the PEM formatted + * certificate for a provided private key, followed by the PEM + * formatted intermediate certificates (if any), in order, and not + * including the root CA (the root CA must be pre-known to the peer, + * see ca). When providing multiple cert chains, they do not have to + * be in the same order as their private keys in key. If the + * intermediate certificates are not provided, the peer will not be + * able to validate the certificate, and the handshake will fail. + */ + cert?: string | Buffer | Array | undefined; + /** + * Colon-separated list of supported signature algorithms. The list + * can contain digest algorithms (SHA256, MD5 etc.), public key + * algorithms (RSA-PSS, ECDSA etc.), combination of both (e.g + * 'RSA+SHA384') or TLS v1.3 scheme names (e.g. rsa_pss_pss_sha512). + */ + sigalgs?: string | undefined; + /** + * Cipher suite specification, replacing the default. For more + * information, see modifying the default cipher suite. Permitted + * ciphers can be obtained via tls.getCiphers(). Cipher names must be + * uppercased in order for OpenSSL to accept them. + */ + ciphers?: string | undefined; + /** + * Name of an OpenSSL engine which can provide the client certificate. + */ + clientCertEngine?: string | undefined; + /** + * PEM formatted CRLs (Certificate Revocation Lists). + */ + crl?: string | Buffer | Array | undefined; + /** + * `'auto'` or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy. + * If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. + * ECDHE-based perfect forward secrecy will still be available. + */ + dhparam?: string | Buffer | undefined; + /** + * A string describing a named curve or a colon separated list of curve + * NIDs or names, for example P-521:P-384:P-256, to use for ECDH key + * agreement. Set to auto to select the curve automatically. Use + * crypto.getCurves() to obtain a list of available curve names. On + * recent releases, openssl ecparam -list_curves will also display the + * name and description of each available elliptic curve. Default: + * tls.DEFAULT_ECDH_CURVE. + */ + ecdhCurve?: string | undefined; + /** + * Attempt to use the server's cipher suite preferences instead of the + * client's. When true, causes SSL_OP_CIPHER_SERVER_PREFERENCE to be + * set in secureOptions + */ + honorCipherOrder?: boolean | undefined; + /** + * Private keys in PEM format. PEM allows the option of private keys + * being encrypted. Encrypted keys will be decrypted with + * options.passphrase. Multiple keys using different algorithms can be + * provided either as an array of unencrypted key strings or buffers, + * or an array of objects in the form {pem: [, + * passphrase: ]}. The object form can only occur in an array. + * object.passphrase is optional. Encrypted keys will be decrypted with + * object.passphrase if provided, or options.passphrase if it is not. + */ + key?: string | Buffer | Array | undefined; + /** + * Name of an OpenSSL engine to get private key from. Should be used + * together with privateKeyIdentifier. + */ + privateKeyEngine?: string | undefined; + /** + * Identifier of a private key managed by an OpenSSL engine. Should be + * used together with privateKeyEngine. Should not be set together with + * key, because both options define a private key in different ways. + */ + privateKeyIdentifier?: string | undefined; + /** + * Optionally set the maximum TLS version to allow. One + * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the + * `secureProtocol` option, use one or the other. + * **Default:** `'TLSv1.3'`, unless changed using CLI options. Using + * `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to + * `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used. + */ + maxVersion?: SecureVersion | undefined; + /** + * Optionally set the minimum TLS version to allow. One + * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the + * `secureProtocol` option, use one or the other. It is not recommended to use + * less than TLSv1.2, but it may be required for interoperability. + * **Default:** `'TLSv1.2'`, unless changed using CLI options. Using + * `--tls-v1.0` sets the default to `'TLSv1'`. Using `--tls-v1.1` sets the default to + * `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to + * 'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used. + */ + minVersion?: SecureVersion | undefined; + /** + * Shared passphrase used for a single private key and/or a PFX. + */ + passphrase?: string | undefined; + /** + * PFX or PKCS12 encoded private key and certificate chain. pfx is an + * alternative to providing key and cert individually. PFX is usually + * encrypted, if it is, passphrase will be used to decrypt it. Multiple + * PFX can be provided either as an array of unencrypted PFX buffers, + * or an array of objects in the form {buf: [, + * passphrase: ]}. The object form can only occur in an array. + * object.passphrase is optional. Encrypted PFX will be decrypted with + * object.passphrase if provided, or options.passphrase if it is not. + */ + pfx?: string | Buffer | Array | undefined; + /** + * Optionally affect the OpenSSL protocol behavior, which is not + * usually necessary. This should be used carefully if at all! Value is + * a numeric bitmask of the SSL_OP_* options from OpenSSL Options + */ + secureOptions?: number | undefined; // Value is a numeric bitmask of the `SSL_OP_*` options + /** + * Legacy mechanism to select the TLS protocol version to use, it does + * not support independent control of the minimum and maximum version, + * and does not support limiting the protocol to TLSv1.3. Use + * minVersion and maxVersion instead. The possible values are listed as + * SSL_METHODS, use the function names as strings. For example, use + * 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method' to allow + * any TLS protocol version up to TLSv1.3. It is not recommended to use + * TLS versions less than 1.2, but it may be required for + * interoperability. Default: none, see minVersion. + */ + secureProtocol?: string | undefined; + /** + * Opaque identifier used by servers to ensure session state is not + * shared between applications. Unused by clients. + */ + sessionIdContext?: string | undefined; + /** + * 48-bytes of cryptographically strong pseudo-random data. + * See Session Resumption for more information. + */ + ticketKeys?: Buffer | undefined; + /** + * The number of seconds after which a TLS session created by the + * server will no longer be resumable. See Session Resumption for more + * information. Default: 300. + */ + sessionTimeout?: number | undefined; + } + interface SecureContext { + context: any; + } + /** + * Verifies the certificate `cert` is issued to `hostname`. + * + * Returns [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, populating it with `reason`, `host`, and `cert` on + * failure. On success, returns [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type). + * + * This function is intended to be used in combination with the`checkServerIdentity` option that can be passed to {@link connect} and as + * such operates on a `certificate object`. For other purposes, consider using `x509.checkHost()` instead. + * + * This function can be overwritten by providing an alternative function as the`options.checkServerIdentity` option that is passed to `tls.connect()`. The + * overwriting function can call `tls.checkServerIdentity()` of course, to augment + * the checks done with additional verification. + * + * This function is only called if the certificate passed all other checks, such as + * being issued by trusted CA (`options.ca`). + * + * Earlier versions of Node.js incorrectly accepted certificates for a given`hostname` if a matching `uniformResourceIdentifier` subject alternative name + * was present (see [CVE-2021-44531](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44531)). Applications that wish to accept`uniformResourceIdentifier` subject alternative names can use + * a custom`options.checkServerIdentity` function that implements the desired behavior. + * @since v0.8.4 + * @param hostname The host name or IP address to verify the certificate against. + * @param cert A `certificate object` representing the peer's certificate. + */ + function checkServerIdentity(hostname: string, cert: PeerCertificate): Error | undefined; + /** + * Creates a new {@link Server}. The `secureConnectionListener`, if provided, is + * automatically set as a listener for the `'secureConnection'` event. + * + * The `ticketKeys` options is automatically shared between `node:cluster` module + * workers. + * + * The following illustrates a simple echo server: + * + * ```js + * const tls = require('node:tls'); + * const fs = require('node:fs'); + * + * const options = { + * key: fs.readFileSync('server-key.pem'), + * cert: fs.readFileSync('server-cert.pem'), + * + * // This is necessary only if using client certificate authentication. + * requestCert: true, + * + * // This is necessary only if the client uses a self-signed certificate. + * ca: [ fs.readFileSync('client-cert.pem') ], + * }; + * + * const server = tls.createServer(options, (socket) => { + * console.log('server connected', + * socket.authorized ? 'authorized' : 'unauthorized'); + * socket.write('welcome!\n'); + * socket.setEncoding('utf8'); + * socket.pipe(socket); + * }); + * server.listen(8000, () => { + * console.log('server bound'); + * }); + * ``` + * + * The server can be tested by connecting to it using the example client from {@link connect}. + * @since v0.3.2 + */ + function createServer(secureConnectionListener?: (socket: TLSSocket) => void): Server; + function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; + /** + * The `callback` function, if specified, will be added as a listener for the `'secureConnect'` event. + * + * `tls.connect()` returns a {@link TLSSocket} object. + * + * Unlike the `https` API, `tls.connect()` does not enable the + * SNI (Server Name Indication) extension by default, which may cause some + * servers to return an incorrect certificate or reject the connection + * altogether. To enable SNI, set the `servername` option in addition + * to `host`. + * + * The following illustrates a client for the echo server example from {@link createServer}: + * + * ```js + * // Assumes an echo server that is listening on port 8000. + * const tls = require('node:tls'); + * const fs = require('node:fs'); + * + * const options = { + * // Necessary only if the server requires client certificate authentication. + * key: fs.readFileSync('client-key.pem'), + * cert: fs.readFileSync('client-cert.pem'), + * + * // Necessary only if the server uses a self-signed certificate. + * ca: [ fs.readFileSync('server-cert.pem') ], + * + * // Necessary only if the server's cert isn't for "localhost". + * checkServerIdentity: () => { return null; }, + * }; + * + * const socket = tls.connect(8000, options, () => { + * console.log('client connected', + * socket.authorized ? 'authorized' : 'unauthorized'); + * process.stdin.pipe(socket); + * process.stdin.resume(); + * }); + * socket.setEncoding('utf8'); + * socket.on('data', (data) => { + * console.log(data); + * }); + * socket.on('end', () => { + * console.log('server ends connection'); + * }); + * ``` + * @since v0.11.3 + */ + function connect(options: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; + function connect( + port: number, + host?: string, + options?: ConnectionOptions, + secureConnectListener?: () => void, + ): TLSSocket; + function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; + /** + * Creates a new secure pair object with two streams, one of which reads and writes + * the encrypted data and the other of which reads and writes the cleartext data. + * Generally, the encrypted stream is piped to/from an incoming encrypted data + * stream and the cleartext one is used as a replacement for the initial encrypted + * stream. + * + * `tls.createSecurePair()` returns a `tls.SecurePair` object with `cleartext` and`encrypted` stream properties. + * + * Using `cleartext` has the same API as {@link TLSSocket}. + * + * The `tls.createSecurePair()` method is now deprecated in favor of`tls.TLSSocket()`. For example, the code: + * + * ```js + * pair = tls.createSecurePair(// ... ); + * pair.encrypted.pipe(socket); + * socket.pipe(pair.encrypted); + * ``` + * + * can be replaced by: + * + * ```js + * secureSocket = tls.TLSSocket(socket, options); + * ``` + * + * where `secureSocket` has the same API as `pair.cleartext`. + * @since v0.3.2 + * @deprecated Since v0.11.3 - Use {@link TLSSocket} instead. + * @param context A secure context object as returned by `tls.createSecureContext()` + * @param isServer `true` to specify that this TLS connection should be opened as a server. + * @param requestCert `true` to specify whether a server should request a certificate from a connecting client. Only applies when `isServer` is `true`. + * @param rejectUnauthorized If not `false` a server automatically reject clients with invalid certificates. Only applies when `isServer` is `true`. + */ + function createSecurePair( + context?: SecureContext, + isServer?: boolean, + requestCert?: boolean, + rejectUnauthorized?: boolean, + ): SecurePair; + /** + * {@link createServer} sets the default value of the `honorCipherOrder` option + * to `true`, other APIs that create secure contexts leave it unset. + * + * {@link createServer} uses a 128 bit truncated SHA1 hash value generated + * from `process.argv` as the default value of the `sessionIdContext` option, other + * APIs that create secure contexts have no default value. + * + * The `tls.createSecureContext()` method creates a `SecureContext` object. It is + * usable as an argument to several `tls` APIs, such as `server.addContext()`, + * but has no public methods. The {@link Server} constructor and the {@link createServer} method do not support the `secureContext` option. + * + * A key is _required_ for ciphers that use certificates. Either `key` or`pfx` can be used to provide it. + * + * If the `ca` option is not given, then Node.js will default to using [Mozilla's publicly trusted list of + * CAs](https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt). + * + * Custom DHE parameters are discouraged in favor of the new `dhparam: 'auto'`option. When set to `'auto'`, well-known DHE parameters of sufficient strength + * will be selected automatically. Otherwise, if necessary, `openssl dhparam` can + * be used to create custom parameters. The key length must be greater than or + * equal to 1024 bits or else an error will be thrown. Although 1024 bits is + * permissible, use 2048 bits or larger for stronger security. + * @since v0.11.13 + */ + function createSecureContext(options?: SecureContextOptions): SecureContext; + /** + * Returns an array with the names of the supported TLS ciphers. The names are + * lower-case for historical reasons, but must be uppercased to be used in + * the `ciphers` option of {@link createSecureContext}. + * + * Not all supported ciphers are enabled by default. See `Modifying the default TLS cipher suite`. + * + * Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for + * TLSv1.2 and below. + * + * ```js + * console.log(tls.getCiphers()); // ['aes128-gcm-sha256', 'aes128-sha', ...] + * ``` + * @since v0.10.2 + */ + function getCiphers(): string[]; + /** + * The default curve name to use for ECDH key agreement in a tls server. + * The default value is 'auto'. See tls.createSecureContext() for further + * information. + */ + let DEFAULT_ECDH_CURVE: string; + /** + * The default value of the maxVersion option of + * tls.createSecureContext(). It can be assigned any of the supported TLS + * protocol versions, 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default: + * 'TLSv1.3', unless changed using CLI options. Using --tls-max-v1.2 sets + * the default to 'TLSv1.2'. Using --tls-max-v1.3 sets the default to + * 'TLSv1.3'. If multiple of the options are provided, the highest maximum + * is used. + */ + let DEFAULT_MAX_VERSION: SecureVersion; + /** + * The default value of the minVersion option of tls.createSecureContext(). + * It can be assigned any of the supported TLS protocol versions, + * 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default: 'TLSv1.2', unless + * changed using CLI options. Using --tls-min-v1.0 sets the default to + * 'TLSv1'. Using --tls-min-v1.1 sets the default to 'TLSv1.1'. Using + * --tls-min-v1.3 sets the default to 'TLSv1.3'. If multiple of the options + * are provided, the lowest minimum is used. + */ + let DEFAULT_MIN_VERSION: SecureVersion; + /** + * The default value of the ciphers option of tls.createSecureContext(). + * It can be assigned any of the supported OpenSSL ciphers. + * Defaults to the content of crypto.constants.defaultCoreCipherList, unless + * changed using CLI options using --tls-default-ciphers. + */ + let DEFAULT_CIPHERS: string; + /** + * An immutable array of strings representing the root certificates (in PEM + * format) used for verifying peer certificates. This is the default value + * of the ca option to tls.createSecureContext(). + */ + const rootCertificates: readonly string[]; +} +declare module "node:tls" { + export * from "tls"; +} diff --git a/node_modules/@types/node/trace_events.d.ts b/node_modules/@types/node/trace_events.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..336135959baba13c54c0d7859445290994236804 --- /dev/null +++ b/node_modules/@types/node/trace_events.d.ts @@ -0,0 +1,182 @@ +/** + * The `node:trace_events` module provides a mechanism to centralize tracing + * information generated by V8, Node.js core, and userspace code. + * + * Tracing can be enabled with the `--trace-event-categories` command-line flag + * or by using the `node:trace_events` module. The `--trace-event-categories` flag + * accepts a list of comma-separated category names. + * + * The available categories are: + * + * * `node`: An empty placeholder. + * * `node.async_hooks`: Enables capture of detailed `async_hooks` trace data. + * The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property. + * * `node.bootstrap`: Enables capture of Node.js bootstrap milestones. + * * `node.console`: Enables capture of `console.time()` and `console.count()`output. + * * `node.threadpoolwork.sync`: Enables capture of trace data for threadpool + * synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`. + * * `node.threadpoolwork.async`: Enables capture of trace data for threadpool + * asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`. + * * `node.dns.native`: Enables capture of trace data for DNS queries. + * * `node.net.native`: Enables capture of trace data for network. + * * `node.environment`: Enables capture of Node.js Environment milestones. + * * `node.fs.sync`: Enables capture of trace data for file system sync methods. + * * `node.fs_dir.sync`: Enables capture of trace data for file system sync + * directory methods. + * * `node.fs.async`: Enables capture of trace data for file system async methods. + * * `node.fs_dir.async`: Enables capture of trace data for file system async + * directory methods. + * * `node.perf`: Enables capture of `Performance API` measurements. + * * `node.perf.usertiming`: Enables capture of only Performance API User Timing + * measures and marks. + * * `node.perf.timerify`: Enables capture of only Performance API timerify + * measurements. + * * `node.promises.rejections`: Enables capture of trace data tracking the number + * of unhandled Promise rejections and handled-after-rejections. + * * `node.vm.script`: Enables capture of trace data for the `node:vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods. + * * `v8`: The `V8` events are GC, compiling, and execution related. + * * `node.http`: Enables capture of trace data for http request / response. + * + * By default the `node`, `node.async_hooks`, and `v8` categories are enabled. + * + * ```bash + * node --trace-event-categories v8,node,node.async_hooks server.js + * ``` + * + * Prior versions of Node.js required the use of the `--trace-events-enabled`flag to enable trace events. This requirement has been removed. However, the`--trace-events-enabled` flag _may_ still be + * used and will enable the`node`, `node.async_hooks`, and `v8` trace event categories by default. + * + * ```bash + * node --trace-events-enabled + * + * # is equivalent to + * + * node --trace-event-categories v8,node,node.async_hooks + * ``` + * + * Alternatively, trace events may be enabled using the `node:trace_events` module: + * + * ```js + * const trace_events = require('node:trace_events'); + * const tracing = trace_events.createTracing({ categories: ['node.perf'] }); + * tracing.enable(); // Enable trace event capture for the 'node.perf' category + * + * // do work + * + * tracing.disable(); // Disable trace event capture for the 'node.perf' category + * ``` + * + * Running Node.js with tracing enabled will produce log files that can be opened + * in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool) tab of Chrome. + * + * The logging file is by default called `node_trace.${rotation}.log`, where`${rotation}` is an incrementing log-rotation id. The filepath pattern can + * be specified with `--trace-event-file-pattern` that accepts a template + * string that supports `${rotation}` and `${pid}`: + * + * ```bash + * node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js + * ``` + * + * To guarantee that the log file is properly generated after signal events like`SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers + * in your code, such as: + * + * ```js + * process.on('SIGINT', function onSigint() { + * console.info('Received SIGINT.'); + * process.exit(130); // Or applicable exit code depending on OS and signal + * }); + * ``` + * + * The tracing system uses the same time source + * as the one used by `process.hrtime()`. + * However the trace-event timestamps are expressed in microseconds, + * unlike `process.hrtime()` which returns nanoseconds. + * + * The features from this module are not available in `Worker` threads. + * @experimental + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/trace_events.js) + */ +declare module "trace_events" { + /** + * The `Tracing` object is used to enable or disable tracing for sets of + * categories. Instances are created using the + * `trace_events.createTracing()` method. + * + * When created, the `Tracing` object is disabled. Calling the + * `tracing.enable()` method adds the categories to the set of enabled trace + * event categories. Calling `tracing.disable()` will remove the categories + * from the set of enabled trace event categories. + */ + interface Tracing { + /** + * A comma-separated list of the trace event categories covered by this + * `Tracing` object. + */ + readonly categories: string; + /** + * Disables this `Tracing` object. + * + * Only trace event categories _not_ covered by other enabled `Tracing` + * objects and _not_ specified by the `--trace-event-categories` flag + * will be disabled. + */ + disable(): void; + /** + * Enables this `Tracing` object for the set of categories covered by + * the `Tracing` object. + */ + enable(): void; + /** + * `true` only if the `Tracing` object has been enabled. + */ + readonly enabled: boolean; + } + interface CreateTracingOptions { + /** + * An array of trace category names. Values included in the array are + * coerced to a string when possible. An error will be thrown if the + * value cannot be coerced. + */ + categories: string[]; + } + /** + * Creates and returns a `Tracing` object for the given set of `categories`. + * + * ```js + * const trace_events = require('node:trace_events'); + * const categories = ['node.perf', 'node.async_hooks']; + * const tracing = trace_events.createTracing({ categories }); + * tracing.enable(); + * // do stuff + * tracing.disable(); + * ``` + * @since v10.0.0 + * @return . + */ + function createTracing(options: CreateTracingOptions): Tracing; + /** + * Returns a comma-separated list of all currently-enabled trace event + * categories. The current set of enabled trace event categories is determined + * by the _union_ of all currently-enabled `Tracing` objects and any categories + * enabled using the `--trace-event-categories` flag. + * + * Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console. + * + * ```js + * const trace_events = require('node:trace_events'); + * const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] }); + * const t2 = trace_events.createTracing({ categories: ['node.perf'] }); + * const t3 = trace_events.createTracing({ categories: ['v8'] }); + * + * t1.enable(); + * t2.enable(); + * + * console.log(trace_events.getEnabledCategories()); + * ``` + * @since v10.0.0 + */ + function getEnabledCategories(): string | undefined; +} +declare module "node:trace_events" { + export * from "trace_events"; +} diff --git a/node_modules/@types/node/ts4.8/assert.d.ts b/node_modules/@types/node/ts4.8/assert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd821433575b42840106da9995aaaec26eb0edc7 --- /dev/null +++ b/node_modules/@types/node/ts4.8/assert.d.ts @@ -0,0 +1,996 @@ +/** + * The `node:assert` module provides a set of assertion functions for verifying + * invariants. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js) + */ +declare module "assert" { + /** + * An alias of {@link ok}. + * @since v0.5.9 + * @param value The input that is checked for being truthy. + */ + function assert(value: unknown, message?: string | Error): asserts value; + namespace assert { + /** + * Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class. + */ + class AssertionError extends Error { + /** + * Set to the `actual` argument for methods such as {@link assert.strictEqual()}. + */ + actual: unknown; + /** + * Set to the `expected` argument for methods such as {@link assert.strictEqual()}. + */ + expected: unknown; + /** + * Set to the passed in operator value. + */ + operator: string; + /** + * Indicates if the message was auto-generated (`true`) or not. + */ + generatedMessage: boolean; + /** + * Value is always `ERR_ASSERTION` to show that the error is an assertion error. + */ + code: "ERR_ASSERTION"; + constructor(options?: { + /** If provided, the error message is set to this value. */ + message?: string | undefined; + /** The `actual` property on the error instance. */ + actual?: unknown | undefined; + /** The `expected` property on the error instance. */ + expected?: unknown | undefined; + /** The `operator` property on the error instance. */ + operator?: string | undefined; + /** If provided, the generated stack trace omits frames before this function. */ + // eslint-disable-next-line @typescript-eslint/ban-types + stackStartFn?: Function | undefined; + }); + } + /** + * This feature is deprecated and will be removed in a future version. + * Please consider using alternatives such as the `mock` helper function. + * @since v14.2.0, v12.19.0 + * @deprecated Deprecated + */ + class CallTracker { + /** + * The wrapper function is expected to be called exactly `exact` times. If the + * function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an + * error. + * + * ```js + * import assert from 'node:assert'; + * + * // Creates call tracker. + * const tracker = new assert.CallTracker(); + * + * function func() {} + * + * // Returns a function that wraps func() that must be called exact times + * // before tracker.verify(). + * const callsfunc = tracker.calls(func); + * ``` + * @since v14.2.0, v12.19.0 + * @param [fn='A no-op function'] + * @param [exact=1] + * @return that wraps `fn`. + */ + calls(exact?: number): () => void; + calls any>(fn?: Func, exact?: number): Func; + /** + * Example: + * + * ```js + * import assert from 'node:assert'; + * + * const tracker = new assert.CallTracker(); + * + * function func() {} + * const callsfunc = tracker.calls(func); + * callsfunc(1, 2, 3); + * + * assert.deepStrictEqual(tracker.getCalls(callsfunc), + * [{ thisArg: undefined, arguments: [1, 2, 3] }]); + * ``` + * @since v18.8.0, v16.18.0 + * @param fn + * @return An Array with all the calls to a tracked function. + */ + getCalls(fn: Function): CallTrackerCall[]; + /** + * The arrays contains information about the expected and actual number of calls of + * the functions that have not been called the expected number of times. + * + * ```js + * import assert from 'node:assert'; + * + * // Creates call tracker. + * const tracker = new assert.CallTracker(); + * + * function func() {} + * + * // Returns a function that wraps func() that must be called exact times + * // before tracker.verify(). + * const callsfunc = tracker.calls(func, 2); + * + * // Returns an array containing information on callsfunc() + * console.log(tracker.report()); + * // [ + * // { + * // message: 'Expected the func function to be executed 2 time(s) but was + * // executed 0 time(s).', + * // actual: 0, + * // expected: 2, + * // operator: 'func', + * // stack: stack trace + * // } + * // ] + * ``` + * @since v14.2.0, v12.19.0 + * @return An Array of objects containing information about the wrapper functions returned by `calls`. + */ + report(): CallTrackerReportInformation[]; + /** + * Reset calls of the call tracker. + * If a tracked function is passed as an argument, the calls will be reset for it. + * If no arguments are passed, all tracked functions will be reset. + * + * ```js + * import assert from 'node:assert'; + * + * const tracker = new assert.CallTracker(); + * + * function func() {} + * const callsfunc = tracker.calls(func); + * + * callsfunc(); + * // Tracker was called once + * assert.strictEqual(tracker.getCalls(callsfunc).length, 1); + * + * tracker.reset(callsfunc); + * assert.strictEqual(tracker.getCalls(callsfunc).length, 0); + * ``` + * @since v18.8.0, v16.18.0 + * @param fn a tracked function to reset. + */ + reset(fn?: Function): void; + /** + * Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that + * have not been called the expected number of times. + * + * ```js + * import assert from 'node:assert'; + * + * // Creates call tracker. + * const tracker = new assert.CallTracker(); + * + * function func() {} + * + * // Returns a function that wraps func() that must be called exact times + * // before tracker.verify(). + * const callsfunc = tracker.calls(func, 2); + * + * callsfunc(); + * + * // Will throw an error since callsfunc() was only called once. + * tracker.verify(); + * ``` + * @since v14.2.0, v12.19.0 + */ + verify(): void; + } + interface CallTrackerCall { + thisArg: object; + arguments: unknown[]; + } + interface CallTrackerReportInformation { + message: string; + /** The actual number of times the function was called. */ + actual: number; + /** The number of times the function was expected to be called. */ + expected: number; + /** The name of the function that is wrapped. */ + operator: string; + /** A stack trace of the function. */ + stack: object; + } + type AssertPredicate = RegExp | (new() => object) | ((thrown: unknown) => boolean) | object | Error; + /** + * Throws an `AssertionError` with the provided error message or a default + * error message. If the `message` parameter is an instance of an `Error` then + * it will be thrown instead of the `AssertionError`. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.fail(); + * // AssertionError [ERR_ASSERTION]: Failed + * + * assert.fail('boom'); + * // AssertionError [ERR_ASSERTION]: boom + * + * assert.fail(new TypeError('need array')); + * // TypeError: need array + * ``` + * + * Using `assert.fail()` with more than two arguments is possible but deprecated. + * See below for further details. + * @since v0.1.21 + * @param [message='Failed'] + */ + function fail(message?: string | Error): never; + /** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */ + function fail( + actual: unknown, + expected: unknown, + message?: string | Error, + operator?: string, + // eslint-disable-next-line @typescript-eslint/ban-types + stackStartFn?: Function, + ): never; + /** + * Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`. + * + * If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default + * error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`. + * If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``. + * + * Be aware that in the `repl` the error message will be different to the one + * thrown in a file! See below for further details. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.ok(true); + * // OK + * assert.ok(1); + * // OK + * + * assert.ok(); + * // AssertionError: No value argument passed to `assert.ok()` + * + * assert.ok(false, 'it\'s false'); + * // AssertionError: it's false + * + * // In the repl: + * assert.ok(typeof 123 === 'string'); + * // AssertionError: false == true + * + * // In a file (e.g. test.js): + * assert.ok(typeof 123 === 'string'); + * // AssertionError: The expression evaluated to a falsy value: + * // + * // assert.ok(typeof 123 === 'string') + * + * assert.ok(false); + * // AssertionError: The expression evaluated to a falsy value: + * // + * // assert.ok(false) + * + * assert.ok(0); + * // AssertionError: The expression evaluated to a falsy value: + * // + * // assert.ok(0) + * ``` + * + * ```js + * import assert from 'node:assert/strict'; + * + * // Using `assert()` works the same: + * assert(0); + * // AssertionError: The expression evaluated to a falsy value: + * // + * // assert(0) + * ``` + * @since v0.1.21 + */ + function ok(value: unknown, message?: string | Error): asserts value; + /** + * **Strict assertion mode** + * + * An alias of {@link strictEqual}. + * + * **Legacy assertion mode** + * + * > Stability: 3 - Legacy: Use {@link strictEqual} instead. + * + * Tests shallow, coercive equality between the `actual` and `expected` parameters + * using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled + * and treated as being identical if both sides are `NaN`. + * + * ```js + * import assert from 'node:assert'; + * + * assert.equal(1, 1); + * // OK, 1 == 1 + * assert.equal(1, '1'); + * // OK, 1 == '1' + * assert.equal(NaN, NaN); + * // OK + * + * assert.equal(1, 2); + * // AssertionError: 1 == 2 + * assert.equal({ a: { b: 1 } }, { a: { b: 1 } }); + * // AssertionError: { a: { b: 1 } } == { a: { b: 1 } } + * ``` + * + * If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default + * error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`. + * @since v0.1.21 + */ + function equal(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * **Strict assertion mode** + * + * An alias of {@link notStrictEqual}. + * + * **Legacy assertion mode** + * + * > Stability: 3 - Legacy: Use {@link notStrictEqual} instead. + * + * Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is + * specially handled and treated as being identical if both sides are `NaN`. + * + * ```js + * import assert from 'node:assert'; + * + * assert.notEqual(1, 2); + * // OK + * + * assert.notEqual(1, 1); + * // AssertionError: 1 != 1 + * + * assert.notEqual(1, '1'); + * // AssertionError: 1 != '1' + * ``` + * + * If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error + * message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`. + * @since v0.1.21 + */ + function notEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * **Strict assertion mode** + * + * An alias of {@link deepStrictEqual}. + * + * **Legacy assertion mode** + * + * > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead. + * + * Tests for deep equality between the `actual` and `expected` parameters. Consider + * using {@link deepStrictEqual} instead. {@link deepEqual} can have + * surprising results. + * + * _Deep equality_ means that the enumerable "own" properties of child objects + * are also recursively evaluated by the following rules. + * @since v0.1.21 + */ + function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * **Strict assertion mode** + * + * An alias of {@link notDeepStrictEqual}. + * + * **Legacy assertion mode** + * + * > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead. + * + * Tests for any deep inequality. Opposite of {@link deepEqual}. + * + * ```js + * import assert from 'node:assert'; + * + * const obj1 = { + * a: { + * b: 1, + * }, + * }; + * const obj2 = { + * a: { + * b: 2, + * }, + * }; + * const obj3 = { + * a: { + * b: 1, + * }, + * }; + * const obj4 = { __proto__: obj1 }; + * + * assert.notDeepEqual(obj1, obj1); + * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } + * + * assert.notDeepEqual(obj1, obj2); + * // OK + * + * assert.notDeepEqual(obj1, obj3); + * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } + * + * assert.notDeepEqual(obj1, obj4); + * // OK + * ``` + * + * If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default + * error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown + * instead of the `AssertionError`. + * @since v0.1.21 + */ + function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * Tests strict equality between the `actual` and `expected` parameters as + * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.strictEqual(1, 2); + * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal: + * // + * // 1 !== 2 + * + * assert.strictEqual(1, 1); + * // OK + * + * assert.strictEqual('Hello foobar', 'Hello World!'); + * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal: + * // + actual - expected + * // + * // + 'Hello foobar' + * // - 'Hello World!' + * // ^ + * + * const apples = 1; + * const oranges = 2; + * assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`); + * // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2 + * + * assert.strictEqual(1, '1', new TypeError('Inputs are not identical')); + * // TypeError: Inputs are not identical + * ``` + * + * If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a + * default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown + * instead of the `AssertionError`. + * @since v0.1.21 + */ + function strictEqual(actual: unknown, expected: T, message?: string | Error): asserts actual is T; + /** + * Tests strict inequality between the `actual` and `expected` parameters as + * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.notStrictEqual(1, 2); + * // OK + * + * assert.notStrictEqual(1, 1); + * // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to: + * // + * // 1 + * + * assert.notStrictEqual(1, '1'); + * // OK + * ``` + * + * If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a + * default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown + * instead of the `AssertionError`. + * @since v0.1.21 + */ + function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * Tests for deep equality between the `actual` and `expected` parameters. + * "Deep" equality means that the enumerable "own" properties of child objects + * are recursively evaluated also by the following rules. + * @since v1.2.0 + */ + function deepStrictEqual(actual: unknown, expected: T, message?: string | Error): asserts actual is T; + /** + * Tests for deep strict inequality. Opposite of {@link deepStrictEqual}. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.notDeepStrictEqual({ a: 1 }, { a: '1' }); + * // OK + * ``` + * + * If the values are deeply and strictly equal, an `AssertionError` is thrown + * with a `message` property set equal to the value of the `message` parameter. If + * the `message` parameter is undefined, a default error message is assigned. If + * the `message` parameter is an instance of an `Error` then it will be thrown + * instead of the `AssertionError`. + * @since v1.2.0 + */ + function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void; + /** + * Expects the function `fn` to throw an error. + * + * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function, + * a validation object where each property will be tested for strict deep equality, + * or an instance of error where each property will be tested for strict deep + * equality including the non-enumerable `message` and `name` properties. When + * using an object, it is also possible to use a regular expression, when + * validating against a string property. See below for examples. + * + * If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation + * fails. + * + * Custom validation object/error instance: + * + * ```js + * import assert from 'node:assert/strict'; + * + * const err = new TypeError('Wrong value'); + * err.code = 404; + * err.foo = 'bar'; + * err.info = { + * nested: true, + * baz: 'text', + * }; + * err.reg = /abc/i; + * + * assert.throws( + * () => { + * throw err; + * }, + * { + * name: 'TypeError', + * message: 'Wrong value', + * info: { + * nested: true, + * baz: 'text', + * }, + * // Only properties on the validation object will be tested for. + * // Using nested objects requires all properties to be present. Otherwise + * // the validation is going to fail. + * }, + * ); + * + * // Using regular expressions to validate error properties: + * assert.throws( + * () => { + * throw err; + * }, + * { + * // The `name` and `message` properties are strings and using regular + * // expressions on those will match against the string. If they fail, an + * // error is thrown. + * name: /^TypeError$/, + * message: /Wrong/, + * foo: 'bar', + * info: { + * nested: true, + * // It is not possible to use regular expressions for nested properties! + * baz: 'text', + * }, + * // The `reg` property contains a regular expression and only if the + * // validation object contains an identical regular expression, it is going + * // to pass. + * reg: /abc/i, + * }, + * ); + * + * // Fails due to the different `message` and `name` properties: + * assert.throws( + * () => { + * const otherErr = new Error('Not found'); + * // Copy all enumerable properties from `err` to `otherErr`. + * for (const [key, value] of Object.entries(err)) { + * otherErr[key] = value; + * } + * throw otherErr; + * }, + * // The error's `message` and `name` properties will also be checked when using + * // an error as validation object. + * err, + * ); + * ``` + * + * Validate instanceof using constructor: + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.throws( + * () => { + * throw new Error('Wrong value'); + * }, + * Error, + * ); + * ``` + * + * Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions): + * + * Using a regular expression runs `.toString` on the error object, and will + * therefore also include the error name. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.throws( + * () => { + * throw new Error('Wrong value'); + * }, + * /^Error: Wrong value$/, + * ); + * ``` + * + * Custom error validation: + * + * The function must return `true` to indicate all internal validations passed. + * It will otherwise fail with an `AssertionError`. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.throws( + * () => { + * throw new Error('Wrong value'); + * }, + * (err) => { + * assert(err instanceof Error); + * assert(/value/.test(err)); + * // Avoid returning anything from validation functions besides `true`. + * // Otherwise, it's not clear what part of the validation failed. Instead, + * // throw an error about the specific validation that failed (as done in this + * // example) and add as much helpful debugging information to that error as + * // possible. + * return true; + * }, + * 'unexpected error', + * ); + * ``` + * + * `error` cannot be a string. If a string is provided as the second + * argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same + * message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using + * a string as the second argument gets considered: + * + * ```js + * import assert from 'node:assert/strict'; + * + * function throwingFirst() { + * throw new Error('First'); + * } + * + * function throwingSecond() { + * throw new Error('Second'); + * } + * + * function notThrowing() {} + * + * // The second argument is a string and the input function threw an Error. + * // The first case will not throw as it does not match for the error message + * // thrown by the input function! + * assert.throws(throwingFirst, 'Second'); + * // In the next example the message has no benefit over the message from the + * // error and since it is not clear if the user intended to actually match + * // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error. + * assert.throws(throwingSecond, 'Second'); + * // TypeError [ERR_AMBIGUOUS_ARGUMENT] + * + * // The string is only used (as message) in case the function does not throw: + * assert.throws(notThrowing, 'Second'); + * // AssertionError [ERR_ASSERTION]: Missing expected exception: Second + * + * // If it was intended to match for the error message do this instead: + * // It does not throw because the error messages match. + * assert.throws(throwingSecond, /Second$/); + * + * // If the error message does not match, an AssertionError is thrown. + * assert.throws(throwingFirst, /Second$/); + * // AssertionError [ERR_ASSERTION] + * ``` + * + * Due to the confusing error-prone notation, avoid a string as the second + * argument. + * @since v0.1.21 + */ + function throws(block: () => unknown, message?: string | Error): void; + function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void; + /** + * Asserts that the function `fn` does not throw an error. + * + * Using `assert.doesNotThrow()` is actually not useful because there + * is no benefit in catching an error and then rethrowing it. Instead, consider + * adding a comment next to the specific code path that should not throw and keep + * error messages as expressive as possible. + * + * When `assert.doesNotThrow()` is called, it will immediately call the `fn`function. + * + * If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a + * different type, or if the `error` parameter is undefined, the error is + * propagated back to the caller. + * + * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation + * function. See {@link throws} for more details. + * + * The following, for instance, will throw the `TypeError` because there is no + * matching error type in the assertion: + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * SyntaxError, + * ); + * ``` + * + * However, the following will result in an `AssertionError` with the message + * 'Got unwanted exception...': + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * TypeError, + * ); + * ``` + * + * If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message: + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * /Wrong value/, + * 'Whoops', + * ); + * // Throws: AssertionError: Got unwanted exception: Whoops + * ``` + * @since v0.1.21 + */ + function doesNotThrow(block: () => unknown, message?: string | Error): void; + function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void; + /** + * Throws `value` if `value` is not `undefined` or `null`. This is useful when + * testing the `error` argument in callbacks. The stack trace contains all frames + * from the error passed to `ifError()` including the potential new frames for`ifError()` itself. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.ifError(null); + * // OK + * assert.ifError(0); + * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0 + * assert.ifError('error'); + * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error' + * assert.ifError(new Error()); + * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error + * + * // Create some random error frames. + * let err; + * (function errorFrame() { + * err = new Error('test error'); + * })(); + * + * (function ifErrorFrame() { + * assert.ifError(err); + * })(); + * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error + * // at ifErrorFrame + * // at errorFrame + * ``` + * @since v0.1.97 + */ + function ifError(value: unknown): asserts value is null | undefined; + /** + * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately + * calls the function and awaits the returned promise to complete. It will then + * check that the promise is rejected. + * + * If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the + * function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error + * handler is skipped. + * + * Besides the async nature to await the completion behaves identically to {@link throws}. + * + * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function, + * an object where each property will be tested for, or an instance of error where + * each property will be tested for including the non-enumerable `message` and`name` properties. + * + * If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject. + * + * ```js + * import assert from 'node:assert/strict'; + * + * await assert.rejects( + * async () => { + * throw new TypeError('Wrong value'); + * }, + * { + * name: 'TypeError', + * message: 'Wrong value', + * }, + * ); + * ``` + * + * ```js + * import assert from 'node:assert/strict'; + * + * await assert.rejects( + * async () => { + * throw new TypeError('Wrong value'); + * }, + * (err) => { + * assert.strictEqual(err.name, 'TypeError'); + * assert.strictEqual(err.message, 'Wrong value'); + * return true; + * }, + * ); + * ``` + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.rejects( + * Promise.reject(new Error('Wrong value')), + * Error, + * ).then(() => { + * // ... + * }); + * ``` + * + * `error` cannot be a string. If a string is provided as the second + * argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the + * example in {@link throws} carefully if using a string as the second + * argument gets considered. + * @since v10.0.0 + */ + function rejects(block: (() => Promise) | Promise, message?: string | Error): Promise; + function rejects( + block: (() => Promise) | Promise, + error: AssertPredicate, + message?: string | Error, + ): Promise; + /** + * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately + * calls the function and awaits the returned promise to complete. It will then + * check that the promise is not rejected. + * + * If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If + * the function does not return a promise, `assert.doesNotReject()` will return a + * rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases + * the error handler is skipped. + * + * Using `assert.doesNotReject()` is actually not useful because there is little + * benefit in catching a rejection and then rejecting it again. Instead, consider + * adding a comment next to the specific code path that should not reject and keep + * error messages as expressive as possible. + * + * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), + * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation + * function. See {@link throws} for more details. + * + * Besides the async nature to await the completion behaves identically to {@link doesNotThrow}. + * + * ```js + * import assert from 'node:assert/strict'; + * + * await assert.doesNotReject( + * async () => { + * throw new TypeError('Wrong value'); + * }, + * SyntaxError, + * ); + * ``` + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotReject(Promise.reject(new TypeError('Wrong value'))) + * .then(() => { + * // ... + * }); + * ``` + * @since v10.0.0 + */ + function doesNotReject( + block: (() => Promise) | Promise, + message?: string | Error, + ): Promise; + function doesNotReject( + block: (() => Promise) | Promise, + error: AssertPredicate, + message?: string | Error, + ): Promise; + /** + * Expects the `string` input to match the regular expression. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.match('I will fail', /pass/); + * // AssertionError [ERR_ASSERTION]: The input did not match the regular ... + * + * assert.match(123, /pass/); + * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string. + * + * assert.match('I will pass', /pass/); + * // OK + * ``` + * + * If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal + * to the value of the `message` parameter. If the `message` parameter is + * undefined, a default error message is assigned. If the `message` parameter is an + * instance of an `Error` then it will be thrown instead of the `AssertionError`. + * @since v13.6.0, v12.16.0 + */ + function match(value: string, regExp: RegExp, message?: string | Error): void; + /** + * Expects the `string` input not to match the regular expression. + * + * ```js + * import assert from 'node:assert/strict'; + * + * assert.doesNotMatch('I will fail', /fail/); + * // AssertionError [ERR_ASSERTION]: The input was expected to not match the ... + * + * assert.doesNotMatch(123, /pass/); + * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string. + * + * assert.doesNotMatch('I will pass', /different/); + * // OK + * ``` + * + * If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal + * to the value of the `message` parameter. If the `message` parameter is + * undefined, a default error message is assigned. If the `message` parameter is an + * instance of an `Error` then it will be thrown instead of the `AssertionError`. + * @since v13.6.0, v12.16.0 + */ + function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void; + const strict: + & Omit< + typeof assert, + | "equal" + | "notEqual" + | "deepEqual" + | "notDeepEqual" + | "ok" + | "strictEqual" + | "deepStrictEqual" + | "ifError" + | "strict" + > + & { + (value: unknown, message?: string | Error): asserts value; + equal: typeof strictEqual; + notEqual: typeof notStrictEqual; + deepEqual: typeof deepStrictEqual; + notDeepEqual: typeof notDeepStrictEqual; + // Mapped types and assertion functions are incompatible? + // TS2775: Assertions require every name in the call target + // to be declared with an explicit type annotation. + ok: typeof ok; + strictEqual: typeof strictEqual; + deepStrictEqual: typeof deepStrictEqual; + ifError: typeof ifError; + strict: typeof strict; + }; + } + export = assert; +} +declare module "node:assert" { + import assert = require("assert"); + export = assert; +} diff --git a/node_modules/@types/node/ts4.8/assert/strict.d.ts b/node_modules/@types/node/ts4.8/assert/strict.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f333913a4565f7067b05ddbc415490e585f2d1e1 --- /dev/null +++ b/node_modules/@types/node/ts4.8/assert/strict.d.ts @@ -0,0 +1,8 @@ +declare module "assert/strict" { + import { strict } from "node:assert"; + export = strict; +} +declare module "node:assert/strict" { + import { strict } from "node:assert"; + export = strict; +} diff --git a/node_modules/@types/node/ts4.8/async_hooks.d.ts b/node_modules/@types/node/ts4.8/async_hooks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0667a6150af717a759e15e4fe04b6d29fe533411 --- /dev/null +++ b/node_modules/@types/node/ts4.8/async_hooks.d.ts @@ -0,0 +1,539 @@ +/** + * We strongly discourage the use of the `async_hooks` API. + * Other APIs that can cover most of its use cases include: + * + * * `AsyncLocalStorage` tracks async context + * * `process.getActiveResourcesInfo()` tracks active resources + * + * The `node:async_hooks` module provides an API to track asynchronous resources. + * It can be accessed using: + * + * ```js + * import async_hooks from 'node:async_hooks'; + * ``` + * @experimental + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/async_hooks.js) + */ +declare module "async_hooks" { + /** + * ```js + * import { executionAsyncId } from 'node:async_hooks'; + * import fs from 'node:fs'; + * + * console.log(executionAsyncId()); // 1 - bootstrap + * const path = '.'; + * fs.open(path, 'r', (err, fd) => { + * console.log(executionAsyncId()); // 6 - open() + * }); + * ``` + * + * The ID returned from `executionAsyncId()` is related to execution timing, not + * causality (which is covered by `triggerAsyncId()`): + * + * ```js + * const server = net.createServer((conn) => { + * // Returns the ID of the server, not of the new connection, because the + * // callback runs in the execution scope of the server's MakeCallback(). + * async_hooks.executionAsyncId(); + * + * }).listen(port, () => { + * // Returns the ID of a TickObject (process.nextTick()) because all + * // callbacks passed to .listen() are wrapped in a nextTick(). + * async_hooks.executionAsyncId(); + * }); + * ``` + * + * Promise contexts may not get precise `executionAsyncIds` by default. + * See the section on `promise execution tracking`. + * @since v8.1.0 + * @return The `asyncId` of the current execution context. Useful to track when something calls. + */ + function executionAsyncId(): number; + /** + * Resource objects returned by `executionAsyncResource()` are most often internal + * Node.js handle objects with undocumented APIs. Using any functions or properties + * on the object is likely to crash your application and should be avoided. + * + * Using `executionAsyncResource()` in the top-level execution context will + * return an empty object as there is no handle or request object to use, + * but having an object representing the top-level can be helpful. + * + * ```js + * import { open } from 'node:fs'; + * import { executionAsyncId, executionAsyncResource } from 'node:async_hooks'; + * + * console.log(executionAsyncId(), executionAsyncResource()); // 1 {} + * open(new URL(import.meta.url), 'r', (err, fd) => { + * console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap + * }); + * ``` + * + * This can be used to implement continuation local storage without the + * use of a tracking `Map` to store the metadata: + * + * ```js + * import { createServer } from 'node:http'; + * import { + * executionAsyncId, + * executionAsyncResource, + * createHook, + * } from 'async_hooks'; + * const sym = Symbol('state'); // Private symbol to avoid pollution + * + * createHook({ + * init(asyncId, type, triggerAsyncId, resource) { + * const cr = executionAsyncResource(); + * if (cr) { + * resource[sym] = cr[sym]; + * } + * }, + * }).enable(); + * + * const server = createServer((req, res) => { + * executionAsyncResource()[sym] = { state: req.url }; + * setTimeout(function() { + * res.end(JSON.stringify(executionAsyncResource()[sym])); + * }, 100); + * }).listen(3000); + * ``` + * @since v13.9.0, v12.17.0 + * @return The resource representing the current execution. Useful to store data within the resource. + */ + function executionAsyncResource(): object; + /** + * ```js + * const server = net.createServer((conn) => { + * // The resource that caused (or triggered) this callback to be called + * // was that of the new connection. Thus the return value of triggerAsyncId() + * // is the asyncId of "conn". + * async_hooks.triggerAsyncId(); + * + * }).listen(port, () => { + * // Even though all callbacks passed to .listen() are wrapped in a nextTick() + * // the callback itself exists because the call to the server's .listen() + * // was made. So the return value would be the ID of the server. + * async_hooks.triggerAsyncId(); + * }); + * ``` + * + * Promise contexts may not get valid `triggerAsyncId`s by default. See + * the section on `promise execution tracking`. + * @return The ID of the resource responsible for calling the callback that is currently being executed. + */ + function triggerAsyncId(): number; + interface HookCallbacks { + /** + * Called when a class is constructed that has the possibility to emit an asynchronous event. + * @param asyncId a unique ID for the async resource + * @param type the type of the async resource + * @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created + * @param resource reference to the resource representing the async operation, needs to be released during destroy + */ + init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void; + /** + * When an asynchronous operation is initiated or completes a callback is called to notify the user. + * The before callback is called just before said callback is executed. + * @param asyncId the unique identifier assigned to the resource about to execute the callback. + */ + before?(asyncId: number): void; + /** + * Called immediately after the callback specified in before is completed. + * @param asyncId the unique identifier assigned to the resource which has executed the callback. + */ + after?(asyncId: number): void; + /** + * Called when a promise has resolve() called. This may not be in the same execution id + * as the promise itself. + * @param asyncId the unique id for the promise that was resolve()d. + */ + promiseResolve?(asyncId: number): void; + /** + * Called after the resource corresponding to asyncId is destroyed + * @param asyncId a unique ID for the async resource + */ + destroy?(asyncId: number): void; + } + interface AsyncHook { + /** + * Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop. + */ + enable(): this; + /** + * Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled. + */ + disable(): this; + } + /** + * Registers functions to be called for different lifetime events of each async + * operation. + * + * The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the + * respective asynchronous event during a resource's lifetime. + * + * All callbacks are optional. For example, if only resource cleanup needs to + * be tracked, then only the `destroy` callback needs to be passed. The + * specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section. + * + * ```js + * import { createHook } from 'node:async_hooks'; + * + * const asyncHook = createHook({ + * init(asyncId, type, triggerAsyncId, resource) { }, + * destroy(asyncId) { }, + * }); + * ``` + * + * The callbacks will be inherited via the prototype chain: + * + * ```js + * class MyAsyncCallbacks { + * init(asyncId, type, triggerAsyncId, resource) { } + * destroy(asyncId) {} + * } + * + * class MyAddedCallbacks extends MyAsyncCallbacks { + * before(asyncId) { } + * after(asyncId) { } + * } + * + * const asyncHook = async_hooks.createHook(new MyAddedCallbacks()); + * ``` + * + * Because promises are asynchronous resources whose lifecycle is tracked + * via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises. + * @since v8.1.0 + * @param callbacks The `Hook Callbacks` to register + * @return Instance used for disabling and enabling hooks + */ + function createHook(callbacks: HookCallbacks): AsyncHook; + interface AsyncResourceOptions { + /** + * The ID of the execution context that created this async event. + * @default executionAsyncId() + */ + triggerAsyncId?: number | undefined; + /** + * Disables automatic `emitDestroy` when the object is garbage collected. + * This usually does not need to be set (even if `emitDestroy` is called + * manually), unless the resource's `asyncId` is retrieved and the + * sensitive API's `emitDestroy` is called with it. + * @default false + */ + requireManualDestroy?: boolean | undefined; + } + /** + * The class `AsyncResource` is designed to be extended by the embedder's async + * resources. Using this, users can easily trigger the lifetime events of their + * own resources. + * + * The `init` hook will trigger when an `AsyncResource` is instantiated. + * + * The following is an overview of the `AsyncResource` API. + * + * ```js + * import { AsyncResource, executionAsyncId } from 'node:async_hooks'; + * + * // AsyncResource() is meant to be extended. Instantiating a + * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then + * // async_hook.executionAsyncId() is used. + * const asyncResource = new AsyncResource( + * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }, + * ); + * + * // Run a function in the execution context of the resource. This will + * // * establish the context of the resource + * // * trigger the AsyncHooks before callbacks + * // * call the provided function `fn` with the supplied arguments + * // * trigger the AsyncHooks after callbacks + * // * restore the original execution context + * asyncResource.runInAsyncScope(fn, thisArg, ...args); + * + * // Call AsyncHooks destroy callbacks. + * asyncResource.emitDestroy(); + * + * // Return the unique ID assigned to the AsyncResource instance. + * asyncResource.asyncId(); + * + * // Return the trigger ID for the AsyncResource instance. + * asyncResource.triggerAsyncId(); + * ``` + */ + class AsyncResource { + /** + * AsyncResource() is meant to be extended. Instantiating a + * new AsyncResource() also triggers init. If triggerAsyncId is omitted then + * async_hook.executionAsyncId() is used. + * @param type The type of async event. + * @param triggerAsyncId The ID of the execution context that created + * this async event (default: `executionAsyncId()`), or an + * AsyncResourceOptions object (since v9.3.0) + */ + constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions); + /** + * Binds the given function to the current execution context. + * @since v14.8.0, v12.19.0 + * @param fn The function to bind to the current execution context. + * @param type An optional name to associate with the underlying `AsyncResource`. + */ + static bind any, ThisArg>( + fn: Func, + type?: string, + thisArg?: ThisArg, + ): Func; + /** + * Binds the given function to execute to this `AsyncResource`'s scope. + * @since v14.8.0, v12.19.0 + * @param fn The function to bind to the current `AsyncResource`. + */ + bind any>(fn: Func): Func; + /** + * Call the provided function with the provided arguments in the execution context + * of the async resource. This will establish the context, trigger the AsyncHooks + * before callbacks, call the function, trigger the AsyncHooks after callbacks, and + * then restore the original execution context. + * @since v9.6.0 + * @param fn The function to call in the execution context of this async resource. + * @param thisArg The receiver to be used for the function call. + * @param args Optional arguments to pass to the function. + */ + runInAsyncScope( + fn: (this: This, ...args: any[]) => Result, + thisArg?: This, + ...args: any[] + ): Result; + /** + * Call all `destroy` hooks. This should only ever be called once. An error will + * be thrown if it is called more than once. This **must** be manually called. If + * the resource is left to be collected by the GC then the `destroy` hooks will + * never be called. + * @return A reference to `asyncResource`. + */ + emitDestroy(): this; + /** + * @return The unique `asyncId` assigned to the resource. + */ + asyncId(): number; + /** + * @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor. + */ + triggerAsyncId(): number; + } + /** + * This class creates stores that stay coherent through asynchronous operations. + * + * While you can create your own implementation on top of the `node:async_hooks`module, `AsyncLocalStorage` should be preferred as it is a performant and memory + * safe implementation that involves significant optimizations that are non-obvious + * to implement. + * + * The following example uses `AsyncLocalStorage` to build a simple logger + * that assigns IDs to incoming HTTP requests and includes them in messages + * logged within each request. + * + * ```js + * import http from 'node:http'; + * import { AsyncLocalStorage } from 'node:async_hooks'; + * + * const asyncLocalStorage = new AsyncLocalStorage(); + * + * function logWithId(msg) { + * const id = asyncLocalStorage.getStore(); + * console.log(`${id !== undefined ? id : '-'}:`, msg); + * } + * + * let idSeq = 0; + * http.createServer((req, res) => { + * asyncLocalStorage.run(idSeq++, () => { + * logWithId('start'); + * // Imagine any chain of async operations here + * setImmediate(() => { + * logWithId('finish'); + * res.end(); + * }); + * }); + * }).listen(8080); + * + * http.get('http://localhost:8080'); + * http.get('http://localhost:8080'); + * // Prints: + * // 0: start + * // 1: start + * // 0: finish + * // 1: finish + * ``` + * + * Each instance of `AsyncLocalStorage` maintains an independent storage context. + * Multiple instances can safely exist simultaneously without risk of interfering + * with each other's data. + * @since v13.10.0, v12.17.0 + */ + class AsyncLocalStorage { + /** + * Binds the given function to the current execution context. + * @since v19.8.0 + * @experimental + * @param fn The function to bind to the current execution context. + * @return A new function that calls `fn` within the captured execution context. + */ + static bind any>(fn: Func): Func; + /** + * Captures the current execution context and returns a function that accepts a + * function as an argument. Whenever the returned function is called, it + * calls the function passed to it within the captured context. + * + * ```js + * const asyncLocalStorage = new AsyncLocalStorage(); + * const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot()); + * const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore())); + * console.log(result); // returns 123 + * ``` + * + * AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple + * async context tracking purposes, for example: + * + * ```js + * class Foo { + * #runInAsyncScope = AsyncLocalStorage.snapshot(); + * + * get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); } + * } + * + * const foo = asyncLocalStorage.run(123, () => new Foo()); + * console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123 + * ``` + * @since v19.8.0 + * @experimental + * @return A new function with the signature `(fn: (...args) : R, ...args) : R`. + */ + static snapshot(): (fn: (...args: TArgs) => R, ...args: TArgs) => R; + /** + * Disables the instance of `AsyncLocalStorage`. All subsequent calls + * to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again. + * + * When calling `asyncLocalStorage.disable()`, all current contexts linked to the + * instance will be exited. + * + * Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores + * provided by the `asyncLocalStorage`, as those objects are garbage collected + * along with the corresponding async resources. + * + * Use this method when the `asyncLocalStorage` is not in use anymore + * in the current process. + * @since v13.10.0, v12.17.0 + * @experimental + */ + disable(): void; + /** + * Returns the current store. + * If called outside of an asynchronous context initialized by + * calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it + * returns `undefined`. + * @since v13.10.0, v12.17.0 + */ + getStore(): T | undefined; + /** + * Runs a function synchronously within a context and returns its + * return value. The store is not accessible outside of the callback function. + * The store is accessible to any asynchronous operations created within the + * callback. + * + * The optional `args` are passed to the callback function. + * + * If the callback function throws an error, the error is thrown by `run()` too. + * The stacktrace is not impacted by this call and the context is exited. + * + * Example: + * + * ```js + * const store = { id: 2 }; + * try { + * asyncLocalStorage.run(store, () => { + * asyncLocalStorage.getStore(); // Returns the store object + * setTimeout(() => { + * asyncLocalStorage.getStore(); // Returns the store object + * }, 200); + * throw new Error(); + * }); + * } catch (e) { + * asyncLocalStorage.getStore(); // Returns undefined + * // The error will be caught here + * } + * ``` + * @since v13.10.0, v12.17.0 + */ + run(store: T, callback: () => R): R; + run(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R; + /** + * Runs a function synchronously outside of a context and returns its + * return value. The store is not accessible within the callback function or + * the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`. + * + * The optional `args` are passed to the callback function. + * + * If the callback function throws an error, the error is thrown by `exit()` too. + * The stacktrace is not impacted by this call and the context is re-entered. + * + * Example: + * + * ```js + * // Within a call to run + * try { + * asyncLocalStorage.getStore(); // Returns the store object or value + * asyncLocalStorage.exit(() => { + * asyncLocalStorage.getStore(); // Returns undefined + * throw new Error(); + * }); + * } catch (e) { + * asyncLocalStorage.getStore(); // Returns the same object or value + * // The error will be caught here + * } + * ``` + * @since v13.10.0, v12.17.0 + * @experimental + */ + exit(callback: (...args: TArgs) => R, ...args: TArgs): R; + /** + * Transitions into the context for the remainder of the current + * synchronous execution and then persists the store through any following + * asynchronous calls. + * + * Example: + * + * ```js + * const store = { id: 1 }; + * // Replaces previous store with the given store object + * asyncLocalStorage.enterWith(store); + * asyncLocalStorage.getStore(); // Returns the store object + * someAsyncOperation(() => { + * asyncLocalStorage.getStore(); // Returns the same object + * }); + * ``` + * + * This transition will continue for the _entire_ synchronous execution. + * This means that if, for example, the context is entered within an event + * handler subsequent event handlers will also run within that context unless + * specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons + * to use the latter method. + * + * ```js + * const store = { id: 1 }; + * + * emitter.on('my-event', () => { + * asyncLocalStorage.enterWith(store); + * }); + * emitter.on('my-event', () => { + * asyncLocalStorage.getStore(); // Returns the same object + * }); + * + * asyncLocalStorage.getStore(); // Returns undefined + * emitter.emit('my-event'); + * asyncLocalStorage.getStore(); // Returns the same object + * ``` + * @since v13.11.0, v12.17.0 + * @experimental + */ + enterWith(store: T): void; + } +} +declare module "node:async_hooks" { + export * from "async_hooks"; +} diff --git a/node_modules/@types/node/ts4.8/buffer.d.ts b/node_modules/@types/node/ts4.8/buffer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ee5c013552af28e2d3babe3e3e3c1ed8b30206d --- /dev/null +++ b/node_modules/@types/node/ts4.8/buffer.d.ts @@ -0,0 +1,2362 @@ +/** + * `Buffer` objects are used to represent a fixed-length sequence of bytes. Many + * Node.js APIs support `Buffer`s. + * + * The `Buffer` class is a subclass of JavaScript's [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) class and + * extends it with methods that cover additional use cases. Node.js APIs accept + * plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) s wherever `Buffer`s are supported as well. + * + * While the `Buffer` class is available within the global scope, it is still + * recommended to explicitly reference it via an import or require statement. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Creates a zero-filled Buffer of length 10. + * const buf1 = Buffer.alloc(10); + * + * // Creates a Buffer of length 10, + * // filled with bytes which all have the value `1`. + * const buf2 = Buffer.alloc(10, 1); + * + * // Creates an uninitialized buffer of length 10. + * // This is faster than calling Buffer.alloc() but the returned + * // Buffer instance might contain old data that needs to be + * // overwritten using fill(), write(), or other functions that fill the Buffer's + * // contents. + * const buf3 = Buffer.allocUnsafe(10); + * + * // Creates a Buffer containing the bytes [1, 2, 3]. + * const buf4 = Buffer.from([1, 2, 3]); + * + * // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries + * // are all truncated using `(value & 255)` to fit into the range 0–255. + * const buf5 = Buffer.from([257, 257.5, -255, '1']); + * + * // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést': + * // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation) + * // [116, 195, 169, 115, 116] (in decimal notation) + * const buf6 = Buffer.from('tést'); + * + * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74]. + * const buf7 = Buffer.from('tést', 'latin1'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/buffer.js) + */ +declare module "buffer" { + import { BinaryLike } from "node:crypto"; + import { ReadableStream as WebReadableStream } from "node:stream/web"; + /** + * This function returns `true` if `input` contains only valid UTF-8-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since v19.4.0, v18.14.0 + * @param input The input to validate. + */ + export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean; + /** + * This function returns `true` if `input` contains only valid ASCII-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since v19.6.0, v18.15.0 + * @param input The input to validate. + */ + export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean; + export const INSPECT_MAX_BYTES: number; + export const kMaxLength: number; + export const kStringMaxLength: number; + export const constants: { + MAX_LENGTH: number; + MAX_STRING_LENGTH: number; + }; + export type TranscodeEncoding = + | "ascii" + | "utf8" + | "utf-8" + | "utf16le" + | "utf-16le" + | "ucs2" + | "ucs-2" + | "latin1" + | "binary"; + /** + * Re-encodes the given `Buffer` or `Uint8Array` instance from one character + * encoding to another. Returns a new `Buffer` instance. + * + * Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if + * conversion from `fromEnc` to `toEnc` is not permitted. + * + * Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`,`'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`. + * + * The transcoding process will use substitution characters if a given byte + * sequence cannot be adequately represented in the target encoding. For instance: + * + * ```js + * import { Buffer, transcode } from 'node:buffer'; + * + * const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii'); + * console.log(newBuf.toString('ascii')); + * // Prints: '?' + * ``` + * + * Because the Euro (`€`) sign is not representable in US-ASCII, it is replaced + * with `?` in the transcoded `Buffer`. + * @since v7.1.0 + * @param source A `Buffer` or `Uint8Array` instance. + * @param fromEnc The current encoding. + * @param toEnc To target encoding. + */ + export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer; + export const SlowBuffer: { + /** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */ + new(size: number): Buffer; + prototype: Buffer; + }; + /** + * Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using + * a prior call to `URL.createObjectURL()`. + * @since v16.7.0 + * @experimental + * @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`. + */ + export function resolveObjectURL(id: string): Blob | undefined; + export { Buffer }; + /** + * @experimental + */ + export interface BlobOptions { + /** + * @default 'utf8' + */ + encoding?: BufferEncoding | undefined; + /** + * The Blob content-type. The intent is for `type` to convey + * the MIME media type of the data, however no validation of the type format + * is performed. + */ + type?: string | undefined; + } + /** + * A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across + * multiple worker threads. + * @since v15.7.0, v14.18.0 + */ + export class Blob { + /** + * The total size of the `Blob` in bytes. + * @since v15.7.0, v14.18.0 + */ + readonly size: number; + /** + * The content-type of the `Blob`. + * @since v15.7.0, v14.18.0 + */ + readonly type: string; + /** + * Creates a new `Blob` object containing a concatenation of the given sources. + * + * {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into + * the 'Blob' and can therefore be safely modified after the 'Blob' is created. + * + * String sources are also copied into the `Blob`. + */ + constructor(sources: Array, options?: BlobOptions); + /** + * Returns a promise that fulfills with an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) containing a copy of + * the `Blob` data. + * @since v15.7.0, v14.18.0 + */ + arrayBuffer(): Promise; + /** + * Creates and returns a new `Blob` containing a subset of this `Blob` objects + * data. The original `Blob` is not altered. + * @since v15.7.0, v14.18.0 + * @param start The starting index. + * @param end The ending index. + * @param type The content-type for the new `Blob` + */ + slice(start?: number, end?: number, type?: string): Blob; + /** + * Returns a promise that fulfills with the contents of the `Blob` decoded as a + * UTF-8 string. + * @since v15.7.0, v14.18.0 + */ + text(): Promise; + /** + * Returns a new `ReadableStream` that allows the content of the `Blob` to be read. + * @since v16.7.0 + */ + stream(): WebReadableStream; + } + export interface FileOptions { + /** + * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be + * converted to the platform native line-ending as specified by `require('node:os').EOL`. + */ + endings?: "native" | "transparent"; + /** The File content-type. */ + type?: string; + /** The last modified date of the file. `Default`: Date.now(). */ + lastModified?: number; + } + /** + * A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files. + * @since v19.2.0, v18.13.0 + */ + export class File extends Blob { + constructor(sources: Array, fileName: string, options?: FileOptions); + /** + * The name of the `File`. + * @since v19.2.0, v18.13.0 + */ + readonly name: string; + /** + * The last modified date of the `File`. + * @since v19.2.0, v18.13.0 + */ + readonly lastModified: number; + } + export import atob = globalThis.atob; + export import btoa = globalThis.btoa; + import { Blob as NodeBlob } from "buffer"; + // This conditional type will be the existing global Blob in a browser, or + // the copy below in a Node environment. + type __Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : NodeBlob; + global { + namespace NodeJS { + export { BufferEncoding }; + } + // Buffer class + type BufferEncoding = + | "ascii" + | "utf8" + | "utf-8" + | "utf16le" + | "utf-16le" + | "ucs2" + | "ucs-2" + | "base64" + | "base64url" + | "latin1" + | "binary" + | "hex"; + type WithImplicitCoercion = + | T + | { + valueOf(): T; + }; + /** + * Raw data is stored in instances of the Buffer class. + * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. + * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex' + */ + interface BufferConstructor { + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead. + */ + new(str: string, encoding?: BufferEncoding): Buffer; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`). + */ + new(size: number): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead. + */ + new(array: Uint8Array): Buffer; + /** + * Produces a Buffer backed by the same allocated memory as + * the given {ArrayBuffer}/{SharedArrayBuffer}. + * + * @param arrayBuffer The ArrayBuffer with which to share memory. + * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead. + */ + new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead. + */ + new(array: readonly any[]): Buffer; + /** + * Copies the passed {buffer} data onto a new {Buffer} instance. + * + * @param buffer The buffer to copy. + * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead. + */ + new(buffer: Buffer): Buffer; + /** + * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`. + * Array entries outside that range will be truncated to fit into it. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'. + * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); + * ``` + * + * If `array` is an `Array`\-like object (that is, one with a `length` property of + * type `number`), it is treated as if it is an array, unless it is a `Buffer` or + * a `Uint8Array`. This means all other `TypedArray` variants get treated as an`Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`. + * + * A `TypeError` will be thrown if `array` is not an `Array` or another type + * appropriate for `Buffer.from()` variants. + * + * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does. + * @since v5.10.0 + */ + from( + arrayBuffer: WithImplicitCoercion, + byteOffset?: number, + length?: number, + ): Buffer; + /** + * Creates a new Buffer using the passed {data} + * @param data data to create a new Buffer + */ + from(data: Uint8Array | readonly number[]): Buffer; + from(data: WithImplicitCoercion): Buffer; + /** + * Creates a new Buffer containing the given JavaScript string {str}. + * If provided, the {encoding} parameter identifies the character encoding. + * If not provided, {encoding} defaults to 'utf8'. + */ + from( + str: + | WithImplicitCoercion + | { + [Symbol.toPrimitive](hint: "string"): string; + }, + encoding?: BufferEncoding, + ): Buffer; + /** + * Creates a new Buffer using the passed {data} + * @param values to create a new Buffer + */ + of(...items: number[]): Buffer; + /** + * Returns `true` if `obj` is a `Buffer`, `false` otherwise. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * Buffer.isBuffer(Buffer.alloc(10)); // true + * Buffer.isBuffer(Buffer.from('foo')); // true + * Buffer.isBuffer('a string'); // false + * Buffer.isBuffer([]); // false + * Buffer.isBuffer(new Uint8Array(1024)); // false + * ``` + * @since v0.1.101 + */ + isBuffer(obj: any): obj is Buffer; + /** + * Returns `true` if `encoding` is the name of a supported character encoding, + * or `false` otherwise. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * console.log(Buffer.isEncoding('utf8')); + * // Prints: true + * + * console.log(Buffer.isEncoding('hex')); + * // Prints: true + * + * console.log(Buffer.isEncoding('utf/8')); + * // Prints: false + * + * console.log(Buffer.isEncoding('')); + * // Prints: false + * ``` + * @since v0.9.1 + * @param encoding A character encoding name to check. + */ + isEncoding(encoding: string): encoding is BufferEncoding; + /** + * Returns the byte length of a string when encoded using `encoding`. + * This is not the same as [`String.prototype.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), which does not account + * for the encoding that is used to convert the string into bytes. + * + * For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input. + * For strings that contain non-base64/hex-encoded data (e.g. whitespace), the + * return value might be greater than the length of a `Buffer` created from the + * string. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const str = '\u00bd + \u00bc = \u00be'; + * + * console.log(`${str}: ${str.length} characters, ` + + * `${Buffer.byteLength(str, 'utf8')} bytes`); + * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes + * ``` + * + * When `string` is a + * `Buffer`/[`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)/[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/- + * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop- + * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned. + * @since v0.1.90 + * @param string A value to calculate the length of. + * @param [encoding='utf8'] If `string` is a string, this is its encoding. + * @return The number of bytes contained within `string`. + */ + byteLength( + string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, + encoding?: BufferEncoding, + ): number; + /** + * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together. + * + * If the list has no items, or if the `totalLength` is 0, then a new zero-length`Buffer` is returned. + * + * If `totalLength` is not provided, it is calculated from the `Buffer` instances + * in `list` by adding their lengths. + * + * If `totalLength` is provided, it is coerced to an unsigned integer. If the + * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is + * truncated to `totalLength`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Create a single `Buffer` from a list of three `Buffer` instances. + * + * const buf1 = Buffer.alloc(10); + * const buf2 = Buffer.alloc(14); + * const buf3 = Buffer.alloc(18); + * const totalLength = buf1.length + buf2.length + buf3.length; + * + * console.log(totalLength); + * // Prints: 42 + * + * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength); + * + * console.log(bufA); + * // Prints: + * console.log(bufA.length); + * // Prints: 42 + * ``` + * + * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does. + * @since v0.7.11 + * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate. + * @param totalLength Total length of the `Buffer` instances in `list` when concatenated. + */ + concat(list: readonly Uint8Array[], totalLength?: number): Buffer; + /** + * Copies the underlying memory of `view` into a new `Buffer`. + * + * ```js + * const u16 = new Uint16Array([0, 0xffff]); + * const buf = Buffer.copyBytesFrom(u16, 1, 1); + * u16[1] = 0; + * console.log(buf.length); // 2 + * console.log(buf[0]); // 255 + * console.log(buf[1]); // 255 + * ``` + * @since v19.8.0 + * @param view The {TypedArray} to copy. + * @param [offset=': 0'] The starting offset within `view`. + * @param [length=view.length - offset] The number of elements from `view` to copy. + */ + copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer; + /** + * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from('1234'); + * const buf2 = Buffer.from('0123'); + * const arr = [buf1, buf2]; + * + * console.log(arr.sort(Buffer.compare)); + * // Prints: [ , ] + * // (This result is equal to: [buf2, buf1].) + * ``` + * @since v0.11.13 + * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details. + */ + compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1; + /** + * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.alloc(5); + * + * console.log(buf); + * // Prints: + * ``` + * + * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. + * + * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.alloc(5, 'a'); + * + * console.log(buf); + * // Prints: + * ``` + * + * If both `fill` and `encoding` are specified, the allocated `Buffer` will be + * initialized by calling `buf.fill(fill, encoding)`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); + * + * console.log(buf); + * // Prints: + * ``` + * + * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance + * contents will never contain sensitive data from previous allocations, including + * data that might not have been allocated for `Buffer`s. + * + * A `TypeError` will be thrown if `size` is not a number. + * @since v5.10.0 + * @param size The desired length of the new `Buffer`. + * @param [fill=0] A value to pre-fill the new `Buffer` with. + * @param [encoding='utf8'] If `fill` is a string, this is its encoding. + */ + alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer; + /** + * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. + * + * The underlying memory for `Buffer` instances created in this way is _not_ + * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(10); + * + * console.log(buf); + * // Prints (contents may vary): + * + * buf.fill(0); + * + * console.log(buf); + * // Prints: + * ``` + * + * A `TypeError` will be thrown if `size` is not a number. + * + * The `Buffer` module pre-allocates an internal `Buffer` instance of + * size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`, + * and `Buffer.concat()` only when `size` is less than or equal to`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). + * + * Use of this pre-allocated internal memory pool is a key difference between + * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`. + * Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less + * than or equal to half `Buffer.poolSize`. The + * difference is subtle but can be important when an application requires the + * additional performance that `Buffer.allocUnsafe()` provides. + * @since v5.10.0 + * @param size The desired length of the new `Buffer`. + */ + allocUnsafe(size: number): Buffer; + /** + * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if + * `size` is 0. + * + * The underlying memory for `Buffer` instances created in this way is _not_ + * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize + * such `Buffer` instances with zeroes. + * + * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances, + * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This + * allows applications to avoid the garbage collection overhead of creating many + * individually allocated `Buffer` instances. This approach improves both + * performance and memory usage by eliminating the need to track and clean up as + * many individual `ArrayBuffer` objects. + * + * However, in the case where a developer may need to retain a small chunk of + * memory from a pool for an indeterminate amount of time, it may be appropriate + * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and + * then copying out the relevant bits. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Need to keep around a few small chunks of memory. + * const store = []; + * + * socket.on('readable', () => { + * let data; + * while (null !== (data = readable.read())) { + * // Allocate for retained data. + * const sb = Buffer.allocUnsafeSlow(10); + * + * // Copy the data into the new allocation. + * data.copy(sb, 0, 0, 10); + * + * store.push(sb); + * } + * }); + * ``` + * + * A `TypeError` will be thrown if `size` is not a number. + * @since v5.12.0 + * @param size The desired length of the new `Buffer`. + */ + allocUnsafeSlow(size: number): Buffer; + /** + * This is the size (in bytes) of pre-allocated internal `Buffer` instances used + * for pooling. This value may be modified. + * @since v0.11.3 + */ + poolSize: number; + } + interface Buffer extends Uint8Array { + /** + * Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did + * not contain enough space to fit the entire string, only part of `string` will be + * written. However, partially encoded characters will not be written. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.alloc(256); + * + * const len = buf.write('\u00bd + \u00bc = \u00be', 0); + * + * console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); + * // Prints: 12 bytes: ½ + ¼ = ¾ + * + * const buffer = Buffer.alloc(10); + * + * const length = buffer.write('abcd', 8); + * + * console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`); + * // Prints: 2 bytes : ab + * ``` + * @since v0.1.90 + * @param string String to write to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write `string`. + * @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`). + * @param [encoding='utf8'] The character encoding of `string`. + * @return Number of bytes written. + */ + write(string: string, encoding?: BufferEncoding): number; + write(string: string, offset: number, encoding?: BufferEncoding): number; + write(string: string, offset: number, length: number, encoding?: BufferEncoding): number; + /** + * Decodes `buf` to a string according to the specified character encoding in`encoding`. `start` and `end` may be passed to decode only a subset of `buf`. + * + * If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8, + * then each invalid byte is replaced with the replacement character `U+FFFD`. + * + * The maximum length of a string instance (in UTF-16 code units) is available + * as {@link constants.MAX_STRING_LENGTH}. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.allocUnsafe(26); + * + * for (let i = 0; i < 26; i++) { + * // 97 is the decimal ASCII value for 'a'. + * buf1[i] = i + 97; + * } + * + * console.log(buf1.toString('utf8')); + * // Prints: abcdefghijklmnopqrstuvwxyz + * console.log(buf1.toString('utf8', 0, 5)); + * // Prints: abcde + * + * const buf2 = Buffer.from('tést'); + * + * console.log(buf2.toString('hex')); + * // Prints: 74c3a97374 + * console.log(buf2.toString('utf8', 0, 3)); + * // Prints: té + * console.log(buf2.toString(undefined, 0, 3)); + * // Prints: té + * ``` + * @since v0.1.90 + * @param [encoding='utf8'] The character encoding to use. + * @param [start=0] The byte offset to start decoding at. + * @param [end=buf.length] The byte offset to stop decoding at (not inclusive). + */ + toString(encoding?: BufferEncoding, start?: number, end?: number): string; + /** + * Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls + * this function when stringifying a `Buffer` instance. + * + * `Buffer.from()` accepts objects in the format returned from this method. + * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]); + * const json = JSON.stringify(buf); + * + * console.log(json); + * // Prints: {"type":"Buffer","data":[1,2,3,4,5]} + * + * const copy = JSON.parse(json, (key, value) => { + * return value && value.type === 'Buffer' ? + * Buffer.from(value) : + * value; + * }); + * + * console.log(copy); + * // Prints: + * ``` + * @since v0.9.2 + */ + toJSON(): { + type: "Buffer"; + data: number[]; + }; + /** + * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from('ABC'); + * const buf2 = Buffer.from('414243', 'hex'); + * const buf3 = Buffer.from('ABCD'); + * + * console.log(buf1.equals(buf2)); + * // Prints: true + * console.log(buf1.equals(buf3)); + * // Prints: false + * ``` + * @since v0.11.13 + * @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`. + */ + equals(otherBuffer: Uint8Array): boolean; + /** + * Compares `buf` with `target` and returns a number indicating whether `buf`comes before, after, or is the same as `target` in sort order. + * Comparison is based on the actual sequence of bytes in each `Buffer`. + * + * * `0` is returned if `target` is the same as `buf` + * * `1` is returned if `target` should come _before_`buf` when sorted. + * * `-1` is returned if `target` should come _after_`buf` when sorted. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from('ABC'); + * const buf2 = Buffer.from('BCD'); + * const buf3 = Buffer.from('ABCD'); + * + * console.log(buf1.compare(buf1)); + * // Prints: 0 + * console.log(buf1.compare(buf2)); + * // Prints: -1 + * console.log(buf1.compare(buf3)); + * // Prints: -1 + * console.log(buf2.compare(buf1)); + * // Prints: 1 + * console.log(buf2.compare(buf3)); + * // Prints: 1 + * console.log([buf1, buf2, buf3].sort(Buffer.compare)); + * // Prints: [ , , ] + * // (This result is equal to: [buf1, buf3, buf2].) + * ``` + * + * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]); + * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]); + * + * console.log(buf1.compare(buf2, 5, 9, 0, 4)); + * // Prints: 0 + * console.log(buf1.compare(buf2, 0, 6, 4)); + * // Prints: -1 + * console.log(buf1.compare(buf2, 5, 6, 5)); + * // Prints: 1 + * ``` + * + * `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`,`targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`. + * @since v0.11.13 + * @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`. + * @param [targetStart=0] The offset within `target` at which to begin comparison. + * @param [targetEnd=target.length] The offset within `target` at which to end comparison (not inclusive). + * @param [sourceStart=0] The offset within `buf` at which to begin comparison. + * @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive). + */ + compare( + target: Uint8Array, + targetStart?: number, + targetEnd?: number, + sourceStart?: number, + sourceEnd?: number, + ): -1 | 0 | 1; + /** + * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`. + * + * [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available + * for all TypedArrays, including Node.js `Buffer`s, although it takes + * different function arguments. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Create two `Buffer` instances. + * const buf1 = Buffer.allocUnsafe(26); + * const buf2 = Buffer.allocUnsafe(26).fill('!'); + * + * for (let i = 0; i < 26; i++) { + * // 97 is the decimal ASCII value for 'a'. + * buf1[i] = i + 97; + * } + * + * // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`. + * buf1.copy(buf2, 8, 16, 20); + * // This is equivalent to: + * // buf2.set(buf1.subarray(16, 20), 8); + * + * console.log(buf2.toString('ascii', 0, 25)); + * // Prints: !!!!!!!!qrst!!!!!!!!!!!!! + * ``` + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Create a `Buffer` and copy data from one region to an overlapping region + * // within the same `Buffer`. + * + * const buf = Buffer.allocUnsafe(26); + * + * for (let i = 0; i < 26; i++) { + * // 97 is the decimal ASCII value for 'a'. + * buf[i] = i + 97; + * } + * + * buf.copy(buf, 0, 4, 10); + * + * console.log(buf.toString()); + * // Prints: efghijghijklmnopqrstuvwxyz + * ``` + * @since v0.1.90 + * @param target A `Buffer` or {@link Uint8Array} to copy into. + * @param [targetStart=0] The offset within `target` at which to begin writing. + * @param [sourceStart=0] The offset within `buf` from which to begin copying. + * @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive). + * @return The number of bytes copied. + */ + copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + /** + * Returns a new `Buffer` that references the same memory as the original, but + * offset and cropped by the `start` and `end` indices. + * + * This method is not compatible with the `Uint8Array.prototype.slice()`, + * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('buffer'); + * + * const copiedBuf = Uint8Array.prototype.slice.call(buf); + * copiedBuf[0]++; + * console.log(copiedBuf.toString()); + * // Prints: cuffer + * + * console.log(buf.toString()); + * // Prints: buffer + * + * // With buf.slice(), the original buffer is modified. + * const notReallyCopiedBuf = buf.slice(); + * notReallyCopiedBuf[0]++; + * console.log(notReallyCopiedBuf.toString()); + * // Prints: cuffer + * console.log(buf.toString()); + * // Also prints: cuffer (!) + * ``` + * @since v0.3.0 + * @deprecated Use `subarray` instead. + * @param [start=0] Where the new `Buffer` will start. + * @param [end=buf.length] Where the new `Buffer` will end (not inclusive). + */ + slice(start?: number, end?: number): Buffer; + /** + * Returns a new `Buffer` that references the same memory as the original, but + * offset and cropped by the `start` and `end` indices. + * + * Specifying `end` greater than `buf.length` will return the same result as + * that of `end` equal to `buf.length`. + * + * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray). + * + * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte + * // from the original `Buffer`. + * + * const buf1 = Buffer.allocUnsafe(26); + * + * for (let i = 0; i < 26; i++) { + * // 97 is the decimal ASCII value for 'a'. + * buf1[i] = i + 97; + * } + * + * const buf2 = buf1.subarray(0, 3); + * + * console.log(buf2.toString('ascii', 0, buf2.length)); + * // Prints: abc + * + * buf1[0] = 33; + * + * console.log(buf2.toString('ascii', 0, buf2.length)); + * // Prints: !bc + * ``` + * + * Specifying negative indexes causes the slice to be generated relative to the + * end of `buf` rather than the beginning. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('buffer'); + * + * console.log(buf.subarray(-6, -1).toString()); + * // Prints: buffe + * // (Equivalent to buf.subarray(0, 5).) + * + * console.log(buf.subarray(-6, -2).toString()); + * // Prints: buff + * // (Equivalent to buf.subarray(0, 4).) + * + * console.log(buf.subarray(-5, -2).toString()); + * // Prints: uff + * // (Equivalent to buf.subarray(1, 4).) + * ``` + * @since v3.0.0 + * @param [start=0] Where the new `Buffer` will start. + * @param [end=buf.length] Where the new `Buffer` will end (not inclusive). + */ + subarray(start?: number, end?: number): Buffer; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. + * + * `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeBigInt64BE(0x0102030405060708n, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v12.0.0, v10.20.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeBigInt64BE(value: bigint, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. + * + * `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeBigInt64LE(0x0102030405060708n, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v12.0.0, v10.20.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeBigInt64LE(value: bigint, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. + * + * This function is also available under the `writeBigUint64BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeBigUInt64BE(0xdecafafecacefaden, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v12.0.0, v10.20.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeBigUInt64BE(value: bigint, offset?: number): number; + /** + * @alias Buffer.writeBigUInt64BE + * @since v14.10.0, v12.19.0 + */ + writeBigUint64BE(value: bigint, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeBigUInt64LE(0xdecafafecacefaden, 0); + * + * console.log(buf); + * // Prints: + * ``` + * + * This function is also available under the `writeBigUint64LE` alias. + * @since v12.0.0, v10.20.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeBigUInt64LE(value: bigint, offset?: number): number; + /** + * @alias Buffer.writeBigUInt64LE + * @since v14.10.0, v12.19.0 + */ + writeBigUint64LE(value: bigint, offset?: number): number; + /** + * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined + * when `value` is anything other than an unsigned integer. + * + * This function is also available under the `writeUintLE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(6); + * + * buf.writeUIntLE(0x1234567890ab, 0, 6); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. + * @return `offset` plus the number of bytes written. + */ + writeUIntLE(value: number, offset: number, byteLength: number): number; + /** + * @alias Buffer.writeUIntLE + * @since v14.9.0, v12.19.0 + */ + writeUintLE(value: number, offset: number, byteLength: number): number; + /** + * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined + * when `value` is anything other than an unsigned integer. + * + * This function is also available under the `writeUintBE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(6); + * + * buf.writeUIntBE(0x1234567890ab, 0, 6); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. + * @return `offset` plus the number of bytes written. + */ + writeUIntBE(value: number, offset: number, byteLength: number): number; + /** + * @alias Buffer.writeUIntBE + * @since v14.9.0, v12.19.0 + */ + writeUintBE(value: number, offset: number, byteLength: number): number; + /** + * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined + * when `value` is anything other than a signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(6); + * + * buf.writeIntLE(0x1234567890ab, 0, 6); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. + * @return `offset` plus the number of bytes written. + */ + writeIntLE(value: number, offset: number, byteLength: number): number; + /** + * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when`value` is anything other than a + * signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(6); + * + * buf.writeIntBE(0x1234567890ab, 0, 6); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. + * @return `offset` plus the number of bytes written. + */ + writeIntBE(value: number, offset: number, byteLength: number): number; + /** + * Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readBigUint64BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); + * + * console.log(buf.readBigUInt64BE(0)); + * // Prints: 4294967295n + * ``` + * @since v12.0.0, v10.20.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. + */ + readBigUInt64BE(offset?: number): bigint; + /** + * @alias Buffer.readBigUInt64BE + * @since v14.10.0, v12.19.0 + */ + readBigUint64BE(offset?: number): bigint; + /** + * Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readBigUint64LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); + * + * console.log(buf.readBigUInt64LE(0)); + * // Prints: 18446744069414584320n + * ``` + * @since v12.0.0, v10.20.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. + */ + readBigUInt64LE(offset?: number): bigint; + /** + * @alias Buffer.readBigUInt64LE + * @since v14.10.0, v12.19.0 + */ + readBigUint64LE(offset?: number): bigint; + /** + * Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed + * values. + * @since v12.0.0, v10.20.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. + */ + readBigInt64BE(offset?: number): bigint; + /** + * Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed + * values. + * @since v12.0.0, v10.20.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. + */ + readBigInt64LE(offset?: number): bigint; + /** + * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned, little-endian integer supporting + * up to 48 bits of accuracy. + * + * This function is also available under the `readUintLE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); + * + * console.log(buf.readUIntLE(0, 6).toString(16)); + * // Prints: ab9078563412 + * ``` + * @since v0.11.15 + * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. + */ + readUIntLE(offset: number, byteLength: number): number; + /** + * @alias Buffer.readUIntLE + * @since v14.9.0, v12.19.0 + */ + readUintLE(offset: number, byteLength: number): number; + /** + * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned big-endian integer supporting + * up to 48 bits of accuracy. + * + * This function is also available under the `readUintBE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); + * + * console.log(buf.readUIntBE(0, 6).toString(16)); + * // Prints: 1234567890ab + * console.log(buf.readUIntBE(1, 6).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.11.15 + * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. + */ + readUIntBE(offset: number, byteLength: number): number; + /** + * @alias Buffer.readUIntBE + * @since v14.9.0, v12.19.0 + */ + readUintBE(offset: number, byteLength: number): number; + /** + * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a little-endian, two's complement signed value + * supporting up to 48 bits of accuracy. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); + * + * console.log(buf.readIntLE(0, 6).toString(16)); + * // Prints: -546f87a9cbee + * ``` + * @since v0.11.15 + * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. + */ + readIntLE(offset: number, byteLength: number): number; + /** + * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a big-endian, two's complement signed value + * supporting up to 48 bits of accuracy. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); + * + * console.log(buf.readIntBE(0, 6).toString(16)); + * // Prints: 1234567890ab + * console.log(buf.readIntBE(1, 6).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * console.log(buf.readIntBE(1, 0).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.11.15 + * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. + * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. + */ + readIntBE(offset: number, byteLength: number): number; + /** + * Reads an unsigned 8-bit integer from `buf` at the specified `offset`. + * + * This function is also available under the `readUint8` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, -2]); + * + * console.log(buf.readUInt8(0)); + * // Prints: 1 + * console.log(buf.readUInt8(1)); + * // Prints: 254 + * console.log(buf.readUInt8(2)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`. + */ + readUInt8(offset?: number): number; + /** + * @alias Buffer.readUInt8 + * @since v14.9.0, v12.19.0 + */ + readUint8(offset?: number): number; + /** + * Reads an unsigned, little-endian 16-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readUint16LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56]); + * + * console.log(buf.readUInt16LE(0).toString(16)); + * // Prints: 3412 + * console.log(buf.readUInt16LE(1).toString(16)); + * // Prints: 5634 + * console.log(buf.readUInt16LE(2).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. + */ + readUInt16LE(offset?: number): number; + /** + * @alias Buffer.readUInt16LE + * @since v14.9.0, v12.19.0 + */ + readUint16LE(offset?: number): number; + /** + * Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readUint16BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56]); + * + * console.log(buf.readUInt16BE(0).toString(16)); + * // Prints: 1234 + * console.log(buf.readUInt16BE(1).toString(16)); + * // Prints: 3456 + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. + */ + readUInt16BE(offset?: number): number; + /** + * @alias Buffer.readUInt16BE + * @since v14.9.0, v12.19.0 + */ + readUint16BE(offset?: number): number; + /** + * Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readUint32LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); + * + * console.log(buf.readUInt32LE(0).toString(16)); + * // Prints: 78563412 + * console.log(buf.readUInt32LE(1).toString(16)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readUInt32LE(offset?: number): number; + /** + * @alias Buffer.readUInt32LE + * @since v14.9.0, v12.19.0 + */ + readUint32LE(offset?: number): number; + /** + * Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`. + * + * This function is also available under the `readUint32BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); + * + * console.log(buf.readUInt32BE(0).toString(16)); + * // Prints: 12345678 + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readUInt32BE(offset?: number): number; + /** + * @alias Buffer.readUInt32BE + * @since v14.9.0, v12.19.0 + */ + readUint32BE(offset?: number): number; + /** + * Reads a signed 8-bit integer from `buf` at the specified `offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([-1, 5]); + * + * console.log(buf.readInt8(0)); + * // Prints: -1 + * console.log(buf.readInt8(1)); + * // Prints: 5 + * console.log(buf.readInt8(2)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.0 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`. + */ + readInt8(offset?: number): number; + /** + * Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0, 5]); + * + * console.log(buf.readInt16LE(0)); + * // Prints: 1280 + * console.log(buf.readInt16LE(1)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. + */ + readInt16LE(offset?: number): number; + /** + * Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0, 5]); + * + * console.log(buf.readInt16BE(0)); + * // Prints: 5 + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. + */ + readInt16BE(offset?: number): number; + /** + * Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0, 0, 0, 5]); + * + * console.log(buf.readInt32LE(0)); + * // Prints: 83886080 + * console.log(buf.readInt32LE(1)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readInt32LE(offset?: number): number; + /** + * Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`. + * + * Integers read from a `Buffer` are interpreted as two's complement signed values. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([0, 0, 0, 5]); + * + * console.log(buf.readInt32BE(0)); + * // Prints: 5 + * ``` + * @since v0.5.5 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readInt32BE(offset?: number): number; + /** + * Reads a 32-bit, little-endian float from `buf` at the specified `offset`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, 2, 3, 4]); + * + * console.log(buf.readFloatLE(0)); + * // Prints: 1.539989614439558e-36 + * console.log(buf.readFloatLE(1)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.11.15 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readFloatLE(offset?: number): number; + /** + * Reads a 32-bit, big-endian float from `buf` at the specified `offset`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, 2, 3, 4]); + * + * console.log(buf.readFloatBE(0)); + * // Prints: 2.387939260590663e-38 + * ``` + * @since v0.11.15 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. + */ + readFloatBE(offset?: number): number; + /** + * Reads a 64-bit, little-endian double from `buf` at the specified `offset`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); + * + * console.log(buf.readDoubleLE(0)); + * // Prints: 5.447603722011605e-270 + * console.log(buf.readDoubleLE(1)); + * // Throws ERR_OUT_OF_RANGE. + * ``` + * @since v0.11.15 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`. + */ + readDoubleLE(offset?: number): number; + /** + * Reads a 64-bit, big-endian double from `buf` at the specified `offset`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); + * + * console.log(buf.readDoubleBE(0)); + * // Prints: 8.20788039913184e-304 + * ``` + * @since v0.11.15 + * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`. + */ + readDoubleBE(offset?: number): number; + reverse(): this; + /** + * Interprets `buf` as an array of unsigned 16-bit integers and swaps the + * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); + * + * console.log(buf1); + * // Prints: + * + * buf1.swap16(); + * + * console.log(buf1); + * // Prints: + * + * const buf2 = Buffer.from([0x1, 0x2, 0x3]); + * + * buf2.swap16(); + * // Throws ERR_INVALID_BUFFER_SIZE. + * ``` + * + * One convenient use of `buf.swap16()` is to perform a fast in-place conversion + * between UTF-16 little-endian and UTF-16 big-endian: + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le'); + * buf.swap16(); // Convert to big-endian UTF-16 text. + * ``` + * @since v5.10.0 + * @return A reference to `buf`. + */ + swap16(): Buffer; + /** + * Interprets `buf` as an array of unsigned 32-bit integers and swaps the + * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); + * + * console.log(buf1); + * // Prints: + * + * buf1.swap32(); + * + * console.log(buf1); + * // Prints: + * + * const buf2 = Buffer.from([0x1, 0x2, 0x3]); + * + * buf2.swap32(); + * // Throws ERR_INVALID_BUFFER_SIZE. + * ``` + * @since v5.10.0 + * @return A reference to `buf`. + */ + swap32(): Buffer; + /** + * Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_. + * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); + * + * console.log(buf1); + * // Prints: + * + * buf1.swap64(); + * + * console.log(buf1); + * // Prints: + * + * const buf2 = Buffer.from([0x1, 0x2, 0x3]); + * + * buf2.swap64(); + * // Throws ERR_INVALID_BUFFER_SIZE. + * ``` + * @since v6.3.0 + * @return A reference to `buf`. + */ + swap64(): Buffer; + /** + * Writes `value` to `buf` at the specified `offset`. `value` must be a + * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything + * other than an unsigned 8-bit integer. + * + * This function is also available under the `writeUint8` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt8(0x3, 0); + * buf.writeUInt8(0x4, 1); + * buf.writeUInt8(0x23, 2); + * buf.writeUInt8(0x42, 3); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`. + * @return `offset` plus the number of bytes written. + */ + writeUInt8(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt8 + * @since v14.9.0, v12.19.0 + */ + writeUint8(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is + * anything other than an unsigned 16-bit integer. + * + * This function is also available under the `writeUint16LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt16LE(0xdead, 0); + * buf.writeUInt16LE(0xbeef, 2); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. + * @return `offset` plus the number of bytes written. + */ + writeUInt16LE(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt16LE + * @since v14.9.0, v12.19.0 + */ + writeUint16LE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an + * unsigned 16-bit integer. + * + * This function is also available under the `writeUint16BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt16BE(0xdead, 0); + * buf.writeUInt16BE(0xbeef, 2); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. + * @return `offset` plus the number of bytes written. + */ + writeUInt16BE(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt16BE + * @since v14.9.0, v12.19.0 + */ + writeUint16BE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is + * anything other than an unsigned 32-bit integer. + * + * This function is also available under the `writeUint32LE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt32LE(0xfeedface, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeUInt32LE(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt32LE + * @since v14.9.0, v12.19.0 + */ + writeUint32LE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an + * unsigned 32-bit integer. + * + * This function is also available under the `writeUint32BE` alias. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeUInt32BE(0xfeedface, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeUInt32BE(value: number, offset?: number): number; + /** + * @alias Buffer.writeUInt32BE + * @since v14.9.0, v12.19.0 + */ + writeUint32BE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset`. `value` must be a valid + * signed 8-bit integer. Behavior is undefined when `value` is anything other than + * a signed 8-bit integer. + * + * `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(2); + * + * buf.writeInt8(2, 0); + * buf.writeInt8(-2, 1); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.0 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`. + * @return `offset` plus the number of bytes written. + */ + writeInt8(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is + * anything other than a signed 16-bit integer. + * + * The `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(2); + * + * buf.writeInt16LE(0x0304, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. + * @return `offset` plus the number of bytes written. + */ + writeInt16LE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is + * anything other than a signed 16-bit integer. + * + * The `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(2); + * + * buf.writeInt16BE(0x0102, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. + * @return `offset` plus the number of bytes written. + */ + writeInt16BE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is + * anything other than a signed 32-bit integer. + * + * The `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeInt32LE(0x05060708, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeInt32LE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is + * anything other than a signed 32-bit integer. + * + * The `value` is interpreted and written as a two's complement signed integer. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeInt32BE(0x01020304, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.5.5 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeInt32BE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is + * undefined when `value` is anything other than a JavaScript number. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeFloatLE(0xcafebabe, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeFloatLE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is + * undefined when `value` is anything other than a JavaScript number. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(4); + * + * buf.writeFloatBE(0xcafebabe, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. + * @return `offset` plus the number of bytes written. + */ + writeFloatBE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything + * other than a JavaScript number. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeDoubleLE(123.456, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeDoubleLE(value: number, offset?: number): number; + /** + * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything + * other than a JavaScript number. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(8); + * + * buf.writeDoubleBE(123.456, 0); + * + * console.log(buf); + * // Prints: + * ``` + * @since v0.11.15 + * @param value Number to be written to `buf`. + * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`. + * @return `offset` plus the number of bytes written. + */ + writeDoubleBE(value: number, offset?: number): number; + /** + * Fills `buf` with the specified `value`. If the `offset` and `end` are not given, + * the entire `buf` will be filled: + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Fill a `Buffer` with the ASCII character 'h'. + * + * const b = Buffer.allocUnsafe(50).fill('h'); + * + * console.log(b.toString()); + * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh + * + * // Fill a buffer with empty string + * const c = Buffer.allocUnsafe(5).fill(''); + * + * console.log(c.fill('')); + * // Prints: + * ``` + * + * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or + * integer. If the resulting integer is greater than `255` (decimal), `buf` will be + * filled with `value & 255`. + * + * If the final write of a `fill()` operation falls on a multi-byte character, + * then only the bytes of that character that fit into `buf` are written: + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Fill a `Buffer` with character that takes up two bytes in UTF-8. + * + * console.log(Buffer.allocUnsafe(5).fill('\u0222')); + * // Prints: + * ``` + * + * If `value` contains invalid characters, it is truncated; if no valid + * fill data remains, an exception is thrown: + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.allocUnsafe(5); + * + * console.log(buf.fill('a')); + * // Prints: + * console.log(buf.fill('aazz', 'hex')); + * // Prints: + * console.log(buf.fill('zz', 'hex')); + * // Throws an exception. + * ``` + * @since v0.5.0 + * @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`. + * @param [offset=0] Number of bytes to skip before starting to fill `buf`. + * @param [end=buf.length] Where to stop filling `buf` (not inclusive). + * @param [encoding='utf8'] The encoding for `value` if `value` is a string. + * @return A reference to `buf`. + */ + fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this; + /** + * If `value` is: + * + * * a string, `value` is interpreted according to the character encoding in`encoding`. + * * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety. + * To compare a partial `Buffer`, use `buf.subarray`. + * * a number, `value` will be interpreted as an unsigned 8-bit integer + * value between `0` and `255`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('this is a buffer'); + * + * console.log(buf.indexOf('this')); + * // Prints: 0 + * console.log(buf.indexOf('is')); + * // Prints: 2 + * console.log(buf.indexOf(Buffer.from('a buffer'))); + * // Prints: 8 + * console.log(buf.indexOf(97)); + * // Prints: 8 (97 is the decimal ASCII value for 'a') + * console.log(buf.indexOf(Buffer.from('a buffer example'))); + * // Prints: -1 + * console.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8))); + * // Prints: 8 + * + * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le'); + * + * console.log(utf16Buffer.indexOf('\u03a3', 0, 'utf16le')); + * // Prints: 4 + * console.log(utf16Buffer.indexOf('\u03a3', -4, 'utf16le')); + * // Prints: 6 + * ``` + * + * If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value, + * an integer between 0 and 255. + * + * If `byteOffset` is not a number, it will be coerced to a number. If the result + * of coercion is `NaN` or `0`, then the entire buffer will be searched. This + * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf). + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const b = Buffer.from('abcdef'); + * + * // Passing a value that's a number, but not a valid byte. + * // Prints: 2, equivalent to searching for 99 or 'c'. + * console.log(b.indexOf(99.9)); + * console.log(b.indexOf(256 + 99)); + * + * // Passing a byteOffset that coerces to NaN or 0. + * // Prints: 1, searching the whole buffer. + * console.log(b.indexOf('b', undefined)); + * console.log(b.indexOf('b', {})); + * console.log(b.indexOf('b', null)); + * console.log(b.indexOf('b', [])); + * ``` + * + * If `value` is an empty string or empty `Buffer` and `byteOffset` is less + * than `buf.length`, `byteOffset` will be returned. If `value` is empty and`byteOffset` is at least `buf.length`, `buf.length` will be returned. + * @since v1.5.0 + * @param value What to search for. + * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. + * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`. + * @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`. + */ + indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; + /** + * Identical to `buf.indexOf()`, except the last occurrence of `value` is found + * rather than the first occurrence. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('this buffer is a buffer'); + * + * console.log(buf.lastIndexOf('this')); + * // Prints: 0 + * console.log(buf.lastIndexOf('buffer')); + * // Prints: 17 + * console.log(buf.lastIndexOf(Buffer.from('buffer'))); + * // Prints: 17 + * console.log(buf.lastIndexOf(97)); + * // Prints: 15 (97 is the decimal ASCII value for 'a') + * console.log(buf.lastIndexOf(Buffer.from('yolo'))); + * // Prints: -1 + * console.log(buf.lastIndexOf('buffer', 5)); + * // Prints: 5 + * console.log(buf.lastIndexOf('buffer', 4)); + * // Prints: -1 + * + * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le'); + * + * console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le')); + * // Prints: 6 + * console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le')); + * // Prints: 4 + * ``` + * + * If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value, + * an integer between 0 and 255. + * + * If `byteOffset` is not a number, it will be coerced to a number. Any arguments + * that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer. + * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf). + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const b = Buffer.from('abcdef'); + * + * // Passing a value that's a number, but not a valid byte. + * // Prints: 2, equivalent to searching for 99 or 'c'. + * console.log(b.lastIndexOf(99.9)); + * console.log(b.lastIndexOf(256 + 99)); + * + * // Passing a byteOffset that coerces to NaN. + * // Prints: 1, searching the whole buffer. + * console.log(b.lastIndexOf('b', undefined)); + * console.log(b.lastIndexOf('b', {})); + * + * // Passing a byteOffset that coerces to 0. + * // Prints: -1, equivalent to passing 0. + * console.log(b.lastIndexOf('b', null)); + * console.log(b.lastIndexOf('b', [])); + * ``` + * + * If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned. + * @since v6.0.0 + * @param value What to search for. + * @param [byteOffset=buf.length - 1] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. + * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`. + * @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`. + */ + lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; + /** + * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `[index, byte]` pairs from the contents + * of `buf`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * // Log the entire contents of a `Buffer`. + * + * const buf = Buffer.from('buffer'); + * + * for (const pair of buf.entries()) { + * console.log(pair); + * } + * // Prints: + * // [0, 98] + * // [1, 117] + * // [2, 102] + * // [3, 102] + * // [4, 101] + * // [5, 114] + * ``` + * @since v1.1.0 + */ + entries(): IterableIterator<[number, number]>; + /** + * Equivalent to `buf.indexOf() !== -1`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('this is a buffer'); + * + * console.log(buf.includes('this')); + * // Prints: true + * console.log(buf.includes('is')); + * // Prints: true + * console.log(buf.includes(Buffer.from('a buffer'))); + * // Prints: true + * console.log(buf.includes(97)); + * // Prints: true (97 is the decimal ASCII value for 'a') + * console.log(buf.includes(Buffer.from('a buffer example'))); + * // Prints: false + * console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8))); + * // Prints: true + * console.log(buf.includes('this', 4)); + * // Prints: false + * ``` + * @since v5.3.0 + * @param value What to search for. + * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. + * @param [encoding='utf8'] If `value` is a string, this is its encoding. + * @return `true` if `value` was found in `buf`, `false` otherwise. + */ + includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean; + /** + * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices). + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('buffer'); + * + * for (const key of buf.keys()) { + * console.log(key); + * } + * // Prints: + * // 0 + * // 1 + * // 2 + * // 3 + * // 4 + * // 5 + * ``` + * @since v1.1.0 + */ + keys(): IterableIterator; + /** + * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) for `buf` values (bytes). This function is + * called automatically when a `Buffer` is used in a `for..of` statement. + * + * ```js + * import { Buffer } from 'node:buffer'; + * + * const buf = Buffer.from('buffer'); + * + * for (const value of buf.values()) { + * console.log(value); + * } + * // Prints: + * // 98 + * // 117 + * // 102 + * // 102 + * // 101 + * // 114 + * + * for (const value of buf) { + * console.log(value); + * } + * // Prints: + * // 98 + * // 117 + * // 102 + * // 102 + * // 101 + * // 114 + * ``` + * @since v1.1.0 + */ + values(): IterableIterator; + } + var Buffer: BufferConstructor; + /** + * Decodes a string of Base64-encoded data into bytes, and encodes those bytes + * into a string using Latin-1 (ISO-8859-1). + * + * The `data` may be any JavaScript-value that can be coerced into a string. + * + * **This function is only provided for compatibility with legacy web platform APIs** + * **and should never be used in new code, because they use strings to represent** + * **binary data and predate the introduction of typed arrays in JavaScript.** + * **For code running using Node.js APIs, converting between base64-encoded strings** + * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.** + * @since v15.13.0, v14.17.0 + * @legacy Use `Buffer.from(data, 'base64')` instead. + * @param data The Base64-encoded input string. + */ + function atob(data: string): string; + /** + * Decodes a string into bytes using Latin-1 (ISO-8859), and encodes those bytes + * into a string using Base64. + * + * The `data` may be any JavaScript-value that can be coerced into a string. + * + * **This function is only provided for compatibility with legacy web platform APIs** + * **and should never be used in new code, because they use strings to represent** + * **binary data and predate the introduction of typed arrays in JavaScript.** + * **For code running using Node.js APIs, converting between base64-encoded strings** + * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.** + * @since v15.13.0, v14.17.0 + * @legacy Use `buf.toString('base64')` instead. + * @param data An ASCII (Latin1) string. + */ + function btoa(data: string): string; + interface Blob extends __Blob {} + /** + * `Blob` class is a global reference for `require('node:buffer').Blob` + * https://nodejs.org/api/buffer.html#class-blob + * @since v18.0.0 + */ + var Blob: typeof globalThis extends { + onmessage: any; + Blob: infer T; + } ? T + : typeof NodeBlob; + } +} +declare module "node:buffer" { + export * from "buffer"; +} diff --git a/node_modules/@types/node/ts4.8/child_process.d.ts b/node_modules/@types/node/ts4.8/child_process.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a97532b474dd66ee96bf1c13335136727f4c0398 --- /dev/null +++ b/node_modules/@types/node/ts4.8/child_process.d.ts @@ -0,0 +1,1540 @@ +/** + * The `node:child_process` module provides the ability to spawn subprocesses in + * a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability + * is primarily provided by the {@link spawn} function: + * + * ```js + * const { spawn } = require('node:child_process'); + * const ls = spawn('ls', ['-lh', '/usr']); + * + * ls.stdout.on('data', (data) => { + * console.log(`stdout: ${data}`); + * }); + * + * ls.stderr.on('data', (data) => { + * console.error(`stderr: ${data}`); + * }); + * + * ls.on('close', (code) => { + * console.log(`child process exited with code ${code}`); + * }); + * ``` + * + * By default, pipes for `stdin`, `stdout`, and `stderr` are established between + * the parent Node.js process and the spawned subprocess. These pipes have + * limited (and platform-specific) capacity. If the subprocess writes to + * stdout in excess of that limit without the output being captured, the + * subprocess blocks waiting for the pipe buffer to accept more data. This is + * identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`option if the output will not be consumed. + * + * The command lookup is performed using the `options.env.PATH` environment + * variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is + * used. If `options.env` is set without `PATH`, lookup on Unix is performed + * on a default search path search of `/usr/bin:/bin` (see your operating system's + * manual for execvpe/execvp), on Windows the current processes environment + * variable `PATH` is used. + * + * On Windows, environment variables are case-insensitive. Node.js + * lexicographically sorts the `env` keys and uses the first one that + * case-insensitively matches. Only first (in lexicographic order) entry will be + * passed to the subprocess. This might lead to issues on Windows when passing + * objects to the `env` option that have multiple variants of the same key, such as`PATH` and `Path`. + * + * The {@link spawn} method spawns the child process asynchronously, + * without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks + * the event loop until the spawned process either exits or is terminated. + * + * For convenience, the `node:child_process` module provides a handful of + * synchronous and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on + * top of {@link spawn} or {@link spawnSync}. + * + * * {@link exec}: spawns a shell and runs a command within that + * shell, passing the `stdout` and `stderr` to a callback function when + * complete. + * * {@link execFile}: similar to {@link exec} except + * that it spawns the command directly without first spawning a shell by + * default. + * * {@link fork}: spawns a new Node.js process and invokes a + * specified module with an IPC communication channel established that allows + * sending messages between parent and child. + * * {@link execSync}: a synchronous version of {@link exec} that will block the Node.js event loop. + * * {@link execFileSync}: a synchronous version of {@link execFile} that will block the Node.js event loop. + * + * For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however, + * the synchronous methods can have significant impact on performance due to + * stalling the event loop while spawned processes complete. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/child_process.js) + */ +declare module "child_process" { + import { ObjectEncodingOptions } from "node:fs"; + import { Abortable, EventEmitter } from "node:events"; + import * as net from "node:net"; + import { Pipe, Readable, Stream, Writable } from "node:stream"; + import { URL } from "node:url"; + type Serializable = string | object | number | boolean | bigint; + type SendHandle = net.Socket | net.Server; + /** + * Instances of the `ChildProcess` represent spawned child processes. + * + * Instances of `ChildProcess` are not intended to be created directly. Rather, + * use the {@link spawn}, {@link exec},{@link execFile}, or {@link fork} methods to create + * instances of `ChildProcess`. + * @since v2.2.0 + */ + class ChildProcess extends EventEmitter { + /** + * A `Writable Stream` that represents the child process's `stdin`. + * + * If a child process waits to read all of its input, the child will not continue + * until this stream has been closed via `end()`. + * + * If the child was spawned with `stdio[0]` set to anything other than `'pipe'`, + * then this will be `null`. + * + * `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will + * refer to the same value. + * + * The `subprocess.stdin` property can be `null` or `undefined`if the child process could not be successfully spawned. + * @since v0.1.90 + */ + stdin: Writable | null; + /** + * A `Readable Stream` that represents the child process's `stdout`. + * + * If the child was spawned with `stdio[1]` set to anything other than `'pipe'`, + * then this will be `null`. + * + * `subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will + * refer to the same value. + * + * ```js + * const { spawn } = require('node:child_process'); + * + * const subprocess = spawn('ls'); + * + * subprocess.stdout.on('data', (data) => { + * console.log(`Received chunk ${data}`); + * }); + * ``` + * + * The `subprocess.stdout` property can be `null` or `undefined`if the child process could not be successfully spawned. + * @since v0.1.90 + */ + stdout: Readable | null; + /** + * A `Readable Stream` that represents the child process's `stderr`. + * + * If the child was spawned with `stdio[2]` set to anything other than `'pipe'`, + * then this will be `null`. + * + * `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will + * refer to the same value. + * + * The `subprocess.stderr` property can be `null` or `undefined`if the child process could not be successfully spawned. + * @since v0.1.90 + */ + stderr: Readable | null; + /** + * The `subprocess.channel` property is a reference to the child's IPC channel. If + * no IPC channel exists, this property is `undefined`. + * @since v7.1.0 + */ + readonly channel?: Pipe | null | undefined; + /** + * A sparse array of pipes to the child process, corresponding with positions in + * the `stdio` option passed to {@link spawn} that have been set + * to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and`subprocess.stdio[2]` are also available as `subprocess.stdin`,`subprocess.stdout`, and `subprocess.stderr`, + * respectively. + * + * In the following example, only the child's fd `1` (stdout) is configured as a + * pipe, so only the parent's `subprocess.stdio[1]` is a stream, all other values + * in the array are `null`. + * + * ```js + * const assert = require('node:assert'); + * const fs = require('node:fs'); + * const child_process = require('node:child_process'); + * + * const subprocess = child_process.spawn('ls', { + * stdio: [ + * 0, // Use parent's stdin for child. + * 'pipe', // Pipe child's stdout to parent. + * fs.openSync('err.out', 'w'), // Direct child's stderr to a file. + * ], + * }); + * + * assert.strictEqual(subprocess.stdio[0], null); + * assert.strictEqual(subprocess.stdio[0], subprocess.stdin); + * + * assert(subprocess.stdout); + * assert.strictEqual(subprocess.stdio[1], subprocess.stdout); + * + * assert.strictEqual(subprocess.stdio[2], null); + * assert.strictEqual(subprocess.stdio[2], subprocess.stderr); + * ``` + * + * The `subprocess.stdio` property can be `undefined` if the child process could + * not be successfully spawned. + * @since v0.7.10 + */ + readonly stdio: [ + Writable | null, + // stdin + Readable | null, + // stdout + Readable | null, + // stderr + Readable | Writable | null | undefined, + // extra + Readable | Writable | null | undefined, // extra + ]; + /** + * The `subprocess.killed` property indicates whether the child process + * successfully received a signal from `subprocess.kill()`. The `killed` property + * does not indicate that the child process has been terminated. + * @since v0.5.10 + */ + readonly killed: boolean; + /** + * Returns the process identifier (PID) of the child process. If the child process + * fails to spawn due to errors, then the value is `undefined` and `error` is + * emitted. + * + * ```js + * const { spawn } = require('node:child_process'); + * const grep = spawn('grep', ['ssh']); + * + * console.log(`Spawned child pid: ${grep.pid}`); + * grep.stdin.end(); + * ``` + * @since v0.1.90 + */ + readonly pid?: number | undefined; + /** + * The `subprocess.connected` property indicates whether it is still possible to + * send and receive messages from a child process. When `subprocess.connected` is`false`, it is no longer possible to send or receive messages. + * @since v0.7.2 + */ + readonly connected: boolean; + /** + * The `subprocess.exitCode` property indicates the exit code of the child process. + * If the child process is still running, the field will be `null`. + */ + readonly exitCode: number | null; + /** + * The `subprocess.signalCode` property indicates the signal received by + * the child process if any, else `null`. + */ + readonly signalCode: NodeJS.Signals | null; + /** + * The `subprocess.spawnargs` property represents the full list of command-line + * arguments the child process was launched with. + */ + readonly spawnargs: string[]; + /** + * The `subprocess.spawnfile` property indicates the executable file name of + * the child process that is launched. + * + * For {@link fork}, its value will be equal to `process.execPath`. + * For {@link spawn}, its value will be the name of + * the executable file. + * For {@link exec}, its value will be the name of the shell + * in which the child process is launched. + */ + readonly spawnfile: string; + /** + * The `subprocess.kill()` method sends a signal to the child process. If no + * argument is given, the process will be sent the `'SIGTERM'` signal. See [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for a list of available signals. This function + * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise. + * + * ```js + * const { spawn } = require('node:child_process'); + * const grep = spawn('grep', ['ssh']); + * + * grep.on('close', (code, signal) => { + * console.log( + * `child process terminated due to receipt of signal ${signal}`); + * }); + * + * // Send SIGHUP to process. + * grep.kill('SIGHUP'); + * ``` + * + * The `ChildProcess` object may emit an `'error'` event if the signal + * cannot be delivered. Sending a signal to a child process that has already exited + * is not an error but may have unforeseen consequences. Specifically, if the + * process identifier (PID) has been reassigned to another process, the signal will + * be delivered to that process instead which can have unexpected results. + * + * While the function is called `kill`, the signal delivered to the child process + * may not actually terminate the process. + * + * See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference. + * + * On Windows, where POSIX signals do not exist, the `signal` argument will be + * ignored, and the process will be killed forcefully and abruptly (similar to`'SIGKILL'`). + * See `Signal Events` for more details. + * + * On Linux, child processes of child processes will not be terminated + * when attempting to kill their parent. This is likely to happen when running a + * new process in a shell or with the use of the `shell` option of `ChildProcess`: + * + * ```js + * 'use strict'; + * const { spawn } = require('node:child_process'); + * + * const subprocess = spawn( + * 'sh', + * [ + * '-c', + * `node -e "setInterval(() => { + * console.log(process.pid, 'is alive') + * }, 500);"`, + * ], { + * stdio: ['inherit', 'inherit', 'inherit'], + * }, + * ); + * + * setTimeout(() => { + * subprocess.kill(); // Does not terminate the Node.js process in the shell. + * }, 2000); + * ``` + * @since v0.1.90 + */ + kill(signal?: NodeJS.Signals | number): boolean; + /** + * Calls {@link ChildProcess.kill} with `'SIGTERM'`. + * @since v20.5.0 + */ + [Symbol.dispose](): void; + /** + * When an IPC channel has been established between the parent and child ( + * i.e. when using {@link fork}), the `subprocess.send()` method can + * be used to send messages to the child process. When the child process is a + * Node.js instance, these messages can be received via the `'message'` event. + * + * The message goes through serialization and parsing. The resulting + * message might not be the same as what is originally sent. + * + * For example, in the parent script: + * + * ```js + * const cp = require('node:child_process'); + * const n = cp.fork(`${__dirname}/sub.js`); + * + * n.on('message', (m) => { + * console.log('PARENT got message:', m); + * }); + * + * // Causes the child to print: CHILD got message: { hello: 'world' } + * n.send({ hello: 'world' }); + * ``` + * + * And then the child script, `'sub.js'` might look like this: + * + * ```js + * process.on('message', (m) => { + * console.log('CHILD got message:', m); + * }); + * + * // Causes the parent to print: PARENT got message: { foo: 'bar', baz: null } + * process.send({ foo: 'bar', baz: NaN }); + * ``` + * + * Child Node.js processes will have a `process.send()` method of their own + * that allows the child to send messages back to the parent. + * + * There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages + * containing a `NODE_` prefix in the `cmd` property are reserved for use within + * Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the`'internalMessage'` event and are consumed internally by Node.js. + * Applications should avoid using such messages or listening for`'internalMessage'` events as it is subject to change without notice. + * + * The optional `sendHandle` argument that may be passed to `subprocess.send()` is + * for passing a TCP server or socket object to the child process. The child will + * receive the object as the second argument passed to the callback function + * registered on the `'message'` event. Any data that is received + * and buffered in the socket will not be sent to the child. + * + * The optional `callback` is a function that is invoked after the message is + * sent but before the child may have received it. The function is called with a + * single argument: `null` on success, or an `Error` object on failure. + * + * If no `callback` function is provided and the message cannot be sent, an`'error'` event will be emitted by the `ChildProcess` object. This can + * happen, for instance, when the child process has already exited. + * + * `subprocess.send()` will return `false` if the channel has closed or when the + * backlog of unsent messages exceeds a threshold that makes it unwise to send + * more. Otherwise, the method returns `true`. The `callback` function can be + * used to implement flow control. + * + * #### Example: sending a server object + * + * The `sendHandle` argument can be used, for instance, to pass the handle of + * a TCP server object to the child process as illustrated in the example below: + * + * ```js + * const subprocess = require('node:child_process').fork('subprocess.js'); + * + * // Open up the server object and send the handle. + * const server = require('node:net').createServer(); + * server.on('connection', (socket) => { + * socket.end('handled by parent'); + * }); + * server.listen(1337, () => { + * subprocess.send('server', server); + * }); + * ``` + * + * The child would then receive the server object as: + * + * ```js + * process.on('message', (m, server) => { + * if (m === 'server') { + * server.on('connection', (socket) => { + * socket.end('handled by child'); + * }); + * } + * }); + * ``` + * + * Once the server is now shared between the parent and child, some connections + * can be handled by the parent and some by the child. + * + * While the example above uses a server created using the `node:net` module,`node:dgram` module servers use exactly the same workflow with the exceptions of + * listening on a `'message'` event instead of `'connection'` and using`server.bind()` instead of `server.listen()`. This is, however, only + * supported on Unix platforms. + * + * #### Example: sending a socket object + * + * Similarly, the `sendHandler` argument can be used to pass the handle of a + * socket to the child process. The example below spawns two children that each + * handle connections with "normal" or "special" priority: + * + * ```js + * const { fork } = require('node:child_process'); + * const normal = fork('subprocess.js', ['normal']); + * const special = fork('subprocess.js', ['special']); + * + * // Open up the server and send sockets to child. Use pauseOnConnect to prevent + * // the sockets from being read before they are sent to the child process. + * const server = require('node:net').createServer({ pauseOnConnect: true }); + * server.on('connection', (socket) => { + * + * // If this is special priority... + * if (socket.remoteAddress === '74.125.127.100') { + * special.send('socket', socket); + * return; + * } + * // This is normal priority. + * normal.send('socket', socket); + * }); + * server.listen(1337); + * ``` + * + * The `subprocess.js` would receive the socket handle as the second argument + * passed to the event callback function: + * + * ```js + * process.on('message', (m, socket) => { + * if (m === 'socket') { + * if (socket) { + * // Check that the client socket exists. + * // It is possible for the socket to be closed between the time it is + * // sent and the time it is received in the child process. + * socket.end(`Request handled with ${process.argv[2]} priority`); + * } + * } + * }); + * ``` + * + * Do not use `.maxConnections` on a socket that has been passed to a subprocess. + * The parent cannot track when the socket is destroyed. + * + * Any `'message'` handlers in the subprocess should verify that `socket` exists, + * as the connection may have been closed during the time it takes to send the + * connection to the child. + * @since v0.5.9 + * @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties: + */ + send(message: Serializable, callback?: (error: Error | null) => void): boolean; + send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean; + send( + message: Serializable, + sendHandle?: SendHandle, + options?: MessageOptions, + callback?: (error: Error | null) => void, + ): boolean; + /** + * Closes the IPC channel between parent and child, allowing the child to exit + * gracefully once there are no other connections keeping it alive. After calling + * this method the `subprocess.connected` and `process.connected` properties in + * both the parent and child (respectively) will be set to `false`, and it will be + * no longer possible to pass messages between the processes. + * + * The `'disconnect'` event will be emitted when there are no messages in the + * process of being received. This will most often be triggered immediately after + * calling `subprocess.disconnect()`. + * + * When the child process is a Node.js instance (e.g. spawned using {@link fork}), the `process.disconnect()` method can be invoked + * within the child process to close the IPC channel as well. + * @since v0.7.2 + */ + disconnect(): void; + /** + * By default, the parent will wait for the detached child to exit. To prevent the + * parent from waiting for a given `subprocess` to exit, use the`subprocess.unref()` method. Doing so will cause the parent's event loop to not + * include the child in its reference count, allowing the parent to exit + * independently of the child, unless there is an established IPC channel between + * the child and the parent. + * + * ```js + * const { spawn } = require('node:child_process'); + * + * const subprocess = spawn(process.argv[0], ['child_program.js'], { + * detached: true, + * stdio: 'ignore', + * }); + * + * subprocess.unref(); + * ``` + * @since v0.7.10 + */ + unref(): void; + /** + * Calling `subprocess.ref()` after making a call to `subprocess.unref()` will + * restore the removed reference count for the child process, forcing the parent + * to wait for the child to exit before exiting itself. + * + * ```js + * const { spawn } = require('node:child_process'); + * + * const subprocess = spawn(process.argv[0], ['child_program.js'], { + * detached: true, + * stdio: 'ignore', + * }); + * + * subprocess.unref(); + * subprocess.ref(); + * ``` + * @since v0.7.10 + */ + ref(): void; + /** + * events.EventEmitter + * 1. close + * 2. disconnect + * 3. error + * 4. exit + * 5. message + * 6. spawn + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + addListener(event: "disconnect", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + addListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + addListener(event: "spawn", listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close", code: number | null, signal: NodeJS.Signals | null): boolean; + emit(event: "disconnect"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "exit", code: number | null, signal: NodeJS.Signals | null): boolean; + emit(event: "message", message: Serializable, sendHandle: SendHandle): boolean; + emit(event: "spawn", listener: () => void): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + on(event: "disconnect", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + on(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + on(event: "spawn", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + once(event: "disconnect", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + once(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + once(event: "spawn", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + prependListener(event: "disconnect", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this; + prependListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + prependListener(event: "spawn", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener( + event: "close", + listener: (code: number | null, signal: NodeJS.Signals | null) => void, + ): this; + prependOnceListener(event: "disconnect", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener( + event: "exit", + listener: (code: number | null, signal: NodeJS.Signals | null) => void, + ): this; + prependOnceListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this; + prependOnceListener(event: "spawn", listener: () => void): this; + } + // return this object when stdio option is undefined or not specified + interface ChildProcessWithoutNullStreams extends ChildProcess { + stdin: Writable; + stdout: Readable; + stderr: Readable; + readonly stdio: [ + Writable, + Readable, + Readable, + // stderr + Readable | Writable | null | undefined, + // extra, no modification + Readable | Writable | null | undefined, // extra, no modification + ]; + } + // return this object when stdio option is a tuple of 3 + interface ChildProcessByStdio + extends ChildProcess + { + stdin: I; + stdout: O; + stderr: E; + readonly stdio: [ + I, + O, + E, + Readable | Writable | null | undefined, + // extra, no modification + Readable | Writable | null | undefined, // extra, no modification + ]; + } + interface MessageOptions { + keepOpen?: boolean | undefined; + } + type IOType = "overlapped" | "pipe" | "ignore" | "inherit"; + type StdioOptions = IOType | Array; + type SerializationType = "json" | "advanced"; + interface MessagingOptions extends Abortable { + /** + * Specify the kind of serialization used for sending messages between processes. + * @default 'json' + */ + serialization?: SerializationType | undefined; + /** + * The signal value to be used when the spawned process will be killed by the abort signal. + * @default 'SIGTERM' + */ + killSignal?: NodeJS.Signals | number | undefined; + /** + * In milliseconds the maximum amount of time the process is allowed to run. + */ + timeout?: number | undefined; + } + interface ProcessEnvOptions { + uid?: number | undefined; + gid?: number | undefined; + cwd?: string | URL | undefined; + env?: NodeJS.ProcessEnv | undefined; + } + interface CommonOptions extends ProcessEnvOptions { + /** + * @default false + */ + windowsHide?: boolean | undefined; + /** + * @default 0 + */ + timeout?: number | undefined; + } + interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable { + argv0?: string | undefined; + /** + * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ + stdio?: StdioOptions | undefined; + shell?: boolean | string | undefined; + windowsVerbatimArguments?: boolean | undefined; + } + interface SpawnOptions extends CommonSpawnOptions { + detached?: boolean | undefined; + } + interface SpawnOptionsWithoutStdio extends SpawnOptions { + stdio?: StdioPipeNamed | StdioPipe[] | undefined; + } + type StdioNull = "inherit" | "ignore" | Stream; + type StdioPipeNamed = "pipe" | "overlapped"; + type StdioPipe = undefined | null | StdioPipeNamed; + interface SpawnOptionsWithStdioTuple< + Stdin extends StdioNull | StdioPipe, + Stdout extends StdioNull | StdioPipe, + Stderr extends StdioNull | StdioPipe, + > extends SpawnOptions { + stdio: [Stdin, Stdout, Stderr]; + } + /** + * The `child_process.spawn()` method spawns a new process using the given`command`, with command-line arguments in `args`. If omitted, `args` defaults + * to an empty array. + * + * **If the `shell` option is enabled, do not pass unsanitized user input to this** + * **function. Any input containing shell metacharacters may be used to trigger** + * **arbitrary command execution.** + * + * A third argument may be used to specify additional options, with these defaults: + * + * ```js + * const defaults = { + * cwd: undefined, + * env: process.env, + * }; + * ``` + * + * Use `cwd` to specify the working directory from which the process is spawned. + * If not given, the default is to inherit the current working directory. If given, + * but the path does not exist, the child process emits an `ENOENT` error + * and exits immediately. `ENOENT` is also emitted when the command + * does not exist. + * + * Use `env` to specify environment variables that will be visible to the new + * process, the default is `process.env`. + * + * `undefined` values in `env` will be ignored. + * + * Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the + * exit code: + * + * ```js + * const { spawn } = require('node:child_process'); + * const ls = spawn('ls', ['-lh', '/usr']); + * + * ls.stdout.on('data', (data) => { + * console.log(`stdout: ${data}`); + * }); + * + * ls.stderr.on('data', (data) => { + * console.error(`stderr: ${data}`); + * }); + * + * ls.on('close', (code) => { + * console.log(`child process exited with code ${code}`); + * }); + * ``` + * + * Example: A very elaborate way to run `ps ax | grep ssh` + * + * ```js + * const { spawn } = require('node:child_process'); + * const ps = spawn('ps', ['ax']); + * const grep = spawn('grep', ['ssh']); + * + * ps.stdout.on('data', (data) => { + * grep.stdin.write(data); + * }); + * + * ps.stderr.on('data', (data) => { + * console.error(`ps stderr: ${data}`); + * }); + * + * ps.on('close', (code) => { + * if (code !== 0) { + * console.log(`ps process exited with code ${code}`); + * } + * grep.stdin.end(); + * }); + * + * grep.stdout.on('data', (data) => { + * console.log(data.toString()); + * }); + * + * grep.stderr.on('data', (data) => { + * console.error(`grep stderr: ${data}`); + * }); + * + * grep.on('close', (code) => { + * if (code !== 0) { + * console.log(`grep process exited with code ${code}`); + * } + * }); + * ``` + * + * Example of checking for failed `spawn`: + * + * ```js + * const { spawn } = require('node:child_process'); + * const subprocess = spawn('bad_command'); + * + * subprocess.on('error', (err) => { + * console.error('Failed to start subprocess.'); + * }); + * ``` + * + * Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process + * title while others (Windows, SunOS) will use `command`. + * + * Node.js overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent. Retrieve + * it with the`process.argv0` property instead. + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except + * the error passed to the callback will be an `AbortError`: + * + * ```js + * const { spawn } = require('node:child_process'); + * const controller = new AbortController(); + * const { signal } = controller; + * const grep = spawn('grep', ['ssh'], { signal }); + * grep.on('error', (err) => { + * // This will be called with err being an AbortError if the controller aborts + * }); + * controller.abort(); // Stops the child process + * ``` + * @since v0.1.90 + * @param command The command to run. + * @param args List of string arguments. + */ + function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn(command: string, options: SpawnOptions): ChildProcess; + // overloads of spawn with 'args' + function spawn( + command: string, + args?: readonly string[], + options?: SpawnOptionsWithoutStdio, + ): ChildProcessWithoutNullStreams; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn( + command: string, + args: readonly string[], + options: SpawnOptionsWithStdioTuple, + ): ChildProcessByStdio; + function spawn(command: string, args: readonly string[], options: SpawnOptions): ChildProcess; + interface ExecOptions extends CommonOptions { + shell?: string | undefined; + signal?: AbortSignal | undefined; + maxBuffer?: number | undefined; + killSignal?: NodeJS.Signals | number | undefined; + } + interface ExecOptionsWithStringEncoding extends ExecOptions { + encoding: BufferEncoding; + } + interface ExecOptionsWithBufferEncoding extends ExecOptions { + encoding: BufferEncoding | null; // specify `null`. + } + interface ExecException extends Error { + cmd?: string | undefined; + killed?: boolean | undefined; + code?: number | undefined; + signal?: NodeJS.Signals | undefined; + } + /** + * Spawns a shell then executes the `command` within that shell, buffering any + * generated output. The `command` string passed to the exec function is processed + * directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters)) + * need to be dealt with accordingly: + * + * ```js + * const { exec } = require('node:child_process'); + * + * exec('"/path/to/test file/test.sh" arg1 arg2'); + * // Double quotes are used so that the space in the path is not interpreted as + * // a delimiter of multiple arguments. + * + * exec('echo "The \\$HOME variable is $HOME"'); + * // The $HOME variable is escaped in the first instance, but not in the second. + * ``` + * + * **Never pass unsanitized user input to this function. Any input containing shell** + * **metacharacters may be used to trigger arbitrary command execution.** + * + * If a `callback` function is provided, it is called with the arguments`(error, stdout, stderr)`. On success, `error` will be `null`. On error,`error` will be an instance of `Error`. The + * `error.code` property will be + * the exit code of the process. By convention, any exit code other than `0`indicates an error. `error.signal` will be the signal that terminated the + * process. + * + * The `stdout` and `stderr` arguments passed to the callback will contain the + * stdout and stderr output of the child process. By default, Node.js will decode + * the output as UTF-8 and pass strings to the callback. The `encoding` option + * can be used to specify the character encoding used to decode the stdout and + * stderr output. If `encoding` is `'buffer'`, or an unrecognized character + * encoding, `Buffer` objects will be passed to the callback instead. + * + * ```js + * const { exec } = require('node:child_process'); + * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => { + * if (error) { + * console.error(`exec error: ${error}`); + * return; + * } + * console.log(`stdout: ${stdout}`); + * console.error(`stderr: ${stderr}`); + * }); + * ``` + * + * If `timeout` is greater than `0`, the parent will send the signal + * identified by the `killSignal` property (the default is `'SIGTERM'`) if the + * child runs longer than `timeout` milliseconds. + * + * Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace + * the existing process and uses a shell to execute the command. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In + * case of an error (including any error resulting in an exit code other than 0), a + * rejected promise is returned, with the same `error` object given in the + * callback, but with two additional properties `stdout` and `stderr`. + * + * ```js + * const util = require('node:util'); + * const exec = util.promisify(require('node:child_process').exec); + * + * async function lsExample() { + * const { stdout, stderr } = await exec('ls'); + * console.log('stdout:', stdout); + * console.error('stderr:', stderr); + * } + * lsExample(); + * ``` + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except + * the error passed to the callback will be an `AbortError`: + * + * ```js + * const { exec } = require('node:child_process'); + * const controller = new AbortController(); + * const { signal } = controller; + * const child = exec('grep ssh', { signal }, (error) => { + * console.error(error); // an AbortError + * }); + * controller.abort(); + * ``` + * @since v0.1.90 + * @param command The command to run, with space-separated arguments. + * @param callback called with the output when process terminates. + */ + function exec( + command: string, + callback?: (error: ExecException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`. + function exec( + command: string, + options: { + encoding: "buffer" | null; + } & ExecOptions, + callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void, + ): ChildProcess; + // `options` with well known `encoding` means stdout/stderr are definitely `string`. + function exec( + command: string, + options: { + encoding: BufferEncoding; + } & ExecOptions, + callback?: (error: ExecException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`. + // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`. + function exec( + command: string, + options: { + encoding: BufferEncoding; + } & ExecOptions, + callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void, + ): ChildProcess; + // `options` without an `encoding` means stdout/stderr are definitely `string`. + function exec( + command: string, + options: ExecOptions, + callback?: (error: ExecException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // fallback if nothing else matches. Worst case is always `string | Buffer`. + function exec( + command: string, + options: (ObjectEncodingOptions & ExecOptions) | undefined | null, + callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void, + ): ChildProcess; + interface PromiseWithChild extends Promise { + child: ChildProcess; + } + namespace exec { + function __promisify__(command: string): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + command: string, + options: { + encoding: "buffer" | null; + } & ExecOptions, + ): PromiseWithChild<{ + stdout: Buffer; + stderr: Buffer; + }>; + function __promisify__( + command: string, + options: { + encoding: BufferEncoding; + } & ExecOptions, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + command: string, + options: ExecOptions, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + command: string, + options?: (ObjectEncodingOptions & ExecOptions) | null, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + } + interface ExecFileOptions extends CommonOptions, Abortable { + maxBuffer?: number | undefined; + killSignal?: NodeJS.Signals | number | undefined; + windowsVerbatimArguments?: boolean | undefined; + shell?: boolean | string | undefined; + signal?: AbortSignal | undefined; + } + interface ExecFileOptionsWithStringEncoding extends ExecFileOptions { + encoding: BufferEncoding; + } + interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions { + encoding: "buffer" | null; + } + interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions { + encoding: BufferEncoding; + } + type ExecFileException = + & Omit + & Omit + & { code?: string | number | undefined | null }; + /** + * The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified + * executable `file` is spawned directly as a new process making it slightly more + * efficient than {@link exec}. + * + * The same options as {@link exec} are supported. Since a shell is + * not spawned, behaviors such as I/O redirection and file globbing are not + * supported. + * + * ```js + * const { execFile } = require('node:child_process'); + * const child = execFile('node', ['--version'], (error, stdout, stderr) => { + * if (error) { + * throw error; + * } + * console.log(stdout); + * }); + * ``` + * + * The `stdout` and `stderr` arguments passed to the callback will contain the + * stdout and stderr output of the child process. By default, Node.js will decode + * the output as UTF-8 and pass strings to the callback. The `encoding` option + * can be used to specify the character encoding used to decode the stdout and + * stderr output. If `encoding` is `'buffer'`, or an unrecognized character + * encoding, `Buffer` objects will be passed to the callback instead. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In + * case of an error (including any error resulting in an exit code other than 0), a + * rejected promise is returned, with the same `error` object given in the + * callback, but with two additional properties `stdout` and `stderr`. + * + * ```js + * const util = require('node:util'); + * const execFile = util.promisify(require('node:child_process').execFile); + * async function getVersion() { + * const { stdout } = await execFile('node', ['--version']); + * console.log(stdout); + * } + * getVersion(); + * ``` + * + * **If the `shell` option is enabled, do not pass unsanitized user input to this** + * **function. Any input containing shell metacharacters may be used to trigger** + * **arbitrary command execution.** + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except + * the error passed to the callback will be an `AbortError`: + * + * ```js + * const { execFile } = require('node:child_process'); + * const controller = new AbortController(); + * const { signal } = controller; + * const child = execFile('node', ['--version'], { signal }, (error) => { + * console.error(error); // an AbortError + * }); + * controller.abort(); + * ``` + * @since v0.1.91 + * @param file The name or path of the executable file to run. + * @param args List of string arguments. + * @param callback Called with the output when process terminates. + */ + function execFile(file: string): ChildProcess; + function execFile( + file: string, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + ): ChildProcess; + function execFile(file: string, args?: readonly string[] | null): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + ): ChildProcess; + // no `options` definitely means stdout/stderr are `string`. + function execFile( + file: string, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`. + function execFile( + file: string, + options: ExecFileOptionsWithBufferEncoding, + callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithBufferEncoding, + callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void, + ): ChildProcess; + // `options` with well known `encoding` means stdout/stderr are definitely `string`. + function execFile( + file: string, + options: ExecFileOptionsWithStringEncoding, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithStringEncoding, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`. + // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`. + function execFile( + file: string, + options: ExecFileOptionsWithOtherEncoding, + callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithOtherEncoding, + callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void, + ): ChildProcess; + // `options` without an `encoding` means stdout/stderr are definitely `string`. + function execFile( + file: string, + options: ExecFileOptions, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptions, + callback: (error: ExecFileException | null, stdout: string, stderr: string) => void, + ): ChildProcess; + // fallback if nothing else matches. Worst case is always `string | Buffer`. + function execFile( + file: string, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + callback: + | ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) + | undefined + | null, + ): ChildProcess; + function execFile( + file: string, + args: readonly string[] | undefined | null, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + callback: + | ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) + | undefined + | null, + ): ChildProcess; + namespace execFile { + function __promisify__(file: string): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + options: ExecFileOptionsWithBufferEncoding, + ): PromiseWithChild<{ + stdout: Buffer; + stderr: Buffer; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithBufferEncoding, + ): PromiseWithChild<{ + stdout: Buffer; + stderr: Buffer; + }>; + function __promisify__( + file: string, + options: ExecFileOptionsWithStringEncoding, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithStringEncoding, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + options: ExecFileOptionsWithOtherEncoding, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptionsWithOtherEncoding, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + function __promisify__( + file: string, + options: ExecFileOptions, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: ExecFileOptions, + ): PromiseWithChild<{ + stdout: string; + stderr: string; + }>; + function __promisify__( + file: string, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + function __promisify__( + file: string, + args: readonly string[] | undefined | null, + options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null, + ): PromiseWithChild<{ + stdout: string | Buffer; + stderr: string | Buffer; + }>; + } + interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable { + execPath?: string | undefined; + execArgv?: string[] | undefined; + silent?: boolean | undefined; + /** + * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ + stdio?: StdioOptions | undefined; + detached?: boolean | undefined; + windowsVerbatimArguments?: boolean | undefined; + } + /** + * The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes. + * Like {@link spawn}, a `ChildProcess` object is returned. The + * returned `ChildProcess` will have an additional communication channel + * built-in that allows messages to be passed back and forth between the parent and + * child. See `subprocess.send()` for details. + * + * Keep in mind that spawned Node.js child processes are + * independent of the parent with exception of the IPC communication channel + * that is established between the two. Each process has its own memory, with + * their own V8 instances. Because of the additional resource allocations + * required, spawning a large number of child Node.js processes is not + * recommended. + * + * By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the`options` object allows for an alternative + * execution path to be used. + * + * Node.js processes launched with a custom `execPath` will communicate with the + * parent process using the file descriptor (fd) identified using the + * environment variable `NODE_CHANNEL_FD` on the child process. + * + * Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the + * current process. + * + * The `shell` option available in {@link spawn} is not supported by`child_process.fork()` and will be ignored if set. + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except + * the error passed to the callback will be an `AbortError`: + * + * ```js + * if (process.argv[2] === 'child') { + * setTimeout(() => { + * console.log(`Hello from ${process.argv[2]}!`); + * }, 1_000); + * } else { + * const { fork } = require('node:child_process'); + * const controller = new AbortController(); + * const { signal } = controller; + * const child = fork(__filename, ['child'], { signal }); + * child.on('error', (err) => { + * // This will be called with err being an AbortError if the controller aborts + * }); + * controller.abort(); // Stops the child process + * } + * ``` + * @since v0.5.0 + * @param modulePath The module to run in the child. + * @param args List of string arguments. + */ + function fork(modulePath: string, options?: ForkOptions): ChildProcess; + function fork(modulePath: string, args?: readonly string[], options?: ForkOptions): ChildProcess; + interface SpawnSyncOptions extends CommonSpawnOptions { + input?: string | NodeJS.ArrayBufferView | undefined; + maxBuffer?: number | undefined; + encoding?: BufferEncoding | "buffer" | null | undefined; + } + interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions { + encoding: BufferEncoding; + } + interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions { + encoding?: "buffer" | null | undefined; + } + interface SpawnSyncReturns { + pid: number; + output: Array; + stdout: T; + stderr: T; + status: number | null; + signal: NodeJS.Signals | null; + error?: Error | undefined; + } + /** + * The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return + * until the child process has fully closed. When a timeout has been encountered + * and `killSignal` is sent, the method won't return until the process has + * completely exited. If the process intercepts and handles the `SIGTERM` signal + * and doesn't exit, the parent process will wait until the child process has + * exited. + * + * **If the `shell` option is enabled, do not pass unsanitized user input to this** + * **function. Any input containing shell metacharacters may be used to trigger** + * **arbitrary command execution.** + * @since v0.11.12 + * @param command The command to run. + * @param args List of string arguments. + */ + function spawnSync(command: string): SpawnSyncReturns; + function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; + function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; + function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; + function spawnSync(command: string, args: readonly string[]): SpawnSyncReturns; + function spawnSync( + command: string, + args: readonly string[], + options: SpawnSyncOptionsWithStringEncoding, + ): SpawnSyncReturns; + function spawnSync( + command: string, + args: readonly string[], + options: SpawnSyncOptionsWithBufferEncoding, + ): SpawnSyncReturns; + function spawnSync( + command: string, + args?: readonly string[], + options?: SpawnSyncOptions, + ): SpawnSyncReturns; + interface CommonExecOptions extends CommonOptions { + input?: string | NodeJS.ArrayBufferView | undefined; + /** + * Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings. + * If passed as an array, the first element is used for `stdin`, the second for + * `stdout`, and the third for `stderr`. A fourth element can be used to + * specify the `stdio` behavior beyond the standard streams. See + * {@link ChildProcess.stdio} for more information. + * + * @default 'pipe' + */ + stdio?: StdioOptions | undefined; + killSignal?: NodeJS.Signals | number | undefined; + maxBuffer?: number | undefined; + encoding?: BufferEncoding | "buffer" | null | undefined; + } + interface ExecSyncOptions extends CommonExecOptions { + shell?: string | undefined; + } + interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions { + encoding: BufferEncoding; + } + interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions { + encoding?: "buffer" | null | undefined; + } + /** + * The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return + * until the child process has fully closed. When a timeout has been encountered + * and `killSignal` is sent, the method won't return until the process has + * completely exited. If the child process intercepts and handles the `SIGTERM`signal and doesn't exit, the parent process will wait until the child process + * has exited. + * + * If the process times out or has a non-zero exit code, this method will throw. + * The `Error` object will contain the entire result from {@link spawnSync}. + * + * **Never pass unsanitized user input to this function. Any input containing shell** + * **metacharacters may be used to trigger arbitrary command execution.** + * @since v0.11.12 + * @param command The command to run. + * @return The stdout from the command. + */ + function execSync(command: string): Buffer; + function execSync(command: string, options: ExecSyncOptionsWithStringEncoding): string; + function execSync(command: string, options: ExecSyncOptionsWithBufferEncoding): Buffer; + function execSync(command: string, options?: ExecSyncOptions): string | Buffer; + interface ExecFileSyncOptions extends CommonExecOptions { + shell?: boolean | string | undefined; + } + interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions { + encoding: BufferEncoding; + } + interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions { + encoding?: "buffer" | null; // specify `null`. + } + /** + * The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not + * return until the child process has fully closed. When a timeout has been + * encountered and `killSignal` is sent, the method won't return until the process + * has completely exited. + * + * If the child process intercepts and handles the `SIGTERM` signal and + * does not exit, the parent process will still wait until the child process has + * exited. + * + * If the process times out or has a non-zero exit code, this method will throw an `Error` that will include the full result of the underlying {@link spawnSync}. + * + * **If the `shell` option is enabled, do not pass unsanitized user input to this** + * **function. Any input containing shell metacharacters may be used to trigger** + * **arbitrary command execution.** + * @since v0.11.12 + * @param file The name or path of the executable file to run. + * @param args List of string arguments. + * @return The stdout from the command. + */ + function execFileSync(file: string): Buffer; + function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string; + function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer; + function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer; + function execFileSync(file: string, args: readonly string[]): Buffer; + function execFileSync( + file: string, + args: readonly string[], + options: ExecFileSyncOptionsWithStringEncoding, + ): string; + function execFileSync( + file: string, + args: readonly string[], + options: ExecFileSyncOptionsWithBufferEncoding, + ): Buffer; + function execFileSync(file: string, args?: readonly string[], options?: ExecFileSyncOptions): string | Buffer; +} +declare module "node:child_process" { + export * from "child_process"; +} diff --git a/node_modules/@types/node/ts4.8/cluster.d.ts b/node_modules/@types/node/ts4.8/cluster.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39cd56ad3c6e2fa946dc94c84e581e385eab2627 --- /dev/null +++ b/node_modules/@types/node/ts4.8/cluster.d.ts @@ -0,0 +1,432 @@ +/** + * Clusters of Node.js processes can be used to run multiple instances of Node.js + * that can distribute workloads among their application threads. When process + * isolation is not needed, use the `worker_threads` module instead, which + * allows running multiple application threads within a single Node.js instance. + * + * The cluster module allows easy creation of child processes that all share + * server ports. + * + * ```js + * import cluster from 'node:cluster'; + * import http from 'node:http'; + * import { availableParallelism } from 'node:os'; + * import process from 'node:process'; + * + * const numCPUs = availableParallelism(); + * + * if (cluster.isPrimary) { + * console.log(`Primary ${process.pid} is running`); + * + * // Fork workers. + * for (let i = 0; i < numCPUs; i++) { + * cluster.fork(); + * } + * + * cluster.on('exit', (worker, code, signal) => { + * console.log(`worker ${worker.process.pid} died`); + * }); + * } else { + * // Workers can share any TCP connection + * // In this case it is an HTTP server + * http.createServer((req, res) => { + * res.writeHead(200); + * res.end('hello world\n'); + * }).listen(8000); + * + * console.log(`Worker ${process.pid} started`); + * } + * ``` + * + * Running Node.js will now share port 8000 between the workers: + * + * ```console + * $ node server.js + * Primary 3596 is running + * Worker 4324 started + * Worker 4520 started + * Worker 6056 started + * Worker 5644 started + * ``` + * + * On Windows, it is not yet possible to set up a named pipe server in a worker. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/cluster.js) + */ +declare module "cluster" { + import * as child from "node:child_process"; + import EventEmitter = require("node:events"); + import * as net from "node:net"; + type SerializationType = "json" | "advanced"; + export interface ClusterSettings { + execArgv?: string[] | undefined; // default: process.execArgv + exec?: string | undefined; + args?: string[] | undefined; + silent?: boolean | undefined; + stdio?: any[] | undefined; + uid?: number | undefined; + gid?: number | undefined; + inspectPort?: number | (() => number) | undefined; + serialization?: SerializationType | undefined; + cwd?: string | undefined; + windowsHide?: boolean | undefined; + } + export interface Address { + address: string; + port: number; + addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6" + } + /** + * A `Worker` object contains all public information and method about a worker. + * In the primary it can be obtained using `cluster.workers`. In a worker + * it can be obtained using `cluster.worker`. + * @since v0.7.0 + */ + export class Worker extends EventEmitter { + /** + * Each new worker is given its own unique id, this id is stored in the`id`. + * + * While a worker is alive, this is the key that indexes it in`cluster.workers`. + * @since v0.8.0 + */ + id: number; + /** + * All workers are created using `child_process.fork()`, the returned object + * from this function is stored as `.process`. In a worker, the global `process`is stored. + * + * See: `Child Process module`. + * + * Workers will call `process.exit(0)` if the `'disconnect'` event occurs + * on `process` and `.exitedAfterDisconnect` is not `true`. This protects against + * accidental disconnection. + * @since v0.7.0 + */ + process: child.ChildProcess; + /** + * Send a message to a worker or primary, optionally with a handle. + * + * In the primary, this sends a message to a specific worker. It is identical to `ChildProcess.send()`. + * + * In a worker, this sends a message to the primary. It is identical to`process.send()`. + * + * This example will echo back all messages from the primary: + * + * ```js + * if (cluster.isPrimary) { + * const worker = cluster.fork(); + * worker.send('hi there'); + * + * } else if (cluster.isWorker) { + * process.on('message', (msg) => { + * process.send(msg); + * }); + * } + * ``` + * @since v0.7.0 + * @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties: + */ + send(message: child.Serializable, callback?: (error: Error | null) => void): boolean; + send( + message: child.Serializable, + sendHandle: child.SendHandle, + callback?: (error: Error | null) => void, + ): boolean; + send( + message: child.Serializable, + sendHandle: child.SendHandle, + options?: child.MessageOptions, + callback?: (error: Error | null) => void, + ): boolean; + /** + * This function will kill the worker. In the primary worker, it does this by + * disconnecting the `worker.process`, and once disconnected, killing with`signal`. In the worker, it does it by killing the process with `signal`. + * + * The `kill()` function kills the worker process without waiting for a graceful + * disconnect, it has the same behavior as `worker.process.kill()`. + * + * This method is aliased as `worker.destroy()` for backwards compatibility. + * + * In a worker, `process.kill()` exists, but it is not this function; + * it is `kill()`. + * @since v0.9.12 + * @param [signal='SIGTERM'] Name of the kill signal to send to the worker process. + */ + kill(signal?: string): void; + destroy(signal?: string): void; + /** + * In a worker, this function will close all servers, wait for the `'close'` event + * on those servers, and then disconnect the IPC channel. + * + * In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself. + * + * Causes `.exitedAfterDisconnect` to be set. + * + * After a server is closed, it will no longer accept new connections, + * but connections may be accepted by any other listening worker. Existing + * connections will be allowed to close as usual. When no more connections exist, + * see `server.close()`, the IPC channel to the worker will close allowing it + * to die gracefully. + * + * The above applies _only_ to server connections, client connections are not + * automatically closed by workers, and disconnect does not wait for them to close + * before exiting. + * + * In a worker, `process.disconnect` exists, but it is not this function; + * it is `disconnect()`. + * + * Because long living server connections may block workers from disconnecting, it + * may be useful to send a message, so application specific actions may be taken to + * close them. It also may be useful to implement a timeout, killing a worker if + * the `'disconnect'` event has not been emitted after some time. + * + * ```js + * if (cluster.isPrimary) { + * const worker = cluster.fork(); + * let timeout; + * + * worker.on('listening', (address) => { + * worker.send('shutdown'); + * worker.disconnect(); + * timeout = setTimeout(() => { + * worker.kill(); + * }, 2000); + * }); + * + * worker.on('disconnect', () => { + * clearTimeout(timeout); + * }); + * + * } else if (cluster.isWorker) { + * const net = require('node:net'); + * const server = net.createServer((socket) => { + * // Connections never end + * }); + * + * server.listen(8000); + * + * process.on('message', (msg) => { + * if (msg === 'shutdown') { + * // Initiate graceful close of any connections to server + * } + * }); + * } + * ``` + * @since v0.7.7 + * @return A reference to `worker`. + */ + disconnect(): void; + /** + * This function returns `true` if the worker is connected to its primary via its + * IPC channel, `false` otherwise. A worker is connected to its primary after it + * has been created. It is disconnected after the `'disconnect'` event is emitted. + * @since v0.11.14 + */ + isConnected(): boolean; + /** + * This function returns `true` if the worker's process has terminated (either + * because of exiting or being signaled). Otherwise, it returns `false`. + * + * ```js + * import cluster from 'node:cluster'; + * import http from 'node:http'; + * import { availableParallelism } from 'node:os'; + * import process from 'node:process'; + * + * const numCPUs = availableParallelism(); + * + * if (cluster.isPrimary) { + * console.log(`Primary ${process.pid} is running`); + * + * // Fork workers. + * for (let i = 0; i < numCPUs; i++) { + * cluster.fork(); + * } + * + * cluster.on('fork', (worker) => { + * console.log('worker is dead:', worker.isDead()); + * }); + * + * cluster.on('exit', (worker, code, signal) => { + * console.log('worker is dead:', worker.isDead()); + * }); + * } else { + * // Workers can share any TCP connection. In this case, it is an HTTP server. + * http.createServer((req, res) => { + * res.writeHead(200); + * res.end(`Current process\n ${process.pid}`); + * process.kill(process.pid); + * }).listen(8000); + * } + * ``` + * @since v0.11.14 + */ + isDead(): boolean; + /** + * This property is `true` if the worker exited due to `.disconnect()`. + * If the worker exited any other way, it is `false`. If the + * worker has not exited, it is `undefined`. + * + * The boolean `worker.exitedAfterDisconnect` allows distinguishing between + * voluntary and accidental exit, the primary may choose not to respawn a worker + * based on this value. + * + * ```js + * cluster.on('exit', (worker, code, signal) => { + * if (worker.exitedAfterDisconnect === true) { + * console.log('Oh, it was just voluntary – no need to worry'); + * } + * }); + * + * // kill worker + * worker.kill(); + * ``` + * @since v6.0.0 + */ + exitedAfterDisconnect: boolean; + /** + * events.EventEmitter + * 1. disconnect + * 2. error + * 3. exit + * 4. listening + * 5. message + * 6. online + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "disconnect", listener: () => void): this; + addListener(event: "error", listener: (error: Error) => void): this; + addListener(event: "exit", listener: (code: number, signal: string) => void): this; + addListener(event: "listening", listener: (address: Address) => void): this; + addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + addListener(event: "online", listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "disconnect"): boolean; + emit(event: "error", error: Error): boolean; + emit(event: "exit", code: number, signal: string): boolean; + emit(event: "listening", address: Address): boolean; + emit(event: "message", message: any, handle: net.Socket | net.Server): boolean; + emit(event: "online"): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "disconnect", listener: () => void): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "exit", listener: (code: number, signal: string) => void): this; + on(event: "listening", listener: (address: Address) => void): this; + on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + on(event: "online", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "disconnect", listener: () => void): this; + once(event: "error", listener: (error: Error) => void): this; + once(event: "exit", listener: (code: number, signal: string) => void): this; + once(event: "listening", listener: (address: Address) => void): this; + once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + once(event: "online", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "disconnect", listener: () => void): this; + prependListener(event: "error", listener: (error: Error) => void): this; + prependListener(event: "exit", listener: (code: number, signal: string) => void): this; + prependListener(event: "listening", listener: (address: Address) => void): this; + prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + prependListener(event: "online", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "disconnect", listener: () => void): this; + prependOnceListener(event: "error", listener: (error: Error) => void): this; + prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; + prependOnceListener(event: "listening", listener: (address: Address) => void): this; + prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + prependOnceListener(event: "online", listener: () => void): this; + } + export interface Cluster extends EventEmitter { + disconnect(callback?: () => void): void; + fork(env?: any): Worker; + /** @deprecated since v16.0.0 - use isPrimary. */ + readonly isMaster: boolean; + readonly isPrimary: boolean; + readonly isWorker: boolean; + schedulingPolicy: number; + readonly settings: ClusterSettings; + /** @deprecated since v16.0.0 - use setupPrimary. */ + setupMaster(settings?: ClusterSettings): void; + /** + * `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings. + */ + setupPrimary(settings?: ClusterSettings): void; + readonly worker?: Worker | undefined; + readonly workers?: NodeJS.Dict | undefined; + readonly SCHED_NONE: number; + readonly SCHED_RR: number; + /** + * events.EventEmitter + * 1. disconnect + * 2. exit + * 3. fork + * 4. listening + * 5. message + * 6. online + * 7. setup + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "disconnect", listener: (worker: Worker) => void): this; + addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + addListener(event: "fork", listener: (worker: Worker) => void): this; + addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + addListener( + event: "message", + listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void, + ): this; // the handle is a net.Socket or net.Server object, or undefined. + addListener(event: "online", listener: (worker: Worker) => void): this; + addListener(event: "setup", listener: (settings: ClusterSettings) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "disconnect", worker: Worker): boolean; + emit(event: "exit", worker: Worker, code: number, signal: string): boolean; + emit(event: "fork", worker: Worker): boolean; + emit(event: "listening", worker: Worker, address: Address): boolean; + emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean; + emit(event: "online", worker: Worker): boolean; + emit(event: "setup", settings: ClusterSettings): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "disconnect", listener: (worker: Worker) => void): this; + on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + on(event: "fork", listener: (worker: Worker) => void): this; + on(event: "listening", listener: (worker: Worker, address: Address) => void): this; + on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + on(event: "online", listener: (worker: Worker) => void): this; + on(event: "setup", listener: (settings: ClusterSettings) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "disconnect", listener: (worker: Worker) => void): this; + once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + once(event: "fork", listener: (worker: Worker) => void): this; + once(event: "listening", listener: (worker: Worker, address: Address) => void): this; + once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + once(event: "online", listener: (worker: Worker) => void): this; + once(event: "setup", listener: (settings: ClusterSettings) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "disconnect", listener: (worker: Worker) => void): this; + prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + prependListener(event: "fork", listener: (worker: Worker) => void): this; + prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + // the handle is a net.Socket or net.Server object, or undefined. + prependListener( + event: "message", + listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void, + ): this; + prependListener(event: "online", listener: (worker: Worker) => void): this; + prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; + prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; + prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + // the handle is a net.Socket or net.Server object, or undefined. + prependOnceListener( + event: "message", + listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void, + ): this; + prependOnceListener(event: "online", listener: (worker: Worker) => void): this; + prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this; + } + const cluster: Cluster; + export default cluster; +} +declare module "node:cluster" { + export * from "cluster"; + export { default as default } from "cluster"; +} diff --git a/node_modules/@types/node/ts4.8/console.d.ts b/node_modules/@types/node/ts4.8/console.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bcc345042058790cbb22a77c89c62cab472ab86d --- /dev/null +++ b/node_modules/@types/node/ts4.8/console.d.ts @@ -0,0 +1,415 @@ +/** + * The `node:console` module provides a simple debugging console that is similar to + * the JavaScript console mechanism provided by web browsers. + * + * The module exports two specific components: + * + * * A `Console` class with methods such as `console.log()`, `console.error()`, and`console.warn()` that can be used to write to any Node.js stream. + * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('node:console')`. + * + * _**Warning**_: The global console object's methods are neither consistently + * synchronous like the browser APIs they resemble, nor are they consistently + * asynchronous like all other Node.js streams. See the `note on process I/O` for + * more information. + * + * Example using the global `console`: + * + * ```js + * console.log('hello world'); + * // Prints: hello world, to stdout + * console.log('hello %s', 'world'); + * // Prints: hello world, to stdout + * console.error(new Error('Whoops, something bad happened')); + * // Prints error message and stack trace to stderr: + * // Error: Whoops, something bad happened + * // at [eval]:5:15 + * // at Script.runInThisContext (node:vm:132:18) + * // at Object.runInThisContext (node:vm:309:38) + * // at node:internal/process/execution:77:19 + * // at [eval]-wrapper:6:22 + * // at evalScript (node:internal/process/execution:76:60) + * // at node:internal/main/eval_string:23:3 + * + * const name = 'Will Robinson'; + * console.warn(`Danger ${name}! Danger!`); + * // Prints: Danger Will Robinson! Danger!, to stderr + * ``` + * + * Example using the `Console` class: + * + * ```js + * const out = getStreamSomehow(); + * const err = getStreamSomehow(); + * const myConsole = new console.Console(out, err); + * + * myConsole.log('hello world'); + * // Prints: hello world, to out + * myConsole.log('hello %s', 'world'); + * // Prints: hello world, to out + * myConsole.error(new Error('Whoops, something bad happened')); + * // Prints: [Error: Whoops, something bad happened], to err + * + * const name = 'Will Robinson'; + * myConsole.warn(`Danger ${name}! Danger!`); + * // Prints: Danger Will Robinson! Danger!, to err + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/console.js) + */ +declare module "console" { + import console = require("node:console"); + export = console; +} +declare module "node:console" { + import { InspectOptions } from "node:util"; + global { + // This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build + interface Console { + Console: console.ConsoleConstructor; + /** + * `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only + * writes a message and does not otherwise affect execution. The output always + * starts with `"Assertion failed"`. If provided, `message` is formatted using `util.format()`. + * + * If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens. + * + * ```js + * console.assert(true, 'does nothing'); + * + * console.assert(false, 'Whoops %s work', 'didn\'t'); + * // Assertion failed: Whoops didn't work + * + * console.assert(); + * // Assertion failed + * ``` + * @since v0.1.101 + * @param value The value tested for being truthy. + * @param message All arguments besides `value` are used as error message. + */ + assert(value: any, message?: string, ...optionalParams: any[]): void; + /** + * When `stdout` is a TTY, calling `console.clear()` will attempt to clear the + * TTY. When `stdout` is not a TTY, this method does nothing. + * + * The specific operation of `console.clear()` can vary across operating systems + * and terminal types. For most Linux operating systems, `console.clear()`operates similarly to the `clear` shell command. On Windows, `console.clear()`will clear only the output in the + * current terminal viewport for the Node.js + * binary. + * @since v8.3.0 + */ + clear(): void; + /** + * Maintains an internal counter specific to `label` and outputs to `stdout` the + * number of times `console.count()` has been called with the given `label`. + * + * ```js + * > console.count() + * default: 1 + * undefined + * > console.count('default') + * default: 2 + * undefined + * > console.count('abc') + * abc: 1 + * undefined + * > console.count('xyz') + * xyz: 1 + * undefined + * > console.count('abc') + * abc: 2 + * undefined + * > console.count() + * default: 3 + * undefined + * > + * ``` + * @since v8.3.0 + * @param [label='default'] The display label for the counter. + */ + count(label?: string): void; + /** + * Resets the internal counter specific to `label`. + * + * ```js + * > console.count('abc'); + * abc: 1 + * undefined + * > console.countReset('abc'); + * undefined + * > console.count('abc'); + * abc: 1 + * undefined + * > + * ``` + * @since v8.3.0 + * @param [label='default'] The display label for the counter. + */ + countReset(label?: string): void; + /** + * The `console.debug()` function is an alias for {@link log}. + * @since v8.0.0 + */ + debug(message?: any, ...optionalParams: any[]): void; + /** + * Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`. + * This function bypasses any custom `inspect()` function defined on `obj`. + * @since v0.1.101 + */ + dir(obj: any, options?: InspectOptions): void; + /** + * This method calls `console.log()` passing it the arguments received. + * This method does not produce any XML formatting. + * @since v8.0.0 + */ + dirxml(...data: any[]): void; + /** + * Prints to `stderr` with newline. Multiple arguments can be passed, with the + * first used as the primary message and all additional used as substitution + * values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`). + * + * ```js + * const code = 5; + * console.error('error #%d', code); + * // Prints: error #5, to stderr + * console.error('error', code); + * // Prints: error 5, to stderr + * ``` + * + * If formatting elements (e.g. `%d`) are not found in the first string then `util.inspect()` is called on each argument and the resulting string + * values are concatenated. See `util.format()` for more information. + * @since v0.1.100 + */ + error(message?: any, ...optionalParams: any[]): void; + /** + * Increases indentation of subsequent lines by spaces for `groupIndentation`length. + * + * If one or more `label`s are provided, those are printed first without the + * additional indentation. + * @since v8.5.0 + */ + group(...label: any[]): void; + /** + * An alias for {@link group}. + * @since v8.5.0 + */ + groupCollapsed(...label: any[]): void; + /** + * Decreases indentation of subsequent lines by spaces for `groupIndentation`length. + * @since v8.5.0 + */ + groupEnd(): void; + /** + * The `console.info()` function is an alias for {@link log}. + * @since v0.1.100 + */ + info(message?: any, ...optionalParams: any[]): void; + /** + * Prints to `stdout` with newline. Multiple arguments can be passed, with the + * first used as the primary message and all additional used as substitution + * values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`). + * + * ```js + * const count = 5; + * console.log('count: %d', count); + * // Prints: count: 5, to stdout + * console.log('count:', count); + * // Prints: count: 5, to stdout + * ``` + * + * See `util.format()` for more information. + * @since v0.1.100 + */ + log(message?: any, ...optionalParams: any[]): void; + /** + * Try to construct a table with the columns of the properties of `tabularData`(or use `properties`) and rows of `tabularData` and log it. Falls back to just + * logging the argument if it can't be parsed as tabular. + * + * ```js + * // These can't be parsed as tabular data + * console.table(Symbol()); + * // Symbol() + * + * console.table(undefined); + * // undefined + * + * console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]); + * // ┌─────────┬─────┬─────┐ + * // │ (index) │ a │ b │ + * // ├─────────┼─────┼─────┤ + * // │ 0 │ 1 │ 'Y' │ + * // │ 1 │ 'Z' │ 2 │ + * // └─────────┴─────┴─────┘ + * + * console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']); + * // ┌─────────┬─────┐ + * // │ (index) │ a │ + * // ├─────────┼─────┤ + * // │ 0 │ 1 │ + * // │ 1 │ 'Z' │ + * // └─────────┴─────┘ + * ``` + * @since v10.0.0 + * @param properties Alternate properties for constructing the table. + */ + table(tabularData: any, properties?: readonly string[]): void; + /** + * Starts a timer that can be used to compute the duration of an operation. Timers + * are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in + * suitable time units to `stdout`. For example, if the elapsed + * time is 3869ms, `console.timeEnd()` displays "3.869s". + * @since v0.1.104 + * @param [label='default'] + */ + time(label?: string): void; + /** + * Stops a timer that was previously started by calling {@link time} and + * prints the result to `stdout`: + * + * ```js + * console.time('bunch-of-stuff'); + * // Do a bunch of stuff. + * console.timeEnd('bunch-of-stuff'); + * // Prints: bunch-of-stuff: 225.438ms + * ``` + * @since v0.1.104 + * @param [label='default'] + */ + timeEnd(label?: string): void; + /** + * For a timer that was previously started by calling {@link time}, prints + * the elapsed time and other `data` arguments to `stdout`: + * + * ```js + * console.time('process'); + * const value = expensiveProcess1(); // Returns 42 + * console.timeLog('process', value); + * // Prints "process: 365.227ms 42". + * doExpensiveProcess2(value); + * console.timeEnd('process'); + * ``` + * @since v10.7.0 + * @param [label='default'] + */ + timeLog(label?: string, ...data: any[]): void; + /** + * Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code. + * + * ```js + * console.trace('Show me'); + * // Prints: (stack trace will vary based on where trace is called) + * // Trace: Show me + * // at repl:2:9 + * // at REPLServer.defaultEval (repl.js:248:27) + * // at bound (domain.js:287:14) + * // at REPLServer.runBound [as eval] (domain.js:300:12) + * // at REPLServer. (repl.js:412:12) + * // at emitOne (events.js:82:20) + * // at REPLServer.emit (events.js:169:7) + * // at REPLServer.Interface._onLine (readline.js:210:10) + * // at REPLServer.Interface._line (readline.js:549:8) + * // at REPLServer.Interface._ttyWrite (readline.js:826:14) + * ``` + * @since v0.1.104 + */ + trace(message?: any, ...optionalParams: any[]): void; + /** + * The `console.warn()` function is an alias for {@link error}. + * @since v0.1.100 + */ + warn(message?: any, ...optionalParams: any[]): void; + // --- Inspector mode only --- + /** + * This method does not display anything unless used in the inspector. + * Starts a JavaScript CPU profile with an optional label. + */ + profile(label?: string): void; + /** + * This method does not display anything unless used in the inspector. + * Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector. + */ + profileEnd(label?: string): void; + /** + * This method does not display anything unless used in the inspector. + * Adds an event with the label `label` to the Timeline panel of the inspector. + */ + timeStamp(label?: string): void; + } + /** + * The `console` module provides a simple debugging console that is similar to the + * JavaScript console mechanism provided by web browsers. + * + * The module exports two specific components: + * + * * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream. + * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`. + * + * _**Warning**_: The global console object's methods are neither consistently + * synchronous like the browser APIs they resemble, nor are they consistently + * asynchronous like all other Node.js streams. See the `note on process I/O` for + * more information. + * + * Example using the global `console`: + * + * ```js + * console.log('hello world'); + * // Prints: hello world, to stdout + * console.log('hello %s', 'world'); + * // Prints: hello world, to stdout + * console.error(new Error('Whoops, something bad happened')); + * // Prints error message and stack trace to stderr: + * // Error: Whoops, something bad happened + * // at [eval]:5:15 + * // at Script.runInThisContext (node:vm:132:18) + * // at Object.runInThisContext (node:vm:309:38) + * // at node:internal/process/execution:77:19 + * // at [eval]-wrapper:6:22 + * // at evalScript (node:internal/process/execution:76:60) + * // at node:internal/main/eval_string:23:3 + * + * const name = 'Will Robinson'; + * console.warn(`Danger ${name}! Danger!`); + * // Prints: Danger Will Robinson! Danger!, to stderr + * ``` + * + * Example using the `Console` class: + * + * ```js + * const out = getStreamSomehow(); + * const err = getStreamSomehow(); + * const myConsole = new console.Console(out, err); + * + * myConsole.log('hello world'); + * // Prints: hello world, to out + * myConsole.log('hello %s', 'world'); + * // Prints: hello world, to out + * myConsole.error(new Error('Whoops, something bad happened')); + * // Prints: [Error: Whoops, something bad happened], to err + * + * const name = 'Will Robinson'; + * myConsole.warn(`Danger ${name}! Danger!`); + * // Prints: Danger Will Robinson! Danger!, to err + * ``` + * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js) + */ + namespace console { + interface ConsoleConstructorOptions { + stdout: NodeJS.WritableStream; + stderr?: NodeJS.WritableStream | undefined; + ignoreErrors?: boolean | undefined; + colorMode?: boolean | "auto" | undefined; + inspectOptions?: InspectOptions | undefined; + /** + * Set group indentation + * @default 2 + */ + groupIndentation?: number | undefined; + } + interface ConsoleConstructor { + prototype: Console; + new(stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console; + new(options: ConsoleConstructorOptions): Console; + } + } + var console: Console; + } + export = globalThis.console; +} diff --git a/node_modules/@types/node/ts4.8/constants.d.ts b/node_modules/@types/node/ts4.8/constants.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3ac2b826436020bc945c03bb85c9a9479245f2f --- /dev/null +++ b/node_modules/@types/node/ts4.8/constants.d.ts @@ -0,0 +1,19 @@ +/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */ +declare module "constants" { + import { constants as osConstants, SignalConstants } from "node:os"; + import { constants as cryptoConstants } from "node:crypto"; + import { constants as fsConstants } from "node:fs"; + + const exp: + & typeof osConstants.errno + & typeof osConstants.priority + & SignalConstants + & typeof cryptoConstants + & typeof fsConstants; + export = exp; +} + +declare module "node:constants" { + import constants = require("constants"); + export = constants; +} diff --git a/node_modules/@types/node/ts4.8/crypto.d.ts b/node_modules/@types/node/ts4.8/crypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a540d91f619977e89fbcd1d7c342bf1d7a6ea7d6 --- /dev/null +++ b/node_modules/@types/node/ts4.8/crypto.d.ts @@ -0,0 +1,4455 @@ +/** + * The `node:crypto` module provides cryptographic functionality that includes a + * set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify + * functions. + * + * ```js + * const { createHmac } = await import('node:crypto'); + * + * const secret = 'abcdefg'; + * const hash = createHmac('sha256', secret) + * .update('I love cupcakes') + * .digest('hex'); + * console.log(hash); + * // Prints: + * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/crypto.js) + */ +declare module "crypto" { + import * as stream from "node:stream"; + import { PeerCertificate } from "node:tls"; + /** + * SPKAC is a Certificate Signing Request mechanism originally implemented by + * Netscape and was specified formally as part of HTML5's `keygen` element. + * + * `` is deprecated since [HTML 5.2](https://www.w3.org/TR/html52/changes.html#features-removed) and new projects + * should not use this element anymore. + * + * The `node:crypto` module provides the `Certificate` class for working with SPKAC + * data. The most common usage is handling output generated by the HTML5`` element. Node.js uses [OpenSSL's SPKAC + * implementation](https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html) internally. + * @since v0.11.8 + */ + class Certificate { + /** + * ```js + * const { Certificate } = await import('node:crypto'); + * const spkac = getSpkacSomehow(); + * const challenge = Certificate.exportChallenge(spkac); + * console.log(challenge.toString('utf8')); + * // Prints: the challenge as a UTF8 string + * ``` + * @since v9.0.0 + * @param encoding The `encoding` of the `spkac` string. + * @return The challenge component of the `spkac` data structure, which includes a public key and a challenge. + */ + static exportChallenge(spkac: BinaryLike): Buffer; + /** + * ```js + * const { Certificate } = await import('node:crypto'); + * const spkac = getSpkacSomehow(); + * const publicKey = Certificate.exportPublicKey(spkac); + * console.log(publicKey); + * // Prints: the public key as + * ``` + * @since v9.0.0 + * @param encoding The `encoding` of the `spkac` string. + * @return The public key component of the `spkac` data structure, which includes a public key and a challenge. + */ + static exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer; + /** + * ```js + * import { Buffer } from 'node:buffer'; + * const { Certificate } = await import('node:crypto'); + * + * const spkac = getSpkacSomehow(); + * console.log(Certificate.verifySpkac(Buffer.from(spkac))); + * // Prints: true or false + * ``` + * @since v9.0.0 + * @param encoding The `encoding` of the `spkac` string. + * @return `true` if the given `spkac` data structure is valid, `false` otherwise. + */ + static verifySpkac(spkac: NodeJS.ArrayBufferView): boolean; + /** + * @deprecated + * @param spkac + * @returns The challenge component of the `spkac` data structure, + * which includes a public key and a challenge. + */ + exportChallenge(spkac: BinaryLike): Buffer; + /** + * @deprecated + * @param spkac + * @param encoding The encoding of the spkac string. + * @returns The public key component of the `spkac` data structure, + * which includes a public key and a challenge. + */ + exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer; + /** + * @deprecated + * @param spkac + * @returns `true` if the given `spkac` data structure is valid, + * `false` otherwise. + */ + verifySpkac(spkac: NodeJS.ArrayBufferView): boolean; + } + namespace constants { + // https://nodejs.org/dist/latest-v20.x/docs/api/crypto.html#crypto-constants + const OPENSSL_VERSION_NUMBER: number; + /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */ + const SSL_OP_ALL: number; + /** Allows legacy insecure renegotiation between OpenSSL and unpatched clients or servers. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */ + const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; + /** Attempts to use the server's preferences instead of the client's when selecting a cipher. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */ + const SSL_OP_CIPHER_SERVER_PREFERENCE: number; + /** Instructs OpenSSL to use Cisco's "speshul" version of DTLS_BAD_VER. */ + const SSL_OP_CISCO_ANYCONNECT: number; + /** Instructs OpenSSL to turn on cookie exchange. */ + const SSL_OP_COOKIE_EXCHANGE: number; + /** Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. */ + const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; + /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */ + const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; + /** Allows initial connection to servers that do not support RI. */ + const SSL_OP_LEGACY_SERVER_CONNECT: number; + /** Instructs OpenSSL to disable support for SSL/TLS compression. */ + const SSL_OP_NO_COMPRESSION: number; + const SSL_OP_NO_QUERY_MTU: number; + /** Instructs OpenSSL to always start a new session when performing renegotiation. */ + const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; + const SSL_OP_NO_SSLv2: number; + const SSL_OP_NO_SSLv3: number; + const SSL_OP_NO_TICKET: number; + const SSL_OP_NO_TLSv1: number; + const SSL_OP_NO_TLSv1_1: number; + const SSL_OP_NO_TLSv1_2: number; + /** Instructs OpenSSL to disable version rollback attack detection. */ + const SSL_OP_TLS_ROLLBACK_BUG: number; + const ENGINE_METHOD_RSA: number; + const ENGINE_METHOD_DSA: number; + const ENGINE_METHOD_DH: number; + const ENGINE_METHOD_RAND: number; + const ENGINE_METHOD_EC: number; + const ENGINE_METHOD_CIPHERS: number; + const ENGINE_METHOD_DIGESTS: number; + const ENGINE_METHOD_PKEY_METHS: number; + const ENGINE_METHOD_PKEY_ASN1_METHS: number; + const ENGINE_METHOD_ALL: number; + const ENGINE_METHOD_NONE: number; + const DH_CHECK_P_NOT_SAFE_PRIME: number; + const DH_CHECK_P_NOT_PRIME: number; + const DH_UNABLE_TO_CHECK_GENERATOR: number; + const DH_NOT_SUITABLE_GENERATOR: number; + const RSA_PKCS1_PADDING: number; + const RSA_SSLV23_PADDING: number; + const RSA_NO_PADDING: number; + const RSA_PKCS1_OAEP_PADDING: number; + const RSA_X931_PADDING: number; + const RSA_PKCS1_PSS_PADDING: number; + /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the digest size when signing or verifying. */ + const RSA_PSS_SALTLEN_DIGEST: number; + /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the maximum permissible value when signing data. */ + const RSA_PSS_SALTLEN_MAX_SIGN: number; + /** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */ + const RSA_PSS_SALTLEN_AUTO: number; + const POINT_CONVERSION_COMPRESSED: number; + const POINT_CONVERSION_UNCOMPRESSED: number; + const POINT_CONVERSION_HYBRID: number; + /** Specifies the built-in default cipher list used by Node.js (colon-separated values). */ + const defaultCoreCipherList: string; + /** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */ + const defaultCipherList: string; + } + interface HashOptions extends stream.TransformOptions { + /** + * For XOF hash functions such as `shake256`, the + * outputLength option can be used to specify the desired output length in bytes. + */ + outputLength?: number | undefined; + } + /** @deprecated since v10.0.0 */ + const fips: boolean; + /** + * Creates and returns a `Hash` object that can be used to generate hash digests + * using the given `algorithm`. Optional `options` argument controls stream + * behavior. For XOF hash functions such as `'shake256'`, the `outputLength` option + * can be used to specify the desired output length in bytes. + * + * The `algorithm` is dependent on the available algorithms supported by the + * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. + * On recent releases of OpenSSL, `openssl list -digest-algorithms` will + * display the available digest algorithms. + * + * Example: generating the sha256 sum of a file + * + * ```js + * import { + * createReadStream, + * } from 'node:fs'; + * import { argv } from 'node:process'; + * const { + * createHash, + * } = await import('node:crypto'); + * + * const filename = argv[2]; + * + * const hash = createHash('sha256'); + * + * const input = createReadStream(filename); + * input.on('readable', () => { + * // Only one element is going to be produced by the + * // hash stream. + * const data = input.read(); + * if (data) + * hash.update(data); + * else { + * console.log(`${hash.digest('hex')} ${filename}`); + * } + * }); + * ``` + * @since v0.1.92 + * @param options `stream.transform` options + */ + function createHash(algorithm: string, options?: HashOptions): Hash; + /** + * Creates and returns an `Hmac` object that uses the given `algorithm` and `key`. + * Optional `options` argument controls stream behavior. + * + * The `algorithm` is dependent on the available algorithms supported by the + * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. + * On recent releases of OpenSSL, `openssl list -digest-algorithms` will + * display the available digest algorithms. + * + * The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is + * a `KeyObject`, its type must be `secret`. If it is a string, please consider `caveats when using strings as inputs to cryptographic APIs`. If it was + * obtained from a cryptographically secure source of entropy, such as {@link randomBytes} or {@link generateKey}, its length should not + * exceed the block size of `algorithm` (e.g., 512 bits for SHA-256). + * + * Example: generating the sha256 HMAC of a file + * + * ```js + * import { + * createReadStream, + * } from 'node:fs'; + * import { argv } from 'node:process'; + * const { + * createHmac, + * } = await import('node:crypto'); + * + * const filename = argv[2]; + * + * const hmac = createHmac('sha256', 'a secret'); + * + * const input = createReadStream(filename); + * input.on('readable', () => { + * // Only one element is going to be produced by the + * // hash stream. + * const data = input.read(); + * if (data) + * hmac.update(data); + * else { + * console.log(`${hmac.digest('hex')} ${filename}`); + * } + * }); + * ``` + * @since v0.1.94 + * @param options `stream.transform` options + */ + function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac; + // https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings + type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary"; + type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1"; + type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2"; + type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding; + type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; + /** + * The `Hash` class is a utility for creating hash digests of data. It can be + * used in one of two ways: + * + * * As a `stream` that is both readable and writable, where data is written + * to produce a computed hash digest on the readable side, or + * * Using the `hash.update()` and `hash.digest()` methods to produce the + * computed hash. + * + * The {@link createHash} method is used to create `Hash` instances. `Hash`objects are not to be created directly using the `new` keyword. + * + * Example: Using `Hash` objects as streams: + * + * ```js + * const { + * createHash, + * } = await import('node:crypto'); + * + * const hash = createHash('sha256'); + * + * hash.on('readable', () => { + * // Only one element is going to be produced by the + * // hash stream. + * const data = hash.read(); + * if (data) { + * console.log(data.toString('hex')); + * // Prints: + * // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50 + * } + * }); + * + * hash.write('some data to hash'); + * hash.end(); + * ``` + * + * Example: Using `Hash` and piped streams: + * + * ```js + * import { createReadStream } from 'node:fs'; + * import { stdout } from 'node:process'; + * const { createHash } = await import('node:crypto'); + * + * const hash = createHash('sha256'); + * + * const input = createReadStream('test.js'); + * input.pipe(hash).setEncoding('hex').pipe(stdout); + * ``` + * + * Example: Using the `hash.update()` and `hash.digest()` methods: + * + * ```js + * const { + * createHash, + * } = await import('node:crypto'); + * + * const hash = createHash('sha256'); + * + * hash.update('some data to hash'); + * console.log(hash.digest('hex')); + * // Prints: + * // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50 + * ``` + * @since v0.1.92 + */ + class Hash extends stream.Transform { + private constructor(); + /** + * Creates a new `Hash` object that contains a deep copy of the internal state + * of the current `Hash` object. + * + * The optional `options` argument controls stream behavior. For XOF hash + * functions such as `'shake256'`, the `outputLength` option can be used to + * specify the desired output length in bytes. + * + * An error is thrown when an attempt is made to copy the `Hash` object after + * its `hash.digest()` method has been called. + * + * ```js + * // Calculate a rolling hash. + * const { + * createHash, + * } = await import('node:crypto'); + * + * const hash = createHash('sha256'); + * + * hash.update('one'); + * console.log(hash.copy().digest('hex')); + * + * hash.update('two'); + * console.log(hash.copy().digest('hex')); + * + * hash.update('three'); + * console.log(hash.copy().digest('hex')); + * + * // Etc. + * ``` + * @since v13.1.0 + * @param options `stream.transform` options + */ + copy(options?: stream.TransformOptions): Hash; + /** + * Updates the hash content with the given `data`, the encoding of which + * is given in `inputEncoding`. + * If `encoding` is not provided, and the `data` is a string, an + * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored. + * + * This can be called many times with new data as it is streamed. + * @since v0.1.92 + * @param inputEncoding The `encoding` of the `data` string. + */ + update(data: BinaryLike): Hash; + update(data: string, inputEncoding: Encoding): Hash; + /** + * Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method). + * If `encoding` is provided a string will be returned; otherwise + * a `Buffer` is returned. + * + * The `Hash` object can not be used again after `hash.digest()` method has been + * called. Multiple calls will cause an error to be thrown. + * @since v0.1.92 + * @param encoding The `encoding` of the return value. + */ + digest(): Buffer; + digest(encoding: BinaryToTextEncoding): string; + } + /** + * The `Hmac` class is a utility for creating cryptographic HMAC digests. It can + * be used in one of two ways: + * + * * As a `stream` that is both readable and writable, where data is written + * to produce a computed HMAC digest on the readable side, or + * * Using the `hmac.update()` and `hmac.digest()` methods to produce the + * computed HMAC digest. + * + * The {@link createHmac} method is used to create `Hmac` instances. `Hmac`objects are not to be created directly using the `new` keyword. + * + * Example: Using `Hmac` objects as streams: + * + * ```js + * const { + * createHmac, + * } = await import('node:crypto'); + * + * const hmac = createHmac('sha256', 'a secret'); + * + * hmac.on('readable', () => { + * // Only one element is going to be produced by the + * // hash stream. + * const data = hmac.read(); + * if (data) { + * console.log(data.toString('hex')); + * // Prints: + * // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e + * } + * }); + * + * hmac.write('some data to hash'); + * hmac.end(); + * ``` + * + * Example: Using `Hmac` and piped streams: + * + * ```js + * import { createReadStream } from 'node:fs'; + * import { stdout } from 'node:process'; + * const { + * createHmac, + * } = await import('node:crypto'); + * + * const hmac = createHmac('sha256', 'a secret'); + * + * const input = createReadStream('test.js'); + * input.pipe(hmac).pipe(stdout); + * ``` + * + * Example: Using the `hmac.update()` and `hmac.digest()` methods: + * + * ```js + * const { + * createHmac, + * } = await import('node:crypto'); + * + * const hmac = createHmac('sha256', 'a secret'); + * + * hmac.update('some data to hash'); + * console.log(hmac.digest('hex')); + * // Prints: + * // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e + * ``` + * @since v0.1.94 + */ + class Hmac extends stream.Transform { + private constructor(); + /** + * Updates the `Hmac` content with the given `data`, the encoding of which + * is given in `inputEncoding`. + * If `encoding` is not provided, and the `data` is a string, an + * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored. + * + * This can be called many times with new data as it is streamed. + * @since v0.1.94 + * @param inputEncoding The `encoding` of the `data` string. + */ + update(data: BinaryLike): Hmac; + update(data: string, inputEncoding: Encoding): Hmac; + /** + * Calculates the HMAC digest of all of the data passed using `hmac.update()`. + * If `encoding` is + * provided a string is returned; otherwise a `Buffer` is returned; + * + * The `Hmac` object can not be used again after `hmac.digest()` has been + * called. Multiple calls to `hmac.digest()` will result in an error being thrown. + * @since v0.1.94 + * @param encoding The `encoding` of the return value. + */ + digest(): Buffer; + digest(encoding: BinaryToTextEncoding): string; + } + type KeyObjectType = "secret" | "public" | "private"; + interface KeyExportOptions { + type: "pkcs1" | "spki" | "pkcs8" | "sec1"; + format: T; + cipher?: string | undefined; + passphrase?: string | Buffer | undefined; + } + interface JwkKeyExportOptions { + format: "jwk"; + } + interface JsonWebKey { + crv?: string | undefined; + d?: string | undefined; + dp?: string | undefined; + dq?: string | undefined; + e?: string | undefined; + k?: string | undefined; + kty?: string | undefined; + n?: string | undefined; + p?: string | undefined; + q?: string | undefined; + qi?: string | undefined; + x?: string | undefined; + y?: string | undefined; + [key: string]: unknown; + } + interface AsymmetricKeyDetails { + /** + * Key size in bits (RSA, DSA). + */ + modulusLength?: number | undefined; + /** + * Public exponent (RSA). + */ + publicExponent?: bigint | undefined; + /** + * Name of the message digest (RSA-PSS). + */ + hashAlgorithm?: string | undefined; + /** + * Name of the message digest used by MGF1 (RSA-PSS). + */ + mgf1HashAlgorithm?: string | undefined; + /** + * Minimal salt length in bytes (RSA-PSS). + */ + saltLength?: number | undefined; + /** + * Size of q in bits (DSA). + */ + divisorLength?: number | undefined; + /** + * Name of the curve (EC). + */ + namedCurve?: string | undefined; + } + /** + * Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key, + * and each kind of key exposes different functions. The {@link createSecretKey}, {@link createPublicKey} and {@link createPrivateKey} methods are used to create `KeyObject`instances. `KeyObject` + * objects are not to be created directly using the `new`keyword. + * + * Most applications should consider using the new `KeyObject` API instead of + * passing keys as strings or `Buffer`s due to improved security features. + * + * `KeyObject` instances can be passed to other threads via `postMessage()`. + * The receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to + * be listed in the `transferList` argument. + * @since v11.6.0 + */ + class KeyObject { + private constructor(); + /** + * Example: Converting a `CryptoKey` instance to a `KeyObject`: + * + * ```js + * const { KeyObject } = await import('node:crypto'); + * const { subtle } = globalThis.crypto; + * + * const key = await subtle.generateKey({ + * name: 'HMAC', + * hash: 'SHA-256', + * length: 256, + * }, true, ['sign', 'verify']); + * + * const keyObject = KeyObject.from(key); + * console.log(keyObject.symmetricKeySize); + * // Prints: 32 (symmetric key size in bytes) + * ``` + * @since v15.0.0 + */ + static from(key: webcrypto.CryptoKey): KeyObject; + /** + * For asymmetric keys, this property represents the type of the key. Supported key + * types are: + * + * * `'rsa'` (OID 1.2.840.113549.1.1.1) + * * `'rsa-pss'` (OID 1.2.840.113549.1.1.10) + * * `'dsa'` (OID 1.2.840.10040.4.1) + * * `'ec'` (OID 1.2.840.10045.2.1) + * * `'x25519'` (OID 1.3.101.110) + * * `'x448'` (OID 1.3.101.111) + * * `'ed25519'` (OID 1.3.101.112) + * * `'ed448'` (OID 1.3.101.113) + * * `'dh'` (OID 1.2.840.113549.1.3.1) + * + * This property is `undefined` for unrecognized `KeyObject` types and symmetric + * keys. + * @since v11.6.0 + */ + asymmetricKeyType?: KeyType | undefined; + /** + * For asymmetric keys, this property represents the size of the embedded key in + * bytes. This property is `undefined` for symmetric keys. + */ + asymmetricKeySize?: number | undefined; + /** + * This property exists only on asymmetric keys. Depending on the type of the key, + * this object contains information about the key. None of the information obtained + * through this property can be used to uniquely identify a key or to compromise + * the security of the key. + * + * For RSA-PSS keys, if the key material contains a `RSASSA-PSS-params` sequence, + * the `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` properties will be + * set. + * + * Other key details might be exposed via this API using additional attributes. + * @since v15.7.0 + */ + asymmetricKeyDetails?: AsymmetricKeyDetails | undefined; + /** + * For symmetric keys, the following encoding options can be used: + * + * For public keys, the following encoding options can be used: + * + * For private keys, the following encoding options can be used: + * + * The result type depends on the selected encoding format, when PEM the + * result is a string, when DER it will be a buffer containing the data + * encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object. + * + * When [JWK](https://tools.ietf.org/html/rfc7517) encoding format was selected, all other encoding options are + * ignored. + * + * PKCS#1, SEC1, and PKCS#8 type keys can be encrypted by using a combination of + * the `cipher` and `format` options. The PKCS#8 `type` can be used with any`format` to encrypt any key algorithm (RSA, EC, or DH) by specifying a`cipher`. PKCS#1 and SEC1 can only be + * encrypted by specifying a `cipher`when the PEM `format` is used. For maximum compatibility, use PKCS#8 for + * encrypted private keys. Since PKCS#8 defines its own + * encryption mechanism, PEM-level encryption is not supported when encrypting + * a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption and [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for + * PKCS#1 and SEC1 encryption. + * @since v11.6.0 + */ + export(options: KeyExportOptions<"pem">): string | Buffer; + export(options?: KeyExportOptions<"der">): Buffer; + export(options?: JwkKeyExportOptions): JsonWebKey; + /** + * For secret keys, this property represents the size of the key in bytes. This + * property is `undefined` for asymmetric keys. + * @since v11.6.0 + */ + symmetricKeySize?: number | undefined; + /** + * Depending on the type of this `KeyObject`, this property is either`'secret'` for secret (symmetric) keys, `'public'` for public (asymmetric) keys + * or `'private'` for private (asymmetric) keys. + * @since v11.6.0 + */ + type: KeyObjectType; + } + type CipherCCMTypes = "aes-128-ccm" | "aes-192-ccm" | "aes-256-ccm" | "chacha20-poly1305"; + type CipherGCMTypes = "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm"; + type CipherOCBTypes = "aes-128-ocb" | "aes-192-ocb" | "aes-256-ocb"; + type BinaryLike = string | NodeJS.ArrayBufferView; + type CipherKey = BinaryLike | KeyObject; + interface CipherCCMOptions extends stream.TransformOptions { + authTagLength: number; + } + interface CipherGCMOptions extends stream.TransformOptions { + authTagLength?: number | undefined; + } + interface CipherOCBOptions extends stream.TransformOptions { + authTagLength: number; + } + /** + * Creates and returns a `Cipher` object that uses the given `algorithm` and`password`. + * + * The `options` argument controls stream behavior and is optional except when a + * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the + * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication + * tag that will be returned by `getAuthTag()` and defaults to 16 bytes. + * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. + * + * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On + * recent OpenSSL releases, `openssl list -cipher-algorithms` will + * display the available cipher algorithms. + * + * The `password` is used to derive the cipher key and initialization vector (IV). + * The value must be either a `'latin1'` encoded string, a `Buffer`, a`TypedArray`, or a `DataView`. + * + * **This function is semantically insecure for all** + * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,** + * **GCM, or CCM).** + * + * The implementation of `crypto.createCipher()` derives keys using the OpenSSL + * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one + * iteration, and no salt. The lack of salt allows dictionary attacks as the same + * password always creates the same key. The low iteration count and + * non-cryptographically secure hash algorithm allow passwords to be tested very + * rapidly. + * + * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that + * developers derive a key and IV on + * their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode + * (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when + * they are used in order to avoid the risk of IV reuse that causes + * vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting Adversaries](https://github.com/nonce-disrespect/nonce-disrespect) for details. + * @since v0.1.94 + * @deprecated Since v10.0.0 - Use {@link createCipheriv} instead. + * @param options `stream.transform` options + */ + function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM; + /** @deprecated since v10.0.0 use `createCipheriv()` */ + function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM; + /** @deprecated since v10.0.0 use `createCipheriv()` */ + function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher; + /** + * Creates and returns a `Cipher` object, with the given `algorithm`, `key` and + * initialization vector (`iv`). + * + * The `options` argument controls stream behavior and is optional except when a + * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the + * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication + * tag that will be returned by `getAuthTag()` and defaults to 16 bytes. + * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. + * + * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On + * recent OpenSSL releases, `openssl list -cipher-algorithms` will + * display the available cipher algorithms. + * + * The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded + * strings,`Buffers`, `TypedArray`, or `DataView`s. The `key` may optionally be + * a `KeyObject` of type `secret`. If the cipher does not need + * an initialization vector, `iv` may be `null`. + * + * When passing strings for `key` or `iv`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * Initialization vectors should be unpredictable and unique; ideally, they will be + * cryptographically random. They do not have to be secret: IVs are typically just + * added to ciphertext messages unencrypted. It may sound contradictory that + * something has to be unpredictable and unique, but does not have to be secret; + * remember that an attacker must not be able to predict ahead of time what a + * given IV will be. + * @since v0.1.94 + * @param options `stream.transform` options + */ + function createCipheriv( + algorithm: CipherCCMTypes, + key: CipherKey, + iv: BinaryLike, + options: CipherCCMOptions, + ): CipherCCM; + function createCipheriv( + algorithm: CipherOCBTypes, + key: CipherKey, + iv: BinaryLike, + options: CipherOCBOptions, + ): CipherOCB; + function createCipheriv( + algorithm: CipherGCMTypes, + key: CipherKey, + iv: BinaryLike, + options?: CipherGCMOptions, + ): CipherGCM; + function createCipheriv( + algorithm: string, + key: CipherKey, + iv: BinaryLike | null, + options?: stream.TransformOptions, + ): Cipher; + /** + * Instances of the `Cipher` class are used to encrypt data. The class can be + * used in one of two ways: + * + * * As a `stream` that is both readable and writable, where plain unencrypted + * data is written to produce encrypted data on the readable side, or + * * Using the `cipher.update()` and `cipher.final()` methods to produce + * the encrypted data. + * + * The {@link createCipher} or {@link createCipheriv} methods are + * used to create `Cipher` instances. `Cipher` objects are not to be created + * directly using the `new` keyword. + * + * Example: Using `Cipher` objects as streams: + * + * ```js + * const { + * scrypt, + * randomFill, + * createCipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * + * // First, we'll generate the key. The key length is dependent on the algorithm. + * // In this case for aes192, it is 24 bytes (192 bits). + * scrypt(password, 'salt', 24, (err, key) => { + * if (err) throw err; + * // Then, we'll generate a random initialization vector + * randomFill(new Uint8Array(16), (err, iv) => { + * if (err) throw err; + * + * // Once we have the key and iv, we can create and use the cipher... + * const cipher = createCipheriv(algorithm, key, iv); + * + * let encrypted = ''; + * cipher.setEncoding('hex'); + * + * cipher.on('data', (chunk) => encrypted += chunk); + * cipher.on('end', () => console.log(encrypted)); + * + * cipher.write('some clear text data'); + * cipher.end(); + * }); + * }); + * ``` + * + * Example: Using `Cipher` and piped streams: + * + * ```js + * import { + * createReadStream, + * createWriteStream, + * } from 'node:fs'; + * + * import { + * pipeline, + * } from 'node:stream'; + * + * const { + * scrypt, + * randomFill, + * createCipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * + * // First, we'll generate the key. The key length is dependent on the algorithm. + * // In this case for aes192, it is 24 bytes (192 bits). + * scrypt(password, 'salt', 24, (err, key) => { + * if (err) throw err; + * // Then, we'll generate a random initialization vector + * randomFill(new Uint8Array(16), (err, iv) => { + * if (err) throw err; + * + * const cipher = createCipheriv(algorithm, key, iv); + * + * const input = createReadStream('test.js'); + * const output = createWriteStream('test.enc'); + * + * pipeline(input, cipher, output, (err) => { + * if (err) throw err; + * }); + * }); + * }); + * ``` + * + * Example: Using the `cipher.update()` and `cipher.final()` methods: + * + * ```js + * const { + * scrypt, + * randomFill, + * createCipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * + * // First, we'll generate the key. The key length is dependent on the algorithm. + * // In this case for aes192, it is 24 bytes (192 bits). + * scrypt(password, 'salt', 24, (err, key) => { + * if (err) throw err; + * // Then, we'll generate a random initialization vector + * randomFill(new Uint8Array(16), (err, iv) => { + * if (err) throw err; + * + * const cipher = createCipheriv(algorithm, key, iv); + * + * let encrypted = cipher.update('some clear text data', 'utf8', 'hex'); + * encrypted += cipher.final('hex'); + * console.log(encrypted); + * }); + * }); + * ``` + * @since v0.1.94 + */ + class Cipher extends stream.Transform { + private constructor(); + /** + * Updates the cipher with `data`. If the `inputEncoding` argument is given, + * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`, `TypedArray`, or`DataView`. If `data` is a `Buffer`, + * `TypedArray`, or `DataView`, then`inputEncoding` is ignored. + * + * The `outputEncoding` specifies the output format of the enciphered + * data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned. + * + * The `cipher.update()` method can be called multiple times with new data until `cipher.final()` is called. Calling `cipher.update()` after `cipher.final()` will result in an error being + * thrown. + * @since v0.1.94 + * @param inputEncoding The `encoding` of the data. + * @param outputEncoding The `encoding` of the return value. + */ + update(data: BinaryLike): Buffer; + update(data: string, inputEncoding: Encoding): Buffer; + update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string; + update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string; + /** + * Once the `cipher.final()` method has been called, the `Cipher` object can no + * longer be used to encrypt data. Attempts to call `cipher.final()` more than + * once will result in an error being thrown. + * @since v0.1.94 + * @param outputEncoding The `encoding` of the return value. + * @return Any remaining enciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned. + */ + final(): Buffer; + final(outputEncoding: BufferEncoding): string; + /** + * When using block encryption algorithms, the `Cipher` class will automatically + * add padding to the input data to the appropriate block size. To disable the + * default padding call `cipher.setAutoPadding(false)`. + * + * When `autoPadding` is `false`, the length of the entire input data must be a + * multiple of the cipher's block size or `cipher.final()` will throw an error. + * Disabling automatic padding is useful for non-standard padding, for instance + * using `0x0` instead of PKCS padding. + * + * The `cipher.setAutoPadding()` method must be called before `cipher.final()`. + * @since v0.7.1 + * @param [autoPadding=true] + * @return for method chaining. + */ + setAutoPadding(autoPadding?: boolean): this; + } + interface CipherCCM extends Cipher { + setAAD( + buffer: NodeJS.ArrayBufferView, + options: { + plaintextLength: number; + }, + ): this; + getAuthTag(): Buffer; + } + interface CipherGCM extends Cipher { + setAAD( + buffer: NodeJS.ArrayBufferView, + options?: { + plaintextLength: number; + }, + ): this; + getAuthTag(): Buffer; + } + interface CipherOCB extends Cipher { + setAAD( + buffer: NodeJS.ArrayBufferView, + options?: { + plaintextLength: number; + }, + ): this; + getAuthTag(): Buffer; + } + /** + * Creates and returns a `Decipher` object that uses the given `algorithm` and`password` (key). + * + * The `options` argument controls stream behavior and is optional except when a + * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the + * authentication tag in bytes, see `CCM mode`. + * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. + * + * **This function is semantically insecure for all** + * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,** + * **GCM, or CCM).** + * + * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL + * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one + * iteration, and no salt. The lack of salt allows dictionary attacks as the same + * password always creates the same key. The low iteration count and + * non-cryptographically secure hash algorithm allow passwords to be tested very + * rapidly. + * + * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that + * developers derive a key and IV on + * their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object. + * @since v0.1.94 + * @deprecated Since v10.0.0 - Use {@link createDecipheriv} instead. + * @param options `stream.transform` options + */ + function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM; + /** @deprecated since v10.0.0 use `createDecipheriv()` */ + function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM; + /** @deprecated since v10.0.0 use `createDecipheriv()` */ + function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher; + /** + * Creates and returns a `Decipher` object that uses the given `algorithm`, `key`and initialization vector (`iv`). + * + * The `options` argument controls stream behavior and is optional except when a + * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the + * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to restrict accepted authentication tags + * to those with the specified length. + * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes. + * + * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On + * recent OpenSSL releases, `openssl list -cipher-algorithms` will + * display the available cipher algorithms. + * + * The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded + * strings,`Buffers`, `TypedArray`, or `DataView`s. The `key` may optionally be + * a `KeyObject` of type `secret`. If the cipher does not need + * an initialization vector, `iv` may be `null`. + * + * When passing strings for `key` or `iv`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * Initialization vectors should be unpredictable and unique; ideally, they will be + * cryptographically random. They do not have to be secret: IVs are typically just + * added to ciphertext messages unencrypted. It may sound contradictory that + * something has to be unpredictable and unique, but does not have to be secret; + * remember that an attacker must not be able to predict ahead of time what a given + * IV will be. + * @since v0.1.94 + * @param options `stream.transform` options + */ + function createDecipheriv( + algorithm: CipherCCMTypes, + key: CipherKey, + iv: BinaryLike, + options: CipherCCMOptions, + ): DecipherCCM; + function createDecipheriv( + algorithm: CipherOCBTypes, + key: CipherKey, + iv: BinaryLike, + options: CipherOCBOptions, + ): DecipherOCB; + function createDecipheriv( + algorithm: CipherGCMTypes, + key: CipherKey, + iv: BinaryLike, + options?: CipherGCMOptions, + ): DecipherGCM; + function createDecipheriv( + algorithm: string, + key: CipherKey, + iv: BinaryLike | null, + options?: stream.TransformOptions, + ): Decipher; + /** + * Instances of the `Decipher` class are used to decrypt data. The class can be + * used in one of two ways: + * + * * As a `stream` that is both readable and writable, where plain encrypted + * data is written to produce unencrypted data on the readable side, or + * * Using the `decipher.update()` and `decipher.final()` methods to + * produce the unencrypted data. + * + * The {@link createDecipher} or {@link createDecipheriv} methods are + * used to create `Decipher` instances. `Decipher` objects are not to be created + * directly using the `new` keyword. + * + * Example: Using `Decipher` objects as streams: + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { + * scryptSync, + * createDecipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * // Key length is dependent on the algorithm. In this case for aes192, it is + * // 24 bytes (192 bits). + * // Use the async `crypto.scrypt()` instead. + * const key = scryptSync(password, 'salt', 24); + * // The IV is usually passed along with the ciphertext. + * const iv = Buffer.alloc(16, 0); // Initialization vector. + * + * const decipher = createDecipheriv(algorithm, key, iv); + * + * let decrypted = ''; + * decipher.on('readable', () => { + * let chunk; + * while (null !== (chunk = decipher.read())) { + * decrypted += chunk.toString('utf8'); + * } + * }); + * decipher.on('end', () => { + * console.log(decrypted); + * // Prints: some clear text data + * }); + * + * // Encrypted with same algorithm, key and iv. + * const encrypted = + * 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; + * decipher.write(encrypted, 'hex'); + * decipher.end(); + * ``` + * + * Example: Using `Decipher` and piped streams: + * + * ```js + * import { + * createReadStream, + * createWriteStream, + * } from 'node:fs'; + * import { Buffer } from 'node:buffer'; + * const { + * scryptSync, + * createDecipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * // Use the async `crypto.scrypt()` instead. + * const key = scryptSync(password, 'salt', 24); + * // The IV is usually passed along with the ciphertext. + * const iv = Buffer.alloc(16, 0); // Initialization vector. + * + * const decipher = createDecipheriv(algorithm, key, iv); + * + * const input = createReadStream('test.enc'); + * const output = createWriteStream('test.js'); + * + * input.pipe(decipher).pipe(output); + * ``` + * + * Example: Using the `decipher.update()` and `decipher.final()` methods: + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { + * scryptSync, + * createDecipheriv, + * } = await import('node:crypto'); + * + * const algorithm = 'aes-192-cbc'; + * const password = 'Password used to generate key'; + * // Use the async `crypto.scrypt()` instead. + * const key = scryptSync(password, 'salt', 24); + * // The IV is usually passed along with the ciphertext. + * const iv = Buffer.alloc(16, 0); // Initialization vector. + * + * const decipher = createDecipheriv(algorithm, key, iv); + * + * // Encrypted using same algorithm, key and iv. + * const encrypted = + * 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa'; + * let decrypted = decipher.update(encrypted, 'hex', 'utf8'); + * decrypted += decipher.final('utf8'); + * console.log(decrypted); + * // Prints: some clear text data + * ``` + * @since v0.1.94 + */ + class Decipher extends stream.Transform { + private constructor(); + /** + * Updates the decipher with `data`. If the `inputEncoding` argument is given, + * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`. If `data` is a `Buffer` then `inputEncoding` is + * ignored. + * + * The `outputEncoding` specifies the output format of the enciphered + * data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned. + * + * The `decipher.update()` method can be called multiple times with new data until `decipher.final()` is called. Calling `decipher.update()` after `decipher.final()` will result in an error + * being thrown. + * @since v0.1.94 + * @param inputEncoding The `encoding` of the `data` string. + * @param outputEncoding The `encoding` of the return value. + */ + update(data: NodeJS.ArrayBufferView): Buffer; + update(data: string, inputEncoding: Encoding): Buffer; + update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string; + update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string; + /** + * Once the `decipher.final()` method has been called, the `Decipher` object can + * no longer be used to decrypt data. Attempts to call `decipher.final()` more + * than once will result in an error being thrown. + * @since v0.1.94 + * @param outputEncoding The `encoding` of the return value. + * @return Any remaining deciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned. + */ + final(): Buffer; + final(outputEncoding: BufferEncoding): string; + /** + * When data has been encrypted without standard block padding, calling`decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and + * removing padding. + * + * Turning auto padding off will only work if the input data's length is a + * multiple of the ciphers block size. + * + * The `decipher.setAutoPadding()` method must be called before `decipher.final()`. + * @since v0.7.1 + * @param [autoPadding=true] + * @return for method chaining. + */ + setAutoPadding(auto_padding?: boolean): this; + } + interface DecipherCCM extends Decipher { + setAuthTag(buffer: NodeJS.ArrayBufferView): this; + setAAD( + buffer: NodeJS.ArrayBufferView, + options: { + plaintextLength: number; + }, + ): this; + } + interface DecipherGCM extends Decipher { + setAuthTag(buffer: NodeJS.ArrayBufferView): this; + setAAD( + buffer: NodeJS.ArrayBufferView, + options?: { + plaintextLength: number; + }, + ): this; + } + interface DecipherOCB extends Decipher { + setAuthTag(buffer: NodeJS.ArrayBufferView): this; + setAAD( + buffer: NodeJS.ArrayBufferView, + options?: { + plaintextLength: number; + }, + ): this; + } + interface PrivateKeyInput { + key: string | Buffer; + format?: KeyFormat | undefined; + type?: "pkcs1" | "pkcs8" | "sec1" | undefined; + passphrase?: string | Buffer | undefined; + encoding?: string | undefined; + } + interface PublicKeyInput { + key: string | Buffer; + format?: KeyFormat | undefined; + type?: "pkcs1" | "spki" | undefined; + encoding?: string | undefined; + } + /** + * Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`. + * + * ```js + * const { + * generateKey, + * } = await import('node:crypto'); + * + * generateKey('hmac', { length: 512 }, (err, key) => { + * if (err) throw err; + * console.log(key.export().toString('hex')); // 46e..........620 + * }); + * ``` + * + * The size of a generated HMAC key should not exceed the block size of the + * underlying hash function. See {@link createHmac} for more information. + * @since v15.0.0 + * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`. + */ + function generateKey( + type: "hmac" | "aes", + options: { + length: number; + }, + callback: (err: Error | null, key: KeyObject) => void, + ): void; + /** + * Synchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`. + * + * ```js + * const { + * generateKeySync, + * } = await import('node:crypto'); + * + * const key = generateKeySync('hmac', { length: 512 }); + * console.log(key.export().toString('hex')); // e89..........41e + * ``` + * + * The size of a generated HMAC key should not exceed the block size of the + * underlying hash function. See {@link createHmac} for more information. + * @since v15.0.0 + * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`. + */ + function generateKeySync( + type: "hmac" | "aes", + options: { + length: number; + }, + ): KeyObject; + interface JsonWebKeyInput { + key: JsonWebKey; + format: "jwk"; + } + /** + * Creates and returns a new key object containing a private key. If `key` is a + * string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key`must be an object with the properties described above. + * + * If the private key is encrypted, a `passphrase` must be specified. The length + * of the passphrase is limited to 1024 bytes. + * @since v11.6.0 + */ + function createPrivateKey(key: PrivateKeyInput | string | Buffer | JsonWebKeyInput): KeyObject; + /** + * Creates and returns a new key object containing a public key. If `key` is a + * string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject`with type `'private'`, the public key is derived from the given private key; + * otherwise, `key` must be an object with the properties described above. + * + * If the format is `'pem'`, the `'key'` may also be an X.509 certificate. + * + * Because public keys can be derived from private keys, a private key may be + * passed instead of a public key. In that case, this function behaves as if {@link createPrivateKey} had been called, except that the type of the + * returned `KeyObject` will be `'public'` and that the private key cannot be + * extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type`'private'` is given, a new `KeyObject` with type `'public'` will be returned + * and it will be impossible to extract the private key from the returned object. + * @since v11.6.0 + */ + function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject | JsonWebKeyInput): KeyObject; + /** + * Creates and returns a new key object containing a secret key for symmetric + * encryption or `Hmac`. + * @since v11.6.0 + * @param encoding The string encoding when `key` is a string. + */ + function createSecretKey(key: NodeJS.ArrayBufferView): KeyObject; + function createSecretKey(key: string, encoding: BufferEncoding): KeyObject; + /** + * Creates and returns a `Sign` object that uses the given `algorithm`. Use {@link getHashes} to obtain the names of the available digest algorithms. + * Optional `options` argument controls the `stream.Writable` behavior. + * + * In some cases, a `Sign` instance can be created using the name of a signature + * algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use + * the corresponding digest algorithm. This does not work for all signature + * algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest + * algorithm names. + * @since v0.1.92 + * @param options `stream.Writable` options + */ + function createSign(algorithm: string, options?: stream.WritableOptions): Sign; + type DSAEncoding = "der" | "ieee-p1363"; + interface SigningOptions { + /** + * @see crypto.constants.RSA_PKCS1_PADDING + */ + padding?: number | undefined; + saltLength?: number | undefined; + dsaEncoding?: DSAEncoding | undefined; + } + interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {} + interface SignKeyObjectInput extends SigningOptions { + key: KeyObject; + } + interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {} + interface VerifyKeyObjectInput extends SigningOptions { + key: KeyObject; + } + interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {} + type KeyLike = string | Buffer | KeyObject; + /** + * The `Sign` class is a utility for generating signatures. It can be used in one + * of two ways: + * + * * As a writable `stream`, where data to be signed is written and the `sign.sign()` method is used to generate and return the signature, or + * * Using the `sign.update()` and `sign.sign()` methods to produce the + * signature. + * + * The {@link createSign} method is used to create `Sign` instances. The + * argument is the string name of the hash function to use. `Sign` objects are not + * to be created directly using the `new` keyword. + * + * Example: Using `Sign` and `Verify` objects as streams: + * + * ```js + * const { + * generateKeyPairSync, + * createSign, + * createVerify, + * } = await import('node:crypto'); + * + * const { privateKey, publicKey } = generateKeyPairSync('ec', { + * namedCurve: 'sect239k1', + * }); + * + * const sign = createSign('SHA256'); + * sign.write('some data to sign'); + * sign.end(); + * const signature = sign.sign(privateKey, 'hex'); + * + * const verify = createVerify('SHA256'); + * verify.write('some data to sign'); + * verify.end(); + * console.log(verify.verify(publicKey, signature, 'hex')); + * // Prints: true + * ``` + * + * Example: Using the `sign.update()` and `verify.update()` methods: + * + * ```js + * const { + * generateKeyPairSync, + * createSign, + * createVerify, + * } = await import('node:crypto'); + * + * const { privateKey, publicKey } = generateKeyPairSync('rsa', { + * modulusLength: 2048, + * }); + * + * const sign = createSign('SHA256'); + * sign.update('some data to sign'); + * sign.end(); + * const signature = sign.sign(privateKey); + * + * const verify = createVerify('SHA256'); + * verify.update('some data to sign'); + * verify.end(); + * console.log(verify.verify(publicKey, signature)); + * // Prints: true + * ``` + * @since v0.1.92 + */ + class Sign extends stream.Writable { + private constructor(); + /** + * Updates the `Sign` content with the given `data`, the encoding of which + * is given in `inputEncoding`. + * If `encoding` is not provided, and the `data` is a string, an + * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored. + * + * This can be called many times with new data as it is streamed. + * @since v0.1.92 + * @param inputEncoding The `encoding` of the `data` string. + */ + update(data: BinaryLike): this; + update(data: string, inputEncoding: Encoding): this; + /** + * Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`. + * + * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an + * object, the following additional properties can be passed: + * + * If `outputEncoding` is provided a string is returned; otherwise a `Buffer` is returned. + * + * The `Sign` object can not be again used after `sign.sign()` method has been + * called. Multiple calls to `sign.sign()` will result in an error being thrown. + * @since v0.1.92 + */ + sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer; + sign( + privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput, + outputFormat: BinaryToTextEncoding, + ): string; + } + /** + * Creates and returns a `Verify` object that uses the given algorithm. + * Use {@link getHashes} to obtain an array of names of the available + * signing algorithms. Optional `options` argument controls the`stream.Writable` behavior. + * + * In some cases, a `Verify` instance can be created using the name of a signature + * algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use + * the corresponding digest algorithm. This does not work for all signature + * algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest + * algorithm names. + * @since v0.1.92 + * @param options `stream.Writable` options + */ + function createVerify(algorithm: string, options?: stream.WritableOptions): Verify; + /** + * The `Verify` class is a utility for verifying signatures. It can be used in one + * of two ways: + * + * * As a writable `stream` where written data is used to validate against the + * supplied signature, or + * * Using the `verify.update()` and `verify.verify()` methods to verify + * the signature. + * + * The {@link createVerify} method is used to create `Verify` instances.`Verify` objects are not to be created directly using the `new` keyword. + * + * See `Sign` for examples. + * @since v0.1.92 + */ + class Verify extends stream.Writable { + private constructor(); + /** + * Updates the `Verify` content with the given `data`, the encoding of which + * is given in `inputEncoding`. + * If `inputEncoding` is not provided, and the `data` is a string, an + * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored. + * + * This can be called many times with new data as it is streamed. + * @since v0.1.92 + * @param inputEncoding The `encoding` of the `data` string. + */ + update(data: BinaryLike): Verify; + update(data: string, inputEncoding: Encoding): Verify; + /** + * Verifies the provided data using the given `object` and `signature`. + * + * If `object` is not a `KeyObject`, this function behaves as if`object` had been passed to {@link createPublicKey}. If it is an + * object, the following additional properties can be passed: + * + * The `signature` argument is the previously calculated signature for the data, in + * the `signatureEncoding`. + * If a `signatureEncoding` is specified, the `signature` is expected to be a + * string; otherwise `signature` is expected to be a `Buffer`,`TypedArray`, or `DataView`. + * + * The `verify` object can not be used again after `verify.verify()` has been + * called. Multiple calls to `verify.verify()` will result in an error being + * thrown. + * + * Because public keys can be derived from private keys, a private key may + * be passed instead of a public key. + * @since v0.1.92 + */ + verify( + object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: NodeJS.ArrayBufferView, + ): boolean; + verify( + object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: string, + signature_format?: BinaryToTextEncoding, + ): boolean; + } + /** + * Creates a `DiffieHellman` key exchange object using the supplied `prime` and an + * optional specific `generator`. + * + * The `generator` argument can be a number, string, or `Buffer`. If`generator` is not specified, the value `2` is used. + * + * If `primeEncoding` is specified, `prime` is expected to be a string; otherwise + * a `Buffer`, `TypedArray`, or `DataView` is expected. + * + * If `generatorEncoding` is specified, `generator` is expected to be a string; + * otherwise a number, `Buffer`, `TypedArray`, or `DataView` is expected. + * @since v0.11.12 + * @param primeEncoding The `encoding` of the `prime` string. + * @param [generator=2] + * @param generatorEncoding The `encoding` of the `generator` string. + */ + function createDiffieHellman(primeLength: number, generator?: number): DiffieHellman; + function createDiffieHellman( + prime: ArrayBuffer | NodeJS.ArrayBufferView, + generator?: number | ArrayBuffer | NodeJS.ArrayBufferView, + ): DiffieHellman; + function createDiffieHellman( + prime: ArrayBuffer | NodeJS.ArrayBufferView, + generator: string, + generatorEncoding: BinaryToTextEncoding, + ): DiffieHellman; + function createDiffieHellman( + prime: string, + primeEncoding: BinaryToTextEncoding, + generator?: number | ArrayBuffer | NodeJS.ArrayBufferView, + ): DiffieHellman; + function createDiffieHellman( + prime: string, + primeEncoding: BinaryToTextEncoding, + generator: string, + generatorEncoding: BinaryToTextEncoding, + ): DiffieHellman; + /** + * The `DiffieHellman` class is a utility for creating Diffie-Hellman key + * exchanges. + * + * Instances of the `DiffieHellman` class can be created using the {@link createDiffieHellman} function. + * + * ```js + * import assert from 'node:assert'; + * + * const { + * createDiffieHellman, + * } = await import('node:crypto'); + * + * // Generate Alice's keys... + * const alice = createDiffieHellman(2048); + * const aliceKey = alice.generateKeys(); + * + * // Generate Bob's keys... + * const bob = createDiffieHellman(alice.getPrime(), alice.getGenerator()); + * const bobKey = bob.generateKeys(); + * + * // Exchange and generate the secret... + * const aliceSecret = alice.computeSecret(bobKey); + * const bobSecret = bob.computeSecret(aliceKey); + * + * // OK + * assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); + * ``` + * @since v0.5.0 + */ + class DiffieHellman { + private constructor(); + /** + * Generates private and public Diffie-Hellman key values unless they have been + * generated or computed already, and returns + * the public key in the specified `encoding`. This key should be + * transferred to the other party. + * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned. + * + * This function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular, + * once a private key has been generated or set, calling this function only updates + * the public key but does not generate a new private key. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + generateKeys(): Buffer; + generateKeys(encoding: BinaryToTextEncoding): string; + /** + * Computes the shared secret using `otherPublicKey` as the other + * party's public key and returns the computed shared secret. The supplied + * key is interpreted using the specified `inputEncoding`, and secret is + * encoded using specified `outputEncoding`. + * If the `inputEncoding` is not + * provided, `otherPublicKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`. + * + * If `outputEncoding` is given a string is returned; otherwise, a `Buffer` is returned. + * @since v0.5.0 + * @param inputEncoding The `encoding` of an `otherPublicKey` string. + * @param outputEncoding The `encoding` of the return value. + */ + computeSecret(otherPublicKey: NodeJS.ArrayBufferView, inputEncoding?: null, outputEncoding?: null): Buffer; + computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding?: null): Buffer; + computeSecret( + otherPublicKey: NodeJS.ArrayBufferView, + inputEncoding: null, + outputEncoding: BinaryToTextEncoding, + ): string; + computeSecret( + otherPublicKey: string, + inputEncoding: BinaryToTextEncoding, + outputEncoding: BinaryToTextEncoding, + ): string; + /** + * Returns the Diffie-Hellman prime in the specified `encoding`. + * If `encoding` is provided a string is + * returned; otherwise a `Buffer` is returned. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + getPrime(): Buffer; + getPrime(encoding: BinaryToTextEncoding): string; + /** + * Returns the Diffie-Hellman generator in the specified `encoding`. + * If `encoding` is provided a string is + * returned; otherwise a `Buffer` is returned. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + getGenerator(): Buffer; + getGenerator(encoding: BinaryToTextEncoding): string; + /** + * Returns the Diffie-Hellman public key in the specified `encoding`. + * If `encoding` is provided a + * string is returned; otherwise a `Buffer` is returned. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + getPublicKey(): Buffer; + getPublicKey(encoding: BinaryToTextEncoding): string; + /** + * Returns the Diffie-Hellman private key in the specified `encoding`. + * If `encoding` is provided a + * string is returned; otherwise a `Buffer` is returned. + * @since v0.5.0 + * @param encoding The `encoding` of the return value. + */ + getPrivateKey(): Buffer; + getPrivateKey(encoding: BinaryToTextEncoding): string; + /** + * Sets the Diffie-Hellman public key. If the `encoding` argument is provided,`publicKey` is expected + * to be a string. If no `encoding` is provided, `publicKey` is expected + * to be a `Buffer`, `TypedArray`, or `DataView`. + * @since v0.5.0 + * @param encoding The `encoding` of the `publicKey` string. + */ + setPublicKey(publicKey: NodeJS.ArrayBufferView): void; + setPublicKey(publicKey: string, encoding: BufferEncoding): void; + /** + * Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected + * to be a string. If no `encoding` is provided, `privateKey` is expected + * to be a `Buffer`, `TypedArray`, or `DataView`. + * + * This function does not automatically compute the associated public key. Either `diffieHellman.setPublicKey()` or `diffieHellman.generateKeys()` can be + * used to manually provide the public key or to automatically derive it. + * @since v0.5.0 + * @param encoding The `encoding` of the `privateKey` string. + */ + setPrivateKey(privateKey: NodeJS.ArrayBufferView): void; + setPrivateKey(privateKey: string, encoding: BufferEncoding): void; + /** + * A bit field containing any warnings and/or errors resulting from a check + * performed during initialization of the `DiffieHellman` object. + * + * The following values are valid for this property (as defined in `node:constants` module): + * + * * `DH_CHECK_P_NOT_SAFE_PRIME` + * * `DH_CHECK_P_NOT_PRIME` + * * `DH_UNABLE_TO_CHECK_GENERATOR` + * * `DH_NOT_SUITABLE_GENERATOR` + * @since v0.11.12 + */ + verifyError: number; + } + /** + * The `DiffieHellmanGroup` class takes a well-known modp group as its argument. + * It works the same as `DiffieHellman`, except that it does not allow changing its keys after creation. + * In other words, it does not implement `setPublicKey()` or `setPrivateKey()` methods. + * + * ```js + * const { createDiffieHellmanGroup } = await import('node:crypto'); + * const dh = createDiffieHellmanGroup('modp1'); + * ``` + * The name (e.g. `'modp1'`) is taken from [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt) (modp1 and 2) and [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt): + * ```bash + * $ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h + * modp1 # 768 bits + * modp2 # 1024 bits + * modp5 # 1536 bits + * modp14 # 2048 bits + * modp15 # etc. + * modp16 + * modp17 + * modp18 + * ``` + * @since v0.7.5 + */ + const DiffieHellmanGroup: DiffieHellmanGroupConstructor; + interface DiffieHellmanGroupConstructor { + new(name: string): DiffieHellmanGroup; + (name: string): DiffieHellmanGroup; + readonly prototype: DiffieHellmanGroup; + } + type DiffieHellmanGroup = Omit; + /** + * Creates a predefined `DiffieHellmanGroup` key exchange object. The + * supported groups are listed in the documentation for `DiffieHellmanGroup`. + * + * The returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing + * the keys (with `diffieHellman.setPublicKey()`, for example). The + * advantage of using this method is that the parties do not have to + * generate nor exchange a group modulus beforehand, saving both processor + * and communication time. + * + * Example (obtaining a shared secret): + * + * ```js + * const { + * getDiffieHellman, + * } = await import('node:crypto'); + * const alice = getDiffieHellman('modp14'); + * const bob = getDiffieHellman('modp14'); + * + * alice.generateKeys(); + * bob.generateKeys(); + * + * const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex'); + * const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex'); + * + * // aliceSecret and bobSecret should be the same + * console.log(aliceSecret === bobSecret); + * ``` + * @since v0.7.5 + */ + function getDiffieHellman(groupName: string): DiffieHellmanGroup; + /** + * An alias for {@link getDiffieHellman} + * @since v0.9.3 + */ + function createDiffieHellmanGroup(name: string): DiffieHellmanGroup; + /** + * Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) + * implementation. A selected HMAC digest algorithm specified by `digest` is + * applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`. + * + * The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an error occurs while deriving the key, `err` will be set; + * otherwise `err` will be `null`. By default, the successfully generated`derivedKey` will be passed to the callback as a `Buffer`. An error will be + * thrown if any of the input arguments specify invalid values or types. + * + * The `iterations` argument must be a number set as high as possible. The + * higher the number of iterations, the more secure the derived key will be, + * but will take a longer amount of time to complete. + * + * The `salt` should be as unique as possible. It is recommended that a salt is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * ```js + * const { + * pbkdf2, + * } = await import('node:crypto'); + * + * pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => { + * if (err) throw err; + * console.log(derivedKey.toString('hex')); // '3745e48...08d59ae' + * }); + * ``` + * + * An array of supported digest functions can be retrieved using {@link getHashes}. + * + * This API uses libuv's threadpool, which can have surprising and + * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information. + * @since v0.5.5 + */ + function pbkdf2( + password: BinaryLike, + salt: BinaryLike, + iterations: number, + keylen: number, + digest: string, + callback: (err: Error | null, derivedKey: Buffer) => void, + ): void; + /** + * Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2) + * implementation. A selected HMAC digest algorithm specified by `digest` is + * applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`. + * + * If an error occurs an `Error` will be thrown, otherwise the derived key will be + * returned as a `Buffer`. + * + * The `iterations` argument must be a number set as high as possible. The + * higher the number of iterations, the more secure the derived key will be, + * but will take a longer amount of time to complete. + * + * The `salt` should be as unique as possible. It is recommended that a salt is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * ```js + * const { + * pbkdf2Sync, + * } = await import('node:crypto'); + * + * const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512'); + * console.log(key.toString('hex')); // '3745e48...08d59ae' + * ``` + * + * An array of supported digest functions can be retrieved using {@link getHashes}. + * @since v0.9.3 + */ + function pbkdf2Sync( + password: BinaryLike, + salt: BinaryLike, + iterations: number, + keylen: number, + digest: string, + ): Buffer; + /** + * Generates cryptographically strong pseudorandom data. The `size` argument + * is a number indicating the number of bytes to generate. + * + * If a `callback` function is provided, the bytes are generated asynchronously + * and the `callback` function is invoked with two arguments: `err` and `buf`. + * If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The`buf` argument is a `Buffer` containing the generated bytes. + * + * ```js + * // Asynchronous + * const { + * randomBytes, + * } = await import('node:crypto'); + * + * randomBytes(256, (err, buf) => { + * if (err) throw err; + * console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`); + * }); + * ``` + * + * If the `callback` function is not provided, the random bytes are generated + * synchronously and returned as a `Buffer`. An error will be thrown if + * there is a problem generating the bytes. + * + * ```js + * // Synchronous + * const { + * randomBytes, + * } = await import('node:crypto'); + * + * const buf = randomBytes(256); + * console.log( + * `${buf.length} bytes of random data: ${buf.toString('hex')}`); + * ``` + * + * The `crypto.randomBytes()` method will not complete until there is + * sufficient entropy available. + * This should normally never take longer than a few milliseconds. The only time + * when generating the random bytes may conceivably block for a longer period of + * time is right after boot, when the whole system is still low on entropy. + * + * This API uses libuv's threadpool, which can have surprising and + * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information. + * + * The asynchronous version of `crypto.randomBytes()` is carried out in a single + * threadpool request. To minimize threadpool task length variation, partition + * large `randomBytes` requests when doing so as part of fulfilling a client + * request. + * @since v0.5.8 + * @param size The number of bytes to generate. The `size` must not be larger than `2**31 - 1`. + * @return if the `callback` function is not provided. + */ + function randomBytes(size: number): Buffer; + function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void; + function pseudoRandomBytes(size: number): Buffer; + function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void; + /** + * Return a random integer `n` such that `min <= n < max`. This + * implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias). + * + * The range (`max - min`) must be less than 248. `min` and `max` must + * be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger). + * + * If the `callback` function is not provided, the random integer is + * generated synchronously. + * + * ```js + * // Asynchronous + * const { + * randomInt, + * } = await import('node:crypto'); + * + * randomInt(3, (err, n) => { + * if (err) throw err; + * console.log(`Random number chosen from (0, 1, 2): ${n}`); + * }); + * ``` + * + * ```js + * // Synchronous + * const { + * randomInt, + * } = await import('node:crypto'); + * + * const n = randomInt(3); + * console.log(`Random number chosen from (0, 1, 2): ${n}`); + * ``` + * + * ```js + * // With `min` argument + * const { + * randomInt, + * } = await import('node:crypto'); + * + * const n = randomInt(1, 7); + * console.log(`The dice rolled: ${n}`); + * ``` + * @since v14.10.0, v12.19.0 + * @param [min=0] Start of random range (inclusive). + * @param max End of random range (exclusive). + * @param callback `function(err, n) {}`. + */ + function randomInt(max: number): number; + function randomInt(min: number, max: number): number; + function randomInt(max: number, callback: (err: Error | null, value: number) => void): void; + function randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void; + /** + * Synchronous version of {@link randomFill}. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { randomFillSync } = await import('node:crypto'); + * + * const buf = Buffer.alloc(10); + * console.log(randomFillSync(buf).toString('hex')); + * + * randomFillSync(buf, 5); + * console.log(buf.toString('hex')); + * + * // The above is equivalent to the following: + * randomFillSync(buf, 5, 5); + * console.log(buf.toString('hex')); + * ``` + * + * Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as`buffer`. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { randomFillSync } = await import('node:crypto'); + * + * const a = new Uint32Array(10); + * console.log(Buffer.from(randomFillSync(a).buffer, + * a.byteOffset, a.byteLength).toString('hex')); + * + * const b = new DataView(new ArrayBuffer(10)); + * console.log(Buffer.from(randomFillSync(b).buffer, + * b.byteOffset, b.byteLength).toString('hex')); + * + * const c = new ArrayBuffer(10); + * console.log(Buffer.from(randomFillSync(c)).toString('hex')); + * ``` + * @since v7.10.0, v6.13.0 + * @param buffer Must be supplied. The size of the provided `buffer` must not be larger than `2**31 - 1`. + * @param [offset=0] + * @param [size=buffer.length - offset] + * @return The object passed as `buffer` argument. + */ + function randomFillSync(buffer: T, offset?: number, size?: number): T; + /** + * This function is similar to {@link randomBytes} but requires the first + * argument to be a `Buffer` that will be filled. It also + * requires that a callback is passed in. + * + * If the `callback` function is not provided, an error will be thrown. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { randomFill } = await import('node:crypto'); + * + * const buf = Buffer.alloc(10); + * randomFill(buf, (err, buf) => { + * if (err) throw err; + * console.log(buf.toString('hex')); + * }); + * + * randomFill(buf, 5, (err, buf) => { + * if (err) throw err; + * console.log(buf.toString('hex')); + * }); + * + * // The above is equivalent to the following: + * randomFill(buf, 5, 5, (err, buf) => { + * if (err) throw err; + * console.log(buf.toString('hex')); + * }); + * ``` + * + * Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as`buffer`. + * + * While this includes instances of `Float32Array` and `Float64Array`, this + * function should not be used to generate random floating-point numbers. The + * result may contain `+Infinity`, `-Infinity`, and `NaN`, and even if the array + * contains finite numbers only, they are not drawn from a uniform random + * distribution and have no meaningful lower or upper bounds. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { randomFill } = await import('node:crypto'); + * + * const a = new Uint32Array(10); + * randomFill(a, (err, buf) => { + * if (err) throw err; + * console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength) + * .toString('hex')); + * }); + * + * const b = new DataView(new ArrayBuffer(10)); + * randomFill(b, (err, buf) => { + * if (err) throw err; + * console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength) + * .toString('hex')); + * }); + * + * const c = new ArrayBuffer(10); + * randomFill(c, (err, buf) => { + * if (err) throw err; + * console.log(Buffer.from(buf).toString('hex')); + * }); + * ``` + * + * This API uses libuv's threadpool, which can have surprising and + * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information. + * + * The asynchronous version of `crypto.randomFill()` is carried out in a single + * threadpool request. To minimize threadpool task length variation, partition + * large `randomFill` requests when doing so as part of fulfilling a client + * request. + * @since v7.10.0, v6.13.0 + * @param buffer Must be supplied. The size of the provided `buffer` must not be larger than `2**31 - 1`. + * @param [offset=0] + * @param [size=buffer.length - offset] + * @param callback `function(err, buf) {}`. + */ + function randomFill( + buffer: T, + callback: (err: Error | null, buf: T) => void, + ): void; + function randomFill( + buffer: T, + offset: number, + callback: (err: Error | null, buf: T) => void, + ): void; + function randomFill( + buffer: T, + offset: number, + size: number, + callback: (err: Error | null, buf: T) => void, + ): void; + interface ScryptOptions { + cost?: number | undefined; + blockSize?: number | undefined; + parallelization?: number | undefined; + N?: number | undefined; + r?: number | undefined; + p?: number | undefined; + maxmem?: number | undefined; + } + /** + * Provides an asynchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based + * key derivation function that is designed to be expensive computationally and + * memory-wise in order to make brute-force attacks unrewarding. + * + * The `salt` should be as unique as possible. It is recommended that a salt is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * The `callback` function is called with two arguments: `err` and `derivedKey`.`err` is an exception object when key derivation fails, otherwise `err` is`null`. `derivedKey` is passed to the + * callback as a `Buffer`. + * + * An exception is thrown when any of the input arguments specify invalid values + * or types. + * + * ```js + * const { + * scrypt, + * } = await import('node:crypto'); + * + * // Using the factory defaults. + * scrypt('password', 'salt', 64, (err, derivedKey) => { + * if (err) throw err; + * console.log(derivedKey.toString('hex')); // '3745e48...08d59ae' + * }); + * // Using a custom N parameter. Must be a power of two. + * scrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => { + * if (err) throw err; + * console.log(derivedKey.toString('hex')); // '3745e48...aa39b34' + * }); + * ``` + * @since v10.5.0 + */ + function scrypt( + password: BinaryLike, + salt: BinaryLike, + keylen: number, + callback: (err: Error | null, derivedKey: Buffer) => void, + ): void; + function scrypt( + password: BinaryLike, + salt: BinaryLike, + keylen: number, + options: ScryptOptions, + callback: (err: Error | null, derivedKey: Buffer) => void, + ): void; + /** + * Provides a synchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based + * key derivation function that is designed to be expensive computationally and + * memory-wise in order to make brute-force attacks unrewarding. + * + * The `salt` should be as unique as possible. It is recommended that a salt is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`. + * + * An exception is thrown when key derivation fails, otherwise the derived key is + * returned as a `Buffer`. + * + * An exception is thrown when any of the input arguments specify invalid values + * or types. + * + * ```js + * const { + * scryptSync, + * } = await import('node:crypto'); + * // Using the factory defaults. + * + * const key1 = scryptSync('password', 'salt', 64); + * console.log(key1.toString('hex')); // '3745e48...08d59ae' + * // Using a custom N parameter. Must be a power of two. + * const key2 = scryptSync('password', 'salt', 64, { N: 1024 }); + * console.log(key2.toString('hex')); // '3745e48...aa39b34' + * ``` + * @since v10.5.0 + */ + function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer; + interface RsaPublicKey { + key: KeyLike; + padding?: number | undefined; + } + interface RsaPrivateKey { + key: KeyLike; + passphrase?: string | undefined; + /** + * @default 'sha1' + */ + oaepHash?: string | undefined; + oaepLabel?: NodeJS.TypedArray | undefined; + padding?: number | undefined; + } + /** + * Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using + * the corresponding private key, for example using {@link privateDecrypt}. + * + * If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an + * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`. + * + * Because RSA public keys can be derived from private keys, a private key may + * be passed instead of a public key. + * @since v0.11.14 + */ + function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer; + /** + * Decrypts `buffer` with `key`.`buffer` was previously encrypted using + * the corresponding private key, for example using {@link privateEncrypt}. + * + * If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an + * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`. + * + * Because RSA public keys can be derived from private keys, a private key may + * be passed instead of a public key. + * @since v1.1.0 + */ + function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer; + /** + * Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using + * the corresponding public key, for example using {@link publicEncrypt}. + * + * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an + * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`. + * @since v0.11.14 + */ + function privateDecrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer; + /** + * Encrypts `buffer` with `privateKey`. The returned data can be decrypted using + * the corresponding public key, for example using {@link publicDecrypt}. + * + * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an + * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`. + * @since v1.1.0 + */ + function privateEncrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer; + /** + * ```js + * const { + * getCiphers, + * } = await import('node:crypto'); + * + * console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...] + * ``` + * @since v0.9.3 + * @return An array with the names of the supported cipher algorithms. + */ + function getCiphers(): string[]; + /** + * ```js + * const { + * getCurves, + * } = await import('node:crypto'); + * + * console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] + * ``` + * @since v2.3.0 + * @return An array with the names of the supported elliptic curves. + */ + function getCurves(): string[]; + /** + * @since v10.0.0 + * @return `1` if and only if a FIPS compliant crypto provider is currently in use, `0` otherwise. A future semver-major release may change the return type of this API to a {boolean}. + */ + function getFips(): 1 | 0; + /** + * Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. + * Throws an error if FIPS mode is not available. + * @since v10.0.0 + * @param bool `true` to enable FIPS mode. + */ + function setFips(bool: boolean): void; + /** + * ```js + * const { + * getHashes, + * } = await import('node:crypto'); + * + * console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...] + * ``` + * @since v0.9.3 + * @return An array of the names of the supported hash algorithms, such as `'RSA-SHA256'`. Hash algorithms are also called "digest" algorithms. + */ + function getHashes(): string[]; + /** + * The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH) + * key exchanges. + * + * Instances of the `ECDH` class can be created using the {@link createECDH} function. + * + * ```js + * import assert from 'node:assert'; + * + * const { + * createECDH, + * } = await import('node:crypto'); + * + * // Generate Alice's keys... + * const alice = createECDH('secp521r1'); + * const aliceKey = alice.generateKeys(); + * + * // Generate Bob's keys... + * const bob = createECDH('secp521r1'); + * const bobKey = bob.generateKeys(); + * + * // Exchange and generate the secret... + * const aliceSecret = alice.computeSecret(bobKey); + * const bobSecret = bob.computeSecret(aliceKey); + * + * assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); + * // OK + * ``` + * @since v0.11.14 + */ + class ECDH { + private constructor(); + /** + * Converts the EC Diffie-Hellman public key specified by `key` and `curve` to the + * format specified by `format`. The `format` argument specifies point encoding + * and can be `'compressed'`, `'uncompressed'` or `'hybrid'`. The supplied key is + * interpreted using the specified `inputEncoding`, and the returned key is encoded + * using the specified `outputEncoding`. + * + * Use {@link getCurves} to obtain a list of available curve names. + * On recent OpenSSL releases, `openssl ecparam -list_curves` will also display + * the name and description of each available elliptic curve. + * + * If `format` is not specified the point will be returned in `'uncompressed'`format. + * + * If the `inputEncoding` is not provided, `key` is expected to be a `Buffer`,`TypedArray`, or `DataView`. + * + * Example (uncompressing a key): + * + * ```js + * const { + * createECDH, + * ECDH, + * } = await import('node:crypto'); + * + * const ecdh = createECDH('secp256k1'); + * ecdh.generateKeys(); + * + * const compressedKey = ecdh.getPublicKey('hex', 'compressed'); + * + * const uncompressedKey = ECDH.convertKey(compressedKey, + * 'secp256k1', + * 'hex', + * 'hex', + * 'uncompressed'); + * + * // The converted key and the uncompressed public key should be the same + * console.log(uncompressedKey === ecdh.getPublicKey('hex')); + * ``` + * @since v10.0.0 + * @param inputEncoding The `encoding` of the `key` string. + * @param outputEncoding The `encoding` of the return value. + * @param [format='uncompressed'] + */ + static convertKey( + key: BinaryLike, + curve: string, + inputEncoding?: BinaryToTextEncoding, + outputEncoding?: "latin1" | "hex" | "base64" | "base64url", + format?: "uncompressed" | "compressed" | "hybrid", + ): Buffer | string; + /** + * Generates private and public EC Diffie-Hellman key values, and returns + * the public key in the specified `format` and `encoding`. This key should be + * transferred to the other party. + * + * The `format` argument specifies point encoding and can be `'compressed'` or`'uncompressed'`. If `format` is not specified, the point will be returned in`'uncompressed'` format. + * + * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned. + * @since v0.11.14 + * @param encoding The `encoding` of the return value. + * @param [format='uncompressed'] + */ + generateKeys(): Buffer; + generateKeys(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string; + /** + * Computes the shared secret using `otherPublicKey` as the other + * party's public key and returns the computed shared secret. The supplied + * key is interpreted using specified `inputEncoding`, and the returned secret + * is encoded using the specified `outputEncoding`. + * If the `inputEncoding` is not + * provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or`DataView`. + * + * If `outputEncoding` is given a string will be returned; otherwise a `Buffer` is returned. + * + * `ecdh.computeSecret` will throw an`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey`lies outside of the elliptic curve. Since `otherPublicKey` is + * usually supplied from a remote user over an insecure network, + * be sure to handle this exception accordingly. + * @since v0.11.14 + * @param inputEncoding The `encoding` of the `otherPublicKey` string. + * @param outputEncoding The `encoding` of the return value. + */ + computeSecret(otherPublicKey: NodeJS.ArrayBufferView): Buffer; + computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): Buffer; + computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string; + computeSecret( + otherPublicKey: string, + inputEncoding: BinaryToTextEncoding, + outputEncoding: BinaryToTextEncoding, + ): string; + /** + * If `encoding` is specified, a string is returned; otherwise a `Buffer` is + * returned. + * @since v0.11.14 + * @param encoding The `encoding` of the return value. + * @return The EC Diffie-Hellman in the specified `encoding`. + */ + getPrivateKey(): Buffer; + getPrivateKey(encoding: BinaryToTextEncoding): string; + /** + * The `format` argument specifies point encoding and can be `'compressed'` or`'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format. + * + * If `encoding` is specified, a string is returned; otherwise a `Buffer` is + * returned. + * @since v0.11.14 + * @param encoding The `encoding` of the return value. + * @param [format='uncompressed'] + * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`. + */ + getPublicKey(encoding?: null, format?: ECDHKeyFormat): Buffer; + getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string; + /** + * Sets the EC Diffie-Hellman private key. + * If `encoding` is provided, `privateKey` is expected + * to be a string; otherwise `privateKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`. + * + * If `privateKey` is not valid for the curve specified when the `ECDH` object was + * created, an error is thrown. Upon setting the private key, the associated + * public point (key) is also generated and set in the `ECDH` object. + * @since v0.11.14 + * @param encoding The `encoding` of the `privateKey` string. + */ + setPrivateKey(privateKey: NodeJS.ArrayBufferView): void; + setPrivateKey(privateKey: string, encoding: BinaryToTextEncoding): void; + } + /** + * Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a + * predefined curve specified by the `curveName` string. Use {@link getCurves} to obtain a list of available curve names. On recent + * OpenSSL releases, `openssl ecparam -list_curves` will also display the name + * and description of each available elliptic curve. + * @since v0.11.14 + */ + function createECDH(curveName: string): ECDH; + /** + * This function compares the underlying bytes that represent the given`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time + * algorithm. + * + * This function does not leak timing information that + * would allow an attacker to guess one of the values. This is suitable for + * comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/). + * + * `a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they + * must have the same byte length. An error is thrown if `a` and `b` have + * different byte lengths. + * + * If at least one of `a` and `b` is a `TypedArray` with more than one byte per + * entry, such as `Uint16Array`, the result will be computed using the platform + * byte order. + * + * **When both of the inputs are `Float32Array`s or`Float64Array`s, this function might return unexpected results due to IEEE 754** + * **encoding of floating-point numbers. In particular, neither `x === y` nor`Object.is(x, y)` implies that the byte representations of two floating-point** + * **numbers `x` and `y` are equal.** + * + * Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code + * is timing-safe. Care should be taken to ensure that the surrounding code does + * not introduce timing vulnerabilities. + * @since v6.6.0 + */ + function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean; + type KeyType = "rsa" | "rsa-pss" | "dsa" | "ec" | "ed25519" | "ed448" | "x25519" | "x448"; + type KeyFormat = "pem" | "der" | "jwk"; + interface BasePrivateKeyEncodingOptions { + format: T; + cipher?: string | undefined; + passphrase?: string | undefined; + } + interface KeyPairKeyObjectResult { + publicKey: KeyObject; + privateKey: KeyObject; + } + interface ED25519KeyPairKeyObjectOptions {} + interface ED448KeyPairKeyObjectOptions {} + interface X25519KeyPairKeyObjectOptions {} + interface X448KeyPairKeyObjectOptions {} + interface ECKeyPairKeyObjectOptions { + /** + * Name of the curve to use + */ + namedCurve: string; + } + interface RSAKeyPairKeyObjectOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Public exponent + * @default 0x10001 + */ + publicExponent?: number | undefined; + } + interface RSAPSSKeyPairKeyObjectOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Public exponent + * @default 0x10001 + */ + publicExponent?: number | undefined; + /** + * Name of the message digest + */ + hashAlgorithm?: string; + /** + * Name of the message digest used by MGF1 + */ + mgf1HashAlgorithm?: string; + /** + * Minimal salt length in bytes + */ + saltLength?: string; + } + interface DSAKeyPairKeyObjectOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Size of q in bits + */ + divisorLength: number; + } + interface RSAKeyPairOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Public exponent + * @default 0x10001 + */ + publicExponent?: number | undefined; + publicKeyEncoding: { + type: "pkcs1" | "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs1" | "pkcs8"; + }; + } + interface RSAPSSKeyPairOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Public exponent + * @default 0x10001 + */ + publicExponent?: number | undefined; + /** + * Name of the message digest + */ + hashAlgorithm?: string; + /** + * Name of the message digest used by MGF1 + */ + mgf1HashAlgorithm?: string; + /** + * Minimal salt length in bytes + */ + saltLength?: string; + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface DSAKeyPairOptions { + /** + * Key size in bits + */ + modulusLength: number; + /** + * Size of q in bits + */ + divisorLength: number; + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface ECKeyPairOptions { + /** + * Name of the curve to use. + */ + namedCurve: string; + publicKeyEncoding: { + type: "pkcs1" | "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "sec1" | "pkcs8"; + }; + } + interface ED25519KeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface ED448KeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface X25519KeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface X448KeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } + interface KeyPairSyncResult { + publicKey: T1; + privateKey: T2; + } + /** + * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC, + * Ed25519, Ed448, X25519, X448, and DH are currently supported. + * + * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function + * behaves as if `keyObject.export()` had been called on its result. Otherwise, + * the respective part of the key is returned as a `KeyObject`. + * + * When encoding public keys, it is recommended to use `'spki'`. When encoding + * private keys, it is recommended to use `'pkcs8'` with a strong passphrase, + * and to keep the passphrase confidential. + * + * ```js + * const { + * generateKeyPairSync, + * } = await import('node:crypto'); + * + * const { + * publicKey, + * privateKey, + * } = generateKeyPairSync('rsa', { + * modulusLength: 4096, + * publicKeyEncoding: { + * type: 'spki', + * format: 'pem', + * }, + * privateKeyEncoding: { + * type: 'pkcs8', + * format: 'pem', + * cipher: 'aes-256-cbc', + * passphrase: 'top secret', + * }, + * }); + * ``` + * + * The return value `{ publicKey, privateKey }` represents the generated key pair. + * When PEM encoding was selected, the respective key will be a string, otherwise + * it will be a buffer containing the data encoded as DER. + * @since v10.12.0 + * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`. + */ + function generateKeyPairSync( + type: "rsa", + options: RSAKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa", + options: RSAKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa", + options: RSAKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa", + options: RSAKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "rsa", options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "rsa-pss", options: RSAPSSKeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "dsa", + options: DSAKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "dsa", + options: DSAKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "dsa", + options: DSAKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "dsa", + options: DSAKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "dsa", options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "ec", + options: ECKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ec", + options: ECKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ec", + options: ECKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ec", + options: ECKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "ec", options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "ed25519", options?: ED25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "ed448", + options: ED448KeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed448", + options: ED448KeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed448", + options: ED448KeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ed448", + options: ED448KeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "ed448", options?: ED448KeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "x25519", + options: X25519KeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x25519", + options: X25519KeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x25519", + options: X25519KeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x25519", + options: X25519KeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "x25519", options?: X25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "x448", + options: X448KeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x448", + options: X448KeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x448", + options: X448KeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "x448", + options: X448KeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync(type: "x448", options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult; + /** + * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC, + * Ed25519, Ed448, X25519, X448, and DH are currently supported. + * + * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function + * behaves as if `keyObject.export()` had been called on its result. Otherwise, + * the respective part of the key is returned as a `KeyObject`. + * + * It is recommended to encode public keys as `'spki'` and private keys as`'pkcs8'` with encryption for long-term storage: + * + * ```js + * const { + * generateKeyPair, + * } = await import('node:crypto'); + * + * generateKeyPair('rsa', { + * modulusLength: 4096, + * publicKeyEncoding: { + * type: 'spki', + * format: 'pem', + * }, + * privateKeyEncoding: { + * type: 'pkcs8', + * format: 'pem', + * cipher: 'aes-256-cbc', + * passphrase: 'top secret', + * }, + * }, (err, publicKey, privateKey) => { + * // Handle errors and use the generated key pair. + * }); + * ``` + * + * On completion, `callback` will be called with `err` set to `undefined` and`publicKey` / `privateKey` representing the generated key pair. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a `Promise` for an `Object` with `publicKey` and `privateKey` properties. + * @since v10.12.0 + * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`. + */ + function generateKeyPair( + type: "rsa", + options: RSAKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "rsa", + options: RSAKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "rsa", + options: RSAKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "rsa", + options: RSAKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "rsa", + options: RSAKeyPairKeyObjectOptions, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "rsa-pss", + options: RSAPSSKeyPairKeyObjectOptions, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "dsa", + options: DSAKeyPairKeyObjectOptions, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ec", + options: ECKeyPairKeyObjectOptions, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ed25519", + options: ED25519KeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ed448", + options: ED448KeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "x25519", + options: X25519KeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "x448", + options: X448KeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; + namespace generateKeyPair { + function __promisify__( + type: "rsa", + options: RSAKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "rsa", + options: RSAKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "rsa", + options: RSAKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "rsa", + options: RSAKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__( + type: "rsa-pss", + options: RSAPSSKeyPairKeyObjectOptions, + ): Promise; + function __promisify__( + type: "dsa", + options: DSAKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "dsa", + options: DSAKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "dsa", + options: DSAKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "dsa", + options: DSAKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise; + function __promisify__( + type: "ec", + options: ECKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "ec", + options: ECKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "ec", + options: ECKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "ec", + options: ECKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise; + function __promisify__( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "ed25519", + options: ED25519KeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "ed25519", + options: ED25519KeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__( + type: "ed25519", + options?: ED25519KeyPairKeyObjectOptions, + ): Promise; + function __promisify__( + type: "ed448", + options: ED448KeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "ed448", + options: ED448KeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "ed448", + options: ED448KeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "ed448", + options: ED448KeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "ed448", options?: ED448KeyPairKeyObjectOptions): Promise; + function __promisify__( + type: "x25519", + options: X25519KeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "x25519", + options: X25519KeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "x25519", + options: X25519KeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "x25519", + options: X25519KeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__( + type: "x25519", + options?: X25519KeyPairKeyObjectOptions, + ): Promise; + function __promisify__( + type: "x448", + options: X448KeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "x448", + options: X448KeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "x448", + options: X448KeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "x448", + options: X448KeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__(type: "x448", options?: X448KeyPairKeyObjectOptions): Promise; + } + /** + * Calculates and returns the signature for `data` using the given private key and + * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is + * dependent upon the key type (especially Ed25519 and Ed448). + * + * If `key` is not a `KeyObject`, this function behaves as if `key` had been + * passed to {@link createPrivateKey}. If it is an object, the following + * additional properties can be passed: + * + * If the `callback` function is provided this function uses libuv's threadpool. + * @since v12.0.0 + */ + function sign( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput, + ): Buffer; + function sign( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput, + callback: (error: Error | null, data: Buffer) => void, + ): void; + /** + * Verifies the given signature for `data` using the given key and algorithm. If`algorithm` is `null` or `undefined`, then the algorithm is dependent upon the + * key type (especially Ed25519 and Ed448). + * + * If `key` is not a `KeyObject`, this function behaves as if `key` had been + * passed to {@link createPublicKey}. If it is an object, the following + * additional properties can be passed: + * + * The `signature` argument is the previously calculated signature for the `data`. + * + * Because public keys can be derived from private keys, a private key or a public + * key may be passed for `key`. + * + * If the `callback` function is provided this function uses libuv's threadpool. + * @since v12.0.0 + */ + function verify( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: NodeJS.ArrayBufferView, + ): boolean; + function verify( + algorithm: string | null | undefined, + data: NodeJS.ArrayBufferView, + key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput, + signature: NodeJS.ArrayBufferView, + callback: (error: Error | null, result: boolean) => void, + ): void; + /** + * Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`. + * Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'`(for Diffie-Hellman), `'ec'` (for ECDH), `'x448'`, or `'x25519'` (for ECDH-ES). + * @since v13.9.0, v12.17.0 + */ + function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): Buffer; + type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts"; + interface CipherInfoOptions { + /** + * A test key length. + */ + keyLength?: number | undefined; + /** + * A test IV length. + */ + ivLength?: number | undefined; + } + interface CipherInfo { + /** + * The name of the cipher. + */ + name: string; + /** + * The nid of the cipher. + */ + nid: number; + /** + * The block size of the cipher in bytes. + * This property is omitted when mode is 'stream'. + */ + blockSize?: number | undefined; + /** + * The expected or default initialization vector length in bytes. + * This property is omitted if the cipher does not use an initialization vector. + */ + ivLength?: number | undefined; + /** + * The expected or default key length in bytes. + */ + keyLength: number; + /** + * The cipher mode. + */ + mode: CipherMode; + } + /** + * Returns information about a given cipher. + * + * Some ciphers accept variable length keys and initialization vectors. By default, + * the `crypto.getCipherInfo()` method will return the default values for these + * ciphers. To test if a given key length or iv length is acceptable for given + * cipher, use the `keyLength` and `ivLength` options. If the given values are + * unacceptable, `undefined` will be returned. + * @since v15.0.0 + * @param nameOrNid The name or nid of the cipher to query. + */ + function getCipherInfo(nameOrNid: string | number, options?: CipherInfoOptions): CipherInfo | undefined; + /** + * HKDF is a simple key derivation function defined in RFC 5869\. The given `ikm`,`salt` and `info` are used with the `digest` to derive a key of `keylen` bytes. + * + * The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an errors occurs while deriving the key, `err` will be set; + * otherwise `err` will be `null`. The successfully generated `derivedKey` will + * be passed to the callback as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). An error will be thrown if any + * of the input arguments specify invalid values or types. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { + * hkdf, + * } = await import('node:crypto'); + * + * hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => { + * if (err) throw err; + * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653' + * }); + * ``` + * @since v15.0.0 + * @param digest The digest algorithm to use. + * @param ikm The input keying material. Must be provided but can be zero-length. + * @param salt The salt value. Must be provided but can be zero-length. + * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes. + * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512` + * generates 64-byte hashes, making the maximum HKDF output 16320 bytes). + */ + function hkdf( + digest: string, + irm: BinaryLike | KeyObject, + salt: BinaryLike, + info: BinaryLike, + keylen: number, + callback: (err: Error | null, derivedKey: ArrayBuffer) => void, + ): void; + /** + * Provides a synchronous HKDF key derivation function as defined in RFC 5869\. The + * given `ikm`, `salt` and `info` are used with the `digest` to derive a key of`keylen` bytes. + * + * The successfully generated `derivedKey` will be returned as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). + * + * An error will be thrown if any of the input arguments specify invalid values or + * types, or if the derived key cannot be generated. + * + * ```js + * import { Buffer } from 'node:buffer'; + * const { + * hkdfSync, + * } = await import('node:crypto'); + * + * const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64); + * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653' + * ``` + * @since v15.0.0 + * @param digest The digest algorithm to use. + * @param ikm The input keying material. Must be provided but can be zero-length. + * @param salt The salt value. Must be provided but can be zero-length. + * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes. + * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512` + * generates 64-byte hashes, making the maximum HKDF output 16320 bytes). + */ + function hkdfSync( + digest: string, + ikm: BinaryLike | KeyObject, + salt: BinaryLike, + info: BinaryLike, + keylen: number, + ): ArrayBuffer; + interface SecureHeapUsage { + /** + * The total allocated secure heap size as specified using the `--secure-heap=n` command-line flag. + */ + total: number; + /** + * The minimum allocation from the secure heap as specified using the `--secure-heap-min` command-line flag. + */ + min: number; + /** + * The total number of bytes currently allocated from the secure heap. + */ + used: number; + /** + * The calculated ratio of `used` to `total` allocated bytes. + */ + utilization: number; + } + /** + * @since v15.6.0 + */ + function secureHeapUsed(): SecureHeapUsage; + interface RandomUUIDOptions { + /** + * By default, to improve performance, + * Node.js will pre-emptively generate and persistently cache enough + * random data to generate up to 128 random UUIDs. To generate a UUID + * without using the cache, set `disableEntropyCache` to `true`. + * + * @default `false` + */ + disableEntropyCache?: boolean | undefined; + } + /** + * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a + * cryptographic pseudorandom number generator. + * @since v15.6.0, v14.17.0 + */ + function randomUUID(options?: RandomUUIDOptions): string; + interface X509CheckOptions { + /** + * @default 'always' + */ + subject?: "always" | "default" | "never"; + /** + * @default true + */ + wildcards?: boolean; + /** + * @default true + */ + partialWildcards?: boolean; + /** + * @default false + */ + multiLabelWildcards?: boolean; + /** + * @default false + */ + singleLabelSubdomains?: boolean; + } + /** + * Encapsulates an X509 certificate and provides read-only access to + * its information. + * + * ```js + * const { X509Certificate } = await import('node:crypto'); + * + * const x509 = new X509Certificate('{... pem encoded cert ...}'); + * + * console.log(x509.subject); + * ``` + * @since v15.6.0 + */ + class X509Certificate { + /** + * Will be \`true\` if this is a Certificate Authority (CA) certificate. + * @since v15.6.0 + */ + readonly ca: boolean; + /** + * The SHA-1 fingerprint of this certificate. + * + * Because SHA-1 is cryptographically broken and because the security of SHA-1 is + * significantly worse than that of algorithms that are commonly used to sign + * certificates, consider using `x509.fingerprint256` instead. + * @since v15.6.0 + */ + readonly fingerprint: string; + /** + * The SHA-256 fingerprint of this certificate. + * @since v15.6.0 + */ + readonly fingerprint256: string; + /** + * The SHA-512 fingerprint of this certificate. + * + * Because computing the SHA-256 fingerprint is usually faster and because it is + * only half the size of the SHA-512 fingerprint, `x509.fingerprint256` may be + * a better choice. While SHA-512 presumably provides a higher level of security in + * general, the security of SHA-256 matches that of most algorithms that are + * commonly used to sign certificates. + * @since v17.2.0, v16.14.0 + */ + readonly fingerprint512: string; + /** + * The complete subject of this certificate. + * @since v15.6.0 + */ + readonly subject: string; + /** + * The subject alternative name specified for this certificate. + * + * This is a comma-separated list of subject alternative names. Each entry begins + * with a string identifying the kind of the subject alternative name followed by + * a colon and the value associated with the entry. + * + * Earlier versions of Node.js incorrectly assumed that it is safe to split this + * property at the two-character sequence `', '` (see [CVE-2021-44532](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532)). However, + * both malicious and legitimate certificates can contain subject alternative names + * that include this sequence when represented as a string. + * + * After the prefix denoting the type of the entry, the remainder of each entry + * might be enclosed in quotes to indicate that the value is a JSON string literal. + * For backward compatibility, Node.js only uses JSON string literals within this + * property when necessary to avoid ambiguity. Third-party code should be prepared + * to handle both possible entry formats. + * @since v15.6.0 + */ + readonly subjectAltName: string | undefined; + /** + * A textual representation of the certificate's authority information access + * extension. + * + * This is a line feed separated list of access descriptions. Each line begins with + * the access method and the kind of the access location, followed by a colon and + * the value associated with the access location. + * + * After the prefix denoting the access method and the kind of the access location, + * the remainder of each line might be enclosed in quotes to indicate that the + * value is a JSON string literal. For backward compatibility, Node.js only uses + * JSON string literals within this property when necessary to avoid ambiguity. + * Third-party code should be prepared to handle both possible entry formats. + * @since v15.6.0 + */ + readonly infoAccess: string | undefined; + /** + * An array detailing the key usages for this certificate. + * @since v15.6.0 + */ + readonly keyUsage: string[]; + /** + * The issuer identification included in this certificate. + * @since v15.6.0 + */ + readonly issuer: string; + /** + * The issuer certificate or `undefined` if the issuer certificate is not + * available. + * @since v15.9.0 + */ + readonly issuerCertificate?: X509Certificate | undefined; + /** + * The public key `KeyObject` for this certificate. + * @since v15.6.0 + */ + readonly publicKey: KeyObject; + /** + * A `Buffer` containing the DER encoding of this certificate. + * @since v15.6.0 + */ + readonly raw: Buffer; + /** + * The serial number of this certificate. + * + * Serial numbers are assigned by certificate authorities and do not uniquely + * identify certificates. Consider using `x509.fingerprint256` as a unique + * identifier instead. + * @since v15.6.0 + */ + readonly serialNumber: string; + /** + * The date/time from which this certificate is considered valid. + * @since v15.6.0 + */ + readonly validFrom: string; + /** + * The date/time until which this certificate is considered valid. + * @since v15.6.0 + */ + readonly validTo: string; + constructor(buffer: BinaryLike); + /** + * Checks whether the certificate matches the given email address. + * + * If the `'subject'` option is undefined or set to `'default'`, the certificate + * subject is only considered if the subject alternative name extension either does + * not exist or does not contain any email addresses. + * + * If the `'subject'` option is set to `'always'` and if the subject alternative + * name extension either does not exist or does not contain a matching email + * address, the certificate subject is considered. + * + * If the `'subject'` option is set to `'never'`, the certificate subject is never + * considered, even if the certificate contains no subject alternative names. + * @since v15.6.0 + * @return Returns `email` if the certificate matches, `undefined` if it does not. + */ + checkEmail(email: string, options?: Pick): string | undefined; + /** + * Checks whether the certificate matches the given host name. + * + * If the certificate matches the given host name, the matching subject name is + * returned. The returned name might be an exact match (e.g., `foo.example.com`) + * or it might contain wildcards (e.g., `*.example.com`). Because host name + * comparisons are case-insensitive, the returned subject name might also differ + * from the given `name` in capitalization. + * + * If the `'subject'` option is undefined or set to `'default'`, the certificate + * subject is only considered if the subject alternative name extension either does + * not exist or does not contain any DNS names. This behavior is consistent with [RFC 2818](https://www.rfc-editor.org/rfc/rfc2818.txt) ("HTTP Over TLS"). + * + * If the `'subject'` option is set to `'always'` and if the subject alternative + * name extension either does not exist or does not contain a matching DNS name, + * the certificate subject is considered. + * + * If the `'subject'` option is set to `'never'`, the certificate subject is never + * considered, even if the certificate contains no subject alternative names. + * @since v15.6.0 + * @return Returns a subject name that matches `name`, or `undefined` if no subject name matches `name`. + */ + checkHost(name: string, options?: X509CheckOptions): string | undefined; + /** + * Checks whether the certificate matches the given IP address (IPv4 or IPv6). + * + * Only [RFC 5280](https://www.rfc-editor.org/rfc/rfc5280.txt) `iPAddress` subject alternative names are considered, and they + * must match the given `ip` address exactly. Other subject alternative names as + * well as the subject field of the certificate are ignored. + * @since v15.6.0 + * @return Returns `ip` if the certificate matches, `undefined` if it does not. + */ + checkIP(ip: string): string | undefined; + /** + * Checks whether this certificate was issued by the given `otherCert`. + * @since v15.6.0 + */ + checkIssued(otherCert: X509Certificate): boolean; + /** + * Checks whether the public key for this certificate is consistent with + * the given private key. + * @since v15.6.0 + * @param privateKey A private key. + */ + checkPrivateKey(privateKey: KeyObject): boolean; + /** + * There is no standard JSON encoding for X509 certificates. The`toJSON()` method returns a string containing the PEM encoded + * certificate. + * @since v15.6.0 + */ + toJSON(): string; + /** + * Returns information about this certificate using the legacy `certificate object` encoding. + * @since v15.6.0 + */ + toLegacyObject(): PeerCertificate; + /** + * Returns the PEM-encoded certificate. + * @since v15.6.0 + */ + toString(): string; + /** + * Verifies that this certificate was signed by the given public key. + * Does not perform any other validation checks on the certificate. + * @since v15.6.0 + * @param publicKey A public key. + */ + verify(publicKey: KeyObject): boolean; + } + type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint; + interface GeneratePrimeOptions { + add?: LargeNumberLike | undefined; + rem?: LargeNumberLike | undefined; + /** + * @default false + */ + safe?: boolean | undefined; + bigint?: boolean | undefined; + } + interface GeneratePrimeOptionsBigInt extends GeneratePrimeOptions { + bigint: true; + } + interface GeneratePrimeOptionsArrayBuffer extends GeneratePrimeOptions { + bigint?: false | undefined; + } + /** + * Generates a pseudorandom prime of `size` bits. + * + * If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime. + * + * The `options.add` and `options.rem` parameters can be used to enforce additional + * requirements, e.g., for Diffie-Hellman: + * + * * If `options.add` and `options.rem` are both set, the prime will satisfy the + * condition that `prime % add = rem`. + * * If only `options.add` is set and `options.safe` is not `true`, the prime will + * satisfy the condition that `prime % add = 1`. + * * If only `options.add` is set and `options.safe` is set to `true`, the prime + * will instead satisfy the condition that `prime % add = 3`. This is necessary + * because `prime % add = 1` for `options.add > 2` would contradict the condition + * enforced by `options.safe`. + * * `options.rem` is ignored if `options.add` is not given. + * + * Both `options.add` and `options.rem` must be encoded as big-endian sequences + * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`. + * + * By default, the prime is encoded as a big-endian sequence of octets + * in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a + * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) is provided. + * @since v15.8.0 + * @param size The size (in bits) of the prime to generate. + */ + function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void; + function generatePrime( + size: number, + options: GeneratePrimeOptionsBigInt, + callback: (err: Error | null, prime: bigint) => void, + ): void; + function generatePrime( + size: number, + options: GeneratePrimeOptionsArrayBuffer, + callback: (err: Error | null, prime: ArrayBuffer) => void, + ): void; + function generatePrime( + size: number, + options: GeneratePrimeOptions, + callback: (err: Error | null, prime: ArrayBuffer | bigint) => void, + ): void; + /** + * Generates a pseudorandom prime of `size` bits. + * + * If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime. + * + * The `options.add` and `options.rem` parameters can be used to enforce additional + * requirements, e.g., for Diffie-Hellman: + * + * * If `options.add` and `options.rem` are both set, the prime will satisfy the + * condition that `prime % add = rem`. + * * If only `options.add` is set and `options.safe` is not `true`, the prime will + * satisfy the condition that `prime % add = 1`. + * * If only `options.add` is set and `options.safe` is set to `true`, the prime + * will instead satisfy the condition that `prime % add = 3`. This is necessary + * because `prime % add = 1` for `options.add > 2` would contradict the condition + * enforced by `options.safe`. + * * `options.rem` is ignored if `options.add` is not given. + * + * Both `options.add` and `options.rem` must be encoded as big-endian sequences + * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`. + * + * By default, the prime is encoded as a big-endian sequence of octets + * in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a + * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) is provided. + * @since v15.8.0 + * @param size The size (in bits) of the prime to generate. + */ + function generatePrimeSync(size: number): ArrayBuffer; + function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint; + function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer; + function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint; + interface CheckPrimeOptions { + /** + * The number of Miller-Rabin probabilistic primality iterations to perform. + * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input. + * Care must be used when selecting a number of checks. + * Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details. + * + * @default 0 + */ + checks?: number | undefined; + } + /** + * Checks the primality of the `candidate`. + * @since v15.8.0 + * @param candidate A possible prime encoded as a sequence of big endian octets of arbitrary length. + */ + function checkPrime(value: LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void; + function checkPrime( + value: LargeNumberLike, + options: CheckPrimeOptions, + callback: (err: Error | null, result: boolean) => void, + ): void; + /** + * Checks the primality of the `candidate`. + * @since v15.8.0 + * @param candidate A possible prime encoded as a sequence of big endian octets of arbitrary length. + * @return `true` if the candidate is a prime with an error probability less than `0.25 ** options.checks`. + */ + function checkPrimeSync(candidate: LargeNumberLike, options?: CheckPrimeOptions): boolean; + /** + * Load and set the `engine` for some or all OpenSSL functions (selected by flags). + * + * `engine` could be either an id or a path to the engine's shared library. + * + * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`is a bit field taking one of or a mix of the following flags (defined in`crypto.constants`): + * + * * `crypto.constants.ENGINE_METHOD_RSA` + * * `crypto.constants.ENGINE_METHOD_DSA` + * * `crypto.constants.ENGINE_METHOD_DH` + * * `crypto.constants.ENGINE_METHOD_RAND` + * * `crypto.constants.ENGINE_METHOD_EC` + * * `crypto.constants.ENGINE_METHOD_CIPHERS` + * * `crypto.constants.ENGINE_METHOD_DIGESTS` + * * `crypto.constants.ENGINE_METHOD_PKEY_METHS` + * * `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS` + * * `crypto.constants.ENGINE_METHOD_ALL` + * * `crypto.constants.ENGINE_METHOD_NONE` + * @since v0.11.11 + * @param flags + */ + function setEngine(engine: string, flags?: number): void; + /** + * A convenient alias for {@link webcrypto.getRandomValues}. This + * implementation is not compliant with the Web Crypto spec, to write + * web-compatible code use {@link webcrypto.getRandomValues} instead. + * @since v17.4.0 + * @return Returns `typedArray`. + */ + function getRandomValues(typedArray: T): T; + /** + * A convenient alias for `crypto.webcrypto.subtle`. + * @since v17.4.0 + */ + const subtle: webcrypto.SubtleCrypto; + /** + * An implementation of the Web Crypto API standard. + * + * See the {@link https://nodejs.org/docs/latest/api/webcrypto.html Web Crypto API documentation} for details. + * @since v15.0.0 + */ + const webcrypto: webcrypto.Crypto; + namespace webcrypto { + type BufferSource = ArrayBufferView | ArrayBuffer; + type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki"; + type KeyType = "private" | "public" | "secret"; + type KeyUsage = + | "decrypt" + | "deriveBits" + | "deriveKey" + | "encrypt" + | "sign" + | "unwrapKey" + | "verify" + | "wrapKey"; + type AlgorithmIdentifier = Algorithm | string; + type HashAlgorithmIdentifier = AlgorithmIdentifier; + type NamedCurve = string; + type BigInteger = Uint8Array; + interface AesCbcParams extends Algorithm { + iv: BufferSource; + } + interface AesCtrParams extends Algorithm { + counter: BufferSource; + length: number; + } + interface AesDerivedKeyParams extends Algorithm { + length: number; + } + interface AesGcmParams extends Algorithm { + additionalData?: BufferSource; + iv: BufferSource; + tagLength?: number; + } + interface AesKeyAlgorithm extends KeyAlgorithm { + length: number; + } + interface AesKeyGenParams extends Algorithm { + length: number; + } + interface Algorithm { + name: string; + } + interface EcKeyAlgorithm extends KeyAlgorithm { + namedCurve: NamedCurve; + } + interface EcKeyGenParams extends Algorithm { + namedCurve: NamedCurve; + } + interface EcKeyImportParams extends Algorithm { + namedCurve: NamedCurve; + } + interface EcdhKeyDeriveParams extends Algorithm { + public: CryptoKey; + } + interface EcdsaParams extends Algorithm { + hash: HashAlgorithmIdentifier; + } + interface Ed448Params extends Algorithm { + context?: BufferSource; + } + interface HkdfParams extends Algorithm { + hash: HashAlgorithmIdentifier; + info: BufferSource; + salt: BufferSource; + } + interface HmacImportParams extends Algorithm { + hash: HashAlgorithmIdentifier; + length?: number; + } + interface HmacKeyAlgorithm extends KeyAlgorithm { + hash: KeyAlgorithm; + length: number; + } + interface HmacKeyGenParams extends Algorithm { + hash: HashAlgorithmIdentifier; + length?: number; + } + interface JsonWebKey { + alg?: string; + crv?: string; + d?: string; + dp?: string; + dq?: string; + e?: string; + ext?: boolean; + k?: string; + key_ops?: string[]; + kty?: string; + n?: string; + oth?: RsaOtherPrimesInfo[]; + p?: string; + q?: string; + qi?: string; + use?: string; + x?: string; + y?: string; + } + interface KeyAlgorithm { + name: string; + } + interface Pbkdf2Params extends Algorithm { + hash: HashAlgorithmIdentifier; + iterations: number; + salt: BufferSource; + } + interface RsaHashedImportParams extends Algorithm { + hash: HashAlgorithmIdentifier; + } + interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm { + hash: KeyAlgorithm; + } + interface RsaHashedKeyGenParams extends RsaKeyGenParams { + hash: HashAlgorithmIdentifier; + } + interface RsaKeyAlgorithm extends KeyAlgorithm { + modulusLength: number; + publicExponent: BigInteger; + } + interface RsaKeyGenParams extends Algorithm { + modulusLength: number; + publicExponent: BigInteger; + } + interface RsaOaepParams extends Algorithm { + label?: BufferSource; + } + interface RsaOtherPrimesInfo { + d?: string; + r?: string; + t?: string; + } + interface RsaPssParams extends Algorithm { + saltLength: number; + } + /** + * Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class. + * `Crypto` is a singleton that provides access to the remainder of the crypto API. + * @since v15.0.0 + */ + interface Crypto { + /** + * Provides access to the `SubtleCrypto` API. + * @since v15.0.0 + */ + readonly subtle: SubtleCrypto; + /** + * Generates cryptographically strong random values. + * The given `typedArray` is filled with random values, and a reference to `typedArray` is returned. + * + * The given `typedArray` must be an integer-based instance of {@link NodeJS.TypedArray}, i.e. `Float32Array` and `Float64Array` are not accepted. + * + * An error will be thrown if the given `typedArray` is larger than 65,536 bytes. + * @since v15.0.0 + */ + getRandomValues>(typedArray: T): T; + /** + * Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID. + * The UUID is generated using a cryptographic pseudorandom number generator. + * @since v16.7.0 + */ + randomUUID(): string; + CryptoKey: CryptoKeyConstructor; + } + // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable. + interface CryptoKeyConstructor { + /** Illegal constructor */ + (_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user. + readonly length: 0; + readonly name: "CryptoKey"; + readonly prototype: CryptoKey; + } + /** + * @since v15.0.0 + */ + interface CryptoKey { + /** + * An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters. + * @since v15.0.0 + */ + readonly algorithm: KeyAlgorithm; + /** + * When `true`, the {@link CryptoKey} can be extracted using either `subtleCrypto.exportKey()` or `subtleCrypto.wrapKey()`. + * @since v15.0.0 + */ + readonly extractable: boolean; + /** + * A string identifying whether the key is a symmetric (`'secret'`) or asymmetric (`'private'` or `'public'`) key. + * @since v15.0.0 + */ + readonly type: KeyType; + /** + * An array of strings identifying the operations for which the key may be used. + * + * The possible usages are: + * - `'encrypt'` - The key may be used to encrypt data. + * - `'decrypt'` - The key may be used to decrypt data. + * - `'sign'` - The key may be used to generate digital signatures. + * - `'verify'` - The key may be used to verify digital signatures. + * - `'deriveKey'` - The key may be used to derive a new key. + * - `'deriveBits'` - The key may be used to derive bits. + * - `'wrapKey'` - The key may be used to wrap another key. + * - `'unwrapKey'` - The key may be used to unwrap another key. + * + * Valid key usages depend on the key algorithm (identified by `cryptokey.algorithm.name`). + * @since v15.0.0 + */ + readonly usages: KeyUsage[]; + } + /** + * The `CryptoKeyPair` is a simple dictionary object with `publicKey` and `privateKey` properties, representing an asymmetric key pair. + * @since v15.0.0 + */ + interface CryptoKeyPair { + /** + * A {@link CryptoKey} whose type will be `'private'`. + * @since v15.0.0 + */ + privateKey: CryptoKey; + /** + * A {@link CryptoKey} whose type will be `'public'`. + * @since v15.0.0 + */ + publicKey: CryptoKey; + } + /** + * @since v15.0.0 + */ + interface SubtleCrypto { + /** + * Using the method and parameters specified in `algorithm` and the keying material provided by `key`, + * `subtle.decrypt()` attempts to decipher the provided `data`. If successful, + * the returned promise will be resolved with an `` containing the plaintext result. + * + * The algorithms currently supported include: + * + * - `'RSA-OAEP'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * @since v15.0.0 + */ + decrypt( + algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + key: CryptoKey, + data: BufferSource, + ): Promise; + /** + * Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`, + * `subtle.deriveBits()` attempts to generate `length` bits. + * The Node.js implementation requires that when `length` is a number it must be multiple of `8`. + * When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed + * for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms. + * If successful, the returned promise will be resolved with an `` containing the generated data. + * + * The algorithms currently supported include: + * + * - `'ECDH'` + * - `'X25519'` + * - `'X448'` + * - `'HKDF'` + * - `'PBKDF2'` + * @since v15.0.0 + */ + deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise; + deriveBits( + algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params, + baseKey: CryptoKey, + length: number, + ): Promise; + /** + * Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`, + * `subtle.deriveKey()` attempts to generate a new ` based on the method and parameters in `derivedKeyAlgorithm`. + * + * Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material, + * then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input. + * + * The algorithms currently supported include: + * + * - `'ECDH'` + * - `'X25519'` + * - `'X448'` + * - `'HKDF'` + * - `'PBKDF2'` + * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. + * @since v15.0.0 + */ + deriveKey( + algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, + baseKey: CryptoKey, + derivedKeyAlgorithm: + | AlgorithmIdentifier + | AesDerivedKeyParams + | HmacImportParams + | HkdfParams + | Pbkdf2Params, + extractable: boolean, + keyUsages: readonly KeyUsage[], + ): Promise; + /** + * Using the method identified by `algorithm`, `subtle.digest()` attempts to generate a digest of `data`. + * If successful, the returned promise is resolved with an `` containing the computed digest. + * + * If `algorithm` is provided as a ``, it must be one of: + * + * - `'SHA-1'` + * - `'SHA-256'` + * - `'SHA-384'` + * - `'SHA-512'` + * + * If `algorithm` is provided as an ``, it must have a `name` property whose value is one of the above. + * @since v15.0.0 + */ + digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; + /** + * Using the method and parameters specified by `algorithm` and the keying material provided by `key`, + * `subtle.encrypt()` attempts to encipher `data`. If successful, + * the returned promise is resolved with an `` containing the encrypted result. + * + * The algorithms currently supported include: + * + * - `'RSA-OAEP'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * @since v15.0.0 + */ + encrypt( + algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + key: CryptoKey, + data: BufferSource, + ): Promise; + /** + * Exports the given key into the specified format, if supported. + * + * If the `` is not extractable, the returned promise will reject. + * + * When `format` is either `'pkcs8'` or `'spki'` and the export is successful, + * the returned promise will be resolved with an `` containing the exported key data. + * + * When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a + * JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification. + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @returns `` containing ``. + * @since v15.0.0 + */ + exportKey(format: "jwk", key: CryptoKey): Promise; + exportKey(format: Exclude, key: CryptoKey): Promise; + /** + * Using the method and parameters provided in `algorithm`, + * `subtle.generateKey()` attempts to generate new keying material. + * Depending the method used, the method may generate either a single `` or a ``. + * + * The `` (public and private key) generating algorithms supported include: + * + * - `'RSASSA-PKCS1-v1_5'` + * - `'RSA-PSS'` + * - `'RSA-OAEP'` + * - `'ECDSA'` + * - `'Ed25519'` + * - `'Ed448'` + * - `'ECDH'` + * - `'X25519'` + * - `'X448'` + * The `` (secret key) generating algorithms supported include: + * + * - `'HMAC'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * - `'AES-KW'` + * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. + * @since v15.0.0 + */ + generateKey( + algorithm: RsaHashedKeyGenParams | EcKeyGenParams, + extractable: boolean, + keyUsages: readonly KeyUsage[], + ): Promise; + generateKey( + algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, + extractable: boolean, + keyUsages: readonly KeyUsage[], + ): Promise; + generateKey( + algorithm: AlgorithmIdentifier, + extractable: boolean, + keyUsages: KeyUsage[], + ): Promise; + /** + * The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format` + * to create a `` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments. + * If the import is successful, the returned promise will be resolved with the created ``. + * + * If importing a `'PBKDF2'` key, `extractable` must be `false`. + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. + * @since v15.0.0 + */ + importKey( + format: "jwk", + keyData: JsonWebKey, + algorithm: + | AlgorithmIdentifier + | RsaHashedImportParams + | EcKeyImportParams + | HmacImportParams + | AesKeyAlgorithm, + extractable: boolean, + keyUsages: readonly KeyUsage[], + ): Promise; + importKey( + format: Exclude, + keyData: BufferSource, + algorithm: + | AlgorithmIdentifier + | RsaHashedImportParams + | EcKeyImportParams + | HmacImportParams + | AesKeyAlgorithm, + extractable: boolean, + keyUsages: KeyUsage[], + ): Promise; + /** + * Using the method and parameters given by `algorithm` and the keying material provided by `key`, + * `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful, + * the returned promise is resolved with an `` containing the generated signature. + * + * The algorithms currently supported include: + * + * - `'RSASSA-PKCS1-v1_5'` + * - `'RSA-PSS'` + * - `'ECDSA'` + * - `'Ed25519'` + * - `'Ed448'` + * - `'HMAC'` + * @since v15.0.0 + */ + sign( + algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, + key: CryptoKey, + data: BufferSource, + ): Promise; + /** + * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. + * The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `` instance. + * It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input) + * then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs. + * If successful, the returned promise is resolved with a `` object. + * + * The wrapping algorithms currently supported include: + * + * - `'RSA-OAEP'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * - `'AES-KW'` + * + * The unwrapped key algorithms supported include: + * + * - `'RSASSA-PKCS1-v1_5'` + * - `'RSA-PSS'` + * - `'RSA-OAEP'` + * - `'ECDSA'` + * - `'Ed25519'` + * - `'Ed448'` + * - `'ECDH'` + * - `'X25519'` + * - `'X448'` + * - `'HMAC'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * - `'AES-KW'` + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. + * @since v15.0.0 + */ + unwrapKey( + format: KeyFormat, + wrappedKey: BufferSource, + unwrappingKey: CryptoKey, + unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + unwrappedKeyAlgorithm: + | AlgorithmIdentifier + | RsaHashedImportParams + | EcKeyImportParams + | HmacImportParams + | AesKeyAlgorithm, + extractable: boolean, + keyUsages: KeyUsage[], + ): Promise; + /** + * Using the method and parameters given in `algorithm` and the keying material provided by `key`, + * `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`. + * The returned promise is resolved with either `true` or `false`. + * + * The algorithms currently supported include: + * + * - `'RSASSA-PKCS1-v1_5'` + * - `'RSA-PSS'` + * - `'ECDSA'` + * - `'Ed25519'` + * - `'Ed448'` + * - `'HMAC'` + * @since v15.0.0 + */ + verify( + algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, + key: CryptoKey, + signature: BufferSource, + data: BufferSource, + ): Promise; + /** + * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. + * The `subtle.wrapKey()` method exports the keying material into the format identified by `format`, + * then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`. + * It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments, + * then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs. + * If successful, the returned promise will be resolved with an `` containing the encrypted key data. + * + * The wrapping algorithms currently supported include: + * + * - `'RSA-OAEP'` + * - `'AES-CTR'` + * - `'AES-CBC'` + * - `'AES-GCM'` + * - `'AES-KW'` + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @since v15.0.0 + */ + wrapKey( + format: KeyFormat, + key: CryptoKey, + wrappingKey: CryptoKey, + wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + ): Promise; + } + } +} +declare module "node:crypto" { + export * from "crypto"; +} diff --git a/node_modules/@types/node/ts4.8/dgram.d.ts b/node_modules/@types/node/ts4.8/dgram.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..692e547fc65fe1f7f7e8dff1e65d3eb151de230c --- /dev/null +++ b/node_modules/@types/node/ts4.8/dgram.d.ts @@ -0,0 +1,586 @@ +/** + * The `node:dgram` module provides an implementation of UDP datagram sockets. + * + * ```js + * import dgram from 'node:dgram'; + * + * const server = dgram.createSocket('udp4'); + * + * server.on('error', (err) => { + * console.error(`server error:\n${err.stack}`); + * server.close(); + * }); + * + * server.on('message', (msg, rinfo) => { + * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`); + * }); + * + * server.on('listening', () => { + * const address = server.address(); + * console.log(`server listening ${address.address}:${address.port}`); + * }); + * + * server.bind(41234); + * // Prints: server listening 0.0.0.0:41234 + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dgram.js) + */ +declare module "dgram" { + import { AddressInfo } from "node:net"; + import * as dns from "node:dns"; + import { Abortable, EventEmitter } from "node:events"; + interface RemoteInfo { + address: string; + family: "IPv4" | "IPv6"; + port: number; + size: number; + } + interface BindOptions { + port?: number | undefined; + address?: string | undefined; + exclusive?: boolean | undefined; + fd?: number | undefined; + } + type SocketType = "udp4" | "udp6"; + interface SocketOptions extends Abortable { + type: SocketType; + reuseAddr?: boolean | undefined; + /** + * @default false + */ + ipv6Only?: boolean | undefined; + recvBufferSize?: number | undefined; + sendBufferSize?: number | undefined; + lookup?: + | (( + hostname: string, + options: dns.LookupOneOptions, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ) => void) + | undefined; + } + /** + * Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram + * messages. When `address` and `port` are not passed to `socket.bind()` the + * method will bind the socket to the "all interfaces" address on a random port + * (it does the right thing for both `udp4` and `udp6` sockets). The bound address + * and port can be retrieved using `socket.address().address` and `socket.address().port`. + * + * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.close()` on the socket: + * + * ```js + * const controller = new AbortController(); + * const { signal } = controller; + * const server = dgram.createSocket({ type: 'udp4', signal }); + * server.on('message', (msg, rinfo) => { + * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`); + * }); + * // Later, when you want to close the server. + * controller.abort(); + * ``` + * @since v0.11.13 + * @param options Available options are: + * @param callback Attached as a listener for `'message'` events. Optional. + */ + function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + /** + * Encapsulates the datagram functionality. + * + * New instances of `dgram.Socket` are created using {@link createSocket}. + * The `new` keyword is not to be used to create `dgram.Socket` instances. + * @since v0.1.99 + */ + class Socket extends EventEmitter { + /** + * Tells the kernel to join a multicast group at the given `multicastAddress` and`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the`multicastInterface` argument is not + * specified, the operating system will choose + * one interface and will add membership to it. To add membership to every + * available interface, call `addMembership` multiple times, once per interface. + * + * When called on an unbound socket, this method will implicitly bind to a random + * port, listening on all interfaces. + * + * When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur: + * + * ```js + * import cluster from 'node:cluster'; + * import dgram from 'node:dgram'; + * + * if (cluster.isPrimary) { + * cluster.fork(); // Works ok. + * cluster.fork(); // Fails with EADDRINUSE. + * } else { + * const s = dgram.createSocket('udp4'); + * s.bind(1234, () => { + * s.addMembership('224.0.0.114'); + * }); + * } + * ``` + * @since v0.6.9 + */ + addMembership(multicastAddress: string, multicastInterface?: string): void; + /** + * Returns an object containing the address information for a socket. + * For UDP sockets, this object will contain `address`, `family`, and `port`properties. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.1.99 + */ + address(): AddressInfo; + /** + * For UDP sockets, causes the `dgram.Socket` to listen for datagram + * messages on a named `port` and optional `address`. If `port` is not + * specified or is `0`, the operating system will attempt to bind to a + * random port. If `address` is not specified, the operating system will + * attempt to listen on all addresses. Once binding is complete, a`'listening'` event is emitted and the optional `callback` function is + * called. + * + * Specifying both a `'listening'` event listener and passing a`callback` to the `socket.bind()` method is not harmful but not very + * useful. + * + * A bound datagram socket keeps the Node.js process running to receive + * datagram messages. + * + * If binding fails, an `'error'` event is generated. In rare case (e.g. + * attempting to bind with a closed socket), an `Error` may be thrown. + * + * Example of a UDP server listening on port 41234: + * + * ```js + * import dgram from 'node:dgram'; + * + * const server = dgram.createSocket('udp4'); + * + * server.on('error', (err) => { + * console.error(`server error:\n${err.stack}`); + * server.close(); + * }); + * + * server.on('message', (msg, rinfo) => { + * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`); + * }); + * + * server.on('listening', () => { + * const address = server.address(); + * console.log(`server listening ${address.address}:${address.port}`); + * }); + * + * server.bind(41234); + * // Prints: server listening 0.0.0.0:41234 + * ``` + * @since v0.1.99 + * @param callback with no parameters. Called when binding is complete. + */ + bind(port?: number, address?: string, callback?: () => void): this; + bind(port?: number, callback?: () => void): this; + bind(callback?: () => void): this; + bind(options: BindOptions, callback?: () => void): this; + /** + * Close the underlying socket and stop listening for data on it. If a callback is + * provided, it is added as a listener for the `'close'` event. + * @since v0.1.99 + * @param callback Called when the socket has been closed. + */ + close(callback?: () => void): this; + /** + * Associates the `dgram.Socket` to a remote address and port. Every + * message sent by this handle is automatically sent to that destination. Also, + * the socket will only receive messages from that remote peer. + * Trying to call `connect()` on an already connected socket will result + * in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not + * provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets) + * will be used by default. Once the connection is complete, a `'connect'` event + * is emitted and the optional `callback` function is called. In case of failure, + * the `callback` is called or, failing this, an `'error'` event is emitted. + * @since v12.0.0 + * @param callback Called when the connection is completed or on error. + */ + connect(port: number, address?: string, callback?: () => void): void; + connect(port: number, callback: () => void): void; + /** + * A synchronous function that disassociates a connected `dgram.Socket` from + * its remote address. Trying to call `disconnect()` on an unbound or already + * disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception. + * @since v12.0.0 + */ + disconnect(): void; + /** + * Instructs the kernel to leave a multicast group at `multicastAddress` using the`IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the + * kernel when the socket is closed or the process terminates, so most apps will + * never have reason to call this. + * + * If `multicastInterface` is not specified, the operating system will attempt to + * drop membership on all valid interfaces. + * @since v0.6.9 + */ + dropMembership(multicastAddress: string, multicastInterface?: string): void; + /** + * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket. + * @since v8.7.0 + * @return the `SO_RCVBUF` socket receive buffer size in bytes. + */ + getRecvBufferSize(): number; + /** + * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket. + * @since v8.7.0 + * @return the `SO_SNDBUF` socket send buffer size in bytes. + */ + getSendBufferSize(): number; + /** + * By default, binding a socket will cause it to block the Node.js process from + * exiting as long as the socket is open. The `socket.unref()` method can be used + * to exclude the socket from the reference counting that keeps the Node.js + * process active. The `socket.ref()` method adds the socket back to the reference + * counting and restores the default behavior. + * + * Calling `socket.ref()` multiples times will have no additional effect. + * + * The `socket.ref()` method returns a reference to the socket so calls can be + * chained. + * @since v0.9.1 + */ + ref(): this; + /** + * Returns an object containing the `address`, `family`, and `port` of the remote + * endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception + * if the socket is not connected. + * @since v12.0.0 + */ + remoteAddress(): AddressInfo; + /** + * Broadcasts a datagram on the socket. + * For connectionless sockets, the destination `port` and `address` must be + * specified. Connected sockets, on the other hand, will use their associated + * remote endpoint, so the `port` and `address` arguments must not be set. + * + * The `msg` argument contains the message to be sent. + * Depending on its type, different behavior can apply. If `msg` is a `Buffer`, + * any `TypedArray` or a `DataView`, + * the `offset` and `length` specify the offset within the `Buffer` where the + * message begins and the number of bytes in the message, respectively. + * If `msg` is a `String`, then it is automatically converted to a `Buffer`with `'utf8'` encoding. With messages that + * contain multi-byte characters, `offset` and `length` will be calculated with + * respect to `byte length` and not the character position. + * If `msg` is an array, `offset` and `length` must not be specified. + * + * The `address` argument is a string. If the value of `address` is a host name, + * DNS will be used to resolve the address of the host. If `address` is not + * provided or otherwise nullish, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default. + * + * If the socket has not been previously bound with a call to `bind`, the socket + * is assigned a random port number and is bound to the "all interfaces" address + * (`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.) + * + * An optional `callback` function may be specified to as a way of reporting + * DNS errors or for determining when it is safe to reuse the `buf` object. + * DNS lookups delay the time to send for at least one tick of the + * Node.js event loop. + * + * The only way to know for sure that the datagram has been sent is by using a`callback`. If an error occurs and a `callback` is given, the error will be + * passed as the first argument to the `callback`. If a `callback` is not given, + * the error is emitted as an `'error'` event on the `socket` object. + * + * Offset and length are optional but both _must_ be set if either are used. + * They are supported only when the first argument is a `Buffer`, a `TypedArray`, + * or a `DataView`. + * + * This method throws `ERR_SOCKET_BAD_PORT` if called on an unbound socket. + * + * Example of sending a UDP packet to a port on `localhost`; + * + * ```js + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; + * + * const message = Buffer.from('Some bytes'); + * const client = dgram.createSocket('udp4'); + * client.send(message, 41234, 'localhost', (err) => { + * client.close(); + * }); + * ``` + * + * Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`; + * + * ```js + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; + * + * const buf1 = Buffer.from('Some '); + * const buf2 = Buffer.from('bytes'); + * const client = dgram.createSocket('udp4'); + * client.send([buf1, buf2], 41234, (err) => { + * client.close(); + * }); + * ``` + * + * Sending multiple buffers might be faster or slower depending on the + * application and operating system. Run benchmarks to + * determine the optimal strategy on a case-by-case basis. Generally speaking, + * however, sending multiple buffers is faster. + * + * Example of sending a UDP packet using a socket connected to a port on`localhost`: + * + * ```js + * import dgram from 'node:dgram'; + * import { Buffer } from 'node:buffer'; + * + * const message = Buffer.from('Some bytes'); + * const client = dgram.createSocket('udp4'); + * client.connect(41234, 'localhost', (err) => { + * client.send(message, (err) => { + * client.close(); + * }); + * }); + * ``` + * @since v0.1.99 + * @param msg Message to be sent. + * @param offset Offset in the buffer where the message starts. + * @param length Number of bytes in the message. + * @param port Destination port. + * @param address Destination host name or IP address. + * @param callback Called when the message has been sent. + */ + send( + msg: string | Uint8Array | readonly any[], + port?: number, + address?: string, + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array | readonly any[], + port?: number, + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array | readonly any[], + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array, + offset: number, + length: number, + port?: number, + address?: string, + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array, + offset: number, + length: number, + port?: number, + callback?: (error: Error | null, bytes: number) => void, + ): void; + send( + msg: string | Uint8Array, + offset: number, + length: number, + callback?: (error: Error | null, bytes: number) => void, + ): void; + /** + * Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP + * packets may be sent to a local interface's broadcast address. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.6.9 + */ + setBroadcast(flag: boolean): void; + /** + * _All references to scope in this section are referring to [IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC + * 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_ + * _with a scope index is written as `'IP%scope'` where scope is an interface name_ + * _or interface number._ + * + * Sets the default outgoing multicast interface of the socket to a chosen + * interface or back to system interface selection. The `multicastInterface` must + * be a valid string representation of an IP from the socket's family. + * + * For IPv4 sockets, this should be the IP configured for the desired physical + * interface. All packets sent to multicast on the socket will be sent on the + * interface determined by the most recent successful use of this call. + * + * For IPv6 sockets, `multicastInterface` should include a scope to indicate the + * interface as in the examples that follow. In IPv6, individual `send` calls can + * also use explicit scope in addresses, so only packets sent to a multicast + * address without specifying an explicit scope are affected by the most recent + * successful use of this call. + * + * This method throws `EBADF` if called on an unbound socket. + * + * #### Example: IPv6 outgoing multicast interface + * + * On most systems, where scope format uses the interface name: + * + * ```js + * const socket = dgram.createSocket('udp6'); + * + * socket.bind(1234, () => { + * socket.setMulticastInterface('::%eth1'); + * }); + * ``` + * + * On Windows, where scope format uses an interface number: + * + * ```js + * const socket = dgram.createSocket('udp6'); + * + * socket.bind(1234, () => { + * socket.setMulticastInterface('::%2'); + * }); + * ``` + * + * #### Example: IPv4 outgoing multicast interface + * + * All systems use an IP of the host on the desired physical interface: + * + * ```js + * const socket = dgram.createSocket('udp4'); + * + * socket.bind(1234, () => { + * socket.setMulticastInterface('10.0.0.2'); + * }); + * ``` + * @since v8.6.0 + */ + setMulticastInterface(multicastInterface: string): void; + /** + * Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`, + * multicast packets will also be received on the local interface. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.3.8 + */ + setMulticastLoopback(flag: boolean): boolean; + /** + * Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for + * "Time to Live", in this context it specifies the number of IP hops that a + * packet is allowed to travel through, specifically for multicast traffic. Each + * router or gateway that forwards a packet decrements the TTL. If the TTL is + * decremented to 0 by a router, it will not be forwarded. + * + * The `ttl` argument may be between 0 and 255\. The default on most systems is `1`. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.3.8 + */ + setMulticastTTL(ttl: number): number; + /** + * Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer + * in bytes. + * + * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket. + * @since v8.7.0 + */ + setRecvBufferSize(size: number): void; + /** + * Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer + * in bytes. + * + * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket. + * @since v8.7.0 + */ + setSendBufferSize(size: number): void; + /** + * Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live", + * in this context it specifies the number of IP hops that a packet is allowed to + * travel through. Each router or gateway that forwards a packet decrements the + * TTL. If the TTL is decremented to 0 by a router, it will not be forwarded. + * Changing TTL values is typically done for network probes or when multicasting. + * + * The `ttl` argument may be between 1 and 255\. The default on most systems + * is 64. + * + * This method throws `EBADF` if called on an unbound socket. + * @since v0.1.101 + */ + setTTL(ttl: number): number; + /** + * By default, binding a socket will cause it to block the Node.js process from + * exiting as long as the socket is open. The `socket.unref()` method can be used + * to exclude the socket from the reference counting that keeps the Node.js + * process active, allowing the process to exit even if the socket is still + * listening. + * + * Calling `socket.unref()` multiple times will have no additional effect. + * + * The `socket.unref()` method returns a reference to the socket so calls can be + * chained. + * @since v0.9.1 + */ + unref(): this; + /** + * Tells the kernel to join a source-specific multicast channel at the given`sourceAddress` and `groupAddress`, using the `multicastInterface` with the`IP_ADD_SOURCE_MEMBERSHIP` socket + * option. If the `multicastInterface` argument + * is not specified, the operating system will choose one interface and will add + * membership to it. To add membership to every available interface, call`socket.addSourceSpecificMembership()` multiple times, once per interface. + * + * When called on an unbound socket, this method will implicitly bind to a random + * port, listening on all interfaces. + * @since v13.1.0, v12.16.0 + */ + addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void; + /** + * Instructs the kernel to leave a source-specific multicast channel at the given`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP`socket option. This method is + * automatically called by the kernel when the + * socket is closed or the process terminates, so most apps will never have + * reason to call this. + * + * If `multicastInterface` is not specified, the operating system will attempt to + * drop membership on all valid interfaces. + * @since v13.1.0, v12.16.0 + */ + dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void; + /** + * events.EventEmitter + * 1. close + * 2. connect + * 3. error + * 4. listening + * 5. message + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connect", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "connect"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connect", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connect", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connect", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connect", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this; + /** + * Calls `socket.close()` and returns a promise that fulfills when the socket has closed. + * @since v20.5.0 + */ + [Symbol.asyncDispose](): Promise; + } +} +declare module "node:dgram" { + export * from "dgram"; +} diff --git a/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts b/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b02f591787907ad3ba942f1e250d53f2000d4a89 --- /dev/null +++ b/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts @@ -0,0 +1,191 @@ +/** + * The `node:diagnostics_channel` module provides an API to create named channels + * to report arbitrary message data for diagnostics purposes. + * + * It can be accessed using: + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * ``` + * + * It is intended that a module writer wanting to report diagnostics messages + * will create one or many top-level channels to report messages through. + * Channels may also be acquired at runtime but it is not encouraged + * due to the additional overhead of doing so. Channels may be exported for + * convenience, but as long as the name is known it can be acquired anywhere. + * + * If you intend for your module to produce diagnostics data for others to + * consume it is recommended that you include documentation of what named + * channels are used along with the shape of the message data. Channel names + * should generally include the module name to avoid collisions with data from + * other modules. + * @since v15.1.0, v14.17.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/diagnostics_channel.js) + */ +declare module "diagnostics_channel" { + /** + * Check if there are active subscribers to the named channel. This is helpful if + * the message you want to send might be expensive to prepare. + * + * This API is optional but helpful when trying to publish messages from very + * performance-sensitive code. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * if (diagnostics_channel.hasSubscribers('my-channel')) { + * // There are subscribers, prepare and publish message + * } + * ``` + * @since v15.1.0, v14.17.0 + * @param name The channel name + * @return If there are active subscribers + */ + function hasSubscribers(name: string | symbol): boolean; + /** + * This is the primary entry-point for anyone wanting to publish to a named + * channel. It produces a channel object which is optimized to reduce overhead at + * publish time as much as possible. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * ``` + * @since v15.1.0, v14.17.0 + * @param name The channel name + * @return The named channel object + */ + function channel(name: string | symbol): Channel; + type ChannelListener = (message: unknown, name: string | symbol) => void; + /** + * Register a message handler to subscribe to this channel. This message handler + * will be run synchronously whenever a message is published to the channel. Any + * errors thrown in the message handler will trigger an `'uncaughtException'`. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * diagnostics_channel.subscribe('my-channel', (message, name) => { + * // Received data + * }); + * ``` + * @since v18.7.0, v16.17.0 + * @param name The channel name + * @param onMessage The handler to receive channel messages + */ + function subscribe(name: string | symbol, onMessage: ChannelListener): void; + /** + * Remove a message handler previously registered to this channel with {@link subscribe}. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * function onMessage(message, name) { + * // Received data + * } + * + * diagnostics_channel.subscribe('my-channel', onMessage); + * + * diagnostics_channel.unsubscribe('my-channel', onMessage); + * ``` + * @since v18.7.0, v16.17.0 + * @param name The channel name + * @param onMessage The previous subscribed handler to remove + * @return `true` if the handler was found, `false` otherwise. + */ + function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean; + /** + * The class `Channel` represents an individual named channel within the data + * pipeline. It is used to track subscribers and to publish messages when there + * are subscribers present. It exists as a separate object to avoid channel + * lookups at publish time, enabling very fast publish speeds and allowing + * for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly + * with `new Channel(name)` is not supported. + * @since v15.1.0, v14.17.0 + */ + class Channel { + readonly name: string | symbol; + /** + * Check if there are active subscribers to this channel. This is helpful if + * the message you want to send might be expensive to prepare. + * + * This API is optional but helpful when trying to publish messages from very + * performance-sensitive code. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * + * if (channel.hasSubscribers) { + * // There are subscribers, prepare and publish message + * } + * ``` + * @since v15.1.0, v14.17.0 + */ + readonly hasSubscribers: boolean; + private constructor(name: string | symbol); + /** + * Publish a message to any subscribers to the channel. This will trigger + * message handlers synchronously so they will execute within the same context. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * + * channel.publish({ + * some: 'message', + * }); + * ``` + * @since v15.1.0, v14.17.0 + * @param message The message to send to the channel subscribers + */ + publish(message: unknown): void; + /** + * Register a message handler to subscribe to this channel. This message handler + * will be run synchronously whenever a message is published to the channel. Any + * errors thrown in the message handler will trigger an `'uncaughtException'`. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * + * channel.subscribe((message, name) => { + * // Received data + * }); + * ``` + * @since v15.1.0, v14.17.0 + * @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)} + * @param onMessage The handler to receive channel messages + */ + subscribe(onMessage: ChannelListener): void; + /** + * Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`. + * + * ```js + * import diagnostics_channel from 'node:diagnostics_channel'; + * + * const channel = diagnostics_channel.channel('my-channel'); + * + * function onMessage(message, name) { + * // Received data + * } + * + * channel.subscribe(onMessage); + * + * channel.unsubscribe(onMessage); + * ``` + * @since v15.1.0, v14.17.0 + * @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)} + * @param onMessage The previous subscribed handler to remove + * @return `true` if the handler was found, `false` otherwise. + */ + unsubscribe(onMessage: ChannelListener): void; + } +} +declare module "node:diagnostics_channel" { + export * from "diagnostics_channel"; +} diff --git a/node_modules/@types/node/ts4.8/dns.d.ts b/node_modules/@types/node/ts4.8/dns.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..380cf7d7015e33c3fd5d2d1ff8c3f43c5f35a92d --- /dev/null +++ b/node_modules/@types/node/ts4.8/dns.d.ts @@ -0,0 +1,809 @@ +/** + * The `node:dns` module enables name resolution. For example, use it to look up IP + * addresses of host names. + * + * Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the + * DNS protocol for lookups. {@link lookup} uses the operating system + * facilities to perform name resolution. It may not need to perform any network + * communication. To perform name resolution the way other applications on the same + * system do, use {@link lookup}. + * + * ```js + * const dns = require('node:dns'); + * + * dns.lookup('example.org', (err, address, family) => { + * console.log('address: %j family: IPv%s', address, family); + * }); + * // address: "93.184.216.34" family: IPv4 + * ``` + * + * All other functions in the `node:dns` module connect to an actual DNS server to + * perform name resolution. They will always use the network to perform DNS + * queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform + * DNS queries, bypassing other name-resolution facilities. + * + * ```js + * const dns = require('node:dns'); + * + * dns.resolve4('archive.org', (err, addresses) => { + * if (err) throw err; + * + * console.log(`addresses: ${JSON.stringify(addresses)}`); + * + * addresses.forEach((a) => { + * dns.reverse(a, (err, hostnames) => { + * if (err) { + * throw err; + * } + * console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`); + * }); + * }); + * }); + * ``` + * + * See the `Implementation considerations section` for more information. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dns.js) + */ +declare module "dns" { + import * as dnsPromises from "node:dns/promises"; + // Supported getaddrinfo flags. + export const ADDRCONFIG: number; + export const V4MAPPED: number; + /** + * If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as + * well as IPv4 mapped IPv6 addresses. + */ + export const ALL: number; + export interface LookupOptions { + family?: number | undefined; + hints?: number | undefined; + all?: boolean | undefined; + /** + * @default true + */ + verbatim?: boolean | undefined; + } + export interface LookupOneOptions extends LookupOptions { + all?: false | undefined; + } + export interface LookupAllOptions extends LookupOptions { + all: true; + } + export interface LookupAddress { + address: string; + family: number; + } + /** + * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or + * AAAA (IPv6) record. All `option` properties are optional. If `options` is an + * integer, then it must be `4` or `6` – if `options` is `0` or not provided, then + * IPv4 and IPv6 addresses are both returned if found. + * + * With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the + * properties `address` and `family`. + * + * On error, `err` is an `Error` object, where `err.code` is the error code. + * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when + * the host name does not exist but also when the lookup fails in other ways + * such as no available file descriptors. + * + * `dns.lookup()` does not necessarily have anything to do with the DNS protocol. + * The implementation uses an operating system facility that can associate names + * with addresses and vice versa. This implementation can have subtle but + * important consequences on the behavior of any Node.js program. Please take some + * time to consult the `Implementation considerations section` before using`dns.lookup()`. + * + * Example usage: + * + * ```js + * const dns = require('node:dns'); + * const options = { + * family: 6, + * hints: dns.ADDRCONFIG | dns.V4MAPPED, + * }; + * dns.lookup('example.com', options, (err, address, family) => + * console.log('address: %j family: IPv%s', address, family)); + * // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6 + * + * // When options.all is true, the result will be an Array. + * options.all = true; + * dns.lookup('example.com', options, (err, addresses) => + * console.log('addresses: %j', addresses)); + * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}] + * ``` + * + * If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties. + * @since v0.1.90 + */ + export function lookup( + hostname: string, + family: number, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void; + export function lookup( + hostname: string, + options: LookupOneOptions, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void; + export function lookup( + hostname: string, + options: LookupAllOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void, + ): void; + export function lookup( + hostname: string, + options: LookupOptions, + callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void, + ): void; + export function lookup( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void, + ): void; + export namespace lookup { + function __promisify__(hostname: string, options: LookupAllOptions): Promise; + function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise; + function __promisify__(hostname: string, options: LookupOptions): Promise; + } + /** + * Resolves the given `address` and `port` into a host name and service using + * the operating system's underlying `getnameinfo` implementation. + * + * If `address` is not a valid IP address, a `TypeError` will be thrown. + * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown. + * + * On an error, `err` is an `Error` object, where `err.code` is the error code. + * + * ```js + * const dns = require('node:dns'); + * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { + * console.log(hostname, service); + * // Prints: localhost ssh + * }); + * ``` + * + * If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties. + * @since v0.11.14 + */ + export function lookupService( + address: string, + port: number, + callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void, + ): void; + export namespace lookupService { + function __promisify__( + address: string, + port: number, + ): Promise<{ + hostname: string; + service: string; + }>; + } + export interface ResolveOptions { + ttl: boolean; + } + export interface ResolveWithTtlOptions extends ResolveOptions { + ttl: true; + } + export interface RecordWithTtl { + address: string; + ttl: number; + } + /** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */ + export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord; + export interface AnyARecord extends RecordWithTtl { + type: "A"; + } + export interface AnyAaaaRecord extends RecordWithTtl { + type: "AAAA"; + } + export interface CaaRecord { + critical: number; + issue?: string | undefined; + issuewild?: string | undefined; + iodef?: string | undefined; + contactemail?: string | undefined; + contactphone?: string | undefined; + } + export interface MxRecord { + priority: number; + exchange: string; + } + export interface AnyMxRecord extends MxRecord { + type: "MX"; + } + export interface NaptrRecord { + flags: string; + service: string; + regexp: string; + replacement: string; + order: number; + preference: number; + } + export interface AnyNaptrRecord extends NaptrRecord { + type: "NAPTR"; + } + export interface SoaRecord { + nsname: string; + hostmaster: string; + serial: number; + refresh: number; + retry: number; + expire: number; + minttl: number; + } + export interface AnySoaRecord extends SoaRecord { + type: "SOA"; + } + export interface SrvRecord { + priority: number; + weight: number; + port: number; + name: string; + } + export interface AnySrvRecord extends SrvRecord { + type: "SRV"; + } + export interface AnyTxtRecord { + type: "TXT"; + entries: string[]; + } + export interface AnyNsRecord { + type: "NS"; + value: string; + } + export interface AnyPtrRecord { + type: "PTR"; + value: string; + } + export interface AnyCnameRecord { + type: "CNAME"; + value: string; + } + export type AnyRecord = + | AnyARecord + | AnyAaaaRecord + | AnyCnameRecord + | AnyMxRecord + | AnyNaptrRecord + | AnyNsRecord + | AnyPtrRecord + | AnySoaRecord + | AnySrvRecord + | AnyTxtRecord; + /** + * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array + * of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource + * records. The type and structure of individual results varies based on `rrtype`: + * + * + * + * On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`. + * @since v0.1.27 + * @param hostname Host name to resolve. + * @param [rrtype='A'] Resource record type. + */ + export function resolve( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "A", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "AAAA", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "ANY", + callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "CNAME", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "MX", + callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "NAPTR", + callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "NS", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "PTR", + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "SOA", + callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "SRV", + callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: "TXT", + callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void, + ): void; + export function resolve( + hostname: string, + rrtype: string, + callback: ( + err: NodeJS.ErrnoException | null, + addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[], + ) => void, + ): void; + export namespace resolve { + function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise; + function __promisify__(hostname: string, rrtype: "ANY"): Promise; + function __promisify__(hostname: string, rrtype: "MX"): Promise; + function __promisify__(hostname: string, rrtype: "NAPTR"): Promise; + function __promisify__(hostname: string, rrtype: "SOA"): Promise; + function __promisify__(hostname: string, rrtype: "SRV"): Promise; + function __promisify__(hostname: string, rrtype: "TXT"): Promise; + function __promisify__( + hostname: string, + rrtype: string, + ): Promise; + } + /** + * Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function + * will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`). + * @since v0.1.16 + * @param hostname Host name to resolve. + */ + export function resolve4( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve4( + hostname: string, + options: ResolveWithTtlOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void, + ): void; + export function resolve4( + hostname: string, + options: ResolveOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void, + ): void; + export namespace resolve4 { + function __promisify__(hostname: string): Promise; + function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise; + function __promisify__(hostname: string, options?: ResolveOptions): Promise; + } + /** + * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function + * will contain an array of IPv6 addresses. + * @since v0.1.16 + * @param hostname Host name to resolve. + */ + export function resolve6( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export function resolve6( + hostname: string, + options: ResolveWithTtlOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void, + ): void; + export function resolve6( + hostname: string, + options: ResolveOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void, + ): void; + export namespace resolve6 { + function __promisify__(hostname: string): Promise; + function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise; + function __promisify__(hostname: string, options?: ResolveOptions): Promise; + } + /** + * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function + * will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`). + * @since v0.3.2 + */ + export function resolveCname( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export namespace resolveCname { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function + * will contain an array of certification authority authorization records + * available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`). + * @since v15.0.0, v14.17.0 + */ + export function resolveCaa( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void, + ): void; + export namespace resolveCaa { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will + * contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`). + * @since v0.1.27 + */ + export function resolveMx( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void, + ): void; + export namespace resolveMx { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of + * objects with the following properties: + * + * * `flags` + * * `service` + * * `regexp` + * * `replacement` + * * `order` + * * `preference` + * + * ```js + * { + * flags: 's', + * service: 'SIP+D2U', + * regexp: '', + * replacement: '_sip._udp.example.com', + * order: 30, + * preference: 100 + * } + * ``` + * @since v0.9.12 + */ + export function resolveNaptr( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void, + ): void; + export namespace resolveNaptr { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will + * contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`). + * @since v0.1.90 + */ + export function resolveNs( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export namespace resolveNs { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will + * be an array of strings containing the reply records. + * @since v6.0.0 + */ + export function resolvePtr( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void, + ): void; + export namespace resolvePtr { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for + * the `hostname`. The `address` argument passed to the `callback` function will + * be an object with the following properties: + * + * * `nsname` + * * `hostmaster` + * * `serial` + * * `refresh` + * * `retry` + * * `expire` + * * `minttl` + * + * ```js + * { + * nsname: 'ns.example.com', + * hostmaster: 'root.example.com', + * serial: 2013101809, + * refresh: 10000, + * retry: 2400, + * expire: 604800, + * minttl: 3600 + * } + * ``` + * @since v0.11.10 + */ + export function resolveSoa( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void, + ): void; + export namespace resolveSoa { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will + * be an array of objects with the following properties: + * + * * `priority` + * * `weight` + * * `port` + * * `name` + * + * ```js + * { + * priority: 10, + * weight: 5, + * port: 21223, + * name: 'service.example.com' + * } + * ``` + * @since v0.1.27 + */ + export function resolveSrv( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void, + ): void; + export namespace resolveSrv { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a + * two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of + * one record. Depending on the use case, these could be either joined together or + * treated separately. + * @since v0.1.27 + */ + export function resolveTxt( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void, + ): void; + export namespace resolveTxt { + function __promisify__(hostname: string): Promise; + } + /** + * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query). + * The `ret` argument passed to the `callback` function will be an array containing + * various types of records. Each object has a property `type` that indicates the + * type of the current record. And depending on the `type`, additional properties + * will be present on the object: + * + * + * + * Here is an example of the `ret` object passed to the callback: + * + * ```js + * [ { type: 'A', address: '127.0.0.1', ttl: 299 }, + * { type: 'CNAME', value: 'example.com' }, + * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 }, + * { type: 'NS', value: 'ns1.example.com' }, + * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] }, + * { type: 'SOA', + * nsname: 'ns1.example.com', + * hostmaster: 'admin.example.com', + * serial: 156696742, + * refresh: 900, + * retry: 900, + * expire: 1800, + * minttl: 60 } ] + * ``` + * + * DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC + * 8482](https://tools.ietf.org/html/rfc8482). + */ + export function resolveAny( + hostname: string, + callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void, + ): void; + export namespace resolveAny { + function __promisify__(hostname: string): Promise; + } + /** + * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an + * array of host names. + * + * On error, `err` is an `Error` object, where `err.code` is + * one of the `DNS error codes`. + * @since v0.1.16 + */ + export function reverse( + ip: string, + callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void, + ): void; + /** + * Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: for `verbatim` defaulting to `false`. + * * `verbatim`: for `verbatim` defaulting to `true`. + * @since v20.1.0 + */ + export function getDefaultResultOrder(): "ipv4first" | "verbatim"; + /** + * Sets the IP address and port of servers to be used when performing DNS + * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted + * addresses. If the port is the IANA default DNS port (53) it can be omitted. + * + * ```js + * dns.setServers([ + * '4.4.4.4', + * '[2001:4860:4860::8888]', + * '4.4.4.4:1053', + * '[2001:4860:4860::8888]:1053', + * ]); + * ``` + * + * An error will be thrown if an invalid address is provided. + * + * The `dns.setServers()` method must not be called while a DNS query is in + * progress. + * + * The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}). + * + * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html). + * That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with + * subsequent servers provided. Fallback DNS servers will only be used if the + * earlier ones time out or result in some other error. + * @since v0.11.3 + * @param servers array of `RFC 5952` formatted addresses + */ + export function setServers(servers: readonly string[]): void; + /** + * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6), + * that are currently configured for DNS resolution. A string will include a port + * section if a custom port is used. + * + * ```js + * [ + * '4.4.4.4', + * '2001:4860:4860::8888', + * '4.4.4.4:1053', + * '[2001:4860:4860::8888]:1053', + * ] + * ``` + * @since v0.11.3 + */ + export function getServers(): string[]; + /** + * Set the default value of `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: sets default `verbatim` `false`. + * * `verbatim`: sets default `verbatim` `true`. + * + * The default is `verbatim` and {@link setDefaultResultOrder} have higher + * priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default + * dns orders in workers. + * @since v16.4.0, v14.18.0 + * @param order must be `'ipv4first'` or `'verbatim'`. + */ + export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void; + // Error codes + export const NODATA: string; + export const FORMERR: string; + export const SERVFAIL: string; + export const NOTFOUND: string; + export const NOTIMP: string; + export const REFUSED: string; + export const BADQUERY: string; + export const BADNAME: string; + export const BADFAMILY: string; + export const BADRESP: string; + export const CONNREFUSED: string; + export const TIMEOUT: string; + export const EOF: string; + export const FILE: string; + export const NOMEM: string; + export const DESTRUCTION: string; + export const BADSTR: string; + export const BADFLAGS: string; + export const NONAME: string; + export const BADHINTS: string; + export const NOTINITIALIZED: string; + export const LOADIPHLPAPI: string; + export const ADDRGETNETWORKPARAMS: string; + export const CANCELLED: string; + export interface ResolverOptions { + timeout?: number | undefined; + /** + * @default 4 + */ + tries?: number; + } + /** + * An independent resolver for DNS requests. + * + * Creating a new resolver uses the default server settings. Setting + * the servers used for a resolver using `resolver.setServers()` does not affect + * other resolvers: + * + * ```js + * const { Resolver } = require('node:dns'); + * const resolver = new Resolver(); + * resolver.setServers(['4.4.4.4']); + * + * // This request will use the server at 4.4.4.4, independent of global settings. + * resolver.resolve4('example.org', (err, addresses) => { + * // ... + * }); + * ``` + * + * The following methods from the `node:dns` module are available: + * + * * `resolver.getServers()` + * * `resolver.resolve()` + * * `resolver.resolve4()` + * * `resolver.resolve6()` + * * `resolver.resolveAny()` + * * `resolver.resolveCaa()` + * * `resolver.resolveCname()` + * * `resolver.resolveMx()` + * * `resolver.resolveNaptr()` + * * `resolver.resolveNs()` + * * `resolver.resolvePtr()` + * * `resolver.resolveSoa()` + * * `resolver.resolveSrv()` + * * `resolver.resolveTxt()` + * * `resolver.reverse()` + * * `resolver.setServers()` + * @since v8.3.0 + */ + export class Resolver { + constructor(options?: ResolverOptions); + /** + * Cancel all outstanding DNS queries made by this resolver. The corresponding + * callbacks will be called with an error with code `ECANCELLED`. + * @since v8.3.0 + */ + cancel(): void; + getServers: typeof getServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCaa: typeof resolveCaa; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + /** + * The resolver instance will send its requests from the specified IP address. + * This allows programs to specify outbound interfaces when used on multi-homed + * systems. + * + * If a v4 or v6 address is not specified, it is set to the default and the + * operating system will choose a local address automatically. + * + * The resolver will use the v4 local address when making requests to IPv4 DNS + * servers, and the v6 local address when making requests to IPv6 DNS servers. + * The `rrtype` of resolution requests has no impact on the local address used. + * @since v15.1.0, v14.17.0 + * @param [ipv4='0.0.0.0'] A string representation of an IPv4 address. + * @param [ipv6='::0'] A string representation of an IPv6 address. + */ + setLocalAddress(ipv4?: string, ipv6?: string): void; + setServers: typeof setServers; + } + export { dnsPromises as promises }; +} +declare module "node:dns" { + export * from "dns"; +} diff --git a/node_modules/@types/node/ts4.8/dns/promises.d.ts b/node_modules/@types/node/ts4.8/dns/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef9b2228123c3a483363e3c102ab8c30ec9be2dd --- /dev/null +++ b/node_modules/@types/node/ts4.8/dns/promises.d.ts @@ -0,0 +1,425 @@ +/** + * The `dns.promises` API provides an alternative set of asynchronous DNS methods + * that return `Promise` objects rather than using callbacks. The API is accessible + * via `require('node:dns').promises` or `require('node:dns/promises')`. + * @since v10.6.0 + */ +declare module "dns/promises" { + import { + AnyRecord, + CaaRecord, + LookupAddress, + LookupAllOptions, + LookupOneOptions, + LookupOptions, + MxRecord, + NaptrRecord, + RecordWithTtl, + ResolveOptions, + ResolverOptions, + ResolveWithTtlOptions, + SoaRecord, + SrvRecord, + } from "node:dns"; + /** + * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6), + * that are currently configured for DNS resolution. A string will include a port + * section if a custom port is used. + * + * ```js + * [ + * '4.4.4.4', + * '2001:4860:4860::8888', + * '4.4.4.4:1053', + * '[2001:4860:4860::8888]:1053', + * ] + * ``` + * @since v10.6.0 + */ + function getServers(): string[]; + /** + * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or + * AAAA (IPv6) record. All `option` properties are optional. If `options` is an + * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4 + * and IPv6 addresses are both returned if found. + * + * With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`. + * + * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code. + * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when + * the host name does not exist but also when the lookup fails in other ways + * such as no available file descriptors. + * + * `dnsPromises.lookup()` does not necessarily have anything to do with the DNS + * protocol. The implementation uses an operating system facility that can + * associate names with addresses and vice versa. This implementation can have + * subtle but important consequences on the behavior of any Node.js program. Please + * take some time to consult the `Implementation considerations section` before + * using `dnsPromises.lookup()`. + * + * Example usage: + * + * ```js + * const dns = require('node:dns'); + * const dnsPromises = dns.promises; + * const options = { + * family: 6, + * hints: dns.ADDRCONFIG | dns.V4MAPPED, + * }; + * + * dnsPromises.lookup('example.com', options).then((result) => { + * console.log('address: %j family: IPv%s', result.address, result.family); + * // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6 + * }); + * + * // When options.all is true, the result will be an Array. + * options.all = true; + * dnsPromises.lookup('example.com', options).then((result) => { + * console.log('addresses: %j', result); + * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}] + * }); + * ``` + * @since v10.6.0 + */ + function lookup(hostname: string, family: number): Promise; + function lookup(hostname: string, options: LookupOneOptions): Promise; + function lookup(hostname: string, options: LookupAllOptions): Promise; + function lookup(hostname: string, options: LookupOptions): Promise; + function lookup(hostname: string): Promise; + /** + * Resolves the given `address` and `port` into a host name and service using + * the operating system's underlying `getnameinfo` implementation. + * + * If `address` is not a valid IP address, a `TypeError` will be thrown. + * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown. + * + * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code. + * + * ```js + * const dnsPromises = require('node:dns').promises; + * dnsPromises.lookupService('127.0.0.1', 22).then((result) => { + * console.log(result.hostname, result.service); + * // Prints: localhost ssh + * }); + * ``` + * @since v10.6.0 + */ + function lookupService( + address: string, + port: number, + ): Promise<{ + hostname: string; + service: string; + }>; + /** + * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array + * of the resource records. When successful, the `Promise` is resolved with an + * array of resource records. The type and structure of individual results vary + * based on `rrtype`: + * + * + * + * On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`. + * @since v10.6.0 + * @param hostname Host name to resolve. + * @param [rrtype='A'] Resource record type. + */ + function resolve(hostname: string): Promise; + function resolve(hostname: string, rrtype: "A"): Promise; + function resolve(hostname: string, rrtype: "AAAA"): Promise; + function resolve(hostname: string, rrtype: "ANY"): Promise; + function resolve(hostname: string, rrtype: "CAA"): Promise; + function resolve(hostname: string, rrtype: "CNAME"): Promise; + function resolve(hostname: string, rrtype: "MX"): Promise; + function resolve(hostname: string, rrtype: "NAPTR"): Promise; + function resolve(hostname: string, rrtype: "NS"): Promise; + function resolve(hostname: string, rrtype: "PTR"): Promise; + function resolve(hostname: string, rrtype: "SOA"): Promise; + function resolve(hostname: string, rrtype: "SRV"): Promise; + function resolve(hostname: string, rrtype: "TXT"): Promise; + function resolve( + hostname: string, + rrtype: string, + ): Promise; + /** + * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4 + * addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`). + * @since v10.6.0 + * @param hostname Host name to resolve. + */ + function resolve4(hostname: string): Promise; + function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise; + function resolve4(hostname: string, options: ResolveOptions): Promise; + /** + * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv6 + * addresses. + * @since v10.6.0 + * @param hostname Host name to resolve. + */ + function resolve6(hostname: string): Promise; + function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise; + function resolve6(hostname: string, options: ResolveOptions): Promise; + /** + * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query). + * On success, the `Promise` is resolved with an array containing various types of + * records. Each object has a property `type` that indicates the type of the + * current record. And depending on the `type`, additional properties will be + * present on the object: + * + * + * + * Here is an example of the result object: + * + * ```js + * [ { type: 'A', address: '127.0.0.1', ttl: 299 }, + * { type: 'CNAME', value: 'example.com' }, + * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 }, + * { type: 'NS', value: 'ns1.example.com' }, + * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] }, + * { type: 'SOA', + * nsname: 'ns1.example.com', + * hostmaster: 'admin.example.com', + * serial: 156696742, + * refresh: 900, + * retry: 900, + * expire: 1800, + * minttl: 60 } ] + * ``` + * @since v10.6.0 + */ + function resolveAny(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success, + * the `Promise` is resolved with an array of objects containing available + * certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`). + * @since v15.0.0, v14.17.0 + */ + function resolveCaa(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success, + * the `Promise` is resolved with an array of canonical name records available for + * the `hostname` (e.g. `['bar.example.com']`). + * @since v10.6.0 + */ + function resolveCname(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects + * containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`). + * @since v10.6.0 + */ + function resolveMx(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array + * of objects with the following properties: + * + * * `flags` + * * `service` + * * `regexp` + * * `replacement` + * * `order` + * * `preference` + * + * ```js + * { + * flags: 's', + * service: 'SIP+D2U', + * regexp: '', + * replacement: '_sip._udp.example.com', + * order: 30, + * preference: 100 + * } + * ``` + * @since v10.6.0 + */ + function resolveNaptr(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server + * records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`). + * @since v10.6.0 + */ + function resolveNs(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings + * containing the reply records. + * @since v10.6.0 + */ + function resolvePtr(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for + * the `hostname`. On success, the `Promise` is resolved with an object with the + * following properties: + * + * * `nsname` + * * `hostmaster` + * * `serial` + * * `refresh` + * * `retry` + * * `expire` + * * `minttl` + * + * ```js + * { + * nsname: 'ns.example.com', + * hostmaster: 'root.example.com', + * serial: 2013101809, + * refresh: 10000, + * retry: 2400, + * expire: 604800, + * minttl: 3600 + * } + * ``` + * @since v10.6.0 + */ + function resolveSoa(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with + * the following properties: + * + * * `priority` + * * `weight` + * * `port` + * * `name` + * + * ```js + * { + * priority: 10, + * weight: 5, + * port: 21223, + * name: 'service.example.com' + * } + * ``` + * @since v10.6.0 + */ + function resolveSrv(hostname: string): Promise; + /** + * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array + * of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of + * one record. Depending on the use case, these could be either joined together or + * treated separately. + * @since v10.6.0 + */ + function resolveTxt(hostname: string): Promise; + /** + * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an + * array of host names. + * + * On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`. + * @since v10.6.0 + */ + function reverse(ip: string): Promise; + /** + * Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: for `verbatim` defaulting to `false`. + * * `verbatim`: for `verbatim` defaulting to `true`. + * @since v20.1.0 + */ + function getDefaultResultOrder(): "ipv4first" | "verbatim"; + /** + * Sets the IP address and port of servers to be used when performing DNS + * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted + * addresses. If the port is the IANA default DNS port (53) it can be omitted. + * + * ```js + * dnsPromises.setServers([ + * '4.4.4.4', + * '[2001:4860:4860::8888]', + * '4.4.4.4:1053', + * '[2001:4860:4860::8888]:1053', + * ]); + * ``` + * + * An error will be thrown if an invalid address is provided. + * + * The `dnsPromises.setServers()` method must not be called while a DNS query is in + * progress. + * + * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html). + * That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with + * subsequent servers provided. Fallback DNS servers will only be used if the + * earlier ones time out or result in some other error. + * @since v10.6.0 + * @param servers array of `RFC 5952` formatted addresses + */ + function setServers(servers: readonly string[]): void; + /** + * Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be: + * + * * `ipv4first`: sets default `verbatim` `false`. + * * `verbatim`: sets default `verbatim` `true`. + * + * The default is `verbatim` and `dnsPromises.setDefaultResultOrder()` have + * higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the + * default dns orders in workers. + * @since v16.4.0, v14.18.0 + * @param order must be `'ipv4first'` or `'verbatim'`. + */ + function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void; + /** + * An independent resolver for DNS requests. + * + * Creating a new resolver uses the default server settings. Setting + * the servers used for a resolver using `resolver.setServers()` does not affect + * other resolvers: + * + * ```js + * const { Resolver } = require('node:dns').promises; + * const resolver = new Resolver(); + * resolver.setServers(['4.4.4.4']); + * + * // This request will use the server at 4.4.4.4, independent of global settings. + * resolver.resolve4('example.org').then((addresses) => { + * // ... + * }); + * + * // Alternatively, the same code can be written using async-await style. + * (async function() { + * const addresses = await resolver.resolve4('example.org'); + * })(); + * ``` + * + * The following methods from the `dnsPromises` API are available: + * + * * `resolver.getServers()` + * * `resolver.resolve()` + * * `resolver.resolve4()` + * * `resolver.resolve6()` + * * `resolver.resolveAny()` + * * `resolver.resolveCaa()` + * * `resolver.resolveCname()` + * * `resolver.resolveMx()` + * * `resolver.resolveNaptr()` + * * `resolver.resolveNs()` + * * `resolver.resolvePtr()` + * * `resolver.resolveSoa()` + * * `resolver.resolveSrv()` + * * `resolver.resolveTxt()` + * * `resolver.reverse()` + * * `resolver.setServers()` + * @since v10.6.0 + */ + class Resolver { + constructor(options?: ResolverOptions); + cancel(): void; + getServers: typeof getServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCaa: typeof resolveCaa; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + setLocalAddress(ipv4?: string, ipv6?: string): void; + setServers: typeof setServers; + } +} +declare module "node:dns/promises" { + export * from "dns/promises"; +} diff --git a/node_modules/@types/node/ts4.8/dom-events.d.ts b/node_modules/@types/node/ts4.8/dom-events.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..147a7b657dfa93431b2724b9e31c05f75cfe230c --- /dev/null +++ b/node_modules/@types/node/ts4.8/dom-events.d.ts @@ -0,0 +1,122 @@ +export {}; // Don't export anything! + +//// DOM-like Events +// NB: The Event / EventTarget / EventListener implementations below were copied +// from lib.dom.d.ts, then edited to reflect Node's documentation at +// https://nodejs.org/api/events.html#class-eventtarget. +// Please read that link to understand important implementation differences. + +// This conditional type will be the existing global Event in a browser, or +// the copy below in a Node environment. +type __Event = typeof globalThis extends { onmessage: any; Event: any } ? {} + : { + /** This is not used in Node.js and is provided purely for completeness. */ + readonly bubbles: boolean; + /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */ + cancelBubble: () => void; + /** True if the event was created with the cancelable option */ + readonly cancelable: boolean; + /** This is not used in Node.js and is provided purely for completeness. */ + readonly composed: boolean; + /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */ + composedPath(): [EventTarget?]; + /** Alias for event.target. */ + readonly currentTarget: EventTarget | null; + /** Is true if cancelable is true and event.preventDefault() has been called. */ + readonly defaultPrevented: boolean; + /** This is not used in Node.js and is provided purely for completeness. */ + readonly eventPhase: 0 | 2; + /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */ + readonly isTrusted: boolean; + /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */ + preventDefault(): void; + /** This is not used in Node.js and is provided purely for completeness. */ + returnValue: boolean; + /** Alias for event.target. */ + readonly srcElement: EventTarget | null; + /** Stops the invocation of event listeners after the current one completes. */ + stopImmediatePropagation(): void; + /** This is not used in Node.js and is provided purely for completeness. */ + stopPropagation(): void; + /** The `EventTarget` dispatching the event */ + readonly target: EventTarget | null; + /** The millisecond timestamp when the Event object was created. */ + readonly timeStamp: number; + /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ + readonly type: string; + }; + +// See comment above explaining conditional type +type __EventTarget = typeof globalThis extends { onmessage: any; EventTarget: any } ? {} + : { + /** + * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value. + * + * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched. + * + * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification. + * Specifically, the `capture` option is used as part of the key when registering a `listener`. + * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. + */ + addEventListener( + type: string, + listener: EventListener | EventListenerObject, + options?: AddEventListenerOptions | boolean, + ): void; + /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ + dispatchEvent(event: Event): boolean; + /** Removes the event listener in target's event listener list with the same type, callback, and options. */ + removeEventListener( + type: string, + listener: EventListener | EventListenerObject, + options?: EventListenerOptions | boolean, + ): void; + }; + +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; + composed?: boolean; +} + +interface EventListenerOptions { + /** Not directly used by Node.js. Added for API completeness. Default: `false`. */ + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */ + once?: boolean; + /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */ + passive?: boolean; +} + +interface EventListener { + (evt: Event): void; +} + +interface EventListenerObject { + handleEvent(object: Event): void; +} + +import {} from "events"; // Make this an ambient declaration +declare global { + /** An event which takes place in the DOM. */ + interface Event extends __Event {} + var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T + : { + prototype: __Event; + new(type: string, eventInitDict?: EventInit): __Event; + }; + + /** + * EventTarget is a DOM interface implemented by objects that can + * receive events and may have listeners for them. + */ + interface EventTarget extends __EventTarget {} + var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T + : { + prototype: __EventTarget; + new(): __EventTarget; + }; +} diff --git a/node_modules/@types/node/ts4.8/domain.d.ts b/node_modules/@types/node/ts4.8/domain.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..72f17bd801e745a3697e684826345fee0d998fcb --- /dev/null +++ b/node_modules/@types/node/ts4.8/domain.d.ts @@ -0,0 +1,170 @@ +/** + * **This module is pending deprecation.** Once a replacement API has been + * finalized, this module will be fully deprecated. Most developers should + * **not** have cause to use this module. Users who absolutely must have + * the functionality that domains provide may rely on it for the time being + * but should expect to have to migrate to a different solution + * in the future. + * + * Domains provide a way to handle multiple different IO operations as a + * single group. If any of the event emitters or callbacks registered to a + * domain emit an `'error'` event, or throw an error, then the domain object + * will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to + * exit immediately with an error code. + * @deprecated Since v1.4.2 - Deprecated + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/domain.js) + */ +declare module "domain" { + import EventEmitter = require("node:events"); + /** + * The `Domain` class encapsulates the functionality of routing errors and + * uncaught exceptions to the active `Domain` object. + * + * To handle the errors that it catches, listen to its `'error'` event. + */ + class Domain extends EventEmitter { + /** + * An array of timers and event emitters that have been explicitly added + * to the domain. + */ + members: Array; + /** + * The `enter()` method is plumbing used by the `run()`, `bind()`, and`intercept()` methods to set the active domain. It sets `domain.active` and`process.domain` to the domain, and implicitly + * pushes the domain onto the domain + * stack managed by the domain module (see {@link exit} for details on the + * domain stack). The call to `enter()` delimits the beginning of a chain of + * asynchronous calls and I/O operations bound to a domain. + * + * Calling `enter()` changes only the active domain, and does not alter the domain + * itself. `enter()` and `exit()` can be called an arbitrary number of times on a + * single domain. + */ + enter(): void; + /** + * The `exit()` method exits the current domain, popping it off the domain stack. + * Any time execution is going to switch to the context of a different chain of + * asynchronous calls, it's important to ensure that the current domain is exited. + * The call to `exit()` delimits either the end of or an interruption to the chain + * of asynchronous calls and I/O operations bound to a domain. + * + * If there are multiple, nested domains bound to the current execution context,`exit()` will exit any domains nested within this domain. + * + * Calling `exit()` changes only the active domain, and does not alter the domain + * itself. `enter()` and `exit()` can be called an arbitrary number of times on a + * single domain. + */ + exit(): void; + /** + * Run the supplied function in the context of the domain, implicitly + * binding all event emitters, timers, and low-level requests that are + * created in that context. Optionally, arguments can be passed to + * the function. + * + * This is the most basic way to use a domain. + * + * ```js + * const domain = require('node:domain'); + * const fs = require('node:fs'); + * const d = domain.create(); + * d.on('error', (er) => { + * console.error('Caught error!', er); + * }); + * d.run(() => { + * process.nextTick(() => { + * setTimeout(() => { // Simulating some various async stuff + * fs.open('non-existent file', 'r', (er, fd) => { + * if (er) throw er; + * // proceed... + * }); + * }, 100); + * }); + * }); + * ``` + * + * In this example, the `d.on('error')` handler will be triggered, rather + * than crashing the program. + */ + run(fn: (...args: any[]) => T, ...args: any[]): T; + /** + * Explicitly adds an emitter to the domain. If any event handlers called by + * the emitter throw an error, or if the emitter emits an `'error'` event, it + * will be routed to the domain's `'error'` event, just like with implicit + * binding. + * + * This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by + * the domain `'error'` handler. + * + * If the Timer or `EventEmitter` was already bound to a domain, it is removed + * from that one, and bound to this one instead. + * @param emitter emitter or timer to be added to the domain + */ + add(emitter: EventEmitter | NodeJS.Timer): void; + /** + * The opposite of {@link add}. Removes domain handling from the + * specified emitter. + * @param emitter emitter or timer to be removed from the domain + */ + remove(emitter: EventEmitter | NodeJS.Timer): void; + /** + * The returned function will be a wrapper around the supplied callback + * function. When the returned function is called, any errors that are + * thrown will be routed to the domain's `'error'` event. + * + * ```js + * const d = domain.create(); + * + * function readSomeFile(filename, cb) { + * fs.readFile(filename, 'utf8', d.bind((er, data) => { + * // If this throws, it will also be passed to the domain. + * return cb(er, data ? JSON.parse(data) : null); + * })); + * } + * + * d.on('error', (er) => { + * // An error occurred somewhere. If we throw it now, it will crash the program + * // with the normal line number and stack message. + * }); + * ``` + * @param callback The callback function + * @return The bound function + */ + bind(callback: T): T; + /** + * This method is almost identical to {@link bind}. However, in + * addition to catching thrown errors, it will also intercept `Error` objects sent as the first argument to the function. + * + * In this way, the common `if (err) return callback(err);` pattern can be replaced + * with a single error handler in a single place. + * + * ```js + * const d = domain.create(); + * + * function readSomeFile(filename, cb) { + * fs.readFile(filename, 'utf8', d.intercept((data) => { + * // Note, the first argument is never passed to the + * // callback since it is assumed to be the 'Error' argument + * // and thus intercepted by the domain. + * + * // If this throws, it will also be passed to the domain + * // so the error-handling logic can be moved to the 'error' + * // event on the domain instead of being repeated throughout + * // the program. + * return cb(null, JSON.parse(data)); + * })); + * } + * + * d.on('error', (er) => { + * // An error occurred somewhere. If we throw it now, it will crash the program + * // with the normal line number and stack message. + * }); + * ``` + * @param callback The callback function + * @return The intercepted function + */ + intercept(callback: T): T; + } + function create(): Domain; +} +declare module "node:domain" { + export * from "domain"; +} diff --git a/node_modules/@types/node/ts4.8/events.d.ts b/node_modules/@types/node/ts4.8/events.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ed47c53aa9c2a5d6d4d146aaff9855135036631 --- /dev/null +++ b/node_modules/@types/node/ts4.8/events.d.ts @@ -0,0 +1,879 @@ +/** + * Much of the Node.js core API is built around an idiomatic asynchronous + * event-driven architecture in which certain kinds of objects (called "emitters") + * emit named events that cause `Function` objects ("listeners") to be called. + * + * For instance: a `net.Server` object emits an event each time a peer + * connects to it; a `fs.ReadStream` emits an event when the file is opened; + * a `stream` emits an event whenever data is available to be read. + * + * All objects that emit events are instances of the `EventEmitter` class. These + * objects expose an `eventEmitter.on()` function that allows one or more + * functions to be attached to named events emitted by the object. Typically, + * event names are camel-cased strings but any valid JavaScript property key + * can be used. + * + * When the `EventEmitter` object emits an event, all of the functions attached + * to that specific event are called _synchronously_. Any values returned by the + * called listeners are _ignored_ and discarded. + * + * The following example shows a simple `EventEmitter` instance with a single + * listener. The `eventEmitter.on()` method is used to register listeners, while + * the `eventEmitter.emit()` method is used to trigger the event. + * + * ```js + * import { EventEmitter } from 'node:events'; + * + * class MyEmitter extends EventEmitter {} + * + * const myEmitter = new MyEmitter(); + * myEmitter.on('event', () => { + * console.log('an event occurred!'); + * }); + * myEmitter.emit('event'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/events.js) + */ +declare module "events" { + import { AsyncResource, AsyncResourceOptions } from "node:async_hooks"; + // NOTE: This class is in the docs but is **not actually exported** by Node. + // If https://github.com/nodejs/node/issues/39903 gets resolved and Node + // actually starts exporting the class, uncomment below. + // import { EventListener, EventListenerObject } from '__dom-events'; + // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */ + // interface NodeEventTarget extends EventTarget { + // /** + // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API. + // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget. + // */ + // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this; + // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */ + // eventNames(): string[]; + // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */ + // listenerCount(type: string): number; + // /** Node.js-specific alias for `eventTarget.removeListener()`. */ + // off(type: string, listener: EventListener | EventListenerObject): this; + // /** Node.js-specific alias for `eventTarget.addListener()`. */ + // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this; + // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */ + // once(type: string, listener: EventListener | EventListenerObject): this; + // /** + // * Node.js-specific extension to the `EventTarget` class. + // * If `type` is specified, removes all registered listeners for `type`, + // * otherwise removes all registered listeners. + // */ + // removeAllListeners(type: string): this; + // /** + // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`. + // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`. + // */ + // removeListener(type: string, listener: EventListener | EventListenerObject): this; + // } + interface EventEmitterOptions { + /** + * Enables automatic capturing of promise rejection. + */ + captureRejections?: boolean | undefined; + } + // Any EventTarget with a Node-style `once` function + interface _NodeEventTarget { + once(eventName: string | symbol, listener: (...args: any[]) => void): this; + } + // Any EventTarget with a DOM-style `addEventListener` + interface _DOMEventTarget { + addEventListener( + eventName: string, + listener: (...args: any[]) => void, + opts?: { + once: boolean; + }, + ): any; + } + interface StaticEventEmitterOptions { + signal?: AbortSignal | undefined; + } + interface EventEmitter extends NodeJS.EventEmitter {} + /** + * The `EventEmitter` class is defined and exposed by the `node:events` module: + * + * ```js + * import { EventEmitter } from 'node:events'; + * ``` + * + * All `EventEmitter`s emit the event `'newListener'` when new listeners are + * added and `'removeListener'` when existing listeners are removed. + * + * It supports the following option: + * @since v0.1.26 + */ + class EventEmitter { + constructor(options?: EventEmitterOptions); + + [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void; + + /** + * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given + * event or that is rejected if the `EventEmitter` emits `'error'` while waiting. + * The `Promise` will resolve with an array of all the arguments emitted to the + * given event. + * + * This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event + * semantics and does not listen to the `'error'` event. + * + * ```js + * import { once, EventEmitter } from 'node:events'; + * import process from 'node:process'; + * + * const ee = new EventEmitter(); + * + * process.nextTick(() => { + * ee.emit('myevent', 42); + * }); + * + * const [value] = await once(ee, 'myevent'); + * console.log(value); + * + * const err = new Error('kaboom'); + * process.nextTick(() => { + * ee.emit('error', err); + * }); + * + * try { + * await once(ee, 'myevent'); + * } catch (err) { + * console.error('error happened', err); + * } + * ``` + * + * The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the + * '`error'` event itself, then it is treated as any other kind of event without + * special handling: + * + * ```js + * import { EventEmitter, once } from 'node:events'; + * + * const ee = new EventEmitter(); + * + * once(ee, 'error') + * .then(([err]) => console.log('ok', err.message)) + * .catch((err) => console.error('error', err.message)); + * + * ee.emit('error', new Error('boom')); + * + * // Prints: ok boom + * ``` + * + * An `AbortSignal` can be used to cancel waiting for the event: + * + * ```js + * import { EventEmitter, once } from 'node:events'; + * + * const ee = new EventEmitter(); + * const ac = new AbortController(); + * + * async function foo(emitter, event, signal) { + * try { + * await once(emitter, event, { signal }); + * console.log('event emitted!'); + * } catch (error) { + * if (error.name === 'AbortError') { + * console.error('Waiting for the event was canceled!'); + * } else { + * console.error('There was an error', error.message); + * } + * } + * } + * + * foo(ee, 'foo', ac.signal); + * ac.abort(); // Abort waiting for the event + * ee.emit('foo'); // Prints: Waiting for the event was canceled! + * ``` + * @since v11.13.0, v10.16.0 + */ + static once( + emitter: _NodeEventTarget, + eventName: string | symbol, + options?: StaticEventEmitterOptions, + ): Promise; + static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise; + /** + * ```js + * import { on, EventEmitter } from 'node:events'; + * import process from 'node:process'; + * + * const ee = new EventEmitter(); + * + * // Emit later on + * process.nextTick(() => { + * ee.emit('foo', 'bar'); + * ee.emit('foo', 42); + * }); + * + * for await (const event of on(ee, 'foo')) { + * // The execution of this inner block is synchronous and it + * // processes one event at a time (even with await). Do not use + * // if concurrent execution is required. + * console.log(event); // prints ['bar'] [42] + * } + * // Unreachable here + * ``` + * + * Returns an `AsyncIterator` that iterates `eventName` events. It will throw + * if the `EventEmitter` emits `'error'`. It removes all listeners when + * exiting the loop. The `value` returned by each iteration is an array + * composed of the emitted event arguments. + * + * An `AbortSignal` can be used to cancel waiting on events: + * + * ```js + * import { on, EventEmitter } from 'node:events'; + * import process from 'node:process'; + * + * const ac = new AbortController(); + * + * (async () => { + * const ee = new EventEmitter(); + * + * // Emit later on + * process.nextTick(() => { + * ee.emit('foo', 'bar'); + * ee.emit('foo', 42); + * }); + * + * for await (const event of on(ee, 'foo', { signal: ac.signal })) { + * // The execution of this inner block is synchronous and it + * // processes one event at a time (even with await). Do not use + * // if concurrent execution is required. + * console.log(event); // prints ['bar'] [42] + * } + * // Unreachable here + * })(); + * + * process.nextTick(() => ac.abort()); + * ``` + * @since v13.6.0, v12.16.0 + * @param eventName The name of the event being listened for + * @return that iterates `eventName` events emitted by the `emitter` + */ + static on( + emitter: NodeJS.EventEmitter, + eventName: string, + options?: StaticEventEmitterOptions, + ): AsyncIterableIterator; + /** + * A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`. + * + * ```js + * import { EventEmitter, listenerCount } from 'node:events'; + * + * const myEmitter = new EventEmitter(); + * myEmitter.on('event', () => {}); + * myEmitter.on('event', () => {}); + * console.log(listenerCount(myEmitter, 'event')); + * // Prints: 2 + * ``` + * @since v0.9.12 + * @deprecated Since v3.2.0 - Use `listenerCount` instead. + * @param emitter The emitter to query + * @param eventName The event name + */ + static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number; + /** + * Returns a copy of the array of listeners for the event named `eventName`. + * + * For `EventEmitter`s this behaves exactly the same as calling `.listeners` on + * the emitter. + * + * For `EventTarget`s this is the only way to get the event listeners for the + * event target. This is useful for debugging and diagnostic purposes. + * + * ```js + * import { getEventListeners, EventEmitter } from 'node:events'; + * + * { + * const ee = new EventEmitter(); + * const listener = () => console.log('Events are fun'); + * ee.on('foo', listener); + * console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ] + * } + * { + * const et = new EventTarget(); + * const listener = () => console.log('Events are fun'); + * et.addEventListener('foo', listener); + * console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ] + * } + * ``` + * @since v15.2.0, v14.17.0 + */ + static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[]; + /** + * Returns the currently set max amount of listeners. + * + * For `EventEmitter`s this behaves exactly the same as calling `.getMaxListeners` on + * the emitter. + * + * For `EventTarget`s this is the only way to get the max event listeners for the + * event target. If the number of event handlers on a single EventTarget exceeds + * the max set, the EventTarget will print a warning. + * + * ```js + * import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events'; + * + * { + * const ee = new EventEmitter(); + * console.log(getMaxListeners(ee)); // 10 + * setMaxListeners(11, ee); + * console.log(getMaxListeners(ee)); // 11 + * } + * { + * const et = new EventTarget(); + * console.log(getMaxListeners(et)); // 10 + * setMaxListeners(11, et); + * console.log(getMaxListeners(et)); // 11 + * } + * ``` + * @since v19.9.0 + */ + static getMaxListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter): number; + /** + * ```js + * import { setMaxListeners, EventEmitter } from 'node:events'; + * + * const target = new EventTarget(); + * const emitter = new EventEmitter(); + * + * setMaxListeners(5, target, emitter); + * ``` + * @since v15.4.0 + * @param n A non-negative number. The maximum number of listeners per `EventTarget` event. + * @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter} + * objects. + */ + static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void; + /** + * Listens once to the `abort` event on the provided `signal`. + * + * Listening to the `abort` event on abort signals is unsafe and may + * lead to resource leaks since another third party with the signal can + * call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change + * this since it would violate the web standard. Additionally, the original + * API makes it easy to forget to remove listeners. + * + * This API allows safely using `AbortSignal`s in Node.js APIs by solving these + * two issues by listening to the event such that `stopImmediatePropagation` does + * not prevent the listener from running. + * + * Returns a disposable so that it may be unsubscribed from more easily. + * + * ```js + * import { addAbortListener } from 'node:events'; + * + * function example(signal) { + * let disposable; + * try { + * signal.addEventListener('abort', (e) => e.stopImmediatePropagation()); + * disposable = addAbortListener(signal, (e) => { + * // Do something when signal is aborted. + * }); + * } finally { + * disposable?.[Symbol.dispose](); + * } + * } + * ``` + * @since v20.5.0 + * @experimental + * @return Disposable that removes the `abort` listener. + */ + static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable; + /** + * This symbol shall be used to install a listener for only monitoring `'error'`events. Listeners installed using this symbol are called before the regular`'error'` listeners are called. + * + * Installing a listener using this symbol does not change the behavior once an`'error'` event is emitted. Therefore, the process will still crash if no + * regular `'error'` listener is installed. + * @since v13.6.0, v12.17.0 + */ + static readonly errorMonitor: unique symbol; + /** + * Value: `Symbol.for('nodejs.rejection')` + * + * See how to write a custom `rejection handler`. + * @since v13.4.0, v12.16.0 + */ + static readonly captureRejectionSymbol: unique symbol; + /** + * Value: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) + * + * Change the default `captureRejections` option on all new `EventEmitter` objects. + * @since v13.4.0, v12.16.0 + */ + static captureRejections: boolean; + /** + * By default, a maximum of `10` listeners can be registered for any single + * event. This limit can be changed for individual `EventEmitter` instances + * using the `emitter.setMaxListeners(n)` method. To change the default + * for _all_`EventEmitter` instances, the `events.defaultMaxListeners`property can be used. If this value is not a positive number, a `RangeError`is thrown. + * + * Take caution when setting the `events.defaultMaxListeners` because the + * change affects _all_`EventEmitter` instances, including those created before + * the change is made. However, calling `emitter.setMaxListeners(n)` still has + * precedence over `events.defaultMaxListeners`. + * + * This is not a hard limit. The `EventEmitter` instance will allow + * more listeners to be added but will output a trace warning to stderr indicating + * that a "possible EventEmitter memory leak" has been detected. For any single`EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()`methods can be used to + * temporarily avoid this warning: + * + * ```js + * import { EventEmitter } from 'node:events'; + * const emitter = new EventEmitter(); + * emitter.setMaxListeners(emitter.getMaxListeners() + 1); + * emitter.once('event', () => { + * // do stuff + * emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0)); + * }); + * ``` + * + * The `--trace-warnings` command-line flag can be used to display the + * stack trace for such warnings. + * + * The emitted warning can be inspected with `process.on('warning')` and will + * have the additional `emitter`, `type`, and `count` properties, referring to + * the event emitter instance, the event's name and the number of attached + * listeners, respectively. + * Its `name` property is set to `'MaxListenersExceededWarning'`. + * @since v0.11.2 + */ + static defaultMaxListeners: number; + } + import internal = require("node:events"); + namespace EventEmitter { + // Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4 + export { internal as EventEmitter }; + export interface Abortable { + /** + * When provided the corresponding `AbortController` can be used to cancel an asynchronous action. + */ + signal?: AbortSignal | undefined; + } + + export interface EventEmitterReferencingAsyncResource extends AsyncResource { + readonly eventEmitter: EventEmitterAsyncResource; + } + + export interface EventEmitterAsyncResourceOptions extends AsyncResourceOptions, EventEmitterOptions { + /** + * The type of async event, this is required when instantiating `EventEmitterAsyncResource` + * directly rather than as a child class. + * @default new.target.name if instantiated as a child class. + */ + name?: string; + } + + /** + * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that + * require manual async tracking. Specifically, all events emitted by instances + * of `events.EventEmitterAsyncResource` will run within its `async context`. + * + * ```js + * import { EventEmitterAsyncResource, EventEmitter } from 'node:events'; + * import { notStrictEqual, strictEqual } from 'node:assert'; + * import { executionAsyncId, triggerAsyncId } from 'node:async_hooks'; + * + * // Async tracking tooling will identify this as 'Q'. + * const ee1 = new EventEmitterAsyncResource({ name: 'Q' }); + * + * // 'foo' listeners will run in the EventEmitters async context. + * ee1.on('foo', () => { + * strictEqual(executionAsyncId(), ee1.asyncId); + * strictEqual(triggerAsyncId(), ee1.triggerAsyncId); + * }); + * + * const ee2 = new EventEmitter(); + * + * // 'foo' listeners on ordinary EventEmitters that do not track async + * // context, however, run in the same async context as the emit(). + * ee2.on('foo', () => { + * notStrictEqual(executionAsyncId(), ee2.asyncId); + * notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId); + * }); + * + * Promise.resolve().then(() => { + * ee1.emit('foo'); + * ee2.emit('foo'); + * }); + * ``` + * + * The `EventEmitterAsyncResource` class has the same methods and takes the + * same options as `EventEmitter` and `AsyncResource` themselves. + * @since v17.4.0, v16.14.0 + */ + export class EventEmitterAsyncResource extends EventEmitter { + /** + * @param options Only optional in child class. + */ + constructor(options?: EventEmitterAsyncResourceOptions); + /** + * Call all `destroy` hooks. This should only ever be called once. An error will + * be thrown if it is called more than once. This **must** be manually called. If + * the resource is left to be collected by the GC then the `destroy` hooks will + * never be called. + */ + emitDestroy(): void; + /** + * The unique `asyncId` assigned to the resource. + */ + readonly asyncId: number; + /** + * The same triggerAsyncId that is passed to the AsyncResource constructor. + */ + readonly triggerAsyncId: number; + /** + * The returned `AsyncResource` object has an additional `eventEmitter` property + * that provides a reference to this `EventEmitterAsyncResource`. + */ + readonly asyncResource: EventEmitterReferencingAsyncResource; + } + } + global { + namespace NodeJS { + interface EventEmitter { + [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void; + /** + * Alias for `emitter.on(eventName, listener)`. + * @since v0.1.26 + */ + addListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Adds the `listener` function to the end of the listeners array for the + * event named `eventName`. No checks are made to see if the `listener` has + * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple + * times. + * + * ```js + * server.on('connection', (stream) => { + * console.log('someone connected!'); + * }); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * + * By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the + * event listener to the beginning of the listeners array. + * + * ```js + * import { EventEmitter } from 'node:events'; + * const myEE = new EventEmitter(); + * myEE.on('foo', () => console.log('a')); + * myEE.prependListener('foo', () => console.log('b')); + * myEE.emit('foo'); + * // Prints: + * // b + * // a + * ``` + * @since v0.1.101 + * @param eventName The name of the event. + * @param listener The callback function + */ + on(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Adds a **one-time**`listener` function for the event named `eventName`. The + * next time `eventName` is triggered, this listener is removed and then invoked. + * + * ```js + * server.once('connection', (stream) => { + * console.log('Ah, we have our first user!'); + * }); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * + * By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the + * event listener to the beginning of the listeners array. + * + * ```js + * import { EventEmitter } from 'node:events'; + * const myEE = new EventEmitter(); + * myEE.once('foo', () => console.log('a')); + * myEE.prependOnceListener('foo', () => console.log('b')); + * myEE.emit('foo'); + * // Prints: + * // b + * // a + * ``` + * @since v0.3.0 + * @param eventName The name of the event. + * @param listener The callback function + */ + once(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Removes the specified `listener` from the listener array for the event named`eventName`. + * + * ```js + * const callback = (stream) => { + * console.log('someone connected!'); + * }; + * server.on('connection', callback); + * // ... + * server.removeListener('connection', callback); + * ``` + * + * `removeListener()` will remove, at most, one instance of a listener from the + * listener array. If any single listener has been added multiple times to the + * listener array for the specified `eventName`, then `removeListener()` must be + * called multiple times to remove each instance. + * + * Once an event is emitted, all listeners attached to it at the + * time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution + * will not remove them from`emit()` in progress. Subsequent events behave as expected. + * + * ```js + * import { EventEmitter } from 'node:events'; + * class MyEmitter extends EventEmitter {} + * const myEmitter = new MyEmitter(); + * + * const callbackA = () => { + * console.log('A'); + * myEmitter.removeListener('event', callbackB); + * }; + * + * const callbackB = () => { + * console.log('B'); + * }; + * + * myEmitter.on('event', callbackA); + * + * myEmitter.on('event', callbackB); + * + * // callbackA removes listener callbackB but it will still be called. + * // Internal listener array at time of emit [callbackA, callbackB] + * myEmitter.emit('event'); + * // Prints: + * // A + * // B + * + * // callbackB is now removed. + * // Internal listener array [callbackA] + * myEmitter.emit('event'); + * // Prints: + * // A + * ``` + * + * Because listeners are managed using an internal array, calling this will + * change the position indices of any listener registered _after_ the listener + * being removed. This will not impact the order in which listeners are called, + * but it means that any copies of the listener array as returned by + * the `emitter.listeners()` method will need to be recreated. + * + * When a single function has been added as a handler multiple times for a single + * event (as in the example below), `removeListener()` will remove the most + * recently added instance. In the example the `once('ping')`listener is removed: + * + * ```js + * import { EventEmitter } from 'node:events'; + * const ee = new EventEmitter(); + * + * function pong() { + * console.log('pong'); + * } + * + * ee.on('ping', pong); + * ee.once('ping', pong); + * ee.removeListener('ping', pong); + * + * ee.emit('ping'); + * ee.emit('ping'); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v0.1.26 + */ + removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Alias for `emitter.removeListener()`. + * @since v10.0.0 + */ + off(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Removes all listeners, or those of the specified `eventName`. + * + * It is bad practice to remove listeners added elsewhere in the code, + * particularly when the `EventEmitter` instance was created by some other + * component or module (e.g. sockets or file streams). + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v0.1.26 + */ + removeAllListeners(event?: string | symbol): this; + /** + * By default `EventEmitter`s will print a warning if more than `10` listeners are + * added for a particular event. This is a useful default that helps finding + * memory leaks. The `emitter.setMaxListeners()` method allows the limit to be + * modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners. + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v0.3.5 + */ + setMaxListeners(n: number): this; + /** + * Returns the current max listener value for the `EventEmitter` which is either + * set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}. + * @since v1.0.0 + */ + getMaxListeners(): number; + /** + * Returns a copy of the array of listeners for the event named `eventName`. + * + * ```js + * server.on('connection', (stream) => { + * console.log('someone connected!'); + * }); + * console.log(util.inspect(server.listeners('connection'))); + * // Prints: [ [Function] ] + * ``` + * @since v0.1.26 + */ + listeners(eventName: string | symbol): Function[]; + /** + * Returns a copy of the array of listeners for the event named `eventName`, + * including any wrappers (such as those created by `.once()`). + * + * ```js + * import { EventEmitter } from 'node:events'; + * const emitter = new EventEmitter(); + * emitter.once('log', () => console.log('log once')); + * + * // Returns a new Array with a function `onceWrapper` which has a property + * // `listener` which contains the original listener bound above + * const listeners = emitter.rawListeners('log'); + * const logFnWrapper = listeners[0]; + * + * // Logs "log once" to the console and does not unbind the `once` event + * logFnWrapper.listener(); + * + * // Logs "log once" to the console and removes the listener + * logFnWrapper(); + * + * emitter.on('log', () => console.log('log persistently')); + * // Will return a new Array with a single function bound by `.on()` above + * const newListeners = emitter.rawListeners('log'); + * + * // Logs "log persistently" twice + * newListeners[0](); + * emitter.emit('log'); + * ``` + * @since v9.4.0 + */ + rawListeners(eventName: string | symbol): Function[]; + /** + * Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments + * to each. + * + * Returns `true` if the event had listeners, `false` otherwise. + * + * ```js + * import { EventEmitter } from 'node:events'; + * const myEmitter = new EventEmitter(); + * + * // First listener + * myEmitter.on('event', function firstListener() { + * console.log('Helloooo! first listener'); + * }); + * // Second listener + * myEmitter.on('event', function secondListener(arg1, arg2) { + * console.log(`event with parameters ${arg1}, ${arg2} in second listener`); + * }); + * // Third listener + * myEmitter.on('event', function thirdListener(...args) { + * const parameters = args.join(', '); + * console.log(`event with parameters ${parameters} in third listener`); + * }); + * + * console.log(myEmitter.listeners('event')); + * + * myEmitter.emit('event', 1, 2, 3, 4, 5); + * + * // Prints: + * // [ + * // [Function: firstListener], + * // [Function: secondListener], + * // [Function: thirdListener] + * // ] + * // Helloooo! first listener + * // event with parameters 1, 2 in second listener + * // event with parameters 1, 2, 3, 4, 5 in third listener + * ``` + * @since v0.1.26 + */ + emit(eventName: string | symbol, ...args: any[]): boolean; + /** + * Returns the number of listeners listening for the event named `eventName`. + * If `listener` is provided, it will return how many times the listener is found + * in the list of the listeners of the event. + * @since v3.2.0 + * @param eventName The name of the event being listened for + * @param listener The event handler function + */ + listenerCount(eventName: string | symbol, listener?: Function): number; + /** + * Adds the `listener` function to the _beginning_ of the listeners array for the + * event named `eventName`. No checks are made to see if the `listener` has + * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple + * times. + * + * ```js + * server.prependListener('connection', (stream) => { + * console.log('someone connected!'); + * }); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v6.0.0 + * @param eventName The name of the event. + * @param listener The callback function + */ + prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Adds a **one-time**`listener` function for the event named `eventName` to the _beginning_ of the listeners array. The next time `eventName` is triggered, this + * listener is removed, and then invoked. + * + * ```js + * server.prependOnceListener('connection', (stream) => { + * console.log('Ah, we have our first user!'); + * }); + * ``` + * + * Returns a reference to the `EventEmitter`, so that calls can be chained. + * @since v6.0.0 + * @param eventName The name of the event. + * @param listener The callback function + */ + prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + /** + * Returns an array listing the events for which the emitter has registered + * listeners. The values in the array are strings or `Symbol`s. + * + * ```js + * import { EventEmitter } from 'node:events'; + * + * const myEE = new EventEmitter(); + * myEE.on('foo', () => {}); + * myEE.on('bar', () => {}); + * + * const sym = Symbol('symbol'); + * myEE.on(sym, () => {}); + * + * console.log(myEE.eventNames()); + * // Prints: [ 'foo', 'bar', Symbol(symbol) ] + * ``` + * @since v6.0.0 + */ + eventNames(): Array; + } + } + } + export = EventEmitter; +} +declare module "node:events" { + import events = require("events"); + export = events; +} diff --git a/node_modules/@types/node/ts4.8/fs.d.ts b/node_modules/@types/node/ts4.8/fs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f98453a53dad6e01f91b39890dfbb938a181604b --- /dev/null +++ b/node_modules/@types/node/ts4.8/fs.d.ts @@ -0,0 +1,4291 @@ +/** + * The `node:fs` module enables interacting with the file system in a + * way modeled on standard POSIX functions. + * + * To use the promise-based APIs: + * + * ```js + * import * as fs from 'node:fs/promises'; + * ``` + * + * To use the callback and sync APIs: + * + * ```js + * import * as fs from 'node:fs'; + * ``` + * + * All file system operations have synchronous, callback, and promise-based + * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM). + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/fs.js) + */ +declare module "fs" { + import * as stream from "node:stream"; + import { Abortable, EventEmitter } from "node:events"; + import { URL } from "node:url"; + import * as promises from "node:fs/promises"; + export { promises }; + /** + * Valid types for path values in "fs". + */ + export type PathLike = string | Buffer | URL; + export type PathOrFileDescriptor = PathLike | number; + export type TimeLike = string | number | Date; + export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void; + export type BufferEncodingOption = + | "buffer" + | { + encoding: "buffer"; + }; + export interface ObjectEncodingOptions { + encoding?: BufferEncoding | null | undefined; + } + export type EncodingOption = ObjectEncodingOptions | BufferEncoding | undefined | null; + export type OpenMode = number | string; + export type Mode = number | string; + export interface StatsBase { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + dev: T; + ino: T; + mode: T; + nlink: T; + uid: T; + gid: T; + rdev: T; + size: T; + blksize: T; + blocks: T; + atimeMs: T; + mtimeMs: T; + ctimeMs: T; + birthtimeMs: T; + atime: Date; + mtime: Date; + ctime: Date; + birthtime: Date; + } + export interface Stats extends StatsBase {} + /** + * A `fs.Stats` object provides information about a file. + * + * Objects returned from {@link stat}, {@link lstat}, {@link fstat}, and + * their synchronous counterparts are of this type. + * If `bigint` in the `options` passed to those methods is true, the numeric values + * will be `bigint` instead of `number`, and the object will contain additional + * nanosecond-precision properties suffixed with `Ns`. + * + * ```console + * Stats { + * dev: 2114, + * ino: 48064969, + * mode: 33188, + * nlink: 1, + * uid: 85, + * gid: 100, + * rdev: 0, + * size: 527, + * blksize: 4096, + * blocks: 8, + * atimeMs: 1318289051000.1, + * mtimeMs: 1318289051000.1, + * ctimeMs: 1318289051000.1, + * birthtimeMs: 1318289051000.1, + * atime: Mon, 10 Oct 2011 23:24:11 GMT, + * mtime: Mon, 10 Oct 2011 23:24:11 GMT, + * ctime: Mon, 10 Oct 2011 23:24:11 GMT, + * birthtime: Mon, 10 Oct 2011 23:24:11 GMT } + * ``` + * + * `bigint` version: + * + * ```console + * BigIntStats { + * dev: 2114n, + * ino: 48064969n, + * mode: 33188n, + * nlink: 1n, + * uid: 85n, + * gid: 100n, + * rdev: 0n, + * size: 527n, + * blksize: 4096n, + * blocks: 8n, + * atimeMs: 1318289051000n, + * mtimeMs: 1318289051000n, + * ctimeMs: 1318289051000n, + * birthtimeMs: 1318289051000n, + * atimeNs: 1318289051000000000n, + * mtimeNs: 1318289051000000000n, + * ctimeNs: 1318289051000000000n, + * birthtimeNs: 1318289051000000000n, + * atime: Mon, 10 Oct 2011 23:24:11 GMT, + * mtime: Mon, 10 Oct 2011 23:24:11 GMT, + * ctime: Mon, 10 Oct 2011 23:24:11 GMT, + * birthtime: Mon, 10 Oct 2011 23:24:11 GMT } + * ``` + * @since v0.1.21 + */ + export class Stats {} + export interface StatsFsBase { + /** Type of file system. */ + type: T; + /** Optimal transfer block size. */ + bsize: T; + /** Total data blocks in file system. */ + blocks: T; + /** Free blocks in file system. */ + bfree: T; + /** Available blocks for unprivileged users */ + bavail: T; + /** Total file nodes in file system. */ + files: T; + /** Free file nodes in file system. */ + ffree: T; + } + export interface StatsFs extends StatsFsBase {} + /** + * Provides information about a mounted file system. + * + * Objects returned from {@link statfs} and its synchronous counterpart are of + * this type. If `bigint` in the `options` passed to those methods is `true`, the + * numeric values will be `bigint` instead of `number`. + * + * ```console + * StatFs { + * type: 1397114950, + * bsize: 4096, + * blocks: 121938943, + * bfree: 61058895, + * bavail: 61058895, + * files: 999, + * ffree: 1000000 + * } + * ``` + * + * `bigint` version: + * + * ```console + * StatFs { + * type: 1397114950n, + * bsize: 4096n, + * blocks: 121938943n, + * bfree: 61058895n, + * bavail: 61058895n, + * files: 999n, + * ffree: 1000000n + * } + * ``` + * @since v19.6.0, v18.15.0 + */ + export class StatsFs {} + export interface BigIntStatsFs extends StatsFsBase {} + export interface StatFsOptions { + bigint?: boolean | undefined; + } + /** + * A representation of a directory entry, which can be a file or a subdirectory + * within the directory, as returned by reading from an `fs.Dir`. The + * directory entry is a combination of the file name and file type pairs. + * + * Additionally, when {@link readdir} or {@link readdirSync} is called with + * the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s. + * @since v10.10.0 + */ + export class Dirent { + /** + * Returns `true` if the `fs.Dirent` object describes a regular file. + * @since v10.10.0 + */ + isFile(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a file system + * directory. + * @since v10.10.0 + */ + isDirectory(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a block device. + * @since v10.10.0 + */ + isBlockDevice(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a character device. + * @since v10.10.0 + */ + isCharacterDevice(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a symbolic link. + * @since v10.10.0 + */ + isSymbolicLink(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a first-in-first-out + * (FIFO) pipe. + * @since v10.10.0 + */ + isFIFO(): boolean; + /** + * Returns `true` if the `fs.Dirent` object describes a socket. + * @since v10.10.0 + */ + isSocket(): boolean; + /** + * The file name that this `fs.Dirent` object refers to. The type of this + * value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}. + * @since v10.10.0 + */ + name: string; + /** + * The base path that this `fs.Dirent` object refers to. + * @since v20.1.0 + */ + path: string; + } + /** + * A class representing a directory stream. + * + * Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`. + * + * ```js + * import { opendir } from 'node:fs/promises'; + * + * try { + * const dir = await opendir('./'); + * for await (const dirent of dir) + * console.log(dirent.name); + * } catch (err) { + * console.error(err); + * } + * ``` + * + * When using the async iterator, the `fs.Dir` object will be automatically + * closed after the iterator exits. + * @since v12.12.0 + */ + export class Dir implements AsyncIterable { + /** + * The read-only path of this directory as was provided to {@link opendir},{@link opendirSync}, or `fsPromises.opendir()`. + * @since v12.12.0 + */ + readonly path: string; + /** + * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read. + */ + [Symbol.asyncIterator](): AsyncIterableIterator; + /** + * Asynchronously close the directory's underlying resource handle. + * Subsequent reads will result in errors. + * + * A promise is returned that will be resolved after the resource has been + * closed. + * @since v12.12.0 + */ + close(): Promise; + close(cb: NoParamCallback): void; + /** + * Synchronously close the directory's underlying resource handle. + * Subsequent reads will result in errors. + * @since v12.12.0 + */ + closeSync(): void; + /** + * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`. + * + * A promise is returned that will be resolved with an `fs.Dirent`, or `null`if there are no more directory entries to read. + * + * Directory entries returned by this function are in no particular order as + * provided by the operating system's underlying directory mechanisms. + * Entries added or removed while iterating over the directory might not be + * included in the iteration results. + * @since v12.12.0 + * @return containing {fs.Dirent|null} + */ + read(): Promise; + read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void; + /** + * Synchronously read the next directory entry as an `fs.Dirent`. See the + * POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail. + * + * If there are no more directory entries to read, `null` will be returned. + * + * Directory entries returned by this function are in no particular order as + * provided by the operating system's underlying directory mechanisms. + * Entries added or removed while iterating over the directory might not be + * included in the iteration results. + * @since v12.12.0 + */ + readSync(): Dirent | null; + } + /** + * Class: fs.StatWatcher + * @since v14.3.0, v12.20.0 + * Extends `EventEmitter` + * A successful call to {@link watchFile} method will return a new fs.StatWatcher object. + */ + export interface StatWatcher extends EventEmitter { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the `fs.StatWatcher` is active. Calling `watcher.ref()` multiple times will have + * no effect. + * + * By default, all `fs.StatWatcher` objects are "ref'ed", making it normally + * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been + * called previously. + * @since v14.3.0, v12.20.0 + */ + ref(): this; + /** + * When called, the active `fs.StatWatcher` object will not require the Node.js + * event loop to remain active. If there is no other activity keeping the + * event loop running, the process may exit before the `fs.StatWatcher` object's + * callback is invoked. Calling `watcher.unref()` multiple times will have + * no effect. + * @since v14.3.0, v12.20.0 + */ + unref(): this; + } + export interface FSWatcher extends EventEmitter { + /** + * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable. + * @since v0.5.8 + */ + close(): void; + /** + * events.EventEmitter + * 1. change + * 2. error + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + addListener(event: "error", listener: (error: Error) => void): this; + addListener(event: "close", listener: () => void): this; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "close", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + once(event: "error", listener: (error: Error) => void): this; + once(event: "close", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + prependListener(event: "error", listener: (error: Error) => void): this; + prependListener(event: "close", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + prependOnceListener(event: "error", listener: (error: Error) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + } + /** + * Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function. + * @since v0.1.93 + */ + export class ReadStream extends stream.Readable { + close(callback?: (err?: NodeJS.ErrnoException | null) => void): void; + /** + * The number of bytes that have been read so far. + * @since v6.4.0 + */ + bytesRead: number; + /** + * The path to the file the stream is reading from as specified in the first + * argument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a + * `Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`. + * @since v0.1.93 + */ + path: string | Buffer; + /** + * This property is `true` if the underlying file has not been opened yet, + * i.e. before the `'ready'` event is emitted. + * @since v11.2.0, v10.16.0 + */ + pending: boolean; + /** + * events.EventEmitter + * 1. open + * 2. close + * 3. ready + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: Buffer | string) => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "open", listener: (fd: number) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "ready", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: Buffer | string) => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "open", listener: (fd: number) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "readable", listener: () => void): this; + on(event: "ready", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: Buffer | string) => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "open", listener: (fd: number) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "readable", listener: () => void): this; + once(event: "ready", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "open", listener: (fd: number) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "ready", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "open", listener: (fd: number) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "ready", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * * Extends `stream.Writable` + * + * Instances of `fs.WriteStream` are created and returned using the {@link createWriteStream} function. + * @since v0.1.93 + */ + export class WriteStream extends stream.Writable { + /** + * Closes `writeStream`. Optionally accepts a + * callback that will be executed once the `writeStream`is closed. + * @since v0.9.4 + */ + close(callback?: (err?: NodeJS.ErrnoException | null) => void): void; + /** + * The number of bytes written so far. Does not include data that is still queued + * for writing. + * @since v0.4.7 + */ + bytesWritten: number; + /** + * The path to the file the stream is writing to as specified in the first + * argument to {@link createWriteStream}. If `path` is passed as a string, then`writeStream.path` will be a string. If `path` is passed as a `Buffer`, then`writeStream.path` will be a + * `Buffer`. + * @since v0.1.93 + */ + path: string | Buffer; + /** + * This property is `true` if the underlying file has not been opened yet, + * i.e. before the `'ready'` event is emitted. + * @since v11.2.0 + */ + pending: boolean; + /** + * events.EventEmitter + * 1. open + * 2. close + * 3. ready + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "open", listener: (fd: number) => void): this; + addListener(event: "pipe", listener: (src: stream.Readable) => void): this; + addListener(event: "ready", listener: () => void): this; + addListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "open", listener: (fd: number) => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + on(event: "ready", listener: () => void): this; + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "open", listener: (fd: number) => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + once(event: "ready", listener: () => void): this; + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "open", listener: (fd: number) => void): this; + prependListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "ready", listener: () => void): this; + prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "open", listener: (fd: number) => void): this; + prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "ready", listener: () => void): this; + prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * Asynchronously rename file at `oldPath` to the pathname provided + * as `newPath`. In the case that `newPath` already exists, it will + * be overwritten. If there is a directory at `newPath`, an error will + * be raised instead. No arguments other than a possible exception are + * given to the completion callback. + * + * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html). + * + * ```js + * import { rename } from 'node:fs'; + * + * rename('oldFile.txt', 'newFile.txt', (err) => { + * if (err) throw err; + * console.log('Rename complete!'); + * }); + * ``` + * @since v0.0.2 + */ + export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void; + export namespace rename { + /** + * Asynchronous rename(2) - Change the name or location of a file or directory. + * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + */ + function __promisify__(oldPath: PathLike, newPath: PathLike): Promise; + } + /** + * Renames the file from `oldPath` to `newPath`. Returns `undefined`. + * + * See the POSIX [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html) documentation for more details. + * @since v0.1.21 + */ + export function renameSync(oldPath: PathLike, newPath: PathLike): void; + /** + * Truncates the file. No arguments other than a possible exception are + * given to the completion callback. A file descriptor can also be passed as the + * first argument. In this case, `fs.ftruncate()` is called. + * + * ```js + * import { truncate } from 'node:fs'; + * // Assuming that 'path/file.txt' is a regular file. + * truncate('path/file.txt', (err) => { + * if (err) throw err; + * console.log('path/file.txt was truncated'); + * }); + * ``` + * + * Passing a file descriptor is deprecated and may result in an error being thrown + * in the future. + * + * See the POSIX [`truncate(2)`](http://man7.org/linux/man-pages/man2/truncate.2.html) documentation for more details. + * @since v0.8.6 + * @param [len=0] + */ + export function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void; + /** + * Asynchronous truncate(2) - Truncate a file to a specified length. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function truncate(path: PathLike, callback: NoParamCallback): void; + export namespace truncate { + /** + * Asynchronous truncate(2) - Truncate a file to a specified length. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param len If not specified, defaults to `0`. + */ + function __promisify__(path: PathLike, len?: number | null): Promise; + } + /** + * Truncates the file. Returns `undefined`. A file descriptor can also be + * passed as the first argument. In this case, `fs.ftruncateSync()` is called. + * + * Passing a file descriptor is deprecated and may result in an error being thrown + * in the future. + * @since v0.8.6 + * @param [len=0] + */ + export function truncateSync(path: PathLike, len?: number | null): void; + /** + * Truncates the file descriptor. No arguments other than a possible exception are + * given to the completion callback. + * + * See the POSIX [`ftruncate(2)`](http://man7.org/linux/man-pages/man2/ftruncate.2.html) documentation for more detail. + * + * If the file referred to by the file descriptor was larger than `len` bytes, only + * the first `len` bytes will be retained in the file. + * + * For example, the following program retains only the first four bytes of the + * file: + * + * ```js + * import { open, close, ftruncate } from 'node:fs'; + * + * function closeFd(fd) { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * + * open('temp.txt', 'r+', (err, fd) => { + * if (err) throw err; + * + * try { + * ftruncate(fd, 4, (err) => { + * closeFd(fd); + * if (err) throw err; + * }); + * } catch (err) { + * closeFd(fd); + * if (err) throw err; + * } + * }); + * ``` + * + * If the file previously was shorter than `len` bytes, it is extended, and the + * extended part is filled with null bytes (`'\0'`): + * + * If `len` is negative then `0` will be used. + * @since v0.8.6 + * @param [len=0] + */ + export function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void; + /** + * Asynchronous ftruncate(2) - Truncate a file to a specified length. + * @param fd A file descriptor. + */ + export function ftruncate(fd: number, callback: NoParamCallback): void; + export namespace ftruncate { + /** + * Asynchronous ftruncate(2) - Truncate a file to a specified length. + * @param fd A file descriptor. + * @param len If not specified, defaults to `0`. + */ + function __promisify__(fd: number, len?: number | null): Promise; + } + /** + * Truncates the file descriptor. Returns `undefined`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link ftruncate}. + * @since v0.8.6 + * @param [len=0] + */ + export function ftruncateSync(fd: number, len?: number | null): void; + /** + * Asynchronously changes owner and group of a file. No arguments other than a + * possible exception are given to the completion callback. + * + * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail. + * @since v0.1.97 + */ + export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void; + export namespace chown { + /** + * Asynchronous chown(2) - Change ownership of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(path: PathLike, uid: number, gid: number): Promise; + } + /** + * Synchronously changes owner and group of a file. Returns `undefined`. + * This is the synchronous version of {@link chown}. + * + * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail. + * @since v0.1.97 + */ + export function chownSync(path: PathLike, uid: number, gid: number): void; + /** + * Sets the owner of the file. No arguments other than a possible exception are + * given to the completion callback. + * + * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail. + * @since v0.4.7 + */ + export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void; + export namespace fchown { + /** + * Asynchronous fchown(2) - Change ownership of a file. + * @param fd A file descriptor. + */ + function __promisify__(fd: number, uid: number, gid: number): Promise; + } + /** + * Sets the owner of the file. Returns `undefined`. + * + * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail. + * @since v0.4.7 + * @param uid The file's new owner's user id. + * @param gid The file's new group's group id. + */ + export function fchownSync(fd: number, uid: number, gid: number): void; + /** + * Set the owner of the symbolic link. No arguments other than a possible + * exception are given to the completion callback. + * + * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more detail. + */ + export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void; + export namespace lchown { + /** + * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(path: PathLike, uid: number, gid: number): Promise; + } + /** + * Set the owner for the path. Returns `undefined`. + * + * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more details. + * @param uid The file's new owner's user id. + * @param gid The file's new group's group id. + */ + export function lchownSync(path: PathLike, uid: number, gid: number): void; + /** + * Changes the access and modification times of a file in the same way as {@link utimes}, with the difference that if the path refers to a symbolic + * link, then the link is not dereferenced: instead, the timestamps of the + * symbolic link itself are changed. + * + * No arguments other than a possible exception are given to the completion + * callback. + * @since v14.5.0, v12.19.0 + */ + export function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void; + export namespace lutimes { + /** + * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, + * with the difference that if the path refers to a symbolic link, then the link is not + * dereferenced: instead, the timestamps of the symbolic link itself are changed. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param atime The last access time. If a string is provided, it will be coerced to number. + * @param mtime The last modified time. If a string is provided, it will be coerced to number. + */ + function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise; + } + /** + * Change the file system timestamps of the symbolic link referenced by `path`. + * Returns `undefined`, or throws an exception when parameters are incorrect or + * the operation fails. This is the synchronous version of {@link lutimes}. + * @since v14.5.0, v12.19.0 + */ + export function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void; + /** + * Asynchronously changes the permissions of a file. No arguments other than a + * possible exception are given to the completion callback. + * + * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail. + * + * ```js + * import { chmod } from 'node:fs'; + * + * chmod('my_file.txt', 0o775, (err) => { + * if (err) throw err; + * console.log('The permissions for file "my_file.txt" have been changed!'); + * }); + * ``` + * @since v0.1.30 + */ + export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void; + export namespace chmod { + /** + * Asynchronous chmod(2) - Change permissions of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param mode A file mode. If a string is passed, it is parsed as an octal integer. + */ + function __promisify__(path: PathLike, mode: Mode): Promise; + } + /** + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link chmod}. + * + * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail. + * @since v0.6.7 + */ + export function chmodSync(path: PathLike, mode: Mode): void; + /** + * Sets the permissions on the file. No arguments other than a possible exception + * are given to the completion callback. + * + * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail. + * @since v0.4.7 + */ + export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void; + export namespace fchmod { + /** + * Asynchronous fchmod(2) - Change permissions of a file. + * @param fd A file descriptor. + * @param mode A file mode. If a string is passed, it is parsed as an octal integer. + */ + function __promisify__(fd: number, mode: Mode): Promise; + } + /** + * Sets the permissions on the file. Returns `undefined`. + * + * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail. + * @since v0.4.7 + */ + export function fchmodSync(fd: number, mode: Mode): void; + /** + * Changes the permissions on a symbolic link. No arguments other than a possible + * exception are given to the completion callback. + * + * This method is only implemented on macOS. + * + * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail. + * @deprecated Since v0.4.7 + */ + export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void; + /** @deprecated */ + export namespace lchmod { + /** + * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param mode A file mode. If a string is passed, it is parsed as an octal integer. + */ + function __promisify__(path: PathLike, mode: Mode): Promise; + } + /** + * Changes the permissions on a symbolic link. Returns `undefined`. + * + * This method is only implemented on macOS. + * + * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail. + * @deprecated Since v0.4.7 + */ + export function lchmodSync(path: PathLike, mode: Mode): void; + /** + * Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `fs.Stats` object. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * + * {@link stat} follows symbolic links. Use {@link lstat} to look at the + * links themselves. + * + * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. + * Instead, user code should open/read/write the file directly and handle the + * error raised if the file is not available. + * + * To check if a file exists without manipulating it afterwards, {@link access} is recommended. + * + * For example, given the following directory structure: + * + * ```text + * - txtDir + * -- file.txt + * - app.js + * ``` + * + * The next program will check for the stats of the given paths: + * + * ```js + * import { stat } from 'node:fs'; + * + * const pathsToCheck = ['./txtDir', './txtDir/file.txt']; + * + * for (let i = 0; i < pathsToCheck.length; i++) { + * stat(pathsToCheck[i], (err, stats) => { + * console.log(stats.isDirectory()); + * console.log(stats); + * }); + * } + * ``` + * + * The resulting output will resemble: + * + * ```console + * true + * Stats { + * dev: 16777220, + * mode: 16877, + * nlink: 3, + * uid: 501, + * gid: 20, + * rdev: 0, + * blksize: 4096, + * ino: 14214262, + * size: 96, + * blocks: 0, + * atimeMs: 1561174653071.963, + * mtimeMs: 1561174614583.3518, + * ctimeMs: 1561174626623.5366, + * birthtimeMs: 1561174126937.2893, + * atime: 2019-06-22T03:37:33.072Z, + * mtime: 2019-06-22T03:36:54.583Z, + * ctime: 2019-06-22T03:37:06.624Z, + * birthtime: 2019-06-22T03:28:46.937Z + * } + * false + * Stats { + * dev: 16777220, + * mode: 33188, + * nlink: 1, + * uid: 501, + * gid: 20, + * rdev: 0, + * blksize: 4096, + * ino: 14214074, + * size: 8, + * blocks: 8, + * atimeMs: 1561174616618.8555, + * mtimeMs: 1561174614584, + * ctimeMs: 1561174614583.8145, + * birthtimeMs: 1561174007710.7478, + * atime: 2019-06-22T03:36:56.619Z, + * mtime: 2019-06-22T03:36:54.584Z, + * ctime: 2019-06-22T03:36:54.584Z, + * birthtime: 2019-06-22T03:26:47.711Z + * } + * ``` + * @since v0.0.2 + */ + export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + export function stat( + path: PathLike, + options: + | (StatOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void, + ): void; + export function stat( + path: PathLike, + options: StatOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void, + ): void; + export function stat( + path: PathLike, + options: StatOptions | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void, + ): void; + export namespace stat { + /** + * Asynchronous stat(2) - Get file status. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__( + path: PathLike, + options?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function __promisify__( + path: PathLike, + options: StatOptions & { + bigint: true; + }, + ): Promise; + function __promisify__(path: PathLike, options?: StatOptions): Promise; + } + export interface StatSyncFn extends Function { + (path: PathLike, options?: undefined): Stats; + ( + path: PathLike, + options?: StatSyncOptions & { + bigint?: false | undefined; + throwIfNoEntry: false; + }, + ): Stats | undefined; + ( + path: PathLike, + options: StatSyncOptions & { + bigint: true; + throwIfNoEntry: false; + }, + ): BigIntStats | undefined; + ( + path: PathLike, + options?: StatSyncOptions & { + bigint?: false | undefined; + }, + ): Stats; + ( + path: PathLike, + options: StatSyncOptions & { + bigint: true; + }, + ): BigIntStats; + ( + path: PathLike, + options: StatSyncOptions & { + bigint: boolean; + throwIfNoEntry?: false | undefined; + }, + ): Stats | BigIntStats; + (path: PathLike, options?: StatSyncOptions): Stats | BigIntStats | undefined; + } + /** + * Synchronous stat(2) - Get file status. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export const statSync: StatSyncFn; + /** + * Invokes the callback with the `fs.Stats` for the file descriptor. + * + * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail. + * @since v0.1.95 + */ + export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + export function fstat( + fd: number, + options: + | (StatOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void, + ): void; + export function fstat( + fd: number, + options: StatOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void, + ): void; + export function fstat( + fd: number, + options: StatOptions | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void, + ): void; + export namespace fstat { + /** + * Asynchronous fstat(2) - Get file status. + * @param fd A file descriptor. + */ + function __promisify__( + fd: number, + options?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function __promisify__( + fd: number, + options: StatOptions & { + bigint: true; + }, + ): Promise; + function __promisify__(fd: number, options?: StatOptions): Promise; + } + /** + * Retrieves the `fs.Stats` for the file descriptor. + * + * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail. + * @since v0.1.95 + */ + export function fstatSync( + fd: number, + options?: StatOptions & { + bigint?: false | undefined; + }, + ): Stats; + export function fstatSync( + fd: number, + options: StatOptions & { + bigint: true; + }, + ): BigIntStats; + export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats; + /** + * Retrieves the `fs.Stats` for the symbolic link referred to by the path. + * The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic + * link, then the link itself is stat-ed, not the file that it refers to. + * + * See the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details. + * @since v0.1.30 + */ + export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + export function lstat( + path: PathLike, + options: + | (StatOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void, + ): void; + export function lstat( + path: PathLike, + options: StatOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void, + ): void; + export function lstat( + path: PathLike, + options: StatOptions | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void, + ): void; + export namespace lstat { + /** + * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__( + path: PathLike, + options?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function __promisify__( + path: PathLike, + options: StatOptions & { + bigint: true; + }, + ): Promise; + function __promisify__(path: PathLike, options?: StatOptions): Promise; + } + /** + * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which + * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * @since v19.6.0, v18.15.0 + * @param path A path to an existing file or directory on the file system to be queried. + */ + export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void; + export function statfs( + path: PathLike, + options: + | (StatFsOptions & { + bigint?: false | undefined; + }) + | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void, + ): void; + export function statfs( + path: PathLike, + options: StatFsOptions & { + bigint: true; + }, + callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void, + ): void; + export function statfs( + path: PathLike, + options: StatFsOptions | undefined, + callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void, + ): void; + export namespace statfs { + /** + * Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an object. + * @param path A path to an existing file or directory on the file system to be queried. + */ + function __promisify__( + path: PathLike, + options?: StatFsOptions & { + bigint?: false | undefined; + }, + ): Promise; + function __promisify__( + path: PathLike, + options: StatFsOptions & { + bigint: true; + }, + ): Promise; + function __promisify__(path: PathLike, options?: StatFsOptions): Promise; + } + /** + * Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which + * contains `path`. + * + * In case of an error, the `err.code` will be one of `Common System Errors`. + * @since v19.6.0, v18.15.0 + * @param path A path to an existing file or directory on the file system to be queried. + */ + export function statfsSync( + path: PathLike, + options?: StatFsOptions & { + bigint?: false | undefined; + }, + ): StatsFs; + export function statfsSync( + path: PathLike, + options: StatFsOptions & { + bigint: true; + }, + ): BigIntStatsFs; + export function statfsSync(path: PathLike, options?: StatFsOptions): StatsFs | BigIntStatsFs; + /** + * Synchronous lstat(2) - Get file status. Does not dereference symbolic links. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export const lstatSync: StatSyncFn; + /** + * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. No arguments other than + * a possible + * exception are given to the completion callback. + * @since v0.1.31 + */ + export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void; + export namespace link { + /** + * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file. + * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(existingPath: PathLike, newPath: PathLike): Promise; + } + /** + * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. Returns `undefined`. + * @since v0.1.31 + */ + export function linkSync(existingPath: PathLike, newPath: PathLike): void; + /** + * Creates the link called `path` pointing to `target`. No arguments other than a + * possible exception are given to the completion callback. + * + * See the POSIX [`symlink(2)`](http://man7.org/linux/man-pages/man2/symlink.2.html) documentation for more details. + * + * The `type` argument is only available on Windows and ignored on other platforms. + * It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is + * not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`. + * If the `target` does not exist, `'file'` will be used. Windows junction points + * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path. Junction + * points on NTFS volumes can only point to directories. + * + * Relative targets are relative to the link's parent directory. + * + * ```js + * import { symlink } from 'node:fs'; + * + * symlink('./mew', './mewtwo', callback); + * ``` + * + * The above example creates a symbolic link `mewtwo` which points to `mew` in the + * same directory: + * + * ```bash + * $ tree . + * . + * ├── mew + * └── mewtwo -> ./mew + * ``` + * @since v0.1.31 + * @param [type='null'] + */ + export function symlink( + target: PathLike, + path: PathLike, + type: symlink.Type | undefined | null, + callback: NoParamCallback, + ): void; + /** + * Asynchronous symlink(2) - Create a new symbolic link to an existing file. + * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol. + * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol. + */ + export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void; + export namespace symlink { + /** + * Asynchronous symlink(2) - Create a new symbolic link to an existing file. + * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol. + * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol. + * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). + * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. + */ + function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise; + type Type = "dir" | "file" | "junction"; + } + /** + * Returns `undefined`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link symlink}. + * @since v0.1.31 + * @param [type='null'] + */ + export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void; + /** + * Reads the contents of the symbolic link referred to by `path`. The callback gets + * two arguments `(err, linkString)`. + * + * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the link path passed to the callback. If the `encoding` is set to `'buffer'`, + * the link path returned will be passed as a `Buffer` object. + * @since v0.1.31 + */ + export function readlink( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, linkString: string) => void, + ): void; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readlink( + path: PathLike, + options: BufferEncodingOption, + callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void, + ): void; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readlink( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void, + ): void; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function readlink( + path: PathLike, + callback: (err: NodeJS.ErrnoException | null, linkString: string) => void, + ): void; + export namespace readlink { + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options?: EncodingOption): Promise; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options: BufferEncodingOption): Promise; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options?: EncodingOption): Promise; + } + /** + * Returns the symbolic link's string value. + * + * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the link path returned. If the `encoding` is set to `'buffer'`, + * the link path returned will be passed as a `Buffer` object. + * @since v0.1.31 + */ + export function readlinkSync(path: PathLike, options?: EncodingOption): string; + /** + * Synchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer; + /** + * Synchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer; + /** + * Asynchronously computes the canonical pathname by resolving `.`, `..`, and + * symbolic links. + * + * A canonical pathname is not necessarily unique. Hard links and bind mounts can + * expose a file system entity through many pathnames. + * + * This function behaves like [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html), with some exceptions: + * + * 1. No case conversion is performed on case-insensitive file systems. + * 2. The maximum number of symbolic links is platform-independent and generally + * (much) higher than what the native [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html) implementation supports. + * + * The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`to resolve relative paths. + * + * Only paths that can be converted to UTF8 strings are supported. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the path passed to the callback. If the `encoding` is set to `'buffer'`, + * the path returned will be passed as a `Buffer` object. + * + * If `path` resolves to a socket or a pipe, the function will return a system + * dependent name for that object. + * @since v0.1.31 + */ + export function realpath( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void, + ): void; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function realpath( + path: PathLike, + options: BufferEncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void, + ): void; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function realpath( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void, + ): void; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function realpath( + path: PathLike, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void, + ): void; + export namespace realpath { + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options?: EncodingOption): Promise; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options: BufferEncodingOption): Promise; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(path: PathLike, options?: EncodingOption): Promise; + /** + * Asynchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html). + * + * The `callback` gets two arguments `(err, resolvedPath)`. + * + * Only paths that can be converted to UTF8 strings are supported. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the path passed to the callback. If the `encoding` is set to `'buffer'`, + * the path returned will be passed as a `Buffer` object. + * + * On Linux, when Node.js is linked against musl libc, the procfs file system must + * be mounted on `/proc` in order for this function to work. Glibc does not have + * this restriction. + * @since v9.2.0 + */ + function native( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void, + ): void; + function native( + path: PathLike, + options: BufferEncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void, + ): void; + function native( + path: PathLike, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void, + ): void; + function native( + path: PathLike, + callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void, + ): void; + } + /** + * Returns the resolved pathname. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link realpath}. + * @since v0.1.31 + */ + export function realpathSync(path: PathLike, options?: EncodingOption): string; + /** + * Synchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer; + /** + * Synchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function realpathSync(path: PathLike, options?: EncodingOption): string | Buffer; + export namespace realpathSync { + function native(path: PathLike, options?: EncodingOption): string; + function native(path: PathLike, options: BufferEncodingOption): Buffer; + function native(path: PathLike, options?: EncodingOption): string | Buffer; + } + /** + * Asynchronously removes a file or symbolic link. No arguments other than a + * possible exception are given to the completion callback. + * + * ```js + * import { unlink } from 'node:fs'; + * // Assuming that 'path/file.txt' is a regular file. + * unlink('path/file.txt', (err) => { + * if (err) throw err; + * console.log('path/file.txt was deleted'); + * }); + * ``` + * + * `fs.unlink()` will not work on a directory, empty or otherwise. To remove a + * directory, use {@link rmdir}. + * + * See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more details. + * @since v0.0.2 + */ + export function unlink(path: PathLike, callback: NoParamCallback): void; + export namespace unlink { + /** + * Asynchronous unlink(2) - delete a name and possibly the file it refers to. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(path: PathLike): Promise; + } + /** + * Synchronous [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html). Returns `undefined`. + * @since v0.1.21 + */ + export function unlinkSync(path: PathLike): void; + export interface RmDirOptions { + /** + * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or + * `EPERM` error is encountered, Node.js will retry the operation with a linear + * backoff wait of `retryDelay` ms longer on each try. This option represents the + * number of retries. This option is ignored if the `recursive` option is not + * `true`. + * @default 0 + */ + maxRetries?: number | undefined; + /** + * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning + * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file. + * Use `fs.rm(path, { recursive: true, force: true })` instead. + * + * If `true`, perform a recursive directory removal. In + * recursive mode, operations are retried on failure. + * @default false + */ + recursive?: boolean | undefined; + /** + * The amount of time in milliseconds to wait between retries. + * This option is ignored if the `recursive` option is not `true`. + * @default 100 + */ + retryDelay?: number | undefined; + } + /** + * Asynchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). No arguments other than a possible exception are given + * to the completion callback. + * + * Using `fs.rmdir()` on a file (not a directory) results in an `ENOENT` error on + * Windows and an `ENOTDIR` error on POSIX. + * + * To get a behavior similar to the `rm -rf` Unix command, use {@link rm} with options `{ recursive: true, force: true }`. + * @since v0.0.2 + */ + export function rmdir(path: PathLike, callback: NoParamCallback): void; + export function rmdir(path: PathLike, options: RmDirOptions, callback: NoParamCallback): void; + export namespace rmdir { + /** + * Asynchronous rmdir(2) - delete a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + function __promisify__(path: PathLike, options?: RmDirOptions): Promise; + } + /** + * Synchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). Returns `undefined`. + * + * Using `fs.rmdirSync()` on a file (not a directory) results in an `ENOENT` error + * on Windows and an `ENOTDIR` error on POSIX. + * + * To get a behavior similar to the `rm -rf` Unix command, use {@link rmSync} with options `{ recursive: true, force: true }`. + * @since v0.1.21 + */ + export function rmdirSync(path: PathLike, options?: RmDirOptions): void; + export interface RmOptions { + /** + * When `true`, exceptions will be ignored if `path` does not exist. + * @default false + */ + force?: boolean | undefined; + /** + * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or + * `EPERM` error is encountered, Node.js will retry the operation with a linear + * backoff wait of `retryDelay` ms longer on each try. This option represents the + * number of retries. This option is ignored if the `recursive` option is not + * `true`. + * @default 0 + */ + maxRetries?: number | undefined; + /** + * If `true`, perform a recursive directory removal. In + * recursive mode, operations are retried on failure. + * @default false + */ + recursive?: boolean | undefined; + /** + * The amount of time in milliseconds to wait between retries. + * This option is ignored if the `recursive` option is not `true`. + * @default 100 + */ + retryDelay?: number | undefined; + } + /** + * Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the + * completion callback. + * @since v14.14.0 + */ + export function rm(path: PathLike, callback: NoParamCallback): void; + export function rm(path: PathLike, options: RmOptions, callback: NoParamCallback): void; + export namespace rm { + /** + * Asynchronously removes files and directories (modeled on the standard POSIX `rm` utility). + */ + function __promisify__(path: PathLike, options?: RmOptions): Promise; + } + /** + * Synchronously removes files and directories (modeled on the standard POSIX `rm`utility). Returns `undefined`. + * @since v14.14.0 + */ + export function rmSync(path: PathLike, options?: RmOptions): void; + export interface MakeDirectoryOptions { + /** + * Indicates whether parent folders should be created. + * If a folder was created, the path to the first created folder will be returned. + * @default false + */ + recursive?: boolean | undefined; + /** + * A file mode. If a string is passed, it is parsed as an octal integer. If not specified + * @default 0o777 + */ + mode?: Mode | undefined; + } + /** + * Asynchronously creates a directory. + * + * The callback is given a possible exception and, if `recursive` is `true`, the + * first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was + * created (for instance, if it was previously created). + * + * The optional `options` argument can be an integer specifying `mode` (permission + * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that + * exists results in an error only + * when `recursive` is false. If `recursive` is false and the directory exists, + * an `EEXIST` error occurs. + * + * ```js + * import { mkdir } from 'node:fs'; + * + * // Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist. + * mkdir('./tmp/a/apple', { recursive: true }, (err) => { + * if (err) throw err; + * }); + * ``` + * + * On Windows, using `fs.mkdir()` on the root directory even with recursion will + * result in an error: + * + * ```js + * import { mkdir } from 'node:fs'; + * + * mkdir('/', { recursive: true }, (err) => { + * // => [Error: EPERM: operation not permitted, mkdir 'C:\'] + * }); + * ``` + * + * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details. + * @since v0.1.8 + */ + export function mkdir( + path: PathLike, + options: MakeDirectoryOptions & { + recursive: true; + }, + callback: (err: NodeJS.ErrnoException | null, path?: string) => void, + ): void; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + export function mkdir( + path: PathLike, + options: + | Mode + | (MakeDirectoryOptions & { + recursive?: false | undefined; + }) + | null + | undefined, + callback: NoParamCallback, + ): void; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + export function mkdir( + path: PathLike, + options: Mode | MakeDirectoryOptions | null | undefined, + callback: (err: NodeJS.ErrnoException | null, path?: string) => void, + ): void; + /** + * Asynchronous mkdir(2) - create a directory with a mode of `0o777`. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function mkdir(path: PathLike, callback: NoParamCallback): void; + export namespace mkdir { + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function __promisify__( + path: PathLike, + options: MakeDirectoryOptions & { + recursive: true; + }, + ): Promise; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function __promisify__( + path: PathLike, + options?: + | Mode + | (MakeDirectoryOptions & { + recursive?: false | undefined; + }) + | null, + ): Promise; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function __promisify__( + path: PathLike, + options?: Mode | MakeDirectoryOptions | null, + ): Promise; + } + /** + * Synchronously creates a directory. Returns `undefined`, or if `recursive` is`true`, the first directory path created. + * This is the synchronous version of {@link mkdir}. + * + * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details. + * @since v0.1.21 + */ + export function mkdirSync( + path: PathLike, + options: MakeDirectoryOptions & { + recursive: true; + }, + ): string | undefined; + /** + * Synchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + export function mkdirSync( + path: PathLike, + options?: + | Mode + | (MakeDirectoryOptions & { + recursive?: false | undefined; + }) + | null, + ): void; + /** + * Synchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined; + /** + * Creates a unique temporary directory. + * + * Generates six random characters to be appended behind a required`prefix` to create a unique temporary directory. Due to platform + * inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms, + * notably the BSDs, can return more than six random characters, and replace + * trailing `X` characters in `prefix` with random characters. + * + * The created directory path is passed as a string to the callback's second + * parameter. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use. + * + * ```js + * import { mkdtemp } from 'node:fs'; + * import { join } from 'node:path'; + * import { tmpdir } from 'node:os'; + * + * mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => { + * if (err) throw err; + * console.log(directory); + * // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2 + * }); + * ``` + * + * The `fs.mkdtemp()` method will append the six randomly selected characters + * directly to the `prefix` string. For instance, given a directory `/tmp`, if the + * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator + * (`require('node:path').sep`). + * + * ```js + * import { tmpdir } from 'node:os'; + * import { mkdtemp } from 'node:fs'; + * + * // The parent directory for the new temporary directory + * const tmpDir = tmpdir(); + * + * // This method is *INCORRECT*: + * mkdtemp(tmpDir, (err, directory) => { + * if (err) throw err; + * console.log(directory); + * // Will print something similar to `/tmpabc123`. + * // A new temporary directory is created at the file system root + * // rather than *within* the /tmp directory. + * }); + * + * // This method is *CORRECT*: + * import { sep } from 'node:path'; + * mkdtemp(`${tmpDir}${sep}`, (err, directory) => { + * if (err) throw err; + * console.log(directory); + * // Will print something similar to `/tmp/abc123`. + * // A new temporary directory is created within + * // the /tmp directory. + * }); + * ``` + * @since v5.10.0 + */ + export function mkdtemp( + prefix: string, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, folder: string) => void, + ): void; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function mkdtemp( + prefix: string, + options: + | "buffer" + | { + encoding: "buffer"; + }, + callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void, + ): void; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function mkdtemp( + prefix: string, + options: EncodingOption, + callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void, + ): void; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + */ + export function mkdtemp( + prefix: string, + callback: (err: NodeJS.ErrnoException | null, folder: string) => void, + ): void; + export namespace mkdtemp { + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(prefix: string, options?: EncodingOption): Promise; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(prefix: string, options: BufferEncodingOption): Promise; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__(prefix: string, options?: EncodingOption): Promise; + } + /** + * Returns the created directory path. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link mkdtemp}. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use. + * @since v5.10.0 + */ + export function mkdtempSync(prefix: string, options?: EncodingOption): string; + /** + * Synchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer; + /** + * Synchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer; + /** + * Reads the contents of a directory. The callback gets two arguments `(err, files)`where `files` is an array of the names of the files in the directory excluding`'.'` and `'..'`. + * + * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the filenames passed to the callback. If the `encoding` is set to `'buffer'`, + * the filenames returned will be passed as `Buffer` objects. + * + * If `options.withFileTypes` is set to `true`, the `files` array will contain `fs.Dirent` objects. + * @since v0.1.8 + */ + export function readdir( + path: PathLike, + options: + | { + encoding: BufferEncoding | null; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | BufferEncoding + | undefined + | null, + callback: (err: NodeJS.ErrnoException | null, files: string[]) => void, + ): void; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readdir( + path: PathLike, + options: + | { + encoding: "buffer"; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | "buffer", + callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void, + ): void; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readdir( + path: PathLike, + options: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | undefined + | null, + callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void, + ): void; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function readdir( + path: PathLike, + callback: (err: NodeJS.ErrnoException | null, files: string[]) => void, + ): void; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options If called with `withFileTypes: true` the result data will be an array of Dirent. + */ + export function readdir( + path: PathLike, + options: ObjectEncodingOptions & { + withFileTypes: true; + recursive?: boolean | undefined; + }, + callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void, + ): void; + export namespace readdir { + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__( + path: PathLike, + options?: + | { + encoding: BufferEncoding | null; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__( + path: PathLike, + options: + | "buffer" + | { + encoding: "buffer"; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function __promisify__( + path: PathLike, + options?: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options If called with `withFileTypes: true` the result data will be an array of Dirent + */ + function __promisify__( + path: PathLike, + options: ObjectEncodingOptions & { + withFileTypes: true; + recursive?: boolean | undefined; + }, + ): Promise; + } + /** + * Reads the contents of the directory. + * + * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the filenames returned. If the `encoding` is set to `'buffer'`, + * the filenames returned will be passed as `Buffer` objects. + * + * If `options.withFileTypes` is set to `true`, the result will contain `fs.Dirent` objects. + * @since v0.1.21 + */ + export function readdirSync( + path: PathLike, + options?: + | { + encoding: BufferEncoding | null; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | BufferEncoding + | null, + ): string[]; + /** + * Synchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readdirSync( + path: PathLike, + options: + | { + encoding: "buffer"; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | "buffer", + ): Buffer[]; + /** + * Synchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + export function readdirSync( + path: PathLike, + options?: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | null, + ): string[] | Buffer[]; + /** + * Synchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options If called with `withFileTypes: true` the result data will be an array of Dirent. + */ + export function readdirSync( + path: PathLike, + options: ObjectEncodingOptions & { + withFileTypes: true; + recursive?: boolean | undefined; + }, + ): Dirent[]; + /** + * Closes the file descriptor. No arguments other than a possible exception are + * given to the completion callback. + * + * Calling `fs.close()` on any file descriptor (`fd`) that is currently in use + * through any other `fs` operation may lead to undefined behavior. + * + * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail. + * @since v0.0.2 + */ + export function close(fd: number, callback?: NoParamCallback): void; + export namespace close { + /** + * Asynchronous close(2) - close a file descriptor. + * @param fd A file descriptor. + */ + function __promisify__(fd: number): Promise; + } + /** + * Closes the file descriptor. Returns `undefined`. + * + * Calling `fs.closeSync()` on any file descriptor (`fd`) that is currently in use + * through any other `fs` operation may lead to undefined behavior. + * + * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail. + * @since v0.1.21 + */ + export function closeSync(fd: number): void; + /** + * Asynchronous file open. See the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more details. + * + * `mode` sets the file mode (permission and sticky bits), but only if the file was + * created. On Windows, only the write permission can be manipulated; see {@link chmod}. + * + * The callback gets two arguments `(err, fd)`. + * + * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented + * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains + * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams). + * + * Functions based on `fs.open()` exhibit this behavior as well:`fs.writeFile()`, `fs.readFile()`, etc. + * @since v0.0.2 + * @param [flags='r'] See `support of file system `flags``. + * @param [mode=0o666] + */ + export function open( + path: PathLike, + flags: OpenMode | undefined, + mode: Mode | undefined | null, + callback: (err: NodeJS.ErrnoException | null, fd: number) => void, + ): void; + /** + * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param [flags='r'] See `support of file system `flags``. + */ + export function open( + path: PathLike, + flags: OpenMode | undefined, + callback: (err: NodeJS.ErrnoException | null, fd: number) => void, + ): void; + /** + * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + */ + export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; + export namespace open { + /** + * Asynchronous open(2) - open and possibly create a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`. + */ + function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise; + } + /** + * Returns an integer representing the file descriptor. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link open}. + * @since v0.1.21 + * @param [flags='r'] + * @param [mode=0o666] + */ + export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number; + /** + * Change the file system timestamps of the object referenced by `path`. + * + * The `atime` and `mtime` arguments follow these rules: + * + * * Values can be either numbers representing Unix epoch time in seconds,`Date`s, or a numeric string like `'123456789.0'`. + * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown. + * @since v0.4.2 + */ + export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void; + export namespace utimes { + /** + * Asynchronously change file timestamps of the file referenced by the supplied path. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param atime The last access time. If a string is provided, it will be coerced to number. + * @param mtime The last modified time. If a string is provided, it will be coerced to number. + */ + function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise; + } + /** + * Returns `undefined`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link utimes}. + * @since v0.4.2 + */ + export function utimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void; + /** + * Change the file system timestamps of the object referenced by the supplied file + * descriptor. See {@link utimes}. + * @since v0.4.2 + */ + export function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void; + export namespace futimes { + /** + * Asynchronously change file timestamps of the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param atime The last access time. If a string is provided, it will be coerced to number. + * @param mtime The last modified time. If a string is provided, it will be coerced to number. + */ + function __promisify__(fd: number, atime: TimeLike, mtime: TimeLike): Promise; + } + /** + * Synchronous version of {@link futimes}. Returns `undefined`. + * @since v0.4.2 + */ + export function futimesSync(fd: number, atime: TimeLike, mtime: TimeLike): void; + /** + * Request that all data for the open file descriptor is flushed to the storage + * device. The specific implementation is operating system and device specific. + * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. No arguments other + * than a possible exception are given to the completion callback. + * @since v0.1.96 + */ + export function fsync(fd: number, callback: NoParamCallback): void; + export namespace fsync { + /** + * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device. + * @param fd A file descriptor. + */ + function __promisify__(fd: number): Promise; + } + /** + * Request that all data for the open file descriptor is flushed to the storage + * device. The specific implementation is operating system and device specific. + * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. Returns `undefined`. + * @since v0.1.96 + */ + export function fsyncSync(fd: number): void; + /** + * Write `buffer` to the file specified by `fd`. + * + * `offset` determines the part of the buffer to be written, and `length` is + * an integer specifying the number of bytes to write. + * + * `position` refers to the offset from the beginning of the file where this data + * should be written. If `typeof position !== 'number'`, the data will be written + * at the current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html). + * + * The callback will be given three arguments `(err, bytesWritten, buffer)` where`bytesWritten` specifies how many _bytes_ were written from `buffer`. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a promise for an `Object` with `bytesWritten` and `buffer` properties. + * + * It is unsafe to use `fs.write()` multiple times on the same file without waiting + * for the callback. For this scenario, {@link createWriteStream} is + * recommended. + * + * On Linux, positional writes don't work when the file is opened in append mode. + * The kernel ignores the position argument and always appends the data to + * the end of the file. + * @since v0.0.2 + * @param [offset=0] + * @param [length=buffer.byteLength - offset] + * @param [position='null'] + */ + export function write( + fd: number, + buffer: TBuffer, + offset: number | undefined | null, + length: number | undefined | null, + position: number | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, + ): void; + /** + * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param offset The part of the buffer to be written. If not supplied, defaults to `0`. + * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`. + */ + export function write( + fd: number, + buffer: TBuffer, + offset: number | undefined | null, + length: number | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, + ): void; + /** + * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param offset The part of the buffer to be written. If not supplied, defaults to `0`. + */ + export function write( + fd: number, + buffer: TBuffer, + offset: number | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, + ): void; + /** + * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + */ + export function write( + fd: number, + buffer: TBuffer, + callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, + ): void; + /** + * Asynchronously writes `string` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param string A string to write. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + * @param encoding The expected string encoding. + */ + export function write( + fd: number, + string: string, + position: number | undefined | null, + encoding: BufferEncoding | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void, + ): void; + /** + * Asynchronously writes `string` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param string A string to write. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + */ + export function write( + fd: number, + string: string, + position: number | undefined | null, + callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void, + ): void; + /** + * Asynchronously writes `string` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param string A string to write. + */ + export function write( + fd: number, + string: string, + callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void, + ): void; + export namespace write { + /** + * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param offset The part of the buffer to be written. If not supplied, defaults to `0`. + * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + */ + function __promisify__( + fd: number, + buffer?: TBuffer, + offset?: number, + length?: number, + position?: number | null, + ): Promise<{ + bytesWritten: number; + buffer: TBuffer; + }>; + /** + * Asynchronously writes `string` to the file referenced by the supplied file descriptor. + * @param fd A file descriptor. + * @param string A string to write. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + * @param encoding The expected string encoding. + */ + function __promisify__( + fd: number, + string: string, + position?: number | null, + encoding?: BufferEncoding | null, + ): Promise<{ + bytesWritten: number; + buffer: string; + }>; + } + /** + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link write}. + * @since v0.1.21 + * @param [offset=0] + * @param [length=buffer.byteLength - offset] + * @param [position='null'] + * @return The number of bytes written. + */ + export function writeSync( + fd: number, + buffer: NodeJS.ArrayBufferView, + offset?: number | null, + length?: number | null, + position?: number | null, + ): number; + /** + * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written. + * @param fd A file descriptor. + * @param string A string to write. + * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. + * @param encoding The expected string encoding. + */ + export function writeSync( + fd: number, + string: string, + position?: number | null, + encoding?: BufferEncoding | null, + ): number; + export type ReadPosition = number | bigint; + export interface ReadSyncOptions { + /** + * @default 0 + */ + offset?: number | undefined; + /** + * @default `length of buffer` + */ + length?: number | undefined; + /** + * @default null + */ + position?: ReadPosition | null | undefined; + } + export interface ReadAsyncOptions extends ReadSyncOptions { + buffer?: TBuffer; + } + /** + * Read data from the file specified by `fd`. + * + * The callback is given the three arguments, `(err, bytesRead, buffer)`. + * + * If the file is not modified concurrently, the end-of-file is reached when the + * number of bytes read is zero. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a promise for an `Object` with `bytesRead` and `buffer` properties. + * @since v0.0.2 + * @param buffer The buffer that the data will be written to. + * @param offset The position in `buffer` to write the data to. + * @param length The number of bytes to read. + * @param position Specifies where to begin reading from in the file. If `position` is `null` or `-1 `, data will be read from the current file position, and the file position will be updated. If + * `position` is an integer, the file position will be unchanged. + */ + export function read( + fd: number, + buffer: TBuffer, + offset: number, + length: number, + position: ReadPosition | null, + callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void, + ): void; + /** + * Similar to the above `fs.read` function, this version takes an optional `options` object. + * If not otherwise specified in an `options` object, + * `buffer` defaults to `Buffer.alloc(16384)`, + * `offset` defaults to `0`, + * `length` defaults to `buffer.byteLength`, `- offset` as of Node 17.6.0 + * `position` defaults to `null` + * @since v12.17.0, 13.11.0 + */ + export function read( + fd: number, + options: ReadAsyncOptions, + callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void, + ): void; + export function read( + fd: number, + callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void, + ): void; + export namespace read { + /** + * @param fd A file descriptor. + * @param buffer The buffer that the data will be written to. + * @param offset The offset in the buffer at which to start writing. + * @param length The number of bytes to read. + * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position. + */ + function __promisify__( + fd: number, + buffer: TBuffer, + offset: number, + length: number, + position: number | null, + ): Promise<{ + bytesRead: number; + buffer: TBuffer; + }>; + function __promisify__( + fd: number, + options: ReadAsyncOptions, + ): Promise<{ + bytesRead: number; + buffer: TBuffer; + }>; + function __promisify__(fd: number): Promise<{ + bytesRead: number; + buffer: NodeJS.ArrayBufferView; + }>; + } + /** + * Returns the number of `bytesRead`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link read}. + * @since v0.1.21 + * @param [position='null'] + */ + export function readSync( + fd: number, + buffer: NodeJS.ArrayBufferView, + offset: number, + length: number, + position: ReadPosition | null, + ): number; + /** + * Similar to the above `fs.readSync` function, this version takes an optional `options` object. + * If no `options` object is specified, it will default with the above values. + */ + export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number; + /** + * Asynchronously reads the entire contents of a file. + * + * ```js + * import { readFile } from 'node:fs'; + * + * readFile('/etc/passwd', (err, data) => { + * if (err) throw err; + * console.log(data); + * }); + * ``` + * + * The callback is passed two arguments `(err, data)`, where `data` is the + * contents of the file. + * + * If no encoding is specified, then the raw buffer is returned. + * + * If `options` is a string, then it specifies the encoding: + * + * ```js + * import { readFile } from 'node:fs'; + * + * readFile('/etc/passwd', 'utf8', callback); + * ``` + * + * When the path is a directory, the behavior of `fs.readFile()` and {@link readFileSync} is platform-specific. On macOS, Linux, and Windows, an + * error will be returned. On FreeBSD, a representation of the directory's contents + * will be returned. + * + * ```js + * import { readFile } from 'node:fs'; + * + * // macOS, Linux, and Windows + * readFile('', (err, data) => { + * // => [Error: EISDIR: illegal operation on a directory, read ] + * }); + * + * // FreeBSD + * readFile('', (err, data) => { + * // => null, + * }); + * ``` + * + * It is possible to abort an ongoing request using an `AbortSignal`. If a + * request is aborted the callback is called with an `AbortError`: + * + * ```js + * import { readFile } from 'node:fs'; + * + * const controller = new AbortController(); + * const signal = controller.signal; + * readFile(fileInfo[0].name, { signal }, (err, buf) => { + * // ... + * }); + * // When you want to abort the request + * controller.abort(); + * ``` + * + * The `fs.readFile()` function buffers the entire file. To minimize memory costs, + * when possible prefer streaming via `fs.createReadStream()`. + * + * Aborting an ongoing request does not abort individual operating + * system requests but rather the internal buffering `fs.readFile` performs. + * @since v0.1.29 + * @param path filename or file descriptor + */ + export function readFile( + path: PathOrFileDescriptor, + options: + | ({ + encoding?: null | undefined; + flag?: string | undefined; + } & Abortable) + | undefined + | null, + callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void, + ): void; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + export function readFile( + path: PathOrFileDescriptor, + options: + | ({ + encoding: BufferEncoding; + flag?: string | undefined; + } & Abortable) + | BufferEncoding, + callback: (err: NodeJS.ErrnoException | null, data: string) => void, + ): void; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + export function readFile( + path: PathOrFileDescriptor, + options: + | (ObjectEncodingOptions & { + flag?: string | undefined; + } & Abortable) + | BufferEncoding + | undefined + | null, + callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void, + ): void; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + */ + export function readFile( + path: PathOrFileDescriptor, + callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void, + ): void; + export namespace readFile { + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function __promisify__( + path: PathOrFileDescriptor, + options?: { + encoding?: null | undefined; + flag?: string | undefined; + } | null, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function __promisify__( + path: PathOrFileDescriptor, + options: + | { + encoding: BufferEncoding; + flag?: string | undefined; + } + | BufferEncoding, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function __promisify__( + path: PathOrFileDescriptor, + options?: + | (ObjectEncodingOptions & { + flag?: string | undefined; + }) + | BufferEncoding + | null, + ): Promise; + } + /** + * Returns the contents of the `path`. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link readFile}. + * + * If the `encoding` option is specified then this function returns a + * string. Otherwise it returns a buffer. + * + * Similar to {@link readFile}, when the path is a directory, the behavior of`fs.readFileSync()` is platform-specific. + * + * ```js + * import { readFileSync } from 'node:fs'; + * + * // macOS, Linux, and Windows + * readFileSync(''); + * // => [Error: EISDIR: illegal operation on a directory, read ] + * + * // FreeBSD + * readFileSync(''); // => + * ``` + * @since v0.1.8 + * @param path filename or file descriptor + */ + export function readFileSync( + path: PathOrFileDescriptor, + options?: { + encoding?: null | undefined; + flag?: string | undefined; + } | null, + ): Buffer; + /** + * Synchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + export function readFileSync( + path: PathOrFileDescriptor, + options: + | { + encoding: BufferEncoding; + flag?: string | undefined; + } + | BufferEncoding, + ): string; + /** + * Synchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + export function readFileSync( + path: PathOrFileDescriptor, + options?: + | (ObjectEncodingOptions & { + flag?: string | undefined; + }) + | BufferEncoding + | null, + ): string | Buffer; + export type WriteFileOptions = + | ( + & ObjectEncodingOptions + & Abortable + & { + mode?: Mode | undefined; + flag?: string | undefined; + flush?: boolean | undefined; + } + ) + | BufferEncoding + | null; + /** + * When `file` is a filename, asynchronously writes data to the file, replacing the + * file if it already exists. `data` can be a string or a buffer. + * + * When `file` is a file descriptor, the behavior is similar to calling`fs.write()` directly (which is recommended). See the notes below on using + * a file descriptor. + * + * The `encoding` option is ignored if `data` is a buffer. + * + * The `mode` option only affects the newly created file. See {@link open} for more details. + * + * ```js + * import { writeFile } from 'node:fs'; + * import { Buffer } from 'node:buffer'; + * + * const data = new Uint8Array(Buffer.from('Hello Node.js')); + * writeFile('message.txt', data, (err) => { + * if (err) throw err; + * console.log('The file has been saved!'); + * }); + * ``` + * + * If `options` is a string, then it specifies the encoding: + * + * ```js + * import { writeFile } from 'node:fs'; + * + * writeFile('message.txt', 'Hello Node.js', 'utf8', callback); + * ``` + * + * It is unsafe to use `fs.writeFile()` multiple times on the same file without + * waiting for the callback. For this scenario, {@link createWriteStream} is + * recommended. + * + * Similarly to `fs.readFile` \- `fs.writeFile` is a convenience method that + * performs multiple `write` calls internally to write the buffer passed to it. + * For performance sensitive code consider using {@link createWriteStream}. + * + * It is possible to use an `AbortSignal` to cancel an `fs.writeFile()`. + * Cancelation is "best effort", and some amount of data is likely still + * to be written. + * + * ```js + * import { writeFile } from 'node:fs'; + * import { Buffer } from 'node:buffer'; + * + * const controller = new AbortController(); + * const { signal } = controller; + * const data = new Uint8Array(Buffer.from('Hello Node.js')); + * writeFile('message.txt', data, { signal }, (err) => { + * // When a request is aborted - the callback is called with an AbortError + * }); + * // When the request should be aborted + * controller.abort(); + * ``` + * + * Aborting an ongoing request does not abort individual operating + * system requests but rather the internal buffering `fs.writeFile` performs. + * @since v0.1.29 + * @param file filename or file descriptor + */ + export function writeFile( + file: PathOrFileDescriptor, + data: string | NodeJS.ArrayBufferView, + options: WriteFileOptions, + callback: NoParamCallback, + ): void; + /** + * Asynchronously writes data to a file, replacing the file if it already exists. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. + */ + export function writeFile( + path: PathOrFileDescriptor, + data: string | NodeJS.ArrayBufferView, + callback: NoParamCallback, + ): void; + export namespace writeFile { + /** + * Asynchronously writes data to a file, replacing the file if it already exists. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. + * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `mode` is not supplied, the default of `0o666` is used. + * If `mode` is a string, it is parsed as an octal integer. + * If `flag` is not supplied, the default of `'w'` is used. + */ + function __promisify__( + path: PathOrFileDescriptor, + data: string | NodeJS.ArrayBufferView, + options?: WriteFileOptions, + ): Promise; + } + /** + * Returns `undefined`. + * + * The `mode` option only affects the newly created file. See {@link open} for more details. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link writeFile}. + * @since v0.1.29 + * @param file filename or file descriptor + */ + export function writeFileSync( + file: PathOrFileDescriptor, + data: string | NodeJS.ArrayBufferView, + options?: WriteFileOptions, + ): void; + /** + * Asynchronously append data to a file, creating the file if it does not yet + * exist. `data` can be a string or a `Buffer`. + * + * The `mode` option only affects the newly created file. See {@link open} for more details. + * + * ```js + * import { appendFile } from 'node:fs'; + * + * appendFile('message.txt', 'data to append', (err) => { + * if (err) throw err; + * console.log('The "data to append" was appended to file!'); + * }); + * ``` + * + * If `options` is a string, then it specifies the encoding: + * + * ```js + * import { appendFile } from 'node:fs'; + * + * appendFile('message.txt', 'data to append', 'utf8', callback); + * ``` + * + * The `path` may be specified as a numeric file descriptor that has been opened + * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will + * not be closed automatically. + * + * ```js + * import { open, close, appendFile } from 'node:fs'; + * + * function closeFd(fd) { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * + * open('message.txt', 'a', (err, fd) => { + * if (err) throw err; + * + * try { + * appendFile(fd, 'data to append', 'utf8', (err) => { + * closeFd(fd); + * if (err) throw err; + * }); + * } catch (err) { + * closeFd(fd); + * throw err; + * } + * }); + * ``` + * @since v0.6.7 + * @param path filename or file descriptor + */ + export function appendFile( + path: PathOrFileDescriptor, + data: string | Uint8Array, + options: WriteFileOptions, + callback: NoParamCallback, + ): void; + /** + * Asynchronously append data to a file, creating the file if it does not exist. + * @param file A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. + */ + export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void; + export namespace appendFile { + /** + * Asynchronously append data to a file, creating the file if it does not exist. + * @param file A path to a file. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + * If a file descriptor is provided, the underlying file will _not_ be closed automatically. + * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. + * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `mode` is not supplied, the default of `0o666` is used. + * If `mode` is a string, it is parsed as an octal integer. + * If `flag` is not supplied, the default of `'a'` is used. + */ + function __promisify__( + file: PathOrFileDescriptor, + data: string | Uint8Array, + options?: WriteFileOptions, + ): Promise; + } + /** + * Synchronously append data to a file, creating the file if it does not yet + * exist. `data` can be a string or a `Buffer`. + * + * The `mode` option only affects the newly created file. See {@link open} for more details. + * + * ```js + * import { appendFileSync } from 'node:fs'; + * + * try { + * appendFileSync('message.txt', 'data to append'); + * console.log('The "data to append" was appended to file!'); + * } catch (err) { + * // Handle the error + * } + * ``` + * + * If `options` is a string, then it specifies the encoding: + * + * ```js + * import { appendFileSync } from 'node:fs'; + * + * appendFileSync('message.txt', 'data to append', 'utf8'); + * ``` + * + * The `path` may be specified as a numeric file descriptor that has been opened + * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will + * not be closed automatically. + * + * ```js + * import { openSync, closeSync, appendFileSync } from 'node:fs'; + * + * let fd; + * + * try { + * fd = openSync('message.txt', 'a'); + * appendFileSync(fd, 'data to append', 'utf8'); + * } catch (err) { + * // Handle the error + * } finally { + * if (fd !== undefined) + * closeSync(fd); + * } + * ``` + * @since v0.6.7 + * @param path filename or file descriptor + */ + export function appendFileSync( + path: PathOrFileDescriptor, + data: string | Uint8Array, + options?: WriteFileOptions, + ): void; + /** + * Watch for changes on `filename`. The callback `listener` will be called each + * time the file is accessed. + * + * The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates + * whether the process should continue to run as long as files are being watched. + * The `options` object may specify an `interval` property indicating how often the + * target should be polled in milliseconds. + * + * The `listener` gets two arguments the current stat object and the previous + * stat object: + * + * ```js + * import { watchFile } from 'fs'; + * + * watchFile('message.text', (curr, prev) => { + * console.log(`the current mtime is: ${curr.mtime}`); + * console.log(`the previous mtime was: ${prev.mtime}`); + * }); + * ``` + * + * These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`, + * the numeric values in these objects are specified as `BigInt`s. + * + * To be notified when the file was modified, not just accessed, it is necessary + * to compare `curr.mtimeMs` and `prev.mtimeMs`. + * + * When an `fs.watchFile` operation results in an `ENOENT` error, it + * will invoke the listener once, with all the fields zeroed (or, for dates, the + * Unix Epoch). If the file is created later on, the listener will be called + * again, with the latest stat objects. This is a change in functionality since + * v0.10. + * + * Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible. + * + * When a file being watched by `fs.watchFile()` disappears and reappears, + * then the contents of `previous` in the second callback event (the file's + * reappearance) will be the same as the contents of `previous` in the first + * callback event (its disappearance). + * + * This happens when: + * + * * the file is deleted, followed by a restore + * * the file is renamed and then renamed a second time back to its original name + * @since v0.1.31 + */ + export interface WatchFileOptions { + bigint?: boolean | undefined; + persistent?: boolean | undefined; + interval?: number | undefined; + } + /** + * Watch for changes on `filename`. The callback `listener` will be called each + * time the file is accessed. + * + * The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates + * whether the process should continue to run as long as files are being watched. + * The `options` object may specify an `interval` property indicating how often the + * target should be polled in milliseconds. + * + * The `listener` gets two arguments the current stat object and the previous + * stat object: + * + * ```js + * import { watchFile } from 'node:fs'; + * + * watchFile('message.text', (curr, prev) => { + * console.log(`the current mtime is: ${curr.mtime}`); + * console.log(`the previous mtime was: ${prev.mtime}`); + * }); + * ``` + * + * These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`, + * the numeric values in these objects are specified as `BigInt`s. + * + * To be notified when the file was modified, not just accessed, it is necessary + * to compare `curr.mtimeMs` and `prev.mtimeMs`. + * + * When an `fs.watchFile` operation results in an `ENOENT` error, it + * will invoke the listener once, with all the fields zeroed (or, for dates, the + * Unix Epoch). If the file is created later on, the listener will be called + * again, with the latest stat objects. This is a change in functionality since + * v0.10. + * + * Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible. + * + * When a file being watched by `fs.watchFile()` disappears and reappears, + * then the contents of `previous` in the second callback event (the file's + * reappearance) will be the same as the contents of `previous` in the first + * callback event (its disappearance). + * + * This happens when: + * + * * the file is deleted, followed by a restore + * * the file is renamed and then renamed a second time back to its original name + * @since v0.1.31 + */ + export function watchFile( + filename: PathLike, + options: + | (WatchFileOptions & { + bigint?: false | undefined; + }) + | undefined, + listener: StatsListener, + ): StatWatcher; + export function watchFile( + filename: PathLike, + options: + | (WatchFileOptions & { + bigint: true; + }) + | undefined, + listener: BigIntStatsListener, + ): StatWatcher; + /** + * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + export function watchFile(filename: PathLike, listener: StatsListener): StatWatcher; + /** + * Stop watching for changes on `filename`. If `listener` is specified, only that + * particular listener is removed. Otherwise, _all_ listeners are removed, + * effectively stopping watching of `filename`. + * + * Calling `fs.unwatchFile()` with a filename that is not being watched is a + * no-op, not an error. + * + * Using {@link watch} is more efficient than `fs.watchFile()` and`fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()`and `fs.unwatchFile()` when possible. + * @since v0.1.31 + * @param listener Optional, a listener previously attached using `fs.watchFile()` + */ + export function unwatchFile(filename: PathLike, listener?: StatsListener): void; + export function unwatchFile(filename: PathLike, listener?: BigIntStatsListener): void; + export interface WatchOptions extends Abortable { + encoding?: BufferEncoding | "buffer" | undefined; + persistent?: boolean | undefined; + recursive?: boolean | undefined; + } + export type WatchEventType = "rename" | "change"; + export type WatchListener = (event: WatchEventType, filename: T | null) => void; + export type StatsListener = (curr: Stats, prev: Stats) => void; + export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void; + /** + * Watch for changes on `filename`, where `filename` is either a file or a + * directory. + * + * The second argument is optional. If `options` is provided as a string, it + * specifies the `encoding`. Otherwise `options` should be passed as an object. + * + * The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'` or `'change'`, and `filename` is the name of the file + * which triggered the event. + * + * On most platforms, `'rename'` is emitted whenever a filename appears or + * disappears in the directory. + * + * The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`. + * + * If a `signal` is passed, aborting the corresponding AbortController will close + * the returned `fs.FSWatcher`. + * @since v0.5.10 + * @param listener + */ + export function watch( + filename: PathLike, + options: + | (WatchOptions & { + encoding: "buffer"; + }) + | "buffer", + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + export function watch( + filename: PathLike, + options?: WatchOptions | BufferEncoding | null, + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + export function watch( + filename: PathLike, + options: WatchOptions | string, + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + export function watch(filename: PathLike, listener?: WatchListener): FSWatcher; + /** + * Test whether or not the given path exists by checking with the file system. + * Then call the `callback` argument with either true or false: + * + * ```js + * import { exists } from 'node:fs'; + * + * exists('/etc/passwd', (e) => { + * console.log(e ? 'it exists' : 'no passwd!'); + * }); + * ``` + * + * **The parameters for this callback are not consistent with other Node.js** + * **callbacks.** Normally, the first parameter to a Node.js callback is an `err`parameter, optionally followed by other parameters. The `fs.exists()` callback + * has only one boolean parameter. This is one reason `fs.access()` is recommended + * instead of `fs.exists()`. + * + * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing + * so introduces a race condition, since other processes may change the file's + * state between the two calls. Instead, user code should open/read/write the + * file directly and handle the error raised if the file does not exist. + * + * **write (NOT RECOMMENDED)** + * + * ```js + * import { exists, open, close } from 'node:fs'; + * + * exists('myfile', (e) => { + * if (e) { + * console.error('myfile already exists'); + * } else { + * open('myfile', 'wx', (err, fd) => { + * if (err) throw err; + * + * try { + * writeMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * } + * }); + * ``` + * + * **write (RECOMMENDED)** + * + * ```js + * import { open, close } from 'node:fs'; + * open('myfile', 'wx', (err, fd) => { + * if (err) { + * if (err.code === 'EEXIST') { + * console.error('myfile already exists'); + * return; + * } + * + * throw err; + * } + * + * try { + * writeMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * ``` + * + * **read (NOT RECOMMENDED)** + * + * ```js + * import { open, close, exists } from 'node:fs'; + * + * exists('myfile', (e) => { + * if (e) { + * open('myfile', 'r', (err, fd) => { + * if (err) throw err; + * + * try { + * readMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * } else { + * console.error('myfile does not exist'); + * } + * }); + * ``` + * + * **read (RECOMMENDED)** + * + * ```js + * import { open, close } from 'node:fs'; + * + * open('myfile', 'r', (err, fd) => { + * if (err) { + * if (err.code === 'ENOENT') { + * console.error('myfile does not exist'); + * return; + * } + * + * throw err; + * } + * + * try { + * readMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * ``` + * + * The "not recommended" examples above check for existence and then use the + * file; the "recommended" examples are better because they use the file directly + * and handle the error, if any. + * + * In general, check for the existence of a file only if the file won't be + * used directly, for example when its existence is a signal from another + * process. + * @since v0.0.2 + * @deprecated Since v1.0.0 - Use {@link stat} or {@link access} instead. + */ + export function exists(path: PathLike, callback: (exists: boolean) => void): void; + /** @deprecated */ + export namespace exists { + /** + * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + */ + function __promisify__(path: PathLike): Promise; + } + /** + * Returns `true` if the path exists, `false` otherwise. + * + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link exists}. + * + * `fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback`parameter to `fs.exists()` accepts parameters that are inconsistent with other + * Node.js callbacks. `fs.existsSync()` does not use a callback. + * + * ```js + * import { existsSync } from 'node:fs'; + * + * if (existsSync('/etc/passwd')) + * console.log('The path exists.'); + * ``` + * @since v0.1.21 + */ + export function existsSync(path: PathLike): boolean; + export namespace constants { + // File Access Constants + /** Constant for fs.access(). File is visible to the calling process. */ + const F_OK: number; + /** Constant for fs.access(). File can be read by the calling process. */ + const R_OK: number; + /** Constant for fs.access(). File can be written by the calling process. */ + const W_OK: number; + /** Constant for fs.access(). File can be executed by the calling process. */ + const X_OK: number; + // File Copy Constants + /** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */ + const COPYFILE_EXCL: number; + /** + * Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink. + * If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used. + */ + const COPYFILE_FICLONE: number; + /** + * Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink. + * If the underlying platform does not support copy-on-write, then the operation will fail with an error. + */ + const COPYFILE_FICLONE_FORCE: number; + // File Open Constants + /** Constant for fs.open(). Flag indicating to open a file for read-only access. */ + const O_RDONLY: number; + /** Constant for fs.open(). Flag indicating to open a file for write-only access. */ + const O_WRONLY: number; + /** Constant for fs.open(). Flag indicating to open a file for read-write access. */ + const O_RDWR: number; + /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */ + const O_CREAT: number; + /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */ + const O_EXCL: number; + /** + * Constant for fs.open(). Flag indicating that if path identifies a terminal device, + * opening the path shall not cause that terminal to become the controlling terminal for the process + * (if the process does not already have one). + */ + const O_NOCTTY: number; + /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */ + const O_TRUNC: number; + /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */ + const O_APPEND: number; + /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */ + const O_DIRECTORY: number; + /** + * constant for fs.open(). + * Flag indicating reading accesses to the file system will no longer result in + * an update to the atime information associated with the file. + * This flag is available on Linux operating systems only. + */ + const O_NOATIME: number; + /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */ + const O_NOFOLLOW: number; + /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */ + const O_SYNC: number; + /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */ + const O_DSYNC: number; + /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */ + const O_SYMLINK: number; + /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */ + const O_DIRECT: number; + /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */ + const O_NONBLOCK: number; + // File Type Constants + /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */ + const S_IFMT: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */ + const S_IFREG: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */ + const S_IFDIR: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */ + const S_IFCHR: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */ + const S_IFBLK: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */ + const S_IFIFO: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */ + const S_IFLNK: number; + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */ + const S_IFSOCK: number; + // File Mode Constants + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */ + const S_IRWXU: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */ + const S_IRUSR: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */ + const S_IWUSR: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */ + const S_IXUSR: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */ + const S_IRWXG: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */ + const S_IRGRP: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */ + const S_IWGRP: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */ + const S_IXGRP: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */ + const S_IRWXO: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */ + const S_IROTH: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */ + const S_IWOTH: number; + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */ + const S_IXOTH: number; + /** + * When set, a memory file mapping is used to access the file. This flag + * is available on Windows operating systems only. On other operating systems, + * this flag is ignored. + */ + const UV_FS_O_FILEMAP: number; + } + /** + * Tests a user's permissions for the file or directory specified by `path`. + * The `mode` argument is an optional integer that specifies the accessibility + * checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK` + * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for + * possible values of `mode`. + * + * The final argument, `callback`, is a callback function that is invoked with + * a possible error argument. If any of the accessibility checks fail, the error + * argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable. + * + * ```js + * import { access, constants } from 'node:fs'; + * + * const file = 'package.json'; + * + * // Check if the file exists in the current directory. + * access(file, constants.F_OK, (err) => { + * console.log(`${file} ${err ? 'does not exist' : 'exists'}`); + * }); + * + * // Check if the file is readable. + * access(file, constants.R_OK, (err) => { + * console.log(`${file} ${err ? 'is not readable' : 'is readable'}`); + * }); + * + * // Check if the file is writable. + * access(file, constants.W_OK, (err) => { + * console.log(`${file} ${err ? 'is not writable' : 'is writable'}`); + * }); + * + * // Check if the file is readable and writable. + * access(file, constants.R_OK | constants.W_OK, (err) => { + * console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`); + * }); + * ``` + * + * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing + * so introduces a race condition, since other processes may change the file's + * state between the two calls. Instead, user code should open/read/write the + * file directly and handle the error raised if the file is not accessible. + * + * **write (NOT RECOMMENDED)** + * + * ```js + * import { access, open, close } from 'node:fs'; + * + * access('myfile', (err) => { + * if (!err) { + * console.error('myfile already exists'); + * return; + * } + * + * open('myfile', 'wx', (err, fd) => { + * if (err) throw err; + * + * try { + * writeMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * }); + * ``` + * + * **write (RECOMMENDED)** + * + * ```js + * import { open, close } from 'node:fs'; + * + * open('myfile', 'wx', (err, fd) => { + * if (err) { + * if (err.code === 'EEXIST') { + * console.error('myfile already exists'); + * return; + * } + * + * throw err; + * } + * + * try { + * writeMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * ``` + * + * **read (NOT RECOMMENDED)** + * + * ```js + * import { access, open, close } from 'node:fs'; + * access('myfile', (err) => { + * if (err) { + * if (err.code === 'ENOENT') { + * console.error('myfile does not exist'); + * return; + * } + * + * throw err; + * } + * + * open('myfile', 'r', (err, fd) => { + * if (err) throw err; + * + * try { + * readMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * }); + * ``` + * + * **read (RECOMMENDED)** + * + * ```js + * import { open, close } from 'node:fs'; + * + * open('myfile', 'r', (err, fd) => { + * if (err) { + * if (err.code === 'ENOENT') { + * console.error('myfile does not exist'); + * return; + * } + * + * throw err; + * } + * + * try { + * readMyData(fd); + * } finally { + * close(fd, (err) => { + * if (err) throw err; + * }); + * } + * }); + * ``` + * + * The "not recommended" examples above check for accessibility and then use the + * file; the "recommended" examples are better because they use the file directly + * and handle the error, if any. + * + * In general, check for the accessibility of a file only if the file will not be + * used directly, for example when its accessibility is a signal from another + * process. + * + * On Windows, access-control policies (ACLs) on a directory may limit access to + * a file or directory. The `fs.access()` function, however, does not check the + * ACL and therefore may report that a path is accessible even if the ACL restricts + * the user from reading or writing to it. + * @since v0.11.15 + * @param [mode=fs.constants.F_OK] + */ + export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void; + /** + * Asynchronously tests a user's permissions for the file specified by path. + * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + export function access(path: PathLike, callback: NoParamCallback): void; + export namespace access { + /** + * Asynchronously tests a user's permissions for the file specified by path. + * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * URL support is _experimental_. + */ + function __promisify__(path: PathLike, mode?: number): Promise; + } + /** + * Synchronously tests a user's permissions for the file or directory specified + * by `path`. The `mode` argument is an optional integer that specifies the + * accessibility checks to be performed. `mode` should be either the value`fs.constants.F_OK` or a mask consisting of the bitwise OR of any of`fs.constants.R_OK`, `fs.constants.W_OK`, and + * `fs.constants.X_OK` (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for + * possible values of `mode`. + * + * If any of the accessibility checks fail, an `Error` will be thrown. Otherwise, + * the method will return `undefined`. + * + * ```js + * import { accessSync, constants } from 'node:fs'; + * + * try { + * accessSync('etc/passwd', constants.R_OK | constants.W_OK); + * console.log('can read/write'); + * } catch (err) { + * console.error('no access!'); + * } + * ``` + * @since v0.11.15 + * @param [mode=fs.constants.F_OK] + */ + export function accessSync(path: PathLike, mode?: number): void; + interface StreamOptions { + flags?: string | undefined; + encoding?: BufferEncoding | undefined; + fd?: number | promises.FileHandle | undefined; + mode?: number | undefined; + autoClose?: boolean | undefined; + emitClose?: boolean | undefined; + start?: number | undefined; + signal?: AbortSignal | null | undefined; + highWaterMark?: number | undefined; + } + interface FSImplementation { + open?: (...args: any[]) => any; + close?: (...args: any[]) => any; + } + interface CreateReadStreamFSImplementation extends FSImplementation { + read: (...args: any[]) => any; + } + interface CreateWriteStreamFSImplementation extends FSImplementation { + write: (...args: any[]) => any; + writev?: (...args: any[]) => any; + } + interface ReadStreamOptions extends StreamOptions { + fs?: CreateReadStreamFSImplementation | null | undefined; + end?: number | undefined; + } + interface WriteStreamOptions extends StreamOptions { + fs?: CreateWriteStreamFSImplementation | null | undefined; + flush?: boolean | undefined; + } + /** + * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream + * returned by this method has a default `highWaterMark` of 64 KiB. + * + * `options` can include `start` and `end` values to read a range of bytes from + * the file instead of the entire file. Both `start` and `end` are inclusive and + * start counting at 0, allowed values are in the + * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `fd` is specified and `start` is + * omitted or `undefined`, `fs.createReadStream()` reads sequentially from the + * current file position. The `encoding` can be any one of those accepted by `Buffer`. + * + * If `fd` is specified, `ReadStream` will ignore the `path` argument and will use + * the specified file descriptor. This means that no `'open'` event will be + * emitted. `fd` should be blocking; non-blocking `fd`s should be passed to `net.Socket`. + * + * If `fd` points to a character device that only supports blocking reads + * (such as keyboard or sound card), read operations do not finish until data is + * available. This can prevent the process from exiting and the stream from + * closing naturally. + * + * By default, the stream will emit a `'close'` event after it has been + * destroyed. Set the `emitClose` option to `false` to change this behavior. + * + * By providing the `fs` option, it is possible to override the corresponding `fs`implementations for `open`, `read`, and `close`. When providing the `fs` option, + * an override for `read` is required. If no `fd` is provided, an override for`open` is also required. If `autoClose` is `true`, an override for `close` is + * also required. + * + * ```js + * import { createReadStream } from 'node:fs'; + * + * // Create a stream from some character device. + * const stream = createReadStream('/dev/input/event0'); + * setTimeout(() => { + * stream.close(); // This may not close the stream. + * // Artificially marking end-of-stream, as if the underlying resource had + * // indicated end-of-file by itself, allows the stream to close. + * // This does not cancel pending read operations, and if there is such an + * // operation, the process may still not be able to exit successfully + * // until it finishes. + * stream.push(null); + * stream.read(0); + * }, 100); + * ``` + * + * If `autoClose` is false, then the file descriptor won't be closed, even if + * there's an error. It is the application's responsibility to close it and make + * sure there's no file descriptor leak. If `autoClose` is set to true (default + * behavior), on `'error'` or `'end'` the file descriptor will be closed + * automatically. + * + * `mode` sets the file mode (permission and sticky bits), but only if the + * file was created. + * + * An example to read the last 10 bytes of a file which is 100 bytes long: + * + * ```js + * import { createReadStream } from 'node:fs'; + * + * createReadStream('sample.txt', { start: 90, end: 99 }); + * ``` + * + * If `options` is a string, then it specifies the encoding. + * @since v0.1.31 + */ + export function createReadStream(path: PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream; + /** + * `options` may also include a `start` option to allow writing data at some + * position past the beginning of the file, allowed values are in the + * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than + * replacing it may require the `flags` option to be set to `r+` rather than the + * default `w`. The `encoding` can be any one of those accepted by `Buffer`. + * + * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false, + * then the file descriptor won't be closed, even if there's an error. + * It is the application's responsibility to close it and make sure there's no + * file descriptor leak. + * + * By default, the stream will emit a `'close'` event after it has been + * destroyed. Set the `emitClose` option to `false` to change this behavior. + * + * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev`, and `close`. Overriding `write()`without `writev()` can reduce + * performance as some optimizations (`_writev()`) + * will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override + * for `open` is also required. If `autoClose` is `true`, an override for `close`is also required. + * + * Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the`path` argument and will use the specified file descriptor. This means that no`'open'` event will be + * emitted. `fd` should be blocking; non-blocking `fd`s + * should be passed to `net.Socket`. + * + * If `options` is a string, then it specifies the encoding. + * @since v0.1.31 + */ + export function createWriteStream(path: PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream; + /** + * Forces all currently queued I/O operations associated with the file to the + * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. No arguments other + * than a possible + * exception are given to the completion callback. + * @since v0.1.96 + */ + export function fdatasync(fd: number, callback: NoParamCallback): void; + export namespace fdatasync { + /** + * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device. + * @param fd A file descriptor. + */ + function __promisify__(fd: number): Promise; + } + /** + * Forces all currently queued I/O operations associated with the file to the + * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. Returns `undefined`. + * @since v0.1.96 + */ + export function fdatasyncSync(fd: number): void; + /** + * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it + * already exists. No arguments other than a possible exception are given to the + * callback function. Node.js makes no guarantees about the atomicity of the copy + * operation. If an error occurs after the destination file has been opened for + * writing, Node.js will attempt to remove the destination. + * + * `mode` is an optional integer that specifies the behavior + * of the copy operation. It is possible to create a mask consisting of the bitwise + * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`). + * + * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already + * exists. + * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a + * copy-on-write reflink. If the platform does not support copy-on-write, then a + * fallback copy mechanism is used. + * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to + * create a copy-on-write reflink. If the platform does not support + * copy-on-write, then the operation will fail. + * + * ```js + * import { copyFile, constants } from 'node:fs'; + * + * function callback(err) { + * if (err) throw err; + * console.log('source.txt was copied to destination.txt'); + * } + * + * // destination.txt will be created or overwritten by default. + * copyFile('source.txt', 'destination.txt', callback); + * + * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists. + * copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback); + * ``` + * @since v8.5.0 + * @param src source filename to copy + * @param dest destination filename of the copy operation + * @param [mode=0] modifiers for copy operation. + */ + export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void; + export function copyFile(src: PathLike, dest: PathLike, mode: number, callback: NoParamCallback): void; + export namespace copyFile { + function __promisify__(src: PathLike, dst: PathLike, mode?: number): Promise; + } + /** + * Synchronously copies `src` to `dest`. By default, `dest` is overwritten if it + * already exists. Returns `undefined`. Node.js makes no guarantees about the + * atomicity of the copy operation. If an error occurs after the destination file + * has been opened for writing, Node.js will attempt to remove the destination. + * + * `mode` is an optional integer that specifies the behavior + * of the copy operation. It is possible to create a mask consisting of the bitwise + * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`). + * + * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already + * exists. + * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a + * copy-on-write reflink. If the platform does not support copy-on-write, then a + * fallback copy mechanism is used. + * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to + * create a copy-on-write reflink. If the platform does not support + * copy-on-write, then the operation will fail. + * + * ```js + * import { copyFileSync, constants } from 'node:fs'; + * + * // destination.txt will be created or overwritten by default. + * copyFileSync('source.txt', 'destination.txt'); + * console.log('source.txt was copied to destination.txt'); + * + * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists. + * copyFileSync('source.txt', 'destination.txt', constants.COPYFILE_EXCL); + * ``` + * @since v8.5.0 + * @param src source filename to copy + * @param dest destination filename of the copy operation + * @param [mode=0] modifiers for copy operation. + */ + export function copyFileSync(src: PathLike, dest: PathLike, mode?: number): void; + /** + * Write an array of `ArrayBufferView`s to the file specified by `fd` using`writev()`. + * + * `position` is the offset from the beginning of the file where this data + * should be written. If `typeof position !== 'number'`, the data will be written + * at the current position. + * + * The callback will be given three arguments: `err`, `bytesWritten`, and`buffers`. `bytesWritten` is how many bytes were written from `buffers`. + * + * If this method is `util.promisify()` ed, it returns a promise for an`Object` with `bytesWritten` and `buffers` properties. + * + * It is unsafe to use `fs.writev()` multiple times on the same file without + * waiting for the callback. For this scenario, use {@link createWriteStream}. + * + * On Linux, positional writes don't work when the file is opened in append mode. + * The kernel ignores the position argument and always appends the data to + * the end of the file. + * @since v12.9.0 + * @param [position='null'] + */ + export function writev( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void, + ): void; + export function writev( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + position: number, + cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void, + ): void; + export interface WriteVResult { + bytesWritten: number; + buffers: NodeJS.ArrayBufferView[]; + } + export namespace writev { + function __promisify__( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + position?: number, + ): Promise; + } + /** + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link writev}. + * @since v12.9.0 + * @param [position='null'] + * @return The number of bytes written. + */ + export function writevSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number; + /** + * Read from a file specified by `fd` and write to an array of `ArrayBufferView`s + * using `readv()`. + * + * `position` is the offset from the beginning of the file from where data + * should be read. If `typeof position !== 'number'`, the data will be read + * from the current position. + * + * The callback will be given three arguments: `err`, `bytesRead`, and`buffers`. `bytesRead` is how many bytes were read from the file. + * + * If this method is invoked as its `util.promisify()` ed version, it returns + * a promise for an `Object` with `bytesRead` and `buffers` properties. + * @since v13.13.0, v12.17.0 + * @param [position='null'] + */ + export function readv( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void, + ): void; + export function readv( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + position: number, + cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void, + ): void; + export interface ReadVResult { + bytesRead: number; + buffers: NodeJS.ArrayBufferView[]; + } + export namespace readv { + function __promisify__( + fd: number, + buffers: readonly NodeJS.ArrayBufferView[], + position?: number, + ): Promise; + } + /** + * For detailed information, see the documentation of the asynchronous version of + * this API: {@link readv}. + * @since v13.13.0, v12.17.0 + * @param [position='null'] + * @return The number of bytes read. + */ + export function readvSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number; + + export interface OpenAsBlobOptions { + /** + * An optional mime type for the blob. + * + * @default 'undefined' + */ + type?: string | undefined; + } + + /** + * Returns a `Blob` whose data is backed by the given file. + * + * The file must not be modified after the `Blob` is created. Any modifications + * will cause reading the `Blob` data to fail with a `DOMException` error. + * Synchronous stat operations on the file when the `Blob` is created, and before + * each read in order to detect whether the file data has been modified on disk. + * + * ```js + * import { openAsBlob } from 'node:fs'; + * + * const blob = await openAsBlob('the.file.txt'); + * const ab = await blob.arrayBuffer(); + * blob.stream(); + * ``` + * @since v19.8.0 + * @experimental + */ + export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise; + + export interface OpenDirOptions { + /** + * @default 'utf8' + */ + encoding?: BufferEncoding | undefined; + /** + * Number of directory entries that are buffered + * internally when reading from the directory. Higher values lead to better + * performance but higher memory usage. + * @default 32 + */ + bufferSize?: number | undefined; + /** + * @default false + */ + recursive?: boolean; + } + /** + * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html). + * + * Creates an `fs.Dir`, which contains all further functions for reading from + * and cleaning up the directory. + * + * The `encoding` option sets the encoding for the `path` while opening the + * directory and subsequent read operations. + * @since v12.12.0 + */ + export function opendirSync(path: PathLike, options?: OpenDirOptions): Dir; + /** + * Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for + * more details. + * + * Creates an `fs.Dir`, which contains all further functions for reading from + * and cleaning up the directory. + * + * The `encoding` option sets the encoding for the `path` while opening the + * directory and subsequent read operations. + * @since v12.12.0 + */ + export function opendir(path: PathLike, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void; + export function opendir( + path: PathLike, + options: OpenDirOptions, + cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void, + ): void; + export namespace opendir { + function __promisify__(path: PathLike, options?: OpenDirOptions): Promise; + } + export interface BigIntStats extends StatsBase { + atimeNs: bigint; + mtimeNs: bigint; + ctimeNs: bigint; + birthtimeNs: bigint; + } + export interface BigIntOptions { + bigint: true; + } + export interface StatOptions { + bigint?: boolean | undefined; + } + export interface StatSyncOptions extends StatOptions { + throwIfNoEntry?: boolean | undefined; + } + interface CopyOptionsBase { + /** + * Dereference symlinks + * @default false + */ + dereference?: boolean; + /** + * When `force` is `false`, and the destination + * exists, throw an error. + * @default false + */ + errorOnExist?: boolean; + /** + * Overwrite existing file or directory. _The copy + * operation will ignore errors if you set this to false and the destination + * exists. Use the `errorOnExist` option to change this behavior. + * @default true + */ + force?: boolean; + /** + * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()} + */ + mode?: number; + /** + * When `true` timestamps from `src` will + * be preserved. + * @default false + */ + preserveTimestamps?: boolean; + /** + * Copy directories recursively. + * @default false + */ + recursive?: boolean; + /** + * When true, path resolution for symlinks will be skipped + * @default false + */ + verbatimSymlinks?: boolean; + } + export interface CopyOptions extends CopyOptionsBase { + /** + * Function to filter copied files/directories. Return + * `true` to copy the item, `false` to ignore it. + */ + filter?(source: string, destination: string): boolean | Promise; + } + export interface CopySyncOptions extends CopyOptionsBase { + /** + * Function to filter copied files/directories. Return + * `true` to copy the item, `false` to ignore it. + */ + filter?(source: string, destination: string): boolean; + } + /** + * Asynchronously copies the entire directory structure from `src` to `dest`, + * including subdirectories and files. + * + * When copying a directory to another directory, globs are not supported and + * behavior is similar to `cp dir1/ dir2/`. + * @since v16.7.0 + * @experimental + * @param src source path to copy. + * @param dest destination path to copy to. + */ + export function cp( + source: string | URL, + destination: string | URL, + callback: (err: NodeJS.ErrnoException | null) => void, + ): void; + export function cp( + source: string | URL, + destination: string | URL, + opts: CopyOptions, + callback: (err: NodeJS.ErrnoException | null) => void, + ): void; + /** + * Synchronously copies the entire directory structure from `src` to `dest`, + * including subdirectories and files. + * + * When copying a directory to another directory, globs are not supported and + * behavior is similar to `cp dir1/ dir2/`. + * @since v16.7.0 + * @experimental + * @param src source path to copy. + * @param dest destination path to copy to. + */ + export function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void; +} +declare module "node:fs" { + export * from "fs"; +} diff --git a/node_modules/@types/node/ts4.8/fs/promises.d.ts b/node_modules/@types/node/ts4.8/fs/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..88a9fc33e91344c14cf676cb9317eda1f1cb96f7 --- /dev/null +++ b/node_modules/@types/node/ts4.8/fs/promises.d.ts @@ -0,0 +1,1239 @@ +/** + * The `fs/promises` API provides asynchronous file system methods that return + * promises. + * + * The promise APIs use the underlying Node.js threadpool to perform file + * system operations off the event loop thread. These operations are not + * synchronized or threadsafe. Care must be taken when performing multiple + * concurrent modifications on the same file or data corruption may occur. + * @since v10.0.0 + */ +declare module "fs/promises" { + import { Abortable } from "node:events"; + import { Stream } from "node:stream"; + import { ReadableStream } from "node:stream/web"; + import { + BigIntStats, + BigIntStatsFs, + BufferEncodingOption, + constants as fsConstants, + CopyOptions, + Dir, + Dirent, + MakeDirectoryOptions, + Mode, + ObjectEncodingOptions, + OpenDirOptions, + OpenMode, + PathLike, + ReadStream, + ReadVResult, + RmDirOptions, + RmOptions, + StatFsOptions, + StatOptions, + Stats, + StatsFs, + TimeLike, + WatchEventType, + WatchOptions, + WriteStream, + WriteVResult, + } from "node:fs"; + import { Interface as ReadlineInterface } from "node:readline"; + interface FileChangeInfo { + eventType: WatchEventType; + filename: T | null; + } + interface FlagAndOpenMode { + mode?: Mode | undefined; + flag?: OpenMode | undefined; + } + interface FileReadResult { + bytesRead: number; + buffer: T; + } + interface FileReadOptions { + /** + * @default `Buffer.alloc(0xffff)` + */ + buffer?: T; + /** + * @default 0 + */ + offset?: number | null; + /** + * @default `buffer.byteLength` + */ + length?: number | null; + position?: number | null; + } + interface CreateReadStreamOptions { + encoding?: BufferEncoding | null | undefined; + autoClose?: boolean | undefined; + emitClose?: boolean | undefined; + start?: number | undefined; + end?: number | undefined; + highWaterMark?: number | undefined; + } + interface CreateWriteStreamOptions { + encoding?: BufferEncoding | null | undefined; + autoClose?: boolean | undefined; + emitClose?: boolean | undefined; + start?: number | undefined; + highWaterMark?: number | undefined; + flush?: boolean | undefined; + } + interface ReadableWebStreamOptions { + /** + * Whether to open a normal or a `'bytes'` stream. + * @since v20.0.0 + */ + type?: "bytes" | undefined; + } + // TODO: Add `EventEmitter` close + interface FileHandle { + /** + * The numeric file descriptor managed by the {FileHandle} object. + * @since v10.0.0 + */ + readonly fd: number; + /** + * Alias of `filehandle.writeFile()`. + * + * When operating on file handles, the mode cannot be changed from what it was set + * to with `fsPromises.open()`. Therefore, this is equivalent to `filehandle.writeFile()`. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + appendFile( + data: string | Uint8Array, + options?: + | (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) + | BufferEncoding + | null, + ): Promise; + /** + * Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html). + * @since v10.0.0 + * @param uid The file's new owner's user id. + * @param gid The file's new group's group id. + * @return Fulfills with `undefined` upon success. + */ + chown(uid: number, gid: number): Promise; + /** + * Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html). + * @since v10.0.0 + * @param mode the file mode bit mask. + * @return Fulfills with `undefined` upon success. + */ + chmod(mode: Mode): Promise; + /** + * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream + * returned by this method has a default `highWaterMark` of 64 KiB. + * + * `options` can include `start` and `end` values to read a range of bytes from + * the file instead of the entire file. Both `start` and `end` are inclusive and + * start counting at 0, allowed values are in the + * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `start` is + * omitted or `undefined`, `filehandle.createReadStream()` reads sequentially from + * the current file position. The `encoding` can be any one of those accepted by `Buffer`. + * + * If the `FileHandle` points to a character device that only supports blocking + * reads (such as keyboard or sound card), read operations do not finish until data + * is available. This can prevent the process from exiting and the stream from + * closing naturally. + * + * By default, the stream will emit a `'close'` event after it has been + * destroyed. Set the `emitClose` option to `false` to change this behavior. + * + * ```js + * import { open } from 'node:fs/promises'; + * + * const fd = await open('/dev/input/event0'); + * // Create a stream from some character device. + * const stream = fd.createReadStream(); + * setTimeout(() => { + * stream.close(); // This may not close the stream. + * // Artificially marking end-of-stream, as if the underlying resource had + * // indicated end-of-file by itself, allows the stream to close. + * // This does not cancel pending read operations, and if there is such an + * // operation, the process may still not be able to exit successfully + * // until it finishes. + * stream.push(null); + * stream.read(0); + * }, 100); + * ``` + * + * If `autoClose` is false, then the file descriptor won't be closed, even if + * there's an error. It is the application's responsibility to close it and make + * sure there's no file descriptor leak. If `autoClose` is set to true (default + * behavior), on `'error'` or `'end'` the file descriptor will be closed + * automatically. + * + * An example to read the last 10 bytes of a file which is 100 bytes long: + * + * ```js + * import { open } from 'node:fs/promises'; + * + * const fd = await open('sample.txt'); + * fd.createReadStream({ start: 90, end: 99 }); + * ``` + * @since v16.11.0 + */ + createReadStream(options?: CreateReadStreamOptions): ReadStream; + /** + * `options` may also include a `start` option to allow writing data at some + * position past the beginning of the file, allowed values are in the + * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than + * replacing it may require the `flags` `open` option to be set to `r+` rather than + * the default `r`. The `encoding` can be any one of those accepted by `Buffer`. + * + * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false, + * then the file descriptor won't be closed, even if there's an error. + * It is the application's responsibility to close it and make sure there's no + * file descriptor leak. + * + * By default, the stream will emit a `'close'` event after it has been + * destroyed. Set the `emitClose` option to `false` to change this behavior. + * @since v16.11.0 + */ + createWriteStream(options?: CreateWriteStreamOptions): WriteStream; + /** + * Forces all currently queued I/O operations associated with the file to the + * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. + * + * Unlike `filehandle.sync` this method does not flush modified metadata. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + datasync(): Promise; + /** + * Request that all data for the open file descriptor is flushed to the storage + * device. The specific implementation is operating system and device specific. + * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + sync(): Promise; + /** + * Reads data from the file and stores that in the given buffer. + * + * If the file is not modified concurrently, the end-of-file is reached when the + * number of bytes read is zero. + * @since v10.0.0 + * @param buffer A buffer that will be filled with the file data read. + * @param offset The location in the buffer at which to start filling. + * @param length The number of bytes to read. + * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an + * integer, the current file position will remain unchanged. + * @return Fulfills upon success with an object with two properties: + */ + read( + buffer: T, + offset?: number | null, + length?: number | null, + position?: number | null, + ): Promise>; + read(options?: FileReadOptions): Promise>; + /** + * Returns a `ReadableStream` that may be used to read the files data. + * + * An error will be thrown if this method is called more than once or is called + * after the `FileHandle` is closed or closing. + * + * ```js + * import { + * open, + * } from 'node:fs/promises'; + * + * const file = await open('./some/file/to/read'); + * + * for await (const chunk of file.readableWebStream()) + * console.log(chunk); + * + * await file.close(); + * ``` + * + * While the `ReadableStream` will read the file to completion, it will not + * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method. + * @since v17.0.0 + * @experimental + */ + readableWebStream(options?: ReadableWebStreamOptions): ReadableStream; + /** + * Asynchronously reads the entire contents of a file. + * + * If `options` is a string, then it specifies the `encoding`. + * + * The `FileHandle` has to support reading. + * + * If one or more `filehandle.read()` calls are made on a file handle and then a`filehandle.readFile()` call is made, the data will be read from the current + * position till the end of the file. It doesn't always read from the beginning + * of the file. + * @since v10.0.0 + * @return Fulfills upon a successful read with the contents of the file. If no encoding is specified (using `options.encoding`), the data is returned as a {Buffer} object. Otherwise, the + * data will be a string. + */ + readFile( + options?: { + encoding?: null | undefined; + flag?: OpenMode | undefined; + } | null, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically. + * The `FileHandle` must have been opened for reading. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + readFile( + options: + | { + encoding: BufferEncoding; + flag?: OpenMode | undefined; + } + | BufferEncoding, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically. + * The `FileHandle` must have been opened for reading. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + readFile( + options?: + | (ObjectEncodingOptions & { + flag?: OpenMode | undefined; + }) + | BufferEncoding + | null, + ): Promise; + /** + * Convenience method to create a `readline` interface and stream over the file. + * See `filehandle.createReadStream()` for the options. + * + * ```js + * import { open } from 'node:fs/promises'; + * + * const file = await open('./some/file/to/read'); + * + * for await (const line of file.readLines()) { + * console.log(line); + * } + * ``` + * @since v18.11.0 + */ + readLines(options?: CreateReadStreamOptions): ReadlineInterface; + /** + * @since v10.0.0 + * @return Fulfills with an {fs.Stats} for the file. + */ + stat( + opts?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + stat( + opts: StatOptions & { + bigint: true; + }, + ): Promise; + stat(opts?: StatOptions): Promise; + /** + * Truncates the file. + * + * If the file was larger than `len` bytes, only the first `len` bytes will be + * retained in the file. + * + * The following example retains only the first four bytes of the file: + * + * ```js + * import { open } from 'node:fs/promises'; + * + * let filehandle = null; + * try { + * filehandle = await open('temp.txt', 'r+'); + * await filehandle.truncate(4); + * } finally { + * await filehandle?.close(); + * } + * ``` + * + * If the file previously was shorter than `len` bytes, it is extended, and the + * extended part is filled with null bytes (`'\0'`): + * + * If `len` is negative then `0` will be used. + * @since v10.0.0 + * @param [len=0] + * @return Fulfills with `undefined` upon success. + */ + truncate(len?: number): Promise; + /** + * Change the file system timestamps of the object referenced by the `FileHandle` then fulfills the promise with no arguments upon success. + * @since v10.0.0 + */ + utimes(atime: TimeLike, mtime: TimeLike): Promise; + /** + * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an + * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an + * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object. + * The promise is fulfilled with no arguments upon success. + * + * If `options` is a string, then it specifies the `encoding`. + * + * The `FileHandle` has to support writing. + * + * It is unsafe to use `filehandle.writeFile()` multiple times on the same file + * without waiting for the promise to be fulfilled (or rejected). + * + * If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the + * current position till the end of the file. It doesn't always write from the + * beginning of the file. + * @since v10.0.0 + */ + writeFile( + data: string | Uint8Array, + options?: + | (ObjectEncodingOptions & FlagAndOpenMode & Abortable & { flush?: boolean | undefined }) + | BufferEncoding + | null, + ): Promise; + /** + * Write `buffer` to the file. + * + * The promise is fulfilled with an object containing two properties: + * + * It is unsafe to use `filehandle.write()` multiple times on the same file + * without waiting for the promise to be fulfilled (or rejected). For this + * scenario, use `filehandle.createWriteStream()`. + * + * On Linux, positional writes do not work when the file is opened in append mode. + * The kernel ignores the position argument and always appends the data to + * the end of the file. + * @since v10.0.0 + * @param offset The start position from within `buffer` where the data to write begins. + * @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write. + * @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current + * position. See the POSIX pwrite(2) documentation for more detail. + */ + write( + buffer: TBuffer, + offset?: number | null, + length?: number | null, + position?: number | null, + ): Promise<{ + bytesWritten: number; + buffer: TBuffer; + }>; + write( + data: string, + position?: number | null, + encoding?: BufferEncoding | null, + ): Promise<{ + bytesWritten: number; + buffer: string; + }>; + /** + * Write an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s to the file. + * + * The promise is fulfilled with an object containing a two properties: + * + * It is unsafe to call `writev()` multiple times on the same file without waiting + * for the promise to be fulfilled (or rejected). + * + * On Linux, positional writes don't work when the file is opened in append mode. + * The kernel ignores the position argument and always appends the data to + * the end of the file. + * @since v12.9.0 + * @param [position='null'] The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current + * position. + */ + writev(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise; + /** + * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s + * @since v13.13.0, v12.17.0 + * @param [position='null'] The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position. + * @return Fulfills upon success an object containing two properties: + */ + readv(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise; + /** + * Closes the file handle after waiting for any pending operation on the handle to + * complete. + * + * ```js + * import { open } from 'node:fs/promises'; + * + * let filehandle; + * try { + * filehandle = await open('thefile.txt', 'r'); + * } finally { + * await filehandle?.close(); + * } + * ``` + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + close(): Promise; + /** + * An alias for {@link FileHandle.close()}. + * @since v20.4.0 + */ + [Symbol.asyncDispose](): Promise; + } + const constants: typeof fsConstants; + /** + * Tests a user's permissions for the file or directory specified by `path`. + * The `mode` argument is an optional integer that specifies the accessibility + * checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK` + * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for + * possible values of `mode`. + * + * If the accessibility check is successful, the promise is fulfilled with no + * value. If any of the accessibility checks fail, the promise is rejected + * with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and + * written by the current process. + * + * ```js + * import { access, constants } from 'node:fs/promises'; + * + * try { + * await access('/etc/passwd', constants.R_OK | constants.W_OK); + * console.log('can access'); + * } catch { + * console.error('cannot access'); + * } + * ``` + * + * Using `fsPromises.access()` to check for the accessibility of a file before + * calling `fsPromises.open()` is not recommended. Doing so introduces a race + * condition, since other processes may change the file's state between the two + * calls. Instead, user code should open/read/write the file directly and handle + * the error raised if the file is not accessible. + * @since v10.0.0 + * @param [mode=fs.constants.F_OK] + * @return Fulfills with `undefined` upon success. + */ + function access(path: PathLike, mode?: number): Promise; + /** + * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it + * already exists. + * + * No guarantees are made about the atomicity of the copy operation. If an + * error occurs after the destination file has been opened for writing, an attempt + * will be made to remove the destination. + * + * ```js + * import { copyFile, constants } from 'node:fs/promises'; + * + * try { + * await copyFile('source.txt', 'destination.txt'); + * console.log('source.txt was copied to destination.txt'); + * } catch { + * console.error('The file could not be copied'); + * } + * + * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists. + * try { + * await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL); + * console.log('source.txt was copied to destination.txt'); + * } catch { + * console.error('The file could not be copied'); + * } + * ``` + * @since v10.0.0 + * @param src source filename to copy + * @param dest destination filename of the copy operation + * @param [mode=0] Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. + * `fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`) + * @return Fulfills with `undefined` upon success. + */ + function copyFile(src: PathLike, dest: PathLike, mode?: number): Promise; + /** + * Opens a `FileHandle`. + * + * Refer to the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more detail. + * + * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented + * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains + * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams). + * @since v10.0.0 + * @param [flags='r'] See `support of file system `flags``. + * @param [mode=0o666] Sets the file mode (permission and sticky bits) if the file is created. + * @return Fulfills with a {FileHandle} object. + */ + function open(path: PathLike, flags?: string | number, mode?: Mode): Promise; + /** + * Renames `oldPath` to `newPath`. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function rename(oldPath: PathLike, newPath: PathLike): Promise; + /** + * Truncates (shortens or extends the length) of the content at `path` to `len`bytes. + * @since v10.0.0 + * @param [len=0] + * @return Fulfills with `undefined` upon success. + */ + function truncate(path: PathLike, len?: number): Promise; + /** + * Removes the directory identified by `path`. + * + * Using `fsPromises.rmdir()` on a file (not a directory) results in the + * promise being rejected with an `ENOENT` error on Windows and an `ENOTDIR`error on POSIX. + * + * To get a behavior similar to the `rm -rf` Unix command, use `fsPromises.rm()` with options `{ recursive: true, force: true }`. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function rmdir(path: PathLike, options?: RmDirOptions): Promise; + /** + * Removes files and directories (modeled on the standard POSIX `rm` utility). + * @since v14.14.0 + * @return Fulfills with `undefined` upon success. + */ + function rm(path: PathLike, options?: RmOptions): Promise; + /** + * Asynchronously creates a directory. + * + * The optional `options` argument can be an integer specifying `mode` (permission + * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fsPromises.mkdir()` when `path` is a directory + * that exists results in a + * rejection only when `recursive` is false. + * + * ```js + * import { mkdir } from 'node:fs/promises'; + * + * try { + * const projectFolder = new URL('./test/project/', import.meta.url); + * const createDir = await mkdir(projectFolder, { recursive: true }); + * + * console.log(`created ${createDir}`); + * } catch (err) { + * console.error(err.message); + * } + * ``` + * @since v10.0.0 + * @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`. + */ + function mkdir( + path: PathLike, + options: MakeDirectoryOptions & { + recursive: true; + }, + ): Promise; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function mkdir( + path: PathLike, + options?: + | Mode + | (MakeDirectoryOptions & { + recursive?: false | undefined; + }) + | null, + ): Promise; + /** + * Asynchronous mkdir(2) - create a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders + * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. + */ + function mkdir(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise; + /** + * Reads the contents of a directory. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the filenames. If the `encoding` is set to `'buffer'`, the filenames returned + * will be passed as `Buffer` objects. + * + * If `options.withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects. + * + * ```js + * import { readdir } from 'node:fs/promises'; + * + * try { + * const files = await readdir(path); + * for (const file of files) + * console.log(file); + * } catch (err) { + * console.error(err); + * } + * ``` + * @since v10.0.0 + * @return Fulfills with an array of the names of the files in the directory excluding `'.'` and `'..'`. + */ + function readdir( + path: PathLike, + options?: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function readdir( + path: PathLike, + options: + | { + encoding: "buffer"; + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + } + | "buffer", + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function readdir( + path: PathLike, + options?: + | (ObjectEncodingOptions & { + withFileTypes?: false | undefined; + recursive?: boolean | undefined; + }) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronous readdir(3) - read a directory. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options If called with `withFileTypes: true` the result data will be an array of Dirent. + */ + function readdir( + path: PathLike, + options: ObjectEncodingOptions & { + withFileTypes: true; + recursive?: boolean | undefined; + }, + ): Promise; + /** + * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is + * fulfilled with the`linkString` upon success. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the link path returned. If the `encoding` is set to `'buffer'`, the link path + * returned will be passed as a `Buffer` object. + * @since v10.0.0 + * @return Fulfills with the `linkString` upon success. + */ + function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function readlink(path: PathLike, options: BufferEncodingOption): Promise; + /** + * Asynchronous readlink(2) - read value of a symbolic link. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise; + /** + * Creates a symbolic link. + * + * The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. If the `type` argument is not a string, Node.js will + * autodetect `target` type and use `'file'` or `'dir'`. If the `target` does not + * exist, `'file'` will be used. Windows junction points require the destination + * path to be absolute. When using `'junction'`, the `target` argument will + * automatically be normalized to absolute path. Junction points on NTFS volumes + * can only point to directories. + * @since v10.0.0 + * @param [type='null'] + * @return Fulfills with `undefined` upon success. + */ + function symlink(target: PathLike, path: PathLike, type?: string | null): Promise; + /** + * Equivalent to `fsPromises.stat()` unless `path` refers to a symbolic link, + * in which case the link itself is stat-ed, not the file that it refers to. + * Refer to the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) document for more detail. + * @since v10.0.0 + * @return Fulfills with the {fs.Stats} object for the given symbolic link `path`. + */ + function lstat( + path: PathLike, + opts?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function lstat( + path: PathLike, + opts: StatOptions & { + bigint: true; + }, + ): Promise; + function lstat(path: PathLike, opts?: StatOptions): Promise; + /** + * @since v10.0.0 + * @return Fulfills with the {fs.Stats} object for the given `path`. + */ + function stat( + path: PathLike, + opts?: StatOptions & { + bigint?: false | undefined; + }, + ): Promise; + function stat( + path: PathLike, + opts: StatOptions & { + bigint: true; + }, + ): Promise; + function stat(path: PathLike, opts?: StatOptions): Promise; + /** + * @since v19.6.0, v18.15.0 + * @return Fulfills with the {fs.StatFs} object for the given `path`. + */ + function statfs( + path: PathLike, + opts?: StatFsOptions & { + bigint?: false | undefined; + }, + ): Promise; + function statfs( + path: PathLike, + opts: StatFsOptions & { + bigint: true; + }, + ): Promise; + function statfs(path: PathLike, opts?: StatFsOptions): Promise; + /** + * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function link(existingPath: PathLike, newPath: PathLike): Promise; + /** + * If `path` refers to a symbolic link, then the link is removed without affecting + * the file or directory to which that link refers. If the `path` refers to a file + * path that is not a symbolic link, the file is deleted. See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more detail. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function unlink(path: PathLike): Promise; + /** + * Changes the permissions of a file. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function chmod(path: PathLike, mode: Mode): Promise; + /** + * Changes the permissions on a symbolic link. + * + * This method is only implemented on macOS. + * @deprecated Since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function lchmod(path: PathLike, mode: Mode): Promise; + /** + * Changes the ownership on a symbolic link. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function lchown(path: PathLike, uid: number, gid: number): Promise; + /** + * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, with the difference that if the path refers to a + * symbolic link, then the link is not dereferenced: instead, the timestamps of + * the symbolic link itself are changed. + * @since v14.5.0, v12.19.0 + * @return Fulfills with `undefined` upon success. + */ + function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise; + /** + * Changes the ownership of a file. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function chown(path: PathLike, uid: number, gid: number): Promise; + /** + * Change the file system timestamps of the object referenced by `path`. + * + * The `atime` and `mtime` arguments follow these rules: + * + * * Values can be either numbers representing Unix epoch time, `Date`s, or a + * numeric string like `'123456789.0'`. + * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown. + * @since v10.0.0 + * @return Fulfills with `undefined` upon success. + */ + function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise; + /** + * Determines the actual location of `path` using the same semantics as the`fs.realpath.native()` function. + * + * Only paths that can be converted to UTF8 strings are supported. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use for + * the path. If the `encoding` is set to `'buffer'`, the path returned will be + * passed as a `Buffer` object. + * + * On Linux, when Node.js is linked against musl libc, the procfs file system must + * be mounted on `/proc` in order for this function to work. Glibc does not have + * this restriction. + * @since v10.0.0 + * @return Fulfills with the resolved path upon success. + */ + function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function realpath(path: PathLike, options: BufferEncodingOption): Promise; + /** + * Asynchronous realpath(3) - return the canonicalized absolute pathname. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function realpath( + path: PathLike, + options?: ObjectEncodingOptions | BufferEncoding | null, + ): Promise; + /** + * Creates a unique temporary directory. A unique directory name is generated by + * appending six random characters to the end of the provided `prefix`. Due to + * platform inconsistencies, avoid trailing `X` characters in `prefix`. Some + * platforms, notably the BSDs, can return more than six random characters, and + * replace trailing `X` characters in `prefix` with random characters. + * + * The optional `options` argument can be a string specifying an encoding, or an + * object with an `encoding` property specifying the character encoding to use. + * + * ```js + * import { mkdtemp } from 'node:fs/promises'; + * import { join } from 'node:path'; + * import { tmpdir } from 'node:os'; + * + * try { + * await mkdtemp(join(tmpdir(), 'foo-')); + * } catch (err) { + * console.error(err); + * } + * ``` + * + * The `fsPromises.mkdtemp()` method will append the six randomly selected + * characters directly to the `prefix` string. For instance, given a directory`/tmp`, if the intention is to create a temporary directory _within_`/tmp`, the`prefix` must end with a trailing + * platform-specific path separator + * (`require('node:path').sep`). + * @since v10.0.0 + * @return Fulfills with a string containing the file system path of the newly created temporary directory. + */ + function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function mkdtemp(prefix: string, options: BufferEncodingOption): Promise; + /** + * Asynchronously creates a unique temporary directory. + * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory. + * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. + */ + function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise; + /** + * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an + * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an + * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object. + * + * The `encoding` option is ignored if `data` is a buffer. + * + * If `options` is a string, then it specifies the encoding. + * + * The `mode` option only affects the newly created file. See `fs.open()` for more details. + * + * Any specified `FileHandle` has to support writing. + * + * It is unsafe to use `fsPromises.writeFile()` multiple times on the same file + * without waiting for the promise to be settled. + * + * Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience + * method that performs multiple `write` calls internally to write the buffer + * passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`. + * + * It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`. + * Cancelation is "best effort", and some amount of data is likely still + * to be written. + * + * ```js + * import { writeFile } from 'node:fs/promises'; + * import { Buffer } from 'node:buffer'; + * + * try { + * const controller = new AbortController(); + * const { signal } = controller; + * const data = new Uint8Array(Buffer.from('Hello Node.js')); + * const promise = writeFile('message.txt', data, { signal }); + * + * // Abort the request before the promise settles. + * controller.abort(); + * + * await promise; + * } catch (err) { + * // When a request is aborted - err is an AbortError + * console.error(err); + * } + * ``` + * + * Aborting an ongoing request does not abort individual operating + * system requests but rather the internal buffering `fs.writeFile` performs. + * @since v10.0.0 + * @param file filename or `FileHandle` + * @return Fulfills with `undefined` upon success. + */ + function writeFile( + file: PathLike | FileHandle, + data: + | string + | NodeJS.ArrayBufferView + | Iterable + | AsyncIterable + | Stream, + options?: + | (ObjectEncodingOptions & { + mode?: Mode | undefined; + flag?: OpenMode | undefined; + } & Abortable) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronously append data to a file, creating the file if it does not yet + * exist. `data` can be a string or a `Buffer`. + * + * If `options` is a string, then it specifies the `encoding`. + * + * The `mode` option only affects the newly created file. See `fs.open()` for more details. + * + * The `path` may be specified as a `FileHandle` that has been opened + * for appending (using `fsPromises.open()`). + * @since v10.0.0 + * @param path filename or {FileHandle} + * @return Fulfills with `undefined` upon success. + */ + function appendFile( + path: PathLike | FileHandle, + data: string | Uint8Array, + options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * + * If no encoding is specified (using `options.encoding`), the data is returned + * as a `Buffer` object. Otherwise, the data will be a string. + * + * If `options` is a string, then it specifies the encoding. + * + * When the `path` is a directory, the behavior of `fsPromises.readFile()` is + * platform-specific. On macOS, Linux, and Windows, the promise will be rejected + * with an error. On FreeBSD, a representation of the directory's contents will be + * returned. + * + * An example of reading a `package.json` file located in the same directory of the + * running code: + * + * ```js + * import { readFile } from 'node:fs/promises'; + * try { + * const filePath = new URL('./package.json', import.meta.url); + * const contents = await readFile(filePath, { encoding: 'utf8' }); + * console.log(contents); + * } catch (err) { + * console.error(err.message); + * } + * ``` + * + * It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a + * request is aborted the promise returned is rejected with an `AbortError`: + * + * ```js + * import { readFile } from 'node:fs/promises'; + * + * try { + * const controller = new AbortController(); + * const { signal } = controller; + * const promise = readFile(fileName, { signal }); + * + * // Abort the request before the promise settles. + * controller.abort(); + * + * await promise; + * } catch (err) { + * // When a request is aborted - err is an AbortError + * console.error(err); + * } + * ``` + * + * Aborting an ongoing request does not abort individual operating + * system requests but rather the internal buffering `fs.readFile` performs. + * + * Any specified `FileHandle` has to support reading. + * @since v10.0.0 + * @param path filename or `FileHandle` + * @return Fulfills with the contents of the file. + */ + function readFile( + path: PathLike | FileHandle, + options?: + | ({ + encoding?: null | undefined; + flag?: OpenMode | undefined; + } & Abortable) + | null, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function readFile( + path: PathLike | FileHandle, + options: + | ({ + encoding: BufferEncoding; + flag?: OpenMode | undefined; + } & Abortable) + | BufferEncoding, + ): Promise; + /** + * Asynchronously reads the entire contents of a file. + * @param path A path to a file. If a URL is provided, it must use the `file:` protocol. + * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically. + * @param options An object that may contain an optional flag. + * If a flag is not provided, it defaults to `'r'`. + */ + function readFile( + path: PathLike | FileHandle, + options?: + | ( + & ObjectEncodingOptions + & Abortable + & { + flag?: OpenMode | undefined; + } + ) + | BufferEncoding + | null, + ): Promise; + /** + * Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail. + * + * Creates an `fs.Dir`, which contains all further functions for reading from + * and cleaning up the directory. + * + * The `encoding` option sets the encoding for the `path` while opening the + * directory and subsequent read operations. + * + * Example using async iteration: + * + * ```js + * import { opendir } from 'node:fs/promises'; + * + * try { + * const dir = await opendir('./'); + * for await (const dirent of dir) + * console.log(dirent.name); + * } catch (err) { + * console.error(err); + * } + * ``` + * + * When using the async iterator, the `fs.Dir` object will be automatically + * closed after the iterator exits. + * @since v12.12.0 + * @return Fulfills with an {fs.Dir}. + */ + function opendir(path: PathLike, options?: OpenDirOptions): Promise; + /** + * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory. + * + * ```js + * const { watch } = require('node:fs/promises'); + * + * const ac = new AbortController(); + * const { signal } = ac; + * setTimeout(() => ac.abort(), 10000); + * + * (async () => { + * try { + * const watcher = watch(__filename, { signal }); + * for await (const event of watcher) + * console.log(event); + * } catch (err) { + * if (err.name === 'AbortError') + * return; + * throw err; + * } + * })(); + * ``` + * + * On most platforms, `'rename'` is emitted whenever a filename appears or + * disappears in the directory. + * + * All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`. + * @since v15.9.0, v14.18.0 + * @return of objects with the properties: + */ + function watch( + filename: PathLike, + options: + | (WatchOptions & { + encoding: "buffer"; + }) + | "buffer", + ): AsyncIterable>; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable>; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + function watch( + filename: PathLike, + options: WatchOptions | string, + ): AsyncIterable> | AsyncIterable>; + /** + * Asynchronously copies the entire directory structure from `src` to `dest`, + * including subdirectories and files. + * + * When copying a directory to another directory, globs are not supported and + * behavior is similar to `cp dir1/ dir2/`. + * @since v16.7.0 + * @experimental + * @param src source path to copy. + * @param dest destination path to copy to. + * @return Fulfills with `undefined` upon success. + */ + function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise; +} +declare module "node:fs/promises" { + export * from "fs/promises"; +} diff --git a/node_modules/@types/node/ts4.8/globals.d.ts b/node_modules/@types/node/ts4.8/globals.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a449e4c73abc04042bf8c29c49b74d21d53967d --- /dev/null +++ b/node_modules/@types/node/ts4.8/globals.d.ts @@ -0,0 +1,381 @@ +// Declare "static" methods in Error +interface ErrorConstructor { + /** Create .stack property on a target object */ + captureStackTrace(targetObject: object, constructorOpt?: Function): void; + + /** + * Optional override for formatting stack traces + * + * @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces + */ + prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined; + + stackTraceLimit: number; +} + +/*-----------------------------------------------* + * * + * GLOBAL * + * * + ------------------------------------------------*/ + +// For backwards compability +interface NodeRequire extends NodeJS.Require {} +interface RequireResolve extends NodeJS.RequireResolve {} +interface NodeModule extends NodeJS.Module {} + +declare var process: NodeJS.Process; +declare var console: Console; + +declare var __filename: string; +declare var __dirname: string; + +declare var require: NodeRequire; +declare var module: NodeModule; + +// Same as module.exports +declare var exports: any; + +/** + * Only available if `--expose-gc` is passed to the process. + */ +declare var gc: undefined | (() => void); + +// #region borrowed +// from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib +/** A controller object that allows you to abort one or more DOM requests as and when desired. */ +interface AbortController { + /** + * Returns the AbortSignal object associated with this object. + */ + + readonly signal: AbortSignal; + /** + * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. + */ + abort(reason?: any): void; +} + +/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */ +interface AbortSignal extends EventTarget { + /** + * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. + */ + readonly aborted: boolean; + readonly reason: any; + onabort: null | ((this: AbortSignal, event: Event) => any); + throwIfAborted(): void; +} + +declare var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T + : { + prototype: AbortController; + new(): AbortController; + }; + +declare var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T + : { + prototype: AbortSignal; + new(): AbortSignal; + abort(reason?: any): AbortSignal; + timeout(milliseconds: number): AbortSignal; + }; +// #endregion borrowed + +// #region Disposable +interface SymbolConstructor { + /** + * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + */ + readonly dispose: unique symbol; + + /** + * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement. + */ + readonly asyncDispose: unique symbol; +} + +interface Disposable { + [Symbol.dispose](): void; +} + +interface AsyncDisposable { + [Symbol.asyncDispose](): PromiseLike; +} +// #endregion Disposable + +// #region ArrayLike.at() +interface RelativeIndexable { + /** + * Takes an integer value and returns the item at that index, + * allowing for positive and negative integers. + * Negative integers count back from the last item in the array. + */ + at(index: number): T | undefined; +} +interface String extends RelativeIndexable {} +interface Array extends RelativeIndexable {} +interface ReadonlyArray extends RelativeIndexable {} +interface Int8Array extends RelativeIndexable {} +interface Uint8Array extends RelativeIndexable {} +interface Uint8ClampedArray extends RelativeIndexable {} +interface Int16Array extends RelativeIndexable {} +interface Uint16Array extends RelativeIndexable {} +interface Int32Array extends RelativeIndexable {} +interface Uint32Array extends RelativeIndexable {} +interface Float32Array extends RelativeIndexable {} +interface Float64Array extends RelativeIndexable {} +interface BigInt64Array extends RelativeIndexable {} +interface BigUint64Array extends RelativeIndexable {} +// #endregion ArrayLike.at() end + +/** + * @since v17.0.0 + * + * Creates a deep clone of an object. + */ +declare function structuredClone( + value: T, + transfer?: { transfer: ReadonlyArray }, +): T; + +/*----------------------------------------------* +* * +* GLOBAL INTERFACES * +* * +*-----------------------------------------------*/ +declare namespace NodeJS { + interface CallSite { + /** + * Value of "this" + */ + getThis(): unknown; + + /** + * Type of "this" as a string. + * This is the name of the function stored in the constructor field of + * "this", if available. Otherwise the object's [[Class]] internal + * property. + */ + getTypeName(): string | null; + + /** + * Current function + */ + getFunction(): Function | undefined; + + /** + * Name of the current function, typically its name property. + * If a name property is not available an attempt will be made to try + * to infer a name from the function's context. + */ + getFunctionName(): string | null; + + /** + * Name of the property [of "this" or one of its prototypes] that holds + * the current function + */ + getMethodName(): string | null; + + /** + * Name of the script [if this function was defined in a script] + */ + getFileName(): string | undefined; + + /** + * Current line number [if this function was defined in a script] + */ + getLineNumber(): number | null; + + /** + * Current column number [if this function was defined in a script] + */ + getColumnNumber(): number | null; + + /** + * A call site object representing the location where eval was called + * [if this function was created using a call to eval] + */ + getEvalOrigin(): string | undefined; + + /** + * Is this a toplevel invocation, that is, is "this" the global object? + */ + isToplevel(): boolean; + + /** + * Does this call take place in code defined by a call to eval? + */ + isEval(): boolean; + + /** + * Is this call in native V8 code? + */ + isNative(): boolean; + + /** + * Is this a constructor call? + */ + isConstructor(): boolean; + } + + interface ErrnoException extends Error { + errno?: number | undefined; + code?: string | undefined; + path?: string | undefined; + syscall?: string | undefined; + } + + interface ReadableStream extends EventEmitter { + readable: boolean; + read(size?: number): string | Buffer; + setEncoding(encoding: BufferEncoding): this; + pause(): this; + resume(): this; + isPaused(): boolean; + pipe(destination: T, options?: { end?: boolean | undefined }): T; + unpipe(destination?: WritableStream): this; + unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void; + wrap(oldStream: ReadableStream): this; + [Symbol.asyncIterator](): AsyncIterableIterator; + } + + interface WritableStream extends EventEmitter { + writable: boolean; + write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean; + write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean; + end(cb?: () => void): this; + end(data: string | Uint8Array, cb?: () => void): this; + end(str: string, encoding?: BufferEncoding, cb?: () => void): this; + } + + interface ReadWriteStream extends ReadableStream, WritableStream {} + + interface RefCounted { + ref(): this; + unref(): this; + } + + type TypedArray = + | Uint8Array + | Uint8ClampedArray + | Uint16Array + | Uint32Array + | Int8Array + | Int16Array + | Int32Array + | BigUint64Array + | BigInt64Array + | Float32Array + | Float64Array; + type ArrayBufferView = TypedArray | DataView; + + interface Require { + (id: string): any; + resolve: RequireResolve; + cache: Dict; + /** + * @deprecated + */ + extensions: RequireExtensions; + main: Module | undefined; + } + + interface RequireResolve { + (id: string, options?: { paths?: string[] | undefined }): string; + paths(request: string): string[] | null; + } + + interface RequireExtensions extends Dict<(m: Module, filename: string) => any> { + ".js": (m: Module, filename: string) => any; + ".json": (m: Module, filename: string) => any; + ".node": (m: Module, filename: string) => any; + } + interface Module { + /** + * `true` if the module is running during the Node.js preload + */ + isPreloading: boolean; + exports: any; + require: Require; + id: string; + filename: string; + loaded: boolean; + /** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */ + parent: Module | null | undefined; + children: Module[]; + /** + * @since v11.14.0 + * + * The directory name of the module. This is usually the same as the path.dirname() of the module.id. + */ + path: string; + paths: string[]; + } + + interface Dict { + [key: string]: T | undefined; + } + + interface ReadOnlyDict { + readonly [key: string]: T | undefined; + } + + namespace fetch { + type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request; + type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response; + type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData; + type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers; + type _RequestInit = typeof globalThis extends { onmessage: any } ? {} + : import("undici-types").RequestInit; + type Request = globalThis.Request; + type Response = globalThis.Response; + type Headers = globalThis.Headers; + type FormData = globalThis.FormData; + type RequestInit = globalThis.RequestInit; + type RequestInfo = import("undici-types").RequestInfo; + type HeadersInit = import("undici-types").HeadersInit; + type BodyInit = import("undici-types").BodyInit; + type RequestRedirect = import("undici-types").RequestRedirect; + type RequestCredentials = import("undici-types").RequestCredentials; + type RequestMode = import("undici-types").RequestMode; + type ReferrerPolicy = import("undici-types").ReferrerPolicy; + type Dispatcher = import("undici-types").Dispatcher; + type RequestDuplex = import("undici-types").RequestDuplex; + } +} + +interface RequestInit extends NodeJS.fetch._RequestInit {} + +declare function fetch( + input: NodeJS.fetch.RequestInfo, + init?: RequestInit, +): Promise; + +interface Request extends NodeJS.fetch._Request {} +declare var Request: typeof globalThis extends { + onmessage: any; + Request: infer T; +} ? T + : typeof import("undici-types").Request; + +interface Response extends NodeJS.fetch._Response {} +declare var Response: typeof globalThis extends { + onmessage: any; + Response: infer T; +} ? T + : typeof import("undici-types").Response; + +interface FormData extends NodeJS.fetch._FormData {} +declare var FormData: typeof globalThis extends { + onmessage: any; + FormData: infer T; +} ? T + : typeof import("undici-types").FormData; + +interface Headers extends NodeJS.fetch._Headers {} +declare var Headers: typeof globalThis extends { + onmessage: any; + Headers: infer T; +} ? T + : typeof import("undici-types").Headers; diff --git a/node_modules/@types/node/ts4.8/globals.global.d.ts b/node_modules/@types/node/ts4.8/globals.global.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef1198c05024940c44e3c1a6429c26091fe2a94f --- /dev/null +++ b/node_modules/@types/node/ts4.8/globals.global.d.ts @@ -0,0 +1 @@ +declare var global: typeof globalThis; diff --git a/node_modules/@types/node/ts4.8/http.d.ts b/node_modules/@types/node/ts4.8/http.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b2c3c2c6be6cdd67b5f1f53c70a55a880ee376f --- /dev/null +++ b/node_modules/@types/node/ts4.8/http.d.ts @@ -0,0 +1,1888 @@ +/** + * To use the HTTP server and client one must `require('node:http')`. + * + * The HTTP interfaces in Node.js are designed to support many features + * of the protocol which have been traditionally difficult to use. + * In particular, large, possibly chunk-encoded, messages. The interface is + * careful to never buffer entire requests or responses, so the + * user is able to stream data. + * + * HTTP message headers are represented by an object like this: + * + * ```js + * { 'content-length': '123', + * 'content-type': 'text/plain', + * 'connection': 'keep-alive', + * 'host': 'example.com', + * 'accept': '*' } + * ``` + * + * Keys are lowercased. Values are not modified. + * + * In order to support the full spectrum of possible HTTP applications, the Node.js + * HTTP API is very low-level. It deals with stream handling and message + * parsing only. It parses a message into headers and body but it does not + * parse the actual headers or the body. + * + * See `message.headers` for details on how duplicate headers are handled. + * + * The raw headers as they were received are retained in the `rawHeaders`property, which is an array of `[key, value, key2, value2, ...]`. For + * example, the previous message header object might have a `rawHeaders`list like the following: + * + * ```js + * [ 'ConTent-Length', '123456', + * 'content-LENGTH', '123', + * 'content-type', 'text/plain', + * 'CONNECTION', 'keep-alive', + * 'Host', 'example.com', + * 'accepT', '*' ] + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http.js) + */ +declare module "http" { + import * as stream from "node:stream"; + import { URL } from "node:url"; + import { LookupOptions } from "node:dns"; + import { EventEmitter } from "node:events"; + import { LookupFunction, Server as NetServer, Socket, TcpSocketConnectOpts } from "node:net"; + // incoming headers will never contain number + interface IncomingHttpHeaders extends NodeJS.Dict { + accept?: string | undefined; + "accept-language"?: string | undefined; + "accept-patch"?: string | undefined; + "accept-ranges"?: string | undefined; + "access-control-allow-credentials"?: string | undefined; + "access-control-allow-headers"?: string | undefined; + "access-control-allow-methods"?: string | undefined; + "access-control-allow-origin"?: string | undefined; + "access-control-expose-headers"?: string | undefined; + "access-control-max-age"?: string | undefined; + "access-control-request-headers"?: string | undefined; + "access-control-request-method"?: string | undefined; + age?: string | undefined; + allow?: string | undefined; + "alt-svc"?: string | undefined; + authorization?: string | undefined; + "cache-control"?: string | undefined; + connection?: string | undefined; + "content-disposition"?: string | undefined; + "content-encoding"?: string | undefined; + "content-language"?: string | undefined; + "content-length"?: string | undefined; + "content-location"?: string | undefined; + "content-range"?: string | undefined; + "content-type"?: string | undefined; + cookie?: string | undefined; + date?: string | undefined; + etag?: string | undefined; + expect?: string | undefined; + expires?: string | undefined; + forwarded?: string | undefined; + from?: string | undefined; + host?: string | undefined; + "if-match"?: string | undefined; + "if-modified-since"?: string | undefined; + "if-none-match"?: string | undefined; + "if-unmodified-since"?: string | undefined; + "last-modified"?: string | undefined; + location?: string | undefined; + origin?: string | undefined; + pragma?: string | undefined; + "proxy-authenticate"?: string | undefined; + "proxy-authorization"?: string | undefined; + "public-key-pins"?: string | undefined; + range?: string | undefined; + referer?: string | undefined; + "retry-after"?: string | undefined; + "sec-websocket-accept"?: string | undefined; + "sec-websocket-extensions"?: string | undefined; + "sec-websocket-key"?: string | undefined; + "sec-websocket-protocol"?: string | undefined; + "sec-websocket-version"?: string | undefined; + "set-cookie"?: string[] | undefined; + "strict-transport-security"?: string | undefined; + tk?: string | undefined; + trailer?: string | undefined; + "transfer-encoding"?: string | undefined; + upgrade?: string | undefined; + "user-agent"?: string | undefined; + vary?: string | undefined; + via?: string | undefined; + warning?: string | undefined; + "www-authenticate"?: string | undefined; + } + // outgoing headers allows numbers (as they are converted internally to strings) + type OutgoingHttpHeader = number | string | string[]; + interface OutgoingHttpHeaders extends NodeJS.Dict { + accept?: string | string[] | undefined; + "accept-charset"?: string | string[] | undefined; + "accept-encoding"?: string | string[] | undefined; + "accept-language"?: string | string[] | undefined; + "accept-ranges"?: string | undefined; + "access-control-allow-credentials"?: string | undefined; + "access-control-allow-headers"?: string | undefined; + "access-control-allow-methods"?: string | undefined; + "access-control-allow-origin"?: string | undefined; + "access-control-expose-headers"?: string | undefined; + "access-control-max-age"?: string | undefined; + "access-control-request-headers"?: string | undefined; + "access-control-request-method"?: string | undefined; + age?: string | undefined; + allow?: string | undefined; + authorization?: string | undefined; + "cache-control"?: string | undefined; + "cdn-cache-control"?: string | undefined; + connection?: string | string[] | undefined; + "content-disposition"?: string | undefined; + "content-encoding"?: string | undefined; + "content-language"?: string | undefined; + "content-length"?: string | number | undefined; + "content-location"?: string | undefined; + "content-range"?: string | undefined; + "content-security-policy"?: string | undefined; + "content-security-policy-report-only"?: string | undefined; + cookie?: string | string[] | undefined; + dav?: string | string[] | undefined; + dnt?: string | undefined; + date?: string | undefined; + etag?: string | undefined; + expect?: string | undefined; + expires?: string | undefined; + forwarded?: string | undefined; + from?: string | undefined; + host?: string | undefined; + "if-match"?: string | undefined; + "if-modified-since"?: string | undefined; + "if-none-match"?: string | undefined; + "if-range"?: string | undefined; + "if-unmodified-since"?: string | undefined; + "last-modified"?: string | undefined; + link?: string | string[] | undefined; + location?: string | undefined; + "max-forwards"?: string | undefined; + origin?: string | undefined; + prgama?: string | string[] | undefined; + "proxy-authenticate"?: string | string[] | undefined; + "proxy-authorization"?: string | undefined; + "public-key-pins"?: string | undefined; + "public-key-pins-report-only"?: string | undefined; + range?: string | undefined; + referer?: string | undefined; + "referrer-policy"?: string | undefined; + refresh?: string | undefined; + "retry-after"?: string | undefined; + "sec-websocket-accept"?: string | undefined; + "sec-websocket-extensions"?: string | string[] | undefined; + "sec-websocket-key"?: string | undefined; + "sec-websocket-protocol"?: string | string[] | undefined; + "sec-websocket-version"?: string | undefined; + server?: string | undefined; + "set-cookie"?: string | string[] | undefined; + "strict-transport-security"?: string | undefined; + te?: string | undefined; + trailer?: string | undefined; + "transfer-encoding"?: string | undefined; + "user-agent"?: string | undefined; + upgrade?: string | undefined; + "upgrade-insecure-requests"?: string | undefined; + vary?: string | undefined; + via?: string | string[] | undefined; + warning?: string | undefined; + "www-authenticate"?: string | string[] | undefined; + "x-content-type-options"?: string | undefined; + "x-dns-prefetch-control"?: string | undefined; + "x-frame-options"?: string | undefined; + "x-xss-protection"?: string | undefined; + } + interface ClientRequestArgs { + _defaultAgent?: Agent | undefined; + agent?: Agent | boolean | undefined; + auth?: string | null | undefined; + // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278 + createConnection?: + | ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket) + | undefined; + defaultPort?: number | string | undefined; + family?: number | undefined; + headers?: OutgoingHttpHeaders | undefined; + hints?: LookupOptions["hints"]; + host?: string | null | undefined; + hostname?: string | null | undefined; + insecureHTTPParser?: boolean | undefined; + localAddress?: string | undefined; + localPort?: number | undefined; + lookup?: LookupFunction | undefined; + /** + * @default 16384 + */ + maxHeaderSize?: number | undefined; + method?: string | undefined; + path?: string | null | undefined; + port?: number | string | null | undefined; + protocol?: string | null | undefined; + setHost?: boolean | undefined; + signal?: AbortSignal | undefined; + socketPath?: string | undefined; + timeout?: number | undefined; + uniqueHeaders?: Array | undefined; + joinDuplicateHeaders?: boolean; + } + interface ServerOptions< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + > { + /** + * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`. + */ + IncomingMessage?: Request | undefined; + /** + * Specifies the `ServerResponse` class to be used. Useful for extending the original `ServerResponse`. + */ + ServerResponse?: Response | undefined; + /** + * Sets the timeout value in milliseconds for receiving the entire request from the client. + * @see Server.requestTimeout for more information. + * @default 300000 + * @since v18.0.0 + */ + requestTimeout?: number | undefined; + /** + * It joins the field line values of multiple headers in a request with `, ` instead of discarding the duplicates. + * @default false + * @since v18.14.0 + */ + joinDuplicateHeaders?: boolean; + /** + * The number of milliseconds of inactivity a server needs to wait for additional incoming data, + * after it has finished writing the last response, before a socket will be destroyed. + * @see Server.keepAliveTimeout for more information. + * @default 5000 + * @since v18.0.0 + */ + keepAliveTimeout?: number | undefined; + /** + * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests. + * @default 30000 + */ + connectionsCheckingInterval?: number | undefined; + /** + * Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`. + * This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`. + * Default: @see stream.getDefaultHighWaterMark(). + * @since v20.1.0 + */ + highWaterMark?: number | undefined; + /** + * Use an insecure HTTP parser that accepts invalid HTTP headers when `true`. + * Using the insecure parser should be avoided. + * See --insecure-http-parser for more information. + * @default false + */ + insecureHTTPParser?: boolean | undefined; + /** + * Optionally overrides the value of + * `--max-http-header-size` for requests received by this server, i.e. + * the maximum length of request headers in bytes. + * @default 16384 + * @since v13.3.0 + */ + maxHeaderSize?: number | undefined; + /** + * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received. + * @default true + * @since v16.5.0 + */ + noDelay?: boolean | undefined; + /** + * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received, + * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`. + * @default false + * @since v16.5.0 + */ + keepAlive?: boolean | undefined; + /** + * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket. + * @default 0 + * @since v16.5.0 + */ + keepAliveInitialDelay?: number | undefined; + /** + * A list of response headers that should be sent only once. + * If the header's value is an array, the items will be joined using `; `. + */ + uniqueHeaders?: Array | undefined; + } + type RequestListener< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + > = (req: InstanceType, res: InstanceType & { req: InstanceType }) => void; + /** + * @since v0.1.17 + */ + class Server< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + > extends NetServer { + constructor(requestListener?: RequestListener); + constructor(options: ServerOptions, requestListener?: RequestListener); + /** + * Sets the timeout value for sockets, and emits a `'timeout'` event on + * the Server object, passing the socket as an argument, if a timeout + * occurs. + * + * If there is a `'timeout'` event listener on the Server object, then it + * will be called with the timed-out socket as an argument. + * + * By default, the Server does not timeout sockets. However, if a callback + * is assigned to the Server's `'timeout'` event, timeouts must be handled + * explicitly. + * @since v0.9.12 + * @param [msecs=0 (no timeout)] + */ + setTimeout(msecs?: number, callback?: () => void): this; + setTimeout(callback: () => void): this; + /** + * Limits maximum incoming headers count. If set to 0, no limit will be applied. + * @since v0.7.0 + */ + maxHeadersCount: number | null; + /** + * The maximum number of requests socket can handle + * before closing keep alive connection. + * + * A value of `0` will disable the limit. + * + * When the limit is reached it will set the `Connection` header value to `close`, + * but will not actually close the connection, subsequent requests sent + * after the limit is reached will get `503 Service Unavailable` as a response. + * @since v16.10.0 + */ + maxRequestsPerSocket: number | null; + /** + * The number of milliseconds of inactivity before a socket is presumed + * to have timed out. + * + * A value of `0` will disable the timeout behavior on incoming connections. + * + * The socket timeout logic is set up on connection, so changing this + * value only affects new connections to the server, not any existing connections. + * @since v0.9.12 + */ + timeout: number; + /** + * Limit the amount of time the parser will wait to receive the complete HTTP + * headers. + * + * If the timeout expires, the server responds with status 408 without + * forwarding the request to the request listener and then closes the connection. + * + * It must be set to a non-zero value (e.g. 120 seconds) to protect against + * potential Denial-of-Service attacks in case the server is deployed without a + * reverse proxy in front. + * @since v11.3.0, v10.14.0 + */ + headersTimeout: number; + /** + * The number of milliseconds of inactivity a server needs to wait for additional + * incoming data, after it has finished writing the last response, before a socket + * will be destroyed. If the server receives new data before the keep-alive + * timeout has fired, it will reset the regular inactivity timeout, i.e.,`server.timeout`. + * + * A value of `0` will disable the keep-alive timeout behavior on incoming + * connections. + * A value of `0` makes the http server behave similarly to Node.js versions prior + * to 8.0.0, which did not have a keep-alive timeout. + * + * The socket timeout logic is set up on connection, so changing this value only + * affects new connections to the server, not any existing connections. + * @since v8.0.0 + */ + keepAliveTimeout: number; + /** + * Sets the timeout value in milliseconds for receiving the entire request from + * the client. + * + * If the timeout expires, the server responds with status 408 without + * forwarding the request to the request listener and then closes the connection. + * + * It must be set to a non-zero value (e.g. 120 seconds) to protect against + * potential Denial-of-Service attacks in case the server is deployed without a + * reverse proxy in front. + * @since v14.11.0 + */ + requestTimeout: number; + /** + * Closes all connections connected to this server. + * @since v18.2.0 + */ + closeAllConnections(): void; + /** + * Closes all connections connected to this server which are not sending a request + * or waiting for a response. + * @since v18.2.0 + */ + closeIdleConnections(): void; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connection", listener: (socket: Socket) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "checkContinue", listener: RequestListener): this; + addListener(event: "checkExpectation", listener: RequestListener): this; + addListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + addListener( + event: "connect", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + addListener(event: "dropRequest", listener: (req: InstanceType, socket: stream.Duplex) => void): this; + addListener(event: "request", listener: RequestListener): this; + addListener( + event: "upgrade", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + emit(event: string, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "connection", socket: Socket): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit( + event: "checkContinue", + req: InstanceType, + res: InstanceType & { req: InstanceType }, + ): boolean; + emit( + event: "checkExpectation", + req: InstanceType, + res: InstanceType & { req: InstanceType }, + ): boolean; + emit(event: "clientError", err: Error, socket: stream.Duplex): boolean; + emit(event: "connect", req: InstanceType, socket: stream.Duplex, head: Buffer): boolean; + emit(event: "dropRequest", req: InstanceType, socket: stream.Duplex): boolean; + emit( + event: "request", + req: InstanceType, + res: InstanceType & { req: InstanceType }, + ): boolean; + emit(event: "upgrade", req: InstanceType, socket: stream.Duplex, head: Buffer): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connection", listener: (socket: Socket) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "checkContinue", listener: RequestListener): this; + on(event: "checkExpectation", listener: RequestListener): this; + on(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + on(event: "connect", listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + on(event: "dropRequest", listener: (req: InstanceType, socket: stream.Duplex) => void): this; + on(event: "request", listener: RequestListener): this; + on(event: "upgrade", listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connection", listener: (socket: Socket) => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "checkContinue", listener: RequestListener): this; + once(event: "checkExpectation", listener: RequestListener): this; + once(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + once( + event: "connect", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + once(event: "dropRequest", listener: (req: InstanceType, socket: stream.Duplex) => void): this; + once(event: "request", listener: RequestListener): this; + once( + event: "upgrade", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connection", listener: (socket: Socket) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "checkContinue", listener: RequestListener): this; + prependListener(event: "checkExpectation", listener: RequestListener): this; + prependListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + prependListener( + event: "connect", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + prependListener( + event: "dropRequest", + listener: (req: InstanceType, socket: stream.Duplex) => void, + ): this; + prependListener(event: "request", listener: RequestListener): this; + prependListener( + event: "upgrade", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "checkContinue", listener: RequestListener): this; + prependOnceListener(event: "checkExpectation", listener: RequestListener): this; + prependOnceListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this; + prependOnceListener( + event: "connect", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + prependOnceListener( + event: "dropRequest", + listener: (req: InstanceType, socket: stream.Duplex) => void, + ): this; + prependOnceListener(event: "request", listener: RequestListener): this; + prependOnceListener( + event: "upgrade", + listener: (req: InstanceType, socket: stream.Duplex, head: Buffer) => void, + ): this; + } + /** + * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from + * the perspective of the participants of an HTTP transaction. + * @since v0.1.17 + */ + class OutgoingMessage extends stream.Writable { + readonly req: Request; + chunkedEncoding: boolean; + shouldKeepAlive: boolean; + useChunkedEncodingByDefault: boolean; + sendDate: boolean; + /** + * @deprecated Use `writableEnded` instead. + */ + finished: boolean; + /** + * Read-only. `true` if the headers were sent, otherwise `false`. + * @since v0.9.3 + */ + readonly headersSent: boolean; + /** + * Alias of `outgoingMessage.socket`. + * @since v0.3.0 + * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead. + */ + readonly connection: Socket | null; + /** + * Reference to the underlying socket. Usually, users will not want to access + * this property. + * + * After calling `outgoingMessage.end()`, this property will be nulled. + * @since v0.3.0 + */ + readonly socket: Socket | null; + constructor(); + /** + * Once a socket is associated with the message and is connected,`socket.setTimeout()` will be called with `msecs` as the first parameter. + * @since v0.9.12 + * @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event. + */ + setTimeout(msecs: number, callback?: () => void): this; + /** + * Sets a single header value. If the header already exists in the to-be-sent + * headers, its value will be replaced. Use an array of strings to send multiple + * headers with the same name. + * @since v0.4.0 + * @param name Header name + * @param value Header value + */ + setHeader(name: string, value: number | string | readonly string[]): this; + /** + * Append a single header value for the header object. + * + * If the value is an array, this is equivalent of calling this method multiple + * times. + * + * If there were no previous value for the header, this is equivalent of calling `outgoingMessage.setHeader(name, value)`. + * + * Depending of the value of `options.uniqueHeaders` when the client request or the + * server were created, this will end up in the header being sent multiple times or + * a single time with values joined using `; `. + * @since v18.3.0, v16.17.0 + * @param name Header name + * @param value Header value + */ + appendHeader(name: string, value: string | readonly string[]): this; + /** + * Gets the value of the HTTP header with the given name. If that header is not + * set, the returned value will be `undefined`. + * @since v0.4.0 + * @param name Name of header + */ + getHeader(name: string): number | string | string[] | undefined; + /** + * Returns a shallow copy of the current outgoing headers. Since a shallow + * copy is used, array values may be mutated without additional calls to + * various header-related HTTP module methods. The keys of the returned + * object are the header names and the values are the respective header + * values. All header names are lowercase. + * + * The object returned by the `outgoingMessage.getHeaders()` method does + * not prototypically inherit from the JavaScript `Object`. This means that + * typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`, + * and others are not defined and will not work. + * + * ```js + * outgoingMessage.setHeader('Foo', 'bar'); + * outgoingMessage.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); + * + * const headers = outgoingMessage.getHeaders(); + * // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] } + * ``` + * @since v7.7.0 + */ + getHeaders(): OutgoingHttpHeaders; + /** + * Returns an array containing the unique names of the current outgoing headers. + * All names are lowercase. + * @since v7.7.0 + */ + getHeaderNames(): string[]; + /** + * Returns `true` if the header identified by `name` is currently set in the + * outgoing headers. The header name is case-insensitive. + * + * ```js + * const hasContentType = outgoingMessage.hasHeader('content-type'); + * ``` + * @since v7.7.0 + */ + hasHeader(name: string): boolean; + /** + * Removes a header that is queued for implicit sending. + * + * ```js + * outgoingMessage.removeHeader('Content-Encoding'); + * ``` + * @since v0.4.0 + * @param name Header name + */ + removeHeader(name: string): void; + /** + * Adds HTTP trailers (headers but at the end of the message) to the message. + * + * Trailers will **only** be emitted if the message is chunked encoded. If not, + * the trailers will be silently discarded. + * + * HTTP requires the `Trailer` header to be sent to emit trailers, + * with a list of header field names in its value, e.g. + * + * ```js + * message.writeHead(200, { 'Content-Type': 'text/plain', + * 'Trailer': 'Content-MD5' }); + * message.write(fileData); + * message.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' }); + * message.end(); + * ``` + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a `TypeError` being thrown. + * @since v0.3.0 + */ + addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void; + /** + * Flushes the message headers. + * + * For efficiency reason, Node.js normally buffers the message headers + * until `outgoingMessage.end()` is called or the first chunk of message data + * is written. It then tries to pack the headers and data into a single TCP + * packet. + * + * It is usually desired (it saves a TCP round-trip), but not when the first + * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message. + * @since v1.6.0 + */ + flushHeaders(): void; + } + /** + * This object is created internally by an HTTP server, not by the user. It is + * passed as the second parameter to the `'request'` event. + * @since v0.1.17 + */ + class ServerResponse extends OutgoingMessage { + /** + * When using implicit headers (not calling `response.writeHead()` explicitly), + * this property controls the status code that will be sent to the client when + * the headers get flushed. + * + * ```js + * response.statusCode = 404; + * ``` + * + * After response header was sent to the client, this property indicates the + * status code which was sent out. + * @since v0.4.0 + */ + statusCode: number; + /** + * When using implicit headers (not calling `response.writeHead()` explicitly), + * this property controls the status message that will be sent to the client when + * the headers get flushed. If this is left as `undefined` then the standard + * message for the status code will be used. + * + * ```js + * response.statusMessage = 'Not found'; + * ``` + * + * After response header was sent to the client, this property indicates the + * status message which was sent out. + * @since v0.11.8 + */ + statusMessage: string; + /** + * If set to `true`, Node.js will check whether the `Content-Length`header value and the size of the body, in bytes, are equal. + * Mismatching the `Content-Length` header value will result + * in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`. + * @since v18.10.0, v16.18.0 + */ + strictContentLength: boolean; + constructor(req: Request); + assignSocket(socket: Socket): void; + detachSocket(socket: Socket): void; + /** + * Sends an HTTP/1.1 100 Continue message to the client, indicating that + * the request body should be sent. See the `'checkContinue'` event on`Server`. + * @since v0.3.0 + */ + writeContinue(callback?: () => void): void; + /** + * Sends an HTTP/1.1 103 Early Hints message to the client with a Link header, + * indicating that the user agent can preload/preconnect the linked resources. + * The `hints` is an object containing the values of headers to be sent with + * early hints message. The optional `callback` argument will be called when + * the response message has been written. + * + * **Example** + * + * ```js + * const earlyHintsLink = '; rel=preload; as=style'; + * response.writeEarlyHints({ + * 'link': earlyHintsLink, + * }); + * + * const earlyHintsLinks = [ + * '; rel=preload; as=style', + * '; rel=preload; as=script', + * ]; + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * 'x-trace-id': 'id for diagnostics', + * }); + * + * const earlyHintsCallback = () => console.log('early hints message sent'); + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * }, earlyHintsCallback); + * ``` + * @since v18.11.0 + * @param hints An object containing the values of headers + * @param callback Will be called when the response message has been written + */ + writeEarlyHints(hints: Record, callback?: () => void): void; + /** + * Sends a response header to the request. The status code is a 3-digit HTTP + * status code, like `404`. The last argument, `headers`, are the response headers. + * Optionally one can give a human-readable `statusMessage` as the second + * argument. + * + * `headers` may be an `Array` where the keys and values are in the same list. + * It is _not_ a list of tuples. So, the even-numbered offsets are key values, + * and the odd-numbered offsets are the associated values. The array is in the same + * format as `request.rawHeaders`. + * + * Returns a reference to the `ServerResponse`, so that calls can be chained. + * + * ```js + * const body = 'hello world'; + * response + * .writeHead(200, { + * 'Content-Length': Buffer.byteLength(body), + * 'Content-Type': 'text/plain', + * }) + * .end(body); + * ``` + * + * This method must only be called once on a message and it must + * be called before `response.end()` is called. + * + * If `response.write()` or `response.end()` are called before calling + * this, the implicit/mutable headers will be calculated and call this function. + * + * When headers have been set with `response.setHeader()`, they will be merged + * with any headers passed to `response.writeHead()`, with the headers passed + * to `response.writeHead()` given precedence. + * + * If this method is called and `response.setHeader()` has not been called, + * it will directly write the supplied header values onto the network channel + * without caching internally, and the `response.getHeader()` on the header + * will not yield the expected result. If progressive population of headers is + * desired with potential future retrieval and modification, use `response.setHeader()` instead. + * + * ```js + * // Returns content-type = text/plain + * const server = http.createServer((req, res) => { + * res.setHeader('Content-Type', 'text/html'); + * res.setHeader('X-Foo', 'bar'); + * res.writeHead(200, { 'Content-Type': 'text/plain' }); + * res.end('ok'); + * }); + * ``` + * + * `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js + * will check whether `Content-Length` and the length of the body which has + * been transmitted are equal or not. + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a \[`Error`\]\[\] being thrown. + * @since v0.1.30 + */ + writeHead( + statusCode: number, + statusMessage?: string, + headers?: OutgoingHttpHeaders | OutgoingHttpHeader[], + ): this; + writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this; + /** + * Sends a HTTP/1.1 102 Processing message to the client, indicating that + * the request body should be sent. + * @since v10.0.0 + */ + writeProcessing(): void; + } + interface InformationEvent { + statusCode: number; + statusMessage: string; + httpVersion: string; + httpVersionMajor: number; + httpVersionMinor: number; + headers: IncomingHttpHeaders; + rawHeaders: string[]; + } + /** + * This object is created internally and returned from {@link request}. It + * represents an _in-progress_ request whose header has already been queued. The + * header is still mutable using the `setHeader(name, value)`,`getHeader(name)`, `removeHeader(name)` API. The actual header will + * be sent along with the first data chunk or when calling `request.end()`. + * + * To get the response, add a listener for `'response'` to the request object.`'response'` will be emitted from the request object when the response + * headers have been received. The `'response'` event is executed with one + * argument which is an instance of {@link IncomingMessage}. + * + * During the `'response'` event, one can add listeners to the + * response object; particularly to listen for the `'data'` event. + * + * If no `'response'` handler is added, then the response will be + * entirely discarded. However, if a `'response'` event handler is added, + * then the data from the response object **must** be consumed, either by + * calling `response.read()` whenever there is a `'readable'` event, or + * by adding a `'data'` handler, or by calling the `.resume()` method. + * Until the data is consumed, the `'end'` event will not fire. Also, until + * the data is read it will consume memory that can eventually lead to a + * 'process out of memory' error. + * + * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered. + * + * Set `Content-Length` header to limit the response body size. + * If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown, + * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`. + * + * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. + * @since v0.1.17 + */ + class ClientRequest extends OutgoingMessage { + /** + * The `request.aborted` property will be `true` if the request has + * been aborted. + * @since v0.11.14 + * @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead. + */ + aborted: boolean; + /** + * The request host. + * @since v14.5.0, v12.19.0 + */ + host: string; + /** + * The request protocol. + * @since v14.5.0, v12.19.0 + */ + protocol: string; + /** + * When sending request through a keep-alive enabled agent, the underlying socket + * might be reused. But if server closes connection at unfortunate time, client + * may run into a 'ECONNRESET' error. + * + * ```js + * import http from 'node:http'; + * + * // Server has a 5 seconds keep-alive timeout by default + * http + * .createServer((req, res) => { + * res.write('hello\n'); + * res.end(); + * }) + * .listen(3000); + * + * setInterval(() => { + * // Adapting a keep-alive agent + * http.get('http://localhost:3000', { agent }, (res) => { + * res.on('data', (data) => { + * // Do nothing + * }); + * }); + * }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout + * ``` + * + * By marking a request whether it reused socket or not, we can do + * automatic error retry base on it. + * + * ```js + * import http from 'node:http'; + * const agent = new http.Agent({ keepAlive: true }); + * + * function retriableRequest() { + * const req = http + * .get('http://localhost:3000', { agent }, (res) => { + * // ... + * }) + * .on('error', (err) => { + * // Check if retry is needed + * if (req.reusedSocket && err.code === 'ECONNRESET') { + * retriableRequest(); + * } + * }); + * } + * + * retriableRequest(); + * ``` + * @since v13.0.0, v12.16.0 + */ + reusedSocket: boolean; + /** + * Limits maximum response headers count. If set to 0, no limit will be applied. + */ + maxHeadersCount: number; + constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void); + /** + * The request method. + * @since v0.1.97 + */ + method: string; + /** + * The request path. + * @since v0.4.0 + */ + path: string; + /** + * Marks the request as aborting. Calling this will cause remaining data + * in the response to be dropped and the socket to be destroyed. + * @since v0.3.8 + * @deprecated Since v14.1.0,v13.14.0 - Use `destroy` instead. + */ + abort(): void; + onSocket(socket: Socket): void; + /** + * Once a socket is assigned to this request and is connected `socket.setTimeout()` will be called. + * @since v0.5.9 + * @param timeout Milliseconds before a request times out. + * @param callback Optional function to be called when a timeout occurs. Same as binding to the `'timeout'` event. + */ + setTimeout(timeout: number, callback?: () => void): this; + /** + * Once a socket is assigned to this request and is connected `socket.setNoDelay()` will be called. + * @since v0.5.9 + */ + setNoDelay(noDelay?: boolean): void; + /** + * Once a socket is assigned to this request and is connected `socket.setKeepAlive()` will be called. + * @since v0.5.9 + */ + setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; + /** + * Returns an array containing the unique names of the current outgoing raw + * headers. Header names are returned with their exact casing being set. + * + * ```js + * request.setHeader('Foo', 'bar'); + * request.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); + * + * const headerNames = request.getRawHeaderNames(); + * // headerNames === ['Foo', 'Set-Cookie'] + * ``` + * @since v15.13.0, v14.17.0 + */ + getRawHeaderNames(): string[]; + /** + * @deprecated + */ + addListener(event: "abort", listener: () => void): this; + addListener( + event: "connect", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + addListener(event: "continue", listener: () => void): this; + addListener(event: "information", listener: (info: InformationEvent) => void): this; + addListener(event: "response", listener: (response: IncomingMessage) => void): this; + addListener(event: "socket", listener: (socket: Socket) => void): this; + addListener(event: "timeout", listener: () => void): this; + addListener( + event: "upgrade", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pipe", listener: (src: stream.Readable) => void): this; + addListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + /** + * @deprecated + */ + on(event: "abort", listener: () => void): this; + on(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; + on(event: "continue", listener: () => void): this; + on(event: "information", listener: (info: InformationEvent) => void): this; + on(event: "response", listener: (response: IncomingMessage) => void): this; + on(event: "socket", listener: (socket: Socket) => void): this; + on(event: "timeout", listener: () => void): this; + on(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + /** + * @deprecated + */ + once(event: "abort", listener: () => void): this; + once(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; + once(event: "continue", listener: () => void): this; + once(event: "information", listener: (info: InformationEvent) => void): this; + once(event: "response", listener: (response: IncomingMessage) => void): this; + once(event: "socket", listener: (socket: Socket) => void): this; + once(event: "timeout", listener: () => void): this; + once(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + /** + * @deprecated + */ + prependListener(event: "abort", listener: () => void): this; + prependListener( + event: "connect", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + prependListener(event: "continue", listener: () => void): this; + prependListener(event: "information", listener: (info: InformationEvent) => void): this; + prependListener(event: "response", listener: (response: IncomingMessage) => void): this; + prependListener(event: "socket", listener: (socket: Socket) => void): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener( + event: "upgrade", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + /** + * @deprecated + */ + prependOnceListener(event: "abort", listener: () => void): this; + prependOnceListener( + event: "connect", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + prependOnceListener(event: "continue", listener: () => void): this; + prependOnceListener(event: "information", listener: (info: InformationEvent) => void): this; + prependOnceListener(event: "response", listener: (response: IncomingMessage) => void): this; + prependOnceListener(event: "socket", listener: (socket: Socket) => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener( + event: "upgrade", + listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void, + ): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to + * access response + * status, headers, and data. + * + * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to + * parse and emit the incoming HTTP headers and payload, as the underlying socket + * may be reused multiple times in case of keep-alive. + * @since v0.1.17 + */ + class IncomingMessage extends stream.Readable { + constructor(socket: Socket); + /** + * The `message.aborted` property will be `true` if the request has + * been aborted. + * @since v10.1.0 + * @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from stream.Readable. + */ + aborted: boolean; + /** + * In case of server request, the HTTP version sent by the client. In the case of + * client response, the HTTP version of the connected-to server. + * Probably either `'1.1'` or `'1.0'`. + * + * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second. + * @since v0.1.1 + */ + httpVersion: string; + httpVersionMajor: number; + httpVersionMinor: number; + /** + * The `message.complete` property will be `true` if a complete HTTP message has + * been received and successfully parsed. + * + * This property is particularly useful as a means of determining if a client or + * server fully transmitted a message before a connection was terminated: + * + * ```js + * const req = http.request({ + * host: '127.0.0.1', + * port: 8080, + * method: 'POST', + * }, (res) => { + * res.resume(); + * res.on('end', () => { + * if (!res.complete) + * console.error( + * 'The connection was terminated while the message was still being sent'); + * }); + * }); + * ``` + * @since v0.3.0 + */ + complete: boolean; + /** + * Alias for `message.socket`. + * @since v0.1.90 + * @deprecated Since v16.0.0 - Use `socket`. + */ + connection: Socket; + /** + * The `net.Socket` object associated with the connection. + * + * With HTTPS support, use `request.socket.getPeerCertificate()` to obtain the + * client's authentication details. + * + * This property is guaranteed to be an instance of the `net.Socket` class, + * a subclass of `stream.Duplex`, unless the user specified a socket + * type other than `net.Socket` or internally nulled. + * @since v0.3.0 + */ + socket: Socket; + /** + * The request/response headers object. + * + * Key-value pairs of header names and values. Header names are lower-cased. + * + * ```js + * // Prints something like: + * // + * // { 'user-agent': 'curl/7.22.0', + * // host: '127.0.0.1:8000', + * // accept: '*' } + * console.log(request.headers); + * ``` + * + * Duplicates in raw headers are handled in the following ways, depending on the + * header name: + * + * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`, + * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded. + * To allow duplicate values of the headers listed above to be joined, + * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more + * information. + * * `set-cookie` is always an array. Duplicates are added to the array. + * * For duplicate `cookie` headers, the values are joined together with `; `. + * * For all other headers, the values are joined together with `, `. + * @since v0.1.5 + */ + headers: IncomingHttpHeaders; + /** + * Similar to `message.headers`, but there is no join logic and the values are + * always arrays of strings, even for headers received just once. + * + * ```js + * // Prints something like: + * // + * // { 'user-agent': ['curl/7.22.0'], + * // host: ['127.0.0.1:8000'], + * // accept: ['*'] } + * console.log(request.headersDistinct); + * ``` + * @since v18.3.0, v16.17.0 + */ + headersDistinct: NodeJS.Dict; + /** + * The raw request/response headers list exactly as they were received. + * + * The keys and values are in the same list. It is _not_ a + * list of tuples. So, the even-numbered offsets are key values, and the + * odd-numbered offsets are the associated values. + * + * Header names are not lowercased, and duplicates are not merged. + * + * ```js + * // Prints something like: + * // + * // [ 'user-agent', + * // 'this is invalid because there can be only one', + * // 'User-Agent', + * // 'curl/7.22.0', + * // 'Host', + * // '127.0.0.1:8000', + * // 'ACCEPT', + * // '*' ] + * console.log(request.rawHeaders); + * ``` + * @since v0.11.6 + */ + rawHeaders: string[]; + /** + * The request/response trailers object. Only populated at the `'end'` event. + * @since v0.3.0 + */ + trailers: NodeJS.Dict; + /** + * Similar to `message.trailers`, but there is no join logic and the values are + * always arrays of strings, even for headers received just once. + * Only populated at the `'end'` event. + * @since v18.3.0, v16.17.0 + */ + trailersDistinct: NodeJS.Dict; + /** + * The raw request/response trailer keys and values exactly as they were + * received. Only populated at the `'end'` event. + * @since v0.11.6 + */ + rawTrailers: string[]; + /** + * Calls `message.socket.setTimeout(msecs, callback)`. + * @since v0.5.9 + */ + setTimeout(msecs: number, callback?: () => void): this; + /** + * **Only valid for request obtained from {@link Server}.** + * + * The request method as a string. Read only. Examples: `'GET'`, `'DELETE'`. + * @since v0.1.1 + */ + method?: string | undefined; + /** + * **Only valid for request obtained from {@link Server}.** + * + * Request URL string. This contains only the URL that is present in the actual + * HTTP request. Take the following request: + * + * ```http + * GET /status?name=ryan HTTP/1.1 + * Accept: text/plain + * ``` + * + * To parse the URL into its parts: + * + * ```js + * new URL(request.url, `http://${request.headers.host}`); + * ``` + * + * When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`: + * + * ```console + * $ node + * > new URL(request.url, `http://${request.headers.host}`) + * URL { + * href: 'http://localhost:3000/status?name=ryan', + * origin: 'http://localhost:3000', + * protocol: 'http:', + * username: '', + * password: '', + * host: 'localhost:3000', + * hostname: 'localhost', + * port: '3000', + * pathname: '/status', + * search: '?name=ryan', + * searchParams: URLSearchParams { 'name' => 'ryan' }, + * hash: '' + * } + * ``` + * @since v0.1.90 + */ + url?: string | undefined; + /** + * **Only valid for response obtained from {@link ClientRequest}.** + * + * The 3-digit HTTP response status code. E.G. `404`. + * @since v0.1.1 + */ + statusCode?: number | undefined; + /** + * **Only valid for response obtained from {@link ClientRequest}.** + * + * The HTTP response status message (reason phrase). E.G. `OK` or `Internal Server Error`. + * @since v0.11.10 + */ + statusMessage?: string | undefined; + /** + * Calls `destroy()` on the socket that received the `IncomingMessage`. If `error`is provided, an `'error'` event is emitted on the socket and `error` is passed + * as an argument to any listeners on the event. + * @since v0.3.0 + */ + destroy(error?: Error): this; + } + interface AgentOptions extends Partial { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean | undefined; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number | undefined; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number | undefined; + /** + * Maximum number of sockets allowed for all hosts in total. Each request will use a new socket until the maximum is reached. Default: Infinity. + */ + maxTotalSockets?: number | undefined; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number | undefined; + /** + * Socket timeout in milliseconds. This will set the timeout after the socket is connected. + */ + timeout?: number | undefined; + /** + * Scheduling strategy to apply when picking the next free socket to use. + * @default `lifo` + */ + scheduling?: "fifo" | "lifo" | undefined; + } + /** + * An `Agent` is responsible for managing connection persistence + * and reuse for HTTP clients. It maintains a queue of pending requests + * for a given host and port, reusing a single socket connection for each + * until the queue is empty, at which time the socket is either destroyed + * or put into a pool where it is kept to be used again for requests to the + * same host and port. Whether it is destroyed or pooled depends on the`keepAlive` `option`. + * + * Pooled connections have TCP Keep-Alive enabled for them, but servers may + * still close idle connections, in which case they will be removed from the + * pool and a new connection will be made when a new HTTP request is made for + * that host and port. Servers may also refuse to allow multiple requests + * over the same connection, in which case the connection will have to be + * remade for every request and cannot be pooled. The `Agent` will still make + * the requests to that server, but each one will occur over a new connection. + * + * When a connection is closed by the client or the server, it is removed + * from the pool. Any unused sockets in the pool will be unrefed so as not + * to keep the Node.js process running when there are no outstanding requests. + * (see `socket.unref()`). + * + * It is good practice, to `destroy()` an `Agent` instance when it is no + * longer in use, because unused sockets consume OS resources. + * + * Sockets are removed from an agent when the socket emits either + * a `'close'` event or an `'agentRemove'` event. When intending to keep one + * HTTP request open for a long time without keeping it in the agent, something + * like the following may be done: + * + * ```js + * http.get(options, (res) => { + * // Do stuff + * }).on('socket', (socket) => { + * socket.emit('agentRemove'); + * }); + * ``` + * + * An agent may also be used for an individual request. By providing`{agent: false}` as an option to the `http.get()` or `http.request()`functions, a one-time use `Agent` with default options + * will be used + * for the client connection. + * + * `agent:false`: + * + * ```js + * http.get({ + * hostname: 'localhost', + * port: 80, + * path: '/', + * agent: false, // Create a new agent just for this one request + * }, (res) => { + * // Do stuff with response + * }); + * ``` + * @since v0.3.4 + */ + class Agent extends EventEmitter { + /** + * By default set to 256. For agents with `keepAlive` enabled, this + * sets the maximum number of sockets that will be left open in the free + * state. + * @since v0.11.7 + */ + maxFreeSockets: number; + /** + * By default set to `Infinity`. Determines how many concurrent sockets the agent + * can have open per origin. Origin is the returned value of `agent.getName()`. + * @since v0.3.6 + */ + maxSockets: number; + /** + * By default set to `Infinity`. Determines how many concurrent sockets the agent + * can have open. Unlike `maxSockets`, this parameter applies across all origins. + * @since v14.5.0, v12.19.0 + */ + maxTotalSockets: number; + /** + * An object which contains arrays of sockets currently awaiting use by + * the agent when `keepAlive` is enabled. Do not modify. + * + * Sockets in the `freeSockets` list will be automatically destroyed and + * removed from the array on `'timeout'`. + * @since v0.11.4 + */ + readonly freeSockets: NodeJS.ReadOnlyDict; + /** + * An object which contains arrays of sockets currently in use by the + * agent. Do not modify. + * @since v0.3.6 + */ + readonly sockets: NodeJS.ReadOnlyDict; + /** + * An object which contains queues of requests that have not yet been assigned to + * sockets. Do not modify. + * @since v0.5.9 + */ + readonly requests: NodeJS.ReadOnlyDict; + constructor(opts?: AgentOptions); + /** + * Destroy any sockets that are currently in use by the agent. + * + * It is usually not necessary to do this. However, if using an + * agent with `keepAlive` enabled, then it is best to explicitly shut down + * the agent when it is no longer needed. Otherwise, + * sockets might stay open for quite a long time before the server + * terminates them. + * @since v0.11.4 + */ + destroy(): void; + } + const METHODS: string[]; + const STATUS_CODES: { + [errorCode: number]: string | undefined; + [errorCode: string]: string | undefined; + }; + /** + * Returns a new instance of {@link Server}. + * + * The `requestListener` is a function which is automatically + * added to the `'request'` event. + * + * ```js + * import http from 'node:http'; + * + * // Create a local server to receive data from + * const server = http.createServer((req, res) => { + * res.writeHead(200, { 'Content-Type': 'application/json' }); + * res.end(JSON.stringify({ + * data: 'Hello World!', + * })); + * }); + * + * server.listen(8000); + * ``` + * + * ```js + * import http from 'node:http'; + * + * // Create a local server to receive data from + * const server = http.createServer(); + * + * // Listen to the request event + * server.on('request', (request, res) => { + * res.writeHead(200, { 'Content-Type': 'application/json' }); + * res.end(JSON.stringify({ + * data: 'Hello World!', + * })); + * }); + * + * server.listen(8000); + * ``` + * @since v0.1.13 + */ + function createServer< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + >(requestListener?: RequestListener): Server; + function createServer< + Request extends typeof IncomingMessage = typeof IncomingMessage, + Response extends typeof ServerResponse = typeof ServerResponse, + >( + options: ServerOptions, + requestListener?: RequestListener, + ): Server; + // although RequestOptions are passed as ClientRequestArgs to ClientRequest directly, + // create interface RequestOptions would make the naming more clear to developers + interface RequestOptions extends ClientRequestArgs {} + /** + * `options` in `socket.connect()` are also supported. + * + * Node.js maintains several connections per server to make HTTP requests. + * This function allows one to transparently issue requests. + * + * `url` can be a string or a `URL` object. If `url` is a + * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object. + * + * If both `url` and `options` are specified, the objects are merged, with the`options` properties taking precedence. + * + * The optional `callback` parameter will be added as a one-time listener for + * the `'response'` event. + * + * `http.request()` returns an instance of the {@link ClientRequest} class. The `ClientRequest` instance is a writable stream. If one needs to + * upload a file with a POST request, then write to the `ClientRequest` object. + * + * ```js + * import http from 'node:http'; + * import { Buffer } from 'node:buffer'; + * + * const postData = JSON.stringify({ + * 'msg': 'Hello World!', + * }); + * + * const options = { + * hostname: 'www.google.com', + * port: 80, + * path: '/upload', + * method: 'POST', + * headers: { + * 'Content-Type': 'application/json', + * 'Content-Length': Buffer.byteLength(postData), + * }, + * }; + * + * const req = http.request(options, (res) => { + * console.log(`STATUS: ${res.statusCode}`); + * console.log(`HEADERS: ${JSON.stringify(res.headers)}`); + * res.setEncoding('utf8'); + * res.on('data', (chunk) => { + * console.log(`BODY: ${chunk}`); + * }); + * res.on('end', () => { + * console.log('No more data in response.'); + * }); + * }); + * + * req.on('error', (e) => { + * console.error(`problem with request: ${e.message}`); + * }); + * + * // Write data to request body + * req.write(postData); + * req.end(); + * ``` + * + * In the example `req.end()` was called. With `http.request()` one + * must always call `req.end()` to signify the end of the request - + * even if there is no data being written to the request body. + * + * If any error is encountered during the request (be that with DNS resolution, + * TCP level errors, or actual HTTP parse errors) an `'error'` event is emitted + * on the returned request object. As with all `'error'` events, if no listeners + * are registered the error will be thrown. + * + * There are a few special headers that should be noted. + * + * * Sending a 'Connection: keep-alive' will notify Node.js that the connection to + * the server should be persisted until the next request. + * * Sending a 'Content-Length' header will disable the default chunked encoding. + * * Sending an 'Expect' header will immediately send the request headers. + * Usually, when sending 'Expect: 100-continue', both a timeout and a listener + * for the `'continue'` event should be set. See RFC 2616 Section 8.2.3 for more + * information. + * * Sending an Authorization header will override using the `auth` option + * to compute basic authentication. + * + * Example using a `URL` as `options`: + * + * ```js + * const options = new URL('http://abc:xyz@example.com'); + * + * const req = http.request(options, (res) => { + * // ... + * }); + * ``` + * + * In a successful request, the following events will be emitted in the following + * order: + * + * * `'socket'` + * * `'response'` + * * `'data'` any number of times, on the `res` object + * (`'data'` will not be emitted at all if the response body is empty, for + * instance, in most redirects) + * * `'end'` on the `res` object + * * `'close'` + * + * In the case of a connection error, the following events will be emitted: + * + * * `'socket'` + * * `'error'` + * * `'close'` + * + * In the case of a premature connection close before the response is received, + * the following events will be emitted in the following order: + * + * * `'socket'` + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'` + * * `'close'` + * + * In the case of a premature connection close after the response is received, + * the following events will be emitted in the following order: + * + * * `'socket'` + * * `'response'` + * * `'data'` any number of times, on the `res` object + * * (connection closed here) + * * `'aborted'` on the `res` object + * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'` + * * `'close'` + * * `'close'` on the `res` object + * + * If `req.destroy()` is called before a socket is assigned, the following + * events will be emitted in the following order: + * + * * (`req.destroy()` called here) + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called + * * `'close'` + * + * If `req.destroy()` is called before the connection succeeds, the following + * events will be emitted in the following order: + * + * * `'socket'` + * * (`req.destroy()` called here) + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called + * * `'close'` + * + * If `req.destroy()` is called after the response is received, the following + * events will be emitted in the following order: + * + * * `'socket'` + * * `'response'` + * * `'data'` any number of times, on the `res` object + * * (`req.destroy()` called here) + * * `'aborted'` on the `res` object + * * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called + * * `'close'` + * * `'close'` on the `res` object + * + * If `req.abort()` is called before a socket is assigned, the following + * events will be emitted in the following order: + * + * * (`req.abort()` called here) + * * `'abort'` + * * `'close'` + * + * If `req.abort()` is called before the connection succeeds, the following + * events will be emitted in the following order: + * + * * `'socket'` + * * (`req.abort()` called here) + * * `'abort'` + * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'` + * * `'close'` + * + * If `req.abort()` is called after the response is received, the following + * events will be emitted in the following order: + * + * * `'socket'` + * * `'response'` + * * `'data'` any number of times, on the `res` object + * * (`req.abort()` called here) + * * `'abort'` + * * `'aborted'` on the `res` object + * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`. + * * `'close'` + * * `'close'` on the `res` object + * + * Setting the `timeout` option or using the `setTimeout()` function will + * not abort the request or do anything besides add a `'timeout'` event. + * + * Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the + * request. Specifically, the `'error'` event will be emitted with an error with + * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided. + * @since v0.3.6 + */ + function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; + function request( + url: string | URL, + options: RequestOptions, + callback?: (res: IncomingMessage) => void, + ): ClientRequest; + /** + * Since most requests are GET requests without bodies, Node.js provides this + * convenience method. The only difference between this method and {@link request} is that it sets the method to GET by default and calls `req.end()`automatically. The callback must take care to + * consume the response + * data for reasons stated in {@link ClientRequest} section. + * + * The `callback` is invoked with a single argument that is an instance of {@link IncomingMessage}. + * + * JSON fetching example: + * + * ```js + * http.get('http://localhost:8000/', (res) => { + * const { statusCode } = res; + * const contentType = res.headers['content-type']; + * + * let error; + * // Any 2xx status code signals a successful response but + * // here we're only checking for 200. + * if (statusCode !== 200) { + * error = new Error('Request Failed.\n' + + * `Status Code: ${statusCode}`); + * } else if (!/^application\/json/.test(contentType)) { + * error = new Error('Invalid content-type.\n' + + * `Expected application/json but received ${contentType}`); + * } + * if (error) { + * console.error(error.message); + * // Consume response data to free up memory + * res.resume(); + * return; + * } + * + * res.setEncoding('utf8'); + * let rawData = ''; + * res.on('data', (chunk) => { rawData += chunk; }); + * res.on('end', () => { + * try { + * const parsedData = JSON.parse(rawData); + * console.log(parsedData); + * } catch (e) { + * console.error(e.message); + * } + * }); + * }).on('error', (e) => { + * console.error(`Got error: ${e.message}`); + * }); + * + * // Create a local server to receive data from + * const server = http.createServer((req, res) => { + * res.writeHead(200, { 'Content-Type': 'application/json' }); + * res.end(JSON.stringify({ + * data: 'Hello World!', + * })); + * }); + * + * server.listen(8000); + * ``` + * @since v0.3.6 + * @param options Accepts the same `options` as {@link request}, with the method set to GET by default. + */ + function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest; + function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + /** + * Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called. + * + * Passing illegal value as `name` will result in a `TypeError` being thrown, + * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`. + * + * It is not necessary to use this method before passing headers to an HTTP request + * or response. The HTTP module will automatically validate such headers. + * Examples: + * + * Example: + * + * ```js + * import { validateHeaderName } from 'node:http'; + * + * try { + * validateHeaderName(''); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN' + * console.error(err.message); // --> 'Header name must be a valid HTTP token [""]' + * } + * ``` + * @since v14.3.0 + * @param [label='Header name'] Label for error message. + */ + function validateHeaderName(name: string): void; + /** + * Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called. + * + * Passing illegal value as `value` will result in a `TypeError` being thrown. + * + * * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`. + * * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`. + * + * It is not necessary to use this method before passing headers to an HTTP request + * or response. The HTTP module will automatically validate such headers. + * + * Examples: + * + * ```js + * import { validateHeaderValue } from 'node:http'; + * + * try { + * validateHeaderValue('x-my-header', undefined); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true + * console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"' + * } + * + * try { + * validateHeaderValue('x-my-header', 'oʊmɪɡə'); + * } catch (err) { + * console.error(err instanceof TypeError); // --> true + * console.error(err.code === 'ERR_INVALID_CHAR'); // --> true + * console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]' + * } + * ``` + * @since v14.3.0 + * @param name Header name + * @param value Header value + */ + function validateHeaderValue(name: string, value: string): void; + /** + * Set the maximum number of idle HTTP parsers. + * @since v18.8.0, v16.18.0 + * @param [max=1000] + */ + function setMaxIdleHTTPParsers(max: number): void; + let globalAgent: Agent; + /** + * Read-only property specifying the maximum allowed size of HTTP headers in bytes. + * Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option. + */ + const maxHeaderSize: number; +} +declare module "node:http" { + export * from "http"; +} diff --git a/node_modules/@types/node/ts4.8/http2.d.ts b/node_modules/@types/node/ts4.8/http2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3b3e8ec4fe80a643325e3b37c287bcdb4c9e2f5 --- /dev/null +++ b/node_modules/@types/node/ts4.8/http2.d.ts @@ -0,0 +1,2382 @@ +/** + * The `node:http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. + * It can be accessed using: + * + * ```js + * const http2 = require('node:http2'); + * ``` + * @since v8.4.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http2.js) + */ +declare module "http2" { + import EventEmitter = require("node:events"); + import * as fs from "node:fs"; + import * as net from "node:net"; + import * as stream from "node:stream"; + import * as tls from "node:tls"; + import * as url from "node:url"; + import { + IncomingHttpHeaders as Http1IncomingHttpHeaders, + IncomingMessage, + OutgoingHttpHeaders, + ServerResponse, + } from "node:http"; + export { OutgoingHttpHeaders } from "node:http"; + export interface IncomingHttpStatusHeader { + ":status"?: number | undefined; + } + export interface IncomingHttpHeaders extends Http1IncomingHttpHeaders { + ":path"?: string | undefined; + ":method"?: string | undefined; + ":authority"?: string | undefined; + ":scheme"?: string | undefined; + } + // Http2Stream + export interface StreamPriorityOptions { + exclusive?: boolean | undefined; + parent?: number | undefined; + weight?: number | undefined; + silent?: boolean | undefined; + } + export interface StreamState { + localWindowSize?: number | undefined; + state?: number | undefined; + localClose?: number | undefined; + remoteClose?: number | undefined; + sumDependencyWeight?: number | undefined; + weight?: number | undefined; + } + export interface ServerStreamResponseOptions { + endStream?: boolean | undefined; + waitForTrailers?: boolean | undefined; + } + export interface StatOptions { + offset: number; + length: number; + } + export interface ServerStreamFileResponseOptions { + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + statCheck?(stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions): void | boolean; + waitForTrailers?: boolean | undefined; + offset?: number | undefined; + length?: number | undefined; + } + export interface ServerStreamFileResponseOptionsWithError extends ServerStreamFileResponseOptions { + onError?(err: NodeJS.ErrnoException): void; + } + export interface Http2Stream extends stream.Duplex { + /** + * Set to `true` if the `Http2Stream` instance was aborted abnormally. When set, + * the `'aborted'` event will have been emitted. + * @since v8.4.0 + */ + readonly aborted: boolean; + /** + * This property shows the number of characters currently buffered to be written. + * See `net.Socket.bufferSize` for details. + * @since v11.2.0, v10.16.0 + */ + readonly bufferSize: number; + /** + * Set to `true` if the `Http2Stream` instance has been closed. + * @since v9.4.0 + */ + readonly closed: boolean; + /** + * Set to `true` if the `Http2Stream` instance has been destroyed and is no longer + * usable. + * @since v8.4.0 + */ + readonly destroyed: boolean; + /** + * Set to `true` if the `END_STREAM` flag was set in the request or response + * HEADERS frame received, indicating that no additional data should be received + * and the readable side of the `Http2Stream` will be closed. + * @since v10.11.0 + */ + readonly endAfterHeaders: boolean; + /** + * The numeric stream identifier of this `Http2Stream` instance. Set to `undefined`if the stream identifier has not yet been assigned. + * @since v8.4.0 + */ + readonly id?: number | undefined; + /** + * Set to `true` if the `Http2Stream` instance has not yet been assigned a + * numeric stream identifier. + * @since v9.4.0 + */ + readonly pending: boolean; + /** + * Set to the `RST_STREAM` `error code` reported when the `Http2Stream` is + * destroyed after either receiving an `RST_STREAM` frame from the connected peer, + * calling `http2stream.close()`, or `http2stream.destroy()`. Will be`undefined` if the `Http2Stream` has not been closed. + * @since v8.4.0 + */ + readonly rstCode: number; + /** + * An object containing the outbound headers sent for this `Http2Stream`. + * @since v9.5.0 + */ + readonly sentHeaders: OutgoingHttpHeaders; + /** + * An array of objects containing the outbound informational (additional) headers + * sent for this `Http2Stream`. + * @since v9.5.0 + */ + readonly sentInfoHeaders?: OutgoingHttpHeaders[] | undefined; + /** + * An object containing the outbound trailers sent for this `HttpStream`. + * @since v9.5.0 + */ + readonly sentTrailers?: OutgoingHttpHeaders | undefined; + /** + * A reference to the `Http2Session` instance that owns this `Http2Stream`. The + * value will be `undefined` after the `Http2Stream` instance is destroyed. + * @since v8.4.0 + */ + readonly session: Http2Session | undefined; + /** + * Provides miscellaneous information about the current state of the`Http2Stream`. + * + * A current state of this `Http2Stream`. + * @since v8.4.0 + */ + readonly state: StreamState; + /** + * Closes the `Http2Stream` instance by sending an `RST_STREAM` frame to the + * connected HTTP/2 peer. + * @since v8.4.0 + * @param [code=http2.constants.NGHTTP2_NO_ERROR] Unsigned 32-bit integer identifying the error code. + * @param callback An optional function registered to listen for the `'close'` event. + */ + close(code?: number, callback?: () => void): void; + /** + * Updates the priority for this `Http2Stream` instance. + * @since v8.4.0 + */ + priority(options: StreamPriorityOptions): void; + /** + * ```js + * const http2 = require('node:http2'); + * const client = http2.connect('http://example.org:8000'); + * const { NGHTTP2_CANCEL } = http2.constants; + * const req = client.request({ ':path': '/' }); + * + * // Cancel the stream if there's no activity after 5 seconds + * req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL)); + * ``` + * @since v8.4.0 + */ + setTimeout(msecs: number, callback?: () => void): void; + /** + * Sends a trailing `HEADERS` frame to the connected HTTP/2 peer. This method + * will cause the `Http2Stream` to be immediately closed and must only be + * called after the `'wantTrailers'` event has been emitted. When sending a + * request or sending a response, the `options.waitForTrailers` option must be set + * in order to keep the `Http2Stream` open after the final `DATA` frame so that + * trailers can be sent. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respond(undefined, { waitForTrailers: true }); + * stream.on('wantTrailers', () => { + * stream.sendTrailers({ xyz: 'abc' }); + * }); + * stream.end('Hello World'); + * }); + * ``` + * + * The HTTP/1 specification forbids trailers from containing HTTP/2 pseudo-header + * fields (e.g. `':method'`, `':path'`, etc). + * @since v10.0.0 + */ + sendTrailers(headers: OutgoingHttpHeaders): void; + addListener(event: "aborted", listener: () => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: Buffer | string) => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + addListener(event: "pipe", listener: (src: stream.Readable) => void): this; + addListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + addListener(event: "streamClosed", listener: (code: number) => void): this; + addListener(event: "timeout", listener: () => void): this; + addListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + addListener(event: "wantTrailers", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "aborted"): boolean; + emit(event: "close"): boolean; + emit(event: "data", chunk: Buffer | string): boolean; + emit(event: "drain"): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "frameError", frameType: number, errorCode: number): boolean; + emit(event: "pipe", src: stream.Readable): boolean; + emit(event: "unpipe", src: stream.Readable): boolean; + emit(event: "streamClosed", code: number): boolean; + emit(event: "timeout"): boolean; + emit(event: "trailers", trailers: IncomingHttpHeaders, flags: number): boolean; + emit(event: "wantTrailers"): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "aborted", listener: () => void): this; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: Buffer | string) => void): this; + on(event: "drain", listener: () => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + on(event: "streamClosed", listener: (code: number) => void): this; + on(event: "timeout", listener: () => void): this; + on(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + on(event: "wantTrailers", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "aborted", listener: () => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: Buffer | string) => void): this; + once(event: "drain", listener: () => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + once(event: "streamClosed", listener: (code: number) => void): this; + once(event: "timeout", listener: () => void): this; + once(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + once(event: "wantTrailers", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "aborted", listener: () => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + prependListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "streamClosed", listener: (code: number) => void): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + prependListener(event: "wantTrailers", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "aborted", listener: () => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this; + prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "streamClosed", listener: (code: number) => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this; + prependOnceListener(event: "wantTrailers", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface ClientHttp2Stream extends Http2Stream { + addListener(event: "continue", listener: () => {}): this; + addListener( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + addListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + addListener( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "continue"): boolean; + emit(event: "headers", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean; + emit(event: "push", headers: IncomingHttpHeaders, flags: number): boolean; + emit(event: "response", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "continue", listener: () => {}): this; + on( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + on( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "continue", listener: () => {}): this; + once( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + once( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "continue", listener: () => {}): this; + prependListener( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + prependListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + prependListener( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "continue", listener: () => {}): this; + prependOnceListener( + event: "headers", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + prependOnceListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; + prependOnceListener( + event: "response", + listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + ): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface ServerHttp2Stream extends Http2Stream { + /** + * True if headers were sent, false otherwise (read-only). + * @since v8.4.0 + */ + readonly headersSent: boolean; + /** + * Read-only property mapped to the `SETTINGS_ENABLE_PUSH` flag of the remote + * client's most recent `SETTINGS` frame. Will be `true` if the remote peer + * accepts push streams, `false` otherwise. Settings are the same for every`Http2Stream` in the same `Http2Session`. + * @since v8.4.0 + */ + readonly pushAllowed: boolean; + /** + * Sends an additional informational `HEADERS` frame to the connected HTTP/2 peer. + * @since v8.4.0 + */ + additionalHeaders(headers: OutgoingHttpHeaders): void; + /** + * Initiates a push stream. The callback is invoked with the new `Http2Stream`instance created for the push stream passed as the second argument, or an`Error` passed as the first argument. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respond({ ':status': 200 }); + * stream.pushStream({ ':path': '/' }, (err, pushStream, headers) => { + * if (err) throw err; + * pushStream.respond({ ':status': 200 }); + * pushStream.end('some pushed data'); + * }); + * stream.end('some data'); + * }); + * ``` + * + * Setting the weight of a push stream is not allowed in the `HEADERS` frame. Pass + * a `weight` value to `http2stream.priority` with the `silent` option set to`true` to enable server-side bandwidth balancing between concurrent streams. + * + * Calling `http2stream.pushStream()` from within a pushed stream is not permitted + * and will throw an error. + * @since v8.4.0 + * @param callback Callback that is called once the push stream has been initiated. + */ + pushStream( + headers: OutgoingHttpHeaders, + callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void, + ): void; + pushStream( + headers: OutgoingHttpHeaders, + options?: StreamPriorityOptions, + callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void, + ): void; + /** + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respond({ ':status': 200 }); + * stream.end('some data'); + * }); + * ``` + * + * Initiates a response. When the `options.waitForTrailers` option is set, the`'wantTrailers'` event will be emitted immediately after queuing the last chunk + * of payload data to be sent. The `http2stream.sendTrailers()` method can then be + * used to sent trailing header fields to the peer. + * + * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically + * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respond({ ':status': 200 }, { waitForTrailers: true }); + * stream.on('wantTrailers', () => { + * stream.sendTrailers({ ABC: 'some value to send' }); + * }); + * stream.end('some data'); + * }); + * ``` + * @since v8.4.0 + */ + respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void; + /** + * Initiates a response whose data is read from the given file descriptor. No + * validation is performed on the given file descriptor. If an error occurs while + * attempting to read data using the file descriptor, the `Http2Stream` will be + * closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR` code. + * + * When used, the `Http2Stream` object's `Duplex` interface will be closed + * automatically. + * + * ```js + * const http2 = require('node:http2'); + * const fs = require('node:fs'); + * + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * const fd = fs.openSync('/some/file', 'r'); + * + * const stat = fs.fstatSync(fd); + * const headers = { + * 'content-length': stat.size, + * 'last-modified': stat.mtime.toUTCString(), + * 'content-type': 'text/plain; charset=utf-8', + * }; + * stream.respondWithFD(fd, headers); + * stream.on('close', () => fs.closeSync(fd)); + * }); + * ``` + * + * The optional `options.statCheck` function may be specified to give user code + * an opportunity to set additional content headers based on the `fs.Stat` details + * of the given fd. If the `statCheck` function is provided, the`http2stream.respondWithFD()` method will perform an `fs.fstat()` call to + * collect details on the provided file descriptor. + * + * The `offset` and `length` options may be used to limit the response to a + * specific range subset. This can be used, for instance, to support HTTP Range + * requests. + * + * The file descriptor or `FileHandle` is not closed when the stream is closed, + * so it will need to be closed manually once it is no longer needed. + * Using the same file descriptor concurrently for multiple streams + * is not supported and may result in data loss. Re-using a file descriptor + * after a stream has finished is supported. + * + * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event + * will be emitted immediately after queuing the last chunk of payload data to be + * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing + * header fields to the peer. + * + * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically + * close when the final `DATA` frame is transmitted. User code _must_ call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. + * + * ```js + * const http2 = require('node:http2'); + * const fs = require('node:fs'); + * + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * const fd = fs.openSync('/some/file', 'r'); + * + * const stat = fs.fstatSync(fd); + * const headers = { + * 'content-length': stat.size, + * 'last-modified': stat.mtime.toUTCString(), + * 'content-type': 'text/plain; charset=utf-8', + * }; + * stream.respondWithFD(fd, headers, { waitForTrailers: true }); + * stream.on('wantTrailers', () => { + * stream.sendTrailers({ ABC: 'some value to send' }); + * }); + * + * stream.on('close', () => fs.closeSync(fd)); + * }); + * ``` + * @since v8.4.0 + * @param fd A readable file descriptor. + */ + respondWithFD( + fd: number | fs.promises.FileHandle, + headers?: OutgoingHttpHeaders, + options?: ServerStreamFileResponseOptions, + ): void; + /** + * Sends a regular file as the response. The `path` must specify a regular file + * or an `'error'` event will be emitted on the `Http2Stream` object. + * + * When used, the `Http2Stream` object's `Duplex` interface will be closed + * automatically. + * + * The optional `options.statCheck` function may be specified to give user code + * an opportunity to set additional content headers based on the `fs.Stat` details + * of the given file: + * + * If an error occurs while attempting to read the file data, the `Http2Stream`will be closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR`code. If the `onError` callback is + * defined, then it will be called. Otherwise + * the stream will be destroyed. + * + * Example using a file path: + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * function statCheck(stat, headers) { + * headers['last-modified'] = stat.mtime.toUTCString(); + * } + * + * function onError(err) { + * // stream.respond() can throw if the stream has been destroyed by + * // the other side. + * try { + * if (err.code === 'ENOENT') { + * stream.respond({ ':status': 404 }); + * } else { + * stream.respond({ ':status': 500 }); + * } + * } catch (err) { + * // Perform actual error handling. + * console.error(err); + * } + * stream.end(); + * } + * + * stream.respondWithFile('/some/file', + * { 'content-type': 'text/plain; charset=utf-8' }, + * { statCheck, onError }); + * }); + * ``` + * + * The `options.statCheck` function may also be used to cancel the send operation + * by returning `false`. For instance, a conditional request may check the stat + * results to determine if the file has been modified to return an appropriate`304` response: + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * function statCheck(stat, headers) { + * // Check the stat here... + * stream.respond({ ':status': 304 }); + * return false; // Cancel the send operation + * } + * stream.respondWithFile('/some/file', + * { 'content-type': 'text/plain; charset=utf-8' }, + * { statCheck }); + * }); + * ``` + * + * The `content-length` header field will be automatically set. + * + * The `offset` and `length` options may be used to limit the response to a + * specific range subset. This can be used, for instance, to support HTTP Range + * requests. + * + * The `options.onError` function may also be used to handle all the errors + * that could happen before the delivery of the file is initiated. The + * default behavior is to destroy the stream. + * + * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event + * will be emitted immediately after queuing the last chunk of payload data to be + * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing + * header fields to the peer. + * + * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically + * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer(); + * server.on('stream', (stream) => { + * stream.respondWithFile('/some/file', + * { 'content-type': 'text/plain; charset=utf-8' }, + * { waitForTrailers: true }); + * stream.on('wantTrailers', () => { + * stream.sendTrailers({ ABC: 'some value to send' }); + * }); + * }); + * ``` + * @since v8.4.0 + */ + respondWithFile( + path: string, + headers?: OutgoingHttpHeaders, + options?: ServerStreamFileResponseOptionsWithError, + ): void; + } + // Http2Session + export interface Settings { + headerTableSize?: number | undefined; + enablePush?: boolean | undefined; + initialWindowSize?: number | undefined; + maxFrameSize?: number | undefined; + maxConcurrentStreams?: number | undefined; + maxHeaderListSize?: number | undefined; + enableConnectProtocol?: boolean | undefined; + } + export interface ClientSessionRequestOptions { + endStream?: boolean | undefined; + exclusive?: boolean | undefined; + parent?: number | undefined; + weight?: number | undefined; + waitForTrailers?: boolean | undefined; + signal?: AbortSignal | undefined; + } + export interface SessionState { + effectiveLocalWindowSize?: number | undefined; + effectiveRecvDataLength?: number | undefined; + nextStreamID?: number | undefined; + localWindowSize?: number | undefined; + lastProcStreamID?: number | undefined; + remoteWindowSize?: number | undefined; + outboundQueueSize?: number | undefined; + deflateDynamicTableSize?: number | undefined; + inflateDynamicTableSize?: number | undefined; + } + export interface Http2Session extends EventEmitter { + /** + * Value will be `undefined` if the `Http2Session` is not yet connected to a + * socket, `h2c` if the `Http2Session` is not connected to a `TLSSocket`, or + * will return the value of the connected `TLSSocket`'s own `alpnProtocol`property. + * @since v9.4.0 + */ + readonly alpnProtocol?: string | undefined; + /** + * Will be `true` if this `Http2Session` instance has been closed, otherwise`false`. + * @since v9.4.0 + */ + readonly closed: boolean; + /** + * Will be `true` if this `Http2Session` instance is still connecting, will be set + * to `false` before emitting `connect` event and/or calling the `http2.connect`callback. + * @since v10.0.0 + */ + readonly connecting: boolean; + /** + * Will be `true` if this `Http2Session` instance has been destroyed and must no + * longer be used, otherwise `false`. + * @since v8.4.0 + */ + readonly destroyed: boolean; + /** + * Value is `undefined` if the `Http2Session` session socket has not yet been + * connected, `true` if the `Http2Session` is connected with a `TLSSocket`, + * and `false` if the `Http2Session` is connected to any other kind of socket + * or stream. + * @since v9.4.0 + */ + readonly encrypted?: boolean | undefined; + /** + * A prototype-less object describing the current local settings of this`Http2Session`. The local settings are local to _this_`Http2Session` instance. + * @since v8.4.0 + */ + readonly localSettings: Settings; + /** + * If the `Http2Session` is connected to a `TLSSocket`, the `originSet` property + * will return an `Array` of origins for which the `Http2Session` may be + * considered authoritative. + * + * The `originSet` property is only available when using a secure TLS connection. + * @since v9.4.0 + */ + readonly originSet?: string[] | undefined; + /** + * Indicates whether the `Http2Session` is currently waiting for acknowledgment of + * a sent `SETTINGS` frame. Will be `true` after calling the`http2session.settings()` method. Will be `false` once all sent `SETTINGS`frames have been acknowledged. + * @since v8.4.0 + */ + readonly pendingSettingsAck: boolean; + /** + * A prototype-less object describing the current remote settings of this`Http2Session`. The remote settings are set by the _connected_ HTTP/2 peer. + * @since v8.4.0 + */ + readonly remoteSettings: Settings; + /** + * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but + * limits available methods to ones safe to use with HTTP/2. + * + * `destroy`, `emit`, `end`, `pause`, `read`, `resume`, and `write` will throw + * an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for more information. + * + * `setTimeout` method will be called on this `Http2Session`. + * + * All other interactions will be routed directly to the socket. + * @since v8.4.0 + */ + readonly socket: net.Socket | tls.TLSSocket; + /** + * Provides miscellaneous information about the current state of the`Http2Session`. + * + * An object describing the current status of this `Http2Session`. + * @since v8.4.0 + */ + readonly state: SessionState; + /** + * The `http2session.type` will be equal to`http2.constants.NGHTTP2_SESSION_SERVER` if this `Http2Session` instance is a + * server, and `http2.constants.NGHTTP2_SESSION_CLIENT` if the instance is a + * client. + * @since v8.4.0 + */ + readonly type: number; + /** + * Gracefully closes the `Http2Session`, allowing any existing streams to + * complete on their own and preventing new `Http2Stream` instances from being + * created. Once closed, `http2session.destroy()`_might_ be called if there + * are no open `Http2Stream` instances. + * + * If specified, the `callback` function is registered as a handler for the`'close'` event. + * @since v9.4.0 + */ + close(callback?: () => void): void; + /** + * Immediately terminates the `Http2Session` and the associated `net.Socket` or`tls.TLSSocket`. + * + * Once destroyed, the `Http2Session` will emit the `'close'` event. If `error`is not undefined, an `'error'` event will be emitted immediately before the`'close'` event. + * + * If there are any remaining open `Http2Streams` associated with the`Http2Session`, those will also be destroyed. + * @since v8.4.0 + * @param error An `Error` object if the `Http2Session` is being destroyed due to an error. + * @param code The HTTP/2 error code to send in the final `GOAWAY` frame. If unspecified, and `error` is not undefined, the default is `INTERNAL_ERROR`, otherwise defaults to `NO_ERROR`. + */ + destroy(error?: Error, code?: number): void; + /** + * Transmits a `GOAWAY` frame to the connected peer _without_ shutting down the`Http2Session`. + * @since v9.4.0 + * @param code An HTTP/2 error code + * @param lastStreamID The numeric ID of the last processed `Http2Stream` + * @param opaqueData A `TypedArray` or `DataView` instance containing additional data to be carried within the `GOAWAY` frame. + */ + goaway(code?: number, lastStreamID?: number, opaqueData?: NodeJS.ArrayBufferView): void; + /** + * Sends a `PING` frame to the connected HTTP/2 peer. A `callback` function must + * be provided. The method will return `true` if the `PING` was sent, `false`otherwise. + * + * The maximum number of outstanding (unacknowledged) pings is determined by the`maxOutstandingPings` configuration option. The default maximum is 10. + * + * If provided, the `payload` must be a `Buffer`, `TypedArray`, or `DataView`containing 8 bytes of data that will be transmitted with the `PING` and + * returned with the ping acknowledgment. + * + * The callback will be invoked with three arguments: an error argument that will + * be `null` if the `PING` was successfully acknowledged, a `duration` argument + * that reports the number of milliseconds elapsed since the ping was sent and the + * acknowledgment was received, and a `Buffer` containing the 8-byte `PING`payload. + * + * ```js + * session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => { + * if (!err) { + * console.log(`Ping acknowledged in ${duration} milliseconds`); + * console.log(`With payload '${payload.toString()}'`); + * } + * }); + * ``` + * + * If the `payload` argument is not specified, the default payload will be the + * 64-bit timestamp (little endian) marking the start of the `PING` duration. + * @since v8.9.3 + * @param payload Optional ping payload. + */ + ping(callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean; + ping( + payload: NodeJS.ArrayBufferView, + callback: (err: Error | null, duration: number, payload: Buffer) => void, + ): boolean; + /** + * Calls `ref()` on this `Http2Session`instance's underlying `net.Socket`. + * @since v9.4.0 + */ + ref(): void; + /** + * Sets the local endpoint's window size. + * The `windowSize` is the total window size to set, not + * the delta. + * + * ```js + * const http2 = require('node:http2'); + * + * const server = http2.createServer(); + * const expectedWindowSize = 2 ** 20; + * server.on('connect', (session) => { + * + * // Set local window size to be 2 ** 20 + * session.setLocalWindowSize(expectedWindowSize); + * }); + * ``` + * @since v15.3.0, v14.18.0 + */ + setLocalWindowSize(windowSize: number): void; + /** + * Used to set a callback function that is called when there is no activity on + * the `Http2Session` after `msecs` milliseconds. The given `callback` is + * registered as a listener on the `'timeout'` event. + * @since v8.4.0 + */ + setTimeout(msecs: number, callback?: () => void): void; + /** + * Updates the current local settings for this `Http2Session` and sends a new`SETTINGS` frame to the connected HTTP/2 peer. + * + * Once called, the `http2session.pendingSettingsAck` property will be `true`while the session is waiting for the remote peer to acknowledge the new + * settings. + * + * The new settings will not become effective until the `SETTINGS` acknowledgment + * is received and the `'localSettings'` event is emitted. It is possible to send + * multiple `SETTINGS` frames while acknowledgment is still pending. + * @since v8.4.0 + * @param callback Callback that is called once the session is connected or right away if the session is already connected. + */ + settings( + settings: Settings, + callback?: (err: Error | null, settings: Settings, duration: number) => void, + ): void; + /** + * Calls `unref()` on this `Http2Session`instance's underlying `net.Socket`. + * @since v9.4.0 + */ + unref(): void; + addListener(event: "close", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener( + event: "frameError", + listener: (frameType: number, errorCode: number, streamID: number) => void, + ): this; + addListener( + event: "goaway", + listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void, + ): this; + addListener(event: "localSettings", listener: (settings: Settings) => void): this; + addListener(event: "ping", listener: () => void): this; + addListener(event: "remoteSettings", listener: (settings: Settings) => void): this; + addListener(event: "timeout", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "frameError", frameType: number, errorCode: number, streamID: number): boolean; + emit(event: "goaway", errorCode: number, lastStreamID: number, opaqueData?: Buffer): boolean; + emit(event: "localSettings", settings: Settings): boolean; + emit(event: "ping"): boolean; + emit(event: "remoteSettings", settings: Settings): boolean; + emit(event: "timeout"): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this; + on(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void): this; + on(event: "localSettings", listener: (settings: Settings) => void): this; + on(event: "ping", listener: () => void): this; + on(event: "remoteSettings", listener: (settings: Settings) => void): this; + on(event: "timeout", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this; + once(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void): this; + once(event: "localSettings", listener: (settings: Settings) => void): this; + once(event: "ping", listener: () => void): this; + once(event: "remoteSettings", listener: (settings: Settings) => void): this; + once(event: "timeout", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener( + event: "frameError", + listener: (frameType: number, errorCode: number, streamID: number) => void, + ): this; + prependListener( + event: "goaway", + listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void, + ): this; + prependListener(event: "localSettings", listener: (settings: Settings) => void): this; + prependListener(event: "ping", listener: () => void): this; + prependListener(event: "remoteSettings", listener: (settings: Settings) => void): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener( + event: "frameError", + listener: (frameType: number, errorCode: number, streamID: number) => void, + ): this; + prependOnceListener( + event: "goaway", + listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void, + ): this; + prependOnceListener(event: "localSettings", listener: (settings: Settings) => void): this; + prependOnceListener(event: "ping", listener: () => void): this; + prependOnceListener(event: "remoteSettings", listener: (settings: Settings) => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface ClientHttp2Session extends Http2Session { + /** + * For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`creates and returns an `Http2Stream` instance that can be used to send an + * HTTP/2 request to the connected server. + * + * When a `ClientHttp2Session` is first created, the socket may not yet be + * connected. if `clienthttp2session.request()` is called during this time, the + * actual request will be deferred until the socket is ready to go. + * If the `session` is closed before the actual request be executed, an`ERR_HTTP2_GOAWAY_SESSION` is thrown. + * + * This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`. + * + * ```js + * const http2 = require('node:http2'); + * const clientSession = http2.connect('https://localhost:1234'); + * const { + * HTTP2_HEADER_PATH, + * HTTP2_HEADER_STATUS, + * } = http2.constants; + * + * const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' }); + * req.on('response', (headers) => { + * console.log(headers[HTTP2_HEADER_STATUS]); + * req.on('data', (chunk) => { // .. }); + * req.on('end', () => { // .. }); + * }); + * ``` + * + * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event + * is emitted immediately after queuing the last chunk of payload data to be sent. + * The `http2stream.sendTrailers()` method can then be called to send trailing + * headers to the peer. + * + * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically + * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`. + * + * When `options.signal` is set with an `AbortSignal` and then `abort` on the + * corresponding `AbortController` is called, the request will emit an `'error'`event with an `AbortError` error. + * + * The `:method` and `:path` pseudo-headers are not specified within `headers`, + * they respectively default to: + * + * * `:method` \= `'GET'` + * * `:path` \= `/` + * @since v8.4.0 + */ + request(headers?: OutgoingHttpHeaders, options?: ClientSessionRequestOptions): ClientHttp2Stream; + addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + addListener(event: "origin", listener: (origins: string[]) => void): this; + addListener( + event: "connect", + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + addListener( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "altsvc", alt: string, origin: string, stream: number): boolean; + emit(event: "origin", origins: readonly string[]): boolean; + emit(event: "connect", session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket): boolean; + emit( + event: "stream", + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + on(event: "origin", listener: (origins: string[]) => void): this; + on(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this; + on( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + once(event: "origin", listener: (origins: string[]) => void): this; + once( + event: "connect", + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + once( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + prependListener(event: "origin", listener: (origins: string[]) => void): this; + prependListener( + event: "connect", + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + prependListener( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; + prependOnceListener(event: "origin", listener: (origins: string[]) => void): this; + prependOnceListener( + event: "connect", + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + prependOnceListener( + event: "stream", + listener: ( + stream: ClientHttp2Stream, + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + ) => void, + ): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface AlternativeServiceOptions { + origin: number | string | url.URL; + } + export interface ServerHttp2Session extends Http2Session { + readonly server: Http2Server | Http2SecureServer; + /** + * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client. + * + * ```js + * const http2 = require('node:http2'); + * + * const server = http2.createServer(); + * server.on('session', (session) => { + * // Set altsvc for origin https://example.org:80 + * session.altsvc('h2=":8000"', 'https://example.org:80'); + * }); + * + * server.on('stream', (stream) => { + * // Set altsvc for a specific stream + * stream.session.altsvc('h2=":8000"', stream.id); + * }); + * ``` + * + * Sending an `ALTSVC` frame with a specific stream ID indicates that the alternate + * service is associated with the origin of the given `Http2Stream`. + * + * The `alt` and origin string _must_ contain only ASCII bytes and are + * strictly interpreted as a sequence of ASCII bytes. The special value `'clear'`may be passed to clear any previously set alternative service for a given + * domain. + * + * When a string is passed for the `originOrStream` argument, it will be parsed as + * a URL and the origin will be derived. For instance, the origin for the + * HTTP URL `'https://example.org/foo/bar'` is the ASCII string`'https://example.org'`. An error will be thrown if either the given string + * cannot be parsed as a URL or if a valid origin cannot be derived. + * + * A `URL` object, or any object with an `origin` property, may be passed as`originOrStream`, in which case the value of the `origin` property will be + * used. The value of the `origin` property _must_ be a properly serialized + * ASCII origin. + * @since v9.4.0 + * @param alt A description of the alternative service configuration as defined by `RFC 7838`. + * @param originOrStream Either a URL string specifying the origin (or an `Object` with an `origin` property) or the numeric identifier of an active `Http2Stream` as given by the + * `http2stream.id` property. + */ + altsvc(alt: string, originOrStream: number | string | url.URL | AlternativeServiceOptions): void; + /** + * Submits an `ORIGIN` frame (as defined by [RFC 8336](https://tools.ietf.org/html/rfc8336)) to the connected client + * to advertise the set of origins for which the server is capable of providing + * authoritative responses. + * + * ```js + * const http2 = require('node:http2'); + * const options = getSecureOptionsSomehow(); + * const server = http2.createSecureServer(options); + * server.on('stream', (stream) => { + * stream.respond(); + * stream.end('ok'); + * }); + * server.on('session', (session) => { + * session.origin('https://example.com', 'https://example.org'); + * }); + * ``` + * + * When a string is passed as an `origin`, it will be parsed as a URL and the + * origin will be derived. For instance, the origin for the HTTP URL`'https://example.org/foo/bar'` is the ASCII string`'https://example.org'`. An error will be thrown if either the given + * string + * cannot be parsed as a URL or if a valid origin cannot be derived. + * + * A `URL` object, or any object with an `origin` property, may be passed as + * an `origin`, in which case the value of the `origin` property will be + * used. The value of the `origin` property _must_ be a properly serialized + * ASCII origin. + * + * Alternatively, the `origins` option may be used when creating a new HTTP/2 + * server using the `http2.createSecureServer()` method: + * + * ```js + * const http2 = require('node:http2'); + * const options = getSecureOptionsSomehow(); + * options.origins = ['https://example.com', 'https://example.org']; + * const server = http2.createSecureServer(options); + * server.on('stream', (stream) => { + * stream.respond(); + * stream.end('ok'); + * }); + * ``` + * @since v10.12.0 + * @param origins One or more URL Strings passed as separate arguments. + */ + origin( + ...origins: Array< + | string + | url.URL + | { + origin: string; + } + > + ): void; + addListener( + event: "connect", + listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + addListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean; + emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this; + on( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once( + event: "connect", + listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + once( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener( + event: "connect", + listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + prependListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener( + event: "connect", + listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): this; + prependOnceListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + // Http2Server + export interface SessionOptions { + maxDeflateDynamicTableSize?: number | undefined; + maxSessionMemory?: number | undefined; + maxHeaderListPairs?: number | undefined; + maxOutstandingPings?: number | undefined; + maxSendHeaderBlockLength?: number | undefined; + paddingStrategy?: number | undefined; + peerMaxConcurrentStreams?: number | undefined; + settings?: Settings | undefined; + /** + * Specifies a timeout in milliseconds that + * a server should wait when an [`'unknownProtocol'`][] is emitted. If the + * socket has not been destroyed by that time the server will destroy it. + * @default 100000 + */ + unknownProtocolTimeout?: number | undefined; + selectPadding?(frameLen: number, maxFrameLen: number): number; + } + export interface ClientSessionOptions extends SessionOptions { + maxReservedRemoteStreams?: number | undefined; + createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined; + protocol?: "http:" | "https:" | undefined; + } + export interface ServerSessionOptions extends SessionOptions { + Http1IncomingMessage?: typeof IncomingMessage | undefined; + Http1ServerResponse?: typeof ServerResponse | undefined; + Http2ServerRequest?: typeof Http2ServerRequest | undefined; + Http2ServerResponse?: typeof Http2ServerResponse | undefined; + } + export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions {} + export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions {} + export interface ServerOptions extends ServerSessionOptions {} + export interface SecureServerOptions extends SecureServerSessionOptions { + allowHTTP1?: boolean | undefined; + origins?: string[] | undefined; + } + interface HTTP2ServerCommon { + setTimeout(msec?: number, callback?: () => void): this; + /** + * Throws ERR_HTTP2_INVALID_SETTING_VALUE for invalid settings values. + * Throws ERR_INVALID_ARG_TYPE for invalid settings argument. + */ + updateSettings(settings: Settings): void; + } + export interface Http2Server extends net.Server, HTTP2ServerCommon { + addListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + addListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + addListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + addListener(event: "sessionError", listener: (err: Error) => void): this; + addListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + addListener(event: "timeout", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean; + emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean; + emit(event: "session", session: ServerHttp2Session): boolean; + emit(event: "sessionError", err: Error): boolean; + emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean; + emit(event: "timeout"): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this; + on(event: "session", listener: (session: ServerHttp2Session) => void): this; + on(event: "sessionError", listener: (err: Error) => void): this; + on( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + on(event: "timeout", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this; + once(event: "session", listener: (session: ServerHttp2Session) => void): this; + once(event: "sessionError", listener: (err: Error) => void): this; + once( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + once(event: "timeout", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + prependListener(event: "sessionError", listener: (err: Error) => void): this; + prependListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependOnceListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + prependOnceListener(event: "sessionError", listener: (err: Error) => void): this; + prependOnceListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon { + addListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + addListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + addListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + addListener(event: "sessionError", listener: (err: Error) => void): this; + addListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + addListener(event: "timeout", listener: () => void): this; + addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean; + emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean; + emit(event: "session", session: ServerHttp2Session): boolean; + emit(event: "sessionError", err: Error): boolean; + emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean; + emit(event: "timeout"): boolean; + emit(event: "unknownProtocol", socket: tls.TLSSocket): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this; + on(event: "session", listener: (session: ServerHttp2Session) => void): this; + on(event: "sessionError", listener: (err: Error) => void): this; + on( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + on(event: "timeout", listener: () => void): this; + on(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this; + once(event: "session", listener: (session: ServerHttp2Session) => void): this; + once(event: "sessionError", listener: (err: Error) => void): this; + once( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + once(event: "timeout", listener: () => void): this; + once(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + prependListener(event: "sessionError", listener: (err: Error) => void): this; + prependListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependListener(event: "timeout", listener: () => void): this; + prependListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener( + event: "checkContinue", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependOnceListener( + event: "request", + listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): this; + prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this; + prependOnceListener(event: "sessionError", listener: (err: Error) => void): this; + prependOnceListener( + event: "stream", + listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + ): this; + prependOnceListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * A `Http2ServerRequest` object is created by {@link Server} or {@link SecureServer} and passed as the first argument to the `'request'` event. It may be used to access a request status, + * headers, and + * data. + * @since v8.4.0 + */ + export class Http2ServerRequest extends stream.Readable { + constructor( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + options: stream.ReadableOptions, + rawHeaders: readonly string[], + ); + /** + * The `request.aborted` property will be `true` if the request has + * been aborted. + * @since v10.1.0 + */ + readonly aborted: boolean; + /** + * The request authority pseudo header field. Because HTTP/2 allows requests + * to set either `:authority` or `host`, this value is derived from`req.headers[':authority']` if present. Otherwise, it is derived from`req.headers['host']`. + * @since v8.4.0 + */ + readonly authority: string; + /** + * See `request.socket`. + * @since v8.4.0 + * @deprecated Since v13.0.0 - Use `socket`. + */ + readonly connection: net.Socket | tls.TLSSocket; + /** + * The `request.complete` property will be `true` if the request has + * been completed, aborted, or destroyed. + * @since v12.10.0 + */ + readonly complete: boolean; + /** + * The request/response headers object. + * + * Key-value pairs of header names and values. Header names are lower-cased. + * + * ```js + * // Prints something like: + * // + * // { 'user-agent': 'curl/7.22.0', + * // host: '127.0.0.1:8000', + * // accept: '*' } + * console.log(request.headers); + * ``` + * + * See `HTTP/2 Headers Object`. + * + * In HTTP/2, the request path, host name, protocol, and method are represented as + * special headers prefixed with the `:` character (e.g. `':path'`). These special + * headers will be included in the `request.headers` object. Care must be taken not + * to inadvertently modify these special headers or errors may occur. For instance, + * removing all headers from the request will cause errors to occur: + * + * ```js + * removeAllHeaders(request.headers); + * assert(request.url); // Fails because the :path header has been removed + * ``` + * @since v8.4.0 + */ + readonly headers: IncomingHttpHeaders; + /** + * In case of server request, the HTTP version sent by the client. In the case of + * client response, the HTTP version of the connected-to server. Returns`'2.0'`. + * + * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second. + * @since v8.4.0 + */ + readonly httpVersion: string; + readonly httpVersionMinor: number; + readonly httpVersionMajor: number; + /** + * The request method as a string. Read-only. Examples: `'GET'`, `'DELETE'`. + * @since v8.4.0 + */ + readonly method: string; + /** + * The raw request/response headers list exactly as they were received. + * + * The keys and values are in the same list. It is _not_ a + * list of tuples. So, the even-numbered offsets are key values, and the + * odd-numbered offsets are the associated values. + * + * Header names are not lowercased, and duplicates are not merged. + * + * ```js + * // Prints something like: + * // + * // [ 'user-agent', + * // 'this is invalid because there can be only one', + * // 'User-Agent', + * // 'curl/7.22.0', + * // 'Host', + * // '127.0.0.1:8000', + * // 'ACCEPT', + * // '*' ] + * console.log(request.rawHeaders); + * ``` + * @since v8.4.0 + */ + readonly rawHeaders: string[]; + /** + * The raw request/response trailer keys and values exactly as they were + * received. Only populated at the `'end'` event. + * @since v8.4.0 + */ + readonly rawTrailers: string[]; + /** + * The request scheme pseudo header field indicating the scheme + * portion of the target URL. + * @since v8.4.0 + */ + readonly scheme: string; + /** + * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but + * applies getters, setters, and methods based on HTTP/2 logic. + * + * `destroyed`, `readable`, and `writable` properties will be retrieved from and + * set on `request.stream`. + * + * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`request.stream`. + * + * `setTimeout` method will be called on `request.stream.session`. + * + * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for + * more information. + * + * All other interactions will be routed directly to the socket. With TLS support, + * use `request.socket.getPeerCertificate()` to obtain the client's + * authentication details. + * @since v8.4.0 + */ + readonly socket: net.Socket | tls.TLSSocket; + /** + * The `Http2Stream` object backing the request. + * @since v8.4.0 + */ + readonly stream: ServerHttp2Stream; + /** + * The request/response trailers object. Only populated at the `'end'` event. + * @since v8.4.0 + */ + readonly trailers: IncomingHttpHeaders; + /** + * Request URL string. This contains only the URL that is present in the actual + * HTTP request. If the request is: + * + * ```http + * GET /status?name=ryan HTTP/1.1 + * Accept: text/plain + * ``` + * + * Then `request.url` will be: + * + * ```js + * '/status?name=ryan' + * ``` + * + * To parse the url into its parts, `new URL()` can be used: + * + * ```console + * $ node + * > new URL('/status?name=ryan', 'http://example.com') + * URL { + * href: 'http://example.com/status?name=ryan', + * origin: 'http://example.com', + * protocol: 'http:', + * username: '', + * password: '', + * host: 'example.com', + * hostname: 'example.com', + * port: '', + * pathname: '/status', + * search: '?name=ryan', + * searchParams: URLSearchParams { 'name' => 'ryan' }, + * hash: '' + * } + * ``` + * @since v8.4.0 + */ + url: string; + /** + * Sets the `Http2Stream`'s timeout value to `msecs`. If a callback is + * provided, then it is added as a listener on the `'timeout'` event on + * the response object. + * + * If no `'timeout'` listener is added to the request, the response, or + * the server, then `Http2Stream` s are destroyed when they time out. If a + * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly. + * @since v8.4.0 + */ + setTimeout(msecs: number, callback?: () => void): void; + read(size?: number): Buffer | string | null; + addListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: Buffer | string) => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "aborted", hadError: boolean, code: number): boolean; + emit(event: "close"): boolean; + emit(event: "data", chunk: Buffer | string): boolean; + emit(event: "end"): boolean; + emit(event: "readable"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: Buffer | string) => void): this; + on(event: "end", listener: () => void): this; + on(event: "readable", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: Buffer | string) => void): this; + once(event: "end", listener: () => void): this; + once(event: "readable", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + /** + * This object is created internally by an HTTP server, not by the user. It is + * passed as the second parameter to the `'request'` event. + * @since v8.4.0 + */ + export class Http2ServerResponse extends stream.Writable { + constructor(stream: ServerHttp2Stream); + /** + * See `response.socket`. + * @since v8.4.0 + * @deprecated Since v13.0.0 - Use `socket`. + */ + readonly connection: net.Socket | tls.TLSSocket; + /** + * Boolean value that indicates whether the response has completed. Starts + * as `false`. After `response.end()` executes, the value will be `true`. + * @since v8.4.0 + * @deprecated Since v13.4.0,v12.16.0 - Use `writableEnded`. + */ + readonly finished: boolean; + /** + * True if headers were sent, false otherwise (read-only). + * @since v8.4.0 + */ + readonly headersSent: boolean; + /** + * A reference to the original HTTP2 `request` object. + * @since v15.7.0 + */ + readonly req: Http2ServerRequest; + /** + * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but + * applies getters, setters, and methods based on HTTP/2 logic. + * + * `destroyed`, `readable`, and `writable` properties will be retrieved from and + * set on `response.stream`. + * + * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`response.stream`. + * + * `setTimeout` method will be called on `response.stream.session`. + * + * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for + * more information. + * + * All other interactions will be routed directly to the socket. + * + * ```js + * const http2 = require('node:http2'); + * const server = http2.createServer((req, res) => { + * const ip = req.socket.remoteAddress; + * const port = req.socket.remotePort; + * res.end(`Your IP address is ${ip} and your source port is ${port}.`); + * }).listen(3000); + * ``` + * @since v8.4.0 + */ + readonly socket: net.Socket | tls.TLSSocket; + /** + * The `Http2Stream` object backing the response. + * @since v8.4.0 + */ + readonly stream: ServerHttp2Stream; + /** + * When true, the Date header will be automatically generated and sent in + * the response if it is not already present in the headers. Defaults to true. + * + * This should only be disabled for testing; HTTP requires the Date header + * in responses. + * @since v8.4.0 + */ + sendDate: boolean; + /** + * When using implicit headers (not calling `response.writeHead()` explicitly), + * this property controls the status code that will be sent to the client when + * the headers get flushed. + * + * ```js + * response.statusCode = 404; + * ``` + * + * After response header was sent to the client, this property indicates the + * status code which was sent out. + * @since v8.4.0 + */ + statusCode: number; + /** + * Status message is not supported by HTTP/2 (RFC 7540 8.1.2.4). It returns + * an empty string. + * @since v8.4.0 + */ + statusMessage: ""; + /** + * This method adds HTTP trailing headers (a header but at the end of the + * message) to the response. + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a `TypeError` being thrown. + * @since v8.4.0 + */ + addTrailers(trailers: OutgoingHttpHeaders): void; + /** + * This method signals to the server that all of the response headers and body + * have been sent; that server should consider this message complete. + * The method, `response.end()`, MUST be called on each response. + * + * If `data` is specified, it is equivalent to calling `response.write(data, encoding)` followed by `response.end(callback)`. + * + * If `callback` is specified, it will be called when the response stream + * is finished. + * @since v8.4.0 + */ + end(callback?: () => void): this; + end(data: string | Uint8Array, callback?: () => void): this; + end(data: string | Uint8Array, encoding: BufferEncoding, callback?: () => void): this; + /** + * Reads out a header that has already been queued but not sent to the client. + * The name is case-insensitive. + * + * ```js + * const contentType = response.getHeader('content-type'); + * ``` + * @since v8.4.0 + */ + getHeader(name: string): string; + /** + * Returns an array containing the unique names of the current outgoing headers. + * All header names are lowercase. + * + * ```js + * response.setHeader('Foo', 'bar'); + * response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); + * + * const headerNames = response.getHeaderNames(); + * // headerNames === ['foo', 'set-cookie'] + * ``` + * @since v8.4.0 + */ + getHeaderNames(): string[]; + /** + * Returns a shallow copy of the current outgoing headers. Since a shallow copy + * is used, array values may be mutated without additional calls to various + * header-related http module methods. The keys of the returned object are the + * header names and the values are the respective header values. All header names + * are lowercase. + * + * The object returned by the `response.getHeaders()` method _does not_prototypically inherit from the JavaScript `Object`. This means that typical`Object` methods such as `obj.toString()`, + * `obj.hasOwnProperty()`, and others + * are not defined and _will not work_. + * + * ```js + * response.setHeader('Foo', 'bar'); + * response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); + * + * const headers = response.getHeaders(); + * // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] } + * ``` + * @since v8.4.0 + */ + getHeaders(): OutgoingHttpHeaders; + /** + * Returns `true` if the header identified by `name` is currently set in the + * outgoing headers. The header name matching is case-insensitive. + * + * ```js + * const hasContentType = response.hasHeader('content-type'); + * ``` + * @since v8.4.0 + */ + hasHeader(name: string): boolean; + /** + * Removes a header that has been queued for implicit sending. + * + * ```js + * response.removeHeader('Content-Encoding'); + * ``` + * @since v8.4.0 + */ + removeHeader(name: string): void; + /** + * Sets a single header value for implicit headers. If this header already exists + * in the to-be-sent headers, its value will be replaced. Use an array of strings + * here to send multiple headers with the same name. + * + * ```js + * response.setHeader('Content-Type', 'text/html; charset=utf-8'); + * ``` + * + * or + * + * ```js + * response.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']); + * ``` + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a `TypeError` being thrown. + * + * When headers have been set with `response.setHeader()`, they will be merged + * with any headers passed to `response.writeHead()`, with the headers passed + * to `response.writeHead()` given precedence. + * + * ```js + * // Returns content-type = text/plain + * const server = http2.createServer((req, res) => { + * res.setHeader('Content-Type', 'text/html; charset=utf-8'); + * res.setHeader('X-Foo', 'bar'); + * res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' }); + * res.end('ok'); + * }); + * ``` + * @since v8.4.0 + */ + setHeader(name: string, value: number | string | readonly string[]): void; + /** + * Sets the `Http2Stream`'s timeout value to `msecs`. If a callback is + * provided, then it is added as a listener on the `'timeout'` event on + * the response object. + * + * If no `'timeout'` listener is added to the request, the response, or + * the server, then `Http2Stream` s are destroyed when they time out. If a + * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly. + * @since v8.4.0 + */ + setTimeout(msecs: number, callback?: () => void): void; + /** + * If this method is called and `response.writeHead()` has not been called, + * it will switch to implicit header mode and flush the implicit headers. + * + * This sends a chunk of the response body. This method may + * be called multiple times to provide successive parts of the body. + * + * In the `node:http` module, the response body is omitted when the + * request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body. + * + * `chunk` can be a string or a buffer. If `chunk` is a string, + * the second parameter specifies how to encode it into a byte stream. + * By default the `encoding` is `'utf8'`. `callback` will be called when this chunk + * of data is flushed. + * + * This is the raw HTTP body and has nothing to do with higher-level multi-part + * body encodings that may be used. + * + * The first time `response.write()` is called, it will send the buffered + * header information and the first chunk of the body to the client. The second + * time `response.write()` is called, Node.js assumes data will be streamed, + * and sends the new data separately. That is, the response is buffered up to the + * first chunk of the body. + * + * Returns `true` if the entire data was flushed successfully to the kernel + * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is free again. + * @since v8.4.0 + */ + write(chunk: string | Uint8Array, callback?: (err: Error) => void): boolean; + write(chunk: string | Uint8Array, encoding: BufferEncoding, callback?: (err: Error) => void): boolean; + /** + * Sends a status `100 Continue` to the client, indicating that the request body + * should be sent. See the `'checkContinue'` event on `Http2Server` and`Http2SecureServer`. + * @since v8.4.0 + */ + writeContinue(): void; + /** + * Sends a status `103 Early Hints` to the client with a Link header, + * indicating that the user agent can preload/preconnect the linked resources. + * The `hints` is an object containing the values of headers to be sent with + * early hints message. + * + * **Example** + * + * ```js + * const earlyHintsLink = '; rel=preload; as=style'; + * response.writeEarlyHints({ + * 'link': earlyHintsLink, + * }); + * + * const earlyHintsLinks = [ + * '; rel=preload; as=style', + * '; rel=preload; as=script', + * ]; + * response.writeEarlyHints({ + * 'link': earlyHintsLinks, + * }); + * ``` + * @since v18.11.0 + */ + writeEarlyHints(hints: Record): void; + /** + * Sends a response header to the request. The status code is a 3-digit HTTP + * status code, like `404`. The last argument, `headers`, are the response headers. + * + * Returns a reference to the `Http2ServerResponse`, so that calls can be chained. + * + * For compatibility with `HTTP/1`, a human-readable `statusMessage` may be + * passed as the second argument. However, because the `statusMessage` has no + * meaning within HTTP/2, the argument will have no effect and a process warning + * will be emitted. + * + * ```js + * const body = 'hello world'; + * response.writeHead(200, { + * 'Content-Length': Buffer.byteLength(body), + * 'Content-Type': 'text/plain; charset=utf-8', + * }); + * ``` + * + * `Content-Length` is given in bytes not characters. The`Buffer.byteLength()` API may be used to determine the number of bytes in a + * given encoding. On outbound messages, Node.js does not check if Content-Length + * and the length of the body being transmitted are equal or not. However, when + * receiving messages, Node.js will automatically reject messages when the`Content-Length` does not match the actual payload size. + * + * This method may be called at most one time on a message before `response.end()` is called. + * + * If `response.write()` or `response.end()` are called before calling + * this, the implicit/mutable headers will be calculated and call this function. + * + * When headers have been set with `response.setHeader()`, they will be merged + * with any headers passed to `response.writeHead()`, with the headers passed + * to `response.writeHead()` given precedence. + * + * ```js + * // Returns content-type = text/plain + * const server = http2.createServer((req, res) => { + * res.setHeader('Content-Type', 'text/html; charset=utf-8'); + * res.setHeader('X-Foo', 'bar'); + * res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' }); + * res.end('ok'); + * }); + * ``` + * + * Attempting to set a header field name or value that contains invalid characters + * will result in a `TypeError` being thrown. + * @since v8.4.0 + */ + writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this; + writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders): this; + /** + * Call `http2stream.pushStream()` with the given headers, and wrap the + * given `Http2Stream` on a newly created `Http2ServerResponse` as the callback + * parameter if successful. When `Http2ServerRequest` is closed, the callback is + * called with an error `ERR_HTTP2_INVALID_STREAM`. + * @since v8.4.0 + * @param headers An object describing the headers + * @param callback Called once `http2stream.pushStream()` is finished, or either when the attempt to create the pushed `Http2Stream` has failed or has been rejected, or the state of + * `Http2ServerRequest` is closed prior to calling the `http2stream.pushStream()` method + */ + createPushResponse( + headers: OutgoingHttpHeaders, + callback: (err: Error | null, res: Http2ServerResponse) => void, + ): void; + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (error: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pipe", listener: (src: stream.Readable) => void): this; + addListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "drain"): boolean; + emit(event: "error", error: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "pipe", src: stream.Readable): boolean; + emit(event: "unpipe", src: stream.Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (error: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (error: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (error: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + export namespace constants { + const NGHTTP2_SESSION_SERVER: number; + const NGHTTP2_SESSION_CLIENT: number; + const NGHTTP2_STREAM_STATE_IDLE: number; + const NGHTTP2_STREAM_STATE_OPEN: number; + const NGHTTP2_STREAM_STATE_RESERVED_LOCAL: number; + const NGHTTP2_STREAM_STATE_RESERVED_REMOTE: number; + const NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: number; + const NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: number; + const NGHTTP2_STREAM_STATE_CLOSED: number; + const NGHTTP2_NO_ERROR: number; + const NGHTTP2_PROTOCOL_ERROR: number; + const NGHTTP2_INTERNAL_ERROR: number; + const NGHTTP2_FLOW_CONTROL_ERROR: number; + const NGHTTP2_SETTINGS_TIMEOUT: number; + const NGHTTP2_STREAM_CLOSED: number; + const NGHTTP2_FRAME_SIZE_ERROR: number; + const NGHTTP2_REFUSED_STREAM: number; + const NGHTTP2_CANCEL: number; + const NGHTTP2_COMPRESSION_ERROR: number; + const NGHTTP2_CONNECT_ERROR: number; + const NGHTTP2_ENHANCE_YOUR_CALM: number; + const NGHTTP2_INADEQUATE_SECURITY: number; + const NGHTTP2_HTTP_1_1_REQUIRED: number; + const NGHTTP2_ERR_FRAME_SIZE_ERROR: number; + const NGHTTP2_FLAG_NONE: number; + const NGHTTP2_FLAG_END_STREAM: number; + const NGHTTP2_FLAG_END_HEADERS: number; + const NGHTTP2_FLAG_ACK: number; + const NGHTTP2_FLAG_PADDED: number; + const NGHTTP2_FLAG_PRIORITY: number; + const DEFAULT_SETTINGS_HEADER_TABLE_SIZE: number; + const DEFAULT_SETTINGS_ENABLE_PUSH: number; + const DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: number; + const DEFAULT_SETTINGS_MAX_FRAME_SIZE: number; + const MAX_MAX_FRAME_SIZE: number; + const MIN_MAX_FRAME_SIZE: number; + const MAX_INITIAL_WINDOW_SIZE: number; + const NGHTTP2_DEFAULT_WEIGHT: number; + const NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: number; + const NGHTTP2_SETTINGS_ENABLE_PUSH: number; + const NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: number; + const NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: number; + const NGHTTP2_SETTINGS_MAX_FRAME_SIZE: number; + const NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: number; + const PADDING_STRATEGY_NONE: number; + const PADDING_STRATEGY_MAX: number; + const PADDING_STRATEGY_CALLBACK: number; + const HTTP2_HEADER_STATUS: string; + const HTTP2_HEADER_METHOD: string; + const HTTP2_HEADER_AUTHORITY: string; + const HTTP2_HEADER_SCHEME: string; + const HTTP2_HEADER_PATH: string; + const HTTP2_HEADER_ACCEPT_CHARSET: string; + const HTTP2_HEADER_ACCEPT_ENCODING: string; + const HTTP2_HEADER_ACCEPT_LANGUAGE: string; + const HTTP2_HEADER_ACCEPT_RANGES: string; + const HTTP2_HEADER_ACCEPT: string; + const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: string; + const HTTP2_HEADER_AGE: string; + const HTTP2_HEADER_ALLOW: string; + const HTTP2_HEADER_AUTHORIZATION: string; + const HTTP2_HEADER_CACHE_CONTROL: string; + const HTTP2_HEADER_CONNECTION: string; + const HTTP2_HEADER_CONTENT_DISPOSITION: string; + const HTTP2_HEADER_CONTENT_ENCODING: string; + const HTTP2_HEADER_CONTENT_LANGUAGE: string; + const HTTP2_HEADER_CONTENT_LENGTH: string; + const HTTP2_HEADER_CONTENT_LOCATION: string; + const HTTP2_HEADER_CONTENT_MD5: string; + const HTTP2_HEADER_CONTENT_RANGE: string; + const HTTP2_HEADER_CONTENT_TYPE: string; + const HTTP2_HEADER_COOKIE: string; + const HTTP2_HEADER_DATE: string; + const HTTP2_HEADER_ETAG: string; + const HTTP2_HEADER_EXPECT: string; + const HTTP2_HEADER_EXPIRES: string; + const HTTP2_HEADER_FROM: string; + const HTTP2_HEADER_HOST: string; + const HTTP2_HEADER_IF_MATCH: string; + const HTTP2_HEADER_IF_MODIFIED_SINCE: string; + const HTTP2_HEADER_IF_NONE_MATCH: string; + const HTTP2_HEADER_IF_RANGE: string; + const HTTP2_HEADER_IF_UNMODIFIED_SINCE: string; + const HTTP2_HEADER_LAST_MODIFIED: string; + const HTTP2_HEADER_LINK: string; + const HTTP2_HEADER_LOCATION: string; + const HTTP2_HEADER_MAX_FORWARDS: string; + const HTTP2_HEADER_PREFER: string; + const HTTP2_HEADER_PROXY_AUTHENTICATE: string; + const HTTP2_HEADER_PROXY_AUTHORIZATION: string; + const HTTP2_HEADER_RANGE: string; + const HTTP2_HEADER_REFERER: string; + const HTTP2_HEADER_REFRESH: string; + const HTTP2_HEADER_RETRY_AFTER: string; + const HTTP2_HEADER_SERVER: string; + const HTTP2_HEADER_SET_COOKIE: string; + const HTTP2_HEADER_STRICT_TRANSPORT_SECURITY: string; + const HTTP2_HEADER_TRANSFER_ENCODING: string; + const HTTP2_HEADER_TE: string; + const HTTP2_HEADER_UPGRADE: string; + const HTTP2_HEADER_USER_AGENT: string; + const HTTP2_HEADER_VARY: string; + const HTTP2_HEADER_VIA: string; + const HTTP2_HEADER_WWW_AUTHENTICATE: string; + const HTTP2_HEADER_HTTP2_SETTINGS: string; + const HTTP2_HEADER_KEEP_ALIVE: string; + const HTTP2_HEADER_PROXY_CONNECTION: string; + const HTTP2_METHOD_ACL: string; + const HTTP2_METHOD_BASELINE_CONTROL: string; + const HTTP2_METHOD_BIND: string; + const HTTP2_METHOD_CHECKIN: string; + const HTTP2_METHOD_CHECKOUT: string; + const HTTP2_METHOD_CONNECT: string; + const HTTP2_METHOD_COPY: string; + const HTTP2_METHOD_DELETE: string; + const HTTP2_METHOD_GET: string; + const HTTP2_METHOD_HEAD: string; + const HTTP2_METHOD_LABEL: string; + const HTTP2_METHOD_LINK: string; + const HTTP2_METHOD_LOCK: string; + const HTTP2_METHOD_MERGE: string; + const HTTP2_METHOD_MKACTIVITY: string; + const HTTP2_METHOD_MKCALENDAR: string; + const HTTP2_METHOD_MKCOL: string; + const HTTP2_METHOD_MKREDIRECTREF: string; + const HTTP2_METHOD_MKWORKSPACE: string; + const HTTP2_METHOD_MOVE: string; + const HTTP2_METHOD_OPTIONS: string; + const HTTP2_METHOD_ORDERPATCH: string; + const HTTP2_METHOD_PATCH: string; + const HTTP2_METHOD_POST: string; + const HTTP2_METHOD_PRI: string; + const HTTP2_METHOD_PROPFIND: string; + const HTTP2_METHOD_PROPPATCH: string; + const HTTP2_METHOD_PUT: string; + const HTTP2_METHOD_REBIND: string; + const HTTP2_METHOD_REPORT: string; + const HTTP2_METHOD_SEARCH: string; + const HTTP2_METHOD_TRACE: string; + const HTTP2_METHOD_UNBIND: string; + const HTTP2_METHOD_UNCHECKOUT: string; + const HTTP2_METHOD_UNLINK: string; + const HTTP2_METHOD_UNLOCK: string; + const HTTP2_METHOD_UPDATE: string; + const HTTP2_METHOD_UPDATEREDIRECTREF: string; + const HTTP2_METHOD_VERSION_CONTROL: string; + const HTTP_STATUS_CONTINUE: number; + const HTTP_STATUS_SWITCHING_PROTOCOLS: number; + const HTTP_STATUS_PROCESSING: number; + const HTTP_STATUS_OK: number; + const HTTP_STATUS_CREATED: number; + const HTTP_STATUS_ACCEPTED: number; + const HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: number; + const HTTP_STATUS_NO_CONTENT: number; + const HTTP_STATUS_RESET_CONTENT: number; + const HTTP_STATUS_PARTIAL_CONTENT: number; + const HTTP_STATUS_MULTI_STATUS: number; + const HTTP_STATUS_ALREADY_REPORTED: number; + const HTTP_STATUS_IM_USED: number; + const HTTP_STATUS_MULTIPLE_CHOICES: number; + const HTTP_STATUS_MOVED_PERMANENTLY: number; + const HTTP_STATUS_FOUND: number; + const HTTP_STATUS_SEE_OTHER: number; + const HTTP_STATUS_NOT_MODIFIED: number; + const HTTP_STATUS_USE_PROXY: number; + const HTTP_STATUS_TEMPORARY_REDIRECT: number; + const HTTP_STATUS_PERMANENT_REDIRECT: number; + const HTTP_STATUS_BAD_REQUEST: number; + const HTTP_STATUS_UNAUTHORIZED: number; + const HTTP_STATUS_PAYMENT_REQUIRED: number; + const HTTP_STATUS_FORBIDDEN: number; + const HTTP_STATUS_NOT_FOUND: number; + const HTTP_STATUS_METHOD_NOT_ALLOWED: number; + const HTTP_STATUS_NOT_ACCEPTABLE: number; + const HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED: number; + const HTTP_STATUS_REQUEST_TIMEOUT: number; + const HTTP_STATUS_CONFLICT: number; + const HTTP_STATUS_GONE: number; + const HTTP_STATUS_LENGTH_REQUIRED: number; + const HTTP_STATUS_PRECONDITION_FAILED: number; + const HTTP_STATUS_PAYLOAD_TOO_LARGE: number; + const HTTP_STATUS_URI_TOO_LONG: number; + const HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE: number; + const HTTP_STATUS_RANGE_NOT_SATISFIABLE: number; + const HTTP_STATUS_EXPECTATION_FAILED: number; + const HTTP_STATUS_TEAPOT: number; + const HTTP_STATUS_MISDIRECTED_REQUEST: number; + const HTTP_STATUS_UNPROCESSABLE_ENTITY: number; + const HTTP_STATUS_LOCKED: number; + const HTTP_STATUS_FAILED_DEPENDENCY: number; + const HTTP_STATUS_UNORDERED_COLLECTION: number; + const HTTP_STATUS_UPGRADE_REQUIRED: number; + const HTTP_STATUS_PRECONDITION_REQUIRED: number; + const HTTP_STATUS_TOO_MANY_REQUESTS: number; + const HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: number; + const HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: number; + const HTTP_STATUS_INTERNAL_SERVER_ERROR: number; + const HTTP_STATUS_NOT_IMPLEMENTED: number; + const HTTP_STATUS_BAD_GATEWAY: number; + const HTTP_STATUS_SERVICE_UNAVAILABLE: number; + const HTTP_STATUS_GATEWAY_TIMEOUT: number; + const HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED: number; + const HTTP_STATUS_VARIANT_ALSO_NEGOTIATES: number; + const HTTP_STATUS_INSUFFICIENT_STORAGE: number; + const HTTP_STATUS_LOOP_DETECTED: number; + const HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED: number; + const HTTP_STATUS_NOT_EXTENDED: number; + const HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED: number; + } + /** + * This symbol can be set as a property on the HTTP/2 headers object with + * an array value in order to provide a list of headers considered sensitive. + */ + export const sensitiveHeaders: symbol; + /** + * Returns an object containing the default settings for an `Http2Session`instance. This method returns a new object instance every time it is called + * so instances returned may be safely modified for use. + * @since v8.4.0 + */ + export function getDefaultSettings(): Settings; + /** + * Returns a `Buffer` instance containing serialized representation of the given + * HTTP/2 settings as specified in the [HTTP/2](https://tools.ietf.org/html/rfc7540) specification. This is intended + * for use with the `HTTP2-Settings` header field. + * + * ```js + * const http2 = require('node:http2'); + * + * const packed = http2.getPackedSettings({ enablePush: false }); + * + * console.log(packed.toString('base64')); + * // Prints: AAIAAAAA + * ``` + * @since v8.4.0 + */ + export function getPackedSettings(settings: Settings): Buffer; + /** + * Returns a `HTTP/2 Settings Object` containing the deserialized settings from + * the given `Buffer` as generated by `http2.getPackedSettings()`. + * @since v8.4.0 + * @param buf The packed settings. + */ + export function getUnpackedSettings(buf: Uint8Array): Settings; + /** + * Returns a `net.Server` instance that creates and manages `Http2Session`instances. + * + * Since there are no browsers known that support [unencrypted HTTP/2](https://http2.github.io/faq/#does-http2-require-encryption), the use of {@link createSecureServer} is necessary when + * communicating + * with browser clients. + * + * ```js + * const http2 = require('node:http2'); + * + * // Create an unencrypted HTTP/2 server. + * // Since there are no browsers known that support + * // unencrypted HTTP/2, the use of `http2.createSecureServer()` + * // is necessary when communicating with browser clients. + * const server = http2.createServer(); + * + * server.on('stream', (stream, headers) => { + * stream.respond({ + * 'content-type': 'text/html; charset=utf-8', + * ':status': 200, + * }); + * stream.end('

Hello World

'); + * }); + * + * server.listen(8000); + * ``` + * @since v8.4.0 + * @param onRequestHandler See `Compatibility API` + */ + export function createServer( + onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): Http2Server; + export function createServer( + options: ServerOptions, + onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): Http2Server; + /** + * Returns a `tls.Server` instance that creates and manages `Http2Session`instances. + * + * ```js + * const http2 = require('node:http2'); + * const fs = require('node:fs'); + * + * const options = { + * key: fs.readFileSync('server-key.pem'), + * cert: fs.readFileSync('server-cert.pem'), + * }; + * + * // Create a secure HTTP/2 server + * const server = http2.createSecureServer(options); + * + * server.on('stream', (stream, headers) => { + * stream.respond({ + * 'content-type': 'text/html; charset=utf-8', + * ':status': 200, + * }); + * stream.end('

Hello World

'); + * }); + * + * server.listen(8443); + * ``` + * @since v8.4.0 + * @param onRequestHandler See `Compatibility API` + */ + export function createSecureServer( + onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): Http2SecureServer; + export function createSecureServer( + options: SecureServerOptions, + onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void, + ): Http2SecureServer; + /** + * Returns a `ClientHttp2Session` instance. + * + * ```js + * const http2 = require('node:http2'); + * const client = http2.connect('https://localhost:1234'); + * + * // Use the client + * + * client.close(); + * ``` + * @since v8.4.0 + * @param authority The remote HTTP/2 server to connect to. This must be in the form of a minimal, valid URL with the `http://` or `https://` prefix, host name, and IP port (if a non-default port + * is used). Userinfo (user ID and password), path, querystring, and fragment details in the URL will be ignored. + * @param listener Will be registered as a one-time listener of the {@link 'connect'} event. + */ + export function connect( + authority: string | url.URL, + listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): ClientHttp2Session; + export function connect( + authority: string | url.URL, + options?: ClientSessionOptions | SecureClientSessionOptions, + listener?: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void, + ): ClientHttp2Session; +} +declare module "node:http2" { + export * from "http2"; +} diff --git a/node_modules/@types/node/ts4.8/https.d.ts b/node_modules/@types/node/ts4.8/https.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..36ae5b2f52eb9b643b32e59346df07b40758cd1f --- /dev/null +++ b/node_modules/@types/node/ts4.8/https.d.ts @@ -0,0 +1,550 @@ +/** + * HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a + * separate module. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/https.js) + */ +declare module "https" { + import { Duplex } from "node:stream"; + import * as tls from "node:tls"; + import * as http from "node:http"; + import { URL } from "node:url"; + type ServerOptions< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions; + type RequestOptions = + & http.RequestOptions + & tls.SecureContextOptions + & { + checkServerIdentity?: typeof tls.checkServerIdentity | undefined; + rejectUnauthorized?: boolean | undefined; // Defaults to true + servername?: string | undefined; // SNI TLS Extension + }; + interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions { + rejectUnauthorized?: boolean | undefined; + maxCachedSessions?: number | undefined; + } + /** + * An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information. + * @since v0.4.5 + */ + class Agent extends http.Agent { + constructor(options?: AgentOptions); + options: AgentOptions; + } + interface Server< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + > extends http.Server {} + /** + * See `http.Server` for more information. + * @since v0.3.4 + */ + class Server< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + > extends tls.Server { + constructor(requestListener?: http.RequestListener); + constructor( + options: ServerOptions, + requestListener?: http.RequestListener, + ); + /** + * Closes all connections connected to this server. + * @since v18.2.0 + */ + closeAllConnections(): void; + /** + * Closes all connections connected to this server which are not sending a request or waiting for a response. + * @since v18.2.0 + */ + closeIdleConnections(): void; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + addListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + addListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + addListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + addListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connection", listener: (socket: Duplex) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "checkContinue", listener: http.RequestListener): this; + addListener(event: "checkExpectation", listener: http.RequestListener): this; + addListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + addListener( + event: "connect", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + addListener(event: "request", listener: http.RequestListener): this; + addListener( + event: "upgrade", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + emit(event: string, ...args: any[]): boolean; + emit(event: "keylog", line: Buffer, tlsSocket: tls.TLSSocket): boolean; + emit( + event: "newSession", + sessionId: Buffer, + sessionData: Buffer, + callback: (err: Error, resp: Buffer) => void, + ): boolean; + emit( + event: "OCSPRequest", + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ): boolean; + emit(event: "resumeSession", sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean; + emit(event: "secureConnection", tlsSocket: tls.TLSSocket): boolean; + emit(event: "tlsClientError", err: Error, tlsSocket: tls.TLSSocket): boolean; + emit(event: "close"): boolean; + emit(event: "connection", socket: Duplex): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit( + event: "checkContinue", + req: InstanceType, + res: InstanceType & { + req: InstanceType; + }, + ): boolean; + emit( + event: "checkExpectation", + req: InstanceType, + res: InstanceType & { + req: InstanceType; + }, + ): boolean; + emit(event: "clientError", err: Error, socket: Duplex): boolean; + emit(event: "connect", req: InstanceType, socket: Duplex, head: Buffer): boolean; + emit( + event: "request", + req: InstanceType, + res: InstanceType & { + req: InstanceType; + }, + ): boolean; + emit(event: "upgrade", req: InstanceType, socket: Duplex, head: Buffer): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + on( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + on( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + on( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + on(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + on(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connection", listener: (socket: Duplex) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "checkContinue", listener: http.RequestListener): this; + on(event: "checkExpectation", listener: http.RequestListener): this; + on(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + on(event: "connect", listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; + on(event: "request", listener: http.RequestListener): this; + on(event: "upgrade", listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + once( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + once( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + once( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + once(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + once(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connection", listener: (socket: Duplex) => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "checkContinue", listener: http.RequestListener): this; + once(event: "checkExpectation", listener: http.RequestListener): this; + once(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + once(event: "connect", listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; + once(event: "request", listener: http.RequestListener): this; + once(event: "upgrade", listener: (req: InstanceType, socket: Duplex, head: Buffer) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + prependListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + prependListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + prependListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + prependListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connection", listener: (socket: Duplex) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "checkContinue", listener: http.RequestListener): this; + prependListener(event: "checkExpectation", listener: http.RequestListener): this; + prependListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + prependListener( + event: "connect", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + prependListener(event: "request", listener: http.RequestListener): this; + prependListener( + event: "upgrade", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this; + prependOnceListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void, + ): this; + prependOnceListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + prependOnceListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void, + ): this; + prependOnceListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this; + prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connection", listener: (socket: Duplex) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "checkContinue", listener: http.RequestListener): this; + prependOnceListener(event: "checkExpectation", listener: http.RequestListener): this; + prependOnceListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this; + prependOnceListener( + event: "connect", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + prependOnceListener(event: "request", listener: http.RequestListener): this; + prependOnceListener( + event: "upgrade", + listener: (req: InstanceType, socket: Duplex, head: Buffer) => void, + ): this; + } + /** + * ```js + * // curl -k https://localhost:8000/ + * const https = require('node:https'); + * const fs = require('node:fs'); + * + * const options = { + * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), + * }; + * + * https.createServer(options, (req, res) => { + * res.writeHead(200); + * res.end('hello world\n'); + * }).listen(8000); + * ``` + * + * Or + * + * ```js + * const https = require('node:https'); + * const fs = require('node:fs'); + * + * const options = { + * pfx: fs.readFileSync('test/fixtures/test_cert.pfx'), + * passphrase: 'sample', + * }; + * + * https.createServer(options, (req, res) => { + * res.writeHead(200); + * res.end('hello world\n'); + * }).listen(8000); + * ``` + * @since v0.3.4 + * @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`. + * @param requestListener A listener to be added to the `'request'` event. + */ + function createServer< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + >(requestListener?: http.RequestListener): Server; + function createServer< + Request extends typeof http.IncomingMessage = typeof http.IncomingMessage, + Response extends typeof http.ServerResponse = typeof http.ServerResponse, + >( + options: ServerOptions, + requestListener?: http.RequestListener, + ): Server; + /** + * Makes a request to a secure web server. + * + * The following additional `options` from `tls.connect()` are also accepted:`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,`honorCipherOrder`, `key`, `passphrase`, + * `pfx`, `rejectUnauthorized`,`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`,`highWaterMark`. + * + * `options` can be an object, a string, or a `URL` object. If `options` is a + * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object. + * + * `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to + * upload a file with a POST request, then write to the `ClientRequest` object. + * + * ```js + * const https = require('node:https'); + * + * const options = { + * hostname: 'encrypted.google.com', + * port: 443, + * path: '/', + * method: 'GET', + * }; + * + * const req = https.request(options, (res) => { + * console.log('statusCode:', res.statusCode); + * console.log('headers:', res.headers); + * + * res.on('data', (d) => { + * process.stdout.write(d); + * }); + * }); + * + * req.on('error', (e) => { + * console.error(e); + * }); + * req.end(); + * ``` + * + * Example using options from `tls.connect()`: + * + * ```js + * const options = { + * hostname: 'encrypted.google.com', + * port: 443, + * path: '/', + * method: 'GET', + * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), + * }; + * options.agent = new https.Agent(options); + * + * const req = https.request(options, (res) => { + * // ... + * }); + * ``` + * + * Alternatively, opt out of connection pooling by not using an `Agent`. + * + * ```js + * const options = { + * hostname: 'encrypted.google.com', + * port: 443, + * path: '/', + * method: 'GET', + * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), + * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'), + * agent: false, + * }; + * + * const req = https.request(options, (res) => { + * // ... + * }); + * ``` + * + * Example using a `URL` as `options`: + * + * ```js + * const options = new URL('https://abc:xyz@example.com'); + * + * const req = https.request(options, (res) => { + * // ... + * }); + * ``` + * + * Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`): + * + * ```js + * const tls = require('node:tls'); + * const https = require('node:https'); + * const crypto = require('node:crypto'); + * + * function sha256(s) { + * return crypto.createHash('sha256').update(s).digest('base64'); + * } + * const options = { + * hostname: 'github.com', + * port: 443, + * path: '/', + * method: 'GET', + * checkServerIdentity: function(host, cert) { + * // Make sure the certificate is issued to the host we are connected to + * const err = tls.checkServerIdentity(host, cert); + * if (err) { + * return err; + * } + * + * // Pin the public key, similar to HPKP pin-sha256 pinning + * const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU='; + * if (sha256(cert.pubkey) !== pubkey256) { + * const msg = 'Certificate verification error: ' + + * `The public key of '${cert.subject.CN}' ` + + * 'does not match our pinned fingerprint'; + * return new Error(msg); + * } + * + * // Pin the exact certificate, rather than the pub key + * const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' + + * 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16'; + * if (cert.fingerprint256 !== cert256) { + * const msg = 'Certificate verification error: ' + + * `The certificate of '${cert.subject.CN}' ` + + * 'does not match our pinned fingerprint'; + * return new Error(msg); + * } + * + * // This loop is informational only. + * // Print the certificate and public key fingerprints of all certs in the + * // chain. Its common to pin the public key of the issuer on the public + * // internet, while pinning the public key of the service in sensitive + * // environments. + * do { + * console.log('Subject Common Name:', cert.subject.CN); + * console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256); + * + * hash = crypto.createHash('sha256'); + * console.log(' Public key ping-sha256:', sha256(cert.pubkey)); + * + * lastprint256 = cert.fingerprint256; + * cert = cert.issuerCertificate; + * } while (cert.fingerprint256 !== lastprint256); + * + * }, + * }; + * + * options.agent = new https.Agent(options); + * const req = https.request(options, (res) => { + * console.log('All OK. Server matched our pinned cert or public key'); + * console.log('statusCode:', res.statusCode); + * // Print the HPKP values + * console.log('headers:', res.headers['public-key-pins']); + * + * res.on('data', (d) => {}); + * }); + * + * req.on('error', (e) => { + * console.error(e.message); + * }); + * req.end(); + * ``` + * + * Outputs for example: + * + * ```text + * Subject Common Name: github.com + * Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16 + * Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU= + * Subject Common Name: DigiCert SHA2 Extended Validation Server CA + * Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A + * Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho= + * Subject Common Name: DigiCert High Assurance EV Root CA + * Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF + * Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18= + * All OK. Server matched our pinned cert or public key + * statusCode: 200 + * headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho="; + * pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4="; + * pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains + * ``` + * @since v0.3.6 + * @param options Accepts all `options` from `request`, with some differences in default values: + */ + function request( + options: RequestOptions | string | URL, + callback?: (res: http.IncomingMessage) => void, + ): http.ClientRequest; + function request( + url: string | URL, + options: RequestOptions, + callback?: (res: http.IncomingMessage) => void, + ): http.ClientRequest; + /** + * Like `http.get()` but for HTTPS. + * + * `options` can be an object, a string, or a `URL` object. If `options` is a + * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object. + * + * ```js + * const https = require('node:https'); + * + * https.get('https://encrypted.google.com/', (res) => { + * console.log('statusCode:', res.statusCode); + * console.log('headers:', res.headers); + * + * res.on('data', (d) => { + * process.stdout.write(d); + * }); + * + * }).on('error', (e) => { + * console.error(e); + * }); + * ``` + * @since v0.3.6 + * @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`. + */ + function get( + options: RequestOptions | string | URL, + callback?: (res: http.IncomingMessage) => void, + ): http.ClientRequest; + function get( + url: string | URL, + options: RequestOptions, + callback?: (res: http.IncomingMessage) => void, + ): http.ClientRequest; + let globalAgent: Agent; +} +declare module "node:https" { + export * from "https"; +} diff --git a/node_modules/@types/node/ts4.8/index.d.ts b/node_modules/@types/node/ts4.8/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c8b38c6347655f38cc3d11fd9723f4bff9c790e --- /dev/null +++ b/node_modules/@types/node/ts4.8/index.d.ts @@ -0,0 +1,88 @@ +/** + * License for programmatically and manually incorporated + * documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc + * + * Copyright Node.js contributors. All rights reserved. + * 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. + */ + +// NOTE: These definitions support NodeJS and TypeScript 4.8 and earlier. + +// Reference required types from the default lib: +/// +/// +/// +/// + +// Base definitions for all NodeJS modules that are not specific to any version of TypeScript: +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// + +/// diff --git a/node_modules/@types/node/ts4.8/inspector.d.ts b/node_modules/@types/node/ts4.8/inspector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3927b81603d1ed6b7185b943e8cef65102f8dfca --- /dev/null +++ b/node_modules/@types/node/ts4.8/inspector.d.ts @@ -0,0 +1,2747 @@ +// Type definitions for inspector + +// These definitions are auto-generated. +// Please see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/19330 +// for more information. + + +/** + * The `node:inspector` module provides an API for interacting with the V8 + * inspector. + * + * It can be accessed using: + * + * ```js + * import * as inspector from 'node:inspector/promises'; + * ``` + * + * or + * + * ```js + * import * as inspector from 'node:inspector'; + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/inspector.js) + */ +declare module 'inspector' { + import EventEmitter = require('node:events'); + interface InspectorNotification { + method: string; + params: T; + } + namespace Schema { + /** + * Description of the protocol domain. + */ + interface Domain { + /** + * Domain name. + */ + name: string; + /** + * Domain version. + */ + version: string; + } + interface GetDomainsReturnType { + /** + * List of supported domains. + */ + domains: Domain[]; + } + } + namespace Runtime { + /** + * Unique script identifier. + */ + type ScriptId = string; + /** + * Unique object identifier. + */ + type RemoteObjectId = string; + /** + * Primitive value which cannot be JSON-stringified. + */ + type UnserializableValue = string; + /** + * Mirror object referencing original JavaScript object. + */ + interface RemoteObject { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * Object class (constructor) name. Specified for object type values only. + */ + className?: string | undefined; + /** + * Remote object value in case of primitive values or JSON values (if it was requested). + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified does not have value, but gets this property. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * Unique object identifier (for non-primitive values). + */ + objectId?: RemoteObjectId | undefined; + /** + * Preview containing abbreviated property values. Specified for object type values only. + * @experimental + */ + preview?: ObjectPreview | undefined; + /** + * @experimental + */ + customPreview?: CustomPreview | undefined; + } + /** + * @experimental + */ + interface CustomPreview { + header: string; + hasBody: boolean; + formatterObjectId: RemoteObjectId; + bindRemoteObjectFunctionId: RemoteObjectId; + configObjectId?: RemoteObjectId | undefined; + } + /** + * Object containing abbreviated remote object value. + * @experimental + */ + interface ObjectPreview { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * True iff some of the properties or entries of the original object did not fit. + */ + overflow: boolean; + /** + * List of the properties. + */ + properties: PropertyPreview[]; + /** + * List of the entries. Specified for map and set subtype values only. + */ + entries?: EntryPreview[] | undefined; + } + /** + * @experimental + */ + interface PropertyPreview { + /** + * Property name. + */ + name: string; + /** + * Object type. Accessor means that the property itself is an accessor property. + */ + type: string; + /** + * User-friendly property value string. + */ + value?: string | undefined; + /** + * Nested value preview. + */ + valuePreview?: ObjectPreview | undefined; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + } + /** + * @experimental + */ + interface EntryPreview { + /** + * Preview of the key. Specified for map-like collection entries. + */ + key?: ObjectPreview | undefined; + /** + * Preview of the value. + */ + value: ObjectPreview; + } + /** + * Object property descriptor. + */ + interface PropertyDescriptor { + /** + * Property name or symbol description. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + /** + * True if the value associated with the property may be changed (data descriptors only). + */ + writable?: boolean | undefined; + /** + * A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only). + */ + get?: RemoteObject | undefined; + /** + * A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only). + */ + set?: RemoteObject | undefined; + /** + * True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. + */ + configurable: boolean; + /** + * True if this property shows up during enumeration of the properties on the corresponding object. + */ + enumerable: boolean; + /** + * True if the result was thrown during the evaluation. + */ + wasThrown?: boolean | undefined; + /** + * True if the property is owned for the object. + */ + isOwn?: boolean | undefined; + /** + * Property symbol object, if the property is of the symbol type. + */ + symbol?: RemoteObject | undefined; + } + /** + * Object internal property descriptor. This property isn't normally visible in JavaScript code. + */ + interface InternalPropertyDescriptor { + /** + * Conventional property name. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + } + /** + * Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified. + */ + interface CallArgument { + /** + * Primitive value or serializable javascript object. + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * Remote object handle. + */ + objectId?: RemoteObjectId | undefined; + } + /** + * Id of an execution context. + */ + type ExecutionContextId = number; + /** + * Description of an isolated world. + */ + interface ExecutionContextDescription { + /** + * Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed. + */ + id: ExecutionContextId; + /** + * Execution context origin. + */ + origin: string; + /** + * Human readable name describing given context. + */ + name: string; + /** + * Embedder-specific auxiliary data. + */ + auxData?: {} | undefined; + } + /** + * Detailed information about exception (or error) that was thrown during script compilation or execution. + */ + interface ExceptionDetails { + /** + * Exception id. + */ + exceptionId: number; + /** + * Exception text, which should be used together with exception object when available. + */ + text: string; + /** + * Line number of the exception location (0-based). + */ + lineNumber: number; + /** + * Column number of the exception location (0-based). + */ + columnNumber: number; + /** + * Script ID of the exception location. + */ + scriptId?: ScriptId | undefined; + /** + * URL of the exception location, to be used when the script was not reported. + */ + url?: string | undefined; + /** + * JavaScript stack trace if available. + */ + stackTrace?: StackTrace | undefined; + /** + * Exception object if available. + */ + exception?: RemoteObject | undefined; + /** + * Identifier of the context where exception happened. + */ + executionContextId?: ExecutionContextId | undefined; + } + /** + * Number of milliseconds since epoch. + */ + type Timestamp = number; + /** + * Stack entry for runtime errors and assertions. + */ + interface CallFrame { + /** + * JavaScript function name. + */ + functionName: string; + /** + * JavaScript script id. + */ + scriptId: ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * JavaScript script line number (0-based). + */ + lineNumber: number; + /** + * JavaScript script column number (0-based). + */ + columnNumber: number; + } + /** + * Call frames for assertions or error messages. + */ + interface StackTrace { + /** + * String label of this stack trace. For async traces this may be a name of the function that initiated the async call. + */ + description?: string | undefined; + /** + * JavaScript function name. + */ + callFrames: CallFrame[]; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + */ + parent?: StackTrace | undefined; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + * @experimental + */ + parentId?: StackTraceId | undefined; + } + /** + * Unique identifier of current debugger. + * @experimental + */ + type UniqueDebuggerId = string; + /** + * If debuggerId is set stack trace comes from another debugger and can be resolved there. This allows to track cross-debugger calls. See Runtime.StackTrace and Debugger.paused for usages. + * @experimental + */ + interface StackTraceId { + id: string; + debuggerId?: UniqueDebuggerId | undefined; + } + interface EvaluateParameterType { + /** + * Expression to evaluate. + */ + expression: string; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + contextId?: ExecutionContextId | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface AwaitPromiseParameterType { + /** + * Identifier of the promise. + */ + promiseObjectId: RemoteObjectId; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + } + interface CallFunctionOnParameterType { + /** + * Declaration of the function to call. + */ + functionDeclaration: string; + /** + * Identifier of the object to call function on. Either objectId or executionContextId should be specified. + */ + objectId?: RemoteObjectId | undefined; + /** + * Call arguments. All call arguments must belong to the same JavaScript world as the target object. + */ + arguments?: CallArgument[] | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + /** + * Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object. + */ + objectGroup?: string | undefined; + } + interface GetPropertiesParameterType { + /** + * Identifier of the object to return properties for. + */ + objectId: RemoteObjectId; + /** + * If true, returns properties belonging only to the element itself, not to its prototype chain. + */ + ownProperties?: boolean | undefined; + /** + * If true, returns accessor properties (with getter/setter) only; internal properties are not returned either. + * @experimental + */ + accessorPropertiesOnly?: boolean | undefined; + /** + * Whether preview should be generated for the results. + * @experimental + */ + generatePreview?: boolean | undefined; + } + interface ReleaseObjectParameterType { + /** + * Identifier of the object to release. + */ + objectId: RemoteObjectId; + } + interface ReleaseObjectGroupParameterType { + /** + * Symbolic object group name. + */ + objectGroup: string; + } + interface SetCustomObjectFormatterEnabledParameterType { + enabled: boolean; + } + interface CompileScriptParameterType { + /** + * Expression to compile. + */ + expression: string; + /** + * Source url to be set for the script. + */ + sourceURL: string; + /** + * Specifies whether the compiled script should be persisted. + */ + persistScript: boolean; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface RunScriptParameterType { + /** + * Id of the script to run. + */ + scriptId: ScriptId; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface QueryObjectsParameterType { + /** + * Identifier of the prototype to return objects for. + */ + prototypeObjectId: RemoteObjectId; + } + interface GlobalLexicalScopeNamesParameterType { + /** + * Specifies in which execution context to lookup global scope variables. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface EvaluateReturnType { + /** + * Evaluation result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface AwaitPromiseReturnType { + /** + * Promise result. Will contain rejected value if promise was rejected. + */ + result: RemoteObject; + /** + * Exception details if stack strace is available. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CallFunctionOnReturnType { + /** + * Call result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface GetPropertiesReturnType { + /** + * Object properties. + */ + result: PropertyDescriptor[]; + /** + * Internal object properties (only of the element itself). + */ + internalProperties?: InternalPropertyDescriptor[] | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CompileScriptReturnType { + /** + * Id of the script. + */ + scriptId?: ScriptId | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface RunScriptReturnType { + /** + * Run result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface QueryObjectsReturnType { + /** + * Array with objects. + */ + objects: RemoteObject; + } + interface GlobalLexicalScopeNamesReturnType { + names: string[]; + } + interface ExecutionContextCreatedEventDataType { + /** + * A newly created execution context. + */ + context: ExecutionContextDescription; + } + interface ExecutionContextDestroyedEventDataType { + /** + * Id of the destroyed context + */ + executionContextId: ExecutionContextId; + } + interface ExceptionThrownEventDataType { + /** + * Timestamp of the exception. + */ + timestamp: Timestamp; + exceptionDetails: ExceptionDetails; + } + interface ExceptionRevokedEventDataType { + /** + * Reason describing why exception was revoked. + */ + reason: string; + /** + * The id of revoked exception, as reported in exceptionThrown. + */ + exceptionId: number; + } + interface ConsoleAPICalledEventDataType { + /** + * Type of the call. + */ + type: string; + /** + * Call arguments. + */ + args: RemoteObject[]; + /** + * Identifier of the context where the call was made. + */ + executionContextId: ExecutionContextId; + /** + * Call timestamp. + */ + timestamp: Timestamp; + /** + * Stack trace captured when the call was made. + */ + stackTrace?: StackTrace | undefined; + /** + * Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context. + * @experimental + */ + context?: string | undefined; + } + interface InspectRequestedEventDataType { + object: RemoteObject; + hints: {}; + } + } + namespace Debugger { + /** + * Breakpoint identifier. + */ + type BreakpointId = string; + /** + * Call frame identifier. + */ + type CallFrameId = string; + /** + * Location in the source code. + */ + interface Location { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + } + /** + * Location in the source code. + * @experimental + */ + interface ScriptPosition { + lineNumber: number; + columnNumber: number; + } + /** + * JavaScript call frame. Array of call frames form the call stack. + */ + interface CallFrame { + /** + * Call frame identifier. This identifier is only valid while the virtual machine is paused. + */ + callFrameId: CallFrameId; + /** + * Name of the JavaScript function called on this call frame. + */ + functionName: string; + /** + * Location in the source code. + */ + functionLocation?: Location | undefined; + /** + * Location in the source code. + */ + location: Location; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Scope chain for this call frame. + */ + scopeChain: Scope[]; + /** + * this object for this call frame. + */ + this: Runtime.RemoteObject; + /** + * The value being returned, if the function is at return point. + */ + returnValue?: Runtime.RemoteObject | undefined; + } + /** + * Scope description. + */ + interface Scope { + /** + * Scope type. + */ + type: string; + /** + * Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties. + */ + object: Runtime.RemoteObject; + name?: string | undefined; + /** + * Location in the source code where scope starts + */ + startLocation?: Location | undefined; + /** + * Location in the source code where scope ends + */ + endLocation?: Location | undefined; + } + /** + * Search match for resource. + */ + interface SearchMatch { + /** + * Line number in resource content. + */ + lineNumber: number; + /** + * Line with match content. + */ + lineContent: string; + } + interface BreakLocation { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + type?: string | undefined; + } + interface SetBreakpointsActiveParameterType { + /** + * New value for breakpoints active state. + */ + active: boolean; + } + interface SetSkipAllPausesParameterType { + /** + * New value for skip pauses state. + */ + skip: boolean; + } + interface SetBreakpointByUrlParameterType { + /** + * Line number to set breakpoint at. + */ + lineNumber: number; + /** + * URL of the resources to set breakpoint on. + */ + url?: string | undefined; + /** + * Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. + */ + urlRegex?: string | undefined; + /** + * Script hash of the resources to set breakpoint on. + */ + scriptHash?: string | undefined; + /** + * Offset in the line to set breakpoint at. + */ + columnNumber?: number | undefined; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface SetBreakpointParameterType { + /** + * Location to set breakpoint in. + */ + location: Location; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface RemoveBreakpointParameterType { + breakpointId: BreakpointId; + } + interface GetPossibleBreakpointsParameterType { + /** + * Start of range to search possible breakpoint locations in. + */ + start: Location; + /** + * End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. + */ + end?: Location | undefined; + /** + * Only consider locations which are in the same (non-nested) function as start. + */ + restrictToFunction?: boolean | undefined; + } + interface ContinueToLocationParameterType { + /** + * Location to continue to. + */ + location: Location; + targetCallFrames?: string | undefined; + } + interface PauseOnAsyncCallParameterType { + /** + * Debugger will pause when async call with given stack trace is started. + */ + parentStackTraceId: Runtime.StackTraceId; + } + interface StepIntoParameterType { + /** + * Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause. + * @experimental + */ + breakOnAsyncCall?: boolean | undefined; + } + interface GetStackTraceParameterType { + stackTraceId: Runtime.StackTraceId; + } + interface SearchInContentParameterType { + /** + * Id of the script to search in. + */ + scriptId: Runtime.ScriptId; + /** + * String to search for. + */ + query: string; + /** + * If true, search is case sensitive. + */ + caseSensitive?: boolean | undefined; + /** + * If true, treats string parameter as regex. + */ + isRegex?: boolean | undefined; + } + interface SetScriptSourceParameterType { + /** + * Id of the script to edit. + */ + scriptId: Runtime.ScriptId; + /** + * New content of the script. + */ + scriptSource: string; + /** + * If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code. + */ + dryRun?: boolean | undefined; + } + interface RestartFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + } + interface GetScriptSourceParameterType { + /** + * Id of the script to get source for. + */ + scriptId: Runtime.ScriptId; + } + interface SetPauseOnExceptionsParameterType { + /** + * Pause on exceptions mode. + */ + state: string; + } + interface EvaluateOnCallFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + /** + * Expression to evaluate. + */ + expression: string; + /** + * String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup). + */ + objectGroup?: string | undefined; + /** + * Specifies whether command line API should be available to the evaluated expression, defaults to false. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether to throw an exception if side effect cannot be ruled out during evaluation. + */ + throwOnSideEffect?: boolean | undefined; + } + interface SetVariableValueParameterType { + /** + * 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. + */ + scopeNumber: number; + /** + * Variable name. + */ + variableName: string; + /** + * New variable value. + */ + newValue: Runtime.CallArgument; + /** + * Id of callframe that holds variable. + */ + callFrameId: CallFrameId; + } + interface SetReturnValueParameterType { + /** + * New return value. + */ + newValue: Runtime.CallArgument; + } + interface SetAsyncCallStackDepthParameterType { + /** + * Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default). + */ + maxDepth: number; + } + interface SetBlackboxPatternsParameterType { + /** + * Array of regexps that will be used to check script url for blackbox state. + */ + patterns: string[]; + } + interface SetBlackboxedRangesParameterType { + /** + * Id of the script. + */ + scriptId: Runtime.ScriptId; + positions: ScriptPosition[]; + } + interface EnableReturnType { + /** + * Unique identifier of the debugger. + * @experimental + */ + debuggerId: Runtime.UniqueDebuggerId; + } + interface SetBreakpointByUrlReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * List of the locations this breakpoint resolved into upon addition. + */ + locations: Location[]; + } + interface SetBreakpointReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * Location this breakpoint resolved into. + */ + actualLocation: Location; + } + interface GetPossibleBreakpointsReturnType { + /** + * List of the possible breakpoint locations. + */ + locations: BreakLocation[]; + } + interface GetStackTraceReturnType { + stackTrace: Runtime.StackTrace; + } + interface SearchInContentReturnType { + /** + * List of search matches. + */ + result: SearchMatch[]; + } + interface SetScriptSourceReturnType { + /** + * New stack trace in case editing has happened while VM was stopped. + */ + callFrames?: CallFrame[] | undefined; + /** + * Whether current call stack was modified after applying the changes. + */ + stackChanged?: boolean | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Exception details if any. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface RestartFrameReturnType { + /** + * New stack trace. + */ + callFrames: CallFrame[]; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + } + interface GetScriptSourceReturnType { + /** + * Script source. + */ + scriptSource: string; + } + interface EvaluateOnCallFrameReturnType { + /** + * Object wrapper for the evaluation result. + */ + result: Runtime.RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface ScriptParsedEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * True, if this script is generated as a result of the live edit operation. + * @experimental + */ + isLiveEdit?: boolean | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface ScriptFailedToParseEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface BreakpointResolvedEventDataType { + /** + * Breakpoint unique identifier. + */ + breakpointId: BreakpointId; + /** + * Actual breakpoint location. + */ + location: Location; + } + interface PausedEventDataType { + /** + * Call stack the virtual machine stopped on. + */ + callFrames: CallFrame[]; + /** + * Pause reason. + */ + reason: string; + /** + * Object containing break-specific auxiliary properties. + */ + data?: {} | undefined; + /** + * Hit breakpoints IDs + */ + hitBreakpoints?: string[] | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Just scheduled async call will have this stack trace as parent stack during async execution. This field is available only after Debugger.stepInto call with breakOnAsynCall flag. + * @experimental + */ + asyncCallStackTraceId?: Runtime.StackTraceId | undefined; + } + } + namespace Console { + /** + * Console message. + */ + interface ConsoleMessage { + /** + * Message source. + */ + source: string; + /** + * Message severity. + */ + level: string; + /** + * Message text. + */ + text: string; + /** + * URL of the message origin. + */ + url?: string | undefined; + /** + * Line number in the resource that generated this message (1-based). + */ + line?: number | undefined; + /** + * Column number in the resource that generated this message (1-based). + */ + column?: number | undefined; + } + interface MessageAddedEventDataType { + /** + * Console message that has been added. + */ + message: ConsoleMessage; + } + } + namespace Profiler { + /** + * Profile node. Holds callsite information, execution statistics and child nodes. + */ + interface ProfileNode { + /** + * Unique id of the node. + */ + id: number; + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Number of samples where this node was on top of the call stack. + */ + hitCount?: number | undefined; + /** + * Child node ids. + */ + children?: number[] | undefined; + /** + * The reason of being not optimized. The function may be deoptimized or marked as don't optimize. + */ + deoptReason?: string | undefined; + /** + * An array of source position ticks. + */ + positionTicks?: PositionTickInfo[] | undefined; + } + /** + * Profile. + */ + interface Profile { + /** + * The list of profile nodes. First item is the root node. + */ + nodes: ProfileNode[]; + /** + * Profiling start timestamp in microseconds. + */ + startTime: number; + /** + * Profiling end timestamp in microseconds. + */ + endTime: number; + /** + * Ids of samples top nodes. + */ + samples?: number[] | undefined; + /** + * Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime. + */ + timeDeltas?: number[] | undefined; + } + /** + * Specifies a number of samples attributed to a certain source position. + */ + interface PositionTickInfo { + /** + * Source line number (1-based). + */ + line: number; + /** + * Number of samples attributed to the source line. + */ + ticks: number; + } + /** + * Coverage data for a source range. + */ + interface CoverageRange { + /** + * JavaScript script source offset for the range start. + */ + startOffset: number; + /** + * JavaScript script source offset for the range end. + */ + endOffset: number; + /** + * Collected execution count of the source range. + */ + count: number; + } + /** + * Coverage data for a JavaScript function. + */ + interface FunctionCoverage { + /** + * JavaScript function name. + */ + functionName: string; + /** + * Source ranges inside the function with coverage data. + */ + ranges: CoverageRange[]; + /** + * Whether coverage data for this function has block granularity. + */ + isBlockCoverage: boolean; + } + /** + * Coverage data for a JavaScript script. + */ + interface ScriptCoverage { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Functions contained in the script that has coverage data. + */ + functions: FunctionCoverage[]; + } + /** + * Describes a type collected during runtime. + * @experimental + */ + interface TypeObject { + /** + * Name of a type collected with type profiling. + */ + name: string; + } + /** + * Source offset and types for a parameter or return value. + * @experimental + */ + interface TypeProfileEntry { + /** + * Source offset of the parameter or end of function for return values. + */ + offset: number; + /** + * The types for this parameter or return value. + */ + types: TypeObject[]; + } + /** + * Type profile data collected during runtime for a JavaScript script. + * @experimental + */ + interface ScriptTypeProfile { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Type profile entries for parameters and return values of the functions in the script. + */ + entries: TypeProfileEntry[]; + } + interface SetSamplingIntervalParameterType { + /** + * New sampling interval in microseconds. + */ + interval: number; + } + interface StartPreciseCoverageParameterType { + /** + * Collect accurate call counts beyond simple 'covered' or 'not covered'. + */ + callCount?: boolean | undefined; + /** + * Collect block-based coverage. + */ + detailed?: boolean | undefined; + } + interface StopReturnType { + /** + * Recorded profile. + */ + profile: Profile; + } + interface TakePreciseCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface GetBestEffortCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface TakeTypeProfileReturnType { + /** + * Type profile for all scripts since startTypeProfile() was turned on. + */ + result: ScriptTypeProfile[]; + } + interface ConsoleProfileStartedEventDataType { + id: string; + /** + * Location of console.profile(). + */ + location: Debugger.Location; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + interface ConsoleProfileFinishedEventDataType { + id: string; + /** + * Location of console.profileEnd(). + */ + location: Debugger.Location; + profile: Profile; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + } + namespace HeapProfiler { + /** + * Heap snapshot object id. + */ + type HeapSnapshotObjectId = string; + /** + * Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes. + */ + interface SamplingHeapProfileNode { + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Allocations size in bytes for the node excluding children. + */ + selfSize: number; + /** + * Child nodes. + */ + children: SamplingHeapProfileNode[]; + } + /** + * Profile. + */ + interface SamplingHeapProfile { + head: SamplingHeapProfileNode; + } + interface StartTrackingHeapObjectsParameterType { + trackAllocations?: boolean | undefined; + } + interface StopTrackingHeapObjectsParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped. + */ + reportProgress?: boolean | undefined; + } + interface TakeHeapSnapshotParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. + */ + reportProgress?: boolean | undefined; + } + interface GetObjectByHeapObjectIdParameterType { + objectId: HeapSnapshotObjectId; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + } + interface AddInspectedHeapObjectParameterType { + /** + * Heap snapshot object id to be accessible by means of $x command line API. + */ + heapObjectId: HeapSnapshotObjectId; + } + interface GetHeapObjectIdParameterType { + /** + * Identifier of the object to get heap object id for. + */ + objectId: Runtime.RemoteObjectId; + } + interface StartSamplingParameterType { + /** + * Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. + */ + samplingInterval?: number | undefined; + } + interface GetObjectByHeapObjectIdReturnType { + /** + * Evaluation result. + */ + result: Runtime.RemoteObject; + } + interface GetHeapObjectIdReturnType { + /** + * Id of the heap snapshot object corresponding to the passed remote object id. + */ + heapSnapshotObjectId: HeapSnapshotObjectId; + } + interface StopSamplingReturnType { + /** + * Recorded sampling heap profile. + */ + profile: SamplingHeapProfile; + } + interface GetSamplingProfileReturnType { + /** + * Return the sampling profile being collected. + */ + profile: SamplingHeapProfile; + } + interface AddHeapSnapshotChunkEventDataType { + chunk: string; + } + interface ReportHeapSnapshotProgressEventDataType { + done: number; + total: number; + finished?: boolean | undefined; + } + interface LastSeenObjectIdEventDataType { + lastSeenObjectId: number; + timestamp: number; + } + interface HeapStatsUpdateEventDataType { + /** + * An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment. + */ + statsUpdate: number[]; + } + } + namespace NodeTracing { + interface TraceConfig { + /** + * Controls how the trace buffer stores data. + */ + recordMode?: string | undefined; + /** + * Included category filters. + */ + includedCategories: string[]; + } + interface StartParameterType { + traceConfig: TraceConfig; + } + interface GetCategoriesReturnType { + /** + * A list of supported tracing categories. + */ + categories: string[]; + } + interface DataCollectedEventDataType { + value: Array<{}>; + } + } + namespace NodeWorker { + type WorkerID = string; + /** + * Unique identifier of attached debugging session. + */ + type SessionID = string; + interface WorkerInfo { + workerId: WorkerID; + type: string; + title: string; + url: string; + } + interface SendMessageToWorkerParameterType { + message: string; + /** + * Identifier of the session. + */ + sessionId: SessionID; + } + interface EnableParameterType { + /** + * Whether to new workers should be paused until the frontend sends `Runtime.runIfWaitingForDebugger` + * message to run them. + */ + waitForDebuggerOnStart: boolean; + } + interface DetachParameterType { + sessionId: SessionID; + } + interface AttachedToWorkerEventDataType { + /** + * Identifier assigned to the session used to send/receive messages. + */ + sessionId: SessionID; + workerInfo: WorkerInfo; + waitingForDebugger: boolean; + } + interface DetachedFromWorkerEventDataType { + /** + * Detached session identifier. + */ + sessionId: SessionID; + } + interface ReceivedMessageFromWorkerEventDataType { + /** + * Identifier of a session which sends a message. + */ + sessionId: SessionID; + message: string; + } + } + namespace NodeRuntime { + interface NotifyWhenWaitingForDisconnectParameterType { + enabled: boolean; + } + } + /** + * The `inspector.Session` is used for dispatching messages to the V8 inspector + * back-end and receiving message responses and notifications. + */ + class Session extends EventEmitter { + /** + * Create a new instance of the inspector.Session class. + * The inspector session needs to be connected through session.connect() before the messages can be dispatched to the inspector backend. + */ + constructor(); + /** + * Connects a session to the inspector back-end. + * @since v8.0.0 + */ + connect(): void; + /** + * Immediately close the session. All pending message callbacks will be called + * with an error. `session.connect()` will need to be called to be able to send + * messages again. Reconnected session will lose all inspector state, such as + * enabled agents or configured breakpoints. + * @since v8.0.0 + */ + disconnect(): void; + /** + * Posts a message to the inspector back-end. `callback` will be notified when + * a response is received. `callback` is a function that accepts two optional + * arguments: error and message-specific result. + * + * ```js + * session.post('Runtime.evaluate', { expression: '2 + 2' }, + * (error, { result }) => console.log(result)); + * // Output: { type: 'number', value: 4, description: '4' } + * ``` + * + * The latest version of the V8 inspector protocol is published on the [Chrome DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/v8/). + * + * Node.js inspector supports all the Chrome DevTools Protocol domains declared + * by V8\. Chrome DevTools Protocol domain provides an interface for interacting + * with one of the runtime agents used to inspect the application state and listen + * to the run-time events. + * + * ## Example usage + * + * Apart from the debugger, various V8 Profilers are available through the DevTools + * protocol. + * @since v8.0.0 + */ + post(method: string, params?: {}, callback?: (err: Error | null, params?: {}) => void): void; + post(method: string, callback?: (err: Error | null, params?: {}) => void): void; + /** + * Returns supported domains. + */ + post(method: 'Schema.getDomains', callback?: (err: Error | null, params: Schema.GetDomainsReturnType) => void): void; + /** + * Evaluates expression on global object. + */ + post(method: 'Runtime.evaluate', params?: Runtime.EvaluateParameterType, callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void): void; + post(method: 'Runtime.evaluate', callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void): void; + /** + * Add handler to promise with given promise object id. + */ + post(method: 'Runtime.awaitPromise', params?: Runtime.AwaitPromiseParameterType, callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void): void; + post(method: 'Runtime.awaitPromise', callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void): void; + /** + * Calls function with given declaration on the given object. Object group of the result is inherited from the target object. + */ + post(method: 'Runtime.callFunctionOn', params?: Runtime.CallFunctionOnParameterType, callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void): void; + post(method: 'Runtime.callFunctionOn', callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void): void; + /** + * Returns properties of a given object. Object group of the result is inherited from the target object. + */ + post(method: 'Runtime.getProperties', params?: Runtime.GetPropertiesParameterType, callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void): void; + post(method: 'Runtime.getProperties', callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void): void; + /** + * Releases remote object with given id. + */ + post(method: 'Runtime.releaseObject', params?: Runtime.ReleaseObjectParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Runtime.releaseObject', callback?: (err: Error | null) => void): void; + /** + * Releases all remote objects that belong to a given group. + */ + post(method: 'Runtime.releaseObjectGroup', params?: Runtime.ReleaseObjectGroupParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Runtime.releaseObjectGroup', callback?: (err: Error | null) => void): void; + /** + * Tells inspected instance to run if it was waiting for debugger to attach. + */ + post(method: 'Runtime.runIfWaitingForDebugger', callback?: (err: Error | null) => void): void; + /** + * Enables reporting of execution contexts creation by means of executionContextCreated event. When the reporting gets enabled the event will be sent immediately for each existing execution context. + */ + post(method: 'Runtime.enable', callback?: (err: Error | null) => void): void; + /** + * Disables reporting of execution contexts creation. + */ + post(method: 'Runtime.disable', callback?: (err: Error | null) => void): void; + /** + * Discards collected exceptions and console API calls. + */ + post(method: 'Runtime.discardConsoleEntries', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post(method: 'Runtime.setCustomObjectFormatterEnabled', params?: Runtime.SetCustomObjectFormatterEnabledParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Runtime.setCustomObjectFormatterEnabled', callback?: (err: Error | null) => void): void; + /** + * Compiles expression. + */ + post(method: 'Runtime.compileScript', params?: Runtime.CompileScriptParameterType, callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void): void; + post(method: 'Runtime.compileScript', callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void): void; + /** + * Runs script with given id in a given context. + */ + post(method: 'Runtime.runScript', params?: Runtime.RunScriptParameterType, callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void): void; + post(method: 'Runtime.runScript', callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void): void; + post(method: 'Runtime.queryObjects', params?: Runtime.QueryObjectsParameterType, callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void): void; + post(method: 'Runtime.queryObjects', callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void): void; + /** + * Returns all let, const and class variables from global scope. + */ + post( + method: 'Runtime.globalLexicalScopeNames', + params?: Runtime.GlobalLexicalScopeNamesParameterType, + callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void + ): void; + post(method: 'Runtime.globalLexicalScopeNames', callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void): void; + /** + * Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received. + */ + post(method: 'Debugger.enable', callback?: (err: Error | null, params: Debugger.EnableReturnType) => void): void; + /** + * Disables debugger for given page. + */ + post(method: 'Debugger.disable', callback?: (err: Error | null) => void): void; + /** + * Activates / deactivates all breakpoints on the page. + */ + post(method: 'Debugger.setBreakpointsActive', params?: Debugger.SetBreakpointsActiveParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setBreakpointsActive', callback?: (err: Error | null) => void): void; + /** + * Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). + */ + post(method: 'Debugger.setSkipAllPauses', params?: Debugger.SetSkipAllPausesParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setSkipAllPauses', callback?: (err: Error | null) => void): void; + /** + * Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads. + */ + post(method: 'Debugger.setBreakpointByUrl', params?: Debugger.SetBreakpointByUrlParameterType, callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void): void; + post(method: 'Debugger.setBreakpointByUrl', callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void): void; + /** + * Sets JavaScript breakpoint at a given location. + */ + post(method: 'Debugger.setBreakpoint', params?: Debugger.SetBreakpointParameterType, callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void): void; + post(method: 'Debugger.setBreakpoint', callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void): void; + /** + * Removes JavaScript breakpoint. + */ + post(method: 'Debugger.removeBreakpoint', params?: Debugger.RemoveBreakpointParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.removeBreakpoint', callback?: (err: Error | null) => void): void; + /** + * Returns possible locations for breakpoint. scriptId in start and end range locations should be the same. + */ + post( + method: 'Debugger.getPossibleBreakpoints', + params?: Debugger.GetPossibleBreakpointsParameterType, + callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void + ): void; + post(method: 'Debugger.getPossibleBreakpoints', callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void): void; + /** + * Continues execution until specific location is reached. + */ + post(method: 'Debugger.continueToLocation', params?: Debugger.ContinueToLocationParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.continueToLocation', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post(method: 'Debugger.pauseOnAsyncCall', params?: Debugger.PauseOnAsyncCallParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.pauseOnAsyncCall', callback?: (err: Error | null) => void): void; + /** + * Steps over the statement. + */ + post(method: 'Debugger.stepOver', callback?: (err: Error | null) => void): void; + /** + * Steps into the function call. + */ + post(method: 'Debugger.stepInto', params?: Debugger.StepIntoParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.stepInto', callback?: (err: Error | null) => void): void; + /** + * Steps out of the function call. + */ + post(method: 'Debugger.stepOut', callback?: (err: Error | null) => void): void; + /** + * Stops on the next JavaScript statement. + */ + post(method: 'Debugger.pause', callback?: (err: Error | null) => void): void; + /** + * This method is deprecated - use Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next scheduled async task if any is scheduled before next pause. Returns success when async task is actually scheduled, returns error if no task were scheduled or another scheduleStepIntoAsync was called. + * @experimental + */ + post(method: 'Debugger.scheduleStepIntoAsync', callback?: (err: Error | null) => void): void; + /** + * Resumes JavaScript execution. + */ + post(method: 'Debugger.resume', callback?: (err: Error | null) => void): void; + /** + * Returns stack trace with given stackTraceId. + * @experimental + */ + post(method: 'Debugger.getStackTrace', params?: Debugger.GetStackTraceParameterType, callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void): void; + post(method: 'Debugger.getStackTrace', callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void): void; + /** + * Searches for given string in script content. + */ + post(method: 'Debugger.searchInContent', params?: Debugger.SearchInContentParameterType, callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void): void; + post(method: 'Debugger.searchInContent', callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void): void; + /** + * Edits JavaScript source live. + */ + post(method: 'Debugger.setScriptSource', params?: Debugger.SetScriptSourceParameterType, callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void): void; + post(method: 'Debugger.setScriptSource', callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void): void; + /** + * Restarts particular call frame from the beginning. + */ + post(method: 'Debugger.restartFrame', params?: Debugger.RestartFrameParameterType, callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void): void; + post(method: 'Debugger.restartFrame', callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void): void; + /** + * Returns source for the script with given id. + */ + post(method: 'Debugger.getScriptSource', params?: Debugger.GetScriptSourceParameterType, callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void): void; + post(method: 'Debugger.getScriptSource', callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void): void; + /** + * Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none. + */ + post(method: 'Debugger.setPauseOnExceptions', params?: Debugger.SetPauseOnExceptionsParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setPauseOnExceptions', callback?: (err: Error | null) => void): void; + /** + * Evaluates expression on a given call frame. + */ + post(method: 'Debugger.evaluateOnCallFrame', params?: Debugger.EvaluateOnCallFrameParameterType, callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void): void; + post(method: 'Debugger.evaluateOnCallFrame', callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void): void; + /** + * Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually. + */ + post(method: 'Debugger.setVariableValue', params?: Debugger.SetVariableValueParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setVariableValue', callback?: (err: Error | null) => void): void; + /** + * Changes return value in top frame. Available only at return break position. + * @experimental + */ + post(method: 'Debugger.setReturnValue', params?: Debugger.SetReturnValueParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setReturnValue', callback?: (err: Error | null) => void): void; + /** + * Enables or disables async call stacks tracking. + */ + post(method: 'Debugger.setAsyncCallStackDepth', params?: Debugger.SetAsyncCallStackDepthParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setAsyncCallStackDepth', callback?: (err: Error | null) => void): void; + /** + * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. + * @experimental + */ + post(method: 'Debugger.setBlackboxPatterns', params?: Debugger.SetBlackboxPatternsParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setBlackboxPatterns', callback?: (err: Error | null) => void): void; + /** + * Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted. + * @experimental + */ + post(method: 'Debugger.setBlackboxedRanges', params?: Debugger.SetBlackboxedRangesParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Debugger.setBlackboxedRanges', callback?: (err: Error | null) => void): void; + /** + * Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification. + */ + post(method: 'Console.enable', callback?: (err: Error | null) => void): void; + /** + * Disables console domain, prevents further console messages from being reported to the client. + */ + post(method: 'Console.disable', callback?: (err: Error | null) => void): void; + /** + * Does nothing. + */ + post(method: 'Console.clearMessages', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.disable', callback?: (err: Error | null) => void): void; + /** + * Changes CPU profiler sampling interval. Must be called before CPU profiles recording started. + */ + post(method: 'Profiler.setSamplingInterval', params?: Profiler.SetSamplingIntervalParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Profiler.setSamplingInterval', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.start', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.stop', callback?: (err: Error | null, params: Profiler.StopReturnType) => void): void; + /** + * Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters. + */ + post(method: 'Profiler.startPreciseCoverage', params?: Profiler.StartPreciseCoverageParameterType, callback?: (err: Error | null) => void): void; + post(method: 'Profiler.startPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code. + */ + post(method: 'Profiler.stopPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started. + */ + post(method: 'Profiler.takePreciseCoverage', callback?: (err: Error | null, params: Profiler.TakePreciseCoverageReturnType) => void): void; + /** + * Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection. + */ + post(method: 'Profiler.getBestEffortCoverage', callback?: (err: Error | null, params: Profiler.GetBestEffortCoverageReturnType) => void): void; + /** + * Enable type profile. + * @experimental + */ + post(method: 'Profiler.startTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Disable type profile. Disabling releases type profile data collected so far. + * @experimental + */ + post(method: 'Profiler.stopTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Collect type profile. + * @experimental + */ + post(method: 'Profiler.takeTypeProfile', callback?: (err: Error | null, params: Profiler.TakeTypeProfileReturnType) => void): void; + post(method: 'HeapProfiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.disable', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.startTrackingHeapObjects', params?: HeapProfiler.StartTrackingHeapObjectsParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.startTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.stopTrackingHeapObjects', params?: HeapProfiler.StopTrackingHeapObjectsParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.stopTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.takeHeapSnapshot', params?: HeapProfiler.TakeHeapSnapshotParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.takeHeapSnapshot', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.collectGarbage', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.getObjectByHeapObjectId', + params?: HeapProfiler.GetObjectByHeapObjectIdParameterType, + callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void + ): void; + post(method: 'HeapProfiler.getObjectByHeapObjectId', callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void): void; + /** + * Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions). + */ + post(method: 'HeapProfiler.addInspectedHeapObject', params?: HeapProfiler.AddInspectedHeapObjectParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.addInspectedHeapObject', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.getHeapObjectId', params?: HeapProfiler.GetHeapObjectIdParameterType, callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void): void; + post(method: 'HeapProfiler.getHeapObjectId', callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void): void; + post(method: 'HeapProfiler.startSampling', params?: HeapProfiler.StartSamplingParameterType, callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.startSampling', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.stopSampling', callback?: (err: Error | null, params: HeapProfiler.StopSamplingReturnType) => void): void; + post(method: 'HeapProfiler.getSamplingProfile', callback?: (err: Error | null, params: HeapProfiler.GetSamplingProfileReturnType) => void): void; + /** + * Gets supported tracing categories. + */ + post(method: 'NodeTracing.getCategories', callback?: (err: Error | null, params: NodeTracing.GetCategoriesReturnType) => void): void; + /** + * Start trace events collection. + */ + post(method: 'NodeTracing.start', params?: NodeTracing.StartParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeTracing.start', callback?: (err: Error | null) => void): void; + /** + * Stop trace events collection. Remaining collected events will be sent as a sequence of + * dataCollected events followed by tracingComplete event. + */ + post(method: 'NodeTracing.stop', callback?: (err: Error | null) => void): void; + /** + * Sends protocol message over session with given id. + */ + post(method: 'NodeWorker.sendMessageToWorker', params?: NodeWorker.SendMessageToWorkerParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeWorker.sendMessageToWorker', callback?: (err: Error | null) => void): void; + /** + * Instructs the inspector to attach to running workers. Will also attach to new workers + * as they start + */ + post(method: 'NodeWorker.enable', params?: NodeWorker.EnableParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeWorker.enable', callback?: (err: Error | null) => void): void; + /** + * Detaches from all running workers and disables attaching to new workers as they are started. + */ + post(method: 'NodeWorker.disable', callback?: (err: Error | null) => void): void; + /** + * Detached from the worker with given sessionId. + */ + post(method: 'NodeWorker.detach', params?: NodeWorker.DetachParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeWorker.detach', callback?: (err: Error | null) => void): void; + /** + * Enable the `NodeRuntime.waitingForDisconnect`. + */ + post(method: 'NodeRuntime.notifyWhenWaitingForDisconnect', params?: NodeRuntime.NotifyWhenWaitingForDisconnectParameterType, callback?: (err: Error | null) => void): void; + post(method: 'NodeRuntime.notifyWhenWaitingForDisconnect', callback?: (err: Error | null) => void): void; + // Events + addListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + addListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + addListener(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + addListener(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + addListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + addListener(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + addListener(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + addListener(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + addListener(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + addListener(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + addListener(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + addListener(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + addListener(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + addListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + addListener(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + addListener(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + addListener(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + addListener(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + addListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + addListener(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + addListener(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + addListener(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + addListener(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + addListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + addListener(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + addListener(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + addListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + addListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: 'inspectorNotification', message: InspectorNotification<{}>): boolean; + emit(event: 'Runtime.executionContextCreated', message: InspectorNotification): boolean; + emit(event: 'Runtime.executionContextDestroyed', message: InspectorNotification): boolean; + emit(event: 'Runtime.executionContextsCleared'): boolean; + emit(event: 'Runtime.exceptionThrown', message: InspectorNotification): boolean; + emit(event: 'Runtime.exceptionRevoked', message: InspectorNotification): boolean; + emit(event: 'Runtime.consoleAPICalled', message: InspectorNotification): boolean; + emit(event: 'Runtime.inspectRequested', message: InspectorNotification): boolean; + emit(event: 'Debugger.scriptParsed', message: InspectorNotification): boolean; + emit(event: 'Debugger.scriptFailedToParse', message: InspectorNotification): boolean; + emit(event: 'Debugger.breakpointResolved', message: InspectorNotification): boolean; + emit(event: 'Debugger.paused', message: InspectorNotification): boolean; + emit(event: 'Debugger.resumed'): boolean; + emit(event: 'Console.messageAdded', message: InspectorNotification): boolean; + emit(event: 'Profiler.consoleProfileStarted', message: InspectorNotification): boolean; + emit(event: 'Profiler.consoleProfileFinished', message: InspectorNotification): boolean; + emit(event: 'HeapProfiler.addHeapSnapshotChunk', message: InspectorNotification): boolean; + emit(event: 'HeapProfiler.resetProfiles'): boolean; + emit(event: 'HeapProfiler.reportHeapSnapshotProgress', message: InspectorNotification): boolean; + emit(event: 'HeapProfiler.lastSeenObjectId', message: InspectorNotification): boolean; + emit(event: 'HeapProfiler.heapStatsUpdate', message: InspectorNotification): boolean; + emit(event: 'NodeTracing.dataCollected', message: InspectorNotification): boolean; + emit(event: 'NodeTracing.tracingComplete'): boolean; + emit(event: 'NodeWorker.attachedToWorker', message: InspectorNotification): boolean; + emit(event: 'NodeWorker.detachedFromWorker', message: InspectorNotification): boolean; + emit(event: 'NodeWorker.receivedMessageFromWorker', message: InspectorNotification): boolean; + emit(event: 'NodeRuntime.waitingForDisconnect'): boolean; + on(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + on(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + on(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + on(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + on(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + on(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + on(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + on(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + on(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + on(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + on(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + on(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + on(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + on(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + on(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + on(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + on(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + on(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + on(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + on(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + on(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + on(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + on(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + on(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + on(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + on(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + on(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + on(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + once(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + once(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + once(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + once(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + once(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + once(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + once(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + once(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + once(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + once(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + once(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + once(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + once(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + once(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + once(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + once(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + once(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + once(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + once(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + once(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + once(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + once(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + once(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + once(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + once(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + once(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + once(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependListener(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + prependListener(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependListener(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + prependListener(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + prependListener(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependListener(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependListener(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependListener(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependListener(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependListener(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependListener(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependListener(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + prependListener(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + prependListener(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + prependListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependListener(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependListener(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependListener(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + prependListener(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependListener(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + prependListener(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependOnceListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependOnceListener(event: 'Runtime.executionContextCreated', listener: (message: InspectorNotification) => void): this; + /** + * Issued when execution context is destroyed. + */ + prependOnceListener(event: 'Runtime.executionContextDestroyed', listener: (message: InspectorNotification) => void): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependOnceListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependOnceListener(event: 'Runtime.exceptionThrown', listener: (message: InspectorNotification) => void): this; + /** + * Issued when unhandled exception was revoked. + */ + prependOnceListener(event: 'Runtime.exceptionRevoked', listener: (message: InspectorNotification) => void): this; + /** + * Issued when console API was called. + */ + prependOnceListener(event: 'Runtime.consoleAPICalled', listener: (message: InspectorNotification) => void): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependOnceListener(event: 'Runtime.inspectRequested', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependOnceListener(event: 'Debugger.scriptParsed', listener: (message: InspectorNotification) => void): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependOnceListener(event: 'Debugger.scriptFailedToParse', listener: (message: InspectorNotification) => void): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependOnceListener(event: 'Debugger.breakpointResolved', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependOnceListener(event: 'Debugger.paused', listener: (message: InspectorNotification) => void): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependOnceListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependOnceListener(event: 'Console.messageAdded', listener: (message: InspectorNotification) => void): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependOnceListener(event: 'Profiler.consoleProfileStarted', listener: (message: InspectorNotification) => void): this; + prependOnceListener(event: 'Profiler.consoleProfileFinished', listener: (message: InspectorNotification) => void): this; + prependOnceListener(event: 'HeapProfiler.addHeapSnapshotChunk', listener: (message: InspectorNotification) => void): this; + prependOnceListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependOnceListener(event: 'HeapProfiler.reportHeapSnapshotProgress', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependOnceListener(event: 'HeapProfiler.lastSeenObjectId', listener: (message: InspectorNotification) => void): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependOnceListener(event: 'HeapProfiler.heapStatsUpdate', listener: (message: InspectorNotification) => void): this; + /** + * Contains an bucket of collected trace events. + */ + prependOnceListener(event: 'NodeTracing.dataCollected', listener: (message: InspectorNotification) => void): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependOnceListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependOnceListener(event: 'NodeWorker.attachedToWorker', listener: (message: InspectorNotification) => void): this; + /** + * Issued when detached from the worker. + */ + prependOnceListener(event: 'NodeWorker.detachedFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependOnceListener(event: 'NodeWorker.receivedMessageFromWorker', listener: (message: InspectorNotification) => void): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependOnceListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + } + /** + * Activate inspector on host and port. Equivalent to`node --inspect=[[host:]port]`, but can be done programmatically after node has + * started. + * + * If wait is `true`, will block until a client has connected to the inspect port + * and flow control has been passed to the debugger client. + * + * See the `security warning` regarding the `host`parameter usage. + * @param [port='what was specified on the CLI'] Port to listen on for inspector connections. Optional. + * @param [host='what was specified on the CLI'] Host to listen on for inspector connections. Optional. + * @param [wait=false] Block until a client has connected. Optional. + * @returns Disposable that calls `inspector.close()`. + */ + function open(port?: number, host?: string, wait?: boolean): Disposable; + /** + * Deactivate the inspector. Blocks until there are no active connections. + */ + function close(): void; + /** + * Return the URL of the active inspector, or `undefined` if there is none. + * + * ```console + * $ node --inspect -p 'inspector.url()' + * Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * For help, see: https://nodejs.org/en/docs/inspector + * ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * + * $ node --inspect=localhost:3000 -p 'inspector.url()' + * Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * For help, see: https://nodejs.org/en/docs/inspector + * ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * + * $ node -p 'inspector.url()' + * undefined + * ``` + */ + function url(): string | undefined; + /** + * Blocks until a client (existing or connected later) has sent`Runtime.runIfWaitingForDebugger` command. + * + * An exception will be thrown if there is no active inspector. + * @since v12.7.0 + */ + function waitForDebugger(): void; +} +/** + * The inspector module provides an API for interacting with the V8 inspector. + */ +declare module 'node:inspector' { + import inspector = require('inspector'); + export = inspector; +} diff --git a/node_modules/@types/node/ts4.8/module.d.ts b/node_modules/@types/node/ts4.8/module.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..68d59c7737bda512502cf2d3ec9c48483c56295e --- /dev/null +++ b/node_modules/@types/node/ts4.8/module.d.ts @@ -0,0 +1,301 @@ +/** + * @since v0.3.7 + * @experimental + */ +declare module "module" { + import { URL } from "node:url"; + import { MessagePort } from "node:worker_threads"; + namespace Module { + /** + * The `module.syncBuiltinESMExports()` method updates all the live bindings for + * builtin `ES Modules` to match the properties of the `CommonJS` exports. It + * does not add or remove exported names from the `ES Modules`. + * + * ```js + * const fs = require('node:fs'); + * const assert = require('node:assert'); + * const { syncBuiltinESMExports } = require('node:module'); + * + * fs.readFile = newAPI; + * + * delete fs.readFileSync; + * + * function newAPI() { + * // ... + * } + * + * fs.newAPI = newAPI; + * + * syncBuiltinESMExports(); + * + * import('node:fs').then((esmFS) => { + * // It syncs the existing readFile property with the new value + * assert.strictEqual(esmFS.readFile, newAPI); + * // readFileSync has been deleted from the required fs + * assert.strictEqual('readFileSync' in fs, false); + * // syncBuiltinESMExports() does not remove readFileSync from esmFS + * assert.strictEqual('readFileSync' in esmFS, true); + * // syncBuiltinESMExports() does not add names + * assert.strictEqual(esmFS.newAPI, undefined); + * }); + * ``` + * @since v12.12.0 + */ + function syncBuiltinESMExports(): void; + /** + * `path` is the resolved path for the file for which a corresponding source map + * should be fetched. + * @since v13.7.0, v12.17.0 + * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. + */ + function findSourceMap(path: string, error?: Error): SourceMap; + interface SourceMapPayload { + file: string; + version: number; + sources: string[]; + sourcesContent: string[]; + names: string[]; + mappings: string; + sourceRoot: string; + } + interface SourceMapping { + generatedLine: number; + generatedColumn: number; + originalSource: string; + originalLine: number; + originalColumn: number; + } + interface SourceOrigin { + /** + * The name of the range in the source map, if one was provided + */ + name?: string; + /** + * The file name of the original source, as reported in the SourceMap + */ + fileName: string; + /** + * The 1-indexed lineNumber of the corresponding call site in the original source + */ + lineNumber: number; + /** + * The 1-indexed columnNumber of the corresponding call site in the original source + */ + columnNumber: number; + } + /** + * @since v13.7.0, v12.17.0 + */ + class SourceMap { + /** + * Getter for the payload used to construct the `SourceMap` instance. + */ + readonly payload: SourceMapPayload; + constructor(payload: SourceMapPayload); + /** + * Given a line offset and column offset in the generated source + * file, returns an object representing the SourceMap range in the + * original file if found, or an empty object if not. + * + * The object returned contains the following keys: + * + * The returned value represents the raw range as it appears in the + * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and + * column numbers as they appear in Error messages and CallSite + * objects. + * + * To get the corresponding 1-indexed line and column numbers from a + * lineNumber and columnNumber as they are reported by Error stacks + * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)` + * @param lineOffset The zero-indexed line number offset in the generated source + * @param columnOffset The zero-indexed column number offset in the generated source + */ + findEntry(lineOffset: number, columnOffset: number): SourceMapping; + /** + * Given a 1-indexed `lineNumber` and `columnNumber` from a call site in the generated source, + * find the corresponding call site location in the original source. + * + * If the `lineNumber` and `columnNumber` provided are not found in any source map, + * then an empty object is returned. + * @param lineNumber The 1-indexed line number of the call site in the generated source + * @param columnNumber The 1-indexed column number of the call site in the generated source + */ + findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {}; + } + /** @deprecated Use `ImportAttributes` instead */ + interface ImportAssertions extends ImportAttributes {} + interface ImportAttributes extends NodeJS.Dict { + type?: string | undefined; + } + type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm"; + type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray; + interface GlobalPreloadContext { + port: MessagePort; + } + /** + * @deprecated This hook will be removed in a future version. + * Use `initialize` instead. When a loader has an `initialize` export, `globalPreload` will be ignored. + * + * Sometimes it might be necessary to run some code inside of the same global scope that the application runs in. + * This hook allows the return of a string that is run as a sloppy-mode script on startup. + * + * @param context Information to assist the preload code + * @return Code to run before application startup + */ + type GlobalPreloadHook = (context: GlobalPreloadContext) => string; + /** + * The `initialize` hook provides a way to define a custom function that runs in the hooks thread + * when the hooks module is initialized. Initialization happens when the hooks module is registered via `register`. + * + * This hook can receive data from a `register` invocation, including ports and other transferrable objects. + * The return value of `initialize` can be a `Promise`, in which case it will be awaited before the main application thread execution resumes. + */ + type InitializeHook = (data: Data) => void | Promise; + interface ResolveHookContext { + /** + * Export conditions of the relevant `package.json` + */ + conditions: string[]; + /** + * @deprecated Use `importAttributes` instead + */ + importAssertions: ImportAttributes; + /** + * An object whose key-value pairs represent the assertions for the module to import + */ + importAttributes: ImportAttributes; + /** + * The module importing this one, or undefined if this is the Node.js entry point + */ + parentURL: string | undefined; + } + interface ResolveFnOutput { + /** + * A hint to the load hook (it might be ignored) + */ + format?: ModuleFormat | null | undefined; + /** + * @deprecated Use `importAttributes` instead + */ + importAssertions?: ImportAttributes | undefined; + /** + * The import attributes to use when caching the module (optional; if excluded the input will be used) + */ + importAttributes?: ImportAttributes | undefined; + /** + * A signal that this hook intends to terminate the chain of `resolve` hooks. + * @default false + */ + shortCircuit?: boolean | undefined; + /** + * The absolute URL to which this input resolves + */ + url: string; + } + /** + * The `resolve` hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as `'module'`) as a hint to the `load` hook. + * If a format is specified, the load hook is ultimately responsible for providing the final `format` value (and it is free to ignore the hint provided by `resolve`); + * if `resolve` provides a format, a custom `load` hook is required even if only to pass the value to the Node.js default `load` hook. + * + * @param specifier The specified URL path of the module to be resolved + * @param context + * @param nextResolve The subsequent `resolve` hook in the chain, or the Node.js default `resolve` hook after the last user-supplied resolve hook + */ + type ResolveHook = ( + specifier: string, + context: ResolveHookContext, + nextResolve: ( + specifier: string, + context?: ResolveHookContext, + ) => ResolveFnOutput | Promise, + ) => ResolveFnOutput | Promise; + interface LoadHookContext { + /** + * Export conditions of the relevant `package.json` + */ + conditions: string[]; + /** + * The format optionally supplied by the `resolve` hook chain + */ + format: ModuleFormat; + /** + * @deprecated Use `importAttributes` instead + */ + importAssertions: ImportAttributes; + /** + * An object whose key-value pairs represent the assertions for the module to import + */ + importAttributes: ImportAttributes; + } + interface LoadFnOutput { + format: ModuleFormat; + /** + * A signal that this hook intends to terminate the chain of `resolve` hooks. + * @default false + */ + shortCircuit?: boolean | undefined; + /** + * The source for Node.js to evaluate + */ + source?: ModuleSource; + } + /** + * The `load` hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed. + * It is also in charge of validating the import assertion. + * + * @param url The URL/path of the module to be loaded + * @param context Metadata about the module + * @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook + */ + type LoadHook = ( + url: string, + context: LoadHookContext, + nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise, + ) => LoadFnOutput | Promise; + } + interface RegisterOptions { + parentURL: string | URL; + data?: Data | undefined; + transferList?: any[] | undefined; + } + interface Module extends NodeModule {} + class Module { + static runMain(): void; + static wrap(code: string): string; + static createRequire(path: string | URL): NodeRequire; + static builtinModules: string[]; + static isBuiltin(moduleName: string): boolean; + static Module: typeof Module; + static register( + specifier: string | URL, + parentURL?: string | URL, + options?: RegisterOptions, + ): void; + static register(specifier: string | URL, options?: RegisterOptions): void; + constructor(id: string, parent?: Module); + } + global { + interface ImportMeta { + url: string; + /** + * Provides a module-relative resolution function scoped to each module, returning + * the URL string. + * + * Second `parent` parameter is only used when the `--experimental-import-meta-resolve` + * command flag enabled. + * + * @since v20.6.0 + * + * @param specifier The module specifier to resolve relative to `parent`. + * @param parent The absolute parent module URL to resolve from. + * @returns The absolute (`file:`) URL string for the resolved module. + */ + resolve(specifier: string, parent?: string | URL | undefined): string; + } + } + export = Module; +} +declare module "node:module" { + import module = require("module"); + export = module; +} diff --git a/node_modules/@types/node/ts4.8/net.d.ts b/node_modules/@types/node/ts4.8/net.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..70789e1ba1c71d917006acfa4cca7769ea1c705e --- /dev/null +++ b/node_modules/@types/node/ts4.8/net.d.ts @@ -0,0 +1,949 @@ +/** + * > Stability: 2 - Stable + * + * The `node:net` module provides an asynchronous network API for creating stream-based + * TCP or `IPC` servers ({@link createServer}) and clients + * ({@link createConnection}). + * + * It can be accessed using: + * + * ```js + * const net = require('node:net'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/net.js) + */ +declare module "net" { + import * as stream from "node:stream"; + import { Abortable, EventEmitter } from "node:events"; + import * as dns from "node:dns"; + type LookupFunction = ( + hostname: string, + options: dns.LookupAllOptions, + callback: (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void, + ) => void; + interface AddressInfo { + address: string; + family: string; + port: number; + } + interface SocketConstructorOpts { + fd?: number | undefined; + allowHalfOpen?: boolean | undefined; + readable?: boolean | undefined; + writable?: boolean | undefined; + signal?: AbortSignal; + } + interface OnReadOpts { + buffer: Uint8Array | (() => Uint8Array); + /** + * This function is called for every chunk of incoming data. + * Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer. + * Return false from this function to implicitly pause() the socket. + */ + callback(bytesWritten: number, buf: Uint8Array): boolean; + } + interface ConnectOpts { + /** + * If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket. + * Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will + * still be emitted as normal and methods like pause() and resume() will also behave as expected. + */ + onread?: OnReadOpts | undefined; + } + interface TcpSocketConnectOpts extends ConnectOpts { + port: number; + host?: string | undefined; + localAddress?: string | undefined; + localPort?: number | undefined; + hints?: number | undefined; + family?: number | undefined; + lookup?: LookupFunction | undefined; + noDelay?: boolean | undefined; + keepAlive?: boolean | undefined; + keepAliveInitialDelay?: number | undefined; + /** + * @since v18.13.0 + */ + autoSelectFamily?: boolean | undefined; + /** + * @since v18.13.0 + */ + autoSelectFamilyAttemptTimeout?: number | undefined; + } + interface IpcSocketConnectOpts extends ConnectOpts { + path: string; + } + type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts; + type SocketReadyState = "opening" | "open" | "readOnly" | "writeOnly" | "closed"; + /** + * This class is an abstraction of a TCP socket or a streaming `IPC` endpoint + * (uses named pipes on Windows, and Unix domain sockets otherwise). It is also + * an `EventEmitter`. + * + * A `net.Socket` can be created by the user and used directly to interact with + * a server. For example, it is returned by {@link createConnection}, + * so the user can use it to talk to the server. + * + * It can also be created by Node.js and passed to the user when a connection + * is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use + * it to interact with the client. + * @since v0.3.4 + */ + class Socket extends stream.Duplex { + constructor(options?: SocketConstructorOpts); + /** + * Destroys the socket after all data is written. If the `finish` event was already emitted the socket is destroyed immediately. + * If the socket is still writable it implicitly calls `socket.end()`. + * @since v0.3.4 + */ + destroySoon(): void; + /** + * Sends data on the socket. The second parameter specifies the encoding in the + * case of a string. It defaults to UTF8 encoding. + * + * Returns `true` if the entire data was flushed successfully to the kernel + * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free. + * + * The optional `callback` parameter will be executed when the data is finally + * written out, which may not be immediately. + * + * See `Writable` stream `write()` method for more + * information. + * @since v0.1.90 + * @param [encoding='utf8'] Only used when data is `string`. + */ + write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean; + write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean; + /** + * Initiate a connection on a given socket. + * + * Possible signatures: + * + * * `socket.connect(options[, connectListener])` + * * `socket.connect(path[, connectListener])` for `IPC` connections. + * * `socket.connect(port[, host][, connectListener])` for TCP connections. + * * Returns: `net.Socket` The socket itself. + * + * This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting, + * instead of a `'connect'` event, an `'error'` event will be emitted with + * the error passed to the `'error'` listener. + * The last parameter `connectListener`, if supplied, will be added as a listener + * for the `'connect'` event **once**. + * + * This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined + * behavior. + */ + connect(options: SocketConnectOpts, connectionListener?: () => void): this; + connect(port: number, host: string, connectionListener?: () => void): this; + connect(port: number, connectionListener?: () => void): this; + connect(path: string, connectionListener?: () => void): this; + /** + * Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information. + * @since v0.1.90 + * @return The socket itself. + */ + setEncoding(encoding?: BufferEncoding): this; + /** + * Pauses the reading of data. That is, `'data'` events will not be emitted. + * Useful to throttle back an upload. + * @return The socket itself. + */ + pause(): this; + /** + * Close the TCP connection by sending an RST packet and destroy the stream. + * If this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected. + * Otherwise, it will call `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. + * If this is not a TCP socket (for example, a pipe), calling this method will immediately throw an `ERR_INVALID_HANDLE_TYPE` Error. + * @since v18.3.0, v16.17.0 + */ + resetAndDestroy(): this; + /** + * Resumes reading after a call to `socket.pause()`. + * @return The socket itself. + */ + resume(): this; + /** + * Sets the socket to timeout after `timeout` milliseconds of inactivity on + * the socket. By default `net.Socket` do not have a timeout. + * + * When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to + * end the connection. + * + * ```js + * socket.setTimeout(3000); + * socket.on('timeout', () => { + * console.log('socket timeout'); + * socket.end(); + * }); + * ``` + * + * If `timeout` is 0, then the existing idle timeout is disabled. + * + * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event. + * @since v0.1.90 + * @return The socket itself. + */ + setTimeout(timeout: number, callback?: () => void): this; + /** + * Enable/disable the use of Nagle's algorithm. + * + * When a TCP connection is created, it will have Nagle's algorithm enabled. + * + * Nagle's algorithm delays data before it is sent via the network. It attempts + * to optimize throughput at the expense of latency. + * + * Passing `true` for `noDelay` or not passing an argument will disable Nagle's + * algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's + * algorithm. + * @since v0.1.90 + * @param [noDelay=true] + * @return The socket itself. + */ + setNoDelay(noDelay?: boolean): this; + /** + * Enable/disable keep-alive functionality, and optionally set the initial + * delay before the first keepalive probe is sent on an idle socket. + * + * Set `initialDelay` (in milliseconds) to set the delay between the last + * data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default + * (or previous) setting. + * + * Enabling the keep-alive functionality will set the following socket options: + * + * * `SO_KEEPALIVE=1` + * * `TCP_KEEPIDLE=initialDelay` + * * `TCP_KEEPCNT=10` + * * `TCP_KEEPINTVL=1` + * @since v0.1.92 + * @param [enable=false] + * @param [initialDelay=0] + * @return The socket itself. + */ + setKeepAlive(enable?: boolean, initialDelay?: number): this; + /** + * Returns the bound `address`, the address `family` name and `port` of the + * socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }` + * @since v0.1.90 + */ + address(): AddressInfo | {}; + /** + * Calling `unref()` on a socket will allow the program to exit if this is the only + * active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect. + * @since v0.9.1 + * @return The socket itself. + */ + unref(): this; + /** + * Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will _not_ let the program exit if it's the only socket left (the default behavior). + * If the socket is `ref`ed calling `ref` again will have no effect. + * @since v0.9.1 + * @return The socket itself. + */ + ref(): this; + /** + * This property is only present if the family autoselection algorithm is enabled in `socket.connect(options)` + * and it is an array of the addresses that have been attempted. + * + * Each address is a string in the form of `$IP:$PORT`. + * If the connection was successful, then the last address is the one that the socket is currently connected to. + * @since v19.4.0 + */ + readonly autoSelectFamilyAttemptedAddresses: string[]; + /** + * This property shows the number of characters buffered for writing. The buffer + * may contain strings whose length after encoding is not yet known. So this number + * is only an approximation of the number of bytes in the buffer. + * + * `net.Socket` has the property that `socket.write()` always works. This is to + * help users get up and running quickly. The computer cannot always keep up + * with the amount of data that is written to a socket. The network connection + * simply might be too slow. Node.js will internally queue up the data written to a + * socket and send it out over the wire when it is possible. + * + * The consequence of this internal buffering is that memory may grow. + * Users who experience large or growing `bufferSize` should attempt to + * "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`. + * @since v0.3.8 + * @deprecated Since v14.6.0 - Use `writableLength` instead. + */ + readonly bufferSize: number; + /** + * The amount of received bytes. + * @since v0.5.3 + */ + readonly bytesRead: number; + /** + * The amount of bytes sent. + * @since v0.5.3 + */ + readonly bytesWritten: number; + /** + * If `true`,`socket.connect(options[, connectListener])` was + * called and has not yet finished. It will stay `true` until the socket becomes + * connected, then it is set to `false` and the `'connect'` event is emitted. Note + * that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event. + * @since v6.1.0 + */ + readonly connecting: boolean; + /** + * This is `true` if the socket is not connected yet, either because `.connect()`has not yet been called or because it is still in the process of connecting + * (see `socket.connecting`). + * @since v11.2.0, v10.16.0 + */ + readonly pending: boolean; + /** + * See `writable.destroyed` for further details. + */ + readonly destroyed: boolean; + /** + * The string representation of the local IP address the remote client is + * connecting on. For example, in a server listening on `'0.0.0.0'`, if a client + * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`. + * @since v0.9.6 + */ + readonly localAddress?: string; + /** + * The numeric representation of the local port. For example, `80` or `21`. + * @since v0.9.6 + */ + readonly localPort?: number; + /** + * The string representation of the local IP family. `'IPv4'` or `'IPv6'`. + * @since v18.8.0, v16.18.0 + */ + readonly localFamily?: string; + /** + * This property represents the state of the connection as a string. + * + * * If the stream is connecting `socket.readyState` is `opening`. + * * If the stream is readable and writable, it is `open`. + * * If the stream is readable and not writable, it is `readOnly`. + * * If the stream is not readable and writable, it is `writeOnly`. + * @since v0.5.0 + */ + readonly readyState: SocketReadyState; + /** + * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if + * the socket is destroyed (for example, if the client disconnected). + * @since v0.5.10 + */ + readonly remoteAddress?: string | undefined; + /** + * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if + * the socket is destroyed (for example, if the client disconnected). + * @since v0.11.14 + */ + readonly remoteFamily?: string | undefined; + /** + * The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if + * the socket is destroyed (for example, if the client disconnected). + * @since v0.5.10 + */ + readonly remotePort?: number | undefined; + /** + * The socket timeout in milliseconds as set by `socket.setTimeout()`. + * It is `undefined` if a timeout has not been set. + * @since v10.7.0 + */ + readonly timeout?: number | undefined; + /** + * Half-closes the socket. i.e., it sends a FIN packet. It is possible the + * server will still send some data. + * + * See `writable.end()` for further details. + * @since v0.1.90 + * @param [encoding='utf8'] Only used when data is `string`. + * @param callback Optional callback for when the socket is finished. + * @return The socket itself. + */ + end(callback?: () => void): this; + end(buffer: Uint8Array | string, callback?: () => void): this; + end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this; + /** + * events.EventEmitter + * 1. close + * 2. connect + * 3. data + * 4. drain + * 5. end + * 6. error + * 7. lookup + * 8. ready + * 9. timeout + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: (hadError: boolean) => void): this; + addListener(event: "connect", listener: () => void): this; + addListener(event: "data", listener: (data: Buffer) => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + addListener(event: "ready", listener: () => void): this; + addListener(event: "timeout", listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close", hadError: boolean): boolean; + emit(event: "connect"): boolean; + emit(event: "data", data: Buffer): boolean; + emit(event: "drain"): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; + emit(event: "ready"): boolean; + emit(event: "timeout"): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: (hadError: boolean) => void): this; + on(event: "connect", listener: () => void): this; + on(event: "data", listener: (data: Buffer) => void): this; + on(event: "drain", listener: () => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + on(event: "ready", listener: () => void): this; + on(event: "timeout", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: (hadError: boolean) => void): this; + once(event: "connect", listener: () => void): this; + once(event: "data", listener: (data: Buffer) => void): this; + once(event: "drain", listener: () => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + once(event: "ready", listener: () => void): this; + once(event: "timeout", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: (hadError: boolean) => void): this; + prependListener(event: "connect", listener: () => void): this; + prependListener(event: "data", listener: (data: Buffer) => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + prependListener(event: "ready", listener: () => void): this; + prependListener(event: "timeout", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: (hadError: boolean) => void): this; + prependOnceListener(event: "connect", listener: () => void): this; + prependOnceListener(event: "data", listener: (data: Buffer) => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener( + event: "lookup", + listener: (err: Error, address: string, family: string | number, host: string) => void, + ): this; + prependOnceListener(event: "ready", listener: () => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + } + interface ListenOptions extends Abortable { + port?: number | undefined; + host?: string | undefined; + backlog?: number | undefined; + path?: string | undefined; + exclusive?: boolean | undefined; + readableAll?: boolean | undefined; + writableAll?: boolean | undefined; + /** + * @default false + */ + ipv6Only?: boolean | undefined; + } + interface ServerOpts { + /** + * Indicates whether half-opened TCP connections are allowed. + * @default false + */ + allowHalfOpen?: boolean | undefined; + /** + * Indicates whether the socket should be paused on incoming connections. + * @default false + */ + pauseOnConnect?: boolean | undefined; + /** + * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received. + * @default false + * @since v16.5.0 + */ + noDelay?: boolean | undefined; + /** + * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received, + * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`. + * @default false + * @since v16.5.0 + */ + keepAlive?: boolean | undefined; + /** + * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket. + * @default 0 + * @since v16.5.0 + */ + keepAliveInitialDelay?: number | undefined; + } + interface DropArgument { + localAddress?: string; + localPort?: number; + localFamily?: string; + remoteAddress?: string; + remotePort?: number; + remoteFamily?: string; + } + /** + * This class is used to create a TCP or `IPC` server. + * @since v0.1.90 + */ + class Server extends EventEmitter { + constructor(connectionListener?: (socket: Socket) => void); + constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void); + /** + * Start a server listening for connections. A `net.Server` can be a TCP or + * an `IPC` server depending on what it listens to. + * + * Possible signatures: + * + * * `server.listen(handle[, backlog][, callback])` + * * `server.listen(options[, callback])` + * * `server.listen(path[, backlog][, callback])` for `IPC` servers + * * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers + * + * This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'` + * event. + * + * All `listen()` methods can take a `backlog` parameter to specify the maximum + * length of the queue of pending connections. The actual length will be determined + * by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512). + * + * All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for + * details). + * + * The `server.listen()` method can be called again if and only if there was an + * error during the first `server.listen()` call or `server.close()` has been + * called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown. + * + * One of the most common errors raised when listening is `EADDRINUSE`. + * This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry + * after a certain amount of time: + * + * ```js + * server.on('error', (e) => { + * if (e.code === 'EADDRINUSE') { + * console.error('Address in use, retrying...'); + * setTimeout(() => { + * server.close(); + * server.listen(PORT, HOST); + * }, 1000); + * } + * }); + * ``` + */ + listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this; + listen(port?: number, hostname?: string, listeningListener?: () => void): this; + listen(port?: number, backlog?: number, listeningListener?: () => void): this; + listen(port?: number, listeningListener?: () => void): this; + listen(path: string, backlog?: number, listeningListener?: () => void): this; + listen(path: string, listeningListener?: () => void): this; + listen(options: ListenOptions, listeningListener?: () => void): this; + listen(handle: any, backlog?: number, listeningListener?: () => void): this; + listen(handle: any, listeningListener?: () => void): this; + /** + * Stops the server from accepting new connections and keeps existing + * connections. This function is asynchronous, the server is finally closed + * when all connections are ended and the server emits a `'close'` event. + * The optional `callback` will be called once the `'close'` event occurs. Unlike + * that event, it will be called with an `Error` as its only argument if the server + * was not open when it was closed. + * @since v0.1.90 + * @param callback Called when the server is closed. + */ + close(callback?: (err?: Error) => void): this; + /** + * Returns the bound `address`, the address `family` name, and `port` of the server + * as reported by the operating system if listening on an IP socket + * (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`. + * + * For a server listening on a pipe or Unix domain socket, the name is returned + * as a string. + * + * ```js + * const server = net.createServer((socket) => { + * socket.end('goodbye\n'); + * }).on('error', (err) => { + * // Handle errors here. + * throw err; + * }); + * + * // Grab an arbitrary unused port. + * server.listen(() => { + * console.log('opened server on', server.address()); + * }); + * ``` + * + * `server.address()` returns `null` before the `'listening'` event has been + * emitted or after calling `server.close()`. + * @since v0.1.90 + */ + address(): AddressInfo | string | null; + /** + * Asynchronously get the number of concurrent connections on the server. Works + * when sockets were sent to forks. + * + * Callback should take two arguments `err` and `count`. + * @since v0.9.7 + */ + getConnections(cb: (error: Error | null, count: number) => void): void; + /** + * Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will _not_ let the program exit if it's the only server left (the default behavior). + * If the server is `ref`ed calling `ref()` again will have no effect. + * @since v0.9.1 + */ + ref(): this; + /** + * Calling `unref()` on a server will allow the program to exit if this is the only + * active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect. + * @since v0.9.1 + */ + unref(): this; + /** + * Set this property to reject connections when the server's connection count gets + * high. + * + * It is not recommended to use this option once a socket has been sent to a child + * with `child_process.fork()`. + * @since v0.2.0 + */ + maxConnections: number; + connections: number; + /** + * Indicates whether or not the server is listening for connections. + * @since v5.7.0 + */ + listening: boolean; + /** + * events.EventEmitter + * 1. close + * 2. connection + * 3. error + * 4. listening + * 5. drop + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connection", listener: (socket: Socket) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "drop", listener: (data?: DropArgument) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "connection", socket: Socket): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit(event: "drop", data?: DropArgument): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "connection", listener: (socket: Socket) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "drop", listener: (data?: DropArgument) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "connection", listener: (socket: Socket) => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "drop", listener: (data?: DropArgument) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connection", listener: (socket: Socket) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "drop", listener: (data?: DropArgument) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "drop", listener: (data?: DropArgument) => void): this; + /** + * Calls {@link Server.close()} and returns a promise that fulfills when the server has closed. + * @since v20.5.0 + */ + [Symbol.asyncDispose](): Promise; + } + type IPVersion = "ipv4" | "ipv6"; + /** + * The `BlockList` object can be used with some network APIs to specify rules for + * disabling inbound or outbound access to specific IP addresses, IP ranges, or + * IP subnets. + * @since v15.0.0, v14.18.0 + */ + class BlockList { + /** + * Adds a rule to block the given IP address. + * @since v15.0.0, v14.18.0 + * @param address An IPv4 or IPv6 address. + * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. + */ + addAddress(address: string, type?: IPVersion): void; + addAddress(address: SocketAddress): void; + /** + * Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive). + * @since v15.0.0, v14.18.0 + * @param start The starting IPv4 or IPv6 address in the range. + * @param end The ending IPv4 or IPv6 address in the range. + * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. + */ + addRange(start: string, end: string, type?: IPVersion): void; + addRange(start: SocketAddress, end: SocketAddress): void; + /** + * Adds a rule to block a range of IP addresses specified as a subnet mask. + * @since v15.0.0, v14.18.0 + * @param net The network IPv4 or IPv6 address. + * @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`. + * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. + */ + addSubnet(net: SocketAddress, prefix: number): void; + addSubnet(net: string, prefix: number, type?: IPVersion): void; + /** + * Returns `true` if the given IP address matches any of the rules added to the`BlockList`. + * + * ```js + * const blockList = new net.BlockList(); + * blockList.addAddress('123.123.123.123'); + * blockList.addRange('10.0.0.1', '10.0.0.10'); + * blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6'); + * + * console.log(blockList.check('123.123.123.123')); // Prints: true + * console.log(blockList.check('10.0.0.3')); // Prints: true + * console.log(blockList.check('222.111.111.222')); // Prints: false + * + * // IPv6 notation for IPv4 addresses works: + * console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true + * console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true + * ``` + * @since v15.0.0, v14.18.0 + * @param address The IP address to check + * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`. + */ + check(address: SocketAddress): boolean; + check(address: string, type?: IPVersion): boolean; + } + interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts { + timeout?: number | undefined; + } + interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts { + timeout?: number | undefined; + } + type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts; + /** + * Creates a new TCP or `IPC` server. + * + * If `allowHalfOpen` is set to `true`, when the other end of the socket + * signals the end of transmission, the server will only send back the end of + * transmission when `socket.end()` is explicitly called. For example, in the + * context of TCP, when a FIN packed is received, a FIN packed is sent + * back only when `socket.end()` is explicitly called. Until then the + * connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information. + * + * If `pauseOnConnect` is set to `true`, then the socket associated with each + * incoming connection will be paused, and no data will be read from its handle. + * This allows connections to be passed between processes without any data being + * read by the original process. To begin reading data from a paused socket, call `socket.resume()`. + * + * The server can be a TCP server or an `IPC` server, depending on what it `listen()` to. + * + * Here is an example of a TCP echo server which listens for connections + * on port 8124: + * + * ```js + * const net = require('node:net'); + * const server = net.createServer((c) => { + * // 'connection' listener. + * console.log('client connected'); + * c.on('end', () => { + * console.log('client disconnected'); + * }); + * c.write('hello\r\n'); + * c.pipe(c); + * }); + * server.on('error', (err) => { + * throw err; + * }); + * server.listen(8124, () => { + * console.log('server bound'); + * }); + * ``` + * + * Test this by using `telnet`: + * + * ```bash + * telnet localhost 8124 + * ``` + * + * To listen on the socket `/tmp/echo.sock`: + * + * ```js + * server.listen('/tmp/echo.sock', () => { + * console.log('server bound'); + * }); + * ``` + * + * Use `nc` to connect to a Unix domain socket server: + * + * ```bash + * nc -U /tmp/echo.sock + * ``` + * @since v0.5.0 + * @param connectionListener Automatically set as a listener for the {@link 'connection'} event. + */ + function createServer(connectionListener?: (socket: Socket) => void): Server; + function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server; + /** + * Aliases to {@link createConnection}. + * + * Possible signatures: + * + * * {@link connect} + * * {@link connect} for `IPC` connections. + * * {@link connect} for TCP connections. + */ + function connect(options: NetConnectOpts, connectionListener?: () => void): Socket; + function connect(port: number, host?: string, connectionListener?: () => void): Socket; + function connect(path: string, connectionListener?: () => void): Socket; + /** + * A factory function, which creates a new {@link Socket}, + * immediately initiates connection with `socket.connect()`, + * then returns the `net.Socket` that starts the connection. + * + * When the connection is established, a `'connect'` event will be emitted + * on the returned socket. The last parameter `connectListener`, if supplied, + * will be added as a listener for the `'connect'` event **once**. + * + * Possible signatures: + * + * * {@link createConnection} + * * {@link createConnection} for `IPC` connections. + * * {@link createConnection} for TCP connections. + * + * The {@link connect} function is an alias to this function. + */ + function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket; + function createConnection(port: number, host?: string, connectionListener?: () => void): Socket; + function createConnection(path: string, connectionListener?: () => void): Socket; + /** + * Gets the current default value of the `autoSelectFamily` option of `socket.connect(options)`. + * The initial default value is `true`, unless the command line option`--no-network-family-autoselection` is provided. + * @since v19.4.0 + */ + function getDefaultAutoSelectFamily(): boolean; + /** + * Sets the default value of the `autoSelectFamily` option of `socket.connect(options)`. + * @since v19.4.0 + */ + function setDefaultAutoSelectFamily(value: boolean): void; + /** + * Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`. + * The initial default value is `250`. + * @since v19.8.0 + */ + function getDefaultAutoSelectFamilyAttemptTimeout(): number; + /** + * Sets the default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`. + * @since v19.8.0 + */ + function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void; + /** + * Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4 + * address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`. + * + * ```js + * net.isIP('::1'); // returns 6 + * net.isIP('127.0.0.1'); // returns 4 + * net.isIP('127.000.000.001'); // returns 0 + * net.isIP('127.0.0.1/24'); // returns 0 + * net.isIP('fhqwhgads'); // returns 0 + * ``` + * @since v0.3.0 + */ + function isIP(input: string): number; + /** + * Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no + * leading zeroes. Otherwise, returns `false`. + * + * ```js + * net.isIPv4('127.0.0.1'); // returns true + * net.isIPv4('127.000.000.001'); // returns false + * net.isIPv4('127.0.0.1/24'); // returns false + * net.isIPv4('fhqwhgads'); // returns false + * ``` + * @since v0.3.0 + */ + function isIPv4(input: string): boolean; + /** + * Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`. + * + * ```js + * net.isIPv6('::1'); // returns true + * net.isIPv6('fhqwhgads'); // returns false + * ``` + * @since v0.3.0 + */ + function isIPv6(input: string): boolean; + interface SocketAddressInitOptions { + /** + * The network address as either an IPv4 or IPv6 string. + * @default 127.0.0.1 + */ + address?: string | undefined; + /** + * @default `'ipv4'` + */ + family?: IPVersion | undefined; + /** + * An IPv6 flow-label used only if `family` is `'ipv6'`. + * @default 0 + */ + flowlabel?: number | undefined; + /** + * An IP port. + * @default 0 + */ + port?: number | undefined; + } + /** + * @since v15.14.0, v14.18.0 + */ + class SocketAddress { + constructor(options: SocketAddressInitOptions); + /** + * Either \`'ipv4'\` or \`'ipv6'\`. + * @since v15.14.0, v14.18.0 + */ + readonly address: string; + /** + * Either \`'ipv4'\` or \`'ipv6'\`. + * @since v15.14.0, v14.18.0 + */ + readonly family: IPVersion; + /** + * @since v15.14.0, v14.18.0 + */ + readonly port: number; + /** + * @since v15.14.0, v14.18.0 + */ + readonly flowlabel: number; + } +} +declare module "node:net" { + export * from "net"; +} diff --git a/node_modules/@types/node/ts4.8/os.d.ts b/node_modules/@types/node/ts4.8/os.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39a33f7fd5b960970c3eb3946ceea8766eb1989d --- /dev/null +++ b/node_modules/@types/node/ts4.8/os.d.ts @@ -0,0 +1,478 @@ +/** + * The `node:os` module provides operating system-related utility methods and + * properties. It can be accessed using: + * + * ```js + * const os = require('node:os'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/os.js) + */ +declare module "os" { + interface CpuInfo { + model: string; + speed: number; + times: { + user: number; + nice: number; + sys: number; + idle: number; + irq: number; + }; + } + interface NetworkInterfaceBase { + address: string; + netmask: string; + mac: string; + internal: boolean; + cidr: string | null; + } + interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase { + family: "IPv4"; + scopeid?: undefined; + } + interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase { + family: "IPv6"; + scopeid: number; + } + interface UserInfo { + username: T; + uid: number; + gid: number; + shell: T | null; + homedir: T; + } + type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6; + /** + * Returns the host name of the operating system as a string. + * @since v0.3.3 + */ + function hostname(): string; + /** + * Returns an array containing the 1, 5, and 15 minute load averages. + * + * The load average is a measure of system activity calculated by the operating + * system and expressed as a fractional number. + * + * The load average is a Unix-specific concept. On Windows, the return value is + * always `[0, 0, 0]`. + * @since v0.3.3 + */ + function loadavg(): number[]; + /** + * Returns the system uptime in number of seconds. + * @since v0.3.3 + */ + function uptime(): number; + /** + * Returns the amount of free system memory in bytes as an integer. + * @since v0.3.3 + */ + function freemem(): number; + /** + * Returns the total amount of system memory in bytes as an integer. + * @since v0.3.3 + */ + function totalmem(): number; + /** + * Returns an array of objects containing information about each logical CPU core. + * The array will be empty if no CPU information is available, such as if the`/proc` file system is unavailable. + * + * The properties included on each object include: + * + * ```js + * [ + * { + * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', + * speed: 2926, + * times: { + * user: 252020, + * nice: 0, + * sys: 30340, + * idle: 1070356870, + * irq: 0, + * }, + * }, + * { + * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', + * speed: 2926, + * times: { + * user: 306960, + * nice: 0, + * sys: 26980, + * idle: 1071569080, + * irq: 0, + * }, + * }, + * { + * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', + * speed: 2926, + * times: { + * user: 248450, + * nice: 0, + * sys: 21750, + * idle: 1070919370, + * irq: 0, + * }, + * }, + * { + * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz', + * speed: 2926, + * times: { + * user: 256880, + * nice: 0, + * sys: 19430, + * idle: 1070905480, + * irq: 20, + * }, + * }, + * ] + * ``` + * + * `nice` values are POSIX-only. On Windows, the `nice` values of all processors + * are always 0. + * + * `os.cpus().length` should not be used to calculate the amount of parallelism + * available to an application. Use {@link availableParallelism} for this purpose. + * @since v0.3.3 + */ + function cpus(): CpuInfo[]; + /** + * Returns an estimate of the default amount of parallelism a program should use. + * Always returns a value greater than zero. + * + * This function is a small wrapper about libuv's [`uv_available_parallelism()`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_available_parallelism). + * @since v19.4.0, v18.14.0 + */ + function availableParallelism(): number; + /** + * Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it + * returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows. + * + * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information + * about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems. + * @since v0.3.3 + */ + function type(): string; + /** + * Returns the operating system as a string. + * + * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `GetVersionExW()` is used. See + * [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. + * @since v0.3.3 + */ + function release(): string; + /** + * Returns an object containing network interfaces that have been assigned a + * network address. + * + * Each key on the returned object identifies a network interface. The associated + * value is an array of objects that each describe an assigned network address. + * + * The properties available on the assigned network address object include: + * + * ```js + * { + * lo: [ + * { + * address: '127.0.0.1', + * netmask: '255.0.0.0', + * family: 'IPv4', + * mac: '00:00:00:00:00:00', + * internal: true, + * cidr: '127.0.0.1/8' + * }, + * { + * address: '::1', + * netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', + * family: 'IPv6', + * mac: '00:00:00:00:00:00', + * scopeid: 0, + * internal: true, + * cidr: '::1/128' + * } + * ], + * eth0: [ + * { + * address: '192.168.1.108', + * netmask: '255.255.255.0', + * family: 'IPv4', + * mac: '01:02:03:0a:0b:0c', + * internal: false, + * cidr: '192.168.1.108/24' + * }, + * { + * address: 'fe80::a00:27ff:fe4e:66a1', + * netmask: 'ffff:ffff:ffff:ffff::', + * family: 'IPv6', + * mac: '01:02:03:0a:0b:0c', + * scopeid: 1, + * internal: false, + * cidr: 'fe80::a00:27ff:fe4e:66a1/64' + * } + * ] + * } + * ``` + * @since v0.6.0 + */ + function networkInterfaces(): NodeJS.Dict; + /** + * Returns the string path of the current user's home directory. + * + * On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it + * uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory. + * + * On Windows, it uses the `USERPROFILE` environment variable if defined. + * Otherwise it uses the path to the profile directory of the current user. + * @since v2.3.0 + */ + function homedir(): string; + /** + * Returns information about the currently effective user. On POSIX platforms, + * this is typically a subset of the password file. The returned object includes + * the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and`gid` fields are `-1`, and `shell` is `null`. + * + * The value of `homedir` returned by `os.userInfo()` is provided by the operating + * system. This differs from the result of `os.homedir()`, which queries + * environment variables for the home directory before falling back to the + * operating system response. + * + * Throws a `SystemError` if a user has no `username` or `homedir`. + * @since v6.0.0 + */ + function userInfo(options: { encoding: "buffer" }): UserInfo; + function userInfo(options?: { encoding: BufferEncoding }): UserInfo; + type SignalConstants = { + [key in NodeJS.Signals]: number; + }; + namespace constants { + const UV_UDP_REUSEADDR: number; + namespace signals {} + const signals: SignalConstants; + namespace errno { + const E2BIG: number; + const EACCES: number; + const EADDRINUSE: number; + const EADDRNOTAVAIL: number; + const EAFNOSUPPORT: number; + const EAGAIN: number; + const EALREADY: number; + const EBADF: number; + const EBADMSG: number; + const EBUSY: number; + const ECANCELED: number; + const ECHILD: number; + const ECONNABORTED: number; + const ECONNREFUSED: number; + const ECONNRESET: number; + const EDEADLK: number; + const EDESTADDRREQ: number; + const EDOM: number; + const EDQUOT: number; + const EEXIST: number; + const EFAULT: number; + const EFBIG: number; + const EHOSTUNREACH: number; + const EIDRM: number; + const EILSEQ: number; + const EINPROGRESS: number; + const EINTR: number; + const EINVAL: number; + const EIO: number; + const EISCONN: number; + const EISDIR: number; + const ELOOP: number; + const EMFILE: number; + const EMLINK: number; + const EMSGSIZE: number; + const EMULTIHOP: number; + const ENAMETOOLONG: number; + const ENETDOWN: number; + const ENETRESET: number; + const ENETUNREACH: number; + const ENFILE: number; + const ENOBUFS: number; + const ENODATA: number; + const ENODEV: number; + const ENOENT: number; + const ENOEXEC: number; + const ENOLCK: number; + const ENOLINK: number; + const ENOMEM: number; + const ENOMSG: number; + const ENOPROTOOPT: number; + const ENOSPC: number; + const ENOSR: number; + const ENOSTR: number; + const ENOSYS: number; + const ENOTCONN: number; + const ENOTDIR: number; + const ENOTEMPTY: number; + const ENOTSOCK: number; + const ENOTSUP: number; + const ENOTTY: number; + const ENXIO: number; + const EOPNOTSUPP: number; + const EOVERFLOW: number; + const EPERM: number; + const EPIPE: number; + const EPROTO: number; + const EPROTONOSUPPORT: number; + const EPROTOTYPE: number; + const ERANGE: number; + const EROFS: number; + const ESPIPE: number; + const ESRCH: number; + const ESTALE: number; + const ETIME: number; + const ETIMEDOUT: number; + const ETXTBSY: number; + const EWOULDBLOCK: number; + const EXDEV: number; + const WSAEINTR: number; + const WSAEBADF: number; + const WSAEACCES: number; + const WSAEFAULT: number; + const WSAEINVAL: number; + const WSAEMFILE: number; + const WSAEWOULDBLOCK: number; + const WSAEINPROGRESS: number; + const WSAEALREADY: number; + const WSAENOTSOCK: number; + const WSAEDESTADDRREQ: number; + const WSAEMSGSIZE: number; + const WSAEPROTOTYPE: number; + const WSAENOPROTOOPT: number; + const WSAEPROTONOSUPPORT: number; + const WSAESOCKTNOSUPPORT: number; + const WSAEOPNOTSUPP: number; + const WSAEPFNOSUPPORT: number; + const WSAEAFNOSUPPORT: number; + const WSAEADDRINUSE: number; + const WSAEADDRNOTAVAIL: number; + const WSAENETDOWN: number; + const WSAENETUNREACH: number; + const WSAENETRESET: number; + const WSAECONNABORTED: number; + const WSAECONNRESET: number; + const WSAENOBUFS: number; + const WSAEISCONN: number; + const WSAENOTCONN: number; + const WSAESHUTDOWN: number; + const WSAETOOMANYREFS: number; + const WSAETIMEDOUT: number; + const WSAECONNREFUSED: number; + const WSAELOOP: number; + const WSAENAMETOOLONG: number; + const WSAEHOSTDOWN: number; + const WSAEHOSTUNREACH: number; + const WSAENOTEMPTY: number; + const WSAEPROCLIM: number; + const WSAEUSERS: number; + const WSAEDQUOT: number; + const WSAESTALE: number; + const WSAEREMOTE: number; + const WSASYSNOTREADY: number; + const WSAVERNOTSUPPORTED: number; + const WSANOTINITIALISED: number; + const WSAEDISCON: number; + const WSAENOMORE: number; + const WSAECANCELLED: number; + const WSAEINVALIDPROCTABLE: number; + const WSAEINVALIDPROVIDER: number; + const WSAEPROVIDERFAILEDINIT: number; + const WSASYSCALLFAILURE: number; + const WSASERVICE_NOT_FOUND: number; + const WSATYPE_NOT_FOUND: number; + const WSA_E_NO_MORE: number; + const WSA_E_CANCELLED: number; + const WSAEREFUSED: number; + } + namespace priority { + const PRIORITY_LOW: number; + const PRIORITY_BELOW_NORMAL: number; + const PRIORITY_NORMAL: number; + const PRIORITY_ABOVE_NORMAL: number; + const PRIORITY_HIGH: number; + const PRIORITY_HIGHEST: number; + } + } + const devNull: string; + const EOL: string; + /** + * Returns the operating system CPU architecture for which the Node.js binary was + * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`,`'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, + * and `'x64'`. + * + * The return value is equivalent to `process.arch`. + * @since v0.5.0 + */ + function arch(): string; + /** + * Returns a string identifying the kernel version. + * + * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not + * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. + * @since v13.11.0, v12.17.0 + */ + function version(): string; + /** + * Returns a string identifying the operating system platform for which + * the Node.js binary was compiled. The value is set at compile time. + * Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`,`'openbsd'`, `'sunos'`, and `'win32'`. + * + * The return value is equivalent to `process.platform`. + * + * The value `'android'` may also be returned if Node.js is built on the Android + * operating system. [Android support is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os). + * @since v0.5.0 + */ + function platform(): NodeJS.Platform; + /** + * Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`,`mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`. + * + * On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not + * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information. + * @since v18.9.0, v16.18.0 + */ + function machine(): string; + /** + * Returns the operating system's default directory for temporary files as a + * string. + * @since v0.9.9 + */ + function tmpdir(): string; + /** + * Returns a string identifying the endianness of the CPU for which the Node.js + * binary was compiled. + * + * Possible values are `'BE'` for big endian and `'LE'` for little endian. + * @since v0.9.4 + */ + function endianness(): "BE" | "LE"; + /** + * Returns the scheduling priority for the process specified by `pid`. If `pid` is + * not provided or is `0`, the priority of the current process is returned. + * @since v10.10.0 + * @param [pid=0] The process ID to retrieve scheduling priority for. + */ + function getPriority(pid?: number): number; + /** + * Attempts to set the scheduling priority for the process specified by `pid`. If`pid` is not provided or is `0`, the process ID of the current process is used. + * + * The `priority` input must be an integer between `-20` (high priority) and `19`(low priority). Due to differences between Unix priority levels and Windows + * priority classes, `priority` is mapped to one of six priority constants in`os.constants.priority`. When retrieving a process priority level, this range + * mapping may cause the return value to be slightly different on Windows. To avoid + * confusion, set `priority` to one of the priority constants. + * + * On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user + * privileges. Otherwise the set priority will be silently reduced to`PRIORITY_HIGH`. + * @since v10.10.0 + * @param [pid=0] The process ID to set scheduling priority for. + * @param priority The scheduling priority to assign to the process. + */ + function setPriority(priority: number): void; + function setPriority(pid: number, priority: number): void; +} +declare module "node:os" { + export * from "os"; +} diff --git a/node_modules/@types/node/ts4.8/path.d.ts b/node_modules/@types/node/ts4.8/path.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f07681ac6460e05a2b23515d13d45e1a0714b6c --- /dev/null +++ b/node_modules/@types/node/ts4.8/path.d.ts @@ -0,0 +1,191 @@ +declare module "path/posix" { + import path = require("path"); + export = path; +} +declare module "path/win32" { + import path = require("path"); + export = path; +} +/** + * The `node:path` module provides utilities for working with file and directory + * paths. It can be accessed using: + * + * ```js + * const path = require('node:path'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/path.js) + */ +declare module "path" { + namespace path { + /** + * A parsed path object generated by path.parse() or consumed by path.format(). + */ + interface ParsedPath { + /** + * The root of the path such as '/' or 'c:\' + */ + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; + } + interface FormatInputPathObject { + /** + * The root of the path such as '/' or 'c:\' + */ + root?: string | undefined; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir?: string | undefined; + /** + * The file name including extension (if any) such as 'index.html' + */ + base?: string | undefined; + /** + * The file extension (if any) such as '.html' + */ + ext?: string | undefined; + /** + * The file name without extension (if any) such as 'index' + */ + name?: string | undefined; + } + interface PlatformPath { + /** + * Normalize a string path, reducing '..' and '.' parts. + * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. + * + * @param path string path to normalize. + * @throws {TypeError} if `path` is not a string. + */ + normalize(path: string): string; + /** + * Join all arguments together and normalize the resulting path. + * + * @param paths paths to join. + * @throws {TypeError} if any of the path segments is not a string. + */ + join(...paths: string[]): string; + /** + * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. + * + * Starting from leftmost {from} parameter, resolves {to} to an absolute path. + * + * If {to} isn't already absolute, {from} arguments are prepended in right to left order, + * until an absolute path is found. If after using all {from} paths still no absolute path is found, + * the current working directory is used as well. The resulting path is normalized, + * and trailing slashes are removed unless the path gets resolved to the root directory. + * + * @param paths A sequence of paths or path segments. + * @throws {TypeError} if any of the arguments is not a string. + */ + resolve(...paths: string[]): string; + /** + * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. + * + * If the given {path} is a zero-length string, `false` will be returned. + * + * @param path path to test. + * @throws {TypeError} if `path` is not a string. + */ + isAbsolute(path: string): boolean; + /** + * Solve the relative path from {from} to {to} based on the current working directory. + * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. + * + * @throws {TypeError} if either `from` or `to` is not a string. + */ + relative(from: string, to: string): string; + /** + * Return the directory name of a path. Similar to the Unix dirname command. + * + * @param path the path to evaluate. + * @throws {TypeError} if `path` is not a string. + */ + dirname(path: string): string; + /** + * Return the last portion of a path. Similar to the Unix basename command. + * Often used to extract the file name from a fully qualified path. + * + * @param path the path to evaluate. + * @param suffix optionally, an extension to remove from the result. + * @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string. + */ + basename(path: string, suffix?: string): string; + /** + * Return the extension of the path, from the last '.' to end of string in the last portion of the path. + * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string. + * + * @param path the path to evaluate. + * @throws {TypeError} if `path` is not a string. + */ + extname(path: string): string; + /** + * The platform-specific file separator. '\\' or '/'. + */ + readonly sep: "\\" | "/"; + /** + * The platform-specific file delimiter. ';' or ':'. + */ + readonly delimiter: ";" | ":"; + /** + * Returns an object from a path string - the opposite of format(). + * + * @param path path to evaluate. + * @throws {TypeError} if `path` is not a string. + */ + parse(path: string): ParsedPath; + /** + * Returns a path string from an object - the opposite of parse(). + * + * @param pathObject path to evaluate. + */ + format(pathObject: FormatInputPathObject): string; + /** + * On Windows systems only, returns an equivalent namespace-prefixed path for the given path. + * If path is not a string, path will be returned without modifications. + * This method is meaningful only on Windows system. + * On POSIX systems, the method is non-operational and always returns path without modifications. + */ + toNamespacedPath(path: string): string; + /** + * Posix specific pathing. + * Same as parent object on posix. + */ + readonly posix: PlatformPath; + /** + * Windows specific pathing. + * Same as parent object on windows + */ + readonly win32: PlatformPath; + } + } + const path: path.PlatformPath; + export = path; +} +declare module "node:path" { + import path = require("path"); + export = path; +} +declare module "node:path/posix" { + import path = require("path/posix"); + export = path; +} +declare module "node:path/win32" { + import path = require("path/win32"); + export = path; +} diff --git a/node_modules/@types/node/ts4.8/perf_hooks.d.ts b/node_modules/@types/node/ts4.8/perf_hooks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e16e5818194558a22f8b269cd581fd566a80cfd --- /dev/null +++ b/node_modules/@types/node/ts4.8/perf_hooks.d.ts @@ -0,0 +1,639 @@ +/** + * This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for + * Node.js-specific performance measurements. + * + * Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/): + * + * * [High Resolution Time](https://www.w3.org/TR/hr-time-2) + * * [Performance Timeline](https://w3c.github.io/performance-timeline/) + * * [User Timing](https://www.w3.org/TR/user-timing/) + * * [Resource Timing](https://www.w3.org/TR/resource-timing-2/) + * + * ```js + * const { PerformanceObserver, performance } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((items) => { + * console.log(items.getEntries()[0].duration); + * performance.clearMarks(); + * }); + * obs.observe({ type: 'measure' }); + * performance.measure('Start to Now'); + * + * performance.mark('A'); + * doSomeLongRunningProcess(() => { + * performance.measure('A to Now', 'A'); + * + * performance.mark('B'); + * performance.measure('A to B', 'A', 'B'); + * }); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/perf_hooks.js) + */ +declare module "perf_hooks" { + import { AsyncResource } from "node:async_hooks"; + type EntryType = "node" | "mark" | "measure" | "gc" | "function" | "http2" | "http"; + interface NodeGCPerformanceDetail { + /** + * When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies + * the type of garbage collection operation that occurred. + * See perf_hooks.constants for valid values. + */ + readonly kind?: number | undefined; + /** + * When `performanceEntry.entryType` is equal to 'gc', the `performance.flags` + * property contains additional information about garbage collection operation. + * See perf_hooks.constants for valid values. + */ + readonly flags?: number | undefined; + } + /** + * The constructor of this class is not exposed to users directly. + * @since v8.5.0 + */ + class PerformanceEntry { + protected constructor(); + /** + * The total number of milliseconds elapsed for this entry. This value will not + * be meaningful for all Performance Entry types. + * @since v8.5.0 + */ + readonly duration: number; + /** + * The name of the performance entry. + * @since v8.5.0 + */ + readonly name: string; + /** + * The high resolution millisecond timestamp marking the starting time of the + * Performance Entry. + * @since v8.5.0 + */ + readonly startTime: number; + /** + * The type of the performance entry. It may be one of: + * + * * `'node'` (Node.js only) + * * `'mark'` (available on the Web) + * * `'measure'` (available on the Web) + * * `'gc'` (Node.js only) + * * `'function'` (Node.js only) + * * `'http2'` (Node.js only) + * * `'http'` (Node.js only) + * @since v8.5.0 + */ + readonly entryType: EntryType; + /** + * Additional detail specific to the `entryType`. + * @since v16.0.0 + */ + readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type. + toJSON(): any; + } + /** + * Exposes marks created via the `Performance.mark()` method. + * @since v18.2.0, v16.17.0 + */ + class PerformanceMark extends PerformanceEntry { + readonly duration: 0; + readonly entryType: "mark"; + } + /** + * Exposes measures created via the `Performance.measure()` method. + * + * The constructor of this class is not exposed to users directly. + * @since v18.2.0, v16.17.0 + */ + class PerformanceMeasure extends PerformanceEntry { + readonly entryType: "measure"; + } + /** + * _This property is an extension by Node.js. It is not available in Web browsers._ + * + * Provides timing details for Node.js itself. The constructor of this class + * is not exposed to users. + * @since v8.5.0 + */ + class PerformanceNodeTiming extends PerformanceEntry { + /** + * The high resolution millisecond timestamp at which the Node.js process + * completed bootstrapping. If bootstrapping has not yet finished, the property + * has the value of -1. + * @since v8.5.0 + */ + readonly bootstrapComplete: number; + /** + * The high resolution millisecond timestamp at which the Node.js environment was + * initialized. + * @since v8.5.0 + */ + readonly environment: number; + /** + * The high resolution millisecond timestamp of the amount of time the event loop + * has been idle within the event loop's event provider (e.g. `epoll_wait`). This + * does not take CPU usage into consideration. If the event loop has not yet + * started (e.g., in the first tick of the main script), the property has the + * value of 0. + * @since v14.10.0, v12.19.0 + */ + readonly idleTime: number; + /** + * The high resolution millisecond timestamp at which the Node.js event loop + * exited. If the event loop has not yet exited, the property has the value of -1\. + * It can only have a value of not -1 in a handler of the `'exit'` event. + * @since v8.5.0 + */ + readonly loopExit: number; + /** + * The high resolution millisecond timestamp at which the Node.js event loop + * started. If the event loop has not yet started (e.g., in the first tick of the + * main script), the property has the value of -1. + * @since v8.5.0 + */ + readonly loopStart: number; + /** + * The high resolution millisecond timestamp at which the V8 platform was + * initialized. + * @since v8.5.0 + */ + readonly v8Start: number; + } + interface EventLoopUtilization { + idle: number; + active: number; + utilization: number; + } + /** + * @param util1 The result of a previous call to eventLoopUtilization() + * @param util2 The result of a previous call to eventLoopUtilization() prior to util1 + */ + type EventLoopUtilityFunction = ( + util1?: EventLoopUtilization, + util2?: EventLoopUtilization, + ) => EventLoopUtilization; + interface MarkOptions { + /** + * Additional optional detail to include with the mark. + */ + detail?: unknown | undefined; + /** + * An optional timestamp to be used as the mark time. + * @default `performance.now()`. + */ + startTime?: number | undefined; + } + interface MeasureOptions { + /** + * Additional optional detail to include with the mark. + */ + detail?: unknown | undefined; + /** + * Duration between start and end times. + */ + duration?: number | undefined; + /** + * Timestamp to be used as the end time, or a string identifying a previously recorded mark. + */ + end?: number | string | undefined; + /** + * Timestamp to be used as the start time, or a string identifying a previously recorded mark. + */ + start?: number | string | undefined; + } + interface TimerifyOptions { + /** + * A histogram object created using + * `perf_hooks.createHistogram()` that will record runtime durations in + * nanoseconds. + */ + histogram?: RecordableHistogram | undefined; + } + interface Performance { + /** + * If name is not provided, removes all PerformanceMark objects from the Performance Timeline. + * If name is provided, removes only the named mark. + * @param name + */ + clearMarks(name?: string): void; + /** + * If name is not provided, removes all PerformanceMeasure objects from the Performance Timeline. + * If name is provided, removes only the named measure. + * @param name + * @since v16.7.0 + */ + clearMeasures(name?: string): void; + /** + * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`. + * If you are only interested in performance entries of certain types or that have certain names, see + * `performance.getEntriesByType()` and `performance.getEntriesByName()`. + * @since v16.7.0 + */ + getEntries(): PerformanceEntry[]; + /** + * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime` + * whose `performanceEntry.name` is equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to `type`. + * @param name + * @param type + * @since v16.7.0 + */ + getEntriesByName(name: string, type?: EntryType): PerformanceEntry[]; + /** + * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime` + * whose `performanceEntry.entryType` is equal to `type`. + * @param type + * @since v16.7.0 + */ + getEntriesByType(type: EntryType): PerformanceEntry[]; + /** + * Creates a new PerformanceMark entry in the Performance Timeline. + * A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark', + * and whose performanceEntry.duration is always 0. + * Performance marks are used to mark specific significant moments in the Performance Timeline. + * @param name + * @return The PerformanceMark entry that was created + */ + mark(name?: string, options?: MarkOptions): PerformanceMark; + /** + * Creates a new PerformanceMeasure entry in the Performance Timeline. + * A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure', + * and whose performanceEntry.duration measures the number of milliseconds elapsed since startMark and endMark. + * + * The startMark argument may identify any existing PerformanceMark in the the Performance Timeline, or may identify + * any of the timestamp properties provided by the PerformanceNodeTiming class. If the named startMark does not exist, + * then startMark is set to timeOrigin by default. + * + * The endMark argument must identify any existing PerformanceMark in the the Performance Timeline or any of the timestamp + * properties provided by the PerformanceNodeTiming class. If the named endMark does not exist, an error will be thrown. + * @param name + * @param startMark + * @param endMark + * @return The PerformanceMeasure entry that was created + */ + measure(name: string, startMark?: string, endMark?: string): PerformanceMeasure; + measure(name: string, options: MeasureOptions): PerformanceMeasure; + /** + * An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones. + */ + readonly nodeTiming: PerformanceNodeTiming; + /** + * @return the current high resolution millisecond timestamp + */ + now(): number; + /** + * The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured. + */ + readonly timeOrigin: number; + /** + * Wraps a function within a new function that measures the running time of the wrapped function. + * A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed. + * @param fn + */ + timerify any>(fn: T, options?: TimerifyOptions): T; + /** + * eventLoopUtilization is similar to CPU utilization except that it is calculated using high precision wall-clock time. + * It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait). + * No other CPU idle time is taken into consideration. + */ + eventLoopUtilization: EventLoopUtilityFunction; + } + interface PerformanceObserverEntryList { + /** + * Returns a list of `PerformanceEntry` objects in chronological order + * with respect to `performanceEntry.startTime`. + * + * ```js + * const { + * performance, + * PerformanceObserver, + * } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((perfObserverList, observer) => { + * console.log(perfObserverList.getEntries()); + * + * * [ + * * PerformanceEntry { + * * name: 'test', + * * entryType: 'mark', + * * startTime: 81.465639, + * * duration: 0 + * * }, + * * PerformanceEntry { + * * name: 'meow', + * * entryType: 'mark', + * * startTime: 81.860064, + * * duration: 0 + * * } + * * ] + * + * performance.clearMarks(); + * performance.clearMeasures(); + * observer.disconnect(); + * }); + * obs.observe({ type: 'mark' }); + * + * performance.mark('test'); + * performance.mark('meow'); + * ``` + * @since v8.5.0 + */ + getEntries(): PerformanceEntry[]; + /** + * Returns a list of `PerformanceEntry` objects in chronological order + * with respect to `performanceEntry.startTime` whose `performanceEntry.name` is + * equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`. + * + * ```js + * const { + * performance, + * PerformanceObserver, + * } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((perfObserverList, observer) => { + * console.log(perfObserverList.getEntriesByName('meow')); + * + * * [ + * * PerformanceEntry { + * * name: 'meow', + * * entryType: 'mark', + * * startTime: 98.545991, + * * duration: 0 + * * } + * * ] + * + * console.log(perfObserverList.getEntriesByName('nope')); // [] + * + * console.log(perfObserverList.getEntriesByName('test', 'mark')); + * + * * [ + * * PerformanceEntry { + * * name: 'test', + * * entryType: 'mark', + * * startTime: 63.518931, + * * duration: 0 + * * } + * * ] + * + * console.log(perfObserverList.getEntriesByName('test', 'measure')); // [] + * + * performance.clearMarks(); + * performance.clearMeasures(); + * observer.disconnect(); + * }); + * obs.observe({ entryTypes: ['mark', 'measure'] }); + * + * performance.mark('test'); + * performance.mark('meow'); + * ``` + * @since v8.5.0 + */ + getEntriesByName(name: string, type?: EntryType): PerformanceEntry[]; + /** + * Returns a list of `PerformanceEntry` objects in chronological order + * with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`is equal to `type`. + * + * ```js + * const { + * performance, + * PerformanceObserver, + * } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((perfObserverList, observer) => { + * console.log(perfObserverList.getEntriesByType('mark')); + * + * * [ + * * PerformanceEntry { + * * name: 'test', + * * entryType: 'mark', + * * startTime: 55.897834, + * * duration: 0 + * * }, + * * PerformanceEntry { + * * name: 'meow', + * * entryType: 'mark', + * * startTime: 56.350146, + * * duration: 0 + * * } + * * ] + * + * performance.clearMarks(); + * performance.clearMeasures(); + * observer.disconnect(); + * }); + * obs.observe({ type: 'mark' }); + * + * performance.mark('test'); + * performance.mark('meow'); + * ``` + * @since v8.5.0 + */ + getEntriesByType(type: EntryType): PerformanceEntry[]; + } + type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void; + /** + * @since v8.5.0 + */ + class PerformanceObserver extends AsyncResource { + constructor(callback: PerformanceObserverCallback); + /** + * Disconnects the `PerformanceObserver` instance from all notifications. + * @since v8.5.0 + */ + disconnect(): void; + /** + * Subscribes the `PerformanceObserver` instance to notifications of new `PerformanceEntry` instances identified either by `options.entryTypes`or `options.type`: + * + * ```js + * const { + * performance, + * PerformanceObserver, + * } = require('node:perf_hooks'); + * + * const obs = new PerformanceObserver((list, observer) => { + * // Called once asynchronously. `list` contains three items. + * }); + * obs.observe({ type: 'mark' }); + * + * for (let n = 0; n < 3; n++) + * performance.mark(`test${n}`); + * ``` + * @since v8.5.0 + */ + observe( + options: + | { + entryTypes: readonly EntryType[]; + buffered?: boolean | undefined; + } + | { + type: EntryType; + buffered?: boolean | undefined; + }, + ): void; + } + namespace constants { + const NODE_PERFORMANCE_GC_MAJOR: number; + const NODE_PERFORMANCE_GC_MINOR: number; + const NODE_PERFORMANCE_GC_INCREMENTAL: number; + const NODE_PERFORMANCE_GC_WEAKCB: number; + const NODE_PERFORMANCE_GC_FLAGS_NO: number; + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; + } + const performance: Performance; + interface EventLoopMonitorOptions { + /** + * The sampling rate in milliseconds. + * Must be greater than zero. + * @default 10 + */ + resolution?: number | undefined; + } + interface Histogram { + /** + * Returns a `Map` object detailing the accumulated percentile distribution. + * @since v11.10.0 + */ + readonly percentiles: Map; + /** + * The number of times the event loop delay exceeded the maximum 1 hour event + * loop delay threshold. + * @since v11.10.0 + */ + readonly exceeds: number; + /** + * The minimum recorded event loop delay. + * @since v11.10.0 + */ + readonly min: number; + /** + * The maximum recorded event loop delay. + * @since v11.10.0 + */ + readonly max: number; + /** + * The mean of the recorded event loop delays. + * @since v11.10.0 + */ + readonly mean: number; + /** + * The standard deviation of the recorded event loop delays. + * @since v11.10.0 + */ + readonly stddev: number; + /** + * Resets the collected histogram data. + * @since v11.10.0 + */ + reset(): void; + /** + * Returns the value at the given percentile. + * @since v11.10.0 + * @param percentile A percentile value in the range (0, 100]. + */ + percentile(percentile: number): number; + } + interface IntervalHistogram extends Histogram { + /** + * Enables the update interval timer. Returns `true` if the timer was + * started, `false` if it was already started. + * @since v11.10.0 + */ + enable(): boolean; + /** + * Disables the update interval timer. Returns `true` if the timer was + * stopped, `false` if it was already stopped. + * @since v11.10.0 + */ + disable(): boolean; + } + interface RecordableHistogram extends Histogram { + /** + * @since v15.9.0, v14.18.0 + * @param val The amount to record in the histogram. + */ + record(val: number | bigint): void; + /** + * Calculates the amount of time (in nanoseconds) that has passed since the + * previous call to `recordDelta()` and records that amount in the histogram. + * + * ## Examples + * @since v15.9.0, v14.18.0 + */ + recordDelta(): void; + /** + * Adds the values from `other` to this histogram. + * @since v17.4.0, v16.14.0 + */ + add(other: RecordableHistogram): void; + } + /** + * _This property is an extension by Node.js. It is not available in Web browsers._ + * + * Creates an `IntervalHistogram` object that samples and reports the event loop + * delay over time. The delays will be reported in nanoseconds. + * + * Using a timer to detect approximate event loop delay works because the + * execution of timers is tied specifically to the lifecycle of the libuv + * event loop. That is, a delay in the loop will cause a delay in the execution + * of the timer, and those delays are specifically what this API is intended to + * detect. + * + * ```js + * const { monitorEventLoopDelay } = require('node:perf_hooks'); + * const h = monitorEventLoopDelay({ resolution: 20 }); + * h.enable(); + * // Do something. + * h.disable(); + * console.log(h.min); + * console.log(h.max); + * console.log(h.mean); + * console.log(h.stddev); + * console.log(h.percentiles); + * console.log(h.percentile(50)); + * console.log(h.percentile(99)); + * ``` + * @since v11.10.0 + */ + function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram; + interface CreateHistogramOptions { + /** + * The minimum recordable value. Must be an integer value greater than 0. + * @default 1 + */ + min?: number | bigint | undefined; + /** + * The maximum recordable value. Must be an integer value greater than min. + * @default Number.MAX_SAFE_INTEGER + */ + max?: number | bigint | undefined; + /** + * The number of accuracy digits. Must be a number between 1 and 5. + * @default 3 + */ + figures?: number | undefined; + } + /** + * Returns a `RecordableHistogram`. + * @since v15.9.0, v14.18.0 + */ + function createHistogram(options?: CreateHistogramOptions): RecordableHistogram; + import { performance as _performance } from "perf_hooks"; + global { + /** + * `performance` is a global reference for `require('perf_hooks').performance` + * https://nodejs.org/api/globals.html#performance + * @since v16.0.0 + */ + var performance: typeof globalThis extends { + onmessage: any; + performance: infer T; + } ? T + : typeof _performance; + } +} +declare module "node:perf_hooks" { + export * from "perf_hooks"; +} diff --git a/node_modules/@types/node/ts4.8/process.d.ts b/node_modules/@types/node/ts4.8/process.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e2747376fc359a4cbf94dbffc73779f6eb43e04 --- /dev/null +++ b/node_modules/@types/node/ts4.8/process.d.ts @@ -0,0 +1,1539 @@ +declare module "process" { + import * as tty from "node:tty"; + import { Worker } from "node:worker_threads"; + global { + var process: NodeJS.Process; + namespace NodeJS { + // this namespace merge is here because these are specifically used + // as the type for process.stdin, process.stdout, and process.stderr. + // they can't live in tty.d.ts because we need to disambiguate the imported name. + interface ReadStream extends tty.ReadStream {} + interface WriteStream extends tty.WriteStream {} + interface MemoryUsageFn { + /** + * The `process.memoryUsage()` method iterate over each page to gather informations about memory + * usage which can be slow depending on the program memory allocations. + */ + (): MemoryUsage; + /** + * method returns an integer representing the Resident Set Size (RSS) in bytes. + */ + rss(): number; + } + interface MemoryUsage { + rss: number; + heapTotal: number; + heapUsed: number; + external: number; + arrayBuffers: number; + } + interface CpuUsage { + user: number; + system: number; + } + interface ProcessRelease { + name: string; + sourceUrl?: string | undefined; + headersUrl?: string | undefined; + libUrl?: string | undefined; + lts?: string | undefined; + } + interface ProcessVersions extends Dict { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + modules: string; + openssl: string; + } + type Platform = + | "aix" + | "android" + | "darwin" + | "freebsd" + | "haiku" + | "linux" + | "openbsd" + | "sunos" + | "win32" + | "cygwin" + | "netbsd"; + type Architecture = + | "arm" + | "arm64" + | "ia32" + | "mips" + | "mipsel" + | "ppc" + | "ppc64" + | "riscv64" + | "s390" + | "s390x" + | "x64"; + type Signals = + | "SIGABRT" + | "SIGALRM" + | "SIGBUS" + | "SIGCHLD" + | "SIGCONT" + | "SIGFPE" + | "SIGHUP" + | "SIGILL" + | "SIGINT" + | "SIGIO" + | "SIGIOT" + | "SIGKILL" + | "SIGPIPE" + | "SIGPOLL" + | "SIGPROF" + | "SIGPWR" + | "SIGQUIT" + | "SIGSEGV" + | "SIGSTKFLT" + | "SIGSTOP" + | "SIGSYS" + | "SIGTERM" + | "SIGTRAP" + | "SIGTSTP" + | "SIGTTIN" + | "SIGTTOU" + | "SIGUNUSED" + | "SIGURG" + | "SIGUSR1" + | "SIGUSR2" + | "SIGVTALRM" + | "SIGWINCH" + | "SIGXCPU" + | "SIGXFSZ" + | "SIGBREAK" + | "SIGLOST" + | "SIGINFO"; + type UncaughtExceptionOrigin = "uncaughtException" | "unhandledRejection"; + type MultipleResolveType = "resolve" | "reject"; + type BeforeExitListener = (code: number) => void; + type DisconnectListener = () => void; + type ExitListener = (code: number) => void; + type RejectionHandledListener = (promise: Promise) => void; + type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void; + /** + * Most of the time the unhandledRejection will be an Error, but this should not be relied upon + * as *anything* can be thrown/rejected, it is therefore unsafe to assume that the value is an Error. + */ + type UnhandledRejectionListener = (reason: unknown, promise: Promise) => void; + type WarningListener = (warning: Error) => void; + type MessageListener = (message: unknown, sendHandle: unknown) => void; + type SignalsListener = (signal: Signals) => void; + type MultipleResolveListener = ( + type: MultipleResolveType, + promise: Promise, + value: unknown, + ) => void; + type WorkerListener = (worker: Worker) => void; + interface Socket extends ReadWriteStream { + isTTY?: true | undefined; + } + // Alias for compatibility + interface ProcessEnv extends Dict { + /** + * Can be used to change the default timezone at runtime + */ + TZ?: string; + } + interface HRTime { + (time?: [number, number]): [number, number]; + bigint(): bigint; + } + interface ProcessReport { + /** + * Directory where the report is written. + * working directory of the Node.js process. + * @default '' indicating that reports are written to the current + */ + directory: string; + /** + * Filename where the report is written. + * The default value is the empty string. + * @default '' the output filename will be comprised of a timestamp, + * PID, and sequence number. + */ + filename: string; + /** + * Returns a JSON-formatted diagnostic report for the running process. + * The report's JavaScript stack trace is taken from err, if present. + */ + getReport(err?: Error): string; + /** + * If true, a diagnostic report is generated on fatal errors, + * such as out of memory errors or failed C++ assertions. + * @default false + */ + reportOnFatalError: boolean; + /** + * If true, a diagnostic report is generated when the process + * receives the signal specified by process.report.signal. + * @default false + */ + reportOnSignal: boolean; + /** + * If true, a diagnostic report is generated on uncaught exception. + * @default false + */ + reportOnUncaughtException: boolean; + /** + * The signal used to trigger the creation of a diagnostic report. + * @default 'SIGUSR2' + */ + signal: Signals; + /** + * Writes a diagnostic report to a file. If filename is not provided, the default filename + * includes the date, time, PID, and a sequence number. + * The report's JavaScript stack trace is taken from err, if present. + * + * @param fileName Name of the file where the report is written. + * This should be a relative path, that will be appended to the directory specified in + * `process.report.directory`, or the current working directory of the Node.js process, + * if unspecified. + * @param error A custom error used for reporting the JavaScript stack. + * @return Filename of the generated report. + */ + writeReport(fileName?: string): string; + writeReport(error?: Error): string; + writeReport(fileName?: string, err?: Error): string; + } + interface ResourceUsage { + fsRead: number; + fsWrite: number; + involuntaryContextSwitches: number; + ipcReceived: number; + ipcSent: number; + majorPageFault: number; + maxRSS: number; + minorPageFault: number; + sharedMemorySize: number; + signalsCount: number; + swappedOut: number; + systemCPUTime: number; + unsharedDataSize: number; + unsharedStackSize: number; + userCPUTime: number; + voluntaryContextSwitches: number; + } + interface EmitWarningOptions { + /** + * When `warning` is a `string`, `type` is the name to use for the _type_ of warning being emitted. + * + * @default 'Warning' + */ + type?: string | undefined; + /** + * A unique identifier for the warning instance being emitted. + */ + code?: string | undefined; + /** + * When `warning` is a `string`, `ctor` is an optional function used to limit the generated stack trace. + * + * @default process.emitWarning + */ + ctor?: Function | undefined; + /** + * Additional text to include with the error. + */ + detail?: string | undefined; + } + interface ProcessConfig { + readonly target_defaults: { + readonly cflags: any[]; + readonly default_configuration: string; + readonly defines: string[]; + readonly include_dirs: string[]; + readonly libraries: string[]; + }; + readonly variables: { + readonly clang: number; + readonly host_arch: string; + readonly node_install_npm: boolean; + readonly node_install_waf: boolean; + readonly node_prefix: string; + readonly node_shared_openssl: boolean; + readonly node_shared_v8: boolean; + readonly node_shared_zlib: boolean; + readonly node_use_dtrace: boolean; + readonly node_use_etw: boolean; + readonly node_use_openssl: boolean; + readonly target_arch: string; + readonly v8_no_strict_aliasing: number; + readonly v8_use_snapshot: boolean; + readonly visibility: string; + }; + } + interface Process extends EventEmitter { + /** + * The `process.stdout` property returns a stream connected to`stdout` (fd `1`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `1` refers to a file, in which case it is + * a `Writable` stream. + * + * For example, to copy `process.stdin` to `process.stdout`: + * + * ```js + * import { stdin, stdout } from 'node:process'; + * + * stdin.pipe(stdout); + * ``` + * + * `process.stdout` differs from other Node.js streams in important ways. See `note on process I/O` for more information. + */ + stdout: WriteStream & { + fd: 1; + }; + /** + * The `process.stderr` property returns a stream connected to`stderr` (fd `2`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `2` refers to a file, in which case it is + * a `Writable` stream. + * + * `process.stderr` differs from other Node.js streams in important ways. See `note on process I/O` for more information. + */ + stderr: WriteStream & { + fd: 2; + }; + /** + * The `process.stdin` property returns a stream connected to`stdin` (fd `0`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `0` refers to a file, in which case it is + * a `Readable` stream. + * + * For details of how to read from `stdin` see `readable.read()`. + * + * As a `Duplex` stream, `process.stdin` can also be used in "old" mode that + * is compatible with scripts written for Node.js prior to v0.10\. + * For more information see `Stream compatibility`. + * + * In "old" streams mode the `stdin` stream is paused by default, so one + * must call `process.stdin.resume()` to read from it. Note also that calling`process.stdin.resume()` itself would switch stream to "old" mode. + */ + stdin: ReadStream & { + fd: 0; + }; + openStdin(): Socket; + /** + * The `process.argv` property returns an array containing the command-line + * arguments passed when the Node.js process was launched. The first element will + * be {@link execPath}. See `process.argv0` if access to the original value + * of `argv[0]` is needed. The second element will be the path to the JavaScript + * file being executed. The remaining elements will be any additional command-line + * arguments. + * + * For example, assuming the following script for `process-args.js`: + * + * ```js + * import { argv } from 'node:process'; + * + * // print process.argv + * argv.forEach((val, index) => { + * console.log(`${index}: ${val}`); + * }); + * ``` + * + * Launching the Node.js process as: + * + * ```bash + * node process-args.js one two=three four + * ``` + * + * Would generate the output: + * + * ```text + * 0: /usr/local/bin/node + * 1: /Users/mjr/work/node/process-args.js + * 2: one + * 3: two=three + * 4: four + * ``` + * @since v0.1.27 + */ + argv: string[]; + /** + * The `process.argv0` property stores a read-only copy of the original value of`argv[0]` passed when Node.js starts. + * + * ```console + * $ bash -c 'exec -a customArgv0 ./node' + * > process.argv[0] + * '/Volumes/code/external/node/out/Release/node' + * > process.argv0 + * 'customArgv0' + * ``` + * @since v6.4.0 + */ + argv0: string; + /** + * The `process.execArgv` property returns the set of Node.js-specific command-line + * options passed when the Node.js process was launched. These options do not + * appear in the array returned by the {@link argv} property, and do not + * include the Node.js executable, the name of the script, or any options following + * the script name. These options are useful in order to spawn child processes with + * the same execution environment as the parent. + * + * ```bash + * node --harmony script.js --version + * ``` + * + * Results in `process.execArgv`: + * + * ```js + * ['--harmony'] + * ``` + * + * And `process.argv`: + * + * ```js + * ['/usr/local/bin/node', 'script.js', '--version'] + * ``` + * + * Refer to `Worker constructor` for the detailed behavior of worker + * threads with this property. + * @since v0.7.7 + */ + execArgv: string[]; + /** + * The `process.execPath` property returns the absolute pathname of the executable + * that started the Node.js process. Symbolic links, if any, are resolved. + * + * ```js + * '/usr/local/bin/node' + * ``` + * @since v0.1.100 + */ + execPath: string; + /** + * The `process.abort()` method causes the Node.js process to exit immediately and + * generate a core file. + * + * This feature is not available in `Worker` threads. + * @since v0.7.0 + */ + abort(): never; + /** + * The `process.chdir()` method changes the current working directory of the + * Node.js process or throws an exception if doing so fails (for instance, if + * the specified `directory` does not exist). + * + * ```js + * import { chdir, cwd } from 'node:process'; + * + * console.log(`Starting directory: ${cwd()}`); + * try { + * chdir('/tmp'); + * console.log(`New directory: ${cwd()}`); + * } catch (err) { + * console.error(`chdir: ${err}`); + * } + * ``` + * + * This feature is not available in `Worker` threads. + * @since v0.1.17 + */ + chdir(directory: string): void; + /** + * The `process.cwd()` method returns the current working directory of the Node.js + * process. + * + * ```js + * import { cwd } from 'node:process'; + * + * console.log(`Current directory: ${cwd()}`); + * ``` + * @since v0.1.8 + */ + cwd(): string; + /** + * The port used by the Node.js debugger when enabled. + * + * ```js + * import process from 'node:process'; + * + * process.debugPort = 5858; + * ``` + * @since v0.7.2 + */ + debugPort: number; + /** + * The `process.emitWarning()` method can be used to emit custom or application + * specific process warnings. These can be listened for by adding a handler to the `'warning'` event. + * + * ```js + * import { emitWarning } from 'node:process'; + * + * // Emit a warning with a code and additional detail. + * emitWarning('Something happened!', { + * code: 'MY_WARNING', + * detail: 'This is some additional information', + * }); + * // Emits: + * // (node:56338) [MY_WARNING] Warning: Something happened! + * // This is some additional information + * ``` + * + * In this example, an `Error` object is generated internally by`process.emitWarning()` and passed through to the `'warning'` handler. + * + * ```js + * import process from 'node:process'; + * + * process.on('warning', (warning) => { + * console.warn(warning.name); // 'Warning' + * console.warn(warning.message); // 'Something happened!' + * console.warn(warning.code); // 'MY_WARNING' + * console.warn(warning.stack); // Stack trace + * console.warn(warning.detail); // 'This is some additional information' + * }); + * ``` + * + * If `warning` is passed as an `Error` object, the `options` argument is ignored. + * @since v8.0.0 + * @param warning The warning to emit. + */ + emitWarning(warning: string | Error, ctor?: Function): void; + emitWarning(warning: string | Error, type?: string, ctor?: Function): void; + emitWarning(warning: string | Error, type?: string, code?: string, ctor?: Function): void; + emitWarning(warning: string | Error, options?: EmitWarningOptions): void; + /** + * The `process.env` property returns an object containing the user environment. + * See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). + * + * An example of this object looks like: + * + * ```js + * { + * TERM: 'xterm-256color', + * SHELL: '/usr/local/bin/bash', + * USER: 'maciej', + * PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', + * PWD: '/Users/maciej', + * EDITOR: 'vim', + * SHLVL: '1', + * HOME: '/Users/maciej', + * LOGNAME: 'maciej', + * _: '/usr/local/bin/node' + * } + * ``` + * + * It is possible to modify this object, but such modifications will not be + * reflected outside the Node.js process, or (unless explicitly requested) + * to other `Worker` threads. + * In other words, the following example would not work: + * + * ```bash + * node -e 'process.env.foo = "bar"' && echo $foo + * ``` + * + * While the following will: + * + * ```js + * import { env } from 'node:process'; + * + * env.foo = 'bar'; + * console.log(env.foo); + * ``` + * + * Assigning a property on `process.env` will implicitly convert the value + * to a string. **This behavior is deprecated.** Future versions of Node.js may + * throw an error when the value is not a string, number, or boolean. + * + * ```js + * import { env } from 'node:process'; + * + * env.test = null; + * console.log(env.test); + * // => 'null' + * env.test = undefined; + * console.log(env.test); + * // => 'undefined' + * ``` + * + * Use `delete` to delete a property from `process.env`. + * + * ```js + * import { env } from 'node:process'; + * + * env.TEST = 1; + * delete env.TEST; + * console.log(env.TEST); + * // => undefined + * ``` + * + * On Windows operating systems, environment variables are case-insensitive. + * + * ```js + * import { env } from 'node:process'; + * + * env.TEST = 1; + * console.log(env.test); + * // => 1 + * ``` + * + * Unless explicitly specified when creating a `Worker` instance, + * each `Worker` thread has its own copy of `process.env`, based on its + * parent thread's `process.env`, or whatever was specified as the `env` option + * to the `Worker` constructor. Changes to `process.env` will not be visible + * across `Worker` threads, and only the main thread can make changes that + * are visible to the operating system or to native add-ons. On Windows, a copy of`process.env` on a `Worker` instance operates in a case-sensitive manner + * unlike the main thread. + * @since v0.1.27 + */ + env: ProcessEnv; + /** + * The `process.exit()` method instructs Node.js to terminate the process + * synchronously with an exit status of `code`. If `code` is omitted, exit uses + * either the 'success' code `0` or the value of `process.exitCode` if it has been + * set. Node.js will not terminate until all the `'exit'` event listeners are + * called. + * + * To exit with a 'failure' code: + * + * ```js + * import { exit } from 'node:process'; + * + * exit(1); + * ``` + * + * The shell that executed Node.js should see the exit code as `1`. + * + * Calling `process.exit()` will force the process to exit as quickly as possible + * even if there are still asynchronous operations pending that have not yet + * completed fully, including I/O operations to `process.stdout` and`process.stderr`. + * + * In most situations, it is not actually necessary to call `process.exit()`explicitly. The Node.js process will exit on its own _if there is no additional_ + * _work pending_ in the event loop. The `process.exitCode` property can be set to + * tell the process which exit code to use when the process exits gracefully. + * + * For instance, the following example illustrates a _misuse_ of the`process.exit()` method that could lead to data printed to stdout being + * truncated and lost: + * + * ```js + * import { exit } from 'node:process'; + * + * // This is an example of what *not* to do: + * if (someConditionNotMet()) { + * printUsageToStdout(); + * exit(1); + * } + * ``` + * + * The reason this is problematic is because writes to `process.stdout` in Node.js + * are sometimes _asynchronous_ and may occur over multiple ticks of the Node.js + * event loop. Calling `process.exit()`, however, forces the process to exit _before_ those additional writes to `stdout` can be performed. + * + * Rather than calling `process.exit()` directly, the code _should_ set the`process.exitCode` and allow the process to exit naturally by avoiding + * scheduling any additional work for the event loop: + * + * ```js + * import process from 'node:process'; + * + * // How to properly set the exit code while letting + * // the process exit gracefully. + * if (someConditionNotMet()) { + * printUsageToStdout(); + * process.exitCode = 1; + * } + * ``` + * + * If it is necessary to terminate the Node.js process due to an error condition, + * throwing an _uncaught_ error and allowing the process to terminate accordingly + * is safer than calling `process.exit()`. + * + * In `Worker` threads, this function stops the current thread rather + * than the current process. + * @since v0.1.13 + * @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed. + */ + exit(code?: number): never; + /** + * A number which will be the process exit code, when the process either + * exits gracefully, or is exited via {@link exit} without specifying + * a code. + * + * Specifying a code to {@link exit} will override any + * previous setting of `process.exitCode`. + * @since v0.11.8 + */ + exitCode?: number | undefined; + /** + * The `process.getgid()` method returns the numerical group identity of the + * process. (See [`getgid(2)`](http://man7.org/linux/man-pages/man2/getgid.2.html).) + * + * ```js + * import process from 'process'; + * + * if (process.getgid) { + * console.log(`Current gid: ${process.getgid()}`); + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v0.1.31 + */ + getgid?: () => number; + /** + * The `process.setgid()` method sets the group identity of the process. (See [`setgid(2)`](http://man7.org/linux/man-pages/man2/setgid.2.html).) The `id` can be passed as either a + * numeric ID or a group name + * string. If a group name is specified, this method blocks while resolving the + * associated numeric ID. + * + * ```js + * import process from 'process'; + * + * if (process.getgid && process.setgid) { + * console.log(`Current gid: ${process.getgid()}`); + * try { + * process.setgid(501); + * console.log(`New gid: ${process.getgid()}`); + * } catch (err) { + * console.log(`Failed to set gid: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v0.1.31 + * @param id The group name or ID + */ + setgid?: (id: number | string) => void; + /** + * The `process.getuid()` method returns the numeric user identity of the process. + * (See [`getuid(2)`](http://man7.org/linux/man-pages/man2/getuid.2.html).) + * + * ```js + * import process from 'process'; + * + * if (process.getuid) { + * console.log(`Current uid: ${process.getuid()}`); + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v0.1.28 + */ + getuid?: () => number; + /** + * The `process.setuid(id)` method sets the user identity of the process. (See [`setuid(2)`](http://man7.org/linux/man-pages/man2/setuid.2.html).) The `id` can be passed as either a + * numeric ID or a username string. + * If a username is specified, the method blocks while resolving the associated + * numeric ID. + * + * ```js + * import process from 'process'; + * + * if (process.getuid && process.setuid) { + * console.log(`Current uid: ${process.getuid()}`); + * try { + * process.setuid(501); + * console.log(`New uid: ${process.getuid()}`); + * } catch (err) { + * console.log(`Failed to set uid: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v0.1.28 + */ + setuid?: (id: number | string) => void; + /** + * The `process.geteuid()` method returns the numerical effective user identity of + * the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).) + * + * ```js + * import process from 'process'; + * + * if (process.geteuid) { + * console.log(`Current uid: ${process.geteuid()}`); + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v2.0.0 + */ + geteuid?: () => number; + /** + * The `process.seteuid()` method sets the effective user identity of the process. + * (See [`seteuid(2)`](http://man7.org/linux/man-pages/man2/seteuid.2.html).) The `id` can be passed as either a numeric ID or a username + * string. If a username is specified, the method blocks while resolving the + * associated numeric ID. + * + * ```js + * import process from 'process'; + * + * if (process.geteuid && process.seteuid) { + * console.log(`Current uid: ${process.geteuid()}`); + * try { + * process.seteuid(501); + * console.log(`New uid: ${process.geteuid()}`); + * } catch (err) { + * console.log(`Failed to set uid: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v2.0.0 + * @param id A user name or ID + */ + seteuid?: (id: number | string) => void; + /** + * The `process.getegid()` method returns the numerical effective group identity + * of the Node.js process. (See [`getegid(2)`](http://man7.org/linux/man-pages/man2/getegid.2.html).) + * + * ```js + * import process from 'process'; + * + * if (process.getegid) { + * console.log(`Current gid: ${process.getegid()}`); + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v2.0.0 + */ + getegid?: () => number; + /** + * The `process.setegid()` method sets the effective group identity of the process. + * (See [`setegid(2)`](http://man7.org/linux/man-pages/man2/setegid.2.html).) The `id` can be passed as either a numeric ID or a group + * name string. If a group name is specified, this method blocks while resolving + * the associated a numeric ID. + * + * ```js + * import process from 'process'; + * + * if (process.getegid && process.setegid) { + * console.log(`Current gid: ${process.getegid()}`); + * try { + * process.setegid(501); + * console.log(`New gid: ${process.getegid()}`); + * } catch (err) { + * console.log(`Failed to set gid: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v2.0.0 + * @param id A group name or ID + */ + setegid?: (id: number | string) => void; + /** + * The `process.getgroups()` method returns an array with the supplementary group + * IDs. POSIX leaves it unspecified if the effective group ID is included but + * Node.js ensures it always is. + * + * ```js + * import process from 'process'; + * + * if (process.getgroups) { + * console.log(process.getgroups()); // [ 16, 21, 297 ] + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * @since v0.9.4 + */ + getgroups?: () => number[]; + /** + * The `process.setgroups()` method sets the supplementary group IDs for the + * Node.js process. This is a privileged operation that requires the Node.js + * process to have `root` or the `CAP_SETGID` capability. + * + * The `groups` array can contain numeric group IDs, group names, or both. + * + * ```js + * import process from 'process'; + * + * if (process.getgroups && process.setgroups) { + * try { + * process.setgroups([501]); + * console.log(process.getgroups()); // new groups + * } catch (err) { + * console.log(`Failed to set groups: ${err}`); + * } + * } + * ``` + * + * This function is only available on POSIX platforms (i.e. not Windows or + * Android). + * This feature is not available in `Worker` threads. + * @since v0.9.4 + */ + setgroups?: (groups: ReadonlyArray) => void; + /** + * The `process.setUncaughtExceptionCaptureCallback()` function sets a function + * that will be invoked when an uncaught exception occurs, which will receive the + * exception value itself as its first argument. + * + * If such a function is set, the `'uncaughtException'` event will + * not be emitted. If `--abort-on-uncaught-exception` was passed from the + * command line or set through `v8.setFlagsFromString()`, the process will + * not abort. Actions configured to take place on exceptions such as report + * generations will be affected too + * + * To unset the capture function,`process.setUncaughtExceptionCaptureCallback(null)` may be used. Calling this + * method with a non-`null` argument while another capture function is set will + * throw an error. + * + * Using this function is mutually exclusive with using the deprecated `domain` built-in module. + * @since v9.3.0 + */ + setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void; + /** + * Indicates whether a callback has been set using {@link setUncaughtExceptionCaptureCallback}. + * @since v9.3.0 + */ + hasUncaughtExceptionCaptureCallback(): boolean; + /** + * The `process.sourceMapsEnabled` property returns whether the [Source Map v3](https://sourcemaps.info/spec.html) support for stack traces is enabled. + * @since v20.7.0 + * @experimental + */ + readonly sourceMapsEnabled: boolean; + /** + * This function enables or disables the Source Map v3 support for stack traces. + * It provides same features as launching Node.js process with commandline options --enable-source-maps. + * @since v16.6.0 + * @experimental + */ + setSourceMapsEnabled(value: boolean): void; + /** + * The `process.version` property contains the Node.js version string. + * + * ```js + * import { version } from 'node:process'; + * + * console.log(`Version: ${version}`); + * // Version: v14.8.0 + * ``` + * + * To get the version string without the prepended _v_, use`process.versions.node`. + * @since v0.1.3 + */ + readonly version: string; + /** + * The `process.versions` property returns an object listing the version strings of + * Node.js and its dependencies. `process.versions.modules` indicates the current + * ABI version, which is increased whenever a C++ API changes. Node.js will refuse + * to load modules that were compiled against a different module ABI version. + * + * ```js + * import { versions } from 'node:process'; + * + * console.log(versions); + * ``` + * + * Will generate an object similar to: + * + * ```console + * { node: '20.2.0', + * acorn: '8.8.2', + * ada: '2.4.0', + * ares: '1.19.0', + * base64: '0.5.0', + * brotli: '1.0.9', + * cjs_module_lexer: '1.2.2', + * cldr: '43.0', + * icu: '73.1', + * llhttp: '8.1.0', + * modules: '115', + * napi: '8', + * nghttp2: '1.52.0', + * nghttp3: '0.7.0', + * ngtcp2: '0.8.1', + * openssl: '3.0.8+quic', + * simdutf: '3.2.9', + * tz: '2023c', + * undici: '5.22.0', + * unicode: '15.0', + * uv: '1.44.2', + * uvwasi: '0.0.16', + * v8: '11.3.244.8-node.9', + * zlib: '1.2.13' } + * ``` + * @since v0.2.0 + */ + readonly versions: ProcessVersions; + /** + * The `process.config` property returns a frozen `Object` containing the + * JavaScript representation of the configure options used to compile the current + * Node.js executable. This is the same as the `config.gypi` file that was produced + * when running the `./configure` script. + * + * An example of the possible output looks like: + * + * ```js + * { + * target_defaults: + * { cflags: [], + * default_configuration: 'Release', + * defines: [], + * include_dirs: [], + * libraries: [] }, + * variables: + * { + * host_arch: 'x64', + * napi_build_version: 5, + * node_install_npm: 'true', + * node_prefix: '', + * node_shared_cares: 'false', + * node_shared_http_parser: 'false', + * node_shared_libuv: 'false', + * node_shared_zlib: 'false', + * node_use_openssl: 'true', + * node_shared_openssl: 'false', + * strict_aliasing: 'true', + * target_arch: 'x64', + * v8_use_snapshot: 1 + * } + * } + * ``` + * @since v0.7.7 + */ + readonly config: ProcessConfig; + /** + * The `process.kill()` method sends the `signal` to the process identified by`pid`. + * + * Signal names are strings such as `'SIGINT'` or `'SIGHUP'`. See `Signal Events` and [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for more information. + * + * This method will throw an error if the target `pid` does not exist. As a special + * case, a signal of `0` can be used to test for the existence of a process. + * Windows platforms will throw an error if the `pid` is used to kill a process + * group. + * + * Even though the name of this function is `process.kill()`, it is really just a + * signal sender, like the `kill` system call. The signal sent may do something + * other than kill the target process. + * + * ```js + * import process, { kill } from 'node:process'; + * + * process.on('SIGHUP', () => { + * console.log('Got SIGHUP signal.'); + * }); + * + * setTimeout(() => { + * console.log('Exiting.'); + * process.exit(0); + * }, 100); + * + * kill(process.pid, 'SIGHUP'); + * ``` + * + * When `SIGUSR1` is received by a Node.js process, Node.js will start the + * debugger. See `Signal Events`. + * @since v0.0.6 + * @param pid A process ID + * @param [signal='SIGTERM'] The signal to send, either as a string or number. + */ + kill(pid: number, signal?: string | number): true; + /** + * The `process.pid` property returns the PID of the process. + * + * ```js + * import { pid } from 'node:process'; + * + * console.log(`This process is pid ${pid}`); + * ``` + * @since v0.1.15 + */ + readonly pid: number; + /** + * The `process.ppid` property returns the PID of the parent of the + * current process. + * + * ```js + * import { ppid } from 'node:process'; + * + * console.log(`The parent process is pid ${ppid}`); + * ``` + * @since v9.2.0, v8.10.0, v6.13.0 + */ + readonly ppid: number; + /** + * The `process.title` property returns the current process title (i.e. returns + * the current value of `ps`). Assigning a new value to `process.title` modifies + * the current value of `ps`. + * + * When a new value is assigned, different platforms will impose different maximum + * length restrictions on the title. Usually such restrictions are quite limited. + * For instance, on Linux and macOS, `process.title` is limited to the size of the + * binary name plus the length of the command-line arguments because setting the`process.title` overwrites the `argv` memory of the process. Node.js v0.8 + * allowed for longer process title strings by also overwriting the `environ`memory but that was potentially insecure and confusing in some (rather obscure) + * cases. + * + * Assigning a value to `process.title` might not result in an accurate label + * within process manager applications such as macOS Activity Monitor or Windows + * Services Manager. + * @since v0.1.104 + */ + title: string; + /** + * The operating system CPU architecture for which the Node.js binary was compiled. + * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`. + * + * ```js + * import { arch } from 'node:process'; + * + * console.log(`This processor architecture is ${arch}`); + * ``` + * @since v0.5.0 + */ + readonly arch: Architecture; + /** + * The `process.platform` property returns a string identifying the operating + * system platform for which the Node.js binary was compiled. + * + * Currently possible values are: + * + * * `'aix'` + * * `'darwin'` + * * `'freebsd'` + * * `'linux'` + * * `'openbsd'` + * * `'sunos'` + * * `'win32'` + * + * ```js + * import { platform } from 'node:process'; + * + * console.log(`This platform is ${platform}`); + * ``` + * + * The value `'android'` may also be returned if the Node.js is built on the + * Android operating system. However, Android support in Node.js [is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os). + * @since v0.1.16 + */ + readonly platform: Platform; + /** + * The `process.mainModule` property provides an alternative way of retrieving `require.main`. The difference is that if the main module changes at + * runtime, `require.main` may still refer to the original main module in + * modules that were required before the change occurred. Generally, it's + * safe to assume that the two refer to the same module. + * + * As with `require.main`, `process.mainModule` will be `undefined` if there + * is no entry script. + * @since v0.1.17 + * @deprecated Since v14.0.0 - Use `main` instead. + */ + mainModule?: Module | undefined; + memoryUsage: MemoryUsageFn; + /** + * Gets the amount of memory available to the process (in bytes) based on + * limits imposed by the OS. If there is no such constraint, or the constraint + * is unknown, `undefined` is returned. + * + * See [`uv_get_constrained_memory`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_get_constrained_memory) for more + * information. + * @since v19.6.0, v18.15.0 + * @experimental + */ + constrainedMemory(): number | undefined; + /** + * The `process.cpuUsage()` method returns the user and system CPU time usage of + * the current process, in an object with properties `user` and `system`, whose + * values are microsecond values (millionth of a second). These values measure time + * spent in user and system code respectively, and may end up being greater than + * actual elapsed time if multiple CPU cores are performing work for this process. + * + * The result of a previous call to `process.cpuUsage()` can be passed as the + * argument to the function, to get a diff reading. + * + * ```js + * import { cpuUsage } from 'node:process'; + * + * const startUsage = cpuUsage(); + * // { user: 38579, system: 6986 } + * + * // spin the CPU for 500 milliseconds + * const now = Date.now(); + * while (Date.now() - now < 500); + * + * console.log(cpuUsage(startUsage)); + * // { user: 514883, system: 11226 } + * ``` + * @since v6.1.0 + * @param previousValue A previous return value from calling `process.cpuUsage()` + */ + cpuUsage(previousValue?: CpuUsage): CpuUsage; + /** + * `process.nextTick()` adds `callback` to the "next tick queue". This queue is + * fully drained after the current operation on the JavaScript stack runs to + * completion and before the event loop is allowed to continue. It's possible to + * create an infinite loop if one were to recursively call `process.nextTick()`. + * See the [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick) guide for more background. + * + * ```js + * import { nextTick } from 'node:process'; + * + * console.log('start'); + * nextTick(() => { + * console.log('nextTick callback'); + * }); + * console.log('scheduled'); + * // Output: + * // start + * // scheduled + * // nextTick callback + * ``` + * + * This is important when developing APIs in order to give users the opportunity + * to assign event handlers _after_ an object has been constructed but before any + * I/O has occurred: + * + * ```js + * import { nextTick } from 'node:process'; + * + * function MyThing(options) { + * this.setupOptions(options); + * + * nextTick(() => { + * this.startDoingStuff(); + * }); + * } + * + * const thing = new MyThing(); + * thing.getReadyForStuff(); + * + * // thing.startDoingStuff() gets called now, not before. + * ``` + * + * It is very important for APIs to be either 100% synchronous or 100% + * asynchronous. Consider this example: + * + * ```js + * // WARNING! DO NOT USE! BAD UNSAFE HAZARD! + * function maybeSync(arg, cb) { + * if (arg) { + * cb(); + * return; + * } + * + * fs.stat('file', cb); + * } + * ``` + * + * This API is hazardous because in the following case: + * + * ```js + * const maybeTrue = Math.random() > 0.5; + * + * maybeSync(maybeTrue, () => { + * foo(); + * }); + * + * bar(); + * ``` + * + * It is not clear whether `foo()` or `bar()` will be called first. + * + * The following approach is much better: + * + * ```js + * import { nextTick } from 'node:process'; + * + * function definitelyAsync(arg, cb) { + * if (arg) { + * nextTick(cb); + * return; + * } + * + * fs.stat('file', cb); + * } + * ``` + * @since v0.1.26 + * @param args Additional arguments to pass when invoking the `callback` + */ + nextTick(callback: Function, ...args: any[]): void; + /** + * The `process.release` property returns an `Object` containing metadata related + * to the current release, including URLs for the source tarball and headers-only + * tarball. + * + * `process.release` contains the following properties: + * + * ```js + * { + * name: 'node', + * lts: 'Hydrogen', + * sourceUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz', + * headersUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz', + * libUrl: 'https://nodejs.org/download/release/v18.12.0/win-x64/node.lib' + * } + * ``` + * + * In custom builds from non-release versions of the source tree, only the`name` property may be present. The additional properties should not be + * relied upon to exist. + * @since v3.0.0 + */ + readonly release: ProcessRelease; + features: { + inspector: boolean; + debug: boolean; + uv: boolean; + ipv6: boolean; + tls_alpn: boolean; + tls_sni: boolean; + tls_ocsp: boolean; + tls: boolean; + }; + /** + * `process.umask()` returns the Node.js process's file mode creation mask. Child + * processes inherit the mask from the parent process. + * @since v0.1.19 + * @deprecated Calling `process.umask()` with no argument causes the process-wide umask to be written twice. This introduces a race condition between threads, and is a potential * + * security vulnerability. There is no safe, cross-platform alternative API. + */ + umask(): number; + /** + * Can only be set if not in worker thread. + */ + umask(mask: string | number): number; + /** + * The `process.uptime()` method returns the number of seconds the current Node.js + * process has been running. + * + * The return value includes fractions of a second. Use `Math.floor()` to get whole + * seconds. + * @since v0.5.0 + */ + uptime(): number; + hrtime: HRTime; + /** + * If Node.js is spawned with an IPC channel, the `process.send()` method can be + * used to send messages to the parent process. Messages will be received as a `'message'` event on the parent's `ChildProcess` object. + * + * If Node.js was not spawned with an IPC channel, `process.send` will be `undefined`. + * + * The message goes through serialization and parsing. The resulting message might + * not be the same as what is originally sent. + * @since v0.5.9 + * @param options used to parameterize the sending of certain types of handles.`options` supports the following properties: + */ + send?( + message: any, + sendHandle?: any, + options?: { + swallowErrors?: boolean | undefined; + }, + callback?: (error: Error | null) => void, + ): boolean; + /** + * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.disconnect()` method will close the + * IPC channel to the parent process, allowing the child process to exit gracefully + * once there are no other connections keeping it alive. + * + * The effect of calling `process.disconnect()` is the same as calling `ChildProcess.disconnect()` from the parent process. + * + * If the Node.js process was not spawned with an IPC channel,`process.disconnect()` will be `undefined`. + * @since v0.7.2 + */ + disconnect(): void; + /** + * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.connected` property will return`true` so long as the IPC + * channel is connected and will return `false` after`process.disconnect()` is called. + * + * Once `process.connected` is `false`, it is no longer possible to send messages + * over the IPC channel using `process.send()`. + * @since v0.7.2 + */ + connected: boolean; + /** + * The `process.allowedNodeEnvironmentFlags` property is a special, + * read-only `Set` of flags allowable within the `NODE_OPTIONS` environment variable. + * + * `process.allowedNodeEnvironmentFlags` extends `Set`, but overrides`Set.prototype.has` to recognize several different possible flag + * representations. `process.allowedNodeEnvironmentFlags.has()` will + * return `true` in the following cases: + * + * * Flags may omit leading single (`-`) or double (`--`) dashes; e.g.,`inspect-brk` for `--inspect-brk`, or `r` for `-r`. + * * Flags passed through to V8 (as listed in `--v8-options`) may replace + * one or more _non-leading_ dashes for an underscore, or vice-versa; + * e.g., `--perf_basic_prof`, `--perf-basic-prof`, `--perf_basic-prof`, + * etc. + * * Flags may contain one or more equals (`=`) characters; all + * characters after and including the first equals will be ignored; + * e.g., `--stack-trace-limit=100`. + * * Flags _must_ be allowable within `NODE_OPTIONS`. + * + * When iterating over `process.allowedNodeEnvironmentFlags`, flags will + * appear only _once_; each will begin with one or more dashes. Flags + * passed through to V8 will contain underscores instead of non-leading + * dashes: + * + * ```js + * import { allowedNodeEnvironmentFlags } from 'node:process'; + * + * allowedNodeEnvironmentFlags.forEach((flag) => { + * // -r + * // --inspect-brk + * // --abort_on_uncaught_exception + * // ... + * }); + * ``` + * + * The methods `add()`, `clear()`, and `delete()` of`process.allowedNodeEnvironmentFlags` do nothing, and will fail + * silently. + * + * If Node.js was compiled _without_ `NODE_OPTIONS` support (shown in {@link config}), `process.allowedNodeEnvironmentFlags` will + * contain what _would have_ been allowable. + * @since v10.10.0 + */ + allowedNodeEnvironmentFlags: ReadonlySet; + /** + * `process.report` is an object whose methods are used to generate diagnostic + * reports for the current process. Additional documentation is available in the `report documentation`. + * @since v11.8.0 + */ + report?: ProcessReport | undefined; + /** + * ```js + * import { resourceUsage } from 'node:process'; + * + * console.log(resourceUsage()); + * /* + * Will output: + * { + * userCPUTime: 82872, + * systemCPUTime: 4143, + * maxRSS: 33164, + * sharedMemorySize: 0, + * unsharedDataSize: 0, + * unsharedStackSize: 0, + * minorPageFault: 2469, + * majorPageFault: 0, + * swappedOut: 0, + * fsRead: 0, + * fsWrite: 8, + * ipcSent: 0, + * ipcReceived: 0, + * signalsCount: 0, + * voluntaryContextSwitches: 79, + * involuntaryContextSwitches: 1 + * } + * + * ``` + * @since v12.6.0 + * @return the resource usage for the current process. All of these values come from the `uv_getrusage` call which returns a [`uv_rusage_t` struct][uv_rusage_t]. + */ + resourceUsage(): ResourceUsage; + /** + * The `process.traceDeprecation` property indicates whether the`--trace-deprecation` flag is set on the current Node.js process. See the + * documentation for the `'warning' event` and the `emitWarning() method` for more information about this + * flag's behavior. + * @since v0.8.0 + */ + traceDeprecation: boolean; + /* EventEmitter */ + addListener(event: "beforeExit", listener: BeforeExitListener): this; + addListener(event: "disconnect", listener: DisconnectListener): this; + addListener(event: "exit", listener: ExitListener): this; + addListener(event: "rejectionHandled", listener: RejectionHandledListener): this; + addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + addListener(event: "warning", listener: WarningListener): this; + addListener(event: "message", listener: MessageListener): this; + addListener(event: Signals, listener: SignalsListener): this; + addListener(event: "multipleResolves", listener: MultipleResolveListener): this; + addListener(event: "worker", listener: WorkerListener): this; + emit(event: "beforeExit", code: number): boolean; + emit(event: "disconnect"): boolean; + emit(event: "exit", code: number): boolean; + emit(event: "rejectionHandled", promise: Promise): boolean; + emit(event: "uncaughtException", error: Error): boolean; + emit(event: "uncaughtExceptionMonitor", error: Error): boolean; + emit(event: "unhandledRejection", reason: unknown, promise: Promise): boolean; + emit(event: "warning", warning: Error): boolean; + emit(event: "message", message: unknown, sendHandle: unknown): this; + emit(event: Signals, signal?: Signals): boolean; + emit( + event: "multipleResolves", + type: MultipleResolveType, + promise: Promise, + value: unknown, + ): this; + emit(event: "worker", listener: WorkerListener): this; + on(event: "beforeExit", listener: BeforeExitListener): this; + on(event: "disconnect", listener: DisconnectListener): this; + on(event: "exit", listener: ExitListener): this; + on(event: "rejectionHandled", listener: RejectionHandledListener): this; + on(event: "uncaughtException", listener: UncaughtExceptionListener): this; + on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + on(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + on(event: "warning", listener: WarningListener): this; + on(event: "message", listener: MessageListener): this; + on(event: Signals, listener: SignalsListener): this; + on(event: "multipleResolves", listener: MultipleResolveListener): this; + on(event: "worker", listener: WorkerListener): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "beforeExit", listener: BeforeExitListener): this; + once(event: "disconnect", listener: DisconnectListener): this; + once(event: "exit", listener: ExitListener): this; + once(event: "rejectionHandled", listener: RejectionHandledListener): this; + once(event: "uncaughtException", listener: UncaughtExceptionListener): this; + once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + once(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + once(event: "warning", listener: WarningListener): this; + once(event: "message", listener: MessageListener): this; + once(event: Signals, listener: SignalsListener): this; + once(event: "multipleResolves", listener: MultipleResolveListener): this; + once(event: "worker", listener: WorkerListener): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "beforeExit", listener: BeforeExitListener): this; + prependListener(event: "disconnect", listener: DisconnectListener): this; + prependListener(event: "exit", listener: ExitListener): this; + prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this; + prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + prependListener(event: "warning", listener: WarningListener): this; + prependListener(event: "message", listener: MessageListener): this; + prependListener(event: Signals, listener: SignalsListener): this; + prependListener(event: "multipleResolves", listener: MultipleResolveListener): this; + prependListener(event: "worker", listener: WorkerListener): this; + prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this; + prependOnceListener(event: "disconnect", listener: DisconnectListener): this; + prependOnceListener(event: "exit", listener: ExitListener): this; + prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this; + prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; + prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this; + prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; + prependOnceListener(event: "warning", listener: WarningListener): this; + prependOnceListener(event: "message", listener: MessageListener): this; + prependOnceListener(event: Signals, listener: SignalsListener): this; + prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this; + prependOnceListener(event: "worker", listener: WorkerListener): this; + listeners(event: "beforeExit"): BeforeExitListener[]; + listeners(event: "disconnect"): DisconnectListener[]; + listeners(event: "exit"): ExitListener[]; + listeners(event: "rejectionHandled"): RejectionHandledListener[]; + listeners(event: "uncaughtException"): UncaughtExceptionListener[]; + listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[]; + listeners(event: "unhandledRejection"): UnhandledRejectionListener[]; + listeners(event: "warning"): WarningListener[]; + listeners(event: "message"): MessageListener[]; + listeners(event: Signals): SignalsListener[]; + listeners(event: "multipleResolves"): MultipleResolveListener[]; + listeners(event: "worker"): WorkerListener[]; + } + } + } + export = process; +} +declare module "node:process" { + import process = require("process"); + export = process; +} diff --git a/node_modules/@types/node/ts4.8/punycode.d.ts b/node_modules/@types/node/ts4.8/punycode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2fc9f9a8ffbcffd5d9e966ef1d2b75fce902017 --- /dev/null +++ b/node_modules/@types/node/ts4.8/punycode.d.ts @@ -0,0 +1,117 @@ +/** + * **The version of the punycode module bundled in Node.js is being deprecated.**In a future major version of Node.js this module will be removed. Users + * currently depending on the `punycode` module should switch to using the + * userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL + * encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`. + * + * The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It + * can be accessed using: + * + * ```js + * const punycode = require('punycode'); + * ``` + * + * [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is + * primarily intended for use in Internationalized Domain Names. Because host + * names in URLs are limited to ASCII characters only, Domain Names that contain + * non-ASCII characters must be converted into ASCII using the Punycode scheme. + * For instance, the Japanese character that translates into the English word,`'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent + * to `'example.com'`) is represented by Punycode as the ASCII string`'xn--fsq.com'`. + * + * The `punycode` module provides a simple implementation of the Punycode standard. + * + * The `punycode` module is a third-party dependency used by Node.js and + * made available to developers as a convenience. Fixes or other modifications to + * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project. + * @deprecated Since v7.0.0 - Deprecated + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js) + */ +declare module "punycode" { + /** + * The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only + * characters to the equivalent string of Unicode codepoints. + * + * ```js + * punycode.decode('maana-pta'); // 'mañana' + * punycode.decode('--dqo34k'); // '☃-⌘' + * ``` + * @since v0.5.1 + */ + function decode(string: string): string; + /** + * The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters. + * + * ```js + * punycode.encode('mañana'); // 'maana-pta' + * punycode.encode('☃-⌘'); // '--dqo34k' + * ``` + * @since v0.5.1 + */ + function encode(string: string): string; + /** + * The `punycode.toUnicode()` method converts a string representing a domain name + * containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be + * converted. + * + * ```js + * // decode domain names + * punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com' + * punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' + * punycode.toUnicode('example.com'); // 'example.com' + * ``` + * @since v0.6.1 + */ + function toUnicode(domain: string): string; + /** + * The `punycode.toASCII()` method converts a Unicode string representing an + * Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the + * domain name will be converted. Calling `punycode.toASCII()` on a string that + * already only contains ASCII characters will have no effect. + * + * ```js + * // encode domain names + * punycode.toASCII('mañana.com'); // 'xn--maana-pta.com' + * punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' + * punycode.toASCII('example.com'); // 'example.com' + * ``` + * @since v0.6.1 + */ + function toASCII(domain: string): string; + /** + * @deprecated since v7.0.0 + * The version of the punycode module bundled in Node.js is being deprecated. + * In a future major version of Node.js this module will be removed. + * Users currently depending on the punycode module should switch to using + * the userland-provided Punycode.js module instead. + */ + const ucs2: ucs2; + interface ucs2 { + /** + * @deprecated since v7.0.0 + * The version of the punycode module bundled in Node.js is being deprecated. + * In a future major version of Node.js this module will be removed. + * Users currently depending on the punycode module should switch to using + * the userland-provided Punycode.js module instead. + */ + decode(string: string): number[]; + /** + * @deprecated since v7.0.0 + * The version of the punycode module bundled in Node.js is being deprecated. + * In a future major version of Node.js this module will be removed. + * Users currently depending on the punycode module should switch to using + * the userland-provided Punycode.js module instead. + */ + encode(codePoints: readonly number[]): string; + } + /** + * @deprecated since v7.0.0 + * The version of the punycode module bundled in Node.js is being deprecated. + * In a future major version of Node.js this module will be removed. + * Users currently depending on the punycode module should switch to using + * the userland-provided Punycode.js module instead. + */ + const version: string; +} +declare module "node:punycode" { + export * from "punycode"; +} diff --git a/node_modules/@types/node/ts4.8/querystring.d.ts b/node_modules/@types/node/ts4.8/querystring.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..54ecc967fff6e684451fc221d54f408576ac6852 --- /dev/null +++ b/node_modules/@types/node/ts4.8/querystring.d.ts @@ -0,0 +1,141 @@ +/** + * The `node:querystring` module provides utilities for parsing and formatting URL + * query strings. It can be accessed using: + * + * ```js + * const querystring = require('node:querystring'); + * ``` + * + * `querystring` is more performant than `URLSearchParams` but is not a + * standardized API. Use `URLSearchParams` when performance is not critical or + * when compatibility with browser code is desirable. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/querystring.js) + */ +declare module "querystring" { + interface StringifyOptions { + encodeURIComponent?: ((str: string) => string) | undefined; + } + interface ParseOptions { + maxKeys?: number | undefined; + decodeURIComponent?: ((str: string) => string) | undefined; + } + interface ParsedUrlQuery extends NodeJS.Dict {} + interface ParsedUrlQueryInput extends + NodeJS.Dict< + | string + | number + | boolean + | readonly string[] + | readonly number[] + | readonly boolean[] + | null + > + {} + /** + * The `querystring.stringify()` method produces a URL query string from a + * given `obj` by iterating through the object's "own properties". + * + * It serializes the following types of values passed in `obj`:[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | + * [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) | + * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) | + * [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) | + * [string\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | + * [number\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) | + * [bigint\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) | + * [boolean\[\]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) The numeric values must be finite. Any other input values will be coerced to + * empty strings. + * + * ```js + * querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' }); + * // Returns 'foo=bar&baz=qux&baz=quux&corge=' + * + * querystring.stringify({ foo: 'bar', baz: 'qux' }, ';', ':'); + * // Returns 'foo:bar;baz:qux' + * ``` + * + * By default, characters requiring percent-encoding within the query string will + * be encoded as UTF-8\. If an alternative encoding is required, then an alternative`encodeURIComponent` option will need to be specified: + * + * ```js + * // Assuming gbkEncodeURIComponent function already exists, + * + * querystring.stringify({ w: '中文', foo: 'bar' }, null, null, + * { encodeURIComponent: gbkEncodeURIComponent }); + * ``` + * @since v0.1.25 + * @param obj The object to serialize into a URL query string + * @param [sep='&'] The substring used to delimit key and value pairs in the query string. + * @param [eq='='] . The substring used to delimit keys and values in the query string. + */ + function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string; + /** + * The `querystring.parse()` method parses a URL query string (`str`) into a + * collection of key and value pairs. + * + * For example, the query string `'foo=bar&abc=xyz&abc=123'` is parsed into: + * + * ```js + * { + * foo: 'bar', + * abc: ['xyz', '123'] + * } + * ``` + * + * The object returned by the `querystring.parse()` method _does not_prototypically inherit from the JavaScript `Object`. This means that typical`Object` methods such as `obj.toString()`, + * `obj.hasOwnProperty()`, and others + * are not defined and _will not work_. + * + * By default, percent-encoded characters within the query string will be assumed + * to use UTF-8 encoding. If an alternative character encoding is used, then an + * alternative `decodeURIComponent` option will need to be specified: + * + * ```js + * // Assuming gbkDecodeURIComponent function already exists... + * + * querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null, + * { decodeURIComponent: gbkDecodeURIComponent }); + * ``` + * @since v0.1.25 + * @param str The URL query string to parse + * @param [sep='&'] The substring used to delimit key and value pairs in the query string. + * @param [eq='='] . The substring used to delimit keys and values in the query string. + */ + function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery; + /** + * The querystring.encode() function is an alias for querystring.stringify(). + */ + const encode: typeof stringify; + /** + * The querystring.decode() function is an alias for querystring.parse(). + */ + const decode: typeof parse; + /** + * The `querystring.escape()` method performs URL percent-encoding on the given`str` in a manner that is optimized for the specific requirements of URL + * query strings. + * + * The `querystring.escape()` method is used by `querystring.stringify()` and is + * generally not expected to be used directly. It is exported primarily to allow + * application code to provide a replacement percent-encoding implementation if + * necessary by assigning `querystring.escape` to an alternative function. + * @since v0.1.25 + */ + function escape(str: string): string; + /** + * The `querystring.unescape()` method performs decoding of URL percent-encoded + * characters on the given `str`. + * + * The `querystring.unescape()` method is used by `querystring.parse()` and is + * generally not expected to be used directly. It is exported primarily to allow + * application code to provide a replacement decoding implementation if + * necessary by assigning `querystring.unescape` to an alternative function. + * + * By default, the `querystring.unescape()` method will attempt to use the + * JavaScript built-in `decodeURIComponent()` method to decode. If that fails, + * a safer equivalent that does not throw on malformed URLs will be used. + * @since v0.1.25 + */ + function unescape(str: string): string; +} +declare module "node:querystring" { + export * from "querystring"; +} diff --git a/node_modules/@types/node/ts4.8/readline.d.ts b/node_modules/@types/node/ts4.8/readline.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b06d58b85e62c03ff7d388177c9dce7bdde86569 --- /dev/null +++ b/node_modules/@types/node/ts4.8/readline.d.ts @@ -0,0 +1,539 @@ +/** + * The `node:readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time. + * + * To use the promise-based APIs: + * + * ```js + * import * as readline from 'node:readline/promises'; + * ``` + * + * To use the callback and sync APIs: + * + * ```js + * import * as readline from 'node:readline'; + * ``` + * + * The following simple example illustrates the basic use of the `node:readline`module. + * + * ```js + * import * as readline from 'node:readline/promises'; + * import { stdin as input, stdout as output } from 'node:process'; + * + * const rl = readline.createInterface({ input, output }); + * + * const answer = await rl.question('What do you think of Node.js? '); + * + * console.log(`Thank you for your valuable feedback: ${answer}`); + * + * rl.close(); + * ``` + * + * Once this code is invoked, the Node.js application will not terminate until the`readline.Interface` is closed because the interface waits for data to be + * received on the `input` stream. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/readline.js) + */ +declare module "readline" { + import { Abortable, EventEmitter } from "node:events"; + import * as promises from "node:readline/promises"; + export { promises }; + export interface Key { + sequence?: string | undefined; + name?: string | undefined; + ctrl?: boolean | undefined; + meta?: boolean | undefined; + shift?: boolean | undefined; + } + /** + * Instances of the `readline.Interface` class are constructed using the`readline.createInterface()` method. Every instance is associated with a + * single `input` `Readable` stream and a single `output` `Writable` stream. + * The `output` stream is used to print prompts for user input that arrives on, + * and is read from, the `input` stream. + * @since v0.1.104 + */ + export class Interface extends EventEmitter { + readonly terminal: boolean; + /** + * The current input data being processed by node. + * + * This can be used when collecting input from a TTY stream to retrieve the + * current value that has been processed thus far, prior to the `line` event + * being emitted. Once the `line` event has been emitted, this property will + * be an empty string. + * + * Be aware that modifying the value during the instance runtime may have + * unintended consequences if `rl.cursor` is not also controlled. + * + * **If not using a TTY stream for input, use the `'line'` event.** + * + * One possible use case would be as follows: + * + * ```js + * const values = ['lorem ipsum', 'dolor sit amet']; + * const rl = readline.createInterface(process.stdin); + * const showResults = debounce(() => { + * console.log( + * '\n', + * values.filter((val) => val.startsWith(rl.line)).join(' '), + * ); + * }, 300); + * process.stdin.on('keypress', (c, k) => { + * showResults(); + * }); + * ``` + * @since v0.1.98 + */ + readonly line: string; + /** + * The cursor position relative to `rl.line`. + * + * This will track where the current cursor lands in the input string, when + * reading input from a TTY stream. The position of cursor determines the + * portion of the input string that will be modified as input is processed, + * as well as the column where the terminal caret will be rendered. + * @since v0.1.98 + */ + readonly cursor: number; + /** + * NOTE: According to the documentation: + * + * > Instances of the `readline.Interface` class are constructed using the + * > `readline.createInterface()` method. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor + */ + protected constructor( + input: NodeJS.ReadableStream, + output?: NodeJS.WritableStream, + completer?: Completer | AsyncCompleter, + terminal?: boolean, + ); + /** + * NOTE: According to the documentation: + * + * > Instances of the `readline.Interface` class are constructed using the + * > `readline.createInterface()` method. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor + */ + protected constructor(options: ReadLineOptions); + /** + * The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`. + * @since v15.3.0, v14.17.0 + * @return the current prompt string + */ + getPrompt(): string; + /** + * The `rl.setPrompt()` method sets the prompt that will be written to `output`whenever `rl.prompt()` is called. + * @since v0.1.98 + */ + setPrompt(prompt: string): void; + /** + * The `rl.prompt()` method writes the `Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new + * location at which to provide input. + * + * When called, `rl.prompt()` will resume the `input` stream if it has been + * paused. + * + * If the `Interface` was created with `output` set to `null` or`undefined` the prompt is not written. + * @since v0.1.98 + * @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`. + */ + prompt(preserveCursor?: boolean): void; + /** + * The `rl.question()` method displays the `query` by writing it to the `output`, + * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument. + * + * When called, `rl.question()` will resume the `input` stream if it has been + * paused. + * + * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. + * + * The `callback` function passed to `rl.question()` does not follow the typical + * pattern of accepting an `Error` object or `null` as the first argument. + * The `callback` is called with the provided answer as the only argument. + * + * An error will be thrown if calling `rl.question()` after `rl.close()`. + * + * Example usage: + * + * ```js + * rl.question('What is your favorite food? ', (answer) => { + * console.log(`Oh, so your favorite food is ${answer}`); + * }); + * ``` + * + * Using an `AbortController` to cancel a question. + * + * ```js + * const ac = new AbortController(); + * const signal = ac.signal; + * + * rl.question('What is your favorite food? ', { signal }, (answer) => { + * console.log(`Oh, so your favorite food is ${answer}`); + * }); + * + * signal.addEventListener('abort', () => { + * console.log('The food question timed out'); + * }, { once: true }); + * + * setTimeout(() => ac.abort(), 10000); + * ``` + * @since v0.3.3 + * @param query A statement or query to write to `output`, prepended to the prompt. + * @param callback A callback function that is invoked with the user's input in response to the `query`. + */ + question(query: string, callback: (answer: string) => void): void; + question(query: string, options: Abortable, callback: (answer: string) => void): void; + /** + * The `rl.pause()` method pauses the `input` stream, allowing it to be resumed + * later if necessary. + * + * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `Interface` instance. + * @since v0.3.4 + */ + pause(): this; + /** + * The `rl.resume()` method resumes the `input` stream if it has been paused. + * @since v0.3.4 + */ + resume(): this; + /** + * The `rl.close()` method closes the `Interface` instance and + * relinquishes control over the `input` and `output` streams. When called, + * the `'close'` event will be emitted. + * + * Calling `rl.close()` does not immediately stop other events (including `'line'`) + * from being emitted by the `Interface` instance. + * @since v0.1.98 + */ + close(): void; + /** + * The `rl.write()` method will write either `data` or a key sequence identified + * by `key` to the `output`. The `key` argument is supported only if `output` is + * a `TTY` text terminal. See `TTY keybindings` for a list of key + * combinations. + * + * If `key` is specified, `data` is ignored. + * + * When called, `rl.write()` will resume the `input` stream if it has been + * paused. + * + * If the `Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written. + * + * ```js + * rl.write('Delete this!'); + * // Simulate Ctrl+U to delete the line written previously + * rl.write(null, { ctrl: true, name: 'u' }); + * ``` + * + * The `rl.write()` method will write the data to the `readline` `Interface`'s`input`_as if it were provided by the user_. + * @since v0.1.98 + */ + write(data: string | Buffer, key?: Key): void; + write(data: undefined | null | string | Buffer, key: Key): void; + /** + * Returns the real position of the cursor in relation to the input + * prompt + string. Long input (wrapping) strings, as well as multiple + * line prompts are included in the calculations. + * @since v13.5.0, v12.16.0 + */ + getCursorPos(): CursorPos; + /** + * events.EventEmitter + * 1. close + * 2. line + * 3. pause + * 4. resume + * 5. SIGCONT + * 6. SIGINT + * 7. SIGTSTP + * 8. history + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "line", listener: (input: string) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: "SIGCONT", listener: () => void): this; + addListener(event: "SIGINT", listener: () => void): this; + addListener(event: "SIGTSTP", listener: () => void): this; + addListener(event: "history", listener: (history: string[]) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "line", input: string): boolean; + emit(event: "pause"): boolean; + emit(event: "resume"): boolean; + emit(event: "SIGCONT"): boolean; + emit(event: "SIGINT"): boolean; + emit(event: "SIGTSTP"): boolean; + emit(event: "history", history: string[]): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "line", listener: (input: string) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: "SIGCONT", listener: () => void): this; + on(event: "SIGINT", listener: () => void): this; + on(event: "SIGTSTP", listener: () => void): this; + on(event: "history", listener: (history: string[]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "line", listener: (input: string) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: "SIGCONT", listener: () => void): this; + once(event: "SIGINT", listener: () => void): this; + once(event: "SIGTSTP", listener: () => void): this; + once(event: "history", listener: (history: string[]) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "line", listener: (input: string) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: "SIGCONT", listener: () => void): this; + prependListener(event: "SIGINT", listener: () => void): this; + prependListener(event: "SIGTSTP", listener: () => void): this; + prependListener(event: "history", listener: (history: string[]) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "line", listener: (input: string) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: "SIGCONT", listener: () => void): this; + prependOnceListener(event: "SIGINT", listener: () => void): this; + prependOnceListener(event: "SIGTSTP", listener: () => void): this; + prependOnceListener(event: "history", listener: (history: string[]) => void): this; + [Symbol.asyncIterator](): AsyncIterableIterator; + } + export type ReadLine = Interface; // type forwarded for backwards compatibility + export type Completer = (line: string) => CompleterResult; + export type AsyncCompleter = ( + line: string, + callback: (err?: null | Error, result?: CompleterResult) => void, + ) => void; + export type CompleterResult = [string[], string]; + export interface ReadLineOptions { + input: NodeJS.ReadableStream; + output?: NodeJS.WritableStream | undefined; + completer?: Completer | AsyncCompleter | undefined; + terminal?: boolean | undefined; + /** + * Initial list of history lines. This option makes sense + * only if `terminal` is set to `true` by the user or by an internal `output` + * check, otherwise the history caching mechanism is not initialized at all. + * @default [] + */ + history?: string[] | undefined; + historySize?: number | undefined; + prompt?: string | undefined; + crlfDelay?: number | undefined; + /** + * If `true`, when a new input line added + * to the history list duplicates an older one, this removes the older line + * from the list. + * @default false + */ + removeHistoryDuplicates?: boolean | undefined; + escapeCodeTimeout?: number | undefined; + tabSize?: number | undefined; + } + /** + * The `readline.createInterface()` method creates a new `readline.Interface`instance. + * + * ```js + * const readline = require('node:readline'); + * const rl = readline.createInterface({ + * input: process.stdin, + * output: process.stdout, + * }); + * ``` + * + * Once the `readline.Interface` instance is created, the most common case is to + * listen for the `'line'` event: + * + * ```js + * rl.on('line', (line) => { + * console.log(`Received: ${line}`); + * }); + * ``` + * + * If `terminal` is `true` for this instance then the `output` stream will get + * the best compatibility if it defines an `output.columns` property and emits + * a `'resize'` event on the `output` if or when the columns ever change + * (`process.stdout` does this automatically when it is a TTY). + * + * When creating a `readline.Interface` using `stdin` as input, the program + * will not terminate until it receives an [EOF character](https://en.wikipedia.org/wiki/End-of-file#EOF_character). To exit without + * waiting for user input, call `process.stdin.unref()`. + * @since v0.1.98 + */ + export function createInterface( + input: NodeJS.ReadableStream, + output?: NodeJS.WritableStream, + completer?: Completer | AsyncCompleter, + terminal?: boolean, + ): Interface; + export function createInterface(options: ReadLineOptions): Interface; + /** + * The `readline.emitKeypressEvents()` method causes the given `Readable` stream to begin emitting `'keypress'` events corresponding to received input. + * + * Optionally, `interface` specifies a `readline.Interface` instance for which + * autocompletion is disabled when copy-pasted input is detected. + * + * If the `stream` is a `TTY`, then it must be in raw mode. + * + * This is automatically called by any readline instance on its `input` if the`input` is a terminal. Closing the `readline` instance does not stop + * the `input` from emitting `'keypress'` events. + * + * ```js + * readline.emitKeypressEvents(process.stdin); + * if (process.stdin.isTTY) + * process.stdin.setRawMode(true); + * ``` + * + * ## Example: Tiny CLI + * + * The following example illustrates the use of `readline.Interface` class to + * implement a small command-line interface: + * + * ```js + * const readline = require('node:readline'); + * const rl = readline.createInterface({ + * input: process.stdin, + * output: process.stdout, + * prompt: 'OHAI> ', + * }); + * + * rl.prompt(); + * + * rl.on('line', (line) => { + * switch (line.trim()) { + * case 'hello': + * console.log('world!'); + * break; + * default: + * console.log(`Say what? I might have heard '${line.trim()}'`); + * break; + * } + * rl.prompt(); + * }).on('close', () => { + * console.log('Have a great day!'); + * process.exit(0); + * }); + * ``` + * + * ## Example: Read file stream line-by-Line + * + * A common use case for `readline` is to consume an input file one line at a + * time. The easiest way to do so is leveraging the `fs.ReadStream` API as + * well as a `for await...of` loop: + * + * ```js + * const fs = require('node:fs'); + * const readline = require('node:readline'); + * + * async function processLineByLine() { + * const fileStream = fs.createReadStream('input.txt'); + * + * const rl = readline.createInterface({ + * input: fileStream, + * crlfDelay: Infinity, + * }); + * // Note: we use the crlfDelay option to recognize all instances of CR LF + * // ('\r\n') in input.txt as a single line break. + * + * for await (const line of rl) { + * // Each line in input.txt will be successively available here as `line`. + * console.log(`Line from file: ${line}`); + * } + * } + * + * processLineByLine(); + * ``` + * + * Alternatively, one could use the `'line'` event: + * + * ```js + * const fs = require('node:fs'); + * const readline = require('node:readline'); + * + * const rl = readline.createInterface({ + * input: fs.createReadStream('sample.txt'), + * crlfDelay: Infinity, + * }); + * + * rl.on('line', (line) => { + * console.log(`Line from file: ${line}`); + * }); + * ``` + * + * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied: + * + * ```js + * const { once } = require('node:events'); + * const { createReadStream } = require('node:fs'); + * const { createInterface } = require('node:readline'); + * + * (async function processLineByLine() { + * try { + * const rl = createInterface({ + * input: createReadStream('big-file.txt'), + * crlfDelay: Infinity, + * }); + * + * rl.on('line', (line) => { + * // Process the line. + * }); + * + * await once(rl, 'close'); + * + * console.log('File processed.'); + * } catch (err) { + * console.error(err); + * } + * })(); + * ``` + * @since v0.7.7 + */ + export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void; + export type Direction = -1 | 0 | 1; + export interface CursorPos { + rows: number; + cols: number; + } + /** + * The `readline.clearLine()` method clears current line of given `TTY` stream + * in a specified direction identified by `dir`. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean; + /** + * The `readline.clearScreenDown()` method clears the given `TTY` stream from + * the current position of the cursor down. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean; + /** + * The `readline.cursorTo()` method moves cursor to the specified position in a + * given `TTY` `stream`. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean; + /** + * The `readline.moveCursor()` method moves the cursor _relative_ to its current + * position in a given `TTY` `stream`. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + export function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean; +} +declare module "node:readline" { + export * from "readline"; +} diff --git a/node_modules/@types/node/ts4.8/readline/promises.d.ts b/node_modules/@types/node/ts4.8/readline/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..73fb1115d50096f9e6bcadf04943a597c5146312 --- /dev/null +++ b/node_modules/@types/node/ts4.8/readline/promises.d.ts @@ -0,0 +1,150 @@ +/** + * @since v17.0.0 + * @experimental + */ +declare module "readline/promises" { + import { AsyncCompleter, Completer, Direction, Interface as _Interface, ReadLineOptions } from "node:readline"; + import { Abortable } from "node:events"; + /** + * Instances of the `readlinePromises.Interface` class are constructed using the`readlinePromises.createInterface()` method. Every instance is associated with a + * single `input` `Readable` stream and a single `output` `Writable` stream. + * The `output` stream is used to print prompts for user input that arrives on, + * and is read from, the `input` stream. + * @since v17.0.0 + */ + class Interface extends _Interface { + /** + * The `rl.question()` method displays the `query` by writing it to the `output`, + * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument. + * + * When called, `rl.question()` will resume the `input` stream if it has been + * paused. + * + * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. + * + * If the question is called after `rl.close()`, it returns a rejected promise. + * + * Example usage: + * + * ```js + * const answer = await rl.question('What is your favorite food? '); + * console.log(`Oh, so your favorite food is ${answer}`); + * ``` + * + * Using an `AbortSignal` to cancel a question. + * + * ```js + * const signal = AbortSignal.timeout(10_000); + * + * signal.addEventListener('abort', () => { + * console.log('The food question timed out'); + * }, { once: true }); + * + * const answer = await rl.question('What is your favorite food? ', { signal }); + * console.log(`Oh, so your favorite food is ${answer}`); + * ``` + * @since v17.0.0 + * @param query A statement or query to write to `output`, prepended to the prompt. + * @return A promise that is fulfilled with the user's input in response to the `query`. + */ + question(query: string): Promise; + question(query: string, options: Abortable): Promise; + } + /** + * @since v17.0.0 + */ + class Readline { + /** + * @param stream A TTY stream. + */ + constructor( + stream: NodeJS.WritableStream, + options?: { + autoCommit?: boolean; + }, + ); + /** + * The `rl.clearLine()` method adds to the internal list of pending action an + * action that clears current line of the associated `stream` in a specified + * direction identified by `dir`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this + */ + clearLine(dir: Direction): this; + /** + * The `rl.clearScreenDown()` method adds to the internal list of pending action an + * action that clears the associated stream from the current position of the + * cursor down. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this + */ + clearScreenDown(): this; + /** + * The `rl.commit()` method sends all the pending actions to the associated`stream` and clears the internal list of pending actions. + * @since v17.0.0 + */ + commit(): Promise; + /** + * The `rl.cursorTo()` method adds to the internal list of pending action an action + * that moves cursor to the specified position in the associated `stream`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this + */ + cursorTo(x: number, y?: number): this; + /** + * The `rl.moveCursor()` method adds to the internal list of pending action an + * action that moves the cursor _relative_ to its current position in the + * associated `stream`. + * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. + * @since v17.0.0 + * @return this + */ + moveCursor(dx: number, dy: number): this; + /** + * The `rl.rollback` methods clears the internal list of pending actions without + * sending it to the associated `stream`. + * @since v17.0.0 + * @return this + */ + rollback(): this; + } + /** + * The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface`instance. + * + * ```js + * const readlinePromises = require('node:readline/promises'); + * const rl = readlinePromises.createInterface({ + * input: process.stdin, + * output: process.stdout, + * }); + * ``` + * + * Once the `readlinePromises.Interface` instance is created, the most common case + * is to listen for the `'line'` event: + * + * ```js + * rl.on('line', (line) => { + * console.log(`Received: ${line}`); + * }); + * ``` + * + * If `terminal` is `true` for this instance then the `output` stream will get + * the best compatibility if it defines an `output.columns` property and emits + * a `'resize'` event on the `output` if or when the columns ever change + * (`process.stdout` does this automatically when it is a TTY). + * @since v17.0.0 + */ + function createInterface( + input: NodeJS.ReadableStream, + output?: NodeJS.WritableStream, + completer?: Completer | AsyncCompleter, + terminal?: boolean, + ): Interface; + function createInterface(options: ReadLineOptions): Interface; +} +declare module "node:readline/promises" { + export * from "readline/promises"; +} diff --git a/node_modules/@types/node/ts4.8/repl.d.ts b/node_modules/@types/node/ts4.8/repl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c5f81b399df50506180bd8d271840029659572b --- /dev/null +++ b/node_modules/@types/node/ts4.8/repl.d.ts @@ -0,0 +1,430 @@ +/** + * The `node:repl` module provides a Read-Eval-Print-Loop (REPL) implementation + * that is available both as a standalone program or includible in other + * applications. It can be accessed using: + * + * ```js + * const repl = require('node:repl'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/repl.js) + */ +declare module "repl" { + import { AsyncCompleter, Completer, Interface } from "node:readline"; + import { Context } from "node:vm"; + import { InspectOptions } from "node:util"; + interface ReplOptions { + /** + * The input prompt to display. + * @default "> " + */ + prompt?: string | undefined; + /** + * The `Readable` stream from which REPL input will be read. + * @default process.stdin + */ + input?: NodeJS.ReadableStream | undefined; + /** + * The `Writable` stream to which REPL output will be written. + * @default process.stdout + */ + output?: NodeJS.WritableStream | undefined; + /** + * If `true`, specifies that the output should be treated as a TTY terminal, and have + * ANSI/VT100 escape codes written to it. + * Default: checking the value of the `isTTY` property on the output stream upon + * instantiation. + */ + terminal?: boolean | undefined; + /** + * The function to be used when evaluating each given line of input. + * Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can + * error with `repl.Recoverable` to indicate the input was incomplete and prompt for + * additional lines. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_default_evaluation + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_custom_evaluation_functions + */ + eval?: REPLEval | undefined; + /** + * Defines if the repl prints output previews or not. + * @default `true` Always `false` in case `terminal` is falsy. + */ + preview?: boolean | undefined; + /** + * If `true`, specifies that the default `writer` function should include ANSI color + * styling to REPL output. If a custom `writer` function is provided then this has no + * effect. + * Default: the REPL instance's `terminal` value. + */ + useColors?: boolean | undefined; + /** + * If `true`, specifies that the default evaluation function will use the JavaScript + * `global` as the context as opposed to creating a new separate context for the REPL + * instance. The node CLI REPL sets this value to `true`. + * Default: `false`. + */ + useGlobal?: boolean | undefined; + /** + * If `true`, specifies that the default writer will not output the return value of a + * command if it evaluates to `undefined`. + * Default: `false`. + */ + ignoreUndefined?: boolean | undefined; + /** + * The function to invoke to format the output of each command before writing to `output`. + * Default: a wrapper for `util.inspect`. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_customizing_repl_output + */ + writer?: REPLWriter | undefined; + /** + * An optional function used for custom Tab auto completion. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#readline_use_of_the_completer_function + */ + completer?: Completer | AsyncCompleter | undefined; + /** + * A flag that specifies whether the default evaluator executes all JavaScript commands in + * strict mode or default (sloppy) mode. + * Accepted values are: + * - `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode. + * - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to + * prefacing every repl statement with `'use strict'`. + */ + replMode?: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT | undefined; + /** + * Stop evaluating the current piece of code when `SIGINT` is received, i.e. `Ctrl+C` is + * pressed. This cannot be used together with a custom `eval` function. + * Default: `false`. + */ + breakEvalOnSigint?: boolean | undefined; + } + type REPLEval = ( + this: REPLServer, + evalCmd: string, + context: Context, + file: string, + cb: (err: Error | null, result: any) => void, + ) => void; + type REPLWriter = (this: REPLServer, obj: any) => string; + /** + * This is the default "writer" value, if none is passed in the REPL options, + * and it can be overridden by custom print functions. + */ + const writer: REPLWriter & { + options: InspectOptions; + }; + type REPLCommandAction = (this: REPLServer, text: string) => void; + interface REPLCommand { + /** + * Help text to be displayed when `.help` is entered. + */ + help?: string | undefined; + /** + * The function to execute, optionally accepting a single string argument. + */ + action: REPLCommandAction; + } + /** + * Instances of `repl.REPLServer` are created using the {@link start} method + * or directly using the JavaScript `new` keyword. + * + * ```js + * const repl = require('node:repl'); + * + * const options = { useColors: true }; + * + * const firstInstance = repl.start(options); + * const secondInstance = new repl.REPLServer(options); + * ``` + * @since v0.1.91 + */ + class REPLServer extends Interface { + /** + * The `vm.Context` provided to the `eval` function to be used for JavaScript + * evaluation. + */ + readonly context: Context; + /** + * @deprecated since v14.3.0 - Use `input` instead. + */ + readonly inputStream: NodeJS.ReadableStream; + /** + * @deprecated since v14.3.0 - Use `output` instead. + */ + readonly outputStream: NodeJS.WritableStream; + /** + * The `Readable` stream from which REPL input will be read. + */ + readonly input: NodeJS.ReadableStream; + /** + * The `Writable` stream to which REPL output will be written. + */ + readonly output: NodeJS.WritableStream; + /** + * The commands registered via `replServer.defineCommand()`. + */ + readonly commands: NodeJS.ReadOnlyDict; + /** + * A value indicating whether the REPL is currently in "editor mode". + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_commands_and_special_keys + */ + readonly editorMode: boolean; + /** + * A value indicating whether the `_` variable has been assigned. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + */ + readonly underscoreAssigned: boolean; + /** + * The last evaluation result from the REPL (assigned to the `_` variable inside of the REPL). + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + */ + readonly last: any; + /** + * A value indicating whether the `_error` variable has been assigned. + * + * @since v9.8.0 + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + */ + readonly underscoreErrAssigned: boolean; + /** + * The last error raised inside the REPL (assigned to the `_error` variable inside of the REPL). + * + * @since v9.8.0 + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable + */ + readonly lastError: any; + /** + * Specified in the REPL options, this is the function to be used when evaluating each + * given line of input. If not specified in the REPL options, this is an async wrapper + * for the JavaScript `eval()` function. + */ + readonly eval: REPLEval; + /** + * Specified in the REPL options, this is a value indicating whether the default + * `writer` function should include ANSI color styling to REPL output. + */ + readonly useColors: boolean; + /** + * Specified in the REPL options, this is a value indicating whether the default `eval` + * function will use the JavaScript `global` as the context as opposed to creating a new + * separate context for the REPL instance. + */ + readonly useGlobal: boolean; + /** + * Specified in the REPL options, this is a value indicating whether the default `writer` + * function should output the result of a command if it evaluates to `undefined`. + */ + readonly ignoreUndefined: boolean; + /** + * Specified in the REPL options, this is the function to invoke to format the output of + * each command before writing to `outputStream`. If not specified in the REPL options, + * this will be a wrapper for `util.inspect`. + */ + readonly writer: REPLWriter; + /** + * Specified in the REPL options, this is the function to use for custom Tab auto-completion. + */ + readonly completer: Completer | AsyncCompleter; + /** + * Specified in the REPL options, this is a flag that specifies whether the default `eval` + * function should execute all JavaScript commands in strict mode or default (sloppy) mode. + * Possible values are: + * - `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode. + * - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to + * prefacing every repl statement with `'use strict'`. + */ + readonly replMode: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT; + /** + * NOTE: According to the documentation: + * + * > Instances of `repl.REPLServer` are created using the `repl.start()` method and + * > _should not_ be created directly using the JavaScript `new` keyword. + * + * `REPLServer` cannot be subclassed due to implementation specifics in NodeJS. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_class_replserver + */ + private constructor(); + /** + * The `replServer.defineCommand()` method is used to add new `.`\-prefixed commands + * to the REPL instance. Such commands are invoked by typing a `.` followed by the`keyword`. The `cmd` is either a `Function` or an `Object` with the following + * properties: + * + * The following example shows two new commands added to the REPL instance: + * + * ```js + * const repl = require('node:repl'); + * + * const replServer = repl.start({ prompt: '> ' }); + * replServer.defineCommand('sayhello', { + * help: 'Say hello', + * action(name) { + * this.clearBufferedCommand(); + * console.log(`Hello, ${name}!`); + * this.displayPrompt(); + * }, + * }); + * replServer.defineCommand('saybye', function saybye() { + * console.log('Goodbye!'); + * this.close(); + * }); + * ``` + * + * The new commands can then be used from within the REPL instance: + * + * ```console + * > .sayhello Node.js User + * Hello, Node.js User! + * > .saybye + * Goodbye! + * ``` + * @since v0.3.0 + * @param keyword The command keyword (_without_ a leading `.` character). + * @param cmd The function to invoke when the command is processed. + */ + defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void; + /** + * The `replServer.displayPrompt()` method readies the REPL instance for input + * from the user, printing the configured `prompt` to a new line in the `output`and resuming the `input` to accept new input. + * + * When multi-line input is being entered, an ellipsis is printed rather than the + * 'prompt'. + * + * When `preserveCursor` is `true`, the cursor placement will not be reset to `0`. + * + * The `replServer.displayPrompt` method is primarily intended to be called from + * within the action function for commands registered using the`replServer.defineCommand()` method. + * @since v0.1.91 + */ + displayPrompt(preserveCursor?: boolean): void; + /** + * The `replServer.clearBufferedCommand()` method clears any command that has been + * buffered but not yet executed. This method is primarily intended to be + * called from within the action function for commands registered using the`replServer.defineCommand()` method. + * @since v9.0.0 + */ + clearBufferedCommand(): void; + /** + * Initializes a history log file for the REPL instance. When executing the + * Node.js binary and using the command-line REPL, a history file is initialized + * by default. However, this is not the case when creating a REPL + * programmatically. Use this method to initialize a history log file when working + * with REPL instances programmatically. + * @since v11.10.0 + * @param historyPath the path to the history file + * @param callback called when history writes are ready or upon error + */ + setupHistory(path: string, callback: (err: Error | null, repl: this) => void): void; + /** + * events.EventEmitter + * 1. close - inherited from `readline.Interface` + * 2. line - inherited from `readline.Interface` + * 3. pause - inherited from `readline.Interface` + * 4. resume - inherited from `readline.Interface` + * 5. SIGCONT - inherited from `readline.Interface` + * 6. SIGINT - inherited from `readline.Interface` + * 7. SIGTSTP - inherited from `readline.Interface` + * 8. exit + * 9. reset + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "line", listener: (input: string) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: "SIGCONT", listener: () => void): this; + addListener(event: "SIGINT", listener: () => void): this; + addListener(event: "SIGTSTP", listener: () => void): this; + addListener(event: "exit", listener: () => void): this; + addListener(event: "reset", listener: (context: Context) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "line", input: string): boolean; + emit(event: "pause"): boolean; + emit(event: "resume"): boolean; + emit(event: "SIGCONT"): boolean; + emit(event: "SIGINT"): boolean; + emit(event: "SIGTSTP"): boolean; + emit(event: "exit"): boolean; + emit(event: "reset", context: Context): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "close", listener: () => void): this; + on(event: "line", listener: (input: string) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: "SIGCONT", listener: () => void): this; + on(event: "SIGINT", listener: () => void): this; + on(event: "SIGTSTP", listener: () => void): this; + on(event: "exit", listener: () => void): this; + on(event: "reset", listener: (context: Context) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "line", listener: (input: string) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: "SIGCONT", listener: () => void): this; + once(event: "SIGINT", listener: () => void): this; + once(event: "SIGTSTP", listener: () => void): this; + once(event: "exit", listener: () => void): this; + once(event: "reset", listener: (context: Context) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "line", listener: (input: string) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: "SIGCONT", listener: () => void): this; + prependListener(event: "SIGINT", listener: () => void): this; + prependListener(event: "SIGTSTP", listener: () => void): this; + prependListener(event: "exit", listener: () => void): this; + prependListener(event: "reset", listener: (context: Context) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "line", listener: (input: string) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: "SIGCONT", listener: () => void): this; + prependOnceListener(event: "SIGINT", listener: () => void): this; + prependOnceListener(event: "SIGTSTP", listener: () => void): this; + prependOnceListener(event: "exit", listener: () => void): this; + prependOnceListener(event: "reset", listener: (context: Context) => void): this; + } + /** + * A flag passed in the REPL options. Evaluates expressions in sloppy mode. + */ + const REPL_MODE_SLOPPY: unique symbol; + /** + * A flag passed in the REPL options. Evaluates expressions in strict mode. + * This is equivalent to prefacing every repl statement with `'use strict'`. + */ + const REPL_MODE_STRICT: unique symbol; + /** + * The `repl.start()` method creates and starts a {@link REPLServer} instance. + * + * If `options` is a string, then it specifies the input prompt: + * + * ```js + * const repl = require('node:repl'); + * + * // a Unix style prompt + * repl.start('$ '); + * ``` + * @since v0.1.91 + */ + function start(options?: string | ReplOptions): REPLServer; + /** + * Indicates a recoverable error that a `REPLServer` can use to support multi-line input. + * + * @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_recoverable_errors + */ + class Recoverable extends SyntaxError { + err: Error; + constructor(err: Error); + } +} +declare module "node:repl" { + export * from "repl"; +} diff --git a/node_modules/@types/node/ts4.8/stream.d.ts b/node_modules/@types/node/ts4.8/stream.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..15c633fcf55f300809d5681a1c0aa9ba4728ea32 --- /dev/null +++ b/node_modules/@types/node/ts4.8/stream.d.ts @@ -0,0 +1,1701 @@ +/** + * A stream is an abstract interface for working with streaming data in Node.js. + * The `node:stream` module provides an API for implementing the stream interface. + * + * There are many stream objects provided by Node.js. For instance, a `request to an HTTP server` and `process.stdout` are both stream instances. + * + * Streams can be readable, writable, or both. All streams are instances of `EventEmitter`. + * + * To access the `node:stream` module: + * + * ```js + * const stream = require('node:stream'); + * ``` + * + * The `node:stream` module is useful for creating new types of stream instances. + * It is usually not necessary to use the `node:stream` module to consume streams. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/stream.js) + */ +declare module "stream" { + import { Abortable, EventEmitter } from "node:events"; + import { Blob as NodeBlob } from "node:buffer"; + import * as streamPromises from "node:stream/promises"; + import * as streamConsumers from "node:stream/consumers"; + import * as streamWeb from "node:stream/web"; + + type ComposeFnParam = (source: any) => void; + + class internal extends EventEmitter { + pipe( + destination: T, + options?: { + end?: boolean | undefined; + }, + ): T; + compose( + stream: T | ComposeFnParam | Iterable | AsyncIterable, + options?: { signal: AbortSignal }, + ): T; + } + import Stream = internal.Stream; + import Readable = internal.Readable; + import ReadableOptions = internal.ReadableOptions; + interface ArrayOptions { + /** the maximum concurrent invocations of `fn` to call on the stream at once. **Default: 1**. */ + concurrency?: number; + /** allows destroying the stream if the signal is aborted. */ + signal?: AbortSignal; + } + class ReadableBase extends Stream implements NodeJS.ReadableStream { + /** + * A utility method for creating Readable Streams out of iterators. + */ + static from(iterable: Iterable | AsyncIterable, options?: ReadableOptions): Readable; + /** + * Returns whether the stream has been read from or cancelled. + * @since v16.8.0 + */ + static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean; + /** + * Returns whether the stream was destroyed or errored before emitting `'end'`. + * @since v16.8.0 + * @experimental + */ + readonly readableAborted: boolean; + /** + * Is `true` if it is safe to call `readable.read()`, which means + * the stream has not been destroyed or emitted `'error'` or `'end'`. + * @since v11.4.0 + */ + readable: boolean; + /** + * Returns whether `'data'` has been emitted. + * @since v16.7.0, v14.18.0 + * @experimental + */ + readonly readableDidRead: boolean; + /** + * Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method. + * @since v12.7.0 + */ + readonly readableEncoding: BufferEncoding | null; + /** + * Becomes `true` when `'end'` event is emitted. + * @since v12.9.0 + */ + readonly readableEnded: boolean; + /** + * This property reflects the current state of a `Readable` stream as described + * in the `Three states` section. + * @since v9.4.0 + */ + readonly readableFlowing: boolean | null; + /** + * Returns the value of `highWaterMark` passed when creating this `Readable`. + * @since v9.3.0 + */ + readonly readableHighWaterMark: number; + /** + * This property contains the number of bytes (or objects) in the queue + * ready to be read. The value provides introspection data regarding + * the status of the `highWaterMark`. + * @since v9.4.0 + */ + readonly readableLength: number; + /** + * Getter for the property `objectMode` of a given `Readable` stream. + * @since v12.3.0 + */ + readonly readableObjectMode: boolean; + /** + * Is `true` after `readable.destroy()` has been called. + * @since v8.0.0 + */ + destroyed: boolean; + /** + * Is `true` after `'close'` has been emitted. + * @since v18.0.0 + */ + readonly closed: boolean; + /** + * Returns error if the stream has been destroyed with an error. + * @since v18.0.0 + */ + readonly errored: Error | null; + constructor(opts?: ReadableOptions); + _construct?(callback: (error?: Error | null) => void): void; + _read(size: number): void; + /** + * The `readable.read()` method reads data out of the internal buffer and + * returns it. If no data is available to be read, `null` is returned. By default, + * the data is returned as a `Buffer` object unless an encoding has been + * specified using the `readable.setEncoding()` method or the stream is operating + * in object mode. + * + * The optional `size` argument specifies a specific number of bytes to read. If`size` bytes are not available to be read, `null` will be returned _unless_the stream has ended, in which + * case all of the data remaining in the internal + * buffer will be returned. + * + * If the `size` argument is not specified, all of the data contained in the + * internal buffer will be returned. + * + * The `size` argument must be less than or equal to 1 GiB. + * + * The `readable.read()` method should only be called on `Readable` streams + * operating in paused mode. In flowing mode, `readable.read()` is called + * automatically until the internal buffer is fully drained. + * + * ```js + * const readable = getReadableStreamSomehow(); + * + * // 'readable' may be triggered multiple times as data is buffered in + * readable.on('readable', () => { + * let chunk; + * console.log('Stream is readable (new data received in buffer)'); + * // Use a loop to make sure we read all currently available data + * while (null !== (chunk = readable.read())) { + * console.log(`Read ${chunk.length} bytes of data...`); + * } + * }); + * + * // 'end' will be triggered once when there is no more data available + * readable.on('end', () => { + * console.log('Reached end of stream.'); + * }); + * ``` + * + * Each call to `readable.read()` returns a chunk of data, or `null`. The chunks + * are not concatenated. A `while` loop is necessary to consume all data + * currently in the buffer. When reading a large file `.read()` may return `null`, + * having consumed all buffered content so far, but there is still more data to + * come not yet buffered. In this case a new `'readable'` event will be emitted + * when there is more data in the buffer. Finally the `'end'` event will be + * emitted when there is no more data to come. + * + * Therefore to read a file's whole contents from a `readable`, it is necessary + * to collect chunks across multiple `'readable'` events: + * + * ```js + * const chunks = []; + * + * readable.on('readable', () => { + * let chunk; + * while (null !== (chunk = readable.read())) { + * chunks.push(chunk); + * } + * }); + * + * readable.on('end', () => { + * const content = chunks.join(''); + * }); + * ``` + * + * A `Readable` stream in object mode will always return a single item from + * a call to `readable.read(size)`, regardless of the value of the`size` argument. + * + * If the `readable.read()` method returns a chunk of data, a `'data'` event will + * also be emitted. + * + * Calling {@link read} after the `'end'` event has + * been emitted will return `null`. No runtime error will be raised. + * @since v0.9.4 + * @param size Optional argument to specify how much data to read. + */ + read(size?: number): any; + /** + * The `readable.setEncoding()` method sets the character encoding for + * data read from the `Readable` stream. + * + * By default, no encoding is assigned and stream data will be returned as`Buffer` objects. Setting an encoding causes the stream data + * to be returned as strings of the specified encoding rather than as `Buffer`objects. For instance, calling `readable.setEncoding('utf8')` will cause the + * output data to be interpreted as UTF-8 data, and passed as strings. Calling`readable.setEncoding('hex')` will cause the data to be encoded in hexadecimal + * string format. + * + * The `Readable` stream will properly handle multi-byte characters delivered + * through the stream that would otherwise become improperly decoded if simply + * pulled from the stream as `Buffer` objects. + * + * ```js + * const readable = getReadableStreamSomehow(); + * readable.setEncoding('utf8'); + * readable.on('data', (chunk) => { + * assert.equal(typeof chunk, 'string'); + * console.log('Got %d characters of string data:', chunk.length); + * }); + * ``` + * @since v0.9.4 + * @param encoding The encoding to use. + */ + setEncoding(encoding: BufferEncoding): this; + /** + * The `readable.pause()` method will cause a stream in flowing mode to stop + * emitting `'data'` events, switching out of flowing mode. Any data that + * becomes available will remain in the internal buffer. + * + * ```js + * const readable = getReadableStreamSomehow(); + * readable.on('data', (chunk) => { + * console.log(`Received ${chunk.length} bytes of data.`); + * readable.pause(); + * console.log('There will be no additional data for 1 second.'); + * setTimeout(() => { + * console.log('Now data will start flowing again.'); + * readable.resume(); + * }, 1000); + * }); + * ``` + * + * The `readable.pause()` method has no effect if there is a `'readable'`event listener. + * @since v0.9.4 + */ + pause(): this; + /** + * The `readable.resume()` method causes an explicitly paused `Readable` stream to + * resume emitting `'data'` events, switching the stream into flowing mode. + * + * The `readable.resume()` method can be used to fully consume the data from a + * stream without actually processing any of that data: + * + * ```js + * getReadableStreamSomehow() + * .resume() + * .on('end', () => { + * console.log('Reached the end, but did not read anything.'); + * }); + * ``` + * + * The `readable.resume()` method has no effect if there is a `'readable'`event listener. + * @since v0.9.4 + */ + resume(): this; + /** + * The `readable.isPaused()` method returns the current operating state of the`Readable`. This is used primarily by the mechanism that underlies the`readable.pipe()` method. In most + * typical cases, there will be no reason to + * use this method directly. + * + * ```js + * const readable = new stream.Readable(); + * + * readable.isPaused(); // === false + * readable.pause(); + * readable.isPaused(); // === true + * readable.resume(); + * readable.isPaused(); // === false + * ``` + * @since v0.11.14 + */ + isPaused(): boolean; + /** + * The `readable.unpipe()` method detaches a `Writable` stream previously attached + * using the {@link pipe} method. + * + * If the `destination` is not specified, then _all_ pipes are detached. + * + * If the `destination` is specified, but no pipe is set up for it, then + * the method does nothing. + * + * ```js + * const fs = require('node:fs'); + * const readable = getReadableStreamSomehow(); + * const writable = fs.createWriteStream('file.txt'); + * // All the data from readable goes into 'file.txt', + * // but only for the first second. + * readable.pipe(writable); + * setTimeout(() => { + * console.log('Stop writing to file.txt.'); + * readable.unpipe(writable); + * console.log('Manually close the file stream.'); + * writable.end(); + * }, 1000); + * ``` + * @since v0.9.4 + * @param destination Optional specific stream to unpipe + */ + unpipe(destination?: NodeJS.WritableStream): this; + /** + * Passing `chunk` as `null` signals the end of the stream (EOF) and behaves the + * same as `readable.push(null)`, after which no more data can be written. The EOF + * signal is put at the end of the buffer and any buffered data will still be + * flushed. + * + * The `readable.unshift()` method pushes a chunk of data back into the internal + * buffer. This is useful in certain situations where a stream is being consumed by + * code that needs to "un-consume" some amount of data that it has optimistically + * pulled out of the source, so that the data can be passed on to some other party. + * + * The `stream.unshift(chunk)` method cannot be called after the `'end'` event + * has been emitted or a runtime error will be thrown. + * + * Developers using `stream.unshift()` often should consider switching to + * use of a `Transform` stream instead. See the `API for stream implementers` section for more information. + * + * ```js + * // Pull off a header delimited by \n\n. + * // Use unshift() if we get too much. + * // Call the callback with (error, header, stream). + * const { StringDecoder } = require('node:string_decoder'); + * function parseHeader(stream, callback) { + * stream.on('error', callback); + * stream.on('readable', onReadable); + * const decoder = new StringDecoder('utf8'); + * let header = ''; + * function onReadable() { + * let chunk; + * while (null !== (chunk = stream.read())) { + * const str = decoder.write(chunk); + * if (str.includes('\n\n')) { + * // Found the header boundary. + * const split = str.split(/\n\n/); + * header += split.shift(); + * const remaining = split.join('\n\n'); + * const buf = Buffer.from(remaining, 'utf8'); + * stream.removeListener('error', callback); + * // Remove the 'readable' listener before unshifting. + * stream.removeListener('readable', onReadable); + * if (buf.length) + * stream.unshift(buf); + * // Now the body of the message can be read from the stream. + * callback(null, header, stream); + * return; + * } + * // Still reading the header. + * header += str; + * } + * } + * } + * ``` + * + * Unlike {@link push}, `stream.unshift(chunk)` will not + * end the reading process by resetting the internal reading state of the stream. + * This can cause unexpected results if `readable.unshift()` is called during a + * read (i.e. from within a {@link _read} implementation on a + * custom stream). Following the call to `readable.unshift()` with an immediate {@link push} will reset the reading state appropriately, + * however it is best to simply avoid calling `readable.unshift()` while in the + * process of performing a read. + * @since v0.9.11 + * @param chunk Chunk of data to unshift onto the read queue. For streams not operating in object mode, `chunk` must be a string, `Buffer`, `Uint8Array`, or `null`. For object mode + * streams, `chunk` may be any JavaScript value. + * @param encoding Encoding of string chunks. Must be a valid `Buffer` encoding, such as `'utf8'` or `'ascii'`. + */ + unshift(chunk: any, encoding?: BufferEncoding): void; + /** + * Prior to Node.js 0.10, streams did not implement the entire `node:stream`module API as it is currently defined. (See `Compatibility` for more + * information.) + * + * When using an older Node.js library that emits `'data'` events and has a {@link pause} method that is advisory only, the`readable.wrap()` method can be used to create a `Readable` + * stream that uses + * the old stream as its data source. + * + * It will rarely be necessary to use `readable.wrap()` but the method has been + * provided as a convenience for interacting with older Node.js applications and + * libraries. + * + * ```js + * const { OldReader } = require('./old-api-module.js'); + * const { Readable } = require('node:stream'); + * const oreader = new OldReader(); + * const myReader = new Readable().wrap(oreader); + * + * myReader.on('readable', () => { + * myReader.read(); // etc. + * }); + * ``` + * @since v0.9.4 + * @param stream An "old style" readable stream + */ + wrap(stream: NodeJS.ReadableStream): this; + push(chunk: any, encoding?: BufferEncoding): boolean; + /** + * The iterator created by this method gives users the option to cancel the destruction + * of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`, + * or if the iterator should destroy the stream if the stream emitted an error during iteration. + * @since v16.3.0 + * @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator, + * or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream. + * **Default: `true`**. + */ + iterator(options?: { destroyOnReturn?: boolean }): AsyncIterableIterator; + /** + * This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream. + * If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream. + * @since v17.4.0, v16.14.0 + * @param fn a function to map over every chunk in the stream. Async or not. + * @returns a stream mapped with the function *fn*. + */ + map(fn: (data: any, options?: Pick) => any, options?: ArrayOptions): Readable; + /** + * This method allows filtering the stream. For each chunk in the stream the *fn* function will be called + * and if it returns a truthy value, the chunk will be passed to the result stream. + * If the *fn* function returns a promise - that promise will be `await`ed. + * @since v17.4.0, v16.14.0 + * @param fn a function to filter chunks from the stream. Async or not. + * @returns a stream filtered with the predicate *fn*. + */ + filter( + fn: (data: any, options?: Pick) => boolean | Promise, + options?: ArrayOptions, + ): Readable; + /** + * This method allows iterating a stream. For each chunk in the stream the *fn* function will be called. + * If the *fn* function returns a promise - that promise will be `await`ed. + * + * This method is different from `for await...of` loops in that it can optionally process chunks concurrently. + * In addition, a `forEach` iteration can only be stopped by having passed a `signal` option + * and aborting the related AbortController while `for await...of` can be stopped with `break` or `return`. + * In either case the stream will be destroyed. + * + * This method is different from listening to the `'data'` event in that it uses the `readable` event + * in the underlying machinary and can limit the number of concurrent *fn* calls. + * @since v17.5.0 + * @param fn a function to call on each chunk of the stream. Async or not. + * @returns a promise for when the stream has finished. + */ + forEach( + fn: (data: any, options?: Pick) => void | Promise, + options?: ArrayOptions, + ): Promise; + /** + * This method allows easily obtaining the contents of a stream. + * + * As this method reads the entire stream into memory, it negates the benefits of streams. It's intended + * for interoperability and convenience, not as the primary way to consume streams. + * @since v17.5.0 + * @returns a promise containing an array with the contents of the stream. + */ + toArray(options?: Pick): Promise; + /** + * This method is similar to `Array.prototype.some` and calls *fn* on each chunk in the stream + * until the awaited return value is `true` (or any truthy value). Once an *fn* call on a chunk + * `await`ed return value is truthy, the stream is destroyed and the promise is fulfilled with `true`. + * If none of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `false`. + * @since v17.5.0 + * @param fn a function to call on each chunk of the stream. Async or not. + * @returns a promise evaluating to `true` if *fn* returned a truthy value for at least one of the chunks. + */ + some( + fn: (data: any, options?: Pick) => boolean | Promise, + options?: ArrayOptions, + ): Promise; + /** + * This method is similar to `Array.prototype.find` and calls *fn* on each chunk in the stream + * to find a chunk with a truthy value for *fn*. Once an *fn* call's awaited return value is truthy, + * the stream is destroyed and the promise is fulfilled with value for which *fn* returned a truthy value. + * If all of the *fn* calls on the chunks return a falsy value, the promise is fulfilled with `undefined`. + * @since v17.5.0 + * @param fn a function to call on each chunk of the stream. Async or not. + * @returns a promise evaluating to the first chunk for which *fn* evaluated with a truthy value, + * or `undefined` if no element was found. + */ + find( + fn: (data: any, options?: Pick) => data is T, + options?: ArrayOptions, + ): Promise; + find( + fn: (data: any, options?: Pick) => boolean | Promise, + options?: ArrayOptions, + ): Promise; + /** + * This method is similar to `Array.prototype.every` and calls *fn* on each chunk in the stream + * to check if all awaited return values are truthy value for *fn*. Once an *fn* call on a chunk + * `await`ed return value is falsy, the stream is destroyed and the promise is fulfilled with `false`. + * If all of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `true`. + * @since v17.5.0 + * @param fn a function to call on each chunk of the stream. Async or not. + * @returns a promise evaluating to `true` if *fn* returned a truthy value for every one of the chunks. + */ + every( + fn: (data: any, options?: Pick) => boolean | Promise, + options?: ArrayOptions, + ): Promise; + /** + * This method returns a new stream by applying the given callback to each chunk of the stream + * and then flattening the result. + * + * It is possible to return a stream or another iterable or async iterable from *fn* and the result streams + * will be merged (flattened) into the returned stream. + * @since v17.5.0 + * @param fn a function to map over every chunk in the stream. May be async. May be a stream or generator. + * @returns a stream flat-mapped with the function *fn*. + */ + flatMap(fn: (data: any, options?: Pick) => any, options?: ArrayOptions): Readable; + /** + * This method returns a new stream with the first *limit* chunks dropped from the start. + * @since v17.5.0 + * @param limit the number of chunks to drop from the readable. + * @returns a stream with *limit* chunks dropped from the start. + */ + drop(limit: number, options?: Pick): Readable; + /** + * This method returns a new stream with the first *limit* chunks. + * @since v17.5.0 + * @param limit the number of chunks to take from the readable. + * @returns a stream with *limit* chunks taken. + */ + take(limit: number, options?: Pick): Readable; + /** + * This method returns a new stream with chunks of the underlying stream paired with a counter + * in the form `[index, chunk]`. The first index value is `0` and it increases by 1 for each chunk produced. + * @since v17.5.0 + * @returns a stream of indexed pairs. + */ + asIndexedPairs(options?: Pick): Readable; + /** + * This method calls *fn* on each chunk of the stream in order, passing it the result from the calculation + * on the previous element. It returns a promise for the final value of the reduction. + * + * If no *initial* value is supplied the first chunk of the stream is used as the initial value. + * If the stream is empty, the promise is rejected with a `TypeError` with the `ERR_INVALID_ARGS` code property. + * + * The reducer function iterates the stream element-by-element which means that there is no *concurrency* parameter + * or parallelism. To perform a reduce concurrently, you can extract the async function to `readable.map` method. + * @since v17.5.0 + * @param fn a reducer function to call over every chunk in the stream. Async or not. + * @param initial the initial value to use in the reduction. + * @returns a promise for the final value of the reduction. + */ + reduce( + fn: (previous: any, data: any, options?: Pick) => T, + initial?: undefined, + options?: Pick, + ): Promise; + reduce( + fn: (previous: T, data: any, options?: Pick) => T, + initial: T, + options?: Pick, + ): Promise; + _destroy(error: Error | null, callback: (error?: Error | null) => void): void; + /** + * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable + * stream will release any internal resources and subsequent calls to `push()`will be ignored. + * + * Once `destroy()` has been called any further calls will be a no-op and no + * further errors except from `_destroy()` may be emitted as `'error'`. + * + * Implementors should not override this method, but instead implement `readable._destroy()`. + * @since v8.0.0 + * @param error Error which will be passed as payload in `'error'` event + */ + destroy(error?: Error): this; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. data + * 3. end + * 4. error + * 5. pause + * 6. readable + * 7. resume + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: any) => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "data", chunk: any): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "pause"): boolean; + emit(event: "readable"): boolean; + emit(event: "resume"): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: any) => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "readable", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: any) => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "readable", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: any) => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: any) => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: "close", listener: () => void): this; + removeListener(event: "data", listener: (chunk: any) => void): this; + removeListener(event: "end", listener: () => void): this; + removeListener(event: "error", listener: (err: Error) => void): this; + removeListener(event: "pause", listener: () => void): this; + removeListener(event: "readable", listener: () => void): this; + removeListener(event: "resume", listener: () => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + [Symbol.asyncIterator](): AsyncIterableIterator; + /** + * Calls `readable.destroy()` with an `AbortError` and returns a promise that fulfills when the stream is finished. + * @since v20.4.0 + */ + [Symbol.asyncDispose](): Promise; + } + import WritableOptions = internal.WritableOptions; + class WritableBase extends Stream implements NodeJS.WritableStream { + /** + * Is `true` if it is safe to call `writable.write()`, which means + * the stream has not been destroyed, errored, or ended. + * @since v11.4.0 + */ + readonly writable: boolean; + /** + * Is `true` after `writable.end()` has been called. This property + * does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead. + * @since v12.9.0 + */ + readonly writableEnded: boolean; + /** + * Is set to `true` immediately before the `'finish'` event is emitted. + * @since v12.6.0 + */ + readonly writableFinished: boolean; + /** + * Return the value of `highWaterMark` passed when creating this `Writable`. + * @since v9.3.0 + */ + readonly writableHighWaterMark: number; + /** + * This property contains the number of bytes (or objects) in the queue + * ready to be written. The value provides introspection data regarding + * the status of the `highWaterMark`. + * @since v9.4.0 + */ + readonly writableLength: number; + /** + * Getter for the property `objectMode` of a given `Writable` stream. + * @since v12.3.0 + */ + readonly writableObjectMode: boolean; + /** + * Number of times `writable.uncork()` needs to be + * called in order to fully uncork the stream. + * @since v13.2.0, v12.16.0 + */ + readonly writableCorked: number; + /** + * Is `true` after `writable.destroy()` has been called. + * @since v8.0.0 + */ + destroyed: boolean; + /** + * Is `true` after `'close'` has been emitted. + * @since v18.0.0 + */ + readonly closed: boolean; + /** + * Returns error if the stream has been destroyed with an error. + * @since v18.0.0 + */ + readonly errored: Error | null; + /** + * Is `true` if the stream's buffer has been full and stream will emit `'drain'`. + * @since v15.2.0, v14.17.0 + */ + readonly writableNeedDrain: boolean; + constructor(opts?: WritableOptions); + _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; + _writev?( + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + _construct?(callback: (error?: Error | null) => void): void; + _destroy(error: Error | null, callback: (error?: Error | null) => void): void; + _final(callback: (error?: Error | null) => void): void; + /** + * The `writable.write()` method writes some data to the stream, and calls the + * supplied `callback` once the data has been fully handled. If an error + * occurs, the `callback` will be called with the error as its + * first argument. The `callback` is called asynchronously and before `'error'` is + * emitted. + * + * The return value is `true` if the internal buffer is less than the`highWaterMark` configured when the stream was created after admitting `chunk`. + * If `false` is returned, further attempts to write data to the stream should + * stop until the `'drain'` event is emitted. + * + * While a stream is not draining, calls to `write()` will buffer `chunk`, and + * return false. Once all currently buffered chunks are drained (accepted for + * delivery by the operating system), the `'drain'` event will be emitted. + * Once `write()` returns false, do not write more chunks + * until the `'drain'` event is emitted. While calling `write()` on a stream that + * is not draining is allowed, Node.js will buffer all written chunks until + * maximum memory usage occurs, at which point it will abort unconditionally. + * Even before it aborts, high memory usage will cause poor garbage collector + * performance and high RSS (which is not typically released back to the system, + * even after the memory is no longer required). Since TCP sockets may never + * drain if the remote peer does not read the data, writing a socket that is + * not draining may lead to a remotely exploitable vulnerability. + * + * Writing data while the stream is not draining is particularly + * problematic for a `Transform`, because the `Transform` streams are paused + * by default until they are piped or a `'data'` or `'readable'` event handler + * is added. + * + * If the data to be written can be generated or fetched on demand, it is + * recommended to encapsulate the logic into a `Readable` and use {@link pipe}. However, if calling `write()` is preferred, it is + * possible to respect backpressure and avoid memory issues using the `'drain'` event: + * + * ```js + * function write(data, cb) { + * if (!stream.write(data)) { + * stream.once('drain', cb); + * } else { + * process.nextTick(cb); + * } + * } + * + * // Wait for cb to be called before doing any other write. + * write('hello', () => { + * console.log('Write completed, do more writes now.'); + * }); + * ``` + * + * A `Writable` stream in object mode will always ignore the `encoding` argument. + * @since v0.9.4 + * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any + * JavaScript value other than `null`. + * @param [encoding='utf8'] The encoding, if `chunk` is a string. + * @param callback Callback for when this chunk of data is flushed. + * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + write(chunk: any, callback?: (error: Error | null | undefined) => void): boolean; + write(chunk: any, encoding: BufferEncoding, callback?: (error: Error | null | undefined) => void): boolean; + /** + * The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream. + * @since v0.11.15 + * @param encoding The new default encoding + */ + setDefaultEncoding(encoding: BufferEncoding): this; + /** + * Calling the `writable.end()` method signals that no more data will be written + * to the `Writable`. The optional `chunk` and `encoding` arguments allow one + * final additional chunk of data to be written immediately before closing the + * stream. + * + * Calling the {@link write} method after calling {@link end} will raise an error. + * + * ```js + * // Write 'hello, ' and then end with 'world!'. + * const fs = require('node:fs'); + * const file = fs.createWriteStream('example.txt'); + * file.write('hello, '); + * file.end('world!'); + * // Writing more now is not allowed! + * ``` + * @since v0.9.4 + * @param chunk Optional data to write. For streams not operating in object mode, `chunk` must be a string, `Buffer` or `Uint8Array`. For object mode streams, `chunk` may be any + * JavaScript value other than `null`. + * @param encoding The encoding if `chunk` is a string + * @param callback Callback for when the stream is finished. + */ + end(cb?: () => void): this; + end(chunk: any, cb?: () => void): this; + end(chunk: any, encoding: BufferEncoding, cb?: () => void): this; + /** + * The `writable.cork()` method forces all written data to be buffered in memory. + * The buffered data will be flushed when either the {@link uncork} or {@link end} methods are called. + * + * The primary intent of `writable.cork()` is to accommodate a situation in which + * several small chunks are written to the stream in rapid succession. Instead of + * immediately forwarding them to the underlying destination, `writable.cork()`buffers all the chunks until `writable.uncork()` is called, which will pass them + * all to `writable._writev()`, if present. This prevents a head-of-line blocking + * situation where data is being buffered while waiting for the first small chunk + * to be processed. However, use of `writable.cork()` without implementing`writable._writev()` may have an adverse effect on throughput. + * + * See also: `writable.uncork()`, `writable._writev()`. + * @since v0.11.2 + */ + cork(): void; + /** + * The `writable.uncork()` method flushes all data buffered since {@link cork} was called. + * + * When using `writable.cork()` and `writable.uncork()` to manage the buffering + * of writes to a stream, defer calls to `writable.uncork()` using`process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event + * loop phase. + * + * ```js + * stream.cork(); + * stream.write('some '); + * stream.write('data '); + * process.nextTick(() => stream.uncork()); + * ``` + * + * If the `writable.cork()` method is called multiple times on a stream, the + * same number of calls to `writable.uncork()` must be called to flush the buffered + * data. + * + * ```js + * stream.cork(); + * stream.write('some '); + * stream.cork(); + * stream.write('data '); + * process.nextTick(() => { + * stream.uncork(); + * // The data will not be flushed until uncork() is called a second time. + * stream.uncork(); + * }); + * ``` + * + * See also: `writable.cork()`. + * @since v0.11.2 + */ + uncork(): void; + /** + * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the writable + * stream has ended and subsequent calls to `write()` or `end()` will result in + * an `ERR_STREAM_DESTROYED` error. + * This is a destructive and immediate way to destroy a stream. Previous calls to`write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error. + * Use `end()` instead of destroy if data should flush before close, or wait for + * the `'drain'` event before destroying the stream. + * + * Once `destroy()` has been called any further calls will be a no-op and no + * further errors except from `_destroy()` may be emitted as `'error'`. + * + * Implementors should not override this method, + * but instead implement `writable._destroy()`. + * @since v8.0.0 + * @param error Optional, an error to emit with `'error'` event. + */ + destroy(error?: Error): this; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. drain + * 3. error + * 4. finish + * 5. pipe + * 6. unpipe + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pipe", listener: (src: Readable) => void): this; + addListener(event: "unpipe", listener: (src: Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "drain"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "pipe", src: Readable): boolean; + emit(event: "unpipe", src: Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: Readable) => void): this; + on(event: "unpipe", listener: (src: Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: Readable) => void): this; + once(event: "unpipe", listener: (src: Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pipe", listener: (src: Readable) => void): this; + prependListener(event: "unpipe", listener: (src: Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: "close", listener: () => void): this; + removeListener(event: "drain", listener: () => void): this; + removeListener(event: "error", listener: (err: Error) => void): this; + removeListener(event: "finish", listener: () => void): this; + removeListener(event: "pipe", listener: (src: Readable) => void): this; + removeListener(event: "unpipe", listener: (src: Readable) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + namespace internal { + class Stream extends internal { + constructor(opts?: ReadableOptions); + } + interface StreamOptions extends Abortable { + emitClose?: boolean | undefined; + highWaterMark?: number | undefined; + objectMode?: boolean | undefined; + construct?(this: T, callback: (error?: Error | null) => void): void; + destroy?(this: T, error: Error | null, callback: (error: Error | null) => void): void; + autoDestroy?: boolean | undefined; + } + interface ReadableOptions extends StreamOptions { + encoding?: BufferEncoding | undefined; + read?(this: Readable, size: number): void; + } + /** + * @since v0.9.4 + */ + class Readable extends ReadableBase { + /** + * A utility method for creating a `Readable` from a web `ReadableStream`. + * @since v17.0.0 + * @experimental + */ + static fromWeb( + readableStream: streamWeb.ReadableStream, + options?: Pick, + ): Readable; + /** + * A utility method for creating a web `ReadableStream` from a `Readable`. + * @since v17.0.0 + * @experimental + */ + static toWeb(streamReadable: Readable): streamWeb.ReadableStream; + } + interface WritableOptions extends StreamOptions { + decodeStrings?: boolean | undefined; + defaultEncoding?: BufferEncoding | undefined; + write?( + this: Writable, + chunk: any, + encoding: BufferEncoding, + callback: (error?: Error | null) => void, + ): void; + writev?( + this: Writable, + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + final?(this: Writable, callback: (error?: Error | null) => void): void; + } + /** + * @since v0.9.4 + */ + class Writable extends WritableBase { + /** + * A utility method for creating a `Writable` from a web `WritableStream`. + * @since v17.0.0 + * @experimental + */ + static fromWeb( + writableStream: streamWeb.WritableStream, + options?: Pick, + ): Writable; + /** + * A utility method for creating a web `WritableStream` from a `Writable`. + * @since v17.0.0 + * @experimental + */ + static toWeb(streamWritable: Writable): streamWeb.WritableStream; + } + interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean | undefined; + readableObjectMode?: boolean | undefined; + writableObjectMode?: boolean | undefined; + readableHighWaterMark?: number | undefined; + writableHighWaterMark?: number | undefined; + writableCorked?: number | undefined; + construct?(this: Duplex, callback: (error?: Error | null) => void): void; + read?(this: Duplex, size: number): void; + write?(this: Duplex, chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; + writev?( + this: Duplex, + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + final?(this: Duplex, callback: (error?: Error | null) => void): void; + destroy?(this: Duplex, error: Error | null, callback: (error: Error | null) => void): void; + } + /** + * Duplex streams are streams that implement both the `Readable` and `Writable` interfaces. + * + * Examples of `Duplex` streams include: + * + * * `TCP sockets` + * * `zlib streams` + * * `crypto streams` + * @since v0.9.4 + */ + class Duplex extends ReadableBase implements WritableBase { + readonly writable: boolean; + readonly writableEnded: boolean; + readonly writableFinished: boolean; + readonly writableHighWaterMark: number; + readonly writableLength: number; + readonly writableObjectMode: boolean; + readonly writableCorked: number; + readonly writableNeedDrain: boolean; + readonly closed: boolean; + readonly errored: Error | null; + /** + * If `false` then the stream will automatically end the writable side when the + * readable side ends. Set initially by the `allowHalfOpen` constructor option, + * which defaults to `true`. + * + * This can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is + * emitted. + * @since v0.9.4 + */ + allowHalfOpen: boolean; + constructor(opts?: DuplexOptions); + /** + * A utility method for creating duplex streams. + * + * - `Stream` converts writable stream into writable `Duplex` and readable stream + * to `Duplex`. + * - `Blob` converts into readable `Duplex`. + * - `string` converts into readable `Duplex`. + * - `ArrayBuffer` converts into readable `Duplex`. + * - `AsyncIterable` converts into a readable `Duplex`. Cannot yield `null`. + * - `AsyncGeneratorFunction` converts into a readable/writable transform + * `Duplex`. Must take a source `AsyncIterable` as first parameter. Cannot yield + * `null`. + * - `AsyncFunction` converts into a writable `Duplex`. Must return + * either `null` or `undefined` + * - `Object ({ writable, readable })` converts `readable` and + * `writable` into `Stream` and then combines them into `Duplex` where the + * `Duplex` will write to the `writable` and read from the `readable`. + * - `Promise` converts into readable `Duplex`. Value `null` is ignored. + * + * @since v16.8.0 + */ + static from( + src: + | Stream + | NodeBlob + | ArrayBuffer + | string + | Iterable + | AsyncIterable + | AsyncGeneratorFunction + | Promise + | Object, + ): Duplex; + _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void; + _writev?( + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + _destroy(error: Error | null, callback: (error: Error | null) => void): void; + _final(callback: (error?: Error | null) => void): void; + write(chunk: any, encoding?: BufferEncoding, cb?: (error: Error | null | undefined) => void): boolean; + write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean; + setDefaultEncoding(encoding: BufferEncoding): this; + end(cb?: () => void): this; + end(chunk: any, cb?: () => void): this; + end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this; + cork(): void; + uncork(): void; + /** + * A utility method for creating a web `ReadableStream` and `WritableStream` from a `Duplex`. + * @since v17.0.0 + * @experimental + */ + static toWeb(streamDuplex: Duplex): { + readable: streamWeb.ReadableStream; + writable: streamWeb.WritableStream; + }; + /** + * A utility method for creating a `Duplex` from a web `ReadableStream` and `WritableStream`. + * @since v17.0.0 + * @experimental + */ + static fromWeb( + duplexStream: { + readable: streamWeb.ReadableStream; + writable: streamWeb.WritableStream; + }, + options?: Pick< + DuplexOptions, + "allowHalfOpen" | "decodeStrings" | "encoding" | "highWaterMark" | "objectMode" | "signal" + >, + ): Duplex; + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. data + * 3. drain + * 4. end + * 5. error + * 6. finish + * 7. pause + * 8. pipe + * 9. readable + * 10. resume + * 11. unpipe + */ + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: any) => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "pipe", listener: (src: Readable) => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: "unpipe", listener: (src: Readable) => void): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + emit(event: "close"): boolean; + emit(event: "data", chunk: any): boolean; + emit(event: "drain"): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "pause"): boolean; + emit(event: "pipe", src: Readable): boolean; + emit(event: "readable"): boolean; + emit(event: "resume"): boolean; + emit(event: "unpipe", src: Readable): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: any) => void): this; + on(event: "drain", listener: () => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pause", listener: () => void): this; + on(event: "pipe", listener: (src: Readable) => void): this; + on(event: "readable", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: "unpipe", listener: (src: Readable) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: any) => void): this; + once(event: "drain", listener: () => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pause", listener: () => void): this; + once(event: "pipe", listener: (src: Readable) => void): this; + once(event: "readable", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: "unpipe", listener: (src: Readable) => void): this; + once(event: string | symbol, listener: (...args: any[]) => void): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: any) => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "pipe", listener: (src: Readable) => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: "unpipe", listener: (src: Readable) => void): this; + prependListener(event: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: any) => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; + prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; + removeListener(event: "close", listener: () => void): this; + removeListener(event: "data", listener: (chunk: any) => void): this; + removeListener(event: "drain", listener: () => void): this; + removeListener(event: "end", listener: () => void): this; + removeListener(event: "error", listener: (err: Error) => void): this; + removeListener(event: "finish", listener: () => void): this; + removeListener(event: "pause", listener: () => void): this; + removeListener(event: "pipe", listener: (src: Readable) => void): this; + removeListener(event: "readable", listener: () => void): this; + removeListener(event: "resume", listener: () => void): this; + removeListener(event: "unpipe", listener: (src: Readable) => void): this; + removeListener(event: string | symbol, listener: (...args: any[]) => void): this; + } + type TransformCallback = (error?: Error | null, data?: any) => void; + interface TransformOptions extends DuplexOptions { + construct?(this: Transform, callback: (error?: Error | null) => void): void; + read?(this: Transform, size: number): void; + write?( + this: Transform, + chunk: any, + encoding: BufferEncoding, + callback: (error?: Error | null) => void, + ): void; + writev?( + this: Transform, + chunks: Array<{ + chunk: any; + encoding: BufferEncoding; + }>, + callback: (error?: Error | null) => void, + ): void; + final?(this: Transform, callback: (error?: Error | null) => void): void; + destroy?(this: Transform, error: Error | null, callback: (error: Error | null) => void): void; + transform?(this: Transform, chunk: any, encoding: BufferEncoding, callback: TransformCallback): void; + flush?(this: Transform, callback: TransformCallback): void; + } + /** + * Transform streams are `Duplex` streams where the output is in some way + * related to the input. Like all `Duplex` streams, `Transform` streams + * implement both the `Readable` and `Writable` interfaces. + * + * Examples of `Transform` streams include: + * + * * `zlib streams` + * * `crypto streams` + * @since v0.9.4 + */ + class Transform extends Duplex { + constructor(opts?: TransformOptions); + _transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void; + _flush(callback: TransformCallback): void; + } + /** + * The `stream.PassThrough` class is a trivial implementation of a `Transform` stream that simply passes the input bytes across to the output. Its purpose is + * primarily for examples and testing, but there are some use cases where`stream.PassThrough` is useful as a building block for novel sorts of streams. + */ + class PassThrough extends Transform {} + /** + * A stream to attach a signal to. + * + * Attaches an AbortSignal to a readable or writeable stream. This lets code + * control stream destruction using an `AbortController`. + * + * Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream, and `controller.error(new + * AbortError())` for webstreams. + * + * ```js + * const fs = require('node:fs'); + * + * const controller = new AbortController(); + * const read = addAbortSignal( + * controller.signal, + * fs.createReadStream(('object.json')), + * ); + * // Later, abort the operation closing the stream + * controller.abort(); + * ``` + * + * Or using an `AbortSignal` with a readable stream as an async iterable: + * + * ```js + * const controller = new AbortController(); + * setTimeout(() => controller.abort(), 10_000); // set a timeout + * const stream = addAbortSignal( + * controller.signal, + * fs.createReadStream(('object.json')), + * ); + * (async () => { + * try { + * for await (const chunk of stream) { + * await process(chunk); + * } + * } catch (e) { + * if (e.name === 'AbortError') { + * // The operation was cancelled + * } else { + * throw e; + * } + * } + * })(); + * ``` + * + * Or using an `AbortSignal` with a ReadableStream: + * + * ```js + * const controller = new AbortController(); + * const rs = new ReadableStream({ + * start(controller) { + * controller.enqueue('hello'); + * controller.enqueue('world'); + * controller.close(); + * }, + * }); + * + * addAbortSignal(controller.signal, rs); + * + * finished(rs, (err) => { + * if (err) { + * if (err.name === 'AbortError') { + * // The operation was cancelled + * } + * } + * }); + * + * const reader = rs.getReader(); + * + * reader.read().then(({ value, done }) => { + * console.log(value); // hello + * console.log(done); // false + * controller.abort(); + * }); + * ``` + * @since v15.4.0 + * @param signal A signal representing possible cancellation + * @param stream a stream to attach a signal to + */ + function addAbortSignal(signal: AbortSignal, stream: T): T; + /** + * Returns the default highWaterMark used by streams. + * Defaults to `16384` (16 KiB), or `16` for `objectMode`. + * @since v19.9.0 + * @param objectMode + */ + function getDefaultHighWaterMark(objectMode: boolean): number; + /** + * Sets the default highWaterMark used by streams. + * @since v19.9.0 + * @param objectMode + * @param value highWaterMark value + */ + function setDefaultHighWaterMark(objectMode: boolean, value: number): void; + interface FinishedOptions extends Abortable { + error?: boolean | undefined; + readable?: boolean | undefined; + writable?: boolean | undefined; + } + /** + * A readable and/or writable stream/webstream. + * + * A function to get notified when a stream is no longer readable, writable + * or has experienced an error or a premature close event. + * + * ```js + * const { finished } = require('node:stream'); + * const fs = require('node:fs'); + * + * const rs = fs.createReadStream('archive.tar'); + * + * finished(rs, (err) => { + * if (err) { + * console.error('Stream failed.', err); + * } else { + * console.log('Stream is done reading.'); + * } + * }); + * + * rs.resume(); // Drain the stream. + * ``` + * + * Especially useful in error handling scenarios where a stream is destroyed + * prematurely (like an aborted HTTP request), and will not emit `'end'`or `'finish'`. + * + * The `finished` API provides `promise version`. + * + * `stream.finished()` leaves dangling event listeners (in particular`'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been + * invoked. The reason for this is so that unexpected `'error'` events (due to + * incorrect stream implementations) do not cause unexpected crashes. + * If this is unwanted behavior then the returned cleanup function needs to be + * invoked in the callback: + * + * ```js + * const cleanup = finished(rs, (err) => { + * cleanup(); + * // ... + * }); + * ``` + * @since v10.0.0 + * @param stream A readable and/or writable stream. + * @param callback A callback function that takes an optional error argument. + * @return A cleanup function which removes all registered listeners. + */ + function finished( + stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, + options: FinishedOptions, + callback: (err?: NodeJS.ErrnoException | null) => void, + ): () => void; + function finished( + stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, + callback: (err?: NodeJS.ErrnoException | null) => void, + ): () => void; + namespace finished { + function __promisify__( + stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, + options?: FinishedOptions, + ): Promise; + } + type PipelineSourceFunction = () => Iterable | AsyncIterable; + type PipelineSource = Iterable | AsyncIterable | NodeJS.ReadableStream | PipelineSourceFunction; + type PipelineTransform, U> = + | NodeJS.ReadWriteStream + | (( + source: S extends (...args: any[]) => Iterable | AsyncIterable ? AsyncIterable + : S, + ) => AsyncIterable); + type PipelineTransformSource = PipelineSource | PipelineTransform; + type PipelineDestinationIterableFunction = (source: AsyncIterable) => AsyncIterable; + type PipelineDestinationPromiseFunction = (source: AsyncIterable) => Promise

; + type PipelineDestination, P> = S extends + PipelineTransformSource ? + | NodeJS.WritableStream + | PipelineDestinationIterableFunction + | PipelineDestinationPromiseFunction + : never; + type PipelineCallback> = S extends + PipelineDestinationPromiseFunction ? (err: NodeJS.ErrnoException | null, value: P) => void + : (err: NodeJS.ErrnoException | null) => void; + type PipelinePromise> = S extends + PipelineDestinationPromiseFunction ? Promise

: Promise; + interface PipelineOptions { + signal?: AbortSignal | undefined; + end?: boolean | undefined; + } + /** + * A module method to pipe between streams and generators forwarding errors and + * properly cleaning up and provide a callback when the pipeline is complete. + * + * ```js + * const { pipeline } = require('node:stream'); + * const fs = require('node:fs'); + * const zlib = require('node:zlib'); + * + * // Use the pipeline API to easily pipe a series of streams + * // together and get notified when the pipeline is fully done. + * + * // A pipeline to gzip a potentially huge tar file efficiently: + * + * pipeline( + * fs.createReadStream('archive.tar'), + * zlib.createGzip(), + * fs.createWriteStream('archive.tar.gz'), + * (err) => { + * if (err) { + * console.error('Pipeline failed.', err); + * } else { + * console.log('Pipeline succeeded.'); + * } + * }, + * ); + * ``` + * + * The `pipeline` API provides a `promise version`. + * + * `stream.pipeline()` will call `stream.destroy(err)` on all streams except: + * + * * `Readable` streams which have emitted `'end'` or `'close'`. + * * `Writable` streams which have emitted `'finish'` or `'close'`. + * + * `stream.pipeline()` leaves dangling event listeners on the streams + * after the `callback` has been invoked. In the case of reuse of streams after + * failure, this can cause event listener leaks and swallowed errors. If the last + * stream is readable, dangling event listeners will be removed so that the last + * stream can be consumed later. + * + * `stream.pipeline()` closes all the streams when an error is raised. + * The `IncomingRequest` usage with `pipeline` could lead to an unexpected behavior + * once it would destroy the socket without sending the expected response. + * See the example below: + * + * ```js + * const fs = require('node:fs'); + * const http = require('node:http'); + * const { pipeline } = require('node:stream'); + * + * const server = http.createServer((req, res) => { + * const fileStream = fs.createReadStream('./fileNotExist.txt'); + * pipeline(fileStream, res, (err) => { + * if (err) { + * console.log(err); // No such file + * // this message can't be sent once `pipeline` already destroyed the socket + * return res.end('error!!!'); + * } + * }); + * }); + * ``` + * @since v10.0.0 + * @param callback Called when the pipeline is fully done. + */ + function pipeline, B extends PipelineDestination>( + source: A, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + T4 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + transform4: T4, + destination: B, + callback?: PipelineCallback, + ): B extends NodeJS.WritableStream ? B : NodeJS.WritableStream; + function pipeline( + streams: ReadonlyArray, + callback?: (err: NodeJS.ErrnoException | null) => void, + ): NodeJS.WritableStream; + function pipeline( + stream1: NodeJS.ReadableStream, + stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, + ...streams: Array< + NodeJS.ReadWriteStream | NodeJS.WritableStream | ((err: NodeJS.ErrnoException | null) => void) + > + ): NodeJS.WritableStream; + namespace pipeline { + function __promisify__, B extends PipelineDestination>( + source: A, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__< + A extends PipelineSource, + T1 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + T4 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + transform4: T4, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function __promisify__( + streams: ReadonlyArray, + options?: PipelineOptions, + ): Promise; + function __promisify__( + stream1: NodeJS.ReadableStream, + stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, + ...streams: Array + ): Promise; + } + interface Pipe { + close(): void; + hasRef(): boolean; + ref(): void; + unref(): void; + } + /** + * Returns whether the stream has encountered an error. + * @since v17.3.0, v16.14.0 + * @experimental + */ + function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean; + /** + * Returns whether the stream is readable. + * @since v17.4.0, v16.14.0 + * @experimental + */ + function isReadable(stream: Readable | NodeJS.ReadableStream): boolean; + const promises: typeof streamPromises; + const consumers: typeof streamConsumers; + } + export = internal; +} +declare module "node:stream" { + import stream = require("stream"); + export = stream; +} diff --git a/node_modules/@types/node/ts4.8/stream/consumers.d.ts b/node_modules/@types/node/ts4.8/stream/consumers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ad9cbab98829fd66db9effa031b885647ba251c --- /dev/null +++ b/node_modules/@types/node/ts4.8/stream/consumers.d.ts @@ -0,0 +1,12 @@ +declare module "stream/consumers" { + import { Blob as NodeBlob } from "node:buffer"; + import { Readable } from "node:stream"; + function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; + function text(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; + function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; + function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; + function json(stream: NodeJS.ReadableStream | Readable | AsyncIterable): Promise; +} +declare module "node:stream/consumers" { + export * from "stream/consumers"; +} diff --git a/node_modules/@types/node/ts4.8/stream/promises.d.ts b/node_modules/@types/node/ts4.8/stream/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6eac5b7156a6b0cecea5c24cd8037a0a75af42eb --- /dev/null +++ b/node_modules/@types/node/ts4.8/stream/promises.d.ts @@ -0,0 +1,83 @@ +declare module "stream/promises" { + import { + FinishedOptions, + PipelineDestination, + PipelineOptions, + PipelinePromise, + PipelineSource, + PipelineTransform, + } from "node:stream"; + function finished( + stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, + options?: FinishedOptions, + ): Promise; + function pipeline, B extends PipelineDestination>( + source: A, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline< + A extends PipelineSource, + T1 extends PipelineTransform, + T2 extends PipelineTransform, + T3 extends PipelineTransform, + T4 extends PipelineTransform, + B extends PipelineDestination, + >( + source: A, + transform1: T1, + transform2: T2, + transform3: T3, + transform4: T4, + destination: B, + options?: PipelineOptions, + ): PipelinePromise; + function pipeline( + streams: ReadonlyArray, + options?: PipelineOptions, + ): Promise; + function pipeline( + stream1: NodeJS.ReadableStream, + stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, + ...streams: Array + ): Promise; +} +declare module "node:stream/promises" { + export * from "stream/promises"; +} diff --git a/node_modules/@types/node/ts4.8/stream/web.d.ts b/node_modules/@types/node/ts4.8/stream/web.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d9161375e1fbcf245594bb4c0b061779a9de916 --- /dev/null +++ b/node_modules/@types/node/ts4.8/stream/web.d.ts @@ -0,0 +1,350 @@ +declare module "stream/web" { + // stub module, pending copy&paste from .d.ts or manual impl + // copy from lib.dom.d.ts + interface ReadableWritablePair { + readable: ReadableStream; + /** + * Provides a convenient, chainable way of piping this readable stream + * through a transform stream (or any other { writable, readable } + * pair). It simply pipes the stream into the writable side of the + * supplied pair, and returns the readable side for further use. + * + * Piping a stream will lock it for the duration of the pipe, preventing + * any other consumer from acquiring a reader. + */ + writable: WritableStream; + } + interface StreamPipeOptions { + preventAbort?: boolean; + preventCancel?: boolean; + /** + * Pipes this readable stream to a given writable stream destination. + * The way in which the piping process behaves under various error + * conditions can be customized with a number of passed options. It + * returns a promise that fulfills when the piping process completes + * successfully, or rejects if any errors were encountered. + * + * Piping a stream will lock it for the duration of the pipe, preventing + * any other consumer from acquiring a reader. + * + * Errors and closures of the source and destination streams propagate + * as follows: + * + * An error in this source readable stream will abort destination, + * unless preventAbort is truthy. The returned promise will be rejected + * with the source's error, or with any error that occurs during + * aborting the destination. + * + * An error in destination will cancel this source readable stream, + * unless preventCancel is truthy. The returned promise will be rejected + * with the destination's error, or with any error that occurs during + * canceling the source. + * + * When this source readable stream closes, destination will be closed, + * unless preventClose is truthy. The returned promise will be fulfilled + * once this process completes, unless an error is encountered while + * closing the destination, in which case it will be rejected with that + * error. + * + * If destination starts out closed or closing, this source readable + * stream will be canceled, unless preventCancel is true. The returned + * promise will be rejected with an error indicating piping to a closed + * stream failed, or with any error that occurs during canceling the + * source. + * + * The signal option can be set to an AbortSignal to allow aborting an + * ongoing pipe operation via the corresponding AbortController. In this + * case, this source readable stream will be canceled, and destination + * aborted, unless the respective options preventCancel or preventAbort + * are set. + */ + preventClose?: boolean; + signal?: AbortSignal; + } + interface ReadableStreamGenericReader { + readonly closed: Promise; + cancel(reason?: any): Promise; + } + interface ReadableStreamDefaultReadValueResult { + done: false; + value: T; + } + interface ReadableStreamDefaultReadDoneResult { + done: true; + value?: undefined; + } + type ReadableStreamController = ReadableStreamDefaultController; + type ReadableStreamDefaultReadResult = + | ReadableStreamDefaultReadValueResult + | ReadableStreamDefaultReadDoneResult; + interface ReadableStreamReadValueResult { + done: false; + value: T; + } + interface ReadableStreamReadDoneResult { + done: true; + value?: T; + } + type ReadableStreamReadResult = ReadableStreamReadValueResult | ReadableStreamReadDoneResult; + interface ReadableByteStreamControllerCallback { + (controller: ReadableByteStreamController): void | PromiseLike; + } + interface UnderlyingSinkAbortCallback { + (reason?: any): void | PromiseLike; + } + interface UnderlyingSinkCloseCallback { + (): void | PromiseLike; + } + interface UnderlyingSinkStartCallback { + (controller: WritableStreamDefaultController): any; + } + interface UnderlyingSinkWriteCallback { + (chunk: W, controller: WritableStreamDefaultController): void | PromiseLike; + } + interface UnderlyingSourceCancelCallback { + (reason?: any): void | PromiseLike; + } + interface UnderlyingSourcePullCallback { + (controller: ReadableStreamController): void | PromiseLike; + } + interface UnderlyingSourceStartCallback { + (controller: ReadableStreamController): any; + } + interface TransformerFlushCallback { + (controller: TransformStreamDefaultController): void | PromiseLike; + } + interface TransformerStartCallback { + (controller: TransformStreamDefaultController): any; + } + interface TransformerTransformCallback { + (chunk: I, controller: TransformStreamDefaultController): void | PromiseLike; + } + interface UnderlyingByteSource { + autoAllocateChunkSize?: number; + cancel?: ReadableStreamErrorCallback; + pull?: ReadableByteStreamControllerCallback; + start?: ReadableByteStreamControllerCallback; + type: "bytes"; + } + interface UnderlyingSource { + cancel?: UnderlyingSourceCancelCallback; + pull?: UnderlyingSourcePullCallback; + start?: UnderlyingSourceStartCallback; + type?: undefined; + } + interface UnderlyingSink { + abort?: UnderlyingSinkAbortCallback; + close?: UnderlyingSinkCloseCallback; + start?: UnderlyingSinkStartCallback; + type?: undefined; + write?: UnderlyingSinkWriteCallback; + } + interface ReadableStreamErrorCallback { + (reason: any): void | PromiseLike; + } + /** This Streams API interface represents a readable stream of byte data. */ + interface ReadableStream { + readonly locked: boolean; + cancel(reason?: any): Promise; + getReader(): ReadableStreamDefaultReader; + getReader(options: { mode: "byob" }): ReadableStreamBYOBReader; + pipeThrough(transform: ReadableWritablePair, options?: StreamPipeOptions): ReadableStream; + pipeTo(destination: WritableStream, options?: StreamPipeOptions): Promise; + tee(): [ReadableStream, ReadableStream]; + values(options?: { preventCancel?: boolean }): AsyncIterableIterator; + [Symbol.asyncIterator](): AsyncIterableIterator; + } + const ReadableStream: { + prototype: ReadableStream; + new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy): ReadableStream; + new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; + }; + interface ReadableStreamDefaultReader extends ReadableStreamGenericReader { + read(): Promise>; + releaseLock(): void; + } + interface ReadableStreamBYOBReader extends ReadableStreamGenericReader { + read(view: T): Promise>; + releaseLock(): void; + } + const ReadableStreamDefaultReader: { + prototype: ReadableStreamDefaultReader; + new(stream: ReadableStream): ReadableStreamDefaultReader; + }; + const ReadableStreamBYOBReader: any; + const ReadableStreamBYOBRequest: any; + interface ReadableByteStreamController { + readonly byobRequest: undefined; + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: ArrayBufferView): void; + error(error?: any): void; + } + const ReadableByteStreamController: { + prototype: ReadableByteStreamController; + new(): ReadableByteStreamController; + }; + interface ReadableStreamDefaultController { + readonly desiredSize: number | null; + close(): void; + enqueue(chunk?: R): void; + error(e?: any): void; + } + const ReadableStreamDefaultController: { + prototype: ReadableStreamDefaultController; + new(): ReadableStreamDefaultController; + }; + interface Transformer { + flush?: TransformerFlushCallback; + readableType?: undefined; + start?: TransformerStartCallback; + transform?: TransformerTransformCallback; + writableType?: undefined; + } + interface TransformStream { + readonly readable: ReadableStream; + readonly writable: WritableStream; + } + const TransformStream: { + prototype: TransformStream; + new( + transformer?: Transformer, + writableStrategy?: QueuingStrategy, + readableStrategy?: QueuingStrategy, + ): TransformStream; + }; + interface TransformStreamDefaultController { + readonly desiredSize: number | null; + enqueue(chunk?: O): void; + error(reason?: any): void; + terminate(): void; + } + const TransformStreamDefaultController: { + prototype: TransformStreamDefaultController; + new(): TransformStreamDefaultController; + }; + /** + * This Streams API interface provides a standard abstraction for writing + * streaming data to a destination, known as a sink. This object comes with + * built-in back pressure and queuing. + */ + interface WritableStream { + readonly locked: boolean; + abort(reason?: any): Promise; + close(): Promise; + getWriter(): WritableStreamDefaultWriter; + } + const WritableStream: { + prototype: WritableStream; + new(underlyingSink?: UnderlyingSink, strategy?: QueuingStrategy): WritableStream; + }; + /** + * This Streams API interface is the object returned by + * WritableStream.getWriter() and once created locks the < writer to the + * WritableStream ensuring that no other streams can write to the underlying + * sink. + */ + interface WritableStreamDefaultWriter { + readonly closed: Promise; + readonly desiredSize: number | null; + readonly ready: Promise; + abort(reason?: any): Promise; + close(): Promise; + releaseLock(): void; + write(chunk?: W): Promise; + } + const WritableStreamDefaultWriter: { + prototype: WritableStreamDefaultWriter; + new(stream: WritableStream): WritableStreamDefaultWriter; + }; + /** + * This Streams API interface represents a controller allowing control of a + * WritableStream's state. When constructing a WritableStream, the + * underlying sink is given a corresponding WritableStreamDefaultController + * instance to manipulate. + */ + interface WritableStreamDefaultController { + error(e?: any): void; + } + const WritableStreamDefaultController: { + prototype: WritableStreamDefaultController; + new(): WritableStreamDefaultController; + }; + interface QueuingStrategy { + highWaterMark?: number; + size?: QueuingStrategySize; + } + interface QueuingStrategySize { + (chunk?: T): number; + } + interface QueuingStrategyInit { + /** + * Creates a new ByteLengthQueuingStrategy with the provided high water + * mark. + * + * Note that the provided high water mark will not be validated ahead of + * time. Instead, if it is negative, NaN, or not a number, the resulting + * ByteLengthQueuingStrategy will cause the corresponding stream + * constructor to throw. + */ + highWaterMark: number; + } + /** + * This Streams API interface provides a built-in byte length queuing + * strategy that can be used when constructing streams. + */ + interface ByteLengthQueuingStrategy extends QueuingStrategy { + readonly highWaterMark: number; + readonly size: QueuingStrategySize; + } + const ByteLengthQueuingStrategy: { + prototype: ByteLengthQueuingStrategy; + new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; + }; + /** + * This Streams API interface provides a built-in byte length queuing + * strategy that can be used when constructing streams. + */ + interface CountQueuingStrategy extends QueuingStrategy { + readonly highWaterMark: number; + readonly size: QueuingStrategySize; + } + const CountQueuingStrategy: { + prototype: CountQueuingStrategy; + new(init: QueuingStrategyInit): CountQueuingStrategy; + }; + interface TextEncoderStream { + /** Returns "utf-8". */ + readonly encoding: "utf-8"; + readonly readable: ReadableStream; + readonly writable: WritableStream; + readonly [Symbol.toStringTag]: string; + } + const TextEncoderStream: { + prototype: TextEncoderStream; + new(): TextEncoderStream; + }; + interface TextDecoderOptions { + fatal?: boolean; + ignoreBOM?: boolean; + } + type BufferSource = ArrayBufferView | ArrayBuffer; + interface TextDecoderStream { + /** Returns encoding's name, lower cased. */ + readonly encoding: string; + /** Returns `true` if error mode is "fatal", and `false` otherwise. */ + readonly fatal: boolean; + /** Returns `true` if ignore BOM flag is set, and `false` otherwise. */ + readonly ignoreBOM: boolean; + readonly readable: ReadableStream; + readonly writable: WritableStream; + readonly [Symbol.toStringTag]: string; + } + const TextDecoderStream: { + prototype: TextDecoderStream; + new(label?: string, options?: TextDecoderOptions): TextDecoderStream; + }; +} +declare module "node:stream/web" { + export * from "stream/web"; +} diff --git a/node_modules/@types/node/ts4.8/string_decoder.d.ts b/node_modules/@types/node/ts4.8/string_decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b8691e1f060076e08ed0f023889adef0f2e8fb4e --- /dev/null +++ b/node_modules/@types/node/ts4.8/string_decoder.d.ts @@ -0,0 +1,67 @@ +/** + * The `node:string_decoder` module provides an API for decoding `Buffer` objects + * into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 + * characters. It can be accessed using: + * + * ```js + * const { StringDecoder } = require('node:string_decoder'); + * ``` + * + * The following example shows the basic use of the `StringDecoder` class. + * + * ```js + * const { StringDecoder } = require('node:string_decoder'); + * const decoder = new StringDecoder('utf8'); + * + * const cent = Buffer.from([0xC2, 0xA2]); + * console.log(decoder.write(cent)); // Prints: ¢ + * + * const euro = Buffer.from([0xE2, 0x82, 0xAC]); + * console.log(decoder.write(euro)); // Prints: € + * ``` + * + * When a `Buffer` instance is written to the `StringDecoder` instance, an + * internal buffer is used to ensure that the decoded string does not contain + * any incomplete multibyte characters. These are held in the buffer until the + * next call to `stringDecoder.write()` or until `stringDecoder.end()` is called. + * + * In the following example, the three UTF-8 encoded bytes of the European Euro + * symbol (`€`) are written over three separate operations: + * + * ```js + * const { StringDecoder } = require('node:string_decoder'); + * const decoder = new StringDecoder('utf8'); + * + * decoder.write(Buffer.from([0xE2])); + * decoder.write(Buffer.from([0x82])); + * console.log(decoder.end(Buffer.from([0xAC]))); // Prints: € + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js) + */ +declare module "string_decoder" { + class StringDecoder { + constructor(encoding?: BufferEncoding); + /** + * Returns a decoded string, ensuring that any incomplete multibyte characters at + * the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the + * returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`. + * @since v0.1.99 + * @param buffer The bytes to decode. + */ + write(buffer: Buffer): string; + /** + * Returns any remaining input stored in the internal buffer as a string. Bytes + * representing incomplete UTF-8 and UTF-16 characters will be replaced with + * substitution characters appropriate for the character encoding. + * + * If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input. + * After `end()` is called, the `stringDecoder` object can be reused for new input. + * @since v0.9.3 + * @param buffer The bytes to decode. + */ + end(buffer?: Buffer): string; + } +} +declare module "node:string_decoder" { + export * from "string_decoder"; +} diff --git a/node_modules/@types/node/ts4.8/test.d.ts b/node_modules/@types/node/ts4.8/test.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..44b6a96408bf8ffbb6f4072309fd1cfa7030ade5 --- /dev/null +++ b/node_modules/@types/node/ts4.8/test.d.ts @@ -0,0 +1,1382 @@ +/** + * The `node:test` module facilitates the creation of JavaScript tests. + * To access it: + * + * ```js + * import test from 'node:test'; + * ``` + * + * This module is only available under the `node:` scheme. The following will not + * work: + * + * ```js + * import test from 'test'; + * ``` + * + * Tests created via the `test` module consist of a single function that is + * processed in one of three ways: + * + * 1. A synchronous function that is considered failing if it throws an exception, + * and is considered passing otherwise. + * 2. A function that returns a `Promise` that is considered failing if the`Promise` rejects, and is considered passing if the `Promise` fulfills. + * 3. A function that receives a callback function. If the callback receives any + * truthy value as its first argument, the test is considered failing. If a + * falsy value is passed as the first argument to the callback, the test is + * considered passing. If the test function receives a callback function and + * also returns a `Promise`, the test will fail. + * + * The following example illustrates how tests are written using the`test` module. + * + * ```js + * test('synchronous passing test', (t) => { + * // This test passes because it does not throw an exception. + * assert.strictEqual(1, 1); + * }); + * + * test('synchronous failing test', (t) => { + * // This test fails because it throws an exception. + * assert.strictEqual(1, 2); + * }); + * + * test('asynchronous passing test', async (t) => { + * // This test passes because the Promise returned by the async + * // function is settled and not rejected. + * assert.strictEqual(1, 1); + * }); + * + * test('asynchronous failing test', async (t) => { + * // This test fails because the Promise returned by the async + * // function is rejected. + * assert.strictEqual(1, 2); + * }); + * + * test('failing test using Promises', (t) => { + * // Promises can be used directly as well. + * return new Promise((resolve, reject) => { + * setImmediate(() => { + * reject(new Error('this will cause the test to fail')); + * }); + * }); + * }); + * + * test('callback passing test', (t, done) => { + * // done() is the callback function. When the setImmediate() runs, it invokes + * // done() with no arguments. + * setImmediate(done); + * }); + * + * test('callback failing test', (t, done) => { + * // When the setImmediate() runs, done() is invoked with an Error object and + * // the test fails. + * setImmediate(() => { + * done(new Error('callback failure')); + * }); + * }); + * ``` + * + * If any tests fail, the process exit code is set to `1`. + * @since v18.0.0, v16.17.0 + * @see [source](https://github.com/nodejs/node/blob/v20.4.0/lib/test.js) + */ +declare module "node:test" { + import { Readable } from "node:stream"; + import { AsyncResource } from "node:async_hooks"; + /** + * ```js + * import { tap } from 'node:test/reporters'; + * import { run } from 'node:test'; + * import process from 'node:process'; + * import path from 'node:path'; + * + * run({ files: [path.resolve('./tests/test.js')] }) + * .compose(tap) + * .pipe(process.stdout); + * ``` + * @since v18.9.0, v16.19.0 + * @param options Configuration options for running tests. The following properties are supported: + */ + function run(options?: RunOptions): TestsStream; + /** + * The `test()` function is the value imported from the `test` module. Each + * invocation of this function results in reporting the test to the `TestsStream`. + * + * The `TestContext` object passed to the `fn` argument can be used to perform + * actions related to the current test. Examples include skipping the test, adding + * additional diagnostic information, or creating subtests. + * + * `test()` returns a `Promise` that fulfills once the test completes. + * if `test()` is called within a `describe()` block, it fulfills immediately. + * The return value can usually be discarded for top level tests. + * However, the return value from subtests should be used to prevent the parent + * test from finishing first and cancelling the subtest + * as shown in the following example. + * + * ```js + * test('top level test', async (t) => { + * // The setTimeout() in the following subtest would cause it to outlive its + * // parent test if 'await' is removed on the next line. Once the parent test + * // completes, it will cancel any outstanding subtests. + * await t.test('longer running subtest', async (t) => { + * return new Promise((resolve, reject) => { + * setTimeout(resolve, 1000); + * }); + * }); + * }); + * ``` + * + * The `timeout` option can be used to fail the test if it takes longer than`timeout` milliseconds to complete. However, it is not a reliable mechanism for + * canceling tests because a running test might block the application thread and + * thus prevent the scheduled cancellation. + * @since v18.0.0, v16.17.0 + * @param [name='The name'] The name of the test, which is displayed when reporting test results. + * @param options Configuration options for the test. The following properties are supported: + * @param [fn='A no-op function'] The function under test. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the callback function is passed as the + * second argument. + * @return Fulfilled with `undefined` once the test completes, or immediately if the test runs within {@link describe}. + */ + function test(name?: string, fn?: TestFn): Promise; + function test(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function test(options?: TestOptions, fn?: TestFn): Promise; + function test(fn?: TestFn): Promise; + namespace test { + export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, test, todo }; + } + /** + * The `describe()` function imported from the `node:test` module. Each + * invocation of this function results in the creation of a Subtest. + * After invocation of top level `describe` functions, + * all top level tests and suites will execute. + * @param [name='The name'] The name of the suite, which is displayed when reporting test results. + * @param options Configuration options for the suite. supports the same options as `test([name][, options][, fn])`. + * @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object. + * @return Immediately fulfilled with `undefined`. + */ + function describe(name?: string, options?: TestOptions, fn?: SuiteFn): Promise; + function describe(name?: string, fn?: SuiteFn): Promise; + function describe(options?: TestOptions, fn?: SuiteFn): Promise; + function describe(fn?: SuiteFn): Promise; + namespace describe { + /** + * Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`. + */ + function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise; + function skip(name?: string, fn?: SuiteFn): Promise; + function skip(options?: TestOptions, fn?: SuiteFn): Promise; + function skip(fn?: SuiteFn): Promise; + /** + * Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`. + */ + function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise; + function todo(name?: string, fn?: SuiteFn): Promise; + function todo(options?: TestOptions, fn?: SuiteFn): Promise; + function todo(fn?: SuiteFn): Promise; + /** + * Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`. + * @since v18.15.0 + */ + function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise; + function only(name?: string, fn?: SuiteFn): Promise; + function only(options?: TestOptions, fn?: SuiteFn): Promise; + function only(fn?: SuiteFn): Promise; + } + /** + * Shorthand for `test()`. + * + * The `it()` function is imported from the `node:test` module. + * @since v18.6.0, v16.17.0 + */ + function it(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function it(name?: string, fn?: TestFn): Promise; + function it(options?: TestOptions, fn?: TestFn): Promise; + function it(fn?: TestFn): Promise; + namespace it { + /** + * Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`. + */ + function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function skip(name?: string, fn?: TestFn): Promise; + function skip(options?: TestOptions, fn?: TestFn): Promise; + function skip(fn?: TestFn): Promise; + /** + * Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`. + */ + function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function todo(name?: string, fn?: TestFn): Promise; + function todo(options?: TestOptions, fn?: TestFn): Promise; + function todo(fn?: TestFn): Promise; + /** + * Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`. + * @since v18.15.0 + */ + function only(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function only(name?: string, fn?: TestFn): Promise; + function only(options?: TestOptions, fn?: TestFn): Promise; + function only(fn?: TestFn): Promise; + } + /** + * Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`. + * @since v20.2.0 + */ + function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function skip(name?: string, fn?: TestFn): Promise; + function skip(options?: TestOptions, fn?: TestFn): Promise; + function skip(fn?: TestFn): Promise; + /** + * Shorthand for marking a test as `TODO`, same as `test([name], { todo: true }[, fn])`. + * @since v20.2.0 + */ + function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function todo(name?: string, fn?: TestFn): Promise; + function todo(options?: TestOptions, fn?: TestFn): Promise; + function todo(fn?: TestFn): Promise; + /** + * Shorthand for marking a test as `only`, same as `test([name], { only: true }[, fn])`. + * @since v20.2.0 + */ + function only(name?: string, options?: TestOptions, fn?: TestFn): Promise; + function only(name?: string, fn?: TestFn): Promise; + function only(options?: TestOptions, fn?: TestFn): Promise; + function only(fn?: TestFn): Promise; + /** + * The type of a function under test. The first argument to this function is a + * {@link TestContext} object. If the test uses callbacks, the callback function is passed as + * the second argument. + */ + type TestFn = (t: TestContext, done: (result?: any) => void) => void | Promise; + /** + * The type of a function under Suite. + */ + type SuiteFn = (s: SuiteContext) => void | Promise; + interface TestShard { + /** + * A positive integer between 1 and `` that specifies the index of the shard to run. + */ + index: number; + /** + * A positive integer that specifies the total number of shards to split the test files to. + */ + total: number; + } + interface RunOptions { + /** + * If a number is provided, then that many files would run in parallel. + * If truthy, it would run (number of cpu cores - 1) files in parallel. + * If falsy, it would only run one file at a time. + * If unspecified, subtests inherit this value from their parent. + * @default true + */ + concurrency?: number | boolean | undefined; + /** + * An array containing the list of files to run. + * If unspecified, the test runner execution model will be used. + */ + files?: readonly string[] | undefined; + /** + * Allows aborting an in-progress test execution. + * @default undefined + */ + signal?: AbortSignal | undefined; + /** + * A number of milliseconds the test will fail after. + * If unspecified, subtests inherit this value from their parent. + * @default Infinity + */ + timeout?: number | undefined; + /** + * Sets inspector port of test child process. + * If a nullish value is provided, each process gets its own port, + * incremented from the primary's `process.debugPort`. + */ + inspectPort?: number | (() => number) | undefined; + /** + * That can be used to only run tests whose name matches the provided pattern. + * Test name patterns are interpreted as JavaScript regular expressions. + * For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run. + */ + testNamePatterns?: string | RegExp | string[] | RegExp[]; + /** + * If truthy, the test context will only run tests that have the `only` option set + */ + only?: boolean; + /** + * A function that accepts the TestsStream instance and can be used to setup listeners before any tests are run. + */ + setup?: (root: Test) => void | Promise; + /** + * Whether to run in watch mode or not. + * @default false + */ + watch?: boolean | undefined; + /** + * Running tests in a specific shard. + * @default undefined + */ + shard?: TestShard | undefined; + } + class Test extends AsyncResource { + concurrency: number; + nesting: number; + only: boolean; + reporter: TestsStream; + runOnlySubtests: boolean; + testNumber: number; + timeout: number | null; + } + /** + * A successful call to `run()` method will return a new `TestsStream` object, streaming a series of events representing the execution of the tests.`TestsStream` will emit events, in the + * order of the tests definition + * @since v18.9.0, v16.19.0 + */ + class TestsStream extends Readable implements NodeJS.ReadableStream { + addListener(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + addListener(event: "test:fail", listener: (data: TestFail) => void): this; + addListener(event: "test:pass", listener: (data: TestPass) => void): this; + addListener(event: "test:plan", listener: (data: TestPlan) => void): this; + addListener(event: "test:start", listener: (data: TestStart) => void): this; + addListener(event: "test:stderr", listener: (data: TestStderr) => void): this; + addListener(event: "test:stdout", listener: (data: TestStdout) => void): this; + addListener(event: string, listener: (...args: any[]) => void): this; + emit(event: "test:diagnostic", data: DiagnosticData): boolean; + emit(event: "test:fail", data: TestFail): boolean; + emit(event: "test:pass", data: TestPass): boolean; + emit(event: "test:plan", data: TestPlan): boolean; + emit(event: "test:start", data: TestStart): boolean; + emit(event: "test:stderr", data: TestStderr): boolean; + emit(event: "test:stdout", data: TestStdout): boolean; + emit(event: string | symbol, ...args: any[]): boolean; + on(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + on(event: "test:fail", listener: (data: TestFail) => void): this; + on(event: "test:pass", listener: (data: TestPass) => void): this; + on(event: "test:plan", listener: (data: TestPlan) => void): this; + on(event: "test:start", listener: (data: TestStart) => void): this; + on(event: "test:stderr", listener: (data: TestStderr) => void): this; + on(event: "test:stdout", listener: (data: TestStdout) => void): this; + on(event: string, listener: (...args: any[]) => void): this; + once(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + once(event: "test:fail", listener: (data: TestFail) => void): this; + once(event: "test:pass", listener: (data: TestPass) => void): this; + once(event: "test:plan", listener: (data: TestPlan) => void): this; + once(event: "test:start", listener: (data: TestStart) => void): this; + once(event: "test:stderr", listener: (data: TestStderr) => void): this; + once(event: "test:stdout", listener: (data: TestStdout) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + prependListener(event: "test:fail", listener: (data: TestFail) => void): this; + prependListener(event: "test:pass", listener: (data: TestPass) => void): this; + prependListener(event: "test:plan", listener: (data: TestPlan) => void): this; + prependListener(event: "test:start", listener: (data: TestStart) => void): this; + prependListener(event: "test:stderr", listener: (data: TestStderr) => void): this; + prependListener(event: "test:stdout", listener: (data: TestStdout) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "test:diagnostic", listener: (data: DiagnosticData) => void): this; + prependOnceListener(event: "test:fail", listener: (data: TestFail) => void): this; + prependOnceListener(event: "test:pass", listener: (data: TestPass) => void): this; + prependOnceListener(event: "test:plan", listener: (data: TestPlan) => void): this; + prependOnceListener(event: "test:start", listener: (data: TestStart) => void): this; + prependOnceListener(event: "test:stderr", listener: (data: TestStderr) => void): this; + prependOnceListener(event: "test:stdout", listener: (data: TestStdout) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + } + /** + * An instance of `TestContext` is passed to each test function in order to + * interact with the test runner. However, the `TestContext` constructor is not + * exposed as part of the API. + * @since v18.0.0, v16.17.0 + */ + class TestContext { + /** + * This function is used to create a hook running before subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v20.1.0 + */ + before: typeof before; + /** + * This function is used to create a hook running before each subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.8.0 + */ + beforeEach: typeof beforeEach; + /** + * This function is used to create a hook that runs after the current test finishes. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.13.0 + */ + after: typeof after; + /** + * This function is used to create a hook running after each subtest of the current test. + * @param fn The hook function. If the hook uses callbacks, the callback function is passed as + * the second argument. Default: A no-op function. + * @param options Configuration options for the hook. + * @since v18.8.0 + */ + afterEach: typeof afterEach; + /** + * This function is used to write diagnostics to the output. Any diagnostic + * information is included at the end of the test's results. This function does + * not return a value. + * + * ```js + * test('top level test', (t) => { + * t.diagnostic('A diagnostic message'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Message to be reported. + */ + diagnostic(message: string): void; + /** + * The name of the test. + * @since v18.8.0, v16.18.0 + */ + readonly name: string; + /** + * If `shouldRunOnlyTests` is truthy, the test context will only run tests that + * have the `only` option set. Otherwise, all tests are run. If Node.js was not + * started with the `--test-only` command-line option, this function is a + * no-op. + * + * ```js + * test('top level test', (t) => { + * // The test context can be set to run subtests with the 'only' option. + * t.runOnly(true); + * return Promise.all([ + * t.test('this subtest is now skipped'), + * t.test('this subtest is run', { only: true }), + * ]); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param shouldRunOnlyTests Whether or not to run `only` tests. + */ + runOnly(shouldRunOnlyTests: boolean): void; + /** + * ```js + * test('top level test', async (t) => { + * await fetch('some/uri', { signal: t.signal }); + * }); + * ``` + * @since v18.7.0, v16.17.0 + */ + readonly signal: AbortSignal; + /** + * This function causes the test's output to indicate the test as skipped. If`message` is provided, it is included in the output. Calling `skip()` does + * not terminate execution of the test function. This function does not return a + * value. + * + * ```js + * test('top level test', (t) => { + * // Make sure to return here as well if the test contains additional logic. + * t.skip('this is skipped'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Optional skip message. + */ + skip(message?: string): void; + /** + * This function adds a `TODO` directive to the test's output. If `message` is + * provided, it is included in the output. Calling `todo()` does not terminate + * execution of the test function. This function does not return a value. + * + * ```js + * test('top level test', (t) => { + * // This test is marked as `TODO` + * t.todo('this is a todo'); + * }); + * ``` + * @since v18.0.0, v16.17.0 + * @param message Optional `TODO` message. + */ + todo(message?: string): void; + /** + * This function is used to create subtests under the current test. This function behaves in + * the same fashion as the top level {@link test} function. + * @since v18.0.0 + * @param name The name of the test, which is displayed when reporting test results. + * Default: The `name` property of fn, or `''` if `fn` does not have a name. + * @param options Configuration options for the test + * @param fn The function under test. This first argument to this function is a + * {@link TestContext} object. If the test uses callbacks, the callback function is + * passed as the second argument. Default: A no-op function. + * @returns A {@link Promise} resolved with `undefined` once the test completes. + */ + test: typeof test; + /** + * Each test provides its own MockTracker instance. + */ + readonly mock: MockTracker; + } + /** + * An instance of `SuiteContext` is passed to each suite function in order to + * interact with the test runner. However, the `SuiteContext` constructor is not + * exposed as part of the API. + * @since v18.7.0, v16.17.0 + */ + class SuiteContext { + /** + * The name of the suite. + * @since v18.8.0, v16.18.0 + */ + readonly name: string; + /** + * Can be used to abort test subtasks when the test has been aborted. + * @since v18.7.0, v16.17.0 + */ + readonly signal: AbortSignal; + } + interface TestOptions { + /** + * If a number is provided, then that many tests would run in parallel. + * If truthy, it would run (number of cpu cores - 1) tests in parallel. + * For subtests, it will be `Infinity` tests in parallel. + * If falsy, it would only run one test at a time. + * If unspecified, subtests inherit this value from their parent. + * @default false + */ + concurrency?: number | boolean | undefined; + /** + * If truthy, and the test context is configured to run `only` tests, then this test will be + * run. Otherwise, the test is skipped. + * @default false + */ + only?: boolean | undefined; + /** + * Allows aborting an in-progress test. + * @since v18.8.0 + */ + signal?: AbortSignal | undefined; + /** + * If truthy, the test is skipped. If a string is provided, that string is displayed in the + * test results as the reason for skipping the test. + * @default false + */ + skip?: boolean | string | undefined; + /** + * A number of milliseconds the test will fail after. If unspecified, subtests inherit this + * value from their parent. + * @default Infinity + * @since v18.7.0 + */ + timeout?: number | undefined; + /** + * If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in + * the test results as the reason why the test is `TODO`. + * @default false + */ + todo?: boolean | string | undefined; + } + /** + * This function is used to create a hook running before running a suite. + * + * ```js + * describe('tests', async () => { + * before(() => console.log('about to run some test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function before(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running after running a suite. + * + * ```js + * describe('tests', async () => { + * after(() => console.log('finished running tests')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function after(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running + * before each subtest of the current suite. + * + * ```js + * describe('tests', async () => { + * beforeEach(() => console.log('about to run a test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function beforeEach(fn?: HookFn, options?: HookOptions): void; + /** + * This function is used to create a hook running + * after each subtest of the current test. + * + * ```js + * describe('tests', async () => { + * afterEach(() => console.log('finished running a test')); + * it('is a subtest', () => { + * assert.ok('some relevant assertion here'); + * }); + * }); + * ``` + * @since v18.8.0, v16.18.0 + * @param [fn='A no-op function'] The hook function. If the hook uses callbacks, the callback function is passed as the second argument. + * @param options Configuration options for the hook. The following properties are supported: + */ + function afterEach(fn?: HookFn, options?: HookOptions): void; + /** + * The hook function. If the hook uses callbacks, the callback function is passed as the + * second argument. + */ + type HookFn = (s: SuiteContext, done: (result?: any) => void) => any; + /** + * Configuration options for hooks. + * @since v18.8.0 + */ + interface HookOptions { + /** + * Allows aborting an in-progress hook. + */ + signal?: AbortSignal | undefined; + /** + * A number of milliseconds the hook will fail after. If unspecified, subtests inherit this + * value from their parent. + * @default Infinity + */ + timeout?: number | undefined; + } + interface MockFunctionOptions { + /** + * The number of times that the mock will use the behavior of `implementation`. + * Once the mock function has been called `times` times, + * it will automatically restore the behavior of `original`. + * This value must be an integer greater than zero. + * @default Infinity + */ + times?: number | undefined; + } + interface MockMethodOptions extends MockFunctionOptions { + /** + * If `true`, `object[methodName]` is treated as a getter. + * This option cannot be used with the `setter` option. + */ + getter?: boolean | undefined; + /** + * If `true`, `object[methodName]` is treated as a setter. + * This option cannot be used with the `getter` option. + */ + setter?: boolean | undefined; + } + type Mock = F & { + mock: MockFunctionContext; + }; + type NoOpFunction = (...args: any[]) => undefined; + type FunctionPropertyNames = { + [K in keyof T]: T[K] extends Function ? K : never; + }[keyof T]; + /** + * The `MockTracker` class is used to manage mocking functionality. The test runner + * module provides a top level `mock` export which is a `MockTracker` instance. + * Each test also provides its own `MockTracker` instance via the test context's`mock` property. + * @since v19.1.0, v18.13.0 + */ + class MockTracker { + /** + * This function is used to create a mock function. + * + * The following example creates a mock function that increments a counter by one + * on each invocation. The `times` option is used to modify the mock behavior such + * that the first two invocations add two to the counter instead of one. + * + * ```js + * test('mocks a counting function', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne, addTwo, { times: 2 }); + * + * assert.strictEqual(fn(), 2); + * assert.strictEqual(fn(), 4); + * assert.strictEqual(fn(), 5); + * assert.strictEqual(fn(), 6); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param [original='A no-op function'] An optional function to create a mock on. + * @param implementation An optional function used as the mock implementation for `original`. This is useful for creating mocks that exhibit one behavior for a specified number of calls and + * then restore the behavior of `original`. + * @param options Optional configuration options for the mock function. The following properties are supported: + * @return The mocked function. The mocked function contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the + * behavior of the mocked function. + */ + fn(original?: F, options?: MockFunctionOptions): Mock; + fn( + original?: F, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock; + /** + * This function is used to create a mock on an existing object method. The + * following example demonstrates how a mock is created on an existing object + * method. + * + * ```js + * test('spies on an object method', (t) => { + * const number = { + * value: 5, + * subtract(a) { + * return this.value - a; + * }, + * }; + * + * t.mock.method(number, 'subtract'); + * assert.strictEqual(number.subtract.mock.calls.length, 0); + * assert.strictEqual(number.subtract(3), 2); + * assert.strictEqual(number.subtract.mock.calls.length, 1); + * + * const call = number.subtract.mock.calls[0]; + * + * assert.deepStrictEqual(call.arguments, [3]); + * assert.strictEqual(call.result, 2); + * assert.strictEqual(call.error, undefined); + * assert.strictEqual(call.target, undefined); + * assert.strictEqual(call.this, number); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param object The object whose method is being mocked. + * @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown. + * @param implementation An optional function used as the mock implementation for `object[methodName]`. + * @param options Optional configuration options for the mock method. The following properties are supported: + * @return The mocked method. The mocked method contains a special `mock` property, which is an instance of {@link MockFunctionContext}, and can be used for inspecting and changing the + * behavior of the mocked method. + */ + method< + MockedObject extends object, + MethodName extends FunctionPropertyNames, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): MockedObject[MethodName] extends Function ? Mock + : never; + method< + MockedObject extends object, + MethodName extends FunctionPropertyNames, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation: Implementation, + options?: MockFunctionOptions, + ): MockedObject[MethodName] extends Function ? Mock + : never; + method( + object: MockedObject, + methodName: keyof MockedObject, + options: MockMethodOptions, + ): Mock; + method( + object: MockedObject, + methodName: keyof MockedObject, + implementation: Function, + options: MockMethodOptions, + ): Mock; + + /** + * This function is syntax sugar for `MockTracker.method` with `options.getter`set to `true`. + * @since v19.3.0, v18.13.0 + */ + getter< + MockedObject extends object, + MethodName extends keyof MockedObject, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): Mock<() => MockedObject[MethodName]>; + getter< + MockedObject extends object, + MethodName extends keyof MockedObject, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock<(() => MockedObject[MethodName]) | Implementation>; + /** + * This function is syntax sugar for `MockTracker.method` with `options.setter`set to `true`. + * @since v19.3.0, v18.13.0 + */ + setter< + MockedObject extends object, + MethodName extends keyof MockedObject, + >( + object: MockedObject, + methodName: MethodName, + options?: MockFunctionOptions, + ): Mock<(value: MockedObject[MethodName]) => void>; + setter< + MockedObject extends object, + MethodName extends keyof MockedObject, + Implementation extends Function, + >( + object: MockedObject, + methodName: MethodName, + implementation?: Implementation, + options?: MockFunctionOptions, + ): Mock<((value: MockedObject[MethodName]) => void) | Implementation>; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTracker` and disassociates the mocks from the`MockTracker` instance. Once disassociated, the mocks can still be used, but the`MockTracker` instance can no longer be + * used to reset their behavior or + * otherwise interact with them. + * + * After each test completes, this function is called on the test context's`MockTracker`. If the global `MockTracker` is used extensively, calling this + * function manually is recommended. + * @since v19.1.0, v18.13.0 + */ + reset(): void; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTracker`. Unlike `mock.reset()`, `mock.restoreAll()` does + * not disassociate the mocks from the `MockTracker` instance. + * @since v19.1.0, v18.13.0 + */ + restoreAll(): void; + timers: MockTimers; + } + const mock: MockTracker; + interface MockFunctionCall< + F extends Function, + ReturnType = F extends (...args: any) => infer T ? T + : F extends abstract new(...args: any) => infer T ? T + : unknown, + Args = F extends (...args: infer Y) => any ? Y + : F extends abstract new(...args: infer Y) => any ? Y + : unknown[], + > { + /** + * An array of the arguments passed to the mock function. + */ + arguments: Args; + /** + * If the mocked function threw then this property contains the thrown value. + */ + error: unknown | undefined; + /** + * The value returned by the mocked function. + * + * If the mocked function threw, it will be `undefined`. + */ + result: ReturnType | undefined; + /** + * An `Error` object whose stack can be used to determine the callsite of the mocked function invocation. + */ + stack: Error; + /** + * If the mocked function is a constructor, this field contains the class being constructed. + * Otherwise this will be `undefined`. + */ + target: F extends abstract new(...args: any) => any ? F : undefined; + /** + * The mocked function's `this` value. + */ + this: unknown; + } + /** + * The `MockFunctionContext` class is used to inspect or manipulate the behavior of + * mocks created via the `MockTracker` APIs. + * @since v19.1.0, v18.13.0 + */ + class MockFunctionContext { + /** + * A getter that returns a copy of the internal array used to track calls to the + * mock. Each entry in the array is an object with the following properties. + * @since v19.1.0, v18.13.0 + */ + readonly calls: Array>; + /** + * This function returns the number of times that this mock has been invoked. This + * function is more efficient than checking `ctx.calls.length` because `ctx.calls`is a getter that creates a copy of the internal call tracking array. + * @since v19.1.0, v18.13.0 + * @return The number of times that this mock has been invoked. + */ + callCount(): number; + /** + * This function is used to change the behavior of an existing mock. + * + * The following example creates a mock function using `t.mock.fn()`, calls the + * mock function, and then changes the mock implementation to a different function. + * + * ```js + * test('changes a mock behavior', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne); + * + * assert.strictEqual(fn(), 1); + * fn.mock.mockImplementation(addTwo); + * assert.strictEqual(fn(), 3); + * assert.strictEqual(fn(), 5); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param implementation The function to be used as the mock's new implementation. + */ + mockImplementation(implementation: Function): void; + /** + * This function is used to change the behavior of an existing mock for a single + * invocation. Once invocation `onCall` has occurred, the mock will revert to + * whatever behavior it would have used had `mockImplementationOnce()` not been + * called. + * + * The following example creates a mock function using `t.mock.fn()`, calls the + * mock function, changes the mock implementation to a different function for the + * next invocation, and then resumes its previous behavior. + * + * ```js + * test('changes a mock behavior once', (t) => { + * let cnt = 0; + * + * function addOne() { + * cnt++; + * return cnt; + * } + * + * function addTwo() { + * cnt += 2; + * return cnt; + * } + * + * const fn = t.mock.fn(addOne); + * + * assert.strictEqual(fn(), 1); + * fn.mock.mockImplementationOnce(addTwo); + * assert.strictEqual(fn(), 3); + * assert.strictEqual(fn(), 4); + * }); + * ``` + * @since v19.1.0, v18.13.0 + * @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`. + * @param onCall The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown. + */ + mockImplementationOnce(implementation: Function, onCall?: number): void; + /** + * Resets the call history of the mock function. + * @since v19.3.0, v18.13.0 + */ + resetCalls(): void; + /** + * Resets the implementation of the mock function to its original behavior. The + * mock can still be used after calling this function. + * @since v19.1.0, v18.13.0 + */ + restore(): void; + } + type Timer = "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout"; + /** + * Mocking timers is a technique commonly used in software testing to simulate and + * control the behavior of timers, such as `setInterval` and `setTimeout`, + * without actually waiting for the specified time intervals. + * + * The `MockTracker` provides a top-level `timers` export + * which is a `MockTimers` instance. + * @since v20.4.0 + * @experimental + */ + class MockTimers { + /** + * Enables timer mocking for the specified timers. + * + * **Note:** When you enable mocking for a specific timer, its associated + * clear function will also be implicitly mocked. + * + * Example usage: + * + * ```js + * import { mock } from 'node:test'; + * mock.timers.enable(['setInterval']); + * ``` + * + * The above example enables mocking for the `setInterval` timer and + * implicitly mocks the `clearInterval` function. Only the `setInterval`and `clearInterval` functions from `node:timers`,`node:timers/promises`, and`globalThis` will be mocked. + * + * Alternatively, if you call `mock.timers.enable()` without any parameters: + * + * All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`) + * will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`, + * and `globalThis` will be mocked. + * @since v20.4.0 + */ + enable(timers?: Timer[]): void; + /** + * This function restores the default behavior of all mocks that were previously + * created by this `MockTimers` instance and disassociates the mocks + * from the `MockTracker` instance. + * + * **Note:** After each test completes, this function is called on + * the test context's `MockTracker`. + * + * ```js + * import { mock } from 'node:test'; + * mock.timers.reset(); + * ``` + * @since v20.4.0 + */ + reset(): void; + /** + * Advances time for all mocked timers. + * + * **Note:** This diverges from how `setTimeout` in Node.js behaves and accepts + * only positive numbers. In Node.js, `setTimeout` with negative numbers is + * only supported for web compatibility reasons. + * + * The following example mocks a `setTimeout` function and + * by using `.tick` advances in + * time triggering all pending timers. + * + * ```js + * import assert from 'node:assert'; + * import { test } from 'node:test'; + * + * test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => { + * const fn = context.mock.fn(); + * + * context.mock.timers.enable(['setTimeout']); + * + * setTimeout(fn, 9999); + * + * assert.strictEqual(fn.mock.callCount(), 0); + * + * // Advance in time + * context.mock.timers.tick(9999); + * + * assert.strictEqual(fn.mock.callCount(), 1); + * }); + * ``` + * + * Alternativelly, the `.tick` function can be called many times + * + * ```js + * import assert from 'node:assert'; + * import { test } from 'node:test'; + * + * test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => { + * const fn = context.mock.fn(); + * context.mock.timers.enable(['setTimeout']); + * const nineSecs = 9000; + * setTimeout(fn, nineSecs); + * + * const twoSeconds = 3000; + * context.mock.timers.tick(twoSeconds); + * context.mock.timers.tick(twoSeconds); + * context.mock.timers.tick(twoSeconds); + * + * assert.strictEqual(fn.mock.callCount(), 1); + * }); + * ``` + * @since v20.4.0 + */ + tick(milliseconds: number): void; + /** + * Triggers all pending mocked timers immediately. + * + * The example below triggers all pending timers immediately, + * causing them to execute without any delay. + * + * ```js + * import assert from 'node:assert'; + * import { test } from 'node:test'; + * + * test('runAll functions following the given order', (context) => { + * context.mock.timers.enable(['setTimeout']); + * const results = []; + * setTimeout(() => results.push(1), 9999); + * + * // Notice that if both timers have the same timeout, + * // the order of execution is guaranteed + * setTimeout(() => results.push(3), 8888); + * setTimeout(() => results.push(2), 8888); + * + * assert.deepStrictEqual(results, []); + * + * context.mock.timers.runAll(); + * + * assert.deepStrictEqual(results, [3, 2, 1]); + * }); + * ``` + * + * **Note:** The `runAll()` function is specifically designed for + * triggering timers in the context of timer mocking. + * It does not have any effect on real-time system + * clocks or actual timers outside of the mocking environment. + * @since v20.4.0 + */ + runAll(): void; + /** + * Calls {@link MockTimers.reset()}. + */ + [Symbol.dispose](): void; + } + export { + after, + afterEach, + before, + beforeEach, + describe, + it, + Mock, + mock, + only, + run, + skip, + test, + test as default, + todo, + }; +} + +interface TestLocationInfo { + /** + * The column number where the test is defined, or + * `undefined` if the test was run through the REPL. + */ + column?: number; + /** + * The path of the test file, `undefined` if test is not ran through a file. + */ + file?: string; + /** + * The line number where the test is defined, or + * `undefined` if the test was run through the REPL. + */ + line?: number; +} +interface DiagnosticData extends TestLocationInfo { + /** + * The diagnostic message. + */ + message: string; + /** + * The nesting level of the test. + */ + nesting: number; +} +interface TestFail extends TestLocationInfo { + /** + * Additional execution metadata. + */ + details: { + /** + * The duration of the test in milliseconds. + */ + duration_ms: number; + /** + * The error thrown by the test. + */ + error: Error; + /** + * The type of the test, used to denote whether this is a suite. + * @since 20.0.0, 19.9.0, 18.17.0 + */ + type?: "suite"; + }; + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The ordinal number of the test. + */ + testNumber: number; + /** + * Present if `context.todo` is called. + */ + todo?: string | boolean; + /** + * Present if `context.skip` is called. + */ + skip?: string | boolean; +} +interface TestPass extends TestLocationInfo { + /** + * Additional execution metadata. + */ + details: { + /** + * The duration of the test in milliseconds. + */ + duration_ms: number; + /** + * The type of the test, used to denote whether this is a suite. + * @since 20.0.0, 19.9.0, 18.17.0 + */ + type?: "suite"; + }; + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The ordinal number of the test. + */ + testNumber: number; + /** + * Present if `context.todo` is called. + */ + todo?: string | boolean; + /** + * Present if `context.skip` is called. + */ + skip?: string | boolean; +} +interface TestPlan extends TestLocationInfo { + /** + * The nesting level of the test. + */ + nesting: number; + /** + * The number of subtests that have ran. + */ + count: number; +} +interface TestStart extends TestLocationInfo { + /** + * The test name. + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; +} +interface TestStderr extends TestLocationInfo { + /** + * The message written to `stderr` + */ + message: string; +} +interface TestStdout extends TestLocationInfo { + /** + * The message written to `stdout` + */ + message: string; +} +interface TestEnqueue extends TestLocationInfo { + /** + * The test name + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; +} +interface TestDequeue extends TestLocationInfo { + /** + * The test name + */ + name: string; + /** + * The nesting level of the test. + */ + nesting: number; +} + +/** + * The `node:test/reporters` module exposes the builtin-reporters for `node:test`. + * To access it: + * + * ```js + * import test from 'node:test/reporters'; + * ``` + * + * This module is only available under the `node:` scheme. The following will not + * work: + * + * ```js + * import test from 'test/reporters'; + * ``` + * @since v19.9.0 + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/test/reporters.js) + */ +declare module "node:test/reporters" { + import { Transform } from "node:stream"; + + type TestEvent = + | { type: "test:diagnostic"; data: DiagnosticData } + | { type: "test:fail"; data: TestFail } + | { type: "test:pass"; data: TestPass } + | { type: "test:plan"; data: TestPlan } + | { type: "test:start"; data: TestStart } + | { type: "test:stderr"; data: TestStderr } + | { type: "test:stdout"; data: TestStdout } + | { type: "test:enqueue"; data: TestEnqueue } + | { type: "test:dequeue"; data: TestDequeue } + | { type: "test:watch:drained" }; + type TestEventGenerator = AsyncGenerator; + + /** + * The `dot` reporter outputs the test results in a compact format, + * where each passing test is represented by a `.`, + * and each failing test is represented by a `X`. + */ + function dot(source: TestEventGenerator): AsyncGenerator<"\n" | "." | "X", void>; + /** + * The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format. + */ + function tap(source: TestEventGenerator): AsyncGenerator; + /** + * The `spec` reporter outputs the test results in a human-readable format. + */ + class Spec extends Transform { + constructor(); + } + /** + * The `junit` reporter outputs test results in a jUnit XML format + */ + function junit(source: TestEventGenerator): AsyncGenerator; + export { dot, junit, Spec as spec, tap, TestEvent }; +} diff --git a/node_modules/@types/node/ts4.8/timers.d.ts b/node_modules/@types/node/ts4.8/timers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..039f31f7ad0e07c4a455b0db6204648fe0e3e8b4 --- /dev/null +++ b/node_modules/@types/node/ts4.8/timers.d.ts @@ -0,0 +1,240 @@ +/** + * The `timer` module exposes a global API for scheduling functions to + * be called at some future period of time. Because the timer functions are + * globals, there is no need to call `require('node:timers')` to use the API. + * + * The timer functions within Node.js implement a similar API as the timers API + * provided by Web Browsers but use a different internal implementation that is + * built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout). + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/timers.js) + */ +declare module "timers" { + import { Abortable } from "node:events"; + import { + setImmediate as setImmediatePromise, + setInterval as setIntervalPromise, + setTimeout as setTimeoutPromise, + } from "node:timers/promises"; + interface TimerOptions extends Abortable { + /** + * Set to `false` to indicate that the scheduled `Timeout` + * should not require the Node.js event loop to remain active. + * @default true + */ + ref?: boolean | undefined; + } + let setTimeout: typeof global.setTimeout; + let clearTimeout: typeof global.clearTimeout; + let setInterval: typeof global.setInterval; + let clearInterval: typeof global.clearInterval; + let setImmediate: typeof global.setImmediate; + let clearImmediate: typeof global.clearImmediate; + global { + namespace NodeJS { + // compatibility with older typings + interface Timer extends RefCounted { + hasRef(): boolean; + refresh(): this; + [Symbol.toPrimitive](): number; + } + /** + * This object is created internally and is returned from `setImmediate()`. It + * can be passed to `clearImmediate()` in order to cancel the scheduled + * actions. + * + * By default, when an immediate is scheduled, the Node.js event loop will continue + * running as long as the immediate is active. The `Immediate` object returned by `setImmediate()` exports both `immediate.ref()` and `immediate.unref()`functions that can be used to + * control this default behavior. + */ + class Immediate implements RefCounted { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the`Immediate` is active. Calling `immediate.ref()` multiple times will have no + * effect. + * + * By default, all `Immediate` objects are "ref'ed", making it normally unnecessary + * to call `immediate.ref()` unless `immediate.unref()` had been called previously. + * @since v9.7.0 + * @return a reference to `immediate` + */ + ref(): this; + /** + * When called, the active `Immediate` object will not require the Node.js event + * loop to remain active. If there is no other activity keeping the event loop + * running, the process may exit before the `Immediate` object's callback is + * invoked. Calling `immediate.unref()` multiple times will have no effect. + * @since v9.7.0 + * @return a reference to `immediate` + */ + unref(): this; + /** + * If true, the `Immediate` object will keep the Node.js event loop active. + * @since v11.0.0 + */ + hasRef(): boolean; + _onImmediate: Function; // to distinguish it from the Timeout class + /** + * Cancels the immediate. This is similar to calling `clearImmediate()`. + * @since v20.5.0 + */ + [Symbol.dispose](): void; + } + /** + * This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the + * scheduled actions. + * + * By default, when a timer is scheduled using either `setTimeout()` or `setInterval()`, the Node.js event loop will continue running as long as the + * timer is active. Each of the `Timeout` objects returned by these functions + * export both `timeout.ref()` and `timeout.unref()` functions that can be used to + * control this default behavior. + */ + class Timeout implements Timer { + /** + * When called, requests that the Node.js event loop _not_ exit so long as the`Timeout` is active. Calling `timeout.ref()` multiple times will have no effect. + * + * By default, all `Timeout` objects are "ref'ed", making it normally unnecessary + * to call `timeout.ref()` unless `timeout.unref()` had been called previously. + * @since v0.9.1 + * @return a reference to `timeout` + */ + ref(): this; + /** + * When called, the active `Timeout` object will not require the Node.js event loop + * to remain active. If there is no other activity keeping the event loop running, + * the process may exit before the `Timeout` object's callback is invoked. Calling`timeout.unref()` multiple times will have no effect. + * @since v0.9.1 + * @return a reference to `timeout` + */ + unref(): this; + /** + * If true, the `Timeout` object will keep the Node.js event loop active. + * @since v11.0.0 + */ + hasRef(): boolean; + /** + * Sets the timer's start time to the current time, and reschedules the timer to + * call its callback at the previously specified duration adjusted to the current + * time. This is useful for refreshing a timer without allocating a new + * JavaScript object. + * + * Using this on a timer that has already called its callback will reactivate the + * timer. + * @since v10.2.0 + * @return a reference to `timeout` + */ + refresh(): this; + [Symbol.toPrimitive](): number; + /** + * Cancels the timeout. + * @since v20.5.0 + */ + [Symbol.dispose](): void; + } + } + /** + * Schedules execution of a one-time `callback` after `delay` milliseconds. + * + * The `callback` will likely not be invoked in precisely `delay` milliseconds. + * Node.js makes no guarantees about the exact timing of when callbacks will fire, + * nor of their ordering. The callback will be called as close as possible to the + * time specified. + * + * When `delay` is larger than `2147483647` or less than `1`, the `delay`will be set to `1`. Non-integer delays are truncated to an integer. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setTimeout()`. + * @since v0.0.1 + * @param callback The function to call when the timer elapses. + * @param [delay=1] The number of milliseconds to wait before calling the `callback`. + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearTimeout} + */ + function setTimeout( + callback: (...args: TArgs) => void, + ms?: number, + ...args: TArgs + ): NodeJS.Timeout; + // util.promisify no rest args compability + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + function setTimeout(callback: (args: void) => void, ms?: number): NodeJS.Timeout; + namespace setTimeout { + const __promisify__: typeof setTimeoutPromise; + } + /** + * Cancels a `Timeout` object created by `setTimeout()`. + * @since v0.0.1 + * @param timeout A `Timeout` object as returned by {@link setTimeout} or the `primitive` of the `Timeout` object as a string or a number. + */ + function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void; + /** + * Schedules repeated execution of `callback` every `delay` milliseconds. + * + * When `delay` is larger than `2147483647` or less than `1`, the `delay` will be + * set to `1`. Non-integer delays are truncated to an integer. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setInterval()`. + * @since v0.0.1 + * @param callback The function to call when the timer elapses. + * @param [delay=1] The number of milliseconds to wait before calling the `callback`. + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearInterval} + */ + function setInterval( + callback: (...args: TArgs) => void, + ms?: number, + ...args: TArgs + ): NodeJS.Timeout; + // util.promisify no rest args compability + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout; + namespace setInterval { + const __promisify__: typeof setIntervalPromise; + } + /** + * Cancels a `Timeout` object created by `setInterval()`. + * @since v0.0.1 + * @param timeout A `Timeout` object as returned by {@link setInterval} or the `primitive` of the `Timeout` object as a string or a number. + */ + function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void; + /** + * Schedules the "immediate" execution of the `callback` after I/O events' + * callbacks. + * + * When multiple calls to `setImmediate()` are made, the `callback` functions are + * queued for execution in the order in which they are created. The entire callback + * queue is processed every event loop iteration. If an immediate timer is queued + * from inside an executing callback, that timer will not be triggered until the + * next event loop iteration. + * + * If `callback` is not a function, a `TypeError` will be thrown. + * + * This method has a custom variant for promises that is available using `timersPromises.setImmediate()`. + * @since v0.9.1 + * @param callback The function to call at the end of this turn of the Node.js `Event Loop` + * @param args Optional arguments to pass when the `callback` is called. + * @return for use with {@link clearImmediate} + */ + function setImmediate( + callback: (...args: TArgs) => void, + ...args: TArgs + ): NodeJS.Immediate; + // util.promisify no rest args compability + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + function setImmediate(callback: (args: void) => void): NodeJS.Immediate; + namespace setImmediate { + const __promisify__: typeof setImmediatePromise; + } + /** + * Cancels an `Immediate` object created by `setImmediate()`. + * @since v0.9.1 + * @param immediate An `Immediate` object as returned by {@link setImmediate}. + */ + function clearImmediate(immediateId: NodeJS.Immediate | undefined): void; + function queueMicrotask(callback: () => void): void; + } +} +declare module "node:timers" { + export * from "timers"; +} diff --git a/node_modules/@types/node/ts4.8/timers/promises.d.ts b/node_modules/@types/node/ts4.8/timers/promises.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a54dc772dcbdb9974966bc3c5072a3e8636c0d4 --- /dev/null +++ b/node_modules/@types/node/ts4.8/timers/promises.d.ts @@ -0,0 +1,93 @@ +/** + * The `timers/promises` API provides an alternative set of timer functions + * that return `Promise` objects. The API is accessible via`require('node:timers/promises')`. + * + * ```js + * import { + * setTimeout, + * setImmediate, + * setInterval, + * } from 'timers/promises'; + * ``` + * @since v15.0.0 + */ +declare module "timers/promises" { + import { TimerOptions } from "node:timers"; + /** + * ```js + * import { + * setTimeout, + * } from 'timers/promises'; + * + * const res = await setTimeout(100, 'result'); + * + * console.log(res); // Prints 'result' + * ``` + * @since v15.0.0 + * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. + * @param value A value with which the promise is fulfilled. + */ + function setTimeout(delay?: number, value?: T, options?: TimerOptions): Promise; + /** + * ```js + * import { + * setImmediate, + * } from 'timers/promises'; + * + * const res = await setImmediate('result'); + * + * console.log(res); // Prints 'result' + * ``` + * @since v15.0.0 + * @param value A value with which the promise is fulfilled. + */ + function setImmediate(value?: T, options?: TimerOptions): Promise; + /** + * Returns an async iterator that generates values in an interval of `delay` ms. + * If `ref` is `true`, you need to call `next()` of async iterator explicitly + * or implicitly to keep the event loop alive. + * + * ```js + * import { + * setInterval, + * } from 'timers/promises'; + * + * const interval = 100; + * for await (const startTime of setInterval(interval, Date.now())) { + * const now = Date.now(); + * console.log(now); + * if ((now - startTime) > 1000) + * break; + * } + * console.log(Date.now()); + * ``` + * @since v15.9.0 + */ + function setInterval(delay?: number, value?: T, options?: TimerOptions): AsyncIterable; + interface Scheduler { + /** + * ```js + * import { scheduler } from 'node:timers/promises'; + * + * await scheduler.wait(1000); // Wait one second before continuing + * ``` + * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. + * Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported. + * @since v16.14.0 + * @experimental + * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. + */ + wait: (delay?: number, options?: TimerOptions) => Promise; + /** + * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. + * Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments. + * @since v16.14.0 + * @experimental + */ + yield: () => Promise; + } + const scheduler: Scheduler; +} +declare module "node:timers/promises" { + export * from "timers/promises"; +} diff --git a/node_modules/@types/node/ts4.8/tls.d.ts b/node_modules/@types/node/ts4.8/tls.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b289e841c3ce3e1e60b02eb607db1f3978358a83 --- /dev/null +++ b/node_modules/@types/node/ts4.8/tls.d.ts @@ -0,0 +1,1210 @@ +/** + * The `node:tls` module provides an implementation of the Transport Layer Security + * (TLS) and Secure Socket Layer (SSL) protocols that is built on top of OpenSSL. + * The module can be accessed using: + * + * ```js + * const tls = require('node:tls'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tls.js) + */ +declare module "tls" { + import { X509Certificate } from "node:crypto"; + import * as net from "node:net"; + import * as stream from "stream"; + const CLIENT_RENEG_LIMIT: number; + const CLIENT_RENEG_WINDOW: number; + interface Certificate { + /** + * Country code. + */ + C: string; + /** + * Street. + */ + ST: string; + /** + * Locality. + */ + L: string; + /** + * Organization. + */ + O: string; + /** + * Organizational unit. + */ + OU: string; + /** + * Common name. + */ + CN: string; + } + interface PeerCertificate { + /** + * `true` if a Certificate Authority (CA), `false` otherwise. + * @since v18.13.0 + */ + ca: boolean; + /** + * The DER encoded X.509 certificate data. + */ + raw: Buffer; + /** + * The certificate subject. + */ + subject: Certificate; + /** + * The certificate issuer, described in the same terms as the `subject`. + */ + issuer: Certificate; + /** + * The date-time the certificate is valid from. + */ + valid_from: string; + /** + * The date-time the certificate is valid to. + */ + valid_to: string; + /** + * The certificate serial number, as a hex string. + */ + serialNumber: string; + /** + * The SHA-1 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ + fingerprint: string; + /** + * The SHA-256 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ + fingerprint256: string; + /** + * The SHA-512 digest of the DER encoded certificate. + * It is returned as a `:` separated hexadecimal string. + */ + fingerprint512: string; + /** + * The extended key usage, a set of OIDs. + */ + ext_key_usage?: string[]; + /** + * A string containing concatenated names for the subject, + * an alternative to the `subject` names. + */ + subjectaltname?: string; + /** + * An array describing the AuthorityInfoAccess, used with OCSP. + */ + infoAccess?: NodeJS.Dict; + /** + * For RSA keys: The RSA bit size. + * + * For EC keys: The key size in bits. + */ + bits?: number; + /** + * The RSA exponent, as a string in hexadecimal number notation. + */ + exponent?: string; + /** + * The RSA modulus, as a hexadecimal string. + */ + modulus?: string; + /** + * The public key. + */ + pubkey?: Buffer; + /** + * The ASN.1 name of the OID of the elliptic curve. + * Well-known curves are identified by an OID. + * While it is unusual, it is possible that the curve + * is identified by its mathematical properties, + * in which case it will not have an OID. + */ + asn1Curve?: string; + /** + * The NIST name for the elliptic curve,if it has one + * (not all well-known curves have been assigned names by NIST). + */ + nistCurve?: string; + } + interface DetailedPeerCertificate extends PeerCertificate { + /** + * The issuer certificate object. + * For self-signed certificates, this may be a circular reference. + */ + issuerCertificate: DetailedPeerCertificate; + } + interface CipherNameAndProtocol { + /** + * The cipher name. + */ + name: string; + /** + * SSL/TLS protocol version. + */ + version: string; + /** + * IETF name for the cipher suite. + */ + standardName: string; + } + interface EphemeralKeyInfo { + /** + * The supported types are 'DH' and 'ECDH'. + */ + type: string; + /** + * The name property is available only when type is 'ECDH'. + */ + name?: string | undefined; + /** + * The size of parameter of an ephemeral key exchange. + */ + size: number; + } + interface KeyObject { + /** + * Private keys in PEM format. + */ + pem: string | Buffer; + /** + * Optional passphrase. + */ + passphrase?: string | undefined; + } + interface PxfObject { + /** + * PFX or PKCS12 encoded private key and certificate chain. + */ + buf: string | Buffer; + /** + * Optional passphrase. + */ + passphrase?: string | undefined; + } + interface TLSSocketOptions extends SecureContextOptions, CommonConnectionOptions { + /** + * If true the TLS socket will be instantiated in server-mode. + * Defaults to false. + */ + isServer?: boolean | undefined; + /** + * An optional net.Server instance. + */ + server?: net.Server | undefined; + /** + * An optional Buffer instance containing a TLS session. + */ + session?: Buffer | undefined; + /** + * If true, specifies that the OCSP status request extension will be + * added to the client hello and an 'OCSPResponse' event will be + * emitted on the socket before establishing a secure communication + */ + requestOCSP?: boolean | undefined; + } + /** + * Performs transparent encryption of written data and all required TLS + * negotiation. + * + * Instances of `tls.TLSSocket` implement the duplex `Stream` interface. + * + * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate}) will only return data while the + * connection is open. + * @since v0.11.4 + */ + class TLSSocket extends net.Socket { + /** + * Construct a new tls.TLSSocket object from an existing TCP socket. + */ + constructor(socket: net.Socket, options?: TLSSocketOptions); + /** + * This property is `true` if the peer certificate was signed by one of the CAs + * specified when creating the `tls.TLSSocket` instance, otherwise `false`. + * @since v0.11.4 + */ + authorized: boolean; + /** + * Returns the reason why the peer's certificate was not been verified. This + * property is set only when `tlsSocket.authorized === false`. + * @since v0.11.4 + */ + authorizationError: Error; + /** + * Always returns `true`. This may be used to distinguish TLS sockets from regular`net.Socket` instances. + * @since v0.11.4 + */ + encrypted: true; + /** + * String containing the selected ALPN protocol. + * Before a handshake has completed, this value is always null. + * When a handshake is completed but not ALPN protocol was selected, tlsSocket.alpnProtocol equals false. + */ + alpnProtocol: string | false | null; + /** + * Returns an object representing the local certificate. The returned object has + * some properties corresponding to the fields of the certificate. + * + * See {@link TLSSocket.getPeerCertificate} for an example of the certificate + * structure. + * + * If there is no local certificate, an empty object will be returned. If the + * socket has been destroyed, `null` will be returned. + * @since v11.2.0 + */ + getCertificate(): PeerCertificate | object | null; + /** + * Returns an object containing information on the negotiated cipher suite. + * + * For example, a TLSv1.2 protocol with AES256-SHA cipher: + * + * ```json + * { + * "name": "AES256-SHA", + * "standardName": "TLS_RSA_WITH_AES_256_CBC_SHA", + * "version": "SSLv3" + * } + * ``` + * + * See [SSL\_CIPHER\_get\_name](https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html) for more information. + * @since v0.11.4 + */ + getCipher(): CipherNameAndProtocol; + /** + * Returns an object representing the type, name, and size of parameter of + * an ephemeral key exchange in `perfect forward secrecy` on a client + * connection. It returns an empty object when the key exchange is not + * ephemeral. As this is only supported on a client socket; `null` is returned + * if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The`name` property is available only when type is `'ECDH'`. + * + * For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`. + * @since v5.0.0 + */ + getEphemeralKeyInfo(): EphemeralKeyInfo | object | null; + /** + * As the `Finished` messages are message digests of the complete handshake + * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can + * be used for external authentication procedures when the authentication + * provided by SSL/TLS is not desired or is not enough. + * + * Corresponds to the `SSL_get_finished` routine in OpenSSL and may be used + * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929). + * @since v9.9.0 + * @return The latest `Finished` message that has been sent to the socket as part of a SSL/TLS handshake, or `undefined` if no `Finished` message has been sent yet. + */ + getFinished(): Buffer | undefined; + /** + * Returns an object representing the peer's certificate. If the peer does not + * provide a certificate, an empty object will be returned. If the socket has been + * destroyed, `null` will be returned. + * + * If the full certificate chain was requested, each certificate will include an`issuerCertificate` property containing an object representing its issuer's + * certificate. + * @since v0.11.4 + * @param detailed Include the full certificate chain if `true`, otherwise include just the peer's certificate. + * @return A certificate object. + */ + getPeerCertificate(detailed: true): DetailedPeerCertificate; + getPeerCertificate(detailed?: false): PeerCertificate; + getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate; + /** + * As the `Finished` messages are message digests of the complete handshake + * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can + * be used for external authentication procedures when the authentication + * provided by SSL/TLS is not desired or is not enough. + * + * Corresponds to the `SSL_get_peer_finished` routine in OpenSSL and may be used + * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929). + * @since v9.9.0 + * @return The latest `Finished` message that is expected or has actually been received from the socket as part of a SSL/TLS handshake, or `undefined` if there is no `Finished` message so + * far. + */ + getPeerFinished(): Buffer | undefined; + /** + * Returns a string containing the negotiated SSL/TLS protocol version of the + * current connection. The value `'unknown'` will be returned for connected + * sockets that have not completed the handshaking process. The value `null` will + * be returned for server sockets or disconnected client sockets. + * + * Protocol versions are: + * + * * `'SSLv3'` + * * `'TLSv1'` + * * `'TLSv1.1'` + * * `'TLSv1.2'` + * * `'TLSv1.3'` + * + * See the OpenSSL [`SSL_get_version`](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html) documentation for more information. + * @since v5.7.0 + */ + getProtocol(): string | null; + /** + * Returns the TLS session data or `undefined` if no session was + * negotiated. On the client, the data can be provided to the `session` option of {@link connect} to resume the connection. On the server, it may be useful + * for debugging. + * + * See `Session Resumption` for more information. + * + * Note: `getSession()` works only for TLSv1.2 and below. For TLSv1.3, applications + * must use the `'session'` event (it also works for TLSv1.2 and below). + * @since v0.11.4 + */ + getSession(): Buffer | undefined; + /** + * See [SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html) for more information. + * @since v12.11.0 + * @return List of signature algorithms shared between the server and the client in the order of decreasing preference. + */ + getSharedSigalgs(): string[]; + /** + * For a client, returns the TLS session ticket if one is available, or`undefined`. For a server, always returns `undefined`. + * + * It may be useful for debugging. + * + * See `Session Resumption` for more information. + * @since v0.11.4 + */ + getTLSTicket(): Buffer | undefined; + /** + * See `Session Resumption` for more information. + * @since v0.5.6 + * @return `true` if the session was reused, `false` otherwise. + */ + isSessionReused(): boolean; + /** + * The `tlsSocket.renegotiate()` method initiates a TLS renegotiation process. + * Upon completion, the `callback` function will be passed a single argument + * that is either an `Error` (if the request failed) or `null`. + * + * This method can be used to request a peer's certificate after the secure + * connection has been established. + * + * When running as the server, the socket will be destroyed with an error after`handshakeTimeout` timeout. + * + * For TLSv1.3, renegotiation cannot be initiated, it is not supported by the + * protocol. + * @since v0.11.8 + * @param callback If `renegotiate()` returned `true`, callback is attached once to the `'secure'` event. If `renegotiate()` returned `false`, `callback` will be called in the next tick with + * an error, unless the `tlsSocket` has been destroyed, in which case `callback` will not be called at all. + * @return `true` if renegotiation was initiated, `false` otherwise. + */ + renegotiate( + options: { + rejectUnauthorized?: boolean | undefined; + requestCert?: boolean | undefined; + }, + callback: (err: Error | null) => void, + ): undefined | boolean; + /** + * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size. + * Returns `true` if setting the limit succeeded; `false` otherwise. + * + * Smaller fragment sizes decrease the buffering latency on the client: larger + * fragments are buffered by the TLS layer until the entire fragment is received + * and its integrity is verified; large fragments can span multiple roundtrips + * and their processing can be delayed due to packet loss or reordering. However, + * smaller fragments add extra TLS framing bytes and CPU overhead, which may + * decrease overall server throughput. + * @since v0.11.11 + * @param [size=16384] The maximum TLS fragment size. The maximum value is `16384`. + */ + setMaxSendFragment(size: number): boolean; + /** + * Disables TLS renegotiation for this `TLSSocket` instance. Once called, attempts + * to renegotiate will trigger an `'error'` event on the `TLSSocket`. + * @since v8.4.0 + */ + disableRenegotiation(): void; + /** + * When enabled, TLS packet trace information is written to `stderr`. This can be + * used to debug TLS connection problems. + * + * The format of the output is identical to the output of`openssl s_client -trace` or `openssl s_server -trace`. While it is produced by + * OpenSSL's `SSL_trace()` function, the format is undocumented, can change + * without notice, and should not be relied on. + * @since v12.2.0 + */ + enableTrace(): void; + /** + * Returns the peer certificate as an `X509Certificate` object. + * + * If there is no peer certificate, or the socket has been destroyed,`undefined` will be returned. + * @since v15.9.0 + */ + getPeerX509Certificate(): X509Certificate | undefined; + /** + * Returns the local certificate as an `X509Certificate` object. + * + * If there is no local certificate, or the socket has been destroyed,`undefined` will be returned. + * @since v15.9.0 + */ + getX509Certificate(): X509Certificate | undefined; + /** + * Keying material is used for validations to prevent different kind of attacks in + * network protocols, for example in the specifications of IEEE 802.1X. + * + * Example + * + * ```js + * const keyingMaterial = tlsSocket.exportKeyingMaterial( + * 128, + * 'client finished'); + * + * /* + * Example return value of keyingMaterial: + * + * + * ``` + * + * See the OpenSSL [`SSL_export_keying_material`](https://www.openssl.org/docs/man1.1.1/man3/SSL_export_keying_material.html) documentation for more + * information. + * @since v13.10.0, v12.17.0 + * @param length number of bytes to retrieve from keying material + * @param label an application specific label, typically this will be a value from the [IANA Exporter Label + * Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels). + * @param context Optionally provide a context. + * @return requested bytes of the keying material + */ + exportKeyingMaterial(length: number, label: string, context: Buffer): Buffer; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + addListener(event: "secureConnect", listener: () => void): this; + addListener(event: "session", listener: (session: Buffer) => void): this; + addListener(event: "keylog", listener: (line: Buffer) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "OCSPResponse", response: Buffer): boolean; + emit(event: "secureConnect"): boolean; + emit(event: "session", session: Buffer): boolean; + emit(event: "keylog", line: Buffer): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "OCSPResponse", listener: (response: Buffer) => void): this; + on(event: "secureConnect", listener: () => void): this; + on(event: "session", listener: (session: Buffer) => void): this; + on(event: "keylog", listener: (line: Buffer) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "OCSPResponse", listener: (response: Buffer) => void): this; + once(event: "secureConnect", listener: () => void): this; + once(event: "session", listener: (session: Buffer) => void): this; + once(event: "keylog", listener: (line: Buffer) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + prependListener(event: "secureConnect", listener: () => void): this; + prependListener(event: "session", listener: (session: Buffer) => void): this; + prependListener(event: "keylog", listener: (line: Buffer) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + prependOnceListener(event: "secureConnect", listener: () => void): this; + prependOnceListener(event: "session", listener: (session: Buffer) => void): this; + prependOnceListener(event: "keylog", listener: (line: Buffer) => void): this; + } + interface CommonConnectionOptions { + /** + * An optional TLS context object from tls.createSecureContext() + */ + secureContext?: SecureContext | undefined; + /** + * When enabled, TLS packet trace information is written to `stderr`. This can be + * used to debug TLS connection problems. + * @default false + */ + enableTrace?: boolean | undefined; + /** + * If true the server will request a certificate from clients that + * connect and attempt to verify that certificate. Defaults to + * false. + */ + requestCert?: boolean | undefined; + /** + * An array of strings or a Buffer naming possible ALPN protocols. + * (Protocols should be ordered by their priority.) + */ + ALPNProtocols?: string[] | Uint8Array[] | Uint8Array | undefined; + /** + * SNICallback(servername, cb) A function that will be + * called if the client supports SNI TLS extension. Two arguments + * will be passed when called: servername and cb. SNICallback should + * invoke cb(null, ctx), where ctx is a SecureContext instance. + * (tls.createSecureContext(...) can be used to get a proper + * SecureContext.) If SNICallback wasn't provided the default callback + * with high-level API will be used (see below). + */ + SNICallback?: ((servername: string, cb: (err: Error | null, ctx?: SecureContext) => void) => void) | undefined; + /** + * If true the server will reject any connection which is not + * authorized with the list of supplied CAs. This option only has an + * effect if requestCert is true. + * @default true + */ + rejectUnauthorized?: boolean | undefined; + } + interface TlsOptions extends SecureContextOptions, CommonConnectionOptions, net.ServerOpts { + /** + * Abort the connection if the SSL/TLS handshake does not finish in the + * specified number of milliseconds. A 'tlsClientError' is emitted on + * the tls.Server object whenever a handshake times out. Default: + * 120000 (120 seconds). + */ + handshakeTimeout?: number | undefined; + /** + * The number of seconds after which a TLS session created by the + * server will no longer be resumable. See Session Resumption for more + * information. Default: 300. + */ + sessionTimeout?: number | undefined; + /** + * 48-bytes of cryptographically strong pseudo-random data. + */ + ticketKeys?: Buffer | undefined; + /** + * @param socket + * @param identity identity parameter sent from the client. + * @return pre-shared key that must either be + * a buffer or `null` to stop the negotiation process. Returned PSK must be + * compatible with the selected cipher's digest. + * + * When negotiating TLS-PSK (pre-shared keys), this function is called + * with the identity provided by the client. + * If the return value is `null` the negotiation process will stop and an + * "unknown_psk_identity" alert message will be sent to the other party. + * If the server wishes to hide the fact that the PSK identity was not known, + * the callback must provide some random data as `psk` to make the connection + * fail with "decrypt_error" before negotiation is finished. + * PSK ciphers are disabled by default, and using TLS-PSK thus + * requires explicitly specifying a cipher suite with the `ciphers` option. + * More information can be found in the RFC 4279. + */ + pskCallback?(socket: TLSSocket, identity: string): DataView | NodeJS.TypedArray | null; + /** + * hint to send to a client to help + * with selecting the identity during TLS-PSK negotiation. Will be ignored + * in TLS 1.3. Upon failing to set pskIdentityHint `tlsClientError` will be + * emitted with `ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED` code. + */ + pskIdentityHint?: string | undefined; + } + interface PSKCallbackNegotation { + psk: DataView | NodeJS.TypedArray; + identity: string; + } + interface ConnectionOptions extends SecureContextOptions, CommonConnectionOptions { + host?: string | undefined; + port?: number | undefined; + path?: string | undefined; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored. + socket?: stream.Duplex | undefined; // Establish secure connection on a given socket rather than creating a new socket + checkServerIdentity?: typeof checkServerIdentity | undefined; + servername?: string | undefined; // SNI TLS Extension + session?: Buffer | undefined; + minDHSize?: number | undefined; + lookup?: net.LookupFunction | undefined; + timeout?: number | undefined; + /** + * When negotiating TLS-PSK (pre-shared keys), this function is called + * with optional identity `hint` provided by the server or `null` + * in case of TLS 1.3 where `hint` was removed. + * It will be necessary to provide a custom `tls.checkServerIdentity()` + * for the connection as the default one will try to check hostname/IP + * of the server against the certificate but that's not applicable for PSK + * because there won't be a certificate present. + * More information can be found in the RFC 4279. + * + * @param hint message sent from the server to help client + * decide which identity to use during negotiation. + * Always `null` if TLS 1.3 is used. + * @returns Return `null` to stop the negotiation process. `psk` must be + * compatible with the selected cipher's digest. + * `identity` must use UTF-8 encoding. + */ + pskCallback?(hint: string | null): PSKCallbackNegotation | null; + } + /** + * Accepts encrypted connections using TLS or SSL. + * @since v0.3.2 + */ + class Server extends net.Server { + constructor(secureConnectionListener?: (socket: TLSSocket) => void); + constructor(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void); + /** + * The `server.addContext()` method adds a secure context that will be used if + * the client request's SNI name matches the supplied `hostname` (or wildcard). + * + * When there are multiple matching contexts, the most recently added one is + * used. + * @since v0.5.3 + * @param hostname A SNI host name or wildcard (e.g. `'*'`) + * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created + * with {@link createSecureContext} itself. + */ + addContext(hostname: string, context: SecureContextOptions): void; + /** + * Returns the session ticket keys. + * + * See `Session Resumption` for more information. + * @since v3.0.0 + * @return A 48-byte buffer containing the session ticket keys. + */ + getTicketKeys(): Buffer; + /** + * The `server.setSecureContext()` method replaces the secure context of an + * existing server. Existing connections to the server are not interrupted. + * @since v11.0.0 + * @param options An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc). + */ + setSecureContext(options: SecureContextOptions): void; + /** + * Sets the session ticket keys. + * + * Changes to the ticket keys are effective only for future server connections. + * Existing or currently pending server connections will use the previous keys. + * + * See `Session Resumption` for more information. + * @since v3.0.0 + * @param keys A 48-byte buffer containing the session ticket keys. + */ + setTicketKeys(keys: Buffer): void; + /** + * events.EventEmitter + * 1. tlsClientError + * 2. newSession + * 3. OCSPRequest + * 4. resumeSession + * 5. secureConnection + * 6. keylog + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + addListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void, + ): this; + addListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + addListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + addListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean; + emit(event: "newSession", sessionId: Buffer, sessionData: Buffer, callback: () => void): boolean; + emit( + event: "OCSPRequest", + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ): boolean; + emit( + event: "resumeSession", + sessionId: Buffer, + callback: (err: Error | null, sessionData: Buffer | null) => void, + ): boolean; + emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; + emit(event: "keylog", line: Buffer, tlsSocket: TLSSocket): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + on(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this; + on( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + on( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + on(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + once( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void, + ): this; + once( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + once( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + once(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + prependListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void, + ): this; + prependListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + prependListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + prependOnceListener( + event: "newSession", + listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void, + ): this; + prependOnceListener( + event: "OCSPRequest", + listener: ( + certificate: Buffer, + issuer: Buffer, + callback: (err: Error | null, resp: Buffer) => void, + ) => void, + ): this; + prependOnceListener( + event: "resumeSession", + listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void, + ): this; + prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this; + } + /** + * @deprecated since v0.11.3 Use `tls.TLSSocket` instead. + */ + interface SecurePair { + encrypted: TLSSocket; + cleartext: TLSSocket; + } + type SecureVersion = "TLSv1.3" | "TLSv1.2" | "TLSv1.1" | "TLSv1"; + interface SecureContextOptions { + /** + * If set, this will be called when a client opens a connection using the ALPN extension. + * One argument will be passed to the callback: an object containing `servername` and `protocols` fields, + * respectively containing the server name from the SNI extension (if any) and an array of + * ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`, + * which will be returned to the client as the selected ALPN protocol, or `undefined`, + * to reject the connection with a fatal alert. If a string is returned that does not match one of + * the client's ALPN protocols, an error will be thrown. + * This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error. + */ + ALPNCallback?: ((arg: { servername: string; protocols: string[] }) => string | undefined) | undefined; + /** + * Optionally override the trusted CA certificates. Default is to trust + * the well-known CAs curated by Mozilla. Mozilla's CAs are completely + * replaced when CAs are explicitly specified using this option. + */ + ca?: string | Buffer | Array | undefined; + /** + * Cert chains in PEM format. One cert chain should be provided per + * private key. Each cert chain should consist of the PEM formatted + * certificate for a provided private key, followed by the PEM + * formatted intermediate certificates (if any), in order, and not + * including the root CA (the root CA must be pre-known to the peer, + * see ca). When providing multiple cert chains, they do not have to + * be in the same order as their private keys in key. If the + * intermediate certificates are not provided, the peer will not be + * able to validate the certificate, and the handshake will fail. + */ + cert?: string | Buffer | Array | undefined; + /** + * Colon-separated list of supported signature algorithms. The list + * can contain digest algorithms (SHA256, MD5 etc.), public key + * algorithms (RSA-PSS, ECDSA etc.), combination of both (e.g + * 'RSA+SHA384') or TLS v1.3 scheme names (e.g. rsa_pss_pss_sha512). + */ + sigalgs?: string | undefined; + /** + * Cipher suite specification, replacing the default. For more + * information, see modifying the default cipher suite. Permitted + * ciphers can be obtained via tls.getCiphers(). Cipher names must be + * uppercased in order for OpenSSL to accept them. + */ + ciphers?: string | undefined; + /** + * Name of an OpenSSL engine which can provide the client certificate. + */ + clientCertEngine?: string | undefined; + /** + * PEM formatted CRLs (Certificate Revocation Lists). + */ + crl?: string | Buffer | Array | undefined; + /** + * `'auto'` or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy. + * If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. + * ECDHE-based perfect forward secrecy will still be available. + */ + dhparam?: string | Buffer | undefined; + /** + * A string describing a named curve or a colon separated list of curve + * NIDs or names, for example P-521:P-384:P-256, to use for ECDH key + * agreement. Set to auto to select the curve automatically. Use + * crypto.getCurves() to obtain a list of available curve names. On + * recent releases, openssl ecparam -list_curves will also display the + * name and description of each available elliptic curve. Default: + * tls.DEFAULT_ECDH_CURVE. + */ + ecdhCurve?: string | undefined; + /** + * Attempt to use the server's cipher suite preferences instead of the + * client's. When true, causes SSL_OP_CIPHER_SERVER_PREFERENCE to be + * set in secureOptions + */ + honorCipherOrder?: boolean | undefined; + /** + * Private keys in PEM format. PEM allows the option of private keys + * being encrypted. Encrypted keys will be decrypted with + * options.passphrase. Multiple keys using different algorithms can be + * provided either as an array of unencrypted key strings or buffers, + * or an array of objects in the form {pem: [, + * passphrase: ]}. The object form can only occur in an array. + * object.passphrase is optional. Encrypted keys will be decrypted with + * object.passphrase if provided, or options.passphrase if it is not. + */ + key?: string | Buffer | Array | undefined; + /** + * Name of an OpenSSL engine to get private key from. Should be used + * together with privateKeyIdentifier. + */ + privateKeyEngine?: string | undefined; + /** + * Identifier of a private key managed by an OpenSSL engine. Should be + * used together with privateKeyEngine. Should not be set together with + * key, because both options define a private key in different ways. + */ + privateKeyIdentifier?: string | undefined; + /** + * Optionally set the maximum TLS version to allow. One + * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the + * `secureProtocol` option, use one or the other. + * **Default:** `'TLSv1.3'`, unless changed using CLI options. Using + * `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to + * `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used. + */ + maxVersion?: SecureVersion | undefined; + /** + * Optionally set the minimum TLS version to allow. One + * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the + * `secureProtocol` option, use one or the other. It is not recommended to use + * less than TLSv1.2, but it may be required for interoperability. + * **Default:** `'TLSv1.2'`, unless changed using CLI options. Using + * `--tls-v1.0` sets the default to `'TLSv1'`. Using `--tls-v1.1` sets the default to + * `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to + * 'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used. + */ + minVersion?: SecureVersion | undefined; + /** + * Shared passphrase used for a single private key and/or a PFX. + */ + passphrase?: string | undefined; + /** + * PFX or PKCS12 encoded private key and certificate chain. pfx is an + * alternative to providing key and cert individually. PFX is usually + * encrypted, if it is, passphrase will be used to decrypt it. Multiple + * PFX can be provided either as an array of unencrypted PFX buffers, + * or an array of objects in the form {buf: [, + * passphrase: ]}. The object form can only occur in an array. + * object.passphrase is optional. Encrypted PFX will be decrypted with + * object.passphrase if provided, or options.passphrase if it is not. + */ + pfx?: string | Buffer | Array | undefined; + /** + * Optionally affect the OpenSSL protocol behavior, which is not + * usually necessary. This should be used carefully if at all! Value is + * a numeric bitmask of the SSL_OP_* options from OpenSSL Options + */ + secureOptions?: number | undefined; // Value is a numeric bitmask of the `SSL_OP_*` options + /** + * Legacy mechanism to select the TLS protocol version to use, it does + * not support independent control of the minimum and maximum version, + * and does not support limiting the protocol to TLSv1.3. Use + * minVersion and maxVersion instead. The possible values are listed as + * SSL_METHODS, use the function names as strings. For example, use + * 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method' to allow + * any TLS protocol version up to TLSv1.3. It is not recommended to use + * TLS versions less than 1.2, but it may be required for + * interoperability. Default: none, see minVersion. + */ + secureProtocol?: string | undefined; + /** + * Opaque identifier used by servers to ensure session state is not + * shared between applications. Unused by clients. + */ + sessionIdContext?: string | undefined; + /** + * 48-bytes of cryptographically strong pseudo-random data. + * See Session Resumption for more information. + */ + ticketKeys?: Buffer | undefined; + /** + * The number of seconds after which a TLS session created by the + * server will no longer be resumable. See Session Resumption for more + * information. Default: 300. + */ + sessionTimeout?: number | undefined; + } + interface SecureContext { + context: any; + } + /** + * Verifies the certificate `cert` is issued to `hostname`. + * + * Returns [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, populating it with `reason`, `host`, and `cert` on + * failure. On success, returns [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type). + * + * This function is intended to be used in combination with the`checkServerIdentity` option that can be passed to {@link connect} and as + * such operates on a `certificate object`. For other purposes, consider using `x509.checkHost()` instead. + * + * This function can be overwritten by providing an alternative function as the`options.checkServerIdentity` option that is passed to `tls.connect()`. The + * overwriting function can call `tls.checkServerIdentity()` of course, to augment + * the checks done with additional verification. + * + * This function is only called if the certificate passed all other checks, such as + * being issued by trusted CA (`options.ca`). + * + * Earlier versions of Node.js incorrectly accepted certificates for a given`hostname` if a matching `uniformResourceIdentifier` subject alternative name + * was present (see [CVE-2021-44531](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44531)). Applications that wish to accept`uniformResourceIdentifier` subject alternative names can use + * a custom`options.checkServerIdentity` function that implements the desired behavior. + * @since v0.8.4 + * @param hostname The host name or IP address to verify the certificate against. + * @param cert A `certificate object` representing the peer's certificate. + */ + function checkServerIdentity(hostname: string, cert: PeerCertificate): Error | undefined; + /** + * Creates a new {@link Server}. The `secureConnectionListener`, if provided, is + * automatically set as a listener for the `'secureConnection'` event. + * + * The `ticketKeys` options is automatically shared between `node:cluster` module + * workers. + * + * The following illustrates a simple echo server: + * + * ```js + * const tls = require('node:tls'); + * const fs = require('node:fs'); + * + * const options = { + * key: fs.readFileSync('server-key.pem'), + * cert: fs.readFileSync('server-cert.pem'), + * + * // This is necessary only if using client certificate authentication. + * requestCert: true, + * + * // This is necessary only if the client uses a self-signed certificate. + * ca: [ fs.readFileSync('client-cert.pem') ], + * }; + * + * const server = tls.createServer(options, (socket) => { + * console.log('server connected', + * socket.authorized ? 'authorized' : 'unauthorized'); + * socket.write('welcome!\n'); + * socket.setEncoding('utf8'); + * socket.pipe(socket); + * }); + * server.listen(8000, () => { + * console.log('server bound'); + * }); + * ``` + * + * The server can be tested by connecting to it using the example client from {@link connect}. + * @since v0.3.2 + */ + function createServer(secureConnectionListener?: (socket: TLSSocket) => void): Server; + function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; + /** + * The `callback` function, if specified, will be added as a listener for the `'secureConnect'` event. + * + * `tls.connect()` returns a {@link TLSSocket} object. + * + * Unlike the `https` API, `tls.connect()` does not enable the + * SNI (Server Name Indication) extension by default, which may cause some + * servers to return an incorrect certificate or reject the connection + * altogether. To enable SNI, set the `servername` option in addition + * to `host`. + * + * The following illustrates a client for the echo server example from {@link createServer}: + * + * ```js + * // Assumes an echo server that is listening on port 8000. + * const tls = require('node:tls'); + * const fs = require('node:fs'); + * + * const options = { + * // Necessary only if the server requires client certificate authentication. + * key: fs.readFileSync('client-key.pem'), + * cert: fs.readFileSync('client-cert.pem'), + * + * // Necessary only if the server uses a self-signed certificate. + * ca: [ fs.readFileSync('server-cert.pem') ], + * + * // Necessary only if the server's cert isn't for "localhost". + * checkServerIdentity: () => { return null; }, + * }; + * + * const socket = tls.connect(8000, options, () => { + * console.log('client connected', + * socket.authorized ? 'authorized' : 'unauthorized'); + * process.stdin.pipe(socket); + * process.stdin.resume(); + * }); + * socket.setEncoding('utf8'); + * socket.on('data', (data) => { + * console.log(data); + * }); + * socket.on('end', () => { + * console.log('server ends connection'); + * }); + * ``` + * @since v0.11.3 + */ + function connect(options: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; + function connect( + port: number, + host?: string, + options?: ConnectionOptions, + secureConnectListener?: () => void, + ): TLSSocket; + function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; + /** + * Creates a new secure pair object with two streams, one of which reads and writes + * the encrypted data and the other of which reads and writes the cleartext data. + * Generally, the encrypted stream is piped to/from an incoming encrypted data + * stream and the cleartext one is used as a replacement for the initial encrypted + * stream. + * + * `tls.createSecurePair()` returns a `tls.SecurePair` object with `cleartext` and`encrypted` stream properties. + * + * Using `cleartext` has the same API as {@link TLSSocket}. + * + * The `tls.createSecurePair()` method is now deprecated in favor of`tls.TLSSocket()`. For example, the code: + * + * ```js + * pair = tls.createSecurePair(// ... ); + * pair.encrypted.pipe(socket); + * socket.pipe(pair.encrypted); + * ``` + * + * can be replaced by: + * + * ```js + * secureSocket = tls.TLSSocket(socket, options); + * ``` + * + * where `secureSocket` has the same API as `pair.cleartext`. + * @since v0.3.2 + * @deprecated Since v0.11.3 - Use {@link TLSSocket} instead. + * @param context A secure context object as returned by `tls.createSecureContext()` + * @param isServer `true` to specify that this TLS connection should be opened as a server. + * @param requestCert `true` to specify whether a server should request a certificate from a connecting client. Only applies when `isServer` is `true`. + * @param rejectUnauthorized If not `false` a server automatically reject clients with invalid certificates. Only applies when `isServer` is `true`. + */ + function createSecurePair( + context?: SecureContext, + isServer?: boolean, + requestCert?: boolean, + rejectUnauthorized?: boolean, + ): SecurePair; + /** + * {@link createServer} sets the default value of the `honorCipherOrder` option + * to `true`, other APIs that create secure contexts leave it unset. + * + * {@link createServer} uses a 128 bit truncated SHA1 hash value generated + * from `process.argv` as the default value of the `sessionIdContext` option, other + * APIs that create secure contexts have no default value. + * + * The `tls.createSecureContext()` method creates a `SecureContext` object. It is + * usable as an argument to several `tls` APIs, such as `server.addContext()`, + * but has no public methods. The {@link Server} constructor and the {@link createServer} method do not support the `secureContext` option. + * + * A key is _required_ for ciphers that use certificates. Either `key` or`pfx` can be used to provide it. + * + * If the `ca` option is not given, then Node.js will default to using [Mozilla's publicly trusted list of + * CAs](https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt). + * + * Custom DHE parameters are discouraged in favor of the new `dhparam: 'auto'`option. When set to `'auto'`, well-known DHE parameters of sufficient strength + * will be selected automatically. Otherwise, if necessary, `openssl dhparam` can + * be used to create custom parameters. The key length must be greater than or + * equal to 1024 bits or else an error will be thrown. Although 1024 bits is + * permissible, use 2048 bits or larger for stronger security. + * @since v0.11.13 + */ + function createSecureContext(options?: SecureContextOptions): SecureContext; + /** + * Returns an array with the names of the supported TLS ciphers. The names are + * lower-case for historical reasons, but must be uppercased to be used in + * the `ciphers` option of {@link createSecureContext}. + * + * Not all supported ciphers are enabled by default. See `Modifying the default TLS cipher suite`. + * + * Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for + * TLSv1.2 and below. + * + * ```js + * console.log(tls.getCiphers()); // ['aes128-gcm-sha256', 'aes128-sha', ...] + * ``` + * @since v0.10.2 + */ + function getCiphers(): string[]; + /** + * The default curve name to use for ECDH key agreement in a tls server. + * The default value is 'auto'. See tls.createSecureContext() for further + * information. + */ + let DEFAULT_ECDH_CURVE: string; + /** + * The default value of the maxVersion option of + * tls.createSecureContext(). It can be assigned any of the supported TLS + * protocol versions, 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default: + * 'TLSv1.3', unless changed using CLI options. Using --tls-max-v1.2 sets + * the default to 'TLSv1.2'. Using --tls-max-v1.3 sets the default to + * 'TLSv1.3'. If multiple of the options are provided, the highest maximum + * is used. + */ + let DEFAULT_MAX_VERSION: SecureVersion; + /** + * The default value of the minVersion option of tls.createSecureContext(). + * It can be assigned any of the supported TLS protocol versions, + * 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default: 'TLSv1.2', unless + * changed using CLI options. Using --tls-min-v1.0 sets the default to + * 'TLSv1'. Using --tls-min-v1.1 sets the default to 'TLSv1.1'. Using + * --tls-min-v1.3 sets the default to 'TLSv1.3'. If multiple of the options + * are provided, the lowest minimum is used. + */ + let DEFAULT_MIN_VERSION: SecureVersion; + /** + * The default value of the ciphers option of tls.createSecureContext(). + * It can be assigned any of the supported OpenSSL ciphers. + * Defaults to the content of crypto.constants.defaultCoreCipherList, unless + * changed using CLI options using --tls-default-ciphers. + */ + let DEFAULT_CIPHERS: string; + /** + * An immutable array of strings representing the root certificates (in PEM + * format) used for verifying peer certificates. This is the default value + * of the ca option to tls.createSecureContext(). + */ + const rootCertificates: readonly string[]; +} +declare module "node:tls" { + export * from "tls"; +} diff --git a/node_modules/@types/node/ts4.8/trace_events.d.ts b/node_modules/@types/node/ts4.8/trace_events.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..336135959baba13c54c0d7859445290994236804 --- /dev/null +++ b/node_modules/@types/node/ts4.8/trace_events.d.ts @@ -0,0 +1,182 @@ +/** + * The `node:trace_events` module provides a mechanism to centralize tracing + * information generated by V8, Node.js core, and userspace code. + * + * Tracing can be enabled with the `--trace-event-categories` command-line flag + * or by using the `node:trace_events` module. The `--trace-event-categories` flag + * accepts a list of comma-separated category names. + * + * The available categories are: + * + * * `node`: An empty placeholder. + * * `node.async_hooks`: Enables capture of detailed `async_hooks` trace data. + * The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property. + * * `node.bootstrap`: Enables capture of Node.js bootstrap milestones. + * * `node.console`: Enables capture of `console.time()` and `console.count()`output. + * * `node.threadpoolwork.sync`: Enables capture of trace data for threadpool + * synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`. + * * `node.threadpoolwork.async`: Enables capture of trace data for threadpool + * asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`. + * * `node.dns.native`: Enables capture of trace data for DNS queries. + * * `node.net.native`: Enables capture of trace data for network. + * * `node.environment`: Enables capture of Node.js Environment milestones. + * * `node.fs.sync`: Enables capture of trace data for file system sync methods. + * * `node.fs_dir.sync`: Enables capture of trace data for file system sync + * directory methods. + * * `node.fs.async`: Enables capture of trace data for file system async methods. + * * `node.fs_dir.async`: Enables capture of trace data for file system async + * directory methods. + * * `node.perf`: Enables capture of `Performance API` measurements. + * * `node.perf.usertiming`: Enables capture of only Performance API User Timing + * measures and marks. + * * `node.perf.timerify`: Enables capture of only Performance API timerify + * measurements. + * * `node.promises.rejections`: Enables capture of trace data tracking the number + * of unhandled Promise rejections and handled-after-rejections. + * * `node.vm.script`: Enables capture of trace data for the `node:vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods. + * * `v8`: The `V8` events are GC, compiling, and execution related. + * * `node.http`: Enables capture of trace data for http request / response. + * + * By default the `node`, `node.async_hooks`, and `v8` categories are enabled. + * + * ```bash + * node --trace-event-categories v8,node,node.async_hooks server.js + * ``` + * + * Prior versions of Node.js required the use of the `--trace-events-enabled`flag to enable trace events. This requirement has been removed. However, the`--trace-events-enabled` flag _may_ still be + * used and will enable the`node`, `node.async_hooks`, and `v8` trace event categories by default. + * + * ```bash + * node --trace-events-enabled + * + * # is equivalent to + * + * node --trace-event-categories v8,node,node.async_hooks + * ``` + * + * Alternatively, trace events may be enabled using the `node:trace_events` module: + * + * ```js + * const trace_events = require('node:trace_events'); + * const tracing = trace_events.createTracing({ categories: ['node.perf'] }); + * tracing.enable(); // Enable trace event capture for the 'node.perf' category + * + * // do work + * + * tracing.disable(); // Disable trace event capture for the 'node.perf' category + * ``` + * + * Running Node.js with tracing enabled will produce log files that can be opened + * in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool) tab of Chrome. + * + * The logging file is by default called `node_trace.${rotation}.log`, where`${rotation}` is an incrementing log-rotation id. The filepath pattern can + * be specified with `--trace-event-file-pattern` that accepts a template + * string that supports `${rotation}` and `${pid}`: + * + * ```bash + * node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js + * ``` + * + * To guarantee that the log file is properly generated after signal events like`SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers + * in your code, such as: + * + * ```js + * process.on('SIGINT', function onSigint() { + * console.info('Received SIGINT.'); + * process.exit(130); // Or applicable exit code depending on OS and signal + * }); + * ``` + * + * The tracing system uses the same time source + * as the one used by `process.hrtime()`. + * However the trace-event timestamps are expressed in microseconds, + * unlike `process.hrtime()` which returns nanoseconds. + * + * The features from this module are not available in `Worker` threads. + * @experimental + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/trace_events.js) + */ +declare module "trace_events" { + /** + * The `Tracing` object is used to enable or disable tracing for sets of + * categories. Instances are created using the + * `trace_events.createTracing()` method. + * + * When created, the `Tracing` object is disabled. Calling the + * `tracing.enable()` method adds the categories to the set of enabled trace + * event categories. Calling `tracing.disable()` will remove the categories + * from the set of enabled trace event categories. + */ + interface Tracing { + /** + * A comma-separated list of the trace event categories covered by this + * `Tracing` object. + */ + readonly categories: string; + /** + * Disables this `Tracing` object. + * + * Only trace event categories _not_ covered by other enabled `Tracing` + * objects and _not_ specified by the `--trace-event-categories` flag + * will be disabled. + */ + disable(): void; + /** + * Enables this `Tracing` object for the set of categories covered by + * the `Tracing` object. + */ + enable(): void; + /** + * `true` only if the `Tracing` object has been enabled. + */ + readonly enabled: boolean; + } + interface CreateTracingOptions { + /** + * An array of trace category names. Values included in the array are + * coerced to a string when possible. An error will be thrown if the + * value cannot be coerced. + */ + categories: string[]; + } + /** + * Creates and returns a `Tracing` object for the given set of `categories`. + * + * ```js + * const trace_events = require('node:trace_events'); + * const categories = ['node.perf', 'node.async_hooks']; + * const tracing = trace_events.createTracing({ categories }); + * tracing.enable(); + * // do stuff + * tracing.disable(); + * ``` + * @since v10.0.0 + * @return . + */ + function createTracing(options: CreateTracingOptions): Tracing; + /** + * Returns a comma-separated list of all currently-enabled trace event + * categories. The current set of enabled trace event categories is determined + * by the _union_ of all currently-enabled `Tracing` objects and any categories + * enabled using the `--trace-event-categories` flag. + * + * Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console. + * + * ```js + * const trace_events = require('node:trace_events'); + * const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] }); + * const t2 = trace_events.createTracing({ categories: ['node.perf'] }); + * const t3 = trace_events.createTracing({ categories: ['v8'] }); + * + * t1.enable(); + * t2.enable(); + * + * console.log(trace_events.getEnabledCategories()); + * ``` + * @since v10.0.0 + */ + function getEnabledCategories(): string | undefined; +} +declare module "node:trace_events" { + export * from "trace_events"; +} diff --git a/node_modules/@types/node/ts4.8/tty.d.ts b/node_modules/@types/node/ts4.8/tty.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c0dafd3ee4a92312faeae80995c25520d5b9918 --- /dev/null +++ b/node_modules/@types/node/ts4.8/tty.d.ts @@ -0,0 +1,208 @@ +/** + * The `node:tty` module provides the `tty.ReadStream` and `tty.WriteStream`classes. In most cases, it will not be necessary or possible to use this module + * directly. However, it can be accessed using: + * + * ```js + * const tty = require('node:tty'); + * ``` + * + * When Node.js detects that it is being run with a text terminal ("TTY") + * attached, `process.stdin` will, by default, be initialized as an instance of`tty.ReadStream` and both `process.stdout` and `process.stderr` will, by + * default, be instances of `tty.WriteStream`. The preferred method of determining + * whether Node.js is being run within a TTY context is to check that the value of + * the `process.stdout.isTTY` property is `true`: + * + * ```console + * $ node -p -e "Boolean(process.stdout.isTTY)" + * true + * $ node -p -e "Boolean(process.stdout.isTTY)" | cat + * false + * ``` + * + * In most cases, there should be little to no reason for an application to + * manually create instances of the `tty.ReadStream` and `tty.WriteStream`classes. + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tty.js) + */ +declare module "tty" { + import * as net from "node:net"; + /** + * The `tty.isatty()` method returns `true` if the given `fd` is associated with + * a TTY and `false` if it is not, including whenever `fd` is not a non-negative + * integer. + * @since v0.5.8 + * @param fd A numeric file descriptor + */ + function isatty(fd: number): boolean; + /** + * Represents the readable side of a TTY. In normal circumstances `process.stdin` will be the only `tty.ReadStream` instance in a Node.js + * process and there should be no reason to create additional instances. + * @since v0.5.8 + */ + class ReadStream extends net.Socket { + constructor(fd: number, options?: net.SocketConstructorOpts); + /** + * A `boolean` that is `true` if the TTY is currently configured to operate as a + * raw device. + * + * This flag is always `false` when a process starts, even if the terminal is + * operating in raw mode. Its value will change with subsequent calls to`setRawMode`. + * @since v0.7.7 + */ + isRaw: boolean; + /** + * Allows configuration of `tty.ReadStream` so that it operates as a raw device. + * + * When in raw mode, input is always available character-by-character, not + * including modifiers. Additionally, all special processing of characters by the + * terminal is disabled, including echoing input + * characters. Ctrl+C will no longer cause a `SIGINT` when + * in this mode. + * @since v0.7.7 + * @param mode If `true`, configures the `tty.ReadStream` to operate as a raw device. If `false`, configures the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw` + * property will be set to the resulting mode. + * @return The read stream instance. + */ + setRawMode(mode: boolean): this; + /** + * A `boolean` that is always `true` for `tty.ReadStream` instances. + * @since v0.5.8 + */ + isTTY: boolean; + } + /** + * -1 - to the left from cursor + * 0 - the entire line + * 1 - to the right from cursor + */ + type Direction = -1 | 0 | 1; + /** + * Represents the writable side of a TTY. In normal circumstances,`process.stdout` and `process.stderr` will be the only`tty.WriteStream` instances created for a Node.js process and there + * should be no reason to create additional instances. + * @since v0.5.8 + */ + class WriteStream extends net.Socket { + constructor(fd: number); + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: "resize", listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: "resize"): boolean; + on(event: string, listener: (...args: any[]) => void): this; + on(event: "resize", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: "resize", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: "resize", listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: "resize", listener: () => void): this; + /** + * `writeStream.clearLine()` clears the current line of this `WriteStream` in a + * direction identified by `dir`. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + clearLine(dir: Direction, callback?: () => void): boolean; + /** + * `writeStream.clearScreenDown()` clears this `WriteStream` from the current + * cursor down. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + clearScreenDown(callback?: () => void): boolean; + /** + * `writeStream.cursorTo()` moves this `WriteStream`'s cursor to the specified + * position. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + cursorTo(x: number, y?: number, callback?: () => void): boolean; + cursorTo(x: number, callback: () => void): boolean; + /** + * `writeStream.moveCursor()` moves this `WriteStream`'s cursor _relative_ to its + * current position. + * @since v0.7.7 + * @param callback Invoked once the operation completes. + * @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`. + */ + moveCursor(dx: number, dy: number, callback?: () => void): boolean; + /** + * Returns: + * + * * `1` for 2, + * * `4` for 16, + * * `8` for 256, + * * `24` for 16,777,216 colors supported. + * + * Use this to determine what colors the terminal supports. Due to the nature of + * colors in terminals it is possible to either have false positives or false + * negatives. It depends on process information and the environment variables that + * may lie about what terminal is used. + * It is possible to pass in an `env` object to simulate the usage of a specific + * terminal. This can be useful to check how specific environment settings behave. + * + * To enforce a specific color support, use one of the below environment settings. + * + * * 2 colors: `FORCE_COLOR = 0` (Disables colors) + * * 16 colors: `FORCE_COLOR = 1` + * * 256 colors: `FORCE_COLOR = 2` + * * 16,777,216 colors: `FORCE_COLOR = 3` + * + * Disabling color support is also possible by using the `NO_COLOR` and`NODE_DISABLE_COLORS` environment variables. + * @since v9.9.0 + * @param [env=process.env] An object containing the environment variables to check. This enables simulating the usage of a specific terminal. + */ + getColorDepth(env?: object): number; + /** + * Returns `true` if the `writeStream` supports at least as many colors as provided + * in `count`. Minimum support is 2 (black and white). + * + * This has the same false positives and negatives as described in `writeStream.getColorDepth()`. + * + * ```js + * process.stdout.hasColors(); + * // Returns true or false depending on if `stdout` supports at least 16 colors. + * process.stdout.hasColors(256); + * // Returns true or false depending on if `stdout` supports at least 256 colors. + * process.stdout.hasColors({ TMUX: '1' }); + * // Returns true. + * process.stdout.hasColors(2 ** 24, { TMUX: '1' }); + * // Returns false (the environment setting pretends to support 2 ** 8 colors). + * ``` + * @since v11.13.0, v10.16.0 + * @param [count=16] The number of colors that are requested (minimum 2). + * @param [env=process.env] An object containing the environment variables to check. This enables simulating the usage of a specific terminal. + */ + hasColors(count?: number): boolean; + hasColors(env?: object): boolean; + hasColors(count: number, env?: object): boolean; + /** + * `writeStream.getWindowSize()` returns the size of the TTY + * corresponding to this `WriteStream`. The array is of the type`[numColumns, numRows]` where `numColumns` and `numRows` represent the number + * of columns and rows in the corresponding TTY. + * @since v0.7.7 + */ + getWindowSize(): [number, number]; + /** + * A `number` specifying the number of columns the TTY currently has. This property + * is updated whenever the `'resize'` event is emitted. + * @since v0.7.7 + */ + columns: number; + /** + * A `number` specifying the number of rows the TTY currently has. This property + * is updated whenever the `'resize'` event is emitted. + * @since v0.7.7 + */ + rows: number; + /** + * A `boolean` that is always `true`. + * @since v0.5.8 + */ + isTTY: boolean; + } +} +declare module "node:tty" { + export * from "tty"; +} diff --git a/node_modules/@types/node/ts4.8/url.d.ts b/node_modules/@types/node/ts4.8/url.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..20a5d85188d6ab1552230097a1ad8ba16fcec742 --- /dev/null +++ b/node_modules/@types/node/ts4.8/url.d.ts @@ -0,0 +1,927 @@ +/** + * The `node:url` module provides utilities for URL resolution and parsing. It can + * be accessed using: + * + * ```js + * import url from 'node:url'; + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/url.js) + */ +declare module "url" { + import { Blob as NodeBlob } from "node:buffer"; + import { ClientRequestArgs } from "node:http"; + import { ParsedUrlQuery, ParsedUrlQueryInput } from "node:querystring"; + // Input to `url.format` + interface UrlObject { + auth?: string | null | undefined; + hash?: string | null | undefined; + host?: string | null | undefined; + hostname?: string | null | undefined; + href?: string | null | undefined; + pathname?: string | null | undefined; + protocol?: string | null | undefined; + search?: string | null | undefined; + slashes?: boolean | null | undefined; + port?: string | number | null | undefined; + query?: string | null | ParsedUrlQueryInput | undefined; + } + // Output of `url.parse` + interface Url { + auth: string | null; + hash: string | null; + host: string | null; + hostname: string | null; + href: string; + path: string | null; + pathname: string | null; + protocol: string | null; + search: string | null; + slashes: boolean | null; + port: string | null; + query: string | null | ParsedUrlQuery; + } + interface UrlWithParsedQuery extends Url { + query: ParsedUrlQuery; + } + interface UrlWithStringQuery extends Url { + query: string | null; + } + /** + * The `url.parse()` method takes a URL string, parses it, and returns a URL + * object. + * + * A `TypeError` is thrown if `urlString` is not a string. + * + * A `URIError` is thrown if the `auth` property is present but cannot be decoded. + * + * `url.parse()` uses a lenient, non-standard algorithm for parsing URL + * strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487) and incorrect handling of usernames and passwords. Do not use with untrusted + * input. CVEs are not issued for `url.parse()` vulnerabilities. Use the `WHATWG URL` API instead. + * @since v0.1.25 + * @deprecated Use the WHATWG URL API instead. + * @param urlString The URL string to parse. + * @param [parseQueryString=false] If `true`, the `query` property will always be set to an object returned by the {@link querystring} module's `parse()` method. If `false`, the `query` property + * on the returned URL object will be an unparsed, undecoded string. + * @param [slashesDenoteHost=false] If `true`, the first token after the literal string `//` and preceding the next `/` will be interpreted as the `host`. For instance, given `//foo/bar`, the + * result would be `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`. + */ + function parse(urlString: string): UrlWithStringQuery; + function parse( + urlString: string, + parseQueryString: false | undefined, + slashesDenoteHost?: boolean, + ): UrlWithStringQuery; + function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery; + function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url; + /** + * The `url.format()` method returns a formatted URL string derived from`urlObject`. + * + * ```js + * const url = require('node:url'); + * url.format({ + * protocol: 'https', + * hostname: 'example.com', + * pathname: '/some/path', + * query: { + * page: 1, + * format: 'json', + * }, + * }); + * + * // => 'https://example.com/some/path?page=1&format=json' + * ``` + * + * If `urlObject` is not an object or a string, `url.format()` will throw a `TypeError`. + * + * The formatting process operates as follows: + * + * * A new empty string `result` is created. + * * If `urlObject.protocol` is a string, it is appended as-is to `result`. + * * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown. + * * For all string values of `urlObject.protocol` that _do not end_ with an ASCII + * colon (`:`) character, the literal string `:` will be appended to `result`. + * * If either of the following conditions is true, then the literal string `//`will be appended to `result`: + * * `urlObject.slashes` property is true; + * * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`; + * * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string + * and appended to `result`followed by the literal string `@`. + * * If the `urlObject.host` property is `undefined` then: + * * If the `urlObject.hostname` is a string, it is appended to `result`. + * * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string, + * an `Error` is thrown. + * * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`: + * * The literal string `:` is appended to `result`, and + * * The value of `urlObject.port` is coerced to a string and appended to`result`. + * * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`. + * * If the `urlObject.pathname` property is a string that is not an empty string: + * * If the `urlObject.pathname`_does not start_ with an ASCII forward slash + * (`/`), then the literal string `'/'` is appended to `result`. + * * The value of `urlObject.pathname` is appended to `result`. + * * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown. + * * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the + * `querystring` module's `stringify()`method passing the value of `urlObject.query`. + * * Otherwise, if `urlObject.search` is a string: + * * If the value of `urlObject.search`_does not start_ with the ASCII question + * mark (`?`) character, the literal string `?` is appended to `result`. + * * The value of `urlObject.search` is appended to `result`. + * * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown. + * * If the `urlObject.hash` property is a string: + * * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`) + * character, the literal string `#` is appended to `result`. + * * The value of `urlObject.hash` is appended to `result`. + * * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a + * string, an `Error` is thrown. + * * `result` is returned. + * @since v0.1.25 + * @legacy Use the WHATWG URL API instead. + * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`. + */ + function format(urlObject: URL, options?: URLFormatOptions): string; + /** + * The `url.format()` method returns a formatted URL string derived from`urlObject`. + * + * ```js + * const url = require('url'); + * url.format({ + * protocol: 'https', + * hostname: 'example.com', + * pathname: '/some/path', + * query: { + * page: 1, + * format: 'json' + * } + * }); + * + * // => 'https://example.com/some/path?page=1&format=json' + * ``` + * + * If `urlObject` is not an object or a string, `url.format()` will throw a `TypeError`. + * + * The formatting process operates as follows: + * + * * A new empty string `result` is created. + * * If `urlObject.protocol` is a string, it is appended as-is to `result`. + * * Otherwise, if `urlObject.protocol` is not `undefined` and is not a string, an `Error` is thrown. + * * For all string values of `urlObject.protocol` that _do not end_ with an ASCII + * colon (`:`) character, the literal string `:` will be appended to `result`. + * * If either of the following conditions is true, then the literal string `//`will be appended to `result`: + * * `urlObject.slashes` property is true; + * * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or`file`; + * * If the value of the `urlObject.auth` property is truthy, and either`urlObject.host` or `urlObject.hostname` are not `undefined`, the value of`urlObject.auth` will be coerced into a string + * and appended to `result`followed by the literal string `@`. + * * If the `urlObject.host` property is `undefined` then: + * * If the `urlObject.hostname` is a string, it is appended to `result`. + * * Otherwise, if `urlObject.hostname` is not `undefined` and is not a string, + * an `Error` is thrown. + * * If the `urlObject.port` property value is truthy, and `urlObject.hostname`is not `undefined`: + * * The literal string `:` is appended to `result`, and + * * The value of `urlObject.port` is coerced to a string and appended to`result`. + * * Otherwise, if the `urlObject.host` property value is truthy, the value of`urlObject.host` is coerced to a string and appended to `result`. + * * If the `urlObject.pathname` property is a string that is not an empty string: + * * If the `urlObject.pathname`_does not start_ with an ASCII forward slash + * (`/`), then the literal string `'/'` is appended to `result`. + * * The value of `urlObject.pathname` is appended to `result`. + * * Otherwise, if `urlObject.pathname` is not `undefined` and is not a string, an `Error` is thrown. + * * If the `urlObject.search` property is `undefined` and if the `urlObject.query`property is an `Object`, the literal string `?` is appended to `result`followed by the output of calling the + * `querystring` module's `stringify()`method passing the value of `urlObject.query`. + * * Otherwise, if `urlObject.search` is a string: + * * If the value of `urlObject.search`_does not start_ with the ASCII question + * mark (`?`) character, the literal string `?` is appended to `result`. + * * The value of `urlObject.search` is appended to `result`. + * * Otherwise, if `urlObject.search` is not `undefined` and is not a string, an `Error` is thrown. + * * If the `urlObject.hash` property is a string: + * * If the value of `urlObject.hash`_does not start_ with the ASCII hash (`#`) + * character, the literal string `#` is appended to `result`. + * * The value of `urlObject.hash` is appended to `result`. + * * Otherwise, if the `urlObject.hash` property is not `undefined` and is not a + * string, an `Error` is thrown. + * * `result` is returned. + * @since v0.1.25 + * @legacy Use the WHATWG URL API instead. + * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`. + */ + function format(urlObject: UrlObject | string): string; + /** + * The `url.resolve()` method resolves a target URL relative to a base URL in a + * manner similar to that of a web browser resolving an anchor tag. + * + * ```js + * const url = require('node:url'); + * url.resolve('/one/two/three', 'four'); // '/one/two/four' + * url.resolve('http://example.com/', '/one'); // 'http://example.com/one' + * url.resolve('http://example.com/one', '/two'); // 'http://example.com/two' + * ``` + * + * To achieve the same result using the WHATWG URL API: + * + * ```js + * function resolve(from, to) { + * const resolvedUrl = new URL(to, new URL(from, 'resolve://')); + * if (resolvedUrl.protocol === 'resolve:') { + * // `from` is a relative URL. + * const { pathname, search, hash } = resolvedUrl; + * return pathname + search + hash; + * } + * return resolvedUrl.toString(); + * } + * + * resolve('/one/two/three', 'four'); // '/one/two/four' + * resolve('http://example.com/', '/one'); // 'http://example.com/one' + * resolve('http://example.com/one', '/two'); // 'http://example.com/two' + * ``` + * @since v0.1.25 + * @legacy Use the WHATWG URL API instead. + * @param from The base URL to use if `to` is a relative URL. + * @param to The target URL to resolve. + */ + function resolve(from: string, to: string): string; + /** + * Returns the [Punycode](https://tools.ietf.org/html/rfc5891#section-4.4) ASCII serialization of the `domain`. If `domain` is an + * invalid domain, the empty string is returned. + * + * It performs the inverse operation to {@link domainToUnicode}. + * + * ```js + * import url from 'node:url'; + * + * console.log(url.domainToASCII('español.com')); + * // Prints xn--espaol-zwa.com + * console.log(url.domainToASCII('中文.com')); + * // Prints xn--fiq228c.com + * console.log(url.domainToASCII('xn--iñvalid.com')); + * // Prints an empty string + * ``` + * @since v7.4.0, v6.13.0 + */ + function domainToASCII(domain: string): string; + /** + * Returns the Unicode serialization of the `domain`. If `domain` is an invalid + * domain, the empty string is returned. + * + * It performs the inverse operation to {@link domainToASCII}. + * + * ```js + * import url from 'node:url'; + * + * console.log(url.domainToUnicode('xn--espaol-zwa.com')); + * // Prints español.com + * console.log(url.domainToUnicode('xn--fiq228c.com')); + * // Prints 中文.com + * console.log(url.domainToUnicode('xn--iñvalid.com')); + * // Prints an empty string + * ``` + * @since v7.4.0, v6.13.0 + */ + function domainToUnicode(domain: string): string; + /** + * This function ensures the correct decodings of percent-encoded characters as + * well as ensuring a cross-platform valid absolute path string. + * + * ```js + * import { fileURLToPath } from 'node:url'; + * + * const __filename = fileURLToPath(import.meta.url); + * + * new URL('file:///C:/path/').pathname; // Incorrect: /C:/path/ + * fileURLToPath('file:///C:/path/'); // Correct: C:\path\ (Windows) + * + * new URL('file://nas/foo.txt').pathname; // Incorrect: /foo.txt + * fileURLToPath('file://nas/foo.txt'); // Correct: \\nas\foo.txt (Windows) + * + * new URL('file:///你好.txt').pathname; // Incorrect: /%E4%BD%A0%E5%A5%BD.txt + * fileURLToPath('file:///你好.txt'); // Correct: /你好.txt (POSIX) + * + * new URL('file:///hello world').pathname; // Incorrect: /hello%20world + * fileURLToPath('file:///hello world'); // Correct: /hello world (POSIX) + * ``` + * @since v10.12.0 + * @param url The file URL string or URL object to convert to a path. + * @return The fully-resolved platform-specific Node.js file path. + */ + function fileURLToPath(url: string | URL): string; + /** + * This function ensures that `path` is resolved absolutely, and that the URL + * control characters are correctly encoded when converting into a File URL. + * + * ```js + * import { pathToFileURL } from 'node:url'; + * + * new URL('/foo#1', 'file:'); // Incorrect: file:///foo#1 + * pathToFileURL('/foo#1'); // Correct: file:///foo%231 (POSIX) + * + * new URL('/some/path%.c', 'file:'); // Incorrect: file:///some/path%.c + * pathToFileURL('/some/path%.c'); // Correct: file:///some/path%25.c (POSIX) + * ``` + * @since v10.12.0 + * @param path The path to convert to a File URL. + * @return The file URL object. + */ + function pathToFileURL(path: string): URL; + /** + * This utility function converts a URL object into an ordinary options object as + * expected by the `http.request()` and `https.request()` APIs. + * + * ```js + * import { urlToHttpOptions } from 'node:url'; + * const myURL = new URL('https://a:b@測試?abc#foo'); + * + * console.log(urlToHttpOptions(myURL)); + * /* + * { + * protocol: 'https:', + * hostname: 'xn--g6w251d', + * hash: '#foo', + * search: '?abc', + * pathname: '/', + * path: '/?abc', + * href: 'https://a:b@xn--g6w251d/?abc#foo', + * auth: 'a:b' + * } + * + * ``` + * @since v15.7.0, v14.18.0 + * @param url The `WHATWG URL` object to convert to an options object. + * @return Options object + */ + function urlToHttpOptions(url: URL): ClientRequestArgs; + interface URLFormatOptions { + auth?: boolean | undefined; + fragment?: boolean | undefined; + search?: boolean | undefined; + unicode?: boolean | undefined; + } + /** + * Browser-compatible `URL` class, implemented by following the WHATWG URL + * Standard. [Examples of parsed URLs](https://url.spec.whatwg.org/#example-url-parsing) may be found in the Standard itself. + * The `URL` class is also available on the global object. + * + * In accordance with browser conventions, all properties of `URL` objects + * are implemented as getters and setters on the class prototype, rather than as + * data properties on the object itself. Thus, unlike `legacy urlObject` s, + * using the `delete` keyword on any properties of `URL` objects (e.g. `delete myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still + * return `true`. + * @since v7.0.0, v6.13.0 + */ + class URL { + /** + * Creates a `'blob:nodedata:...'` URL string that represents the given `Blob` object and can be used to retrieve the `Blob` later. + * + * ```js + * const { + * Blob, + * resolveObjectURL, + * } = require('node:buffer'); + * + * const blob = new Blob(['hello']); + * const id = URL.createObjectURL(blob); + * + * // later... + * + * const otherBlob = resolveObjectURL(id); + * console.log(otherBlob.size); + * ``` + * + * The data stored by the registered `Blob` will be retained in memory until`URL.revokeObjectURL()` is called to remove it. + * + * `Blob` objects are registered within the current thread. If using Worker + * Threads, `Blob` objects registered within one Worker will not be available + * to other workers or the main thread. + * @since v16.7.0 + * @experimental + */ + static createObjectURL(blob: NodeBlob): string; + /** + * Removes the stored `Blob` identified by the given ID. Attempting to revoke a + * ID that isn't registered will silently fail. + * @since v16.7.0 + * @experimental + * @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`. + */ + static revokeObjectURL(objectUrl: string): void; + /** + * Checks if an `input` relative to the `base` can be parsed to a `URL`. + * + * ```js + * const isValid = URL.canParse('/foo', 'https://example.org/'); // true + * + * const isNotValid = URL.canParse('/foo'); // false + * ``` + * @since v19.9.0 + * @param input The absolute or relative input URL to parse. If `input` is relative, then `base` is required. If `input` is absolute, the `base` is ignored. If `input` is not a string, it is + * `converted to a string` first. + * @param base The base URL to resolve against if the `input` is not absolute. If `base` is not a string, it is `converted to a string` first. + */ + static canParse(input: string, base?: string): boolean; + constructor(input: string, base?: string | URL); + /** + * Gets and sets the fragment portion of the URL. + * + * ```js + * const myURL = new URL('https://example.org/foo#bar'); + * console.log(myURL.hash); + * // Prints #bar + * + * myURL.hash = 'baz'; + * console.log(myURL.href); + * // Prints https://example.org/foo#baz + * ``` + * + * Invalid URL characters included in the value assigned to the `hash` property + * are `percent-encoded`. The selection of which characters to + * percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce. + */ + hash: string; + /** + * Gets and sets the host portion of the URL. + * + * ```js + * const myURL = new URL('https://example.org:81/foo'); + * console.log(myURL.host); + * // Prints example.org:81 + * + * myURL.host = 'example.com:82'; + * console.log(myURL.href); + * // Prints https://example.com:82/foo + * ``` + * + * Invalid host values assigned to the `host` property are ignored. + */ + host: string; + /** + * Gets and sets the host name portion of the URL. The key difference between`url.host` and `url.hostname` is that `url.hostname` does _not_ include the + * port. + * + * ```js + * const myURL = new URL('https://example.org:81/foo'); + * console.log(myURL.hostname); + * // Prints example.org + * + * // Setting the hostname does not change the port + * myURL.hostname = 'example.com'; + * console.log(myURL.href); + * // Prints https://example.com:81/foo + * + * // Use myURL.host to change the hostname and port + * myURL.host = 'example.org:82'; + * console.log(myURL.href); + * // Prints https://example.org:82/foo + * ``` + * + * Invalid host name values assigned to the `hostname` property are ignored. + */ + hostname: string; + /** + * Gets and sets the serialized URL. + * + * ```js + * const myURL = new URL('https://example.org/foo'); + * console.log(myURL.href); + * // Prints https://example.org/foo + * + * myURL.href = 'https://example.com/bar'; + * console.log(myURL.href); + * // Prints https://example.com/bar + * ``` + * + * Getting the value of the `href` property is equivalent to calling {@link toString}. + * + * Setting the value of this property to a new value is equivalent to creating a + * new `URL` object using `new URL(value)`. Each of the `URL`object's properties will be modified. + * + * If the value assigned to the `href` property is not a valid URL, a `TypeError`will be thrown. + */ + href: string; + /** + * Gets the read-only serialization of the URL's origin. + * + * ```js + * const myURL = new URL('https://example.org/foo/bar?baz'); + * console.log(myURL.origin); + * // Prints https://example.org + * ``` + * + * ```js + * const idnURL = new URL('https://測試'); + * console.log(idnURL.origin); + * // Prints https://xn--g6w251d + * + * console.log(idnURL.hostname); + * // Prints xn--g6w251d + * ``` + */ + readonly origin: string; + /** + * Gets and sets the password portion of the URL. + * + * ```js + * const myURL = new URL('https://abc:xyz@example.com'); + * console.log(myURL.password); + * // Prints xyz + * + * myURL.password = '123'; + * console.log(myURL.href); + * // Prints https://abc:123@example.com/ + * ``` + * + * Invalid URL characters included in the value assigned to the `password` property + * are `percent-encoded`. The selection of which characters to + * percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce. + */ + password: string; + /** + * Gets and sets the path portion of the URL. + * + * ```js + * const myURL = new URL('https://example.org/abc/xyz?123'); + * console.log(myURL.pathname); + * // Prints /abc/xyz + * + * myURL.pathname = '/abcdef'; + * console.log(myURL.href); + * // Prints https://example.org/abcdef?123 + * ``` + * + * Invalid URL characters included in the value assigned to the `pathname`property are `percent-encoded`. The selection of which characters + * to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce. + */ + pathname: string; + /** + * Gets and sets the port portion of the URL. + * + * The port value may be a number or a string containing a number in the range`0` to `65535` (inclusive). Setting the value to the default port of the`URL` objects given `protocol` will + * result in the `port` value becoming + * the empty string (`''`). + * + * The port value can be an empty string in which case the port depends on + * the protocol/scheme: + * + * + * + * Upon assigning a value to the port, the value will first be converted to a + * string using `.toString()`. + * + * If that string is invalid but it begins with a number, the leading number is + * assigned to `port`. + * If the number lies outside the range denoted above, it is ignored. + * + * ```js + * const myURL = new URL('https://example.org:8888'); + * console.log(myURL.port); + * // Prints 8888 + * + * // Default ports are automatically transformed to the empty string + * // (HTTPS protocol's default port is 443) + * myURL.port = '443'; + * console.log(myURL.port); + * // Prints the empty string + * console.log(myURL.href); + * // Prints https://example.org/ + * + * myURL.port = 1234; + * console.log(myURL.port); + * // Prints 1234 + * console.log(myURL.href); + * // Prints https://example.org:1234/ + * + * // Completely invalid port strings are ignored + * myURL.port = 'abcd'; + * console.log(myURL.port); + * // Prints 1234 + * + * // Leading numbers are treated as a port number + * myURL.port = '5678abcd'; + * console.log(myURL.port); + * // Prints 5678 + * + * // Non-integers are truncated + * myURL.port = 1234.5678; + * console.log(myURL.port); + * // Prints 1234 + * + * // Out-of-range numbers which are not represented in scientific notation + * // will be ignored. + * myURL.port = 1e10; // 10000000000, will be range-checked as described below + * console.log(myURL.port); + * // Prints 1234 + * ``` + * + * Numbers which contain a decimal point, + * such as floating-point numbers or numbers in scientific notation, + * are not an exception to this rule. + * Leading numbers up to the decimal point will be set as the URL's port, + * assuming they are valid: + * + * ```js + * myURL.port = 4.567e21; + * console.log(myURL.port); + * // Prints 4 (because it is the leading number in the string '4.567e21') + * ``` + */ + port: string; + /** + * Gets and sets the protocol portion of the URL. + * + * ```js + * const myURL = new URL('https://example.org'); + * console.log(myURL.protocol); + * // Prints https: + * + * myURL.protocol = 'ftp'; + * console.log(myURL.href); + * // Prints ftp://example.org/ + * ``` + * + * Invalid URL protocol values assigned to the `protocol` property are ignored. + */ + protocol: string; + /** + * Gets and sets the serialized query portion of the URL. + * + * ```js + * const myURL = new URL('https://example.org/abc?123'); + * console.log(myURL.search); + * // Prints ?123 + * + * myURL.search = 'abc=xyz'; + * console.log(myURL.href); + * // Prints https://example.org/abc?abc=xyz + * ``` + * + * Any invalid URL characters appearing in the value assigned the `search`property will be `percent-encoded`. The selection of which + * characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce. + */ + search: string; + /** + * Gets the `URLSearchParams` object representing the query parameters of the + * URL. This property is read-only but the `URLSearchParams` object it provides + * can be used to mutate the URL instance; to replace the entirety of query + * parameters of the URL, use the {@link search} setter. See `URLSearchParams` documentation for details. + * + * Use care when using `.searchParams` to modify the `URL` because, + * per the WHATWG specification, the `URLSearchParams` object uses + * different rules to determine which characters to percent-encode. For + * instance, the `URL` object will not percent encode the ASCII tilde (`~`) + * character, while `URLSearchParams` will always encode it: + * + * ```js + * const myURL = new URL('https://example.org/abc?foo=~bar'); + * + * console.log(myURL.search); // prints ?foo=~bar + * + * // Modify the URL via searchParams... + * myURL.searchParams.sort(); + * + * console.log(myURL.search); // prints ?foo=%7Ebar + * ``` + */ + readonly searchParams: URLSearchParams; + /** + * Gets and sets the username portion of the URL. + * + * ```js + * const myURL = new URL('https://abc:xyz@example.com'); + * console.log(myURL.username); + * // Prints abc + * + * myURL.username = '123'; + * console.log(myURL.href); + * // Prints https://123:xyz@example.com/ + * ``` + * + * Any invalid URL characters appearing in the value assigned the `username`property will be `percent-encoded`. The selection of which + * characters to percent-encode may vary somewhat from what the {@link parse} and {@link format} methods would produce. + */ + username: string; + /** + * The `toString()` method on the `URL` object returns the serialized URL. The + * value returned is equivalent to that of {@link href} and {@link toJSON}. + */ + toString(): string; + /** + * The `toJSON()` method on the `URL` object returns the serialized URL. The + * value returned is equivalent to that of {@link href} and {@link toString}. + * + * This method is automatically called when an `URL` object is serialized + * with [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). + * + * ```js + * const myURLs = [ + * new URL('https://www.example.com'), + * new URL('https://test.example.org'), + * ]; + * console.log(JSON.stringify(myURLs)); + * // Prints ["https://www.example.com/","https://test.example.org/"] + * ``` + */ + toJSON(): string; + } + /** + * The `URLSearchParams` API provides read and write access to the query of a`URL`. The `URLSearchParams` class can also be used standalone with one of the + * four following constructors. + * The `URLSearchParams` class is also available on the global object. + * + * The WHATWG `URLSearchParams` interface and the `querystring` module have + * similar purpose, but the purpose of the `querystring` module is more + * general, as it allows the customization of delimiter characters (`&` and `=`). + * On the other hand, this API is designed purely for URL query strings. + * + * ```js + * const myURL = new URL('https://example.org/?abc=123'); + * console.log(myURL.searchParams.get('abc')); + * // Prints 123 + * + * myURL.searchParams.append('abc', 'xyz'); + * console.log(myURL.href); + * // Prints https://example.org/?abc=123&abc=xyz + * + * myURL.searchParams.delete('abc'); + * myURL.searchParams.set('a', 'b'); + * console.log(myURL.href); + * // Prints https://example.org/?a=b + * + * const newSearchParams = new URLSearchParams(myURL.searchParams); + * // The above is equivalent to + * // const newSearchParams = new URLSearchParams(myURL.search); + * + * newSearchParams.append('a', 'c'); + * console.log(myURL.href); + * // Prints https://example.org/?a=b + * console.log(newSearchParams.toString()); + * // Prints a=b&a=c + * + * // newSearchParams.toString() is implicitly called + * myURL.search = newSearchParams; + * console.log(myURL.href); + * // Prints https://example.org/?a=b&a=c + * newSearchParams.delete('a'); + * console.log(myURL.href); + * // Prints https://example.org/?a=b&a=c + * ``` + * @since v7.5.0, v6.13.0 + */ + class URLSearchParams implements Iterable<[string, string]> { + constructor( + init?: + | URLSearchParams + | string + | Record + | Iterable<[string, string]> + | ReadonlyArray<[string, string]>, + ); + /** + * Append a new name-value pair to the query string. + */ + append(name: string, value: string): void; + /** + * If `value` is provided, removes all name-value pairs + * where name is `name` and value is `value`.. + * + * If `value` is not provided, removes all name-value pairs whose name is `name`. + */ + delete(name: string, value?: string): void; + /** + * Returns an ES6 `Iterator` over each of the name-value pairs in the query. + * Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`. + * + * Alias for `urlSearchParams[@@iterator]()`. + */ + entries(): IterableIterator<[string, string]>; + /** + * Iterates over each name-value pair in the query and invokes the given function. + * + * ```js + * const myURL = new URL('https://example.org/?a=b&c=d'); + * myURL.searchParams.forEach((value, name, searchParams) => { + * console.log(name, value, myURL.searchParams === searchParams); + * }); + * // Prints: + * // a b true + * // c d true + * ``` + * @param fn Invoked for each name-value pair in the query + * @param thisArg To be used as `this` value for when `fn` is called + */ + forEach( + callback: (this: TThis, value: string, name: string, searchParams: URLSearchParams) => void, + thisArg?: TThis, + ): void; + /** + * Returns the value of the first name-value pair whose name is `name`. If there + * are no such pairs, `null` is returned. + * @return or `null` if there is no name-value pair with the given `name`. + */ + get(name: string): string | null; + /** + * Returns the values of all name-value pairs whose name is `name`. If there are + * no such pairs, an empty array is returned. + */ + getAll(name: string): string[]; + /** + * Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument. + * + * If `value` is provided, returns `true` when name-value pair with + * same `name` and `value` exists. + * + * If `value` is not provided, returns `true` if there is at least one name-value + * pair whose name is `name`. + */ + has(name: string, value?: string): boolean; + /** + * Returns an ES6 `Iterator` over the names of each name-value pair. + * + * ```js + * const params = new URLSearchParams('foo=bar&foo=baz'); + * for (const name of params.keys()) { + * console.log(name); + * } + * // Prints: + * // foo + * // foo + * ``` + */ + keys(): IterableIterator; + /** + * Sets the value in the `URLSearchParams` object associated with `name` to`value`. If there are any pre-existing name-value pairs whose names are `name`, + * set the first such pair's value to `value` and remove all others. If not, + * append the name-value pair to the query string. + * + * ```js + * const params = new URLSearchParams(); + * params.append('foo', 'bar'); + * params.append('foo', 'baz'); + * params.append('abc', 'def'); + * console.log(params.toString()); + * // Prints foo=bar&foo=baz&abc=def + * + * params.set('foo', 'def'); + * params.set('xyz', 'opq'); + * console.log(params.toString()); + * // Prints foo=def&abc=def&xyz=opq + * ``` + */ + set(name: string, value: string): void; + /** + * The total number of parameter entries. + * @since v19.8.0 + */ + readonly size: number; + /** + * Sort all existing name-value pairs in-place by their names. Sorting is done + * with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs + * with the same name is preserved. + * + * This method can be used, in particular, to increase cache hits. + * + * ```js + * const params = new URLSearchParams('query[]=abc&type=search&query[]=123'); + * params.sort(); + * console.log(params.toString()); + * // Prints query%5B%5D=abc&query%5B%5D=123&type=search + * ``` + * @since v7.7.0, v6.13.0 + */ + sort(): void; + /** + * Returns the search parameters serialized as a string, with characters + * percent-encoded where necessary. + */ + toString(): string; + /** + * Returns an ES6 `Iterator` over the values of each name-value pair. + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator<[string, string]>; + } + import { URL as _URL, URLSearchParams as _URLSearchParams } from "url"; + global { + interface URLSearchParams extends _URLSearchParams {} + interface URL extends _URL {} + interface Global { + URL: typeof _URL; + URLSearchParams: typeof _URLSearchParams; + } + /** + * `URL` class is a global reference for `require('url').URL` + * https://nodejs.org/api/url.html#the-whatwg-url-api + * @since v10.0.0 + */ + var URL: typeof globalThis extends { + onmessage: any; + URL: infer T; + } ? T + : typeof _URL; + /** + * `URLSearchParams` class is a global reference for `require('url').URLSearchParams` + * https://nodejs.org/api/url.html#class-urlsearchparams + * @since v10.0.0 + */ + var URLSearchParams: typeof globalThis extends { + onmessage: any; + URLSearchParams: infer T; + } ? T + : typeof _URLSearchParams; + } +} +declare module "node:url" { + export * from "url"; +} diff --git a/node_modules/@types/node/ts4.8/util.d.ts b/node_modules/@types/node/ts4.8/util.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d55c350ef2f77860e1623db657dab8f67ea71e2 --- /dev/null +++ b/node_modules/@types/node/ts4.8/util.d.ts @@ -0,0 +1,2186 @@ +/** + * The `node:util` module supports the needs of Node.js internal APIs. Many of the + * utilities are useful for application and module developers as well. To access + * it: + * + * ```js + * const util = require('node:util'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/util.js) + */ +declare module "util" { + import * as types from "node:util/types"; + export interface InspectOptions { + /** + * If `true`, object's non-enumerable symbols and properties are included in the formatted result. + * `WeakMap` and `WeakSet` entries are also included as well as user defined prototype properties (excluding method properties). + * @default false + */ + showHidden?: boolean | undefined; + /** + * Specifies the number of times to recurse while formatting object. + * This is useful for inspecting large objects. + * To recurse up to the maximum call stack size pass `Infinity` or `null`. + * @default 2 + */ + depth?: number | null | undefined; + /** + * If `true`, the output is styled with ANSI color codes. Colors are customizable. + */ + colors?: boolean | undefined; + /** + * If `false`, `[util.inspect.custom](depth, opts, inspect)` functions are not invoked. + * @default true + */ + customInspect?: boolean | undefined; + /** + * If `true`, `Proxy` inspection includes the target and handler objects. + * @default false + */ + showProxy?: boolean | undefined; + /** + * Specifies the maximum number of `Array`, `TypedArray`, `WeakMap`, and `WeakSet` elements + * to include when formatting. Set to `null` or `Infinity` to show all elements. + * Set to `0` or negative to show no elements. + * @default 100 + */ + maxArrayLength?: number | null | undefined; + /** + * Specifies the maximum number of characters to + * include when formatting. Set to `null` or `Infinity` to show all elements. + * Set to `0` or negative to show no characters. + * @default 10000 + */ + maxStringLength?: number | null | undefined; + /** + * The length at which input values are split across multiple lines. + * Set to `Infinity` to format the input as a single line + * (in combination with `compact` set to `true` or any number >= `1`). + * @default 80 + */ + breakLength?: number | undefined; + /** + * Setting this to `false` causes each object key + * to be displayed on a new line. It will also add new lines to text that is + * longer than `breakLength`. If set to a number, the most `n` inner elements + * are united on a single line as long as all properties fit into + * `breakLength`. Short array elements are also grouped together. Note that no + * text will be reduced below 16 characters, no matter the `breakLength` size. + * For more information, see the example below. + * @default true + */ + compact?: boolean | number | undefined; + /** + * If set to `true` or a function, all properties of an object, and `Set` and `Map` + * entries are sorted in the resulting string. + * If set to `true` the default sort is used. + * If set to a function, it is used as a compare function. + */ + sorted?: boolean | ((a: string, b: string) => number) | undefined; + /** + * If set to `true`, getters are going to be + * inspected as well. If set to `'get'` only getters without setter are going + * to be inspected. If set to `'set'` only getters having a corresponding + * setter are going to be inspected. This might cause side effects depending on + * the getter function. + * @default false + */ + getters?: "get" | "set" | boolean | undefined; + /** + * If set to `true`, an underscore is used to separate every three digits in all bigints and numbers. + * @default false + */ + numericSeparator?: boolean | undefined; + } + export type Style = + | "special" + | "number" + | "bigint" + | "boolean" + | "undefined" + | "null" + | "string" + | "symbol" + | "date" + | "regexp" + | "module"; + export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => any; // TODO: , inspect: inspect + export interface InspectOptionsStylized extends InspectOptions { + stylize(text: string, styleType: Style): string; + } + /** + * The `util.format()` method returns a formatted string using the first argument + * as a `printf`\-like format string which can contain zero or more format + * specifiers. Each specifier is replaced with the converted value from the + * corresponding argument. Supported specifiers are: + * + * If a specifier does not have a corresponding argument, it is not replaced: + * + * ```js + * util.format('%s:%s', 'foo'); + * // Returns: 'foo:%s' + * ``` + * + * Values that are not part of the format string are formatted using`util.inspect()` if their type is not `string`. + * + * If there are more arguments passed to the `util.format()` method than the + * number of specifiers, the extra arguments are concatenated to the returned + * string, separated by spaces: + * + * ```js + * util.format('%s:%s', 'foo', 'bar', 'baz'); + * // Returns: 'foo:bar baz' + * ``` + * + * If the first argument does not contain a valid format specifier, `util.format()`returns a string that is the concatenation of all arguments separated by spaces: + * + * ```js + * util.format(1, 2, 3); + * // Returns: '1 2 3' + * ``` + * + * If only one argument is passed to `util.format()`, it is returned as it is + * without any formatting: + * + * ```js + * util.format('%% %s'); + * // Returns: '%% %s' + * ``` + * + * `util.format()` is a synchronous method that is intended as a debugging tool. + * Some input values can have a significant performance overhead that can block the + * event loop. Use this function with care and never in a hot code path. + * @since v0.5.3 + * @param format A `printf`-like format string. + */ + export function format(format?: any, ...param: any[]): string; + /** + * This function is identical to {@link format}, except in that it takes + * an `inspectOptions` argument which specifies options that are passed along to {@link inspect}. + * + * ```js + * util.formatWithOptions({ colors: true }, 'See object %O', { foo: 42 }); + * // Returns 'See object { foo: 42 }', where `42` is colored as a number + * // when printed to a terminal. + * ``` + * @since v10.0.0 + */ + export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string; + /** + * Returns the string name for a numeric error code that comes from a Node.js API. + * The mapping between error codes and error names is platform-dependent. + * See `Common System Errors` for the names of common errors. + * + * ```js + * fs.access('file/that/does/not/exist', (err) => { + * const name = util.getSystemErrorName(err.errno); + * console.error(name); // ENOENT + * }); + * ``` + * @since v9.7.0 + */ + export function getSystemErrorName(err: number): string; + /** + * Returns a Map of all system error codes available from the Node.js API. + * The mapping between error codes and error names is platform-dependent. + * See `Common System Errors` for the names of common errors. + * + * ```js + * fs.access('file/that/does/not/exist', (err) => { + * const errorMap = util.getSystemErrorMap(); + * const name = errorMap.get(err.errno); + * console.error(name); // ENOENT + * }); + * ``` + * @since v16.0.0, v14.17.0 + */ + export function getSystemErrorMap(): Map; + /** + * The `util.log()` method prints the given `string` to `stdout` with an included + * timestamp. + * + * ```js + * const util = require('node:util'); + * + * util.log('Timestamped message.'); + * ``` + * @since v0.3.0 + * @deprecated Since v6.0.0 - Use a third party module instead. + */ + export function log(string: string): void; + /** + * Returns the `string` after replacing any surrogate code points + * (or equivalently, any unpaired surrogate code units) with the + * Unicode "replacement character" U+FFFD. + * @since v16.8.0, v14.18.0 + */ + export function toUSVString(string: string): string; + /** + * Creates and returns an `AbortController` instance whose `AbortSignal` is marked + * as transferable and can be used with `structuredClone()` or `postMessage()`. + * @since v18.11.0 + * @experimental + * @returns A transferable AbortController + */ + export function transferableAbortController(): AbortController; + /** + * Marks the given `AbortSignal` as transferable so that it can be used with`structuredClone()` and `postMessage()`. + * + * ```js + * const signal = transferableAbortSignal(AbortSignal.timeout(100)); + * const channel = new MessageChannel(); + * channel.port2.postMessage(signal, [signal]); + * ``` + * @since v18.11.0 + * @experimental + * @param signal The AbortSignal + * @returns The same AbortSignal + */ + export function transferableAbortSignal(signal: AbortSignal): AbortSignal; + /** + * Listens to abort event on the provided `signal` and + * returns a promise that is fulfilled when the `signal` is + * aborted. If the passed `resource` is garbage collected before the `signal` is + * aborted, the returned promise shall remain pending indefinitely. + * + * ```js + * import { aborted } from 'node:util'; + * + * const dependent = obtainSomethingAbortable(); + * + * aborted(dependent.signal, dependent).then(() => { + * // Do something when dependent is aborted. + * }); + * + * dependent.on('event', () => { + * dependent.abort(); + * }); + * ``` + * @since v19.7.0 + * @experimental + * @param resource Any non-null entity, reference to which is held weakly. + */ + export function aborted(signal: AbortSignal, resource: any): Promise; + /** + * The `util.inspect()` method returns a string representation of `object` that is + * intended for debugging. The output of `util.inspect` may change at any time + * and should not be depended upon programmatically. Additional `options` may be + * passed that alter the result.`util.inspect()` will use the constructor's name and/or `@@toStringTag` to make + * an identifiable tag for an inspected value. + * + * ```js + * class Foo { + * get [Symbol.toStringTag]() { + * return 'bar'; + * } + * } + * + * class Bar {} + * + * const baz = Object.create(null, { [Symbol.toStringTag]: { value: 'foo' } }); + * + * util.inspect(new Foo()); // 'Foo [bar] {}' + * util.inspect(new Bar()); // 'Bar {}' + * util.inspect(baz); // '[foo] {}' + * ``` + * + * Circular references point to their anchor by using a reference index: + * + * ```js + * const { inspect } = require('node:util'); + * + * const obj = {}; + * obj.a = [obj]; + * obj.b = {}; + * obj.b.inner = obj.b; + * obj.b.obj = obj; + * + * console.log(inspect(obj)); + * // { + * // a: [ [Circular *1] ], + * // b: { inner: [Circular *2], obj: [Circular *1] } + * // } + * ``` + * + * The following example inspects all properties of the `util` object: + * + * ```js + * const util = require('node:util'); + * + * console.log(util.inspect(util, { showHidden: true, depth: null })); + * ``` + * + * The following example highlights the effect of the `compact` option: + * + * ```js + * const util = require('node:util'); + * + * const o = { + * a: [1, 2, [[ + * 'Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit, sed do ' + + * 'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.', + * 'test', + * 'foo']], 4], + * b: new Map([['za', 1], ['zb', 'test']]), + * }; + * console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 })); + * + * // { a: + * // [ 1, + * // 2, + * // [ [ 'Lorem ipsum dolor sit amet,\nconsectetur [...]', // A long line + * // 'test', + * // 'foo' ] ], + * // 4 ], + * // b: Map(2) { 'za' => 1, 'zb' => 'test' } } + * + * // Setting `compact` to false or an integer creates more reader friendly output. + * console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 })); + * + * // { + * // a: [ + * // 1, + * // 2, + * // [ + * // [ + * // 'Lorem ipsum dolor sit amet,\n' + + * // 'consectetur adipiscing elit, sed do eiusmod \n' + + * // 'tempor incididunt ut labore et dolore magna aliqua.', + * // 'test', + * // 'foo' + * // ] + * // ], + * // 4 + * // ], + * // b: Map(2) { + * // 'za' => 1, + * // 'zb' => 'test' + * // } + * // } + * + * // Setting `breakLength` to e.g. 150 will print the "Lorem ipsum" text in a + * // single line. + * ``` + * + * The `showHidden` option allows [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) and + * [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries to be + * inspected. If there are more entries than `maxArrayLength`, there is no + * guarantee which entries are displayed. That means retrieving the same [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries twice may + * result in different output. Furthermore, entries + * with no remaining strong references may be garbage collected at any time. + * + * ```js + * const { inspect } = require('node:util'); + * + * const obj = { a: 1 }; + * const obj2 = { b: 2 }; + * const weakSet = new WeakSet([obj, obj2]); + * + * console.log(inspect(weakSet, { showHidden: true })); + * // WeakSet { { a: 1 }, { b: 2 } } + * ``` + * + * The `sorted` option ensures that an object's property insertion order does not + * impact the result of `util.inspect()`. + * + * ```js + * const { inspect } = require('node:util'); + * const assert = require('node:assert'); + * + * const o1 = { + * b: [2, 3, 1], + * a: '`a` comes before `b`', + * c: new Set([2, 3, 1]), + * }; + * console.log(inspect(o1, { sorted: true })); + * // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set(3) { 1, 2, 3 } } + * console.log(inspect(o1, { sorted: (a, b) => b.localeCompare(a) })); + * // { c: Set(3) { 3, 2, 1 }, b: [ 2, 3, 1 ], a: '`a` comes before `b`' } + * + * const o2 = { + * c: new Set([2, 1, 3]), + * a: '`a` comes before `b`', + * b: [2, 3, 1], + * }; + * assert.strict.equal( + * inspect(o1, { sorted: true }), + * inspect(o2, { sorted: true }), + * ); + * ``` + * + * The `numericSeparator` option adds an underscore every three digits to all + * numbers. + * + * ```js + * const { inspect } = require('node:util'); + * + * const thousand = 1_000; + * const million = 1_000_000; + * const bigNumber = 123_456_789n; + * const bigDecimal = 1_234.123_45; + * + * console.log(inspect(thousand, { numericSeparator: true })); + * // 1_000 + * console.log(inspect(million, { numericSeparator: true })); + * // 1_000_000 + * console.log(inspect(bigNumber, { numericSeparator: true })); + * // 123_456_789n + * console.log(inspect(bigDecimal, { numericSeparator: true })); + * // 1_234.123_45 + * ``` + * + * `util.inspect()` is a synchronous method intended for debugging. Its maximum + * output length is approximately 128 MiB. Inputs that result in longer output will + * be truncated. + * @since v0.3.0 + * @param object Any JavaScript primitive or `Object`. + * @return The representation of `object`. + */ + export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string; + export function inspect(object: any, options?: InspectOptions): string; + export namespace inspect { + let colors: NodeJS.Dict<[number, number]>; + let styles: { + [K in Style]: string; + }; + let defaultOptions: InspectOptions; + /** + * Allows changing inspect settings from the repl. + */ + let replDefaults: InspectOptions; + /** + * That can be used to declare custom inspect functions. + */ + const custom: unique symbol; + } + /** + * Alias for [`Array.isArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray). + * + * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isArray([]); + * // Returns: true + * util.isArray(new Array()); + * // Returns: true + * util.isArray({}); + * // Returns: false + * ``` + * @since v0.6.0 + * @deprecated Since v4.0.0 - Use `isArray` instead. + */ + export function isArray(object: unknown): object is unknown[]; + /** + * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isRegExp(/some regexp/); + * // Returns: true + * util.isRegExp(new RegExp('another regexp')); + * // Returns: true + * util.isRegExp({}); + * // Returns: false + * ``` + * @since v0.6.0 + * @deprecated Since v4.0.0 - Deprecated + */ + export function isRegExp(object: unknown): object is RegExp; + /** + * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isDate(new Date()); + * // Returns: true + * util.isDate(Date()); + * // false (without 'new' returns a String) + * util.isDate({}); + * // Returns: false + * ``` + * @since v0.6.0 + * @deprecated Since v4.0.0 - Use {@link types.isDate} instead. + */ + export function isDate(object: unknown): object is Date; + /** + * Returns `true` if the given `object` is an `Error`. Otherwise, returns`false`. + * + * ```js + * const util = require('node:util'); + * + * util.isError(new Error()); + * // Returns: true + * util.isError(new TypeError()); + * // Returns: true + * util.isError({ name: 'Error', message: 'an error occurred' }); + * // Returns: false + * ``` + * + * This method relies on `Object.prototype.toString()` behavior. It is + * possible to obtain an incorrect result when the `object` argument manipulates`@@toStringTag`. + * + * ```js + * const util = require('node:util'); + * const obj = { name: 'Error', message: 'an error occurred' }; + * + * util.isError(obj); + * // Returns: false + * obj[Symbol.toStringTag] = 'Error'; + * util.isError(obj); + * // Returns: true + * ``` + * @since v0.6.0 + * @deprecated Since v4.0.0 - Use {@link types.isNativeError} instead. + */ + export function isError(object: unknown): object is Error; + /** + * Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and`extends` keywords to get language level inheritance support. Also note + * that the two styles are [semantically incompatible](https://github.com/nodejs/node/issues/4179). + * + * Inherit the prototype methods from one [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The + * prototype of `constructor` will be set to a new object created from`superConstructor`. + * + * This mainly adds some input validation on top of`Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`. + * As an additional convenience, `superConstructor` will be accessible + * through the `constructor.super_` property. + * + * ```js + * const util = require('node:util'); + * const EventEmitter = require('node:events'); + * + * function MyStream() { + * EventEmitter.call(this); + * } + * + * util.inherits(MyStream, EventEmitter); + * + * MyStream.prototype.write = function(data) { + * this.emit('data', data); + * }; + * + * const stream = new MyStream(); + * + * console.log(stream instanceof EventEmitter); // true + * console.log(MyStream.super_ === EventEmitter); // true + * + * stream.on('data', (data) => { + * console.log(`Received data: "${data}"`); + * }); + * stream.write('It works!'); // Received data: "It works!" + * ``` + * + * ES6 example using `class` and `extends`: + * + * ```js + * const EventEmitter = require('node:events'); + * + * class MyStream extends EventEmitter { + * write(data) { + * this.emit('data', data); + * } + * } + * + * const stream = new MyStream(); + * + * stream.on('data', (data) => { + * console.log(`Received data: "${data}"`); + * }); + * stream.write('With ES6'); + * ``` + * @since v0.3.0 + * @legacy Use ES2015 class syntax and `extends` keyword instead. + */ + export function inherits(constructor: unknown, superConstructor: unknown): void; + export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void; + export interface DebugLogger extends DebugLoggerFunction { + enabled: boolean; + } + /** + * The `util.debuglog()` method is used to create a function that conditionally + * writes debug messages to `stderr` based on the existence of the `NODE_DEBUG`environment variable. If the `section` name appears within the value of that + * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op. + * + * ```js + * const util = require('node:util'); + * const debuglog = util.debuglog('foo'); + * + * debuglog('hello from foo [%d]', 123); + * ``` + * + * If this program is run with `NODE_DEBUG=foo` in the environment, then + * it will output something like: + * + * ```console + * FOO 3245: hello from foo [123] + * ``` + * + * where `3245` is the process id. If it is not run with that + * environment variable set, then it will not print anything. + * + * The `section` supports wildcard also: + * + * ```js + * const util = require('node:util'); + * const debuglog = util.debuglog('foo-bar'); + * + * debuglog('hi there, it\'s foo-bar [%d]', 2333); + * ``` + * + * if it is run with `NODE_DEBUG=foo*` in the environment, then it will output + * something like: + * + * ```console + * FOO-BAR 3257: hi there, it's foo-bar [2333] + * ``` + * + * Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`environment variable: `NODE_DEBUG=fs,net,tls`. + * + * The optional `callback` argument can be used to replace the logging function + * with a different function that doesn't have any initialization or + * unnecessary wrapping. + * + * ```js + * const util = require('node:util'); + * let debuglog = util.debuglog('internals', (debug) => { + * // Replace with a logging function that optimizes out + * // testing if the section is enabled + * debuglog = debug; + * }); + * ``` + * @since v0.11.3 + * @param section A string identifying the portion of the application for which the `debuglog` function is being created. + * @param callback A callback invoked the first time the logging function is called with a function argument that is a more optimized logging function. + * @return The logging function + */ + export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger; + export const debug: typeof debuglog; + /** + * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isBoolean(1); + * // Returns: false + * util.isBoolean(0); + * // Returns: false + * util.isBoolean(false); + * // Returns: true + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `typeof value === 'boolean'` instead. + */ + export function isBoolean(object: unknown): object is boolean; + /** + * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isBuffer({ length: 0 }); + * // Returns: false + * util.isBuffer([]); + * // Returns: false + * util.isBuffer(Buffer.from('hello world')); + * // Returns: true + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `isBuffer` instead. + */ + export function isBuffer(object: unknown): object is Buffer; + /** + * Returns `true` if the given `object` is a `Function`. Otherwise, returns`false`. + * + * ```js + * const util = require('node:util'); + * + * function Foo() {} + * const Bar = () => {}; + * + * util.isFunction({}); + * // Returns: false + * util.isFunction(Foo); + * // Returns: true + * util.isFunction(Bar); + * // Returns: true + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `typeof value === 'function'` instead. + */ + export function isFunction(object: unknown): boolean; + /** + * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`. + * + * ```js + * const util = require('node:util'); + * + * util.isNull(0); + * // Returns: false + * util.isNull(undefined); + * // Returns: false + * util.isNull(null); + * // Returns: true + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `value === null` instead. + */ + export function isNull(object: unknown): object is null; + /** + * Returns `true` if the given `object` is `null` or `undefined`. Otherwise, + * returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isNullOrUndefined(0); + * // Returns: false + * util.isNullOrUndefined(undefined); + * // Returns: true + * util.isNullOrUndefined(null); + * // Returns: true + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `value === undefined || value === null` instead. + */ + export function isNullOrUndefined(object: unknown): object is null | undefined; + /** + * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isNumber(false); + * // Returns: false + * util.isNumber(Infinity); + * // Returns: true + * util.isNumber(0); + * // Returns: true + * util.isNumber(NaN); + * // Returns: true + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `typeof value === 'number'` instead. + */ + export function isNumber(object: unknown): object is number; + /** + * Returns `true` if the given `object` is strictly an `Object`**and** not a`Function` (even though functions are objects in JavaScript). + * Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isObject(5); + * // Returns: false + * util.isObject(null); + * // Returns: false + * util.isObject({}); + * // Returns: true + * util.isObject(() => {}); + * // Returns: false + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `value !== null && typeof value === 'object'` instead. + */ + export function isObject(object: unknown): boolean; + /** + * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`. + * + * ```js + * const util = require('node:util'); + * + * util.isPrimitive(5); + * // Returns: true + * util.isPrimitive('foo'); + * // Returns: true + * util.isPrimitive(false); + * // Returns: true + * util.isPrimitive(null); + * // Returns: true + * util.isPrimitive(undefined); + * // Returns: true + * util.isPrimitive({}); + * // Returns: false + * util.isPrimitive(() => {}); + * // Returns: false + * util.isPrimitive(/^$/); + * // Returns: false + * util.isPrimitive(new Date()); + * // Returns: false + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead. + */ + export function isPrimitive(object: unknown): boolean; + /** + * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isString(''); + * // Returns: true + * util.isString('foo'); + * // Returns: true + * util.isString(String('foo')); + * // Returns: true + * util.isString(5); + * // Returns: false + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `typeof value === 'string'` instead. + */ + export function isString(object: unknown): object is string; + /** + * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * util.isSymbol(5); + * // Returns: false + * util.isSymbol('foo'); + * // Returns: false + * util.isSymbol(Symbol('foo')); + * // Returns: true + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `typeof value === 'symbol'` instead. + */ + export function isSymbol(object: unknown): object is symbol; + /** + * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`. + * + * ```js + * const util = require('node:util'); + * + * const foo = undefined; + * util.isUndefined(5); + * // Returns: false + * util.isUndefined(foo); + * // Returns: true + * util.isUndefined(null); + * // Returns: false + * ``` + * @since v0.11.5 + * @deprecated Since v4.0.0 - Use `value === undefined` instead. + */ + export function isUndefined(object: unknown): object is undefined; + /** + * The `util.deprecate()` method wraps `fn` (which may be a function or class) in + * such a way that it is marked as deprecated. + * + * ```js + * const util = require('node:util'); + * + * exports.obsoleteFunction = util.deprecate(() => { + * // Do something here. + * }, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.'); + * ``` + * + * When called, `util.deprecate()` will return a function that will emit a`DeprecationWarning` using the `'warning'` event. The warning will + * be emitted and printed to `stderr` the first time the returned function is + * called. After the warning is emitted, the wrapped function is called without + * emitting a warning. + * + * If the same optional `code` is supplied in multiple calls to `util.deprecate()`, + * the warning will be emitted only once for that `code`. + * + * ```js + * const util = require('node:util'); + * + * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001'); + * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001'); + * fn1(); // Emits a deprecation warning with code DEP0001 + * fn2(); // Does not emit a deprecation warning because it has the same code + * ``` + * + * If either the `--no-deprecation` or `--no-warnings` command-line flags are + * used, or if the `process.noDeprecation` property is set to `true`_prior_ to + * the first deprecation warning, the `util.deprecate()` method does nothing. + * + * If the `--trace-deprecation` or `--trace-warnings` command-line flags are set, + * or the `process.traceDeprecation` property is set to `true`, a warning and a + * stack trace are printed to `stderr` the first time the deprecated function is + * called. + * + * If the `--throw-deprecation` command-line flag is set, or the`process.throwDeprecation` property is set to `true`, then an exception will be + * thrown when the deprecated function is called. + * + * The `--throw-deprecation` command-line flag and `process.throwDeprecation`property take precedence over `--trace-deprecation` and`process.traceDeprecation`. + * @since v0.8.0 + * @param fn The function that is being deprecated. + * @param msg A warning message to display when the deprecated function is invoked. + * @param code A deprecation code. See the `list of deprecated APIs` for a list of codes. + * @return The deprecated function wrapped to emit a warning. + */ + export function deprecate(fn: T, msg: string, code?: string): T; + /** + * Returns `true` if there is deep strict equality between `val1` and `val2`. + * Otherwise, returns `false`. + * + * See `assert.deepStrictEqual()` for more information about deep strict + * equality. + * @since v9.0.0 + */ + export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean; + /** + * Returns `str` with any ANSI escape codes removed. + * + * ```js + * console.log(util.stripVTControlCharacters('\u001B[4mvalue\u001B[0m')); + * // Prints "value" + * ``` + * @since v16.11.0 + */ + export function stripVTControlCharacters(str: string): string; + /** + * Takes an `async` function (or a function that returns a `Promise`) and returns a + * function following the error-first callback style, i.e. taking + * an `(err, value) => ...` callback as the last argument. In the callback, the + * first argument will be the rejection reason (or `null` if the `Promise`resolved), and the second argument will be the resolved value. + * + * ```js + * const util = require('node:util'); + * + * async function fn() { + * return 'hello world'; + * } + * const callbackFunction = util.callbackify(fn); + * + * callbackFunction((err, ret) => { + * if (err) throw err; + * console.log(ret); + * }); + * ``` + * + * Will print: + * + * ```text + * hello world + * ``` + * + * The callback is executed asynchronously, and will have a limited stack trace. + * If the callback throws, the process will emit an `'uncaughtException'` event, and if not handled will exit. + * + * Since `null` has a special meaning as the first argument to a callback, if a + * wrapped function rejects a `Promise` with a falsy value as a reason, the value + * is wrapped in an `Error` with the original value stored in a field named`reason`. + * + * ```js + * function fn() { + * return Promise.reject(null); + * } + * const callbackFunction = util.callbackify(fn); + * + * callbackFunction((err, ret) => { + * // When the Promise was rejected with `null` it is wrapped with an Error and + * // the original value is stored in `reason`. + * err && Object.hasOwn(err, 'reason') && err.reason === null; // true + * }); + * ``` + * @since v8.2.0 + * @param fn An `async` function + * @return a callback style function + */ + export function callbackify(fn: () => Promise): (callback: (err: NodeJS.ErrnoException) => void) => void; + export function callbackify( + fn: () => Promise, + ): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; + export function callbackify( + fn: (arg1: T1) => Promise, + ): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void; + export function callbackify( + fn: (arg1: T1) => Promise, + ): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2) => Promise, + ): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2) => Promise, + ): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2, arg3: T3) => Promise, + ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2, arg3: T3) => Promise, + ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise, + ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise, + ): ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + callback: (err: NodeJS.ErrnoException | null, result: TResult) => void, + ) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise, + ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise, + ): ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + callback: (err: NodeJS.ErrnoException | null, result: TResult) => void, + ) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise, + ): ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + callback: (err: NodeJS.ErrnoException) => void, + ) => void; + export function callbackify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise, + ): ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + callback: (err: NodeJS.ErrnoException | null, result: TResult) => void, + ) => void; + export interface CustomPromisifyLegacy extends Function { + __promisify__: TCustom; + } + export interface CustomPromisifySymbol extends Function { + [promisify.custom]: TCustom; + } + export type CustomPromisify = + | CustomPromisifySymbol + | CustomPromisifyLegacy; + /** + * Takes a function following the common error-first callback style, i.e. taking + * an `(err, value) => ...` callback as the last argument, and returns a version + * that returns promises. + * + * ```js + * const util = require('node:util'); + * const fs = require('node:fs'); + * + * const stat = util.promisify(fs.stat); + * stat('.').then((stats) => { + * // Do something with `stats` + * }).catch((error) => { + * // Handle the error. + * }); + * ``` + * + * Or, equivalently using `async function`s: + * + * ```js + * const util = require('node:util'); + * const fs = require('node:fs'); + * + * const stat = util.promisify(fs.stat); + * + * async function callStat() { + * const stats = await stat('.'); + * console.log(`This directory is owned by ${stats.uid}`); + * } + * + * callStat(); + * ``` + * + * If there is an `original[util.promisify.custom]` property present, `promisify`will return its value, see `Custom promisified functions`. + * + * `promisify()` assumes that `original` is a function taking a callback as its + * final argument in all cases. If `original` is not a function, `promisify()`will throw an error. If `original` is a function but its last argument is not + * an error-first callback, it will still be passed an error-first + * callback as its last argument. + * + * Using `promisify()` on class methods or other methods that use `this` may not + * work as expected unless handled specially: + * + * ```js + * const util = require('node:util'); + * + * class Foo { + * constructor() { + * this.a = 42; + * } + * + * bar(callback) { + * callback(null, this.a); + * } + * } + * + * const foo = new Foo(); + * + * const naiveBar = util.promisify(foo.bar); + * // TypeError: Cannot read property 'a' of undefined + * // naiveBar().then(a => console.log(a)); + * + * naiveBar.call(foo).then((a) => console.log(a)); // '42' + * + * const bindBar = naiveBar.bind(foo); + * bindBar().then((a) => console.log(a)); // '42' + * ``` + * @since v8.0.0 + */ + export function promisify(fn: CustomPromisify): TCustom; + export function promisify( + fn: (callback: (err: any, result: TResult) => void) => void, + ): () => Promise; + export function promisify(fn: (callback: (err?: any) => void) => void): () => Promise; + export function promisify( + fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void, + ): (arg1: T1) => Promise; + export function promisify(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise; + export function promisify( + fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void, + ): (arg1: T1, arg2: T2) => Promise; + export function promisify( + fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void, + ): (arg1: T1, arg2: T2) => Promise; + export function promisify( + fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void, + ): (arg1: T1, arg2: T2, arg3: T3) => Promise; + export function promisify( + fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void, + ): (arg1: T1, arg2: T2, arg3: T3) => Promise; + export function promisify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void, + ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise; + export function promisify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void, + ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise; + export function promisify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void, + ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise; + export function promisify( + fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void, + ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise; + export function promisify(fn: Function): Function; + export namespace promisify { + /** + * That can be used to declare custom promisified variants of functions. + */ + const custom: unique symbol; + } + /** + * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API. + * + * ```js + * const decoder = new TextDecoder(); + * const u8arr = new Uint8Array([72, 101, 108, 108, 111]); + * console.log(decoder.decode(u8arr)); // Hello + * ``` + * @since v8.3.0 + */ + export class TextDecoder { + /** + * The encoding supported by the `TextDecoder` instance. + */ + readonly encoding: string; + /** + * The value will be `true` if decoding errors result in a `TypeError` being + * thrown. + */ + readonly fatal: boolean; + /** + * The value will be `true` if the decoding result will include the byte order + * mark. + */ + readonly ignoreBOM: boolean; + constructor( + encoding?: string, + options?: { + fatal?: boolean | undefined; + ignoreBOM?: boolean | undefined; + }, + ); + /** + * Decodes the `input` and returns a string. If `options.stream` is `true`, any + * incomplete byte sequences occurring at the end of the `input` are buffered + * internally and emitted after the next call to `textDecoder.decode()`. + * + * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a`TypeError` being thrown. + * @param input An `ArrayBuffer`, `DataView`, or `TypedArray` instance containing the encoded data. + */ + decode( + input?: NodeJS.ArrayBufferView | ArrayBuffer | null, + options?: { + stream?: boolean | undefined; + }, + ): string; + } + export interface EncodeIntoResult { + /** + * The read Unicode code units of input. + */ + read: number; + /** + * The written UTF-8 bytes of output. + */ + written: number; + } + export { types }; + + //// TextEncoder/Decoder + /** + * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All + * instances of `TextEncoder` only support UTF-8 encoding. + * + * ```js + * const encoder = new TextEncoder(); + * const uint8array = encoder.encode('this is some data'); + * ``` + * + * The `TextEncoder` class is also available on the global object. + * @since v8.3.0 + */ + export class TextEncoder { + /** + * The encoding supported by the `TextEncoder` instance. Always set to `'utf-8'`. + */ + readonly encoding: string; + /** + * UTF-8 encodes the `input` string and returns a `Uint8Array` containing the + * encoded bytes. + * @param [input='an empty string'] The text to encode. + */ + encode(input?: string): Uint8Array; + /** + * UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object + * containing the read Unicode code units and written UTF-8 bytes. + * + * ```js + * const encoder = new TextEncoder(); + * const src = 'this is some data'; + * const dest = new Uint8Array(10); + * const { read, written } = encoder.encodeInto(src, dest); + * ``` + * @param src The text to encode. + * @param dest The array to hold the encode result. + */ + encodeInto(src: string, dest: Uint8Array): EncodeIntoResult; + } + import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from "util"; + global { + /** + * `TextDecoder` class is a global reference for `require('util').TextDecoder` + * https://nodejs.org/api/globals.html#textdecoder + * @since v11.0.0 + */ + var TextDecoder: typeof globalThis extends { + onmessage: any; + TextDecoder: infer TextDecoder; + } ? TextDecoder + : typeof _TextDecoder; + /** + * `TextEncoder` class is a global reference for `require('util').TextEncoder` + * https://nodejs.org/api/globals.html#textencoder + * @since v11.0.0 + */ + var TextEncoder: typeof globalThis extends { + onmessage: any; + TextEncoder: infer TextEncoder; + } ? TextEncoder + : typeof _TextEncoder; + } + + //// parseArgs + /** + * Provides a higher level API for command-line argument parsing than interacting + * with `process.argv` directly. Takes a specification for the expected arguments + * and returns a structured object with the parsed options and positionals. + * + * ```js + * import { parseArgs } from 'node:util'; + * const args = ['-f', '--bar', 'b']; + * const options = { + * foo: { + * type: 'boolean', + * short: 'f', + * }, + * bar: { + * type: 'string', + * }, + * }; + * const { + * values, + * positionals, + * } = parseArgs({ args, options }); + * console.log(values, positionals); + * // Prints: [Object: null prototype] { foo: true, bar: 'b' } [] + * ``` + * @since v18.3.0, v16.17.0 + * @param config Used to provide arguments for parsing and to configure the parser. `config` supports the following properties: + * @return The parsed command line arguments: + */ + export function parseArgs(config?: T): ParsedResults; + interface ParseArgsOptionConfig { + /** + * Type of argument. + */ + type: "string" | "boolean"; + /** + * Whether this option can be provided multiple times. + * If `true`, all values will be collected in an array. + * If `false`, values for the option are last-wins. + * @default false. + */ + multiple?: boolean | undefined; + /** + * A single character alias for the option. + */ + short?: string | undefined; + /** + * The default option value when it is not set by args. + * It must be of the same type as the the `type` property. + * When `multiple` is `true`, it must be an array. + * @since v18.11.0 + */ + default?: string | boolean | string[] | boolean[] | undefined; + } + interface ParseArgsOptionsConfig { + [longOption: string]: ParseArgsOptionConfig; + } + export interface ParseArgsConfig { + /** + * Array of argument strings. + */ + args?: string[] | undefined; + /** + * Used to describe arguments known to the parser. + */ + options?: ParseArgsOptionsConfig | undefined; + /** + * Should an error be thrown when unknown arguments are encountered, + * or when arguments are passed that do not match the `type` configured in `options`. + * @default true + */ + strict?: boolean | undefined; + /** + * Whether this command accepts positional arguments. + */ + allowPositionals?: boolean | undefined; + /** + * Return the parsed tokens. This is useful for extending the built-in behavior, + * from adding additional checks through to reprocessing the tokens in different ways. + * @default false + */ + tokens?: boolean | undefined; + } + /* + IfDefaultsTrue and IfDefaultsFalse are helpers to handle default values for missing boolean properties. + TypeScript does not have exact types for objects: https://github.com/microsoft/TypeScript/issues/12936 + This means it is impossible to distinguish between "field X is definitely not present" and "field X may or may not be present". + But we expect users to generally provide their config inline or `as const`, which means TS will always know whether a given field is present. + So this helper treats "not definitely present" (i.e., not `extends boolean`) as being "definitely not present", i.e. it should have its default value. + This is technically incorrect but is a much nicer UX for the common case. + The IfDefaultsTrue version is for things which default to true; the IfDefaultsFalse version is for things which default to false. + */ + type IfDefaultsTrue = T extends true ? IfTrue + : T extends false ? IfFalse + : IfTrue; + + // we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false` + type IfDefaultsFalse = T extends false ? IfFalse + : T extends true ? IfTrue + : IfFalse; + + type ExtractOptionValue = IfDefaultsTrue< + T["strict"], + O["type"] extends "string" ? string : O["type"] extends "boolean" ? boolean : string | boolean, + string | boolean + >; + + type ParsedValues = + & IfDefaultsTrue + & (T["options"] extends ParseArgsOptionsConfig ? { + -readonly [LongOption in keyof T["options"]]: IfDefaultsFalse< + T["options"][LongOption]["multiple"], + undefined | Array>, + undefined | ExtractOptionValue + >; + } + : {}); + + type ParsedPositionals = IfDefaultsTrue< + T["strict"], + IfDefaultsFalse, + IfDefaultsTrue + >; + + type PreciseTokenForOptions< + K extends string, + O extends ParseArgsOptionConfig, + > = O["type"] extends "string" ? { + kind: "option"; + index: number; + name: K; + rawName: string; + value: string; + inlineValue: boolean; + } + : O["type"] extends "boolean" ? { + kind: "option"; + index: number; + name: K; + rawName: string; + value: undefined; + inlineValue: undefined; + } + : OptionToken & { name: K }; + + type TokenForOptions< + T extends ParseArgsConfig, + K extends keyof T["options"] = keyof T["options"], + > = K extends unknown + ? T["options"] extends ParseArgsOptionsConfig ? PreciseTokenForOptions + : OptionToken + : never; + + type ParsedOptionToken = IfDefaultsTrue, OptionToken>; + + type ParsedPositionalToken = IfDefaultsTrue< + T["strict"], + IfDefaultsFalse, + IfDefaultsTrue + >; + + type ParsedTokens = Array< + ParsedOptionToken | ParsedPositionalToken | { kind: "option-terminator"; index: number } + >; + + type PreciseParsedResults = IfDefaultsFalse< + T["tokens"], + { + values: ParsedValues; + positionals: ParsedPositionals; + tokens: ParsedTokens; + }, + { + values: ParsedValues; + positionals: ParsedPositionals; + } + >; + + type OptionToken = + | { kind: "option"; index: number; name: string; rawName: string; value: string; inlineValue: boolean } + | { + kind: "option"; + index: number; + name: string; + rawName: string; + value: undefined; + inlineValue: undefined; + }; + + type Token = + | OptionToken + | { kind: "positional"; index: number; value: string } + | { kind: "option-terminator"; index: number }; + + // If ParseArgsConfig extends T, then the user passed config constructed elsewhere. + // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above. + type ParsedResults = ParseArgsConfig extends T ? { + values: { + [longOption: string]: undefined | string | boolean | Array; + }; + positionals: string[]; + tokens?: Token[]; + } + : PreciseParsedResults; + + /** + * An implementation of [the MIMEType class](https://bmeck.github.io/node-proposal-mime-api/). + * + * In accordance with browser conventions, all properties of `MIMEType` objects + * are implemented as getters and setters on the class prototype, rather than as + * data properties on the object itself. + * + * A MIME string is a structured string containing multiple meaningful + * components. When parsed, a `MIMEType` object is returned containing + * properties for each of these components. + * @since v19.1.0, v18.13.0 + * @experimental + */ + export class MIMEType { + /** + * Creates a new MIMEType object by parsing the input. + * + * A `TypeError` will be thrown if the `input` is not a valid MIME. + * Note that an effort will be made to coerce the given values into strings. + * @param input The input MIME to parse. + */ + constructor(input: string | { toString: () => string }); + + /** + * Gets and sets the type portion of the MIME. + * + * ```js + * import { MIMEType } from 'node:util'; + * + * const myMIME = new MIMEType('text/javascript'); + * console.log(myMIME.type); + * // Prints: text + * myMIME.type = 'application'; + * console.log(myMIME.type); + * // Prints: application + * console.log(String(myMIME)); + * // Prints: application/javascript + * ``` + */ + type: string; + /** + * Gets and sets the subtype portion of the MIME. + * + * ```js + * import { MIMEType } from 'node:util'; + * + * const myMIME = new MIMEType('text/ecmascript'); + * console.log(myMIME.subtype); + * // Prints: ecmascript + * myMIME.subtype = 'javascript'; + * console.log(myMIME.subtype); + * // Prints: javascript + * console.log(String(myMIME)); + * // Prints: text/javascript + * ``` + */ + subtype: string; + /** + * Gets the essence of the MIME. This property is read only. + * Use `mime.type` or `mime.subtype` to alter the MIME. + * + * ```js + * import { MIMEType } from 'node:util'; + * + * const myMIME = new MIMEType('text/javascript;key=value'); + * console.log(myMIME.essence); + * // Prints: text/javascript + * myMIME.type = 'application'; + * console.log(myMIME.essence); + * // Prints: application/javascript + * console.log(String(myMIME)); + * // Prints: application/javascript;key=value + * ``` + */ + readonly essence: string; + /** + * Gets the `MIMEParams` object representing the + * parameters of the MIME. This property is read-only. See `MIMEParams` documentation for details. + */ + readonly params: MIMEParams; + /** + * The `toString()` method on the `MIMEType` object returns the serialized MIME. + * + * Because of the need for standard compliance, this method does not allow users + * to customize the serialization process of the MIME. + */ + toString(): string; + } + /** + * The `MIMEParams` API provides read and write access to the parameters of a`MIMEType`. + * @since v19.1.0, v18.13.0 + */ + export class MIMEParams { + /** + * Remove all name-value pairs whose name is `name`. + */ + delete(name: string): void; + /** + * Returns an iterator over each of the name-value pairs in the parameters. + * Each item of the iterator is a JavaScript `Array`. The first item of the array + * is the `name`, the second item of the array is the `value`. + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns the value of the first name-value pair whose name is `name`. If there + * are no such pairs, `null` is returned. + * @return or `null` if there is no name-value pair with the given `name`. + */ + get(name: string): string | null; + /** + * Returns `true` if there is at least one name-value pair whose name is `name`. + */ + has(name: string): boolean; + /** + * Returns an iterator over the names of each name-value pair. + * + * ```js + * import { MIMEType } from 'node:util'; + * + * const { params } = new MIMEType('text/plain;foo=0;bar=1'); + * for (const name of params.keys()) { + * console.log(name); + * } + * // Prints: + * // foo + * // bar + * ``` + */ + keys(): IterableIterator; + /** + * Sets the value in the `MIMEParams` object associated with `name` to`value`. If there are any pre-existing name-value pairs whose names are `name`, + * set the first such pair's value to `value`. + * + * ```js + * import { MIMEType } from 'node:util'; + * + * const { params } = new MIMEType('text/plain;foo=0;bar=1'); + * params.set('foo', 'def'); + * params.set('baz', 'xyz'); + * console.log(params.toString()); + * // Prints: foo=def;bar=1;baz=xyz + * ``` + */ + set(name: string, value: string): void; + /** + * Returns an iterator over the values of each name-value pair. + */ + values(): IterableIterator; + /** + * Returns an iterator over each of the name-value pairs in the parameters. + */ + [Symbol.iterator]: typeof MIMEParams.prototype.entries; + } +} +declare module "util/types" { + export * from "util/types"; +} +declare module "util/types" { + import { KeyObject, webcrypto } from "node:crypto"; + /** + * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or + * [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance. + * + * See also `util.types.isArrayBuffer()` and `util.types.isSharedArrayBuffer()`. + * + * ```js + * util.types.isAnyArrayBuffer(new ArrayBuffer()); // Returns true + * util.types.isAnyArrayBuffer(new SharedArrayBuffer()); // Returns true + * ``` + * @since v10.0.0 + */ + function isAnyArrayBuffer(object: unknown): object is ArrayBufferLike; + /** + * Returns `true` if the value is an `arguments` object. + * + * ```js + * function foo() { + * util.types.isArgumentsObject(arguments); // Returns true + * } + * ``` + * @since v10.0.0 + */ + function isArgumentsObject(object: unknown): object is IArguments; + /** + * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instance. + * This does _not_ include [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instances. Usually, it is + * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that. + * + * ```js + * util.types.isArrayBuffer(new ArrayBuffer()); // Returns true + * util.types.isArrayBuffer(new SharedArrayBuffer()); // Returns false + * ``` + * @since v10.0.0 + */ + function isArrayBuffer(object: unknown): object is ArrayBuffer; + /** + * Returns `true` if the value is an instance of one of the [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) views, such as typed + * array objects or [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView). Equivalent to + * [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView). + * + * ```js + * util.types.isArrayBufferView(new Int8Array()); // true + * util.types.isArrayBufferView(Buffer.from('hello world')); // true + * util.types.isArrayBufferView(new DataView(new ArrayBuffer(16))); // true + * util.types.isArrayBufferView(new ArrayBuffer()); // false + * ``` + * @since v10.0.0 + */ + function isArrayBufferView(object: unknown): object is NodeJS.ArrayBufferView; + /** + * Returns `true` if the value is an [async function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function). + * This only reports back what the JavaScript engine is seeing; + * in particular, the return value may not match the original source code if + * a transpilation tool was used. + * + * ```js + * util.types.isAsyncFunction(function foo() {}); // Returns false + * util.types.isAsyncFunction(async function foo() {}); // Returns true + * ``` + * @since v10.0.0 + */ + function isAsyncFunction(object: unknown): boolean; + /** + * Returns `true` if the value is a `BigInt64Array` instance. + * + * ```js + * util.types.isBigInt64Array(new BigInt64Array()); // Returns true + * util.types.isBigInt64Array(new BigUint64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isBigInt64Array(value: unknown): value is BigInt64Array; + /** + * Returns `true` if the value is a `BigUint64Array` instance. + * + * ```js + * util.types.isBigUint64Array(new BigInt64Array()); // Returns false + * util.types.isBigUint64Array(new BigUint64Array()); // Returns true + * ``` + * @since v10.0.0 + */ + function isBigUint64Array(value: unknown): value is BigUint64Array; + /** + * Returns `true` if the value is a boolean object, e.g. created + * by `new Boolean()`. + * + * ```js + * util.types.isBooleanObject(false); // Returns false + * util.types.isBooleanObject(true); // Returns false + * util.types.isBooleanObject(new Boolean(false)); // Returns true + * util.types.isBooleanObject(new Boolean(true)); // Returns true + * util.types.isBooleanObject(Boolean(false)); // Returns false + * util.types.isBooleanObject(Boolean(true)); // Returns false + * ``` + * @since v10.0.0 + */ + function isBooleanObject(object: unknown): object is Boolean; + /** + * Returns `true` if the value is any boxed primitive object, e.g. created + * by `new Boolean()`, `new String()` or `Object(Symbol())`. + * + * For example: + * + * ```js + * util.types.isBoxedPrimitive(false); // Returns false + * util.types.isBoxedPrimitive(new Boolean(false)); // Returns true + * util.types.isBoxedPrimitive(Symbol('foo')); // Returns false + * util.types.isBoxedPrimitive(Object(Symbol('foo'))); // Returns true + * util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true + * ``` + * @since v10.11.0 + */ + function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol; + /** + * Returns `true` if the value is a built-in [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) instance. + * + * ```js + * const ab = new ArrayBuffer(20); + * util.types.isDataView(new DataView(ab)); // Returns true + * util.types.isDataView(new Float64Array()); // Returns false + * ``` + * + * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView). + * @since v10.0.0 + */ + function isDataView(object: unknown): object is DataView; + /** + * Returns `true` if the value is a built-in [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) instance. + * + * ```js + * util.types.isDate(new Date()); // Returns true + * ``` + * @since v10.0.0 + */ + function isDate(object: unknown): object is Date; + /** + * Returns `true` if the value is a native `External` value. + * + * A native `External` value is a special type of object that contains a + * raw C++ pointer (`void*`) for access from native code, and has no other + * properties. Such objects are created either by Node.js internals or native + * addons. In JavaScript, they are [frozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) objects with a`null` prototype. + * + * ```c + * #include + * #include + * napi_value result; + * static napi_value MyNapi(napi_env env, napi_callback_info info) { + * int* raw = (int*) malloc(1024); + * napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &result); + * if (status != napi_ok) { + * napi_throw_error(env, NULL, "napi_create_external failed"); + * return NULL; + * } + * return result; + * } + * ... + * DECLARE_NAPI_PROPERTY("myNapi", MyNapi) + * ... + * ``` + * + * ```js + * const native = require('napi_addon.node'); + * const data = native.myNapi(); + * util.types.isExternal(data); // returns true + * util.types.isExternal(0); // returns false + * util.types.isExternal(new String('foo')); // returns false + * ``` + * + * For further information on `napi_create_external`, refer to `napi_create_external()`. + * @since v10.0.0 + */ + function isExternal(object: unknown): boolean; + /** + * Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance. + * + * ```js + * util.types.isFloat32Array(new ArrayBuffer()); // Returns false + * util.types.isFloat32Array(new Float32Array()); // Returns true + * util.types.isFloat32Array(new Float64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isFloat32Array(object: unknown): object is Float32Array; + /** + * Returns `true` if the value is a built-in [`Float64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array) instance. + * + * ```js + * util.types.isFloat64Array(new ArrayBuffer()); // Returns false + * util.types.isFloat64Array(new Uint8Array()); // Returns false + * util.types.isFloat64Array(new Float64Array()); // Returns true + * ``` + * @since v10.0.0 + */ + function isFloat64Array(object: unknown): object is Float64Array; + /** + * Returns `true` if the value is a generator function. + * This only reports back what the JavaScript engine is seeing; + * in particular, the return value may not match the original source code if + * a transpilation tool was used. + * + * ```js + * util.types.isGeneratorFunction(function foo() {}); // Returns false + * util.types.isGeneratorFunction(function* foo() {}); // Returns true + * ``` + * @since v10.0.0 + */ + function isGeneratorFunction(object: unknown): object is GeneratorFunction; + /** + * Returns `true` if the value is a generator object as returned from a + * built-in generator function. + * This only reports back what the JavaScript engine is seeing; + * in particular, the return value may not match the original source code if + * a transpilation tool was used. + * + * ```js + * function* foo() {} + * const generator = foo(); + * util.types.isGeneratorObject(generator); // Returns true + * ``` + * @since v10.0.0 + */ + function isGeneratorObject(object: unknown): object is Generator; + /** + * Returns `true` if the value is a built-in [`Int8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array) instance. + * + * ```js + * util.types.isInt8Array(new ArrayBuffer()); // Returns false + * util.types.isInt8Array(new Int8Array()); // Returns true + * util.types.isInt8Array(new Float64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isInt8Array(object: unknown): object is Int8Array; + /** + * Returns `true` if the value is a built-in [`Int16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array) instance. + * + * ```js + * util.types.isInt16Array(new ArrayBuffer()); // Returns false + * util.types.isInt16Array(new Int16Array()); // Returns true + * util.types.isInt16Array(new Float64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isInt16Array(object: unknown): object is Int16Array; + /** + * Returns `true` if the value is a built-in [`Int32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array) instance. + * + * ```js + * util.types.isInt32Array(new ArrayBuffer()); // Returns false + * util.types.isInt32Array(new Int32Array()); // Returns true + * util.types.isInt32Array(new Float64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isInt32Array(object: unknown): object is Int32Array; + /** + * Returns `true` if the value is a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance. + * + * ```js + * util.types.isMap(new Map()); // Returns true + * ``` + * @since v10.0.0 + */ + function isMap( + object: T | {}, + ): object is T extends ReadonlyMap ? (unknown extends T ? never : ReadonlyMap) + : Map; + /** + * Returns `true` if the value is an iterator returned for a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance. + * + * ```js + * const map = new Map(); + * util.types.isMapIterator(map.keys()); // Returns true + * util.types.isMapIterator(map.values()); // Returns true + * util.types.isMapIterator(map.entries()); // Returns true + * util.types.isMapIterator(map[Symbol.iterator]()); // Returns true + * ``` + * @since v10.0.0 + */ + function isMapIterator(object: unknown): boolean; + /** + * Returns `true` if the value is an instance of a [Module Namespace Object](https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects). + * + * ```js + * import * as ns from './a.js'; + * + * util.types.isModuleNamespaceObject(ns); // Returns true + * ``` + * @since v10.0.0 + */ + function isModuleNamespaceObject(value: unknown): boolean; + /** + * Returns `true` if the value was returned by the constructor of a [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects). + * + * ```js + * console.log(util.types.isNativeError(new Error())); // true + * console.log(util.types.isNativeError(new TypeError())); // true + * console.log(util.types.isNativeError(new RangeError())); // true + * ``` + * + * Subclasses of the native error types are also native errors: + * + * ```js + * class MyError extends Error {} + * console.log(util.types.isNativeError(new MyError())); // true + * ``` + * + * A value being `instanceof` a native error class is not equivalent to `isNativeError()`returning `true` for that value. `isNativeError()` returns `true` for errors + * which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false`for these errors: + * + * ```js + * const vm = require('node:vm'); + * const context = vm.createContext({}); + * const myError = vm.runInContext('new Error()', context); + * console.log(util.types.isNativeError(myError)); // true + * console.log(myError instanceof Error); // false + * ``` + * + * Conversely, `isNativeError()` returns `false` for all objects which were not + * returned by the constructor of a native error. That includes values + * which are `instanceof` native errors: + * + * ```js + * const myError = { __proto__: Error.prototype }; + * console.log(util.types.isNativeError(myError)); // false + * console.log(myError instanceof Error); // true + * ``` + * @since v10.0.0 + */ + function isNativeError(object: unknown): object is Error; + /** + * Returns `true` if the value is a number object, e.g. created + * by `new Number()`. + * + * ```js + * util.types.isNumberObject(0); // Returns false + * util.types.isNumberObject(new Number(0)); // Returns true + * ``` + * @since v10.0.0 + */ + function isNumberObject(object: unknown): object is Number; + /** + * Returns `true` if the value is a built-in [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). + * + * ```js + * util.types.isPromise(Promise.resolve(42)); // Returns true + * ``` + * @since v10.0.0 + */ + function isPromise(object: unknown): object is Promise; + /** + * Returns `true` if the value is a [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) instance. + * + * ```js + * const target = {}; + * const proxy = new Proxy(target, {}); + * util.types.isProxy(target); // Returns false + * util.types.isProxy(proxy); // Returns true + * ``` + * @since v10.0.0 + */ + function isProxy(object: unknown): boolean; + /** + * Returns `true` if the value is a regular expression object. + * + * ```js + * util.types.isRegExp(/abc/); // Returns true + * util.types.isRegExp(new RegExp('abc')); // Returns true + * ``` + * @since v10.0.0 + */ + function isRegExp(object: unknown): object is RegExp; + /** + * Returns `true` if the value is a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance. + * + * ```js + * util.types.isSet(new Set()); // Returns true + * ``` + * @since v10.0.0 + */ + function isSet( + object: T | {}, + ): object is T extends ReadonlySet ? (unknown extends T ? never : ReadonlySet) : Set; + /** + * Returns `true` if the value is an iterator returned for a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance. + * + * ```js + * const set = new Set(); + * util.types.isSetIterator(set.keys()); // Returns true + * util.types.isSetIterator(set.values()); // Returns true + * util.types.isSetIterator(set.entries()); // Returns true + * util.types.isSetIterator(set[Symbol.iterator]()); // Returns true + * ``` + * @since v10.0.0 + */ + function isSetIterator(object: unknown): boolean; + /** + * Returns `true` if the value is a built-in [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance. + * This does _not_ include [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instances. Usually, it is + * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that. + * + * ```js + * util.types.isSharedArrayBuffer(new ArrayBuffer()); // Returns false + * util.types.isSharedArrayBuffer(new SharedArrayBuffer()); // Returns true + * ``` + * @since v10.0.0 + */ + function isSharedArrayBuffer(object: unknown): object is SharedArrayBuffer; + /** + * Returns `true` if the value is a string object, e.g. created + * by `new String()`. + * + * ```js + * util.types.isStringObject('foo'); // Returns false + * util.types.isStringObject(new String('foo')); // Returns true + * ``` + * @since v10.0.0 + */ + function isStringObject(object: unknown): object is String; + /** + * Returns `true` if the value is a symbol object, created + * by calling `Object()` on a `Symbol` primitive. + * + * ```js + * const symbol = Symbol('foo'); + * util.types.isSymbolObject(symbol); // Returns false + * util.types.isSymbolObject(Object(symbol)); // Returns true + * ``` + * @since v10.0.0 + */ + function isSymbolObject(object: unknown): object is Symbol; + /** + * Returns `true` if the value is a built-in [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) instance. + * + * ```js + * util.types.isTypedArray(new ArrayBuffer()); // Returns false + * util.types.isTypedArray(new Uint8Array()); // Returns true + * util.types.isTypedArray(new Float64Array()); // Returns true + * ``` + * + * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView). + * @since v10.0.0 + */ + function isTypedArray(object: unknown): object is NodeJS.TypedArray; + /** + * Returns `true` if the value is a built-in [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instance. + * + * ```js + * util.types.isUint8Array(new ArrayBuffer()); // Returns false + * util.types.isUint8Array(new Uint8Array()); // Returns true + * util.types.isUint8Array(new Float64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isUint8Array(object: unknown): object is Uint8Array; + /** + * Returns `true` if the value is a built-in [`Uint8ClampedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) instance. + * + * ```js + * util.types.isUint8ClampedArray(new ArrayBuffer()); // Returns false + * util.types.isUint8ClampedArray(new Uint8ClampedArray()); // Returns true + * util.types.isUint8ClampedArray(new Float64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isUint8ClampedArray(object: unknown): object is Uint8ClampedArray; + /** + * Returns `true` if the value is a built-in [`Uint16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array) instance. + * + * ```js + * util.types.isUint16Array(new ArrayBuffer()); // Returns false + * util.types.isUint16Array(new Uint16Array()); // Returns true + * util.types.isUint16Array(new Float64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isUint16Array(object: unknown): object is Uint16Array; + /** + * Returns `true` if the value is a built-in [`Uint32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) instance. + * + * ```js + * util.types.isUint32Array(new ArrayBuffer()); // Returns false + * util.types.isUint32Array(new Uint32Array()); // Returns true + * util.types.isUint32Array(new Float64Array()); // Returns false + * ``` + * @since v10.0.0 + */ + function isUint32Array(object: unknown): object is Uint32Array; + /** + * Returns `true` if the value is a built-in [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) instance. + * + * ```js + * util.types.isWeakMap(new WeakMap()); // Returns true + * ``` + * @since v10.0.0 + */ + function isWeakMap(object: unknown): object is WeakMap; + /** + * Returns `true` if the value is a built-in [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) instance. + * + * ```js + * util.types.isWeakSet(new WeakSet()); // Returns true + * ``` + * @since v10.0.0 + */ + function isWeakSet(object: unknown): object is WeakSet; + /** + * Returns `true` if `value` is a `KeyObject`, `false` otherwise. + * @since v16.2.0 + */ + function isKeyObject(object: unknown): object is KeyObject; + /** + * Returns `true` if `value` is a `CryptoKey`, `false` otherwise. + * @since v16.2.0 + */ + function isCryptoKey(object: unknown): object is webcrypto.CryptoKey; +} +declare module "node:util" { + export * from "util"; +} +declare module "node:util/types" { + export * from "util/types"; +} diff --git a/node_modules/@types/node/ts4.8/v8.d.ts b/node_modules/@types/node/ts4.8/v8.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6790e7621f31a39604697ac17c56a129674f6db1 --- /dev/null +++ b/node_modules/@types/node/ts4.8/v8.d.ts @@ -0,0 +1,635 @@ +/** + * The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using: + * + * ```js + * const v8 = require('node:v8'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/v8.js) + */ +declare module "v8" { + import { Readable } from "node:stream"; + interface HeapSpaceInfo { + space_name: string; + space_size: number; + space_used_size: number; + space_available_size: number; + physical_space_size: number; + } + // ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */ + type DoesZapCodeSpaceFlag = 0 | 1; + interface HeapInfo { + total_heap_size: number; + total_heap_size_executable: number; + total_physical_size: number; + total_available_size: number; + used_heap_size: number; + heap_size_limit: number; + malloced_memory: number; + peak_malloced_memory: number; + does_zap_garbage: DoesZapCodeSpaceFlag; + number_of_native_contexts: number; + number_of_detached_contexts: number; + total_global_handles_size: number; + used_global_handles_size: number; + external_memory: number; + } + interface HeapCodeStatistics { + code_and_metadata_size: number; + bytecode_and_metadata_size: number; + external_script_source_size: number; + } + /** + * Returns an integer representing a version tag derived from the V8 version, + * command-line flags, and detected CPU features. This is useful for determining + * whether a `vm.Script` `cachedData` buffer is compatible with this instance + * of V8. + * + * ```js + * console.log(v8.cachedDataVersionTag()); // 3947234607 + * // The value returned by v8.cachedDataVersionTag() is derived from the V8 + * // version, command-line flags, and detected CPU features. Test that the value + * // does indeed update when flags are toggled. + * v8.setFlagsFromString('--allow_natives_syntax'); + * console.log(v8.cachedDataVersionTag()); // 183726201 + * ``` + * @since v8.0.0 + */ + function cachedDataVersionTag(): number; + /** + * Returns an object with the following properties: + * + * `does_zap_garbage` is a 0/1 boolean, which signifies whether the`--zap_code_space` option is enabled or not. This makes V8 overwrite heap + * garbage with a bit pattern. The RSS footprint (resident set size) gets bigger + * because it continuously touches all heap pages and that makes them less likely + * to get swapped out by the operating system. + * + * `number_of_native_contexts` The value of native\_context is the number of the + * top-level contexts currently active. Increase of this number over time indicates + * a memory leak. + * + * `number_of_detached_contexts` The value of detached\_context is the number + * of contexts that were detached and not yet garbage collected. This number + * being non-zero indicates a potential memory leak. + * + * `total_global_handles_size` The value of total\_global\_handles\_size is the + * total memory size of V8 global handles. + * + * `used_global_handles_size` The value of used\_global\_handles\_size is the + * used memory size of V8 global handles. + * + * `external_memory` The value of external\_memory is the memory size of array + * buffers and external strings. + * + * ```js + * { + * total_heap_size: 7326976, + * total_heap_size_executable: 4194304, + * total_physical_size: 7326976, + * total_available_size: 1152656, + * used_heap_size: 3476208, + * heap_size_limit: 1535115264, + * malloced_memory: 16384, + * peak_malloced_memory: 1127496, + * does_zap_garbage: 0, + * number_of_native_contexts: 1, + * number_of_detached_contexts: 0, + * total_global_handles_size: 8192, + * used_global_handles_size: 3296, + * external_memory: 318824 + * } + * ``` + * @since v1.0.0 + */ + function getHeapStatistics(): HeapInfo; + /** + * Returns statistics about the V8 heap spaces, i.e. the segments which make up + * the V8 heap. Neither the ordering of heap spaces, nor the availability of a + * heap space can be guaranteed as the statistics are provided via the + * V8[`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the + * next. + * + * The value returned is an array of objects containing the following properties: + * + * ```json + * [ + * { + * "space_name": "new_space", + * "space_size": 2063872, + * "space_used_size": 951112, + * "space_available_size": 80824, + * "physical_space_size": 2063872 + * }, + * { + * "space_name": "old_space", + * "space_size": 3090560, + * "space_used_size": 2493792, + * "space_available_size": 0, + * "physical_space_size": 3090560 + * }, + * { + * "space_name": "code_space", + * "space_size": 1260160, + * "space_used_size": 644256, + * "space_available_size": 960, + * "physical_space_size": 1260160 + * }, + * { + * "space_name": "map_space", + * "space_size": 1094160, + * "space_used_size": 201608, + * "space_available_size": 0, + * "physical_space_size": 1094160 + * }, + * { + * "space_name": "large_object_space", + * "space_size": 0, + * "space_used_size": 0, + * "space_available_size": 1490980608, + * "physical_space_size": 0 + * } + * ] + * ``` + * @since v6.0.0 + */ + function getHeapSpaceStatistics(): HeapSpaceInfo[]; + /** + * The `v8.setFlagsFromString()` method can be used to programmatically set + * V8 command-line flags. This method should be used with care. Changing settings + * after the VM has started may result in unpredictable behavior, including + * crashes and data loss; or it may simply do nothing. + * + * The V8 options available for a version of Node.js may be determined by running`node --v8-options`. + * + * Usage: + * + * ```js + * // Print GC events to stdout for one minute. + * const v8 = require('node:v8'); + * v8.setFlagsFromString('--trace_gc'); + * setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3); + * ``` + * @since v1.0.0 + */ + function setFlagsFromString(flags: string): void; + /** + * Generates a snapshot of the current V8 heap and returns a Readable + * Stream that may be used to read the JSON serialized representation. + * This JSON stream format is intended to be used with tools such as + * Chrome DevTools. The JSON schema is undocumented and specific to the + * V8 engine. Therefore, the schema may change from one version of V8 to the next. + * + * Creating a heap snapshot requires memory about twice the size of the heap at + * the time the snapshot is created. This results in the risk of OOM killers + * terminating the process. + * + * Generating a snapshot is a synchronous operation which blocks the event loop + * for a duration depending on the heap size. + * + * ```js + * // Print heap snapshot to the console + * const v8 = require('node:v8'); + * const stream = v8.getHeapSnapshot(); + * stream.pipe(process.stdout); + * ``` + * @since v11.13.0 + * @return A Readable containing the V8 heap snapshot. + */ + function getHeapSnapshot(): Readable; + /** + * Generates a snapshot of the current V8 heap and writes it to a JSON + * file. This file is intended to be used with tools such as Chrome + * DevTools. The JSON schema is undocumented and specific to the V8 + * engine, and may change from one version of V8 to the next. + * + * A heap snapshot is specific to a single V8 isolate. When using `worker threads`, a heap snapshot generated from the main thread will + * not contain any information about the workers, and vice versa. + * + * Creating a heap snapshot requires memory about twice the size of the heap at + * the time the snapshot is created. This results in the risk of OOM killers + * terminating the process. + * + * Generating a snapshot is a synchronous operation which blocks the event loop + * for a duration depending on the heap size. + * + * ```js + * const { writeHeapSnapshot } = require('node:v8'); + * const { + * Worker, + * isMainThread, + * parentPort, + * } = require('node:worker_threads'); + * + * if (isMainThread) { + * const worker = new Worker(__filename); + * + * worker.once('message', (filename) => { + * console.log(`worker heapdump: ${filename}`); + * // Now get a heapdump for the main thread. + * console.log(`main thread heapdump: ${writeHeapSnapshot()}`); + * }); + * + * // Tell the worker to create a heapdump. + * worker.postMessage('heapdump'); + * } else { + * parentPort.once('message', (message) => { + * if (message === 'heapdump') { + * // Generate a heapdump for the worker + * // and return the filename to the parent. + * parentPort.postMessage(writeHeapSnapshot()); + * } + * }); + * } + * ``` + * @since v11.13.0 + * @param filename The file path where the V8 heap snapshot is to be saved. If not specified, a file name with the pattern `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be + * generated, where `{pid}` will be the PID of the Node.js process, `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from the main Node.js thread or the id of a + * worker thread. + * @return The filename where the snapshot was saved. + */ + function writeHeapSnapshot(filename?: string): string; + /** + * Get statistics about code and its metadata in the heap, see + * V8[`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the + * following properties: + * + * ```js + * { + * code_and_metadata_size: 212208, + * bytecode_and_metadata_size: 161368, + * external_script_source_size: 1410794, + * cpu_profiler_metadata_size: 0, + * } + * ``` + * @since v12.8.0 + */ + function getHeapCodeStatistics(): HeapCodeStatistics; + /** + * @since v8.0.0 + */ + class Serializer { + /** + * Writes out a header, which includes the serialization format version. + */ + writeHeader(): void; + /** + * Serializes a JavaScript value and adds the serialized representation to the + * internal buffer. + * + * This throws an error if `value` cannot be serialized. + */ + writeValue(val: any): boolean; + /** + * Returns the stored internal buffer. This serializer should not be used once + * the buffer is released. Calling this method results in undefined behavior + * if a previous write has failed. + */ + releaseBuffer(): Buffer; + /** + * Marks an `ArrayBuffer` as having its contents transferred out of band. + * Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`. + * @param id A 32-bit unsigned integer. + * @param arrayBuffer An `ArrayBuffer` instance. + */ + transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void; + /** + * Write a raw 32-bit unsigned integer. + * For use inside of a custom `serializer._writeHostObject()`. + */ + writeUint32(value: number): void; + /** + * Write a raw 64-bit unsigned integer, split into high and low 32-bit parts. + * For use inside of a custom `serializer._writeHostObject()`. + */ + writeUint64(hi: number, lo: number): void; + /** + * Write a JS `number` value. + * For use inside of a custom `serializer._writeHostObject()`. + */ + writeDouble(value: number): void; + /** + * Write raw bytes into the serializer's internal buffer. The deserializer + * will require a way to compute the length of the buffer. + * For use inside of a custom `serializer._writeHostObject()`. + */ + writeRawBytes(buffer: NodeJS.TypedArray): void; + } + /** + * A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only + * stores the part of their underlying `ArrayBuffer`s that they are referring to. + * @since v8.0.0 + */ + class DefaultSerializer extends Serializer {} + /** + * @since v8.0.0 + */ + class Deserializer { + constructor(data: NodeJS.TypedArray); + /** + * Reads and validates a header (including the format version). + * May, for example, reject an invalid or unsupported wire format. In that case, + * an `Error` is thrown. + */ + readHeader(): boolean; + /** + * Deserializes a JavaScript value from the buffer and returns it. + */ + readValue(): any; + /** + * Marks an `ArrayBuffer` as having its contents transferred out of band. + * Pass the corresponding `ArrayBuffer` in the serializing context to `serializer.transferArrayBuffer()` (or return the `id` from `serializer._getSharedArrayBufferId()` in the case of + * `SharedArrayBuffer`s). + * @param id A 32-bit unsigned integer. + * @param arrayBuffer An `ArrayBuffer` instance. + */ + transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void; + /** + * Reads the underlying wire format version. Likely mostly to be useful to + * legacy code reading old wire format versions. May not be called before`.readHeader()`. + */ + getWireFormatVersion(): number; + /** + * Read a raw 32-bit unsigned integer and return it. + * For use inside of a custom `deserializer._readHostObject()`. + */ + readUint32(): number; + /** + * Read a raw 64-bit unsigned integer and return it as an array `[hi, lo]`with two 32-bit unsigned integer entries. + * For use inside of a custom `deserializer._readHostObject()`. + */ + readUint64(): [number, number]; + /** + * Read a JS `number` value. + * For use inside of a custom `deserializer._readHostObject()`. + */ + readDouble(): number; + /** + * Read raw bytes from the deserializer's internal buffer. The `length` parameter + * must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`. + * For use inside of a custom `deserializer._readHostObject()`. + */ + readRawBytes(length: number): Buffer; + } + /** + * A subclass of `Deserializer` corresponding to the format written by `DefaultSerializer`. + * @since v8.0.0 + */ + class DefaultDeserializer extends Deserializer {} + /** + * Uses a `DefaultSerializer` to serialize `value` into a buffer. + * + * `ERR_BUFFER_TOO_LARGE` will be thrown when trying to + * serialize a huge object which requires buffer + * larger than `buffer.constants.MAX_LENGTH`. + * @since v8.0.0 + */ + function serialize(value: any): Buffer; + /** + * Uses a `DefaultDeserializer` with default options to read a JS value + * from a buffer. + * @since v8.0.0 + * @param buffer A buffer returned by {@link serialize}. + */ + function deserialize(buffer: NodeJS.TypedArray): any; + /** + * The `v8.takeCoverage()` method allows the user to write the coverage started by `NODE_V8_COVERAGE` to disk on demand. This method can be invoked multiple + * times during the lifetime of the process. Each time the execution counter will + * be reset and a new coverage report will be written to the directory specified + * by `NODE_V8_COVERAGE`. + * + * When the process is about to exit, one last coverage will still be written to + * disk unless {@link stopCoverage} is invoked before the process exits. + * @since v15.1.0, v14.18.0, v12.22.0 + */ + function takeCoverage(): void; + /** + * The `v8.stopCoverage()` method allows the user to stop the coverage collection + * started by `NODE_V8_COVERAGE`, so that V8 can release the execution count + * records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand. + * @since v15.1.0, v14.18.0, v12.22.0 + */ + function stopCoverage(): void; + /** + * This API collects GC data in current thread. + * @since v19.6.0, v18.15.0 + */ + class GCProfiler { + /** + * Start collecting GC data. + * @since v19.6.0, v18.15.0 + */ + start(): void; + /** + * Stop collecting GC data and return an object.The content of object + * is as follows. + * + * ```json + * { + * "version": 1, + * "startTime": 1674059033862, + * "statistics": [ + * { + * "gcType": "Scavenge", + * "beforeGC": { + * "heapStatistics": { + * "totalHeapSize": 5005312, + * "totalHeapSizeExecutable": 524288, + * "totalPhysicalSize": 5226496, + * "totalAvailableSize": 4341325216, + * "totalGlobalHandlesSize": 8192, + * "usedGlobalHandlesSize": 2112, + * "usedHeapSize": 4883840, + * "heapSizeLimit": 4345298944, + * "mallocedMemory": 254128, + * "externalMemory": 225138, + * "peakMallocedMemory": 181760 + * }, + * "heapSpaceStatistics": [ + * { + * "spaceName": "read_only_space", + * "spaceSize": 0, + * "spaceUsedSize": 0, + * "spaceAvailableSize": 0, + * "physicalSpaceSize": 0 + * } + * ] + * }, + * "cost": 1574.14, + * "afterGC": { + * "heapStatistics": { + * "totalHeapSize": 6053888, + * "totalHeapSizeExecutable": 524288, + * "totalPhysicalSize": 5500928, + * "totalAvailableSize": 4341101384, + * "totalGlobalHandlesSize": 8192, + * "usedGlobalHandlesSize": 2112, + * "usedHeapSize": 4059096, + * "heapSizeLimit": 4345298944, + * "mallocedMemory": 254128, + * "externalMemory": 225138, + * "peakMallocedMemory": 181760 + * }, + * "heapSpaceStatistics": [ + * { + * "spaceName": "read_only_space", + * "spaceSize": 0, + * "spaceUsedSize": 0, + * "spaceAvailableSize": 0, + * "physicalSpaceSize": 0 + * } + * ] + * } + * } + * ], + * "endTime": 1674059036865 + * } + * ``` + * + * Here's an example. + * + * ```js + * const { GCProfiler } = require('v8'); + * const profiler = new GCProfiler(); + * profiler.start(); + * setTimeout(() => { + * console.log(profiler.stop()); + * }, 1000); + * ``` + * @since v19.6.0, v18.15.0 + */ + stop(): GCProfilerResult; + } + interface GCProfilerResult { + version: number; + startTime: number; + endTime: number; + statistics: Array<{ + gcType: string; + cost: number; + beforeGC: { + heapStatistics: HeapStatistics; + heapSpaceStatistics: HeapSpaceStatistics[]; + }; + afterGC: { + heapStatistics: HeapStatistics; + heapSpaceStatistics: HeapSpaceStatistics[]; + }; + }>; + } + interface HeapStatistics { + totalHeapSize: number; + totalHeapSizeExecutable: number; + totalPhysicalSize: number; + totalAvailableSize: number; + totalGlobalHandlesSize: number; + usedGlobalHandlesSize: number; + usedHeapSize: number; + heapSizeLimit: number; + mallocedMemory: number; + externalMemory: number; + peakMallocedMemory: number; + } + interface HeapSpaceStatistics { + spaceName: string; + spaceSize: number; + spaceUsedSize: number; + spaceAvailableSize: number; + physicalSpaceSize: number; + } + /** + * Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will + * happen if a promise is created without ever getting a continuation. + * @since v17.1.0, v16.14.0 + * @param promise The promise being created. + * @param parent The promise continued from, if applicable. + */ + interface Init { + (promise: Promise, parent: Promise): void; + } + /** + * Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming. + * + * The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise. + * The before callback may be called many times in the case where many continuations have been made from the same promise. + * @since v17.1.0, v16.14.0 + */ + interface Before { + (promise: Promise): void; + } + /** + * Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await. + * @since v17.1.0, v16.14.0 + */ + interface After { + (promise: Promise): void; + } + /** + * Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or + * {@link Promise.reject()}. + * @since v17.1.0, v16.14.0 + */ + interface Settled { + (promise: Promise): void; + } + /** + * Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or + * around an await, and when the promise resolves or rejects. + * + * Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and + * `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop. + * @since v17.1.0, v16.14.0 + */ + interface HookCallbacks { + init?: Init; + before?: Before; + after?: After; + settled?: Settled; + } + interface PromiseHooks { + /** + * The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param init The {@link Init | `init` callback} to call when a promise is created. + * @return Call to stop the hook. + */ + onInit: (init: Init) => Function; + /** + * The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param settled The {@link Settled | `settled` callback} to call when a promise is created. + * @return Call to stop the hook. + */ + onSettled: (settled: Settled) => Function; + /** + * The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param before The {@link Before | `before` callback} to call before a promise continuation executes. + * @return Call to stop the hook. + */ + onBefore: (before: Before) => Function; + /** + * The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param after The {@link After | `after` callback} to call after a promise continuation executes. + * @return Call to stop the hook. + */ + onAfter: (after: After) => Function; + /** + * Registers functions to be called for different lifetime events of each promise. + * The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime. + * All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed. + * The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop. + * @since v17.1.0, v16.14.0 + * @param callbacks The {@link HookCallbacks | Hook Callbacks} to register + * @return Used for disabling hooks + */ + createHook: (callbacks: HookCallbacks) => Function; + } + /** + * The `promiseHooks` interface can be used to track promise lifecycle events. + * @since v17.1.0, v16.14.0 + */ + const promiseHooks: PromiseHooks; +} +declare module "node:v8" { + export * from "v8"; +} diff --git a/node_modules/@types/node/ts4.8/vm.d.ts b/node_modules/@types/node/ts4.8/vm.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a310ccb325e032e07407a7676601b301a942038 --- /dev/null +++ b/node_modules/@types/node/ts4.8/vm.d.ts @@ -0,0 +1,903 @@ +/** + * The `node:vm` module enables compiling and running code within V8 Virtual + * Machine contexts. + * + * **The `node:vm` module is not a security** + * **mechanism. Do not use it to run untrusted code.** + * + * JavaScript code can be compiled and run immediately or + * compiled, saved, and run later. + * + * A common use case is to run the code in a different V8 Context. This means + * invoked code has a different global object than the invoking code. + * + * One can provide the context by `contextifying` an + * object. The invoked code treats any property in the context like a + * global variable. Any changes to global variables caused by the invoked + * code are reflected in the context object. + * + * ```js + * const vm = require('node:vm'); + * + * const x = 1; + * + * const context = { x: 2 }; + * vm.createContext(context); // Contextify the object. + * + * const code = 'x += 40; var y = 17;'; + * // `x` and `y` are global variables in the context. + * // Initially, x has the value 2 because that is the value of context.x. + * vm.runInContext(code, context); + * + * console.log(context.x); // 42 + * console.log(context.y); // 17 + * + * console.log(x); // 1; y is not defined. + * ``` + * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/vm.js) + */ +declare module "vm" { + import { ImportAttributes } from "node:module"; + interface Context extends NodeJS.Dict {} + interface BaseOptions { + /** + * Specifies the filename used in stack traces produced by this script. + * Default: `''`. + */ + filename?: string | undefined; + /** + * Specifies the line number offset that is displayed in stack traces produced by this script. + * Default: `0`. + */ + lineOffset?: number | undefined; + /** + * Specifies the column number offset that is displayed in stack traces produced by this script. + * @default 0 + */ + columnOffset?: number | undefined; + } + interface ScriptOptions extends BaseOptions { + /** + * V8's code cache data for the supplied source. + */ + cachedData?: Buffer | NodeJS.ArrayBufferView | undefined; + /** @deprecated in favor of `script.createCachedData()` */ + produceCachedData?: boolean | undefined; + /** + * Called during evaluation of this module when `import()` is called. + * If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`. + */ + importModuleDynamically?: + | ((specifier: string, script: Script, importAttributes: ImportAttributes) => Module) + | undefined; + } + interface RunningScriptOptions extends BaseOptions { + /** + * When `true`, if an `Error` occurs while compiling the `code`, the line of code causing the error is attached to the stack trace. + * Default: `true`. + */ + displayErrors?: boolean | undefined; + /** + * Specifies the number of milliseconds to execute code before terminating execution. + * If execution is terminated, an `Error` will be thrown. This value must be a strictly positive integer. + */ + timeout?: number | undefined; + /** + * If `true`, the execution will be terminated when `SIGINT` (Ctrl+C) is received. + * Existing handlers for the event that have been attached via `process.on('SIGINT')` will be disabled during script execution, but will continue to work after that. + * If execution is terminated, an `Error` will be thrown. + * Default: `false`. + */ + breakOnSigint?: boolean | undefined; + } + interface RunningScriptInNewContextOptions extends RunningScriptOptions { + /** + * Human-readable name of the newly created context. + */ + contextName?: CreateContextOptions["name"]; + /** + * Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL, + * but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object. + * Most notably, this string should omit the trailing slash, as that denotes a path. + */ + contextOrigin?: CreateContextOptions["origin"]; + contextCodeGeneration?: CreateContextOptions["codeGeneration"]; + /** + * If set to `afterEvaluate`, microtasks will be run immediately after the script has run. + */ + microtaskMode?: CreateContextOptions["microtaskMode"]; + } + interface RunningCodeOptions extends RunningScriptOptions { + cachedData?: ScriptOptions["cachedData"]; + importModuleDynamically?: ScriptOptions["importModuleDynamically"]; + } + interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions { + cachedData?: ScriptOptions["cachedData"]; + importModuleDynamically?: ScriptOptions["importModuleDynamically"]; + } + interface CompileFunctionOptions extends BaseOptions { + /** + * Provides an optional data with V8's code cache data for the supplied source. + */ + cachedData?: Buffer | undefined; + /** + * Specifies whether to produce new cache data. + * Default: `false`, + */ + produceCachedData?: boolean | undefined; + /** + * The sandbox/context in which the said function should be compiled in. + */ + parsingContext?: Context | undefined; + /** + * An array containing a collection of context extensions (objects wrapping the current scope) to be applied while compiling + */ + contextExtensions?: Object[] | undefined; + } + interface CreateContextOptions { + /** + * Human-readable name of the newly created context. + * @default 'VM Context i' Where i is an ascending numerical index of the created context. + */ + name?: string | undefined; + /** + * Corresponds to the newly created context for display purposes. + * The origin should be formatted like a `URL`, but with only the scheme, host, and port (if necessary), + * like the value of the `url.origin` property of a URL object. + * Most notably, this string should omit the trailing slash, as that denotes a path. + * @default '' + */ + origin?: string | undefined; + codeGeneration?: + | { + /** + * If set to false any calls to eval or function constructors (Function, GeneratorFunction, etc) + * will throw an EvalError. + * @default true + */ + strings?: boolean | undefined; + /** + * If set to false any attempt to compile a WebAssembly module will throw a WebAssembly.CompileError. + * @default true + */ + wasm?: boolean | undefined; + } + | undefined; + /** + * If set to `afterEvaluate`, microtasks will be run immediately after the script has run. + */ + microtaskMode?: "afterEvaluate" | undefined; + } + type MeasureMemoryMode = "summary" | "detailed"; + interface MeasureMemoryOptions { + /** + * @default 'summary' + */ + mode?: MeasureMemoryMode | undefined; + /** + * @default 'default' + */ + execution?: "default" | "eager" | undefined; + } + interface MemoryMeasurement { + total: { + jsMemoryEstimate: number; + jsMemoryRange: [number, number]; + }; + } + /** + * Instances of the `vm.Script` class contain precompiled scripts that can be + * executed in specific contexts. + * @since v0.3.1 + */ + class Script { + constructor(code: string, options?: ScriptOptions | string); + /** + * Runs the compiled code contained by the `vm.Script` object within the given`contextifiedObject` and returns the result. Running code does not have access + * to local scope. + * + * The following example compiles code that increments a global variable, sets + * the value of another global variable, then execute the code multiple times. + * The globals are contained in the `context` object. + * + * ```js + * const vm = require('node:vm'); + * + * const context = { + * animal: 'cat', + * count: 2, + * }; + * + * const script = new vm.Script('count += 1; name = "kitty";'); + * + * vm.createContext(context); + * for (let i = 0; i < 10; ++i) { + * script.runInContext(context); + * } + * + * console.log(context); + * // Prints: { animal: 'cat', count: 12, name: 'kitty' } + * ``` + * + * Using the `timeout` or `breakOnSigint` options will result in new event loops + * and corresponding threads being started, which have a non-zero performance + * overhead. + * @since v0.3.1 + * @param contextifiedObject A `contextified` object as returned by the `vm.createContext()` method. + * @return the result of the very last statement executed in the script. + */ + runInContext(contextifiedObject: Context, options?: RunningScriptOptions): any; + /** + * First contextifies the given `contextObject`, runs the compiled code contained + * by the `vm.Script` object within the created context, and returns the result. + * Running code does not have access to local scope. + * + * The following example compiles code that sets a global variable, then executes + * the code multiple times in different contexts. The globals are set on and + * contained within each individual `context`. + * + * ```js + * const vm = require('node:vm'); + * + * const script = new vm.Script('globalVar = "set"'); + * + * const contexts = [{}, {}, {}]; + * contexts.forEach((context) => { + * script.runInNewContext(context); + * }); + * + * console.log(contexts); + * // Prints: [{ globalVar: 'set' }, { globalVar: 'set' }, { globalVar: 'set' }] + * ``` + * @since v0.3.1 + * @param contextObject An object that will be `contextified`. If `undefined`, a new object will be created. + * @return the result of the very last statement executed in the script. + */ + runInNewContext(contextObject?: Context, options?: RunningScriptInNewContextOptions): any; + /** + * Runs the compiled code contained by the `vm.Script` within the context of the + * current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object. + * + * The following example compiles code that increments a `global` variable then + * executes that code multiple times: + * + * ```js + * const vm = require('node:vm'); + * + * global.globalVar = 0; + * + * const script = new vm.Script('globalVar += 1', { filename: 'myfile.vm' }); + * + * for (let i = 0; i < 1000; ++i) { + * script.runInThisContext(); + * } + * + * console.log(globalVar); + * + * // 1000 + * ``` + * @since v0.3.1 + * @return the result of the very last statement executed in the script. + */ + runInThisContext(options?: RunningScriptOptions): any; + /** + * Creates a code cache that can be used with the `Script` constructor's`cachedData` option. Returns a `Buffer`. This method may be called at any + * time and any number of times. + * + * The code cache of the `Script` doesn't contain any JavaScript observable + * states. The code cache is safe to be saved along side the script source and + * used to construct new `Script` instances multiple times. + * + * Functions in the `Script` source can be marked as lazily compiled and they are + * not compiled at construction of the `Script`. These functions are going to be + * compiled when they are invoked the first time. The code cache serializes the + * metadata that V8 currently knows about the `Script` that it can use to speed up + * future compilations. + * + * ```js + * const script = new vm.Script(` + * function add(a, b) { + * return a + b; + * } + * + * const x = add(1, 2); + * `); + * + * const cacheWithoutAdd = script.createCachedData(); + * // In `cacheWithoutAdd` the function `add()` is marked for full compilation + * // upon invocation. + * + * script.runInThisContext(); + * + * const cacheWithAdd = script.createCachedData(); + * // `cacheWithAdd` contains fully compiled function `add()`. + * ``` + * @since v10.6.0 + */ + createCachedData(): Buffer; + /** @deprecated in favor of `script.createCachedData()` */ + cachedDataProduced?: boolean | undefined; + /** + * When `cachedData` is supplied to create the `vm.Script`, this value will be set + * to either `true` or `false` depending on acceptance of the data by V8\. + * Otherwise the value is `undefined`. + * @since v5.7.0 + */ + cachedDataRejected?: boolean | undefined; + cachedData?: Buffer | undefined; + /** + * When the script is compiled from a source that contains a source map magic + * comment, this property will be set to the URL of the source map. + * + * ```js + * import vm from 'node:vm'; + * + * const script = new vm.Script(` + * function myFunc() {} + * //# sourceMappingURL=sourcemap.json + * `); + * + * console.log(script.sourceMapURL); + * // Prints: sourcemap.json + * ``` + * @since v19.1.0, v18.13.0 + */ + sourceMapURL?: string | undefined; + } + /** + * If given a `contextObject`, the `vm.createContext()` method will `prepare + * that object` so that it can be used in calls to {@link runInContext} or `script.runInContext()`. Inside such scripts, + * the `contextObject` will be the global object, retaining all of its existing + * properties but also having the built-in objects and functions any standard [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global variables + * will remain unchanged. + * + * ```js + * const vm = require('node:vm'); + * + * global.globalVar = 3; + * + * const context = { globalVar: 1 }; + * vm.createContext(context); + * + * vm.runInContext('globalVar *= 2;', context); + * + * console.log(context); + * // Prints: { globalVar: 2 } + * + * console.log(global.globalVar); + * // Prints: 3 + * ``` + * + * If `contextObject` is omitted (or passed explicitly as `undefined`), a new, + * empty `contextified` object will be returned. + * + * The `vm.createContext()` method is primarily useful for creating a single + * context that can be used to run multiple scripts. For instance, if emulating a + * web browser, the method can be used to create a single context representing a + * window's global object, then run all ``); + }); + } + function serve() { + return __awaiter(this, void 0, void 0, function* () { + server = http_1.createServer((req, res) => serve_handler_1.default(req, res, { public: testDir })); + yield new Promise(resolve => server.listen(0, resolve)); + }); + } + before(function () { + return __awaiter(this, void 0, void 0, function* () { + yield buildWebpack(); + yield serve(); + this.timeout(20 * 1000); + const { port } = server.address(); + const browser = yield puppeteer_1.default.launch({ + executablePath: 'google-chrome-stable', + args: ['--no-sandbox'], + }); + page = yield browser.newPage(); + yield page.goto(`http://localhost:${port}`); + yield page.waitForFunction('!!window.blake3'); + yield page.evaluate(addInputs); + }); + }); + runTests({ + get page() { + return page; + }, + }); + after(() => { + page === null || page === void 0 ? void 0 : page.browser().close(); + server === null || server === void 0 ? void 0 : server.close(); + }); + }); + describe('native browser', () => { + let server; + let page; + function serve() { + return __awaiter(this, void 0, void 0, function* () { + server = http_1.createServer((req, res) => serve_handler_1.default(req, res, { public: path_1.resolve(__dirname, '..') })); + yield new Promise(resolve => server.listen(0, resolve)); + }); + } + before(function () { + return __awaiter(this, void 0, void 0, function* () { + yield serve(); + this.timeout(20 * 1000); + const { port } = server.address(); + const browser = yield puppeteer_1.default.launch({ + executablePath: 'google-chrome-stable', + args: ['--no-sandbox'], + }); + page = yield browser.newPage(); + page.on('console', console.log); + page.on('pageerror', console.log); + page.on('error', console.log); + yield page.goto(`http://localhost:${port}/browser-async.test.html`); + yield page.waitForFunction('!!window.blake3'); + yield page.evaluate(addInputs); + }); + }); + runTests({ + get page() { + return page; + }, + }); + after(() => { + page === null || page === void 0 ? void 0 : page.browser().close(); + server.close(); + }); + }); +}); +function runTests(opts) { + it('hashes a string', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.large.input).toString("hex")'); + chai_1.expect(result).to.equal(test_helpers_1.inputs.large.hash.toString('hex')); + })); + describe('input encoding', () => { + it('hashes a uint8array', () => __awaiter(this, void 0, void 0, function* () { + const contents = [...new Uint8Array(Buffer.from(test_helpers_1.inputs.hello.input))]; + const result = yield opts.page.evaluate(`blake3.hash(new Uint8Array([${contents.join(',')}])).toString("hex")`); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + })); + it('hashes a string', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.large.input).toString("hex")'); + chai_1.expect(result).to.equal(test_helpers_1.inputs.large.hash.toString('hex')); + })); + it('customizes output length', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.hello.input, { length: 16 }).toString("hex")'); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.slice(0, 16).toString('hex')); + })); + }); + describe('output encoding', () => { + const tcases = [ + { encoding: 'hex', expected: test_helpers_1.inputs.hello.hash.toString('hex') }, + { encoding: 'base64', expected: test_helpers_1.inputs.hello.hash.toString('base64') }, + { encoding: 'utf8', expected: test_helpers_1.inputs.hello.hash.toString('utf8') }, + ]; + tcases.forEach(({ encoding, expected }) => it(encoding, () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.hash(inputs.hello.input).toString("${encoding}")`); + chai_1.expect(result).to.equal(expected); + }))); + it('raw', () => __awaiter(this, void 0, void 0, function* () { + const result = (yield opts.page.evaluate(`blake3.hash(inputs.hello.input)`)); + const actual = Buffer.alloc(32); + for (let i = 0; i < actual.length; i++) { + actual[i] = result[i]; // it comes as a plain object, we need to convert it to a buffer + } + chai_1.expect(actual).to.deep.equal(test_helpers_1.inputs.hello.hash); + })); + }); + describe('hash class', () => { + it('digests', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + ${[...Buffer.from(test_helpers_1.inputs.hello.input)] + .map(byte => `hash.update(new Uint8Array([${byte}]));`) + .join('\n')} + return hash.digest('hex'); + })()`); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + })); + it('customizes the output length', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + hash.update(${JSON.stringify(test_helpers_1.inputs.hello.input)}); + return hash.digest('hex', { length: 16 }); + })()`); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.slice(0, 16).toString('hex')); + })); + it('returns a hash instance from digest', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + ${[...Buffer.from(test_helpers_1.inputs.hello.input)] + .map(byte => `hash.update(new Uint8Array([${byte}]));`) + .join('\n')} + return hash.digest('hex'); + })()`); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + })); + }); + describe('reader', () => { + it('is sane with a Hash', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + hash.update("hello"); + + return blake3.using(hash.reader(), reader => [ + reader.read(48).toString('hex'), + reader.toArray().toString('hex'), + reader.toString('hex'), + ]); + })()`); + chai_1.expect(result).to.deep.equal([ + test_helpers_1.hello48.toString('hex'), + test_helpers_1.inputs.hello.hash.toString('hex'), + test_helpers_1.inputs.hello.hash.toString('hex'), + ]); + })); + }); + describe('original test vectors', () => { + for (const { inputLen, expectedDerive, expectedHash, expectedKeyed, } of test_helpers_1.ogTestVectors.cases.slice(0, 6)) { + describe(`${inputLen}`, () => __awaiter(this, void 0, void 0, function* () { + const input = Buffer.alloc(inputLen); + for (let i = 0; i < inputLen; i++) { + input[i] = i % 251; + } + const inputStr = `new Uint8Array([${input.join(',')}])`; + it('hash()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.hash( + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + chai_1.expect(result).to.equal(expectedHash); + })); + it('deriveKey()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.deriveKey( + ${JSON.stringify(test_helpers_1.ogTestVectors.context)}, + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + chai_1.expect(result).to.equal(expectedDerive); + })); + it('createKeyed()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hasher = blake3.createKeyed(new Uint8Array([${Buffer.from(test_helpers_1.ogTestVectors.key).join(',')}])); + hasher.update(${inputStr}); + return hasher.digest({ length: ${expectedHash.length / 2} }).toString('hex'); + })()`); + chai_1.expect(result).to.equal(expectedKeyed); + })); + it('keyedHash()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.keyedHash( + new Uint8Array([${Buffer.from(test_helpers_1.ogTestVectors.key).join(',')}]), + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + chai_1.expect(result).to.equal(expectedKeyed); + })); + })); + } + }); +} +//# sourceMappingURL=browser.test.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser.test.js.map b/node_modules/blake3-wasm/dist/browser.test.js.map new file mode 100644 index 0000000000000000000000000000000000000000..78f1ea977b7fc5289dcac89164e32e1660c4c750 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.test.js","sourceRoot":"","sources":["../ts/browser.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,2BAA8C;AAC9C,+BAA4C;AAE5C,2BAA4B;AAC5B,+BAA+B;AAC/B,0DAA4C;AAC5C,kEAAoC;AACpC,sDAA8B;AAC9B,sDAAqE;AAErE,4EAA4E;AAC5E,4EAA4E;AAC5E,mEAAmE;AACnE,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,MAAM,SAAS,GAAG,mBAAmB,IAAI,CAAC,SAAS,CAAC,qBAAM,CAAC,EAAE,CAAC;IAE9D,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;QACvB,MAAM,OAAO,GAAG,cAAO,CAAC,WAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC;QACzD,IAAI,MAAc,CAAC;QACnB,IAAI,IAAoB,CAAC;QAEzB;;WAEG;QACH,SAAe,YAAY;;gBACzB,IA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c,MAAM,CAAC,IAAI,CAAC,4BAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CACrF,GAAG,CACJ;4BACe,QAAQ;6CACS,YAAY,CAAC,MAAM,GAAG,CAAC;eACrD,CAAC,CAAC;oBAEP,aAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBACzC,CAAC,CAAA,CAAC,CAAC;gBAEH,EAAE,CAAC,aAAa,EAAE,GAAS,EAAE;oBAC3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;8BACpB,MAAM,CAAC,IAAI,CAAC,4BAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;cACxD,QAAQ;wBACE,YAAY,CAAC,MAAM,GAAG,CAAC;4BACnB,CAAC,CAAC;oBAEpB,aAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBACzC,CAAC,CAAA,CAAC,CAAC;YACL,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/encoding.d.ts b/node_modules/blake3-wasm/dist/browser/encoding.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c8b547c7c98d5265a56ea6619415890fbd35120 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/encoding.d.ts @@ -0,0 +1,5 @@ +export declare type BrowserEncoding = 'hex' | 'base64' | 'utf8'; +/** + * @hidden + */ +export declare const mustGetEncoder: (encoding: BrowserEncoding) => (data: Uint8Array) => string; diff --git a/node_modules/blake3-wasm/dist/browser/encoding.js b/node_modules/blake3-wasm/dist/browser/encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..2d6134149b855d8bae8df947d29f94464823275f --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/encoding.js @@ -0,0 +1,30 @@ +"use strict"; +// A small collection of encodings for convenience of use in the browser. +Object.defineProperty(exports, "__esModule", { value: true }); +const decoder = new TextDecoder(); +const encoders = { + // certainly not the fastest, but hashes are pretty small + base64: data => btoa(String.fromCharCode(...data)), + hex: data => { + let out = ''; + for (const byte of data) { + if (byte < 0x10) { + out += '0'; + } + out += byte.toString(16); + } + return out; + }, + utf8: data => decoder.decode(data), +}; +/** + * @hidden + */ +exports.mustGetEncoder = (encoding) => { + const encoder = encoders[encoding]; + if (!encoder) { + throw new Error(`Unknown encoding ${encoding}`); + } + return encoder; +}; +//# sourceMappingURL=encoding.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/encoding.js.map b/node_modules/blake3-wasm/dist/browser/encoding.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b524e4a5494f5c32799874ac059e8c06b42e2364 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/encoding.js.map @@ -0,0 +1 @@ +{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../ts/browser/encoding.ts"],"names":[],"mappings":";AAAA,yEAAyE;;AAIzE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,QAAQ,GAA6D;IACzE,yDAAyD;IACzD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IAElD,GAAG,EAAE,IAAI,CAAC,EAAE;QACV,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;YACvB,IAAI,IAAI,GAAG,IAAI,EAAE;gBACf,GAAG,IAAI,GAAG,CAAC;aACZ;YAED,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SAC1B;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;CACnC,CAAC;AAEF;;GAEG;AACU,QAAA,cAAc,GAAG,CAAC,QAAyB,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;KACjD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-fn.d.ts b/node_modules/blake3-wasm/dist/browser/hash-fn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a341ea25f10048223542053a90bf0bd52cdc0bec --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-fn.d.ts @@ -0,0 +1,24 @@ +import { BaseHashInput, IBaseHashOptions } from '../base/hash-fn'; +import { Hash } from './hash'; +/** + * Input used for browser-based hashes. + */ +export declare type HashInput = BaseHashInput | string; +/** + * @hidden + */ +export declare const normalizeInput: (input: import("..").HashInput) => Uint8Array; +/** + * Returns a blake3 hash of the input. + */ +export declare function hash(input: HashInput, { length }?: IBaseHashOptions): Hash; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Hash; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export declare function keyedHash(key: Uint8Array, input: HashInput, { length }?: IBaseHashOptions): Hash; diff --git a/node_modules/blake3-wasm/dist/browser/hash-fn.js b/node_modules/blake3-wasm/dist/browser/hash-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..525998008fe473317675258140225f8286d48a57 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-fn.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_fn_1 = require("../base/hash-fn"); +const hash_1 = require("./hash"); +const wasm_1 = require("./wasm"); +const textEncoder = new TextEncoder(); +/** + * @hidden + */ +exports.normalizeInput = (input) => hash_fn_1.inputToArray(typeof input === 'string' ? textEncoder.encode(input) : input); +/** + * Returns a blake3 hash of the input. + */ +function hash(input, { length = hash_fn_1.defaultHashLength } = {}) { + const result = new hash_1.Hash(length); + wasm_1.getWasm().hash(exports.normalizeInput(input), result); + return result; +} +exports.hash = hash; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +function deriveKey(context, material, { length = hash_fn_1.defaultHashLength } = {}) { + const derive = wasm_1.getWasm().create_derive(context); + derive.update(exports.normalizeInput(material)); + const result = new hash_1.Hash(length); + derive.digest(result); + return result; +} +exports.deriveKey = deriveKey; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +function keyedHash(key, input, { length = hash_fn_1.defaultHashLength } = {}) { + if (key.length !== 32) { + throw new Error(`key provided to keyedHash must be 32 bytes, got ${key.length}`); + } + const derive = wasm_1.getWasm().create_keyed(key); + derive.update(exports.normalizeInput(input)); + const result = new hash_1.Hash(length); + derive.digest(result); + return result; +} +exports.keyedHash = keyedHash; +//# sourceMappingURL=hash-fn.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-fn.js.map b/node_modules/blake3-wasm/dist/browser/hash-fn.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9ce0b9cc75ffa12c5305391d00538db79cfa2656 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/browser/hash-fn.ts"],"names":[],"mappings":";;AAAA,6CAAmG;AACnG,iCAA8B;AAC9B,iCAAiC;AAOjC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC;;GAEG;AACU,QAAA,cAAc,GAAG,CAAC,KAAgB,EAAc,E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,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAdD,8BAcC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-instance.d.ts b/node_modules/blake3-wasm/dist/browser/hash-instance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a706b3e154ce9331bcc02b18ea0e4e62a63682c --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-instance.d.ts @@ -0,0 +1,31 @@ +import { BaseHash as BaseHasher } from '../base/index'; +import { HashInput } from './hash-fn'; +import { BrowserEncoding } from './encoding'; +import { IBaseHashOptions } from '../base/hash-fn'; +import { BrowserHashReader } from './hash-reader'; +import { IInternalReader } from '../base/hash-reader'; +import { Hash } from './hash'; +/** + * @inheritdoc + */ +export declare class BrowserHasher extends BaseHasher { + /** + * @inheritdoc + * @override + */ + update(data: HashInput): this; + /** + * Returns a digest of the hash with the given encoding. + */ + digest(options?: IBaseHashOptions): Hash; + digest(encoding: undefined, options: IBaseHashOptions): Hash; + digest(encoding: BrowserEncoding, options?: IBaseHashOptions): string; +} +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => BrowserHasher; +/** + * A Node.js crypto-like createHash method. + */ +export declare const createKeyed: (key: Uint8Array) => BrowserHasher; diff --git a/node_modules/blake3-wasm/dist/browser/hash-instance.js b/node_modules/blake3-wasm/dist/browser/hash-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..63193574bf5309db4e32d25829e01441db18ecd5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-instance.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const index_1 = require("../base/index"); +const hash_fn_1 = require("./hash-fn"); +const encoding_1 = require("./encoding"); +const hash_reader_1 = require("./hash-reader"); +const hash_1 = require("./hash"); +const wasm_1 = require("./wasm"); +/** + * @inheritdoc + */ +class BrowserHasher extends index_1.BaseHash { + /** + * @inheritdoc + * @override + */ + update(data) { + return super.update(hash_fn_1.normalizeInput(data)); + } + digest(encoding, options) { + let resolvedOpts; + let resolvedEnc; + if (encoding && typeof encoding === 'object') { + resolvedOpts = encoding; + resolvedEnc = undefined; + } + else { + resolvedOpts = options; + resolvedEnc = encoding; + } + const result = super.digest(resolvedOpts); + return resolvedEnc ? encoding_1.mustGetEncoder(resolvedEnc)(result) : result; + } +} +exports.BrowserHasher = BrowserHasher; +/** + * A Node.js crypto-like createHash method. + */ +exports.createHash = () => new BrowserHasher(wasm_1.getWasm().create_hasher(), l => new hash_1.Hash(l), r => new hash_reader_1.BrowserHashReader(r)); +/** + * A Node.js crypto-like createHash method. + */ +exports.createKeyed = (key) => new BrowserHasher(wasm_1.getWasm().create_keyed(key), l => new hash_1.Hash(l), r => new hash_reader_1.BrowserHashReader(r)); +//# sourceMappingURL=hash-instance.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-instance.js.map b/node_modules/blake3-wasm/dist/browser/hash-instance.js.map new file mode 100644 index 0000000000000000000000000000000000000000..211b8023206d6cc61201b3bab5e5a7930b9e0705 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/browser/hash-instance.ts"],"names":[],"mappings":";;AAAA,yCAAuD;AACvD,uCAAsD;AACtD,yCAA6D;AAE7D,+CAAkD;AAElD,iCAA8B;AAC9B,iCAAiC;AAEjC;;GAEG;AACH,MAAa,aAAc,SAAQ,gBAAoD;IACrF;;;OAGG;IACI,MAAM,CAAC,IAAe;QAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,wBAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAQM,MAAM,CACX,QAA6C,EAC7C,OAA0B;QAE1B,IAAI,YAA0C,CAAC;QAC/C,IAAI,WAAwC,CAAC;QAC7C,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAC5C,YAAY,GAAG,QAAQ,CAAC;YACxB,WAAW,GAAG,SAAS,CAAC;SACzB;aAAM;YACL,YAAY,GAAG,OAAO,CAAC;YACvB,WAAW,GAAG,QAAQ,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,CAAC,CAAC,yBAAc,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACpE,CAAC;CACF;AAhCD,sCAgCC;AAED;;GAEG;AACU,QAAA,UAAU,GAAG,GAAG,EAAE,CAC7B,IAAI,aAAa,CACf,cAAO,EAAE,CAAC,aAAa,EAAE,EACzB,CAAC,CAAC,EAAE,CAAC,IAAI,WAAI,CAAC,CAAC,CAAC,EAChB,CAAC,CAAC,EAAE,CAAC,IAAI,+BAAiB,CAAC,CAAC,CAAC,CAC9B,CAAC;AAEJ;;GAEG;AACU,QAAA,WAAW,GAAG,CAAC,GAAe,EAAE,EAAE,CAC7C,IAAI,aAAa,CACf,cAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAC3B,CAAC,CAAC,EAAE,CAAC,IAAI,WAAI,CAAC,CAAC,CAAC,EAChB,CAAC,CAAC,EAAE,CAAC,IAAI,+BAAiB,CAAC,CAAC,CAAC,CAC9B,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-reader.d.ts b/node_modules/blake3-wasm/dist/browser/hash-reader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f2a75c7cf1f3d64ba02e9e5773db0ad9cdfe5711 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-reader.d.ts @@ -0,0 +1,17 @@ +import { BaseHashReader } from '../base/hash-reader'; +import { BrowserEncoding } from './encoding'; +import { Hash } from './hash'; +/** + * A hash reader for WebAssembly targets. + */ +export declare class BrowserHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding?: BrowserEncoding): string; + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray(): Hash; + protected alloc(bytes: number): Hash; +} diff --git a/node_modules/blake3-wasm/dist/browser/hash-reader.js b/node_modules/blake3-wasm/dist/browser/hash-reader.js new file mode 100644 index 0000000000000000000000000000000000000000..a48c3b2c80216c43259445200d3bafff18d33b57 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-reader.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_reader_1 = require("../base/hash-reader"); +const hash_1 = require("./hash"); +const index_1 = require("../base/index"); +/** + * A hash reader for WebAssembly targets. + */ +class BrowserHashReader extends hash_reader_1.BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toArray().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray() { + this.position = BigInt(0); + return this.read(index_1.defaultHashLength); + } + alloc(bytes) { + return new hash_1.Hash(bytes); + } +} +exports.BrowserHashReader = BrowserHashReader; +//# sourceMappingURL=hash-reader.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-reader.js.map b/node_modules/blake3-wasm/dist/browser/hash-reader.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b25f1a0e7101da83ca2dd712970782f1c0debec6 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/browser/hash-reader.ts"],"names":[],"mappings":";;AAAA,qDAAqD;AAErD,iCAA8B;AAC9B,yCAAkD;AAElD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,4BAAoB;IACzD;;OAEG;IACI,QAAQ,CAAC,WAA4B,KAAK;QAC/C,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAiB,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,KAAa;QAC3B,OAAO,IAAI,WAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACF;AAnBD,8CAmBC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash.d.ts b/node_modules/blake3-wasm/dist/browser/hash.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6487771755ba014a52333bc5413d28a10d5f67c6 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash.d.ts @@ -0,0 +1,11 @@ +import { BrowserEncoding } from './encoding'; +/** + * Hash returned from functions in the browser. + */ +export declare class Hash extends Uint8Array { + /** + * A constant-time comparison against the other hash/array. + */ + equals(other: unknown): boolean; + toString(encoding?: BrowserEncoding): string; +} diff --git a/node_modules/blake3-wasm/dist/browser/hash.js b/node_modules/blake3-wasm/dist/browser/hash.js new file mode 100644 index 0000000000000000000000000000000000000000..16145aa077341ad4fafb83b8fee679398bce411f --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const encoding_1 = require("./encoding"); +/** + * Hash returned from functions in the browser. + */ +class Hash extends Uint8Array { + /** + * A constant-time comparison against the other hash/array. + */ + equals(other) { + if (!(other instanceof Uint8Array)) { + return false; + } + if (other.length !== this.length) { + return false; + } + let cmp = 0; + for (let i = 0; i < this.length; i++) { + cmp |= this[i] ^ other[i]; + } + return cmp === 0; + } + toString(encoding = 'hex') { + return encoding_1.mustGetEncoder(encoding)(this); + } +} +exports.Hash = Hash; +//# sourceMappingURL=hash.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash.js.map b/node_modules/blake3-wasm/dist/browser/hash.js.map new file mode 100644 index 0000000000000000000000000000000000000000..33039d20c01e5406d49012254a88fb7020cc2c4a --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../ts/browser/hash.ts"],"names":[],"mappings":";;AAAA,yCAA6D;AAE7D;;GAEG;AACH,MAAa,IAAK,SAAQ,UAAU;IAClC;;OAEG;IACI,MAAM,CAAC,KAAc;QAC1B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;YAClC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3B;QAED,OAAO,GAAG,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,QAAQ,CAAC,WAA4B,KAAK;QAC/C,OAAO,yBAAc,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAxBD,oBAwBC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/index.d.ts b/node_modules/blake3-wasm/dist/browser/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f44c7ede6aebba6bb85bcfd6f8bc9c9ce3422d8d --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/index.d.ts @@ -0,0 +1,3 @@ +export { hash, HashInput, deriveKey, keyedHash } from './hash-fn'; +export * from './hash-instance'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/dist/browser/index.js b/node_modules/blake3-wasm/dist/browser/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3a8ca9e4ec1712dd40e951e48a90ff33ce838896 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/index.js @@ -0,0 +1,12 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +var hash_fn_1 = require("./hash-fn"); +exports.hash = hash_fn_1.hash; +exports.deriveKey = hash_fn_1.deriveKey; +exports.keyedHash = hash_fn_1.keyedHash; +__export(require("./hash-instance")); +__export(require("../base/index")); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/index.js.map b/node_modules/blake3-wasm/dist/browser/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9595245027350bfdc3d1645f5b7874624922ed12 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/browser/index.ts"],"names":[],"mappings":";;;;;AAAA,qCAAkE;AAAzD,yBAAA,IAAI,CAAA;AAAa,8BAAA,SAAS,CAAA;AAAE,8BAAA,SAAS,CAAA;AAC9C,qCAAgC;AAChC,mCAA8B"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/wasm.d.ts b/node_modules/blake3-wasm/dist/browser/wasm.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..559b61e1b407ac945602c0bc6c49fb4b3e800cc9 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/wasm.d.ts @@ -0,0 +1,10 @@ +import * as rawWasm from '../../dist/wasm/browser/blake3_js'; +/** + * Gets the webassembly module provided in provideWasm. + */ +export declare const getWasm: () => typeof rawWasm; +/** + * Sets the webassembly module used for the browser build. This indirection is + * needed to provide compatibility between the "browser" and "browser-async" modes. + */ +export declare const provideWasm: (w: typeof rawWasm) => void; diff --git a/node_modules/blake3-wasm/dist/browser/wasm.js b/node_modules/blake3-wasm/dist/browser/wasm.js new file mode 100644 index 0000000000000000000000000000000000000000..8bef8fe119512d38f225251c7f0223d47e9049ab --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/wasm.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let wasm; +/** + * Gets the webassembly module provided in provideWasm. + */ +exports.getWasm = () => { + if (!wasm) { + throw new Error('BLAKE3 webassembly not loaded. Please import the module via `blake3/browser` or `blake3/browser-async`'); + } + return wasm; +}; +/** + * Sets the webassembly module used for the browser build. This indirection is + * needed to provide compatibility between the "browser" and "browser-async" modes. + */ +exports.provideWasm = (w) => { + wasm = w; +}; +//# sourceMappingURL=wasm.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/wasm.js.map b/node_modules/blake3-wasm/dist/browser/wasm.js.map new file mode 100644 index 0000000000000000000000000000000000000000..7ee45c5a5d1794e4ba033c1521abe7f33d12b5ad --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/wasm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../ts/browser/wasm.ts"],"names":[],"mappings":";;AAEA,IAAI,IAAoB,CAAC;AAEzB;;GAEG;AACU,QAAA,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAG,CAAC,CAAiB,EAAE,EAAE;IAC/C,IAAI,GAAG,CAAC,CAAC;AACX,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/add-js-extensions.d.ts b/node_modules/blake3-wasm/dist/build/add-js-extensions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/add-js-extensions.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/build/add-js-extensions.js b/node_modules/blake3-wasm/dist/build/add-js-extensions.js new file mode 100644 index 0000000000000000000000000000000000000000..0aa30af93a5bc3d8e603d39118f2d8d64d6837c2 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/add-js-extensions.js @@ -0,0 +1,49 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const ts = __importStar(require("typescript")); +const fs_1 = require("fs"); +const path_1 = require("path"); +/** + * Script that adds .js extension to imports so that it's compatible with plain + * browser/non-webpack bundlers. TS doesn't support this natively yet. + * @see https://github.com/microsoft/TypeScript/issues/16577 + */ +function processFile(file) { + let source = fs_1.readFileSync(file, 'utf-8'); + const program = ts.createSourceFile(path_1.basename(file), source, ts.ScriptTarget.ES2015, true); + let offset = 0; + const process = (node) => { + if ((!ts.isImportDeclaration(node) && !ts.isExportDeclaration(node)) || !node.moduleSpecifier) { + return ts.forEachChild(node, process); + } + const specifier = node.moduleSpecifier; + if (path_1.extname(specifier.getText()) === '') { + const idx = specifier.end + offset - 1; + source = source.slice(0, idx) + '.js' + source.slice(idx); + offset += 3; + } + }; + process(program); + fs_1.writeFileSync(file, source); +} +function processDir(dir) { + const entries = fs_1.readdirSync(dir); + for (const entry of entries) { + const path = path_1.join(dir, entry); + if (path.endsWith('.js')) { + processFile(path); + } + else if (fs_1.statSync(path).isDirectory()) { + processDir(path); + } + } +} +processDir(path_1.resolve(__dirname, '..', '..', 'esm')); +//# sourceMappingURL=add-js-extensions.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/add-js-extensions.js.map b/node_modules/blake3-wasm/dist/build/add-js-extensions.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3dcb10c5387f5a0bada16b0fa9b28c5b67132ac6 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/add-js-extensions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"add-js-extensions.js","sourceRoot":"","sources":["../../ts/build/add-js-extensions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAiC;AACjC,2BAAwE;AACxE,+BAAwD;AAExD;;;;GAIG;AAEH,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,MAAM,GAAG,iBAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,eAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE1F,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,OAAO,GAAG,CAAC,IAAa,EAAQ,EAAE;QACtC,IAAI,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YAC7F,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SACvC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC;QACvC,IAAI,cAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACvC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;YACvC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1D,MAAM,IAAI,CAAC,CAAC;SACb;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjB,kBAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,OAAO,GAAG,gBAAW,CAAC,GAAG,CAAC,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,IAAI,GAAG,WAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACxB,WAAW,CAAC,IAAI,CAAC,CAAC;SACnB;aAAM,IAAI,aAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;YACvC,UAAU,CAAC,IAAI,CAAC,CAAC;SAClB;KACF;AACH,CAAC;AAED,UAAU,CAAC,cAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/generate-tasks.d.ts b/node_modules/blake3-wasm/dist/build/generate-tasks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/generate-tasks.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/build/generate-tasks.js b/node_modules/blake3-wasm/dist/build/generate-tasks.js new file mode 100644 index 0000000000000000000000000000000000000000..bea411b8e5d8f9da9f227e0ba1be2495c1bd8246 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/generate-tasks.js @@ -0,0 +1,88 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs_1 = require("fs"); +const js_yaml_1 = require("js-yaml"); +const node_fetch_1 = __importDefault(require("node-fetch")); +const path_1 = require("path"); +const minVersion = 64; +(() => __awaiter(void 0, void 0, void 0, function* () { + const res = yield node_fetch_1.default('https://nodejs.org/dist/index.json'); + if (!res.ok) { + throw new Error(`${res.status} error from Node.js releases page`); + } + const releases = yield res.json(); + const buildVersion = new Map(); + const versionMap = {}; + for (const release of releases) { + const moduleVersion = Number(release.modules); + if (!moduleVersion || moduleVersion < minVersion) { + break; + } + versionMap[release.version] = Number(moduleVersion); + if (buildVersion.has(moduleVersion)) { + continue; + } + buildVersion.set(moduleVersion, release.version); + } + const buildYaml = { + name: 'Generate Binaries', + on: { + push: { + branches: ['generate-binary'], + }, + }, + jobs: { + build: { + name: 'Build', + 'runs-on': '${{ matrix.os }}', + strategy: { + matrix: { os: ['macos-latest', 'ubuntu-latest', 'windows-latest'] }, + }, + steps: [ + { uses: 'actions/checkout@master' }, + { run: 'mkdir dist' }, + { + uses: 'actions-rs/toolchain@v1', + with: { target: 'wasm32-unknown-unknown', toolchain: 'nightly' }, + }, + ...[...buildVersion.entries()] + .map(([moduleVersion, nodeVersion], i) => [ + { uses: 'actions/setup-node@v1', with: { 'node-version': nodeVersion } }, + { + // See: https://github.com/actions/setup-node/issues/68 + shell: 'powershell', + name: 'patch node-gyp for VS 2019', + run: 'npm install --global node-gyp@latest\r\nnpm prefix -g | % {npm config set node_gyp "$_\\node_modules\\node-gyp\\bin\\node-gyp.js"}', + if: "matrix.os == 'windows-latest'", + }, + i === 0 + ? { run: 'npm install neon-cli rimraf' } + : { run: './node_modules/.bin/rimraf rs/native/target' }, + { run: '../node_modules/.bin/neon build --release', 'working-directory': 'rs' }, + { run: `mv rs/native/index.node dist/\${{ matrix.os }}-${moduleVersion}.node` }, + ]) + .reduce((acc, v) => [...acc, ...v], []), + { + uses: 'actions/upload-artifact@v1', + with: { name: 'dist', path: 'dist' }, + }, + ], + }, + }, + }; + fs_1.writeFileSync(path_1.join(__dirname, '..', '..', '.github', 'workflows', 'build-neon.yml'), js_yaml_1.dump(buildYaml)); + fs_1.writeFileSync(path_1.join(__dirname, '..', '..', 'targets.json'), JSON.stringify(versionMap)); +}))(); +//# sourceMappingURL=generate-tasks.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/generate-tasks.js.map b/node_modules/blake3-wasm/dist/build/generate-tasks.js.map new file mode 100644 index 0000000000000000000000000000000000000000..908f629659ec19c357c3fbc3f321eda9d64dbaf2 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/generate-tasks.js.map @@ -0,0 +1 @@ +{"version":3,"file":"generate-tasks.js","sourceRoot":"","sources":["../../ts/build/generate-tasks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2BAAmC;AACnC,qCAA+B;AAC/B,4DAA+B;AAC/B,+BAA4B;AAE5B,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,CAAC,GAAS,EAAE;IACV,MAAM,GAAG,GAAG,MAAM,oBAAK,CAAC,oCAAoC,CAAC,CAAC;IAC9D,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,mCAAmC,CAAC,CAAC;KACnE;IAED,MAAM,QAAQ,GAA2C,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1E,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC/C,MAAM,UAAU,GAA8B,EAAE,CAAC;IACjD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,aAAa,IAAI,aAAa,GAAG,UAAU,EAAE;YAChD,MAAM;SACP;QAED,UAAU,CA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EAAE,6CAA6C,EAAE;wBAC1D,EAAE,GAAG,EAAE,2CAA2C,EAAE,mBAAmB,EAAE,IAAI,EAAE;wBAC/E,EAAE,GAAG,EAAE,kDAAkD,aAAa,OAAO,EAAE;qBAChF,CAAC;yBACD,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;oBACzC;wBACE,IAAI,EAAE,4BAA4B;wBAClC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;qBACrC;iBACF;aACF;SACF;KACF,CAAC;IAEF,kBAAa,CACX,WAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,CAAC,EACrE,cAAI,CAAC,SAAS,CAAC,CAChB,CAAC;IACF,kBAAa,CAAC,WAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AACzF,CAAC,CAAA,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/install.d.ts b/node_modules/blake3-wasm/dist/build/install.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/install.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/build/install.js b/node_modules/blake3-wasm/dist/build/install.js new file mode 100644 index 0000000000000000000000000000000000000000..20fe5f0fa115fc8101c6687e19c2835c65204788 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/install.js @@ -0,0 +1,100 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs_1 = require("fs"); +const https_1 = require("https"); +const path_1 = require("path"); +const stream_1 = require("stream"); +const versions_1 = require("./versions"); +/** + * Post-install script. Downloads the binary for the current Node.js version + * from the Gitub releases page, if it's available. + */ +const builtPlatforms = { + win32: 'windows-latest', + linux: 'ubuntu-latest', + darwin: 'macos-latest', +}; +const { version } = require('../../package.json'); +const repoUrl = process.env.BLAKE3_REPO_URL || 'https://github.com/connor4312/blake3'; +const targets = require('../../targets.json'); +const bindingPath = path_1.join(__dirname, '..', 'native.node'); +function install() { + return __awaiter(this, void 0, void 0, function* () { + const current = versions_1.parseVersion(process.version); + const api = getBestAbiVersion(current); + if (!api) { + console.error('Your Node.js release is out of LTS and BLAKE3 bindings are not built for it. Update it to use native BLAKE3 bindings.'); + return fallback(); + } + const platform = builtPlatforms[process.platform]; + if (!platform) { + console.error(`BLAKE3 bindings are not built for your platform (${process.platform})`); + return fallback(); + } + console.log(`Retrieving native BLAKE3 bindings for Node ${api.nodeVersion} on ${process.platform}...`); + yield download(`${repoUrl}/releases/download/v${version}/${platform}-${api.abiVersion}.node`); + try { + require(bindingPath); + } + catch (e) { + console.log(`Error trying to import bindings: ${e.message}`); + return fallback(); + } + useNativeImport(); + console.log('BLAKE3 bindings retrieved'); + }); +} +function getBestAbiVersion(current) { + for (const targetVersion of Object.keys(targets)) { + const parsed = versions_1.parseVersion(targetVersion); + if (versions_1.compareVersion(current, parsed) >= 0) { + return { nodeVersion: targetVersion, abiVersion: targets[targetVersion] }; + } + } + return undefined; +} +function fallback() { + console.error('BLAKE3 will use slower WebAssembly bindings when required in Node.js'); +} +function download(url) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise(resolve => { + const onError = (err) => { + console.error(`Could not download binding from ${url}: ${err.stack || err.message}`); + resolve(false); + }; + const req = https_1.get(url, res => { + if (res.headers.location) { + resolve(download(res.headers.location)); + return; + } + if (!res.statusCode || res.statusCode >= 300) { + console.error(`Unexpected ${res.statusCode} from ${url}`); + resolve(false); + return; + } + stream_1.pipeline(res, fs_1.createWriteStream(bindingPath), err => (err ? onError(err) : resolve(true))); + }); + req.on('error', onError); + }); + }); +} +function useNativeImport() { + const indexFile = path_1.join(__dirname, '..', 'index.js'); + const contents = fs_1.readFileSync(indexFile, 'utf-8'); + fs_1.writeFileSync(indexFile, contents.replace('"./node"', '"./node-native"')); +} +install().catch(err => { + console.error(`There was an uncaught error installing native bindings: ${err.stack}`); + fallback(); +}); +//# sourceMappingURL=install.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/install.js.map b/node_modules/blake3-wasm/dist/build/install.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3bf335be396d892a7a984652c4e97d7ce930b3a5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/install.js.map @@ -0,0 +1 @@ +{"version":3,"file":"install.js","sourceRoot":"","sources":["../../ts/build/install.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2BAAoE;AACpE,iCAA4B;AAC5B,+BAA4B;AAC5B,mCAAkC;AAClC,yCAAoE;AAEpE;;;GAGG;AAEH,MAAM,cAAc,GAAwC;IAC1D,KAAK,EAAE,gBAAgB;IACvB,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,cAAc;CACvB,CAAC;AAEF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,sCAAsC,CAAC;AACtF,MAAM,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC9C,MAAM,WAAW,GAAG,WAAI,CAAC,SAA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C;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAED,SAAS,eAAe;IACtB,MAAM,SAAS,GAAG,WAAI,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,iBAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClD,kBAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACpB,OAAO,CAAC,KAAK,CAAC,2DAA2D,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;IACtF,QAAQ,EAAE,CAAC;AACb,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/versions.d.ts b/node_modules/blake3-wasm/dist/build/versions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..17d98415f31576e8d3aa5e8d161a7fbed71cff0b --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/versions.d.ts @@ -0,0 +1,14 @@ +export declare const minNodeVersion = 10; +/** + * @hidden + */ +export interface IVersion { + major: number; + minor: number; + patch: number; +} +/** + * @hidden + */ +export declare const parseVersion: (version: string) => IVersion; +export declare const compareVersion: (a: IVersion, b: IVersion) => number; diff --git a/node_modules/blake3-wasm/dist/build/versions.js b/node_modules/blake3-wasm/dist/build/versions.js new file mode 100644 index 0000000000000000000000000000000000000000..e97f1afdb2032a83765bc3092a8fc494a45a429a --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/versions.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.minNodeVersion = 10; +/** + * @hidden + */ +exports.parseVersion = (version) => { + const [, major, minor, patch] = /^v([0-9]+)\.([0-9]+)\.([0-9]+)/.exec(version) || []; + return { major: Number(major), minor: Number(minor), patch: Number(patch) }; +}; +exports.compareVersion = (a, b) => a.major - b.major || a.minor - b.minor || a.patch - b.patch; +//# sourceMappingURL=versions.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/versions.js.map b/node_modules/blake3-wasm/dist/build/versions.js.map new file mode 100644 index 0000000000000000000000000000000000000000..74900e044686ace1a89270d409c6fe1707864c5a --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/versions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../ts/build/versions.ts"],"names":[],"mappings":";;AAAa,QAAA,cAAc,GAAG,EAAE,CAAC;AAWjC;;GAEG;AACU,QAAA,YAAY,GAAG,CAAC,OAAe,EAAY,EAAE;IACxD,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,gCAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACrF,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC9E,CAAC,CAAC;AAEW,QAAA,cAAc,GAAG,CAAC,CAAW,EAAE,CAAW,EAAE,EAAE,CACzD,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/index.d.ts b/node_modules/blake3-wasm/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0dddb69c011f6c534050580097bb28d927fad16 --- /dev/null +++ b/node_modules/blake3-wasm/dist/index.d.ts @@ -0,0 +1 @@ +export * from './node'; diff --git a/node_modules/blake3-wasm/dist/index.js b/node_modules/blake3-wasm/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3834342827de2a5b87c914467070165c1d91b733 --- /dev/null +++ b/node_modules/blake3-wasm/dist/index.js @@ -0,0 +1,19 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +// Bunlers add the `process.browser` flag to indicate the build enviroment. +// Throw a verbose error if we see people bundling the Node.js build in their +// browser, since it probably won't work for them (or at least not give them) +// nice tree shaking and such. +// +// Note that we don't check the presence of window/document, since those can +// be emulated in common test scenarios (e.g. jest's default setup with jsdom). +if (process.browser) { + throw new Error('You tried to import the Node.js version of blake3, instead of the browser ' + + 'version, in your build. You can fix this by importing "blake3/browser" ' + + 'instead of "blake3"'); +} +__export(require("./node")); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/index.js.map b/node_modules/blake3-wasm/dist/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8c9776bb2b7eeba02d0c68b24aad77e18eb0beaf --- /dev/null +++ b/node_modules/blake3-wasm/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,8BAA8B;AAC9B,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,IAAK,OAAe,CAAC,OAAO,EAAE;IAC5B,MAAM,IAAI,KAAK,CACb,4EAA4E;QAC1E,yEAAyE;QACzE,qBAAqB,CACxB,CAAC;CACH;AAED,4BAAuB"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node-native/hash-fn.d.ts b/node_modules/blake3-wasm/dist/node-native/hash-fn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..573cb22c7d1688ec38c55ea4df1a7aab2b761da8 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/hash-fn.d.ts @@ -0,0 +1,21 @@ +/// +import { HashInput } from '../node/hash-fn'; +import { IBaseHashOptions } from '../base/hash-fn'; +/** + * @hidden + */ +export declare const normalizeInput: (input: HashInput, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Buffer; +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +export declare function hash(input: HashInput, { length }?: IBaseHashOptions): Buffer | string; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Buffer; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export declare function keyedHash(key: Buffer, input: HashInput, { length }?: IBaseHashOptions): Buffer; diff --git a/node_modules/blake3-wasm/dist/node-native/hash-fn.js b/node_modules/blake3-wasm/dist/node-native/hash-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..5281988994dafaa0f30b04bf50f2818cf8e29749 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/hash-fn.js @@ -0,0 +1,51 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const native_1 = __importDefault(require("./native")); +const hash_fn_1 = require("../base/hash-fn"); +/** + * @hidden + */ +exports.normalizeInput = (input, encoding) => { + if (input instanceof Buffer) { + return input; + } + if (typeof input === 'string') { + return Buffer.from(input, encoding); + } + return Buffer.from(input); +}; +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +function hash(input, { length = hash_fn_1.defaultHashLength } = {}) { + return native_1.default.hash(exports.normalizeInput(input), length); +} +exports.hash = hash; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +function deriveKey(context, material, { length = hash_fn_1.defaultHashLength } = {}) { + const hasher = new native_1.default.Hasher(undefined, context); + hasher.update(exports.normalizeInput(material)); + const result = Buffer.alloc(length); + hasher.digest(result); + return result; +} +exports.deriveKey = deriveKey; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +function keyedHash(key, input, { length = hash_fn_1.defaultHashLength } = {}) { + const hasher = new native_1.default.Hasher(key); + hasher.update(exports.normalizeInput(input)); + const result = Buffer.alloc(length); + hasher.digest(result); + return result; +} +exports.keyedHash = keyedHash; +//# sourceMappingURL=hash-fn.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node-native/hash-fn.js.map b/node_modules/blake3-wasm/dist/node-native/hash-fn.js.map new file mode 100644 index 0000000000000000000000000000000000000000..794f5b3e4d0be4b7e6aeefebcb0ebf7a9d1f7e6a --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/node-native/hash-fn.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAE9B,6CAAsE;AAEtE;;GAEG;AACU,QAAA,cAAc,GAAG,CAAC,KAAgB,EAAE,QAAyB,EAAU,EAAE;IACpF,IAAI,KAAK,YAAY,MAAM,EAAE;QAC3B,OAAO,KAAK,CAAC;KACd;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;KACrC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,KAAmB,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF;;GAEG;AACH,SAAgB,IAAI,CAClB,KAAgB,EAChB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,OAAO,gBAAM,CAAC,IAAI,CAAC,sBAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AALD,oBAKC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CACvB,OAAe,EACf,QAAmB,EACnB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,8BAUC;AAED;;GAEG;AACH,SAAgB,SAAS,CACvB,GAAW,EACX,KAAgB,EAChB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,8BAUC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node-native/hash-instance.d.ts b/node_modules/blake3-wasm/dist/node-native/hash-instance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f1d97ba18574b1e7f833c8b30f45494f25fe927c --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/hash-instance.d.ts @@ -0,0 +1,15 @@ +/// +import { INativeReader } from './native'; +import { NodeHash } from '../node/hash-instance'; +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => NodeHash; +/** + * Construct a new Hasher for the keyed hash function. + */ +export declare const createKeyed: (key: Buffer) => NodeHash; +/** + * Construct a new Hasher for the key derivation function. + */ +export declare const createDeriveKey: (context: string) => NodeHash; diff --git a/node_modules/blake3-wasm/dist/node-native/hash-instance.js b/node_modules/blake3-wasm/dist/node-native/hash-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..cd30204923eaa1e9414cd40f0716595a2a62c33f --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/hash-instance.js @@ -0,0 +1,31 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const native_1 = __importDefault(require("./native")); +const hash_instance_1 = require("../node/hash-instance"); +const hash_reader_1 = require("../node/hash-reader"); +// A buffer we reuse for sending bigints. set_position is synchronous, so +// this just saves creating garbage. +const bigIntBuffer = Buffer.alloc(8); +const readerFactory = (r) => new hash_reader_1.NodeHashReader({ + fill: target => r.fill(target), + set_position: position => { + bigIntBuffer.writeBigUInt64BE(position); + r.set_position(bigIntBuffer); + }, +}); +/** + * A Node.js crypto-like createHash method. + */ +exports.createHash = () => new hash_instance_1.NodeHash(new native_1.default.Hasher(), readerFactory); +/** + * Construct a new Hasher for the keyed hash function. + */ +exports.createKeyed = (key) => new hash_instance_1.NodeHash(new native_1.default.Hasher(key), readerFactory); +/** + * Construct a new Hasher for the key derivation function. + */ +exports.createDeriveKey = (context) => new hash_instance_1.NodeHash(new native_1.default.Hasher(undefined, context), readerFactory); +//# sourceMappingURL=hash-instance.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node-native/hash-instance.js.map b/node_modules/blake3-wasm/dist/node-native/hash-instance.js.map new file mode 100644 index 0000000000000000000000000000000000000000..cd20ddf7f8269c194e201b2395c61728f0ddf360 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/node-native/hash-instance.ts"],"names":[],"mappings":";;;;;AAAA,sDAAiD;AACjD,yDAAiD;AACjD,qDAAqD;AAErD,yEAAyE;AACzE,oCAAoC;AACpC,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAErC,MAAM,aAAa,GAAG,CAAC,CAAgB,EAAE,EAAE,CACzC,IAAI,4BAAc,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B,YAAY,EAAE,QAAQ,CAAC,EAAE;QACvB,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC,CAAC;AAEL;;GAEG;AACU,QAAA,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,wBAAQ,CAAC,IAAI,gBAAM,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC;AAEjF;;GAEG;AACU,QAAA,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,wBAAQ,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;AAEhG;;GAEG;AACU,QAAA,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CACjD,IAAI,wBAAQ,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node-native/index.d.ts b/node_modules/blake3-wasm/dist/node-native/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e37c80edc011842f54de2497496ce1c7793c7fd5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/index.d.ts @@ -0,0 +1,5 @@ +export { HashInput } from '../node/hash-fn'; +export { hash, deriveKey, keyedHash } from './hash-fn'; +export * from '../node/hash-reader'; +export * from './hash-instance'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/dist/node-native/index.js b/node_modules/blake3-wasm/dist/node-native/index.js new file mode 100644 index 0000000000000000000000000000000000000000..defe1dc7bd750779af73f3f2d687bc713ee82b47 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/index.js @@ -0,0 +1,13 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +var hash_fn_1 = require("./hash-fn"); +exports.hash = hash_fn_1.hash; +exports.deriveKey = hash_fn_1.deriveKey; +exports.keyedHash = hash_fn_1.keyedHash; +__export(require("../node/hash-reader")); +__export(require("./hash-instance")); +__export(require("../base/index")); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node-native/index.js.map b/node_modules/blake3-wasm/dist/node-native/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..95a404fd9fc52db7e1e6c0861efd222ee0709427 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/node-native/index.ts"],"names":[],"mappings":";;;;;AACA,qCAAuD;AAA9C,yBAAA,IAAI,CAAA;AAAE,8BAAA,SAAS,CAAA;AAAE,8BAAA,SAAS,CAAA;AACnC,yCAAoC;AACpC,qCAAgC;AAChC,mCAA8B"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node-native/native.d.ts b/node_modules/blake3-wasm/dist/node-native/native.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..be1a909d730fa530b70eb85390929bd02bf4a9d4 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/native.d.ts @@ -0,0 +1,16 @@ +/// +import { IInternalHash } from '../base/index'; +export interface INativeReader { + free?(): void; + fill(target: Uint8Array): void; + set_position(position: Buffer): void; +} +export interface INativeHash extends IInternalHash { + new (hashKey?: Buffer, context?: string): INativeHash; +} +export interface INativeModule { + Hasher: INativeHash; + hash(input: Buffer, length: number): Buffer; +} +declare const native: INativeModule; +export default native; diff --git a/node_modules/blake3-wasm/dist/node-native/native.js b/node_modules/blake3-wasm/dist/node-native/native.js new file mode 100644 index 0000000000000000000000000000000000000000..47d4173fbd95ba25f4d4e2c7b26fda9fbb6cac94 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/native.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const native = require('../native.node'); +exports.default = native; +//# sourceMappingURL=native.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node-native/native.js.map b/node_modules/blake3-wasm/dist/node-native/native.js.map new file mode 100644 index 0000000000000000000000000000000000000000..545e1efc0502296ee947dc3e74053127f2f627cc --- /dev/null +++ b/node_modules/blake3-wasm/dist/node-native/native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"native.js","sourceRoot":"","sources":["../../ts/node-native/native.ts"],"names":[],"mappings":";;AAiBA,MAAM,MAAM,GAAkB,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAExD,kBAAe,MAAM,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node.test.d.ts b/node_modules/blake3-wasm/dist/node.test.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/dist/node.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/node.test.js b/node_modules/blake3-wasm/dist/node.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c368975bc28d361889e9a358464a91389fb95246 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node.test.js @@ -0,0 +1,207 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const wasm = __importStar(require("./node")); +const native = __importStar(require("./node-native")); +const chai_1 = require("chai"); +const test_helpers_1 = require("./base/test-helpers"); +const stream_buffers_1 = require("stream-buffers"); +const hash_reader_1 = require("./base/hash-reader"); +function suite({ hash, createHash, keyedHash, deriveKey, createDeriveKey, createKeyed, }) { + describe('encoding', () => { + it('hashes a buffer', () => { + chai_1.expect(hash(Buffer.from(test_helpers_1.inputs.hello.input))).to.deep.equal(test_helpers_1.inputs.hello.hash); + }); + it('hashes a string', () => { + chai_1.expect(hash(test_helpers_1.inputs.hello.input)).to.deep.equal(test_helpers_1.inputs.hello.hash); + }); + it('hashes an arraybuffer', () => { + const buf = Buffer.from(test_helpers_1.inputs.hello.input); + chai_1.expect(hash(new Uint8Array(buf).buffer)).to.deep.equal(test_helpers_1.inputs.hello.hash); + }); + it('customizes the output length', () => { + chai_1.expect(hash(test_helpers_1.inputs.hello.input, { length: 16 })).to.deep.equal(test_helpers_1.inputs.hello.hash.slice(0, 16)); + }); + }); + describe('memory-safety (#5)', () => { + it('hash', () => { + const hashA = hash('hello'); + const hashB = hash('goodbye'); + chai_1.expect(hashA.toString('hex')).to.equal('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f'); + chai_1.expect(hashB.toString('hex')).to.equal('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69'); + }); + it('hasher', () => { + const hasherA = createHash(); + const hasherB = createHash(); + hasherA.update('hel'); + hasherB.update('good'); + hasherA.update('lo'); + hasherB.update('bye'); + const hashA = hasherA.digest(); + const hashB = hasherB.digest(); + chai_1.expect(hashA.toString('hex')).to.equal('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f'); + chai_1.expect(hashB.toString('hex')).to.equal('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69'); + }); + }); + describe('hasher', () => { + it('digests', callback => { + const buffer = new stream_buffers_1.ReadableStreamBuffer(); + buffer.put(Buffer.from(test_helpers_1.inputs.large.input)); + buffer.stop(); + const hash = createHash(); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest(); + chai_1.expect(actual).to.deep.equal(test_helpers_1.inputs.large.hash); + callback(); + }); + }); + it('is a transform stream', callback => { + const buffer = new stream_buffers_1.ReadableStreamBuffer(); + buffer.put(Buffer.from(test_helpers_1.inputs.large.input)); + buffer.stop(); + buffer + .pipe(createHash()) + .on('error', callback) + .on('data', hash => { + chai_1.expect(hash).to.deep.equal(test_helpers_1.inputs.large.hash); + callback(); + }); + }); + it('customizes the output length', () => { + const hash = createHash(); + hash.update(test_helpers_1.inputs.hello.input); + chai_1.expect(hash.digest('hex', { length: 16 })).to.equal(test_helpers_1.inputs.hello.hash.slice(0, 16).toString('hex')); + }); + it('throws on write after dispose', () => { + const hash = createHash(); + hash.dispose(); + chai_1.expect(() => hash.update('')).to.throw(/after dispose/); + }); + it('allows taking incremental hashes', () => { + const hasher = createHash(); + hasher.update('hel'); + const hashA = hasher.digest(undefined, { dispose: false }); + const readA = hasher.reader({ dispose: false }); + hasher.update('lo'); + const hashB = hasher.digest(undefined, { dispose: false }); + const readB = hasher.reader({ dispose: false }); + const expectedA = Buffer.from('3121c5bb1b9193123447ac7cfda042f67f967e7a8cf5c12e7570e25529746e4a', 'hex'); + chai_1.expect(hashA).to.deep.equal(expectedA); + chai_1.expect(readA.toBuffer()).to.deep.equal(expectedA); + chai_1.expect(hashB).to.deep.equal(test_helpers_1.inputs.hello.hash); + chai_1.expect(readB.toBuffer()).to.deep.equal(test_helpers_1.inputs.hello.hash); + hasher.dispose(); + readA.dispose(); + readB.dispose(); + }); + }); + describe('reader', () => { + let reader; + beforeEach(() => { + const hash = createHash(); + hash.update(test_helpers_1.inputs.hello.input); + reader = hash.reader(); + }); + afterEach(() => reader.dispose()); + it('implements toString()', () => { + chai_1.expect(reader.toString('hex')).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + reader.position = BigInt(42); + chai_1.expect(reader.toString('hex')).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + }); + it('implements toBuffer()', () => { + chai_1.expect(reader.toBuffer()).to.deep.equal(test_helpers_1.inputs.hello.hash); + reader.position = BigInt(42); + chai_1.expect(reader.toBuffer()).to.deep.equal(test_helpers_1.inputs.hello.hash); + }); + it('implements readInto() and advances', () => { + const actual = Buffer.alloc(32); + reader.readInto(actual.slice(0, 10)); + reader.readInto(actual.slice(10)); + chai_1.expect(actual).to.deep.equal(test_helpers_1.inputs.hello.hash); + chai_1.expect(reader.position).to.equal(BigInt(32)); + }); + it('implements read() and advances', () => { + const actual = reader.read(32); + chai_1.expect(actual).to.deep.equal(test_helpers_1.inputs.hello.hash); + chai_1.expect(reader.position).to.equal(BigInt(32)); + const actualNext = reader.read(16); + chai_1.expect(actualNext).to.deep.equal(test_helpers_1.hello48.slice(32)); + chai_1.expect(reader.position).to.equal(BigInt(48)); + }); + it('manually sets position', () => { + reader.position = BigInt(32); + const actual = reader.read(16); + chai_1.expect(actual).to.deep.equal(test_helpers_1.hello48.slice(32)); + }); + it('throws if set out of range', () => { + chai_1.expect(() => (reader.position = BigInt(-1))).to.throw(RangeError); + chai_1.expect(() => (reader.position = BigInt('18446744073709551616'))).to.throw(RangeError); + reader.position = hash_reader_1.maxHashBytes - BigInt(1); + chai_1.expect(() => reader.read(2)).to.throw(RangeError); + }); + }); + describe('original test vectors', () => { + for (const { inputLen, expectedDerive, expectedKeyed, expectedHash } of test_helpers_1.ogTestVectors.cases) { + describe(`${inputLen}`, () => __awaiter(this, void 0, void 0, function* () { + const input = Buffer.alloc(inputLen); + for (let i = 0; i < inputLen; i++) { + input[i] = i % 251; + } + it('hash()', () => { + chai_1.expect(hash(input, { length: expectedHash.length / 2 }).toString('hex')).to.equal(expectedHash); + }); + it('deriveKey()', () => { + chai_1.expect(deriveKey(test_helpers_1.ogTestVectors.context, input, { length: expectedDerive.length / 2 }).toString('hex')).to.equal(expectedDerive); + }); + it('createDeriveKey()', callback => { + const buffer = new stream_buffers_1.ReadableStreamBuffer(); + buffer.put(Buffer.from(input)); + buffer.stop(); + const hash = createDeriveKey(test_helpers_1.ogTestVectors.context); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest({ length: expectedDerive.length / 2 }).toString('hex'); + chai_1.expect(actual).to.equal(expectedDerive); + callback(); + }); + }); + it('keyedHash()', () => { + chai_1.expect(keyedHash(Buffer.from(test_helpers_1.ogTestVectors.key), input, { + length: expectedKeyed.length / 2, + }).toString('hex')).to.equal(expectedKeyed); + }); + it('createKeyed()', callback => { + const buffer = new stream_buffers_1.ReadableStreamBuffer(); + buffer.put(Buffer.from(input)); + buffer.stop(); + const hash = createKeyed(Buffer.from(test_helpers_1.ogTestVectors.key)); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest({ length: expectedDerive.length / 2 }).toString('hex'); + chai_1.expect(actual).to.equal(expectedKeyed); + callback(); + }); + }); + })); + } + }); +} +describe('node.js wasm', () => suite(wasm)); +describe('node.js native', () => suite(native)); +//# sourceMappingURL=node.test.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node.test.js.map b/node_modules/blake3-wasm/dist/node.test.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6afab0a83aad323616eff1b7de2bccc35f4255b8 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"node.test.js","sourceRoot":"","sources":["../ts/node.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,sDAAwC;AACxC,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000000000000000000000000..33d792731c3092fb8d5138b050cf9b7ee68989c8 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-fn.d.ts @@ -0,0 +1,24 @@ +/// +import { BaseHashInput, IBaseHashOptions } from '../base/hash-fn'; +/** + * Input used for node-based hashes. + */ +export declare type HashInput = BaseHashInput | string; +/** + * @hidden + */ +export declare const normalizeInput: (input: HashInput, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Uint8Array; +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +export declare function hash(input: HashInput, { length }?: IBaseHashOptions): Buffer | string; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Buffer; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export declare function keyedHash(key: Buffer, input: HashInput, { length }?: IBaseHashOptions): Buffer; diff --git a/node_modules/blake3-wasm/dist/node/hash-fn.js b/node_modules/blake3-wasm/dist/node/hash-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..bad82b4cd2bb2c70c02f11c10b1c060c7aa1256e --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-fn.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_fn_1 = require("../base/hash-fn"); +const blake3_js_1 = require("../../dist/wasm/nodejs/blake3_js"); +/** + * @hidden + */ +exports.normalizeInput = (input, encoding) => hash_fn_1.inputToArray(typeof input === 'string' ? Buffer.from(input, encoding) : input); +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +function hash(input, { length = hash_fn_1.defaultHashLength } = {}) { + const result = Buffer.alloc(length); + blake3_js_1.hash(exports.normalizeInput(input), result); + return result; +} +exports.hash = hash; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +function deriveKey(context, material, { length = hash_fn_1.defaultHashLength } = {}) { + const derive = blake3_js_1.create_derive(context); + derive.update(exports.normalizeInput(material)); + const result = Buffer.alloc(length); + derive.digest(result); + return result; +} +exports.deriveKey = deriveKey; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +function keyedHash(key, input, { length = hash_fn_1.defaultHashLength } = {}) { + if (key.length !== 32) { + throw new Error(`key provided to keyedHash must be 32 bytes, got ${key.length}`); + } + const derive = blake3_js_1.create_keyed(key); + derive.update(exports.normalizeInput(input)); + const result = Buffer.alloc(length); + derive.digest(result); + return result; +} +exports.keyedHash = keyedHash; +//# sourceMappingURL=hash-fn.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-fn.js.map b/node_modules/blake3-wasm/dist/node/hash-fn.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9f8fc5025851108a9110f277cd1d09b8e8224150 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/node/hash-fn.ts"],"names":[],"mappings":";;AAAA,6CAAmG;AACnG,gEAI0C;AAO1C;;GAEG;AACU,QAAA,cAAc,GAAG,CAAC,KAAgB,EAAE,QAAyB,EAAc,EAAE,CACxF,sBAAY,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAEjF;;GAEG;AACH,SAAgB,IAAI,CAClB,KAAgB,EAChB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,gBAAO,CAAC,sBAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC;AAPD,oBAOC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CACvB,OAAe,EACf,QAAmB,EACnB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,yBAAY,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,8BAUC;AAED;;GAEG;AACH,SAAgB,SAAS,CACvB,GAAW,EACX,KAAgB,EAChB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClF;IAED,MAAM,MAAM,GAAG,wBAAW,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAdD,8BAcC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-instance.d.ts b/node_modules/blake3-wasm/dist/node/hash-instance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a72c9f90a420210905ec55b14d17af995f9625a --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-instance.d.ts @@ -0,0 +1,75 @@ +/// +import { HashInput } from './hash-fn'; +import { IHasher, IInternalHash, IHasherDigestOptions } from '../base/index'; +import { Transform, TransformCallback } from 'stream'; +import { IBaseHashOptions } from '../base/hash-fn'; +import { NodeHashReader } from './hash-reader'; +export interface INodeHash extends IHasher { + /** + * @inheritdoc + * @override + */ + update(data: HashInput, encoding?: BufferEncoding): this; + /** + * @inheritdoc + * @override + */ + digest(options?: IBaseHashOptions): Buffer; + /** + * Returns a digest of the hash with the given set of hash options. + */ + digest(encoding: undefined, options: IBaseHashOptions): Buffer; + /** + * Returns a digest of the hash with the given encoding. + */ + digest(encoding: BufferEncoding, options?: IBaseHashOptions): string; +} +/** + * @inheritdoc + */ +export declare class NodeHash extends Transform implements IHasher { + private readonly hash; + constructor(implementation: IInternalHash, getReader: (r: Reader) => NodeHashReader); + /** + * @reader + */ + reader(options?: { + dispose?: boolean; + }): NodeHashReader; + /** + * @inheritdoc + */ + update(data: HashInput, encoding?: BufferEncoding): this; + /** + * @inheritdoc + */ + digest(encoding?: IHasherDigestOptions): Buffer; + digest(encoding: undefined, options: IHasherDigestOptions): Buffer; + digest(encoding: BufferEncoding, options?: IHasherDigestOptions): string; + /** + * @inheritdoc + */ + dispose(): void; + /** + * @inheritdoc + * @hidden + */ + _transform(chunk: Buffer | string, encoding: string, callback: TransformCallback): void; + /** + * @inheritdoc + * @hidden + */ + _flush(callback: TransformCallback): void; +} +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => NodeHash; +/** + * Construct a new Hasher for the keyed hash function. + */ +export declare const createKeyed: (key: Buffer) => NodeHash; +/** + * Construct a new Hasher for the key derivation function. + */ +export declare const createDeriveKey: (context: string) => NodeHash; diff --git a/node_modules/blake3-wasm/dist/node/hash-instance.js b/node_modules/blake3-wasm/dist/node/hash-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..3598e0d90485eb041ff5b5f11830cd94dcd236de --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-instance.js @@ -0,0 +1,79 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_fn_1 = require("./hash-fn"); +const index_1 = require("../base/index"); +const stream_1 = require("stream"); +const wasm_1 = require("./wasm"); +const hash_reader_1 = require("./hash-reader"); +/** + * @inheritdoc + */ +class NodeHash extends stream_1.Transform { + constructor(implementation, getReader) { + super(); + this.hash = new index_1.BaseHash(implementation, l => Buffer.alloc(l), getReader); + } + /** + * @reader + */ + reader(options) { + const reader = this.hash.reader(options); + return reader; + } + /** + * @inheritdoc + */ + update(data, encoding) { + this.hash.update(hash_fn_1.normalizeInput(data, encoding)); + return this; + } + digest(encoding, options) { + let resolvedOpts; + let resolvedEnc; + if (encoding && typeof encoding === 'object') { + resolvedOpts = encoding; + resolvedEnc = undefined; + } + else { + resolvedOpts = options; + resolvedEnc = encoding; + } + const result = this.hash.digest(resolvedOpts); + return resolvedEnc ? result.toString(resolvedEnc) : result; + } + /** + * @inheritdoc + */ + dispose() { + this.hash.dispose(); + } + /** + * @inheritdoc + * @hidden + */ + _transform(chunk, encoding, callback) { + this.update(chunk, encoding); + callback(); + } + /** + * @inheritdoc + * @hidden + */ + _flush(callback) { + callback(null, this.digest()); + } +} +exports.NodeHash = NodeHash; +/** + * A Node.js crypto-like createHash method. + */ +exports.createHash = () => new NodeHash(wasm_1.getWasm().create_hasher(), r => new hash_reader_1.NodeHashReader(r)); +/** + * Construct a new Hasher for the keyed hash function. + */ +exports.createKeyed = (key) => new NodeHash(wasm_1.getWasm().create_keyed(key), r => new hash_reader_1.NodeHashReader(r)); +/** + * Construct a new Hasher for the key derivation function. + */ +exports.createDeriveKey = (context) => new NodeHash(wasm_1.getWasm().create_derive(context), r => new hash_reader_1.NodeHashReader(r)); +//# sourceMappingURL=hash-instance.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-instance.js.map b/node_modules/blake3-wasm/dist/node/hash-instance.js.map new file mode 100644 index 0000000000000000000000000000000000000000..568482b68a4bd5edb8caac77b7dce3a4cc3ef636 --- /dev/null +++ b/node_modules/blake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CAAC,MAAM,CAAC;IAC7D,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,KAAsB,EAAE,QAAgB,EAAE,QAA2B;QAC9E,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,QAA0B,CAAC,CAAC;QAC/C,QAAQ,EAAE,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAA2B;QAChC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAChC,CAAC;CACF;AAvED,4BAuEC;AAED;;GAEG;AACU,QAAA,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,cAAO,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,4BAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG;;GAEG;AACU,QAAA,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CACzC,IAAI,QAAQ,CAAC,cAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,4BAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE;;GAEG;AACU,QAAA,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CACjD,IAAI,QAAQ,CAAC,cAAO,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,4BAAc,CAAC,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-reader.d.ts b/node_modules/blake3-wasm/dist/node/hash-reader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f217f7d2136daf630a669e8ec8d65e6a87c46fff --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-reader.d.ts @@ -0,0 +1,16 @@ +/// +import { BaseHashReader } from '../base/hash-reader'; +/** + * A hash reader for WebAssembly targets. + */ +export declare class NodeHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding?: BufferEncoding): string; + /** + * Converts first 32 bytes of the hash to an array. + */ + toBuffer(): Buffer; + protected alloc(bytes: number): Buffer; +} diff --git a/node_modules/blake3-wasm/dist/node/hash-reader.js b/node_modules/blake3-wasm/dist/node/hash-reader.js new file mode 100644 index 0000000000000000000000000000000000000000..e5525e730dba453162147ca40b9007d1713ac84c --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-reader.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_reader_1 = require("../base/hash-reader"); +const hash_fn_1 = require("../base/hash-fn"); +/** + * A hash reader for WebAssembly targets. + */ +class NodeHashReader extends hash_reader_1.BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toBuffer().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toBuffer() { + this.position = BigInt(0); + return this.read(hash_fn_1.defaultHashLength); + } + alloc(bytes) { + return Buffer.alloc(bytes); + } +} +exports.NodeHashReader = NodeHashReader; +//# sourceMappingURL=hash-reader.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-reader.js.map b/node_modules/blake3-wasm/dist/node/hash-reader.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4ef5e836021b2e914f9341b4b7aaf60bdd353468 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/node/hash-reader.ts"],"names":[],"mappings":";;AAAA,qDAAqD;AACrD,6CAAoD;AAEpD;;GAEG;AACH,MAAa,cAAe,SAAQ,4BAAsB;IACxD;;OAEG;IACI,QAAQ,CAAC,WAA2B,KAAK;QAC9C,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,2BAAiB,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,KAAa;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AAnBD,wCAmBC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/index.d.ts b/node_modules/blake3-wasm/dist/node/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7cd09cc3ff28cf3ee158d148d73119f76265e017 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/index.d.ts @@ -0,0 +1,4 @@ +export { hash, deriveKey, keyedHash, HashInput } from './hash-fn'; +export * from './hash-instance'; +export * from './hash-reader'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/dist/node/index.js b/node_modules/blake3-wasm/dist/node/index.js new file mode 100644 index 0000000000000000000000000000000000000000..f3052fa813e0382302ce271c735afa93730754d3 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/index.js @@ -0,0 +1,13 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +var hash_fn_1 = require("./hash-fn"); +exports.hash = hash_fn_1.hash; +exports.deriveKey = hash_fn_1.deriveKey; +exports.keyedHash = hash_fn_1.keyedHash; +__export(require("./hash-instance")); +__export(require("./hash-reader")); +__export(require("../base/index")); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/index.js.map b/node_modules/blake3-wasm/dist/node/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b156a6c2e713be56351f8283268521055bb9b21e --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/node/index.ts"],"names":[],"mappings":";;;;;AAAA,qCAAkE;AAAzD,yBAAA,IAAI,CAAA;AAAE,8BAAA,SAAS,CAAA;AAAE,8BAAA,SAAS,CAAA;AACnC,qCAAgC;AAChC,mCAA8B;AAC9B,mCAA8B"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/wasm.d.ts b/node_modules/blake3-wasm/dist/node/wasm.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..41e73fd9be7866665be2cfdbf46ff834e195d148 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/wasm.d.ts @@ -0,0 +1,6 @@ +import * as wasm from '../../dist/wasm/nodejs/blake3_js'; +/** + * Lazyily get the WebAssembly module. Used to avoid unnecessarily importing + * the wasm when extending the WebAssembly node code for native bindings. + */ +export declare const getWasm: () => typeof wasm; diff --git a/node_modules/blake3-wasm/dist/node/wasm.js b/node_modules/blake3-wasm/dist/node/wasm.js new file mode 100644 index 0000000000000000000000000000000000000000..9d4caa56da80d9ec9176183fb22beb1467aca70a --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/wasm.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let w; +/** + * Lazyily get the WebAssembly module. Used to avoid unnecessarily importing + * the wasm when extending the WebAssembly node code for native bindings. + */ +exports.getWasm = () => { + if (!w) { + w = require('../../dist/wasm/nodejs/blake3_js'); + } + return w; +}; +//# sourceMappingURL=wasm.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/wasm.js.map b/node_modules/blake3-wasm/dist/node/wasm.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3cf7b7f6d7f022df20d651971d47dab513264cbd --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/wasm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../ts/node/wasm.ts"],"names":[],"mappings":";;AAEA,IAAI,CAA0B,CAAC;AAE/B;;;GAGG;AACU,QAAA,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,CAAC,GAAG,OAAO,CAAC,kCAAkC,CAAgB,CAAC;KAChE;IAED,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.d.ts b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..963531ed72a25dc935d4d1b5b815fa17858f0fd7 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.d.ts @@ -0,0 +1,51 @@ +/* tslint:disable */ +/* eslint-disable */ +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +export function hash(data: Uint8Array, out: Uint8Array): void; +/** +* @returns {Blake3Hash} +*/ +export function create_hasher(): Blake3Hash; +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +export function create_keyed(key_slice: Uint8Array): Blake3Hash; +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +export function create_derive(context: string): Blake3Hash; +/** +*/ +export class Blake3Hash { + free(): void; +/** +* @returns {HashReader} +*/ + reader(): HashReader; +/** +* @param {Uint8Array} input_bytes +*/ + update(input_bytes: Uint8Array): void; +/** +* @param {Uint8Array} out +*/ + digest(out: Uint8Array): void; +} +/** +*/ +export class HashReader { + free(): void; +/** +* @param {Uint8Array} bytes +*/ + fill(bytes: Uint8Array): void; +/** +* @param {BigInt} position +*/ + set_position(position: BigInt): void; +} diff --git a/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.js b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.js new file mode 100644 index 0000000000000000000000000000000000000000..da7aaed2c3a1214fcc044534a053198c0c35e77d --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.js @@ -0,0 +1,2 @@ +import * as wasm from "./blake3_js_bg.wasm"; +export * from "./blake3_js_bg.js"; \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/browser/blake3_js_bg.wasm b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js_bg.wasm new file mode 100644 index 0000000000000000000000000000000000000000..cdb496e223465dfdd839198f06d566a1445c29a3 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js_bg.wasm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94f6042f9492e9ac3c9f8b93fdf05a3b43a757c303487beaed3ef1bcec5e977d +size 34398 diff --git a/node_modules/blake3-wasm/dist/wasm/browser/package.json b/node_modules/blake3-wasm/dist/wasm/browser/package.json new file mode 100644 index 0000000000000000000000000000000000000000..509802f9f293e6a1ec55299b7b4c9c1c58c3dadb --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/browser/package.json @@ -0,0 +1,12 @@ +{ + "name": "blake3-js", + "version": "0.1.0", + "files": [ + "blake3_js_bg.wasm", + "blake3_js.js", + "blake3_js.d.ts" + ], + "module": "blake3_js.js", + "types": "blake3_js.d.ts", + "sideEffects": false +} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.d.ts b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..963531ed72a25dc935d4d1b5b815fa17858f0fd7 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.d.ts @@ -0,0 +1,51 @@ +/* tslint:disable */ +/* eslint-disable */ +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +export function hash(data: Uint8Array, out: Uint8Array): void; +/** +* @returns {Blake3Hash} +*/ +export function create_hasher(): Blake3Hash; +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +export function create_keyed(key_slice: Uint8Array): Blake3Hash; +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +export function create_derive(context: string): Blake3Hash; +/** +*/ +export class Blake3Hash { + free(): void; +/** +* @returns {HashReader} +*/ + reader(): HashReader; +/** +* @param {Uint8Array} input_bytes +*/ + update(input_bytes: Uint8Array): void; +/** +* @param {Uint8Array} out +*/ + digest(out: Uint8Array): void; +} +/** +*/ +export class HashReader { + free(): void; +/** +* @param {Uint8Array} bytes +*/ + fill(bytes: Uint8Array): void; +/** +* @param {BigInt} position +*/ + set_position(position: BigInt): void; +} diff --git a/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.js b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.js new file mode 100644 index 0000000000000000000000000000000000000000..e655b33b4dc17fb39f8ae325b01a70de9c64579b --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.js @@ -0,0 +1,196 @@ +let imports = {}; +imports['__wbindgen_placeholder__'] = module.exports; +let wasm; +const { TextDecoder } = require(String.raw`util`); + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachegetUint8Memory0 = null; +function getUint8Memory0() { + if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { + cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachegetUint8Memory0; +} + +function getStringFromWasm0(ptr, len) { + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +let WASM_VECTOR_LEN = 0; + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1); + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +module.exports.hash = function(data, out) { + try { + var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + var ptr1 = passArray8ToWasm0(out, wasm.__wbindgen_malloc); + var len1 = WASM_VECTOR_LEN; + wasm.hash(ptr0, len0, ptr1, len1); + } finally { + out.set(getUint8Memory0().subarray(ptr1 / 1, ptr1 / 1 + len1)); + wasm.__wbindgen_free(ptr1, len1 * 1); + } +}; + +/** +* @returns {Blake3Hash} +*/ +module.exports.create_hasher = function() { + var ret = wasm.create_hasher(); + return Blake3Hash.__wrap(ret); +}; + +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +module.exports.create_keyed = function(key_slice) { + var ptr0 = passArray8ToWasm0(key_slice, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + var ret = wasm.create_keyed(ptr0, len0); + return Blake3Hash.__wrap(ret); +}; + +let cachegetNodeBufferMemory0 = null; +function getNodeBufferMemory0() { + if (cachegetNodeBufferMemory0 === null || cachegetNodeBufferMemory0.buffer !== wasm.memory.buffer) { + cachegetNodeBufferMemory0 = Buffer.from(wasm.memory.buffer); + } + return cachegetNodeBufferMemory0; +} + +function passStringToWasm0(arg, malloc) { + + const len = Buffer.byteLength(arg); + const ptr = malloc(len); + getNodeBufferMemory0().write(arg, ptr, len); + WASM_VECTOR_LEN = len; + return ptr; +} +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +module.exports.create_derive = function(context) { + var ptr0 = passStringToWasm0(context, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + var ret = wasm.create_derive(ptr0, len0); + return Blake3Hash.__wrap(ret); +}; + +const u32CvtShim = new Uint32Array(2); + +const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); +/** +*/ +class Blake3Hash { + + static __wrap(ptr) { + const obj = Object.create(Blake3Hash.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_blake3hash_free(ptr); + } + /** + * @returns {HashReader} + */ + reader() { + var ret = wasm.blake3hash_reader(this.ptr); + return HashReader.__wrap(ret); + } + /** + * @param {Uint8Array} input_bytes + */ + update(input_bytes) { + var ptr0 = passArray8ToWasm0(input_bytes, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.blake3hash_update(this.ptr, ptr0, len0); + } + /** + * @param {Uint8Array} out + */ + digest(out) { + try { + var ptr0 = passArray8ToWasm0(out, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.blake3hash_digest(this.ptr, ptr0, len0); + } finally { + out.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } +} +module.exports.Blake3Hash = Blake3Hash; +/** +*/ +class HashReader { + + static __wrap(ptr) { + const obj = Object.create(HashReader.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_hashreader_free(ptr); + } + /** + * @param {Uint8Array} bytes + */ + fill(bytes) { + try { + var ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.hashreader_fill(this.ptr, ptr0, len0); + } finally { + bytes.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } + /** + * @param {BigInt} position + */ + set_position(position) { + uint64CvtShim[0] = position; + const low0 = u32CvtShim[0]; + const high0 = u32CvtShim[1]; + wasm.hashreader_set_position(this.ptr, low0, high0); + } +} +module.exports.HashReader = HashReader; + +module.exports.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + +const path = require('path').join(__dirname, 'blake3_js_bg.wasm'); +const bytes = require('fs').readFileSync(path); + +const wasmModule = new WebAssembly.Module(bytes); +const wasmInstance = new WebAssembly.Instance(wasmModule, imports); +wasm = wasmInstance.exports; +module.exports.__wasm = wasm; + diff --git a/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js_bg.wasm b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js_bg.wasm new file mode 100644 index 0000000000000000000000000000000000000000..9f94146ee811f005c7bdbeef4730f7419cd25555 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js_bg.wasm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2dcc96fd2bd25392060d166e96cabbd2574cc1fedd32aa0233871c641c897c9f +size 34405 diff --git a/node_modules/blake3-wasm/dist/wasm/nodejs/package.json b/node_modules/blake3-wasm/dist/wasm/nodejs/package.json new file mode 100644 index 0000000000000000000000000000000000000000..18de4b54c4f1d27bc33153670892d0ce9f80b780 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/nodejs/package.json @@ -0,0 +1,12 @@ +{ + "name": "blake3-js", + "version": "0.1.0", + "files": [ + "blake3_js_bg.wasm", + "blake3_js.js", + "blake3_js_bg.js", + "blake3_js.d.ts" + ], + "main": "blake3_js.js", + "types": "blake3_js.d.ts" +} \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/web/blake3_js.d.ts b/node_modules/blake3-wasm/dist/wasm/web/blake3_js.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd566ed3396cb5c5e591b3f6206c032bfa80ace6 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/web/blake3_js.d.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +export function hash(data: Uint8Array, out: Uint8Array): void; +/** +* @returns {Blake3Hash} +*/ +export function create_hasher(): Blake3Hash; +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +export function create_keyed(key_slice: Uint8Array): Blake3Hash; +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +export function create_derive(context: string): Blake3Hash; +/** +*/ +export class Blake3Hash { + free(): void; +/** +* @returns {HashReader} +*/ + reader(): HashReader; +/** +* @param {Uint8Array} input_bytes +*/ + update(input_bytes: Uint8Array): void; +/** +* @param {Uint8Array} out +*/ + digest(out: Uint8Array): void; +} +/** +*/ +export class HashReader { + free(): void; +/** +* @param {Uint8Array} bytes +*/ + fill(bytes: Uint8Array): void; +/** +* @param {BigInt} position +*/ + set_position(position: BigInt): void; +} + +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; + +export interface InitOutput { + readonly memory: WebAssembly.Memory; + readonly hash: (a: number, b: number, c: number, d: number) => void; + readonly create_hasher: () => number; + readonly create_keyed: (a: number, b: number) => number; + readonly create_derive: (a: number, b: number) => number; + readonly __wbg_blake3hash_free: (a: number) => void; + readonly blake3hash_reader: (a: number) => number; + readonly blake3hash_update: (a: number, b: number, c: number) => void; + readonly blake3hash_digest: (a: number, b: number, c: number) => void; + readonly __wbg_hashreader_free: (a: number) => void; + readonly hashreader_fill: (a: number, b: number, c: number) => void; + readonly hashreader_set_position: (a: number, b: number, c: number) => void; + readonly __wbindgen_malloc: (a: number) => number; + readonly __wbindgen_free: (a: number, b: number) => void; + readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; +} + +/** +* If `module_or_path` is {RequestInfo} or {URL}, makes a request and +* for everything else, calls `WebAssembly.instantiate` directly. +* +* @param {InitInput | Promise} module_or_path +* +* @returns {Promise} +*/ +export default function init (module_or_path?: InitInput | Promise): Promise; + \ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/web/blake3_js.js b/node_modules/blake3-wasm/dist/wasm/web/blake3_js.js new file mode 100644 index 0000000000000000000000000000000000000000..4fa37747aa8b61fa8f29736871ec2c8d38ffcb3d --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/web/blake3_js.js @@ -0,0 +1,273 @@ + +let wasm; + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachegetUint8Memory0 = null; +function getUint8Memory0() { + if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { + cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachegetUint8Memory0; +} + +function getStringFromWasm0(ptr, len) { + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +let WASM_VECTOR_LEN = 0; + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1); + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +export function hash(data, out) { + try { + var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + var ptr1 = passArray8ToWasm0(out, wasm.__wbindgen_malloc); + var len1 = WASM_VECTOR_LEN; + wasm.hash(ptr0, len0, ptr1, len1); + } finally { + out.set(getUint8Memory0().subarray(ptr1 / 1, ptr1 / 1 + len1)); + wasm.__wbindgen_free(ptr1, len1 * 1); + } +} + +/** +* @returns {Blake3Hash} +*/ +export function create_hasher() { + var ret = wasm.create_hasher(); + return Blake3Hash.__wrap(ret); +} + +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +export function create_keyed(key_slice) { + var ptr0 = passArray8ToWasm0(key_slice, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + var ret = wasm.create_keyed(ptr0, len0); + return Blake3Hash.__wrap(ret); +} + +let cachedTextEncoder = new TextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length); + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len); + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3); + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +export function create_derive(context) { + var ptr0 = passStringToWasm0(context, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + var ret = wasm.create_derive(ptr0, len0); + return Blake3Hash.__wrap(ret); +} + +const u32CvtShim = new Uint32Array(2); + +const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); +/** +*/ +export class Blake3Hash { + + static __wrap(ptr) { + const obj = Object.create(Blake3Hash.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_blake3hash_free(ptr); + } + /** + * @returns {HashReader} + */ + reader() { + var ret = wasm.blake3hash_reader(this.ptr); + return HashReader.__wrap(ret); + } + /** + * @param {Uint8Array} input_bytes + */ + update(input_bytes) { + var ptr0 = passArray8ToWasm0(input_bytes, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.blake3hash_update(this.ptr, ptr0, len0); + } + /** + * @param {Uint8Array} out + */ + digest(out) { + try { + var ptr0 = passArray8ToWasm0(out, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.blake3hash_digest(this.ptr, ptr0, len0); + } finally { + out.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } +} +/** +*/ +export class HashReader { + + static __wrap(ptr) { + const obj = Object.create(HashReader.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_hashreader_free(ptr); + } + /** + * @param {Uint8Array} bytes + */ + fill(bytes) { + try { + var ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.hashreader_fill(this.ptr, ptr0, len0); + } finally { + bytes.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } + /** + * @param {BigInt} position + */ + set_position(position) { + uint64CvtShim[0] = position; + const low0 = u32CvtShim[0]; + const high0 = u32CvtShim[1]; + wasm.hashreader_set_position(this.ptr, low0, high0); + } +} + +async function load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +async function init(input) { + if (typeof input === 'undefined') { + input = import.meta.url.replace(/\.js$/, '_bg.wasm'); + } + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + const { instance, module } = await load(await input, imports); + + wasm = instance.exports; + init.__wbindgen_wasm_module = module; + + return wasm; +} + +export default init; + diff --git a/node_modules/blake3-wasm/dist/wasm/web/blake3_js_bg.wasm b/node_modules/blake3-wasm/dist/wasm/web/blake3_js_bg.wasm new file mode 100644 index 0000000000000000000000000000000000000000..6cd7814694d10eddfd822583025e1e9b0c143581 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/web/blake3_js_bg.wasm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:560ff7f4aad22343fdc6995df3145365974552f7ba9891456b83955ed9aa4cdb +size 34384 diff --git a/node_modules/blake3-wasm/dist/wasm/web/package.json b/node_modules/blake3-wasm/dist/wasm/web/package.json new file mode 100644 index 0000000000000000000000000000000000000000..509802f9f293e6a1ec55299b7b4c9c1c58c3dadb --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/web/package.json @@ -0,0 +1,12 @@ +{ + "name": "blake3-js", + "version": "0.1.0", + "files": [ + "blake3_js_bg.wasm", + "blake3_js.js", + "blake3_js.d.ts" + ], + "module": "blake3_js.js", + "types": "blake3_js.d.ts", + "sideEffects": false +} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/disposable.d.ts b/node_modules/blake3-wasm/esm/base/disposable.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..27db792d3e03aec761e99675e56bf7ba844a7ce0 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.d.ts @@ -0,0 +1,17 @@ +/** + * A type which requires manual disposal to free unmanaged resources. In the + * context of this library, this usually means freeing memory from WebAssembly + * code. + */ +export interface IDisposable { + /** + * Frees unmanaged resources of the object. This method is idempotent; + * calling it multiple times will have no ill effects. + */ + dispose(): void; +} +/** + * A helper function that calls `.dispose()` on the {@link IDisposable} when + * the given function (or promise returned by the function) returns. + */ +export declare const using: (disposable: D, fn: (d: D) => T) => T; diff --git a/node_modules/blake3-wasm/esm/base/disposable.js b/node_modules/blake3-wasm/esm/base/disposable.js new file mode 100644 index 0000000000000000000000000000000000000000..f10f7829ddd866db0aecd71dc4e1952f9664d32e --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.js @@ -0,0 +1,27 @@ +const isPromiseLike = (value) => typeof value === 'object' && !!value && 'then' in value; +/** + * A helper function that calls `.dispose()` on the {@link IDisposable} when + * the given function (or promise returned by the function) returns. + */ +export const using = (disposable, fn) => { + let ret; + try { + ret = fn(disposable); + } + catch (e) { + disposable.dispose(); + throw e; + } + if (!isPromiseLike(ret)) { + disposable.dispose(); + return ret; + } + return ret.then(value => { + disposable.dispose(); + return value; + }, err => { + disposable.dispose(); + throw err; + }); +}; +//# sourceMappingURL=disposable.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/disposable.js.map b/node_modules/blake3-wasm/esm/base/disposable.js.map new file mode 100644 index 0000000000000000000000000000000000000000..bf4fe9634c5a7b3cf624223c3a85062f994b698a --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"disposable.js","sourceRoot":"","sources":["../../ts/base/disposable.ts"],"names":[],"mappings":"AAaA,MAAM,aAAa,GAAG,CAAC,KAAc,EAAiC,EAAE,CACtE,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAA2B,UAAa,EAAE,EAAe,EAAK,EAAE;IACnF,IAAI,GAAmB,CAAC;IACxB,IAAI;QACF,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;KACtB;IAAC,OAAO,CAAC,EAAE;QACV,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,CAAC,CAAC;KACT;IAED,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE;QACvB,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC;KACZ;IAED,OAAQ,GAAG,CAAC,IAAI,CACd,KAAK,CAAC,EAAE;QACN,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC,EACD,GAAG,CAAC,EAAE;QACJ,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,GAAG,CAAC;IACZ,CAAC,CACe,CAAC;AACrB,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/disposable.test.d.ts b/node_modules/blake3-wasm/esm/base/disposable.test.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/base/disposable.test.js b/node_modules/blake3-wasm/esm/base/disposable.test.js new file mode 100644 index 0000000000000000000000000000000000000000..94175ba60ce319e44a15bcd5f674d5fc886d6ced --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.test.js @@ -0,0 +1,68 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { using } from '../node.js'; +import { expect } from 'chai.js'; +describe('disposable', () => { + describe('using', () => { + let disposed; + let disposable; + beforeEach(() => { + disposed = false; + disposable = { dispose: () => (disposed = true) }; + }); + it('disposes after sync call', () => { + const v = using(disposable, d => { + expect(d).to.equal(disposable); + expect(disposed).to.be.false; + return 42; + }); + expect(v).to.equal(42); + expect(disposed).to.be.true; + }); + it('disposes after sync throw', () => { + const err = new Error(); + try { + using(disposable, () => { + throw err; + }); + throw new Error('expected to throw'); + } + catch (e) { + expect(e).to.equal(err); + } + expect(disposed).to.be.true; + }); + it('disposes after promise resolve', () => __awaiter(void 0, void 0, void 0, function* () { + const v = yield using(disposable, () => __awaiter(void 0, void 0, void 0, function* () { + yield Promise.resolve(); + expect(disposed).to.be.false; + return 42; + })); + expect(v).to.equal(42); + expect(disposed).to.be.true; + })); + it('disposes after promise reject', () => __awaiter(void 0, void 0, void 0, function* () { + const err = new Error(); + try { + yield using(disposable, () => __awaiter(void 0, void 0, void 0, function* () { + yield Promise.resolve(); + expect(disposed).to.be.false; + throw err; + })); + throw new Error('expected to throw'); + } + catch (e) { + expect(e).to.equal(err); + } + expect(disposed).to.be.true; + })); + }); +}); +//# sourceMappingURL=disposable.test.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/disposable.test.js.map b/node_modules/blake3-wasm/esm/base/disposable.test.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a6879e715fe43e66c57871d25e37c6944e51161d --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"disposable.test.js","sourceRoot":"","sources":["../../ts/base/disposable.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAe,KAAK,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;QACrB,IAAI,QAAiB,CAAC;QACtB,IAAI,UAAuB,CAAC;QAC5B,UAAU,CAAC,GAAG,EAAE;YACd,QAAQ,GAAG,KAAK,CAAC;YACjB,UAAU,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;YAClC,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE;gBAC9B,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAC/B,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;gBAC7B,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KA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AC,OAAO,EAAE,CAAC;oBACxB,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;oBAC7B,MAAM,GAAG,CAAC;gBACZ,CAAC,CAAA,CAAC,CAAC;gBACH,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;aACtC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACzB;YAED,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAC9B,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-fn.d.ts b/node_modules/blake3-wasm/esm/base/hash-fn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b654a09709361ef8aa907d14a3a7f6c6fc8c488 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-fn.d.ts @@ -0,0 +1,23 @@ +/** + * Options passed to hash functions. + */ +export interface IBaseHashOptions { + /** + * Length of the desired hash, in bytes. Note that when encoding the output + * as a string, this is *not* the string length. + */ + length?: number; +} +/** + * Default hash length, in bytes, unless otherwise specified. + */ +export declare const defaultHashLength = 32; +/** + * A type that can be hashed. + */ +export declare type BaseHashInput = Uint8Array | ArrayBuffer | SharedArrayBuffer | ArrayLike; +/** + * Converts the input to an Uint8Array. + * @hidden + */ +export declare const inputToArray: (input: BaseHashInput) => Uint8Array; diff --git a/node_modules/blake3-wasm/esm/base/hash-fn.js b/node_modules/blake3-wasm/esm/base/hash-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..b017bae26b42c2c24c7d2decb3d6cad349c0a288 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-fn.js @@ -0,0 +1,10 @@ +/** + * Default hash length, in bytes, unless otherwise specified. + */ +export const defaultHashLength = 32; +/** + * Converts the input to an Uint8Array. + * @hidden + */ +export const inputToArray = (input) => input instanceof Uint8Array ? input : new Uint8Array(input); +//# sourceMappingURL=hash-fn.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-fn.js.map b/node_modules/blake3-wasm/esm/base/hash-fn.js.map new file mode 100644 index 0000000000000000000000000000000000000000..1ec8a491aa32bc856906fd7ef28083e52dad252f --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/base/hash-fn.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAOpC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,EAAE,CACnD,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-instance.d.ts b/node_modules/blake3-wasm/esm/base/hash-instance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f55095d015980754f8b8cb2734132fc841aef5a --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-instance.d.ts @@ -0,0 +1,79 @@ +import { BaseHashInput, IBaseHashOptions } from './hash-fn'; +import { IHashReader } from './hash-reader'; +/** + * A blake3 hash. Quite similar to Node's crypto hashing. + * + * Note that you must call {@link IHash#dispose} or {@link IHash#done} when + * you're finished with it to free memory. + */ +export interface IHasher { + /** + * Adds the given data to the hash. + * @throws {Error} if {@link IHash#digest} has already been called. + */ + update(data: BaseHashInput): this; + /** + * Returns a digest of the hash. + * + * If `dispose: false` is given in the options, the hash will not + * automatically be disposed of, allowing you to continue updating + * it after obtaining the current reader. + */ + digest(options?: IBaseHashOptions & { + dispose?: boolean; + }): T; + /** + * Returns a {@link HashReader} for the current hash. + * + * If `dispose: false` is given in the options, the hash will not + * automatically be disposed of, allowing you to continue updating + * it after obtaining the current reader. + */ + reader(options?: { + dispose?: boolean; + }): IHashReader; + /** + * Frees data associated with the hash. This *must* be called if + * {@link IHash#digest} is not called in order to free memory. + */ + dispose(): void; +} +/** + * @hidden + */ +export interface IInternalHash { + free(): void; + reader(): Reader; + update(bytes: Uint8Array): void; + digest(into: Uint8Array): void; +} +export interface IHasherDigestOptions extends IBaseHashOptions { + dispose?: boolean; +} +/** + * Base implementation of hashing. + */ +export declare class BaseHash> implements IHasher { + private readonly alloc; + private readonly getReader; + private hash; + constructor(implementation: IInternalHash, alloc: (length: number) => Binary, getReader: (internal: InternalReader) => Reader); + /** + * @inheritdoc + */ + update(data: BaseHashInput): this; + /** + * @inheritdoc + */ + digest({ length, dispose }?: IHasherDigestOptions): Binary; + /** + * @inheritdoc + */ + reader({ dispose }?: { + dispose?: boolean; + }): Reader; + /** + * @inheritdoc + */ + dispose(): void; +} diff --git a/node_modules/blake3-wasm/esm/base/hash-instance.js b/node_modules/blake3-wasm/esm/base/hash-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..aae7bef3d829ca7e50b87309d6205a8f5408cf45 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-instance.js @@ -0,0 +1,57 @@ +import { inputToArray, defaultHashLength } from './hash-fn.js'; +/** + * Base implementation of hashing. + */ +export class BaseHash { + constructor(implementation, alloc, getReader) { + this.alloc = alloc; + this.getReader = getReader; + this.hash = implementation; + } + /** + * @inheritdoc + */ + update(data) { + if (!this.hash) { + throw new Error('Cannot continue updating hashing after dispose() has been called'); + } + this.hash.update(inputToArray(data)); + return this; + } + /** + * @inheritdoc + */ + digest({ length = defaultHashLength, dispose = true } = {}) { + if (!this.hash) { + throw new Error('Cannot call digest() after dipose() has been called'); + } + const digested = this.alloc(length); + this.hash.digest(digested); + if (dispose) { + this.dispose(); + } + return digested; + } + /** + * @inheritdoc + */ + reader({ dispose = true } = {}) { + if (!this.hash) { + throw new Error('Cannot call reader() after dipose() has been called'); + } + const reader = this.getReader(this.hash.reader()); + if (dispose) { + this.dispose(); + } + return reader; + } + /** + * @inheritdoc + */ + dispose() { + var _a; + (_a = this.hash) === null || _a === void 0 ? void 0 : _a.free(); + this.hash = undefined; + } +} +//# sourceMappingURL=hash-instance.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-instance.js.map b/node_modules/blake3-wasm/esm/base/hash-instance.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ff78db6296a59492cd17fe67390fbf61ef449fef --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/base/hash-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAoB,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAuD7F;;GAEG;AACH,MAAM,OAAO,QAAQ;IAInB,YACE,cAA6C,EAC5B,KAAiC,EACjC,SAA+C;QAD/C,UAAK,GAAL,KAAK,CAA4B;QACjC,cAAS,GAAT,SAAS,CAAsC;QAEhE,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,IAAmB;QAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB,EAAE,OAAO,GAAG,IAAI,KAA2B,EAAE;QACrF,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE3B,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,KAA4B,EAAE;QAC1D,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAClD,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,OAAO;;QACL,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,GAAG;QAClB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;CACF"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-reader.d.ts b/node_modules/blake3-wasm/esm/base/hash-reader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad6a8facbc1094081c7263bfbe44013df50dca3d --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-reader.d.ts @@ -0,0 +1,61 @@ +import { IDisposable } from './disposable'; +/** + * The maximum number of bytes that can be read from the hash. + * + * Calculated out 2^64-1, since `Xn` syntax (for `Xn ** Yn`) requires TS + * targeting esnext/es2020 which includes features that Node 10 doesn't + * yet supported. + */ +export declare const maxHashBytes: bigint; +/** + * The HashReader is a type returned from any of the hash functions. It can + */ +export interface IHashReader extends IDisposable { + /** + * Returns the position of the reader in the hash. Can be written to to seek. + */ + position: bigint; + /** + * Reads data from the hash into the target array. The target will always + * be completely filled with data. + */ + readInto(target: Uint8Array): void; + /** + * Reads and returns the given number of bytes from the hash, advancing + * the position of the reader. + */ + read(bytes: number): T; +} +/** + * Underlying native or wasm module code backing the reader. + * @hidden + */ +export interface IInternalReader { + free?(): void; + fill(target: Uint8Array): void; + set_position(position: bigint): void; +} +/** + * Base hash reader implementation. + */ +export declare abstract class BaseHashReader implements IHashReader { + private reader; + private pos; + get position(): bigint; + set position(value: bigint); + constructor(reader: IInternalReader); + /** + * @inheritdoc + */ + readInto(target: Uint8Array): void; + /** + * @inheritdoc + */ + read(bytes: number): T; + /** + * @inheritdoc + */ + dispose(): void; + protected abstract alloc(bytes: number): T; + private boundsCheck; +} diff --git a/node_modules/blake3-wasm/esm/base/hash-reader.js b/node_modules/blake3-wasm/esm/base/hash-reader.js new file mode 100644 index 0000000000000000000000000000000000000000..2b4224db67e81d3a6f7f3cb5f9cdaacb5dcad46a --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-reader.js @@ -0,0 +1,67 @@ +/** + * The maximum number of bytes that can be read from the hash. + * + * Calculated out 2^64-1, since `Xn` syntax (for `Xn ** Yn`) requires TS + * targeting esnext/es2020 which includes features that Node 10 doesn't + * yet supported. + */ +export const maxHashBytes = BigInt('18446744073709551615'); +/** + * Base hash reader implementation. + */ +export class BaseHashReader { + constructor(reader) { + this.pos = BigInt(0); + this.reader = reader; + } + get position() { + return this.pos; + } + set position(value) { + var _a; + // to avoid footguns of people using numbers: + if (typeof value !== 'bigint') { + throw new Error(`Got a ${typeof value} set in to reader.position, expected a bigint`); + } + this.boundsCheck(value); + this.pos = value; + (_a = this.reader) === null || _a === void 0 ? void 0 : _a.set_position(value); + } + /** + * @inheritdoc + */ + readInto(target) { + if (!this.reader) { + throw new Error(`Cannot read from a hash after it was disposed`); + } + const next = this.pos + BigInt(target.length); + this.boundsCheck(next); + this.reader.fill(target); + this.position = next; + } + /** + * @inheritdoc + */ + read(bytes) { + const data = this.alloc(bytes); + this.readInto(data); + return data; + } + /** + * @inheritdoc + */ + dispose() { + var _a, _b; + (_b = (_a = this.reader) === null || _a === void 0 ? void 0 : _a.free) === null || _b === void 0 ? void 0 : _b.call(_a); + this.reader = undefined; + } + boundsCheck(position) { + if (position > maxHashBytes) { + throw new RangeError(`Cannot read past ${maxHashBytes} bytes in BLAKE3 hashes`); + } + if (position < BigInt(0)) { + throw new RangeError(`Cannot read to a negative position`); + } + } +} +//# sourceMappingURL=hash-reader.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-reader.js.map b/node_modules/blake3-wasm/esm/base/hash-reader.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3272e25a329b1bc56176076aa68cf738dd241df9 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/base/hash-reader.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAkC3D;;GAEG;AACH,MAAM,OAAgB,cAAc;IAmBlC,YAAY,MAAuB;QAjB3B,QAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAkBtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAjBD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAW,QAAQ,CAAC,KAAa;;QAC/B,6CAA6C;QAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,KAAK,+CAA+C,CAAC,CAAC;SACvF;QAED,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;QACjB,MAAA,IAAI,CAAC,MAAM,0CAAE,YAAY,CAAC,KAAK,EAAE;IACnC,CAAC;IAMD;;OAEG;IACI,QAAQ,CAAC,MAAkB;QAChC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAClE;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,KAAa;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,OAAO;;QACZ,YAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,mDAAK;QACtB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAIO,WAAW,CAAC,QAAgB;QAClC,IAAI,QAAQ,GAAG,YAAY,EAAE;YAC3B,MAAM,IAAI,UAAU,CAAC,oBAAoB,YAAY,yBAAyB,CAAC,CAAC;SACjF;QAED,IAAI,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE;YACxB,MAAM,IAAI,UAAU,CAAC,oCAAoC,CAAC,CAAC;SAC5D;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/index.d.ts b/node_modules/blake3-wasm/esm/base/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa61a59a01bc54522d71dc04c7277051e183d694 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/index.d.ts @@ -0,0 +1,4 @@ +export * from './hash-fn'; +export * from './hash-reader'; +export * from './hash-instance'; +export * from './disposable'; diff --git a/node_modules/blake3-wasm/esm/base/index.js b/node_modules/blake3-wasm/esm/base/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1bddd8bb614764316b53dd59fcd1c2b46e4c85a4 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/index.js @@ -0,0 +1,5 @@ +export * from './hash-fn.js'; +export * from './hash-reader.js'; +export * from './hash-instance.js'; +export * from './disposable.js'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/index.js.map b/node_modules/blake3-wasm/esm/base/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e7220dae11d703740e00a8f998d3802f6dc4b20c --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/base/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/test-helpers.d.ts b/node_modules/blake3-wasm/esm/base/test-helpers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b4b3ddec61120a216254dd0d3dd4f94fb0e8533 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/test-helpers.d.ts @@ -0,0 +1,41 @@ +/// +export declare const hello48: Buffer; +export declare const inputs: { + large: { + input: string; + hash: Buffer; + }; + hello: { + input: string; + hash: Buffer; + }; + goodbye: { + input: string; + hash: Buffer; + }; +}; +/** + * Test vectors from the BLAKE3 repo. + * + * > Each test is an input length and three outputs, one for each of the hash, + * > keyedHash, and deriveKey modes. The input in each case is filled with a + * > 251-byte-long repeating pattern: 0, 1, 2, ..., 249, 250, 0, 1, ... The + * > key used with keyedHash is the 32-byte ASCII string given in the 'key' + * > field below. For deriveKey, the test input is used as the input key, and + * > the context string is 'BLAKE3 2019-12-27 6:29:52 example context'. + * > (As good practice for following the security requirements of deriveKey, + * > test runners should make that context string a hardcoded constant, and we + * > do not provided it in machine-readable form.) Outputs are encoded as + * > hexadecimal. Each case is an extended output, and implementations should + * > also check that the first 32 bytes match their default-length output. + */ +export declare const ogTestVectors: { + key: string; + context: string; + cases: { + inputLen: number; + expectedHash: string; + expectedKeyed: string; + expectedDerive: string; + }[]; +}; diff --git a/node_modules/blake3-wasm/esm/base/test-helpers.js b/node_modules/blake3-wasm/esm/base/test-helpers.js new file mode 100644 index 0000000000000000000000000000000000000000..92bbc9dbbe74a1e7478afaeae3c138af19625611 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/test-helpers.js @@ -0,0 +1,164 @@ +import { readFileSync } from 'fs.js'; +export const hello48 = Buffer.from('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200fe992405f0d785b599a2e3387f6d34d01', 'hex'); +export const inputs = { + large: { + input: readFileSync(__dirname + '/../../test-input.txt', 'utf-8'), + hash: Buffer.from('2a2cf9cbc9f8d48f7d089273bc2d796a3cd0677b64234dab0c59e6e29d6a7164', 'hex'), + }, + hello: { + input: 'hello', + hash: Buffer.from('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f', 'hex'), + }, + goodbye: { + input: 'goodbye', + hash: Buffer.from('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69', 'hex'), + }, +}; +/** + * Test vectors from the BLAKE3 repo. + * + * > Each test is an input length and three outputs, one for each of the hash, + * > keyedHash, and deriveKey modes. The input in each case is filled with a + * > 251-byte-long repeating pattern: 0, 1, 2, ..., 249, 250, 0, 1, ... The + * > key used with keyedHash is the 32-byte ASCII string given in the 'key' + * > field below. For deriveKey, the test input is used as the input key, and + * > the context string is 'BLAKE3 2019-12-27 6:29:52 example context'. + * > (As good practice for following the security requirements of deriveKey, + * > test runners should make that context string a hardcoded constant, and we + * > do not provided it in machine-readable form.) Outputs are encoded as + * > hexadecimal. Each case is an extended output, and implementations should + * > also check that the first 32 bytes match their default-length output. + */ +export const ogTestVectors = { + key: 'whats the Elvish word for friend', + context: 'BLAKE3 2019-12-27 16:29:52 test vectors context', + cases: [ + { + inputLen: 0, + expectedHash: 'af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262e00f03e7b69af26b7faaf09fcd333050338ddfe085b8cc869ca98b206c08243a26f5487789e8f660afe6c99ef9e0c52b92e7393024a80459cf91f476f9ffdbda7001c22e159b402631f277ca96f2defdf1078282314e763699a31c5363165421cce14d', + expectedKeyed: '92b2b75604ed3c761f9d6f62392c8a9227ad0ea3f09573e783f1498a4ed60d26b18171a2f22a4b94822c701f107153dba24918c4bae4d2945c20ece13387627d3b73cbf97b797d5e59948c7ef788f54372df45e45e4293c7dc18c1d41144a9758be58960856be1eabbe22c2653190de560ca3b2ac4aa692a9210694254c371e851bc8f', + expectedDerive: '2cc39783c223154fea8dfb7c1b1660f2ac2dcbd1c1de8277b0b0dd39b7e50d7d905630c8be290dfcf3e6842f13bddd573c098c3f17361f1f206b8cad9d088aa4a3f746752c6b0ce6a83b0da81d59649257cdf8eb3e9f7d4998e41021fac119deefb896224ac99f860011f73609e6e0e4540f93b273e56547dfd3aa1a035ba6689d89a0', + }, + { + inputLen: 1, + expectedHash: '2d3adedff11b61f14c886e35afa036736dcd87a74d27b5c1510225d0f592e213c3a6cb8bf623e20cdb535f8d1a5ffb86342d9c0b64aca3bce1d31f60adfa137b358ad4d79f97b47c3d5e79f179df87a3b9776ef8325f8329886ba42f07fb138bb502f4081cbcec3195c5871e6c23e2cc97d3c69a613eba131e5f1351f3f1da786545e5', + expectedKeyed: '6d7878dfff2f485635d39013278ae14f1454b8c0a3a2d34bc1ab38228a80c95b6568c0490609413006fbd428eb3fd14e7756d90f73a4725fad147f7bf70fd61c4e0cf7074885e92b0e3f125978b4154986d4fb202a3f331a3fb6cf349a3a70e49990f98fe4289761c8602c4e6ab1138d31d3b62218078b2f3ba9a88e1d08d0dd4cea11', + expectedDerive: 'b3e2e340a117a499c6cf2398a19ee0d29cca2bb7404c73063382693bf66cb06c5827b91bf889b6b97c5477f535361caefca0b5d8c4746441c57617111933158950670f9aa8a05d791daae10ac683cbef8faf897c84e6114a59d2173c3f417023a35d6983f2c7dfa57e7fc559ad751dbfb9ffab39c2ef8c4aafebc9ae973a64f0c76551', + }, + { + inputLen: 1023, + expectedHash: '10108970eeda3eb932baac1428c7a2163b0e924c9a9e25b35bba72b28f70bd11a182d27a591b05592b15607500e1e8dd56bc6c7fc063715b7a1d737df5bad3339c56778957d870eb9717b57ea3d9fb68d1b55127bba6a906a4a24bbd5acb2d123a37b28f9e9a81bbaae360d58f85e5fc9d75f7c370a0cc09b6522d9c8d822f2f28f485', + expectedKeyed: 'c951ecdf03288d0fcc96ee3413563d8a6d3589547f2c2fb36d9786470f1b9d6e890316d2e6d8b8c25b0a5b2180f94fb1a158ef508c3cde45e2966bd796a696d3e13efd86259d756387d9becf5c8bf1ce2192b87025152907b6d8cc33d17826d8b7b9bc97e38c3c85108ef09f013e01c229c20a83d9e8efac5b37470da28575fd755a10', + expectedDerive: '74a16c1c3d44368a86e1ca6df64be6a2f64cce8f09220787450722d85725dea59c413264404661e9e4d955409dfe4ad3aa487871bcd454ed12abfe2c2b1eb7757588cf6cb18d2eccad49e018c0d0fec323bec82bf1644c6325717d13ea712e6840d3e6e730d35553f59eff5377a9c350bcc1556694b924b858f329c44ee64b884ef00d', + }, + { + inputLen: 1024, + expectedHash: '42214739f095a406f3fc83deb889744ac00df831c10daa55189b5d121c855af71cf8107265ecdaf8505b95d8fcec83a98a6a96ea5109d2c179c47a387ffbb404756f6eeae7883b446b70ebb144527c2075ab8ab204c0086bb22b7c93d465efc57f8d917f0b385c6df265e77003b85102967486ed57db5c5ca170ba441427ed9afa684e', + expectedKeyed: '75c46f6f3d9eb4f55ecaaee480db732e6c2105546f1e675003687c31719c7ba4a78bc838c72852d4f49c864acb7adafe2478e824afe51c8919d06168414c265f298a8094b1ad813a9b8614acabac321f24ce61c5a5346eb519520d38ecc43e89b5000236df0597243e4d2493fd626730e2ba17ac4d8824d09d1a4a8f57b8227778e2de', + expectedDerive: '7356cd7720d5b66b6d0697eb3177d9f8d73a4a5c5e968896eb6a6896843027066c23b601d3ddfb391e90d5c8eccdef4ae2a264bce9e612ba15e2bc9d654af1481b2e75dbabe615974f1070bba84d56853265a34330b4766f8e75edd1f4a1650476c10802f22b64bd3919d246ba20a17558bc51c199efdec67e80a227251808d8ce5bad', + }, + { + inputLen: 1025, + expectedHash: 'd00278ae47eb27b34faecf67b4fe263f82d5412916c1ffd97c8cb7fb814b8444f4c4a22b4b399155358a994e52bf255de60035742ec71bd08ac275a1b51cc6bfe332b0ef84b409108cda080e6269ed4b3e2c3f7d722aa4cdc98d16deb554e5627be8f955c98e1d5f9565a9194cad0c4285f93700062d9595adb992ae68ff12800ab67a', + expectedKeyed: '357dc55de0c7e382c900fd6e320acc04146be01db6a8ce7210b7189bd664ea69362396b77fdc0d2634a552970843722066c3c15902ae5097e00ff53f1e116f1cd5352720113a837ab2452cafbde4d54085d9cf5d21ca613071551b25d52e69d6c81123872b6f19cd3bc1333edf0c52b94de23ba772cf82636cff4542540a7738d5b930', + expectedDerive: 'effaa245f065fbf82ac186839a249707c3bddf6d3fdda22d1b95a3c970379bcb5d31013a167509e9066273ab6e2123bc835b408b067d88f96addb550d96b6852dad38e320b9d940f86db74d398c770f462118b35d2724efa13da97194491d96dd37c3c09cbef665953f2ee85ec83d88b88d11547a6f911c8217cca46defa2751e7f3ad', + }, + { + inputLen: 2048, + expectedHash: 'e776b6028c7cd22a4d0ba182a8bf62205d2ef576467e838ed6f2529b85fba24a9a60bf80001410ec9eea6698cd537939fad4749edd484cb541aced55cd9bf54764d063f23f6f1e32e12958ba5cfeb1bf618ad094266d4fc3c968c2088f677454c288c67ba0dba337b9d91c7e1ba586dc9a5bc2d5e90c14f53a8863ac75655461cea8f9', + expectedKeyed: '879cf1fa2ea0e79126cb1063617a05b6ad9d0b696d0d757cf053439f60a99dd10173b961cd574288194b23ece278c330fbb8585485e74967f31352a8183aa782b2b22f26cdcadb61eed1a5bc144b8198fbb0c13abbf8e3192c145d0a5c21633b0ef86054f42809df823389ee40811a5910dcbd1018af31c3b43aa55201ed4edaac74fe', + expectedDerive: '7b2945cb4fef70885cc5d78a87bf6f6207dd901ff239201351ffac04e1088a23e2c11a1ebffcea4d80447867b61badb1383d842d4e79645d48dd82ccba290769caa7af8eaa1bd78a2a5e6e94fbdab78d9c7b74e894879f6a515257ccf6f95056f4e25390f24f6b35ffbb74b766202569b1d797f2d4bd9d17524c720107f985f4ddc583', + }, + { + inputLen: 2049, + expectedHash: '5f4d72f40d7a5f82b15ca2b2e44b1de3c2ef86c426c95c1af0b687952256303096de31d71d74103403822a2e0bc1eb193e7aecc9643a76b7bbc0c9f9c52e8783aae98764ca468962b5c2ec92f0c74eb5448d519713e09413719431c802f948dd5d90425a4ecdadece9eb178d80f26efccae630734dff63340285adec2aed3b51073ad3', + expectedKeyed: '9f29700902f7c86e514ddc4df1e3049f258b2472b6dd5267f61bf13983b78dd5f9a88abfefdfa1e00b418971f2b39c64ca621e8eb37fceac57fd0c8fc8e117d43b81447be22d5d8186f8f5919ba6bcc6846bd7d50726c06d245672c2ad4f61702c646499ee1173daa061ffe15bf45a631e2946d616a4c345822f1151284712f76b2b0e', + expectedDerive: '2ea477c5515cc3dd606512ee72bb3e0e758cfae7232826f35fb98ca1bcbdf27316d8e9e79081a80b046b60f6a263616f33ca464bd78d79fa18200d06c7fc9bffd808cc4755277a7d5e09da0f29ed150f6537ea9bed946227ff184cc66a72a5f8c1e4bd8b04e81cf40fe6dc4427ad5678311a61f4ffc39d195589bdbc670f63ae70f4b6', + }, + { + inputLen: 3072, + expectedHash: 'b98cb0ff3623be03326b373de6b9095218513e64f1ee2edd2525c7ad1e5cffd29a3f6b0b978d6608335c09dc94ccf682f9951cdfc501bfe47b9c9189a6fc7b404d120258506341a6d802857322fbd20d3e5dae05b95c88793fa83db1cb08e7d8008d1599b6209d78336e24839724c191b2a52a80448306e0daa84a3fdb566661a37e11', + expectedKeyed: '044a0e7b172a312dc02a4c9a818c036ffa2776368d7f528268d2e6b5df19177022f302d0529e4174cc507c463671217975e81dab02b8fdeb0d7ccc7568dd22574c783a76be215441b32e91b9a904be8ea81f7a0afd14bad8ee7c8efc305ace5d3dd61b996febe8da4f56ca0919359a7533216e2999fc87ff7d8f176fbecb3d6f34278b', + expectedDerive: '050df97f8c2ead654d9bb3ab8c9178edcd902a32f8495949feadcc1e0480c46b3604131bbd6e3ba573b6dd682fa0a63e5b165d39fc43a625d00207607a2bfeb65ff1d29292152e26b298868e3b87be95d6458f6f2ce6118437b632415abe6ad522874bcd79e4030a5e7bad2efa90a7a7c67e93f0a18fb28369d0a9329ab5c24134ccb0', + }, + { + inputLen: 3073, + expectedHash: '7124b49501012f81cc7f11ca069ec9226cecb8a2c850cfe644e327d22d3e1cd39a27ae3b79d68d89da9bf25bc27139ae65a324918a5f9b7828181e52cf373c84f35b639b7fccbb985b6f2fa56aea0c18f531203497b8bbd3a07ceb5926f1cab74d14bd66486d9a91eba99059a98bd1cd25876b2af5a76c3e9eed554ed72ea952b603bf', + expectedKeyed: '68dede9bef00ba89e43f31a6825f4cf433389fedae75c04ee9f0cf16a427c95a96d6da3fe985054d3478865be9a092250839a697bbda74e279e8a9e69f0025e4cfddd6cfb434b1cd9543aaf97c635d1b451a4386041e4bb100f5e45407cbbc24fa53ea2de3536ccb329e4eb9466ec37093a42cf62b82903c696a93a50b702c80f3c3c5', + expectedDerive: '72613c9ec9ff7e40f8f5c173784c532ad852e827dba2bf85b2ab4b76f7079081576288e552647a9d86481c2cae75c2dd4e7c5195fb9ada1ef50e9c5098c249d743929191441301c69e1f48505a4305ec1778450ee48b8e69dc23a25960fe33070ea549119599760a8a2d28aeca06b8c5e9ba58bc19e11fe57b6ee98aa44b2a8e6b14a5', + }, + { + inputLen: 4096, + expectedHash: '015094013f57a5277b59d8475c0501042c0b642e531b0a1c8f58d2163229e9690289e9409ddb1b99768eafe1623da896faf7e1114bebeadc1be30829b6f8af707d85c298f4f0ff4d9438aef948335612ae921e76d411c3a9111df62d27eaf871959ae0062b5492a0feb98ef3ed4af277f5395172dbe5c311918ea0074ce0036454f620', + expectedKeyed: 'befc660aea2f1718884cd8deb9902811d332f4fc4a38cf7c7300d597a081bfc0bbb64a36edb564e01e4b4aaf3b060092a6b838bea44afebd2deb8298fa562b7b597c757b9df4c911c3ca462e2ac89e9a787357aaf74c3b56d5c07bc93ce899568a3eb17d9250c20f6c5f6c1e792ec9a2dcb715398d5a6ec6d5c54f586a00403a1af1de', + expectedDerive: '1e0d7f3db8c414c97c6307cbda6cd27ac3b030949da8e23be1a1a924ad2f25b9d78038f7b198596c6cc4a9ccf93223c08722d684f240ff6569075ed81591fd93f9fff1110b3a75bc67e426012e5588959cc5a4c192173a03c00731cf84544f65a2fb9378989f72e9694a6a394a8a30997c2e67f95a504e631cd2c5f55246024761b245', + }, + { + inputLen: 4097, + expectedHash: '9b4052b38f1c5fc8b1f9ff7ac7b27cd242487b3d890d15c96a1c25b8aa0fb99505f91b0b5600a11251652eacfa9497b31cd3c409ce2e45cfe6c0a016967316c426bd26f619eab5d70af9a418b845c608840390f361630bd497b1ab44019316357c61dbe091ce72fc16dc340ac3d6e009e050b3adac4b5b2c92e722cffdc46501531956', + expectedKeyed: '00df940cd36bb9fa7cbbc3556744e0dbc8191401afe70520ba292ee3ca80abbc606db4976cfdd266ae0abf667d9481831ff12e0caa268e7d3e57260c0824115a54ce595ccc897786d9dcbf495599cfd90157186a46ec800a6763f1c59e36197e9939e900809f7077c102f888caaf864b253bc41eea812656d46742e4ea42769f89b83f', + expectedDerive: 'aca51029626b55fda7117b42a7c211f8c6e9ba4fe5b7a8ca922f34299500ead8a897f66a400fed9198fd61dd2d58d382458e64e100128075fc54b860934e8de2e84170734b06e1d212a117100820dbc48292d148afa50567b8b84b1ec336ae10d40c8c975a624996e12de31abbe135d9d159375739c333798a80c64ae895e51e22f3ad', + }, + { + inputLen: 5120, + expectedHash: '9cadc15fed8b5d854562b26a9536d9707cadeda9b143978f319ab34230535833acc61c8fdc114a2010ce8038c853e121e1544985133fccdd0a2d507e8e615e611e9a0ba4f47915f49e53d721816a9198e8b30f12d20ec3689989175f1bf7a300eee0d9321fad8da232ece6efb8e9fd81b42ad161f6b9550a069e66b11b40487a5f5059', + expectedKeyed: '2c493e48e9b9bf31e0553a22b23503c0a3388f035cece68eb438d22fa1943e209b4dc9209cd80ce7c1f7c9a744658e7e288465717ae6e56d5463d4f80cdb2ef56495f6a4f5487f69749af0c34c2cdfa857f3056bf8d807336a14d7b89bf62bef2fb54f9af6a546f818dc1e98b9e07f8a5834da50fa28fb5874af91bf06020d1bf0120e', + expectedDerive: '7a7acac8a02adcf3038d74cdd1d34527de8a0fcc0ee3399d1262397ce5817f6055d0cefd84d9d57fe792d65a278fd20384ac6c30fdb340092f1a74a92ace99c482b28f0fc0ef3b923e56ade20c6dba47e49227166251337d80a037e987ad3a7f728b5ab6dfafd6e2ab1bd583a95d9c895ba9c2422c24ea0f62961f0dca45cad47bfa0d', + }, + { + inputLen: 5121, + expectedHash: '628bd2cb2004694adaab7bbd778a25df25c47b9d4155a55f8fbd79f2fe154cff96adaab0613a6146cdaabe498c3a94e529d3fc1da2bd08edf54ed64d40dcd6777647eac51d8277d70219a9694334a68bc8f0f23e20b0ff70ada6f844542dfa32cd4204ca1846ef76d811cdb296f65e260227f477aa7aa008bac878f72257484f2b6c95', + expectedKeyed: '6ccf1c34753e7a044db80798ecd0782a8f76f33563accaddbfbb2e0ea4b2d0240d07e63f13667a8d1490e5e04f13eb617aea16a8c8a5aaed1ef6fbde1b0515e3c81050b361af6ead126032998290b563e3caddeaebfab592e155f2e161fb7cba939092133f23f9e65245e58ec23457b78a2e8a125588aad6e07d7f11a85b88d375b72d', + expectedDerive: 'b07f01e518e702f7ccb44a267e9e112d403a7b3f4883a47ffbed4b48339b3c341a0add0ac032ab5aaea1e4e5b004707ec5681ae0fcbe3796974c0b1cf31a194740c14519273eedaabec832e8a784b6e7cfc2c5952677e6c3f2c3914454082d7eb1ce1766ac7d75a4d3001fc89544dd46b5147382240d689bbbaefc359fb6ae30263165', + }, + { + inputLen: 6144, + expectedHash: '3e2e5b74e048f3add6d21faab3f83aa44d3b2278afb83b80b3c35164ebeca2054d742022da6fdda444ebc384b04a54c3ac5839b49da7d39f6d8a9db03deab32aade156c1c0311e9b3435cde0ddba0dce7b26a376cad121294b689193508dd63151603c6ddb866ad16c2ee41585d1633a2cea093bea714f4c5d6b903522045b20395c83', + expectedKeyed: '3d6b6d21281d0ade5b2b016ae4034c5dec10ca7e475f90f76eac7138e9bc8f1dc35754060091dc5caf3efabe0603c60f45e415bb3407db67e6beb3d11cf8e4f7907561f05dace0c15807f4b5f389c841eb114d81a82c02a00b57206b1d11fa6e803486b048a5ce87105a686dee041207e095323dfe172df73deb8c9532066d88f9da7e', + expectedDerive: '2a95beae63ddce523762355cf4b9c1d8f131465780a391286a5d01abb5683a1597099e3c6488aab6c48f3c15dbe1942d21dbcdc12115d19a8b8465fb54e9053323a9178e4275647f1a9927f6439e52b7031a0b465c861a3fc531527f7758b2b888cf2f20582e9e2c593709c0a44f9c6e0f8b963994882ea4168827823eef1f64169fef', + }, + { + inputLen: 6145, + expectedHash: 'f1323a8631446cc50536a9f705ee5cb619424d46887f3c376c695b70e0f0507f18a2cfdd73c6e39dd75ce7c1c6e3ef238fd54465f053b25d21044ccb2093beb015015532b108313b5829c3621ce324b8e14229091b7c93f32db2e4e63126a377d2a63a3597997d4f1cba59309cb4af240ba70cebff9a23d5e3ff0cdae2cfd54e070022', + expectedKeyed: '9ac301e9e39e45e3250a7e3b3df701aa0fb6889fbd80eeecf28dbc6300fbc539f3c184ca2f59780e27a576c1d1fb9772e99fd17881d02ac7dfd39675aca918453283ed8c3169085ef4a466b91c1649cc341dfdee60e32231fc34c9c4e0b9a2ba87ca8f372589c744c15fd6f985eec15e98136f25beeb4b13c4e43dc84abcc79cd4646c', + expectedDerive: '379bcc61d0051dd489f686c13de00d5b14c505245103dc040d9e4dd1facab8e5114493d029bdbd295aaa744a59e31f35c7f52dba9c3642f773dd0b4262a9980a2aef811697e1305d37ba9d8b6d850ef07fe41108993180cf779aeece363704c76483458603bbeeb693cffbbe5588d1f3535dcad888893e53d977424bb707201569a8d2', + }, + { + inputLen: 7168, + expectedHash: '61da957ec2499a95d6b8023e2b0e604ec7f6b50e80a9678b89d2628e99ada77a5707c321c83361793b9af62a40f43b523df1c8633cecb4cd14d00bdc79c78fca5165b863893f6d38b02ff7236c5a9a8ad2dba87d24c547cab046c29fc5bc1ed142e1de4763613bb162a5a538e6ef05ed05199d751f9eb58d332791b8d73fb74e4fce95', + expectedKeyed: 'b42835e40e9d4a7f42ad8cc04f85a963a76e18198377ed84adddeaecacc6f3fca2f01d5277d69bb681c70fa8d36094f73ec06e452c80d2ff2257ed82e7ba348400989a65ee8daa7094ae0933e3d2210ac6395c4af24f91c2b590ef87d7788d7066ea3eaebca4c08a4f14b9a27644f99084c3543711b64a070b94f2c9d1d8a90d035d52', + expectedDerive: '11c37a112765370c94a51415d0d651190c288566e295d505defdad895dae223730d5a5175a38841693020669c7638f40b9bc1f9f39cf98bda7a5b54ae24218a800a2116b34665aa95d846d97ea988bfcb53dd9c055d588fa21ba78996776ea6c40bc428b53c62b5f3ccf200f647a5aae8067f0ea1976391fcc72af1945100e2a6dcb88', + }, + { + inputLen: 7169, + expectedHash: 'a003fc7a51754a9b3c7fae0367ab3d782dccf28855a03d435f8cfe74605e781798a8b20534be1ca9eb2ae2df3fae2ea60e48c6fb0b850b1385b5de0fe460dbe9d9f9b0d8db4435da75c601156df9d047f4ede008732eb17adc05d96180f8a73548522840779e6062d643b79478a6e8dbce68927f36ebf676ffa7d72d5f68f050b119c8', + expectedKeyed: 'ed9b1a922c046fdb3d423ae34e143b05ca1bf28b710432857bf738bcedbfa5113c9e28d72fcbfc020814ce3f5d4fc867f01c8f5b6caf305b3ea8a8ba2da3ab69fabcb438f19ff11f5378ad4484d75c478de425fb8e6ee809b54eec9bdb184315dc856617c09f5340451bf42fd3270a7b0b6566169f242e533777604c118a6358250f54', + expectedDerive: '554b0a5efea9ef183f2f9b931b7497995d9eb26f5c5c6dad2b97d62fc5ac31d99b20652c016d88ba2a611bbd761668d5eda3e568e940faae24b0d9991c3bd25a65f770b89fdcadabcb3d1a9c1cb63e69721cacf1ae69fefdcef1e3ef41bc5312ccc17222199e47a26552c6adc460cf47a72319cb5039369d0060eaea59d6c65130f1dd', + }, + { + inputLen: 8192, + expectedHash: 'aae792484c8efe4f19e2ca7d371d8c467ffb10748d8a5a1ae579948f718a2a635fe51a27db045a567c1ad51be5aa34c01c6651c4d9b5b5ac5d0fd58cf18dd61a47778566b797a8c67df7b1d60b97b19288d2d877bb2df417ace009dcb0241ca1257d62712b6a4043b4ff33f690d849da91ea3bf711ed583cb7b7a7da2839ba71309bbf', + expectedKeyed: 'dc9637c8845a770b4cbf76b8daec0eebf7dc2eac11498517f08d44c8fc00d58a4834464159dcbc12a0ba0c6d6eb41bac0ed6585cabfe0aca36a375e6c5480c22afdc40785c170f5a6b8a1107dbee282318d00d915ac9ed1143ad40765ec120042ee121cd2baa36250c618adaf9e27260fda2f94dea8fb6f08c04f8f10c78292aa46102', + expectedDerive: 'ad01d7ae4ad059b0d33baa3c01319dcf8088094d0359e5fd45d6aeaa8b2d0c3d4c9e58958553513b67f84f8eac653aeeb02ae1d5672dcecf91cd9985a0e67f4501910ecba25555395427ccc7241d70dc21c190e2aadee875e5aae6bf1912837e53411dabf7a56cbf8e4fb780432b0d7fe6cec45024a0788cf5874616407757e9e6bef7', + }, + { + inputLen: 8193, + expectedHash: 'bab6c09cb8ce8cf459261398d2e7aef35700bf488116ceb94a36d0f5f1b7bc3bb2282aa69be089359ea1154b9a9286c4a56af4de975a9aa4a5c497654914d279bea60bb6d2cf7225a2fa0ff5ef56bbe4b149f3ed15860f78b4e2ad04e158e375c1e0c0b551cd7dfc82f1b155c11b6b3ed51ec9edb30d133653bb5709d1dbd55f4e1ff6', + expectedKeyed: '954a2a75420c8d6547e3ba5b98d963e6fa6491addc8c023189cc519821b4a1f5f03228648fd983aef045c2fa8290934b0866b615f585149587dda2299039965328835a2b18f1d63b7e300fc76ff260b571839fe44876a4eae66cbac8c67694411ed7e09df51068a22c6e67d6d3dd2cca8ff12e3275384006c80f4db68023f24eebba57', + expectedDerive: 'af1e0346e389b17c23200270a64aa4e1ead98c61695d917de7d5b00491c9b0f12f20a01d6d622edf3de026a4db4e4526225debb93c1237934d71c7340bb5916158cbdafe9ac3225476b6ab57a12357db3abbad7a26c6e66290e44034fb08a20a8d0ec264f309994d2810c49cfba6989d7abb095897459f5425adb48aba07c5fb3c83c0', + }, + { + inputLen: 16384, + expectedHash: 'f875d6646de28985646f34ee13be9a576fd515f76b5b0a26bb324735041ddde49d764c270176e53e97bdffa58d549073f2c660be0e81293767ed4e4929f9ad34bbb39a529334c57c4a381ffd2a6d4bfdbf1482651b172aa883cc13408fa67758a3e47503f93f87720a3177325f7823251b85275f64636a8f1d599c2e49722f42e93893', + expectedKeyed: '9e9fc4eb7cf081ea7c47d1807790ed211bfec56aa25bb7037784c13c4b707b0df9e601b101e4cf63a404dfe50f2e1865bb12edc8fca166579ce0c70dba5a5c0fc960ad6f3772183416a00bd29d4c6e651ea7620bb100c9449858bf14e1ddc9ecd35725581ca5b9160de04060045993d972571c3e8f71e9d0496bfa744656861b169d65', + expectedDerive: '160e18b5878cd0df1c3af85eb25a0db5344d43a6fbd7a8ef4ed98d0714c3f7e160dc0b1f09caa35f2f417b9ef309dfe5ebd67f4c9507995a531374d099cf8ae317542e885ec6f589378864d3ea98716b3bbb65ef4ab5e0ab5bb298a501f19a41ec19af84a5e6b428ecd813b1a47ed91c9657c3fba11c406bc316768b58f6802c9e9b57', + }, + { + inputLen: 31744, + expectedHash: '62b6960e1a44bcc1eb1a611a8d6235b6b4b78f32e7abc4fb4c6cdcce94895c47860cc51f2b0c28a7b77304bd55fe73af663c02d3f52ea053ba43431ca5bab7bfea2f5e9d7121770d88f70ae9649ea713087d1914f7f312147e247f87eb2d4ffef0ac978bf7b6579d57d533355aa20b8b77b13fd09748728a5cc327a8ec470f4013226f', + expectedKeyed: 'efa53b389ab67c593dba624d898d0f7353ab99e4ac9d42302ee64cbf9939a4193a7258db2d9cd32a7a3ecfce46144114b15c2fcb68a618a976bd74515d47be08b628be420b5e830fade7c080e351a076fbc38641ad80c736c8a18fe3c66ce12f95c61c2462a9770d60d0f77115bbcd3782b593016a4e728d4c06cee4505cb0c08a42ec', + expectedDerive: '39772aef80e0ebe60596361e45b061e8f417429d529171b6764468c22928e28e9759adeb797a3fbf771b1bcea30150a020e317982bf0d6e7d14dd9f064bc11025c25f31e81bd78a921db0174f03dd481d30e93fd8e90f8b2fee209f849f2d2a52f31719a490fb0ba7aea1e09814ee912eba111a9fde9d5c274185f7bae8ba85d300a2b', + }, + ], +}; +//# sourceMappingURL=test-helpers.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/test-helpers.js.map b/node_modules/blake3-wasm/esm/base/test-helpers.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9200569386b791aa665b1935b8b6b486fde7fa74 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/test-helpers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../ts/base/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAChC,kGAAkG,EAClG,KAAK,CACN,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE;QACL,KAAK,EAAE,YAAY,CAAC,SAAS,GAAG,uBAAuB,EAAE,OAAO,CAAC;QACjE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,kEAAkE,EAAE,KAAK,CAAC;KAC7F;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,MAAM,CAAC,IAA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Ac,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,IAAI;YACd,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,KAAK;YACf,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,KAAK;YACf,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;KACF;CACF,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser.test.d.ts b/node_modules/blake3-wasm/esm/browser.test.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/browser.test.js b/node_modules/blake3-wasm/esm/browser.test.js new file mode 100644 index 0000000000000000000000000000000000000000..6a171240cec22014c56495fbbc7920f99a83f016 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser.test.js @@ -0,0 +1,261 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { expect } from 'chai.js'; +import { mkdirSync, writeFileSync } from 'fs.js'; +import { createServer } from 'http.js'; +import { tmpdir } from 'os.js'; +import { resolve } from 'path.js'; +import puppeteer from 'puppeteer.js'; +import handler from 'serve-handler.js'; +import webpack from 'webpack.js'; +import { hello48, inputs, ogTestVectors } from './base/test-helpers.js'; +// Much of the browser code is also used in Node's wasm. We test things more +// thoroughly there because tests are easier to write and debug, these tests +// are primarily for sanity and checking browser-specific behavior. +describe('browser', () => { + const addInputs = `window.inputs = ${JSON.stringify(inputs)}`; + describe('webpack', () => { + const testDir = resolve(tmpdir(), 'blake3-browser-test'); + let server; + let page; + /** + * Builds the browser lib into the testDir. + */ + function buildWebpack() { + return __awaiter(this, void 0, void 0, function* () { + try { + mkdirSync(testDir); + } + catch (_a) { + // already exists, probably + } + writeFileSync(resolve(testDir, 'entry-src.js'), `import("blake3/browser").then(b3 => window.blake3 = b3);`); + const stats = yield new Promise((res, rej) => webpack({ + mode: 'production', + devtool: 'source-map', + entry: resolve(testDir, 'entry-src.js'), + output: { + path: testDir, + filename: 'main.js', + }, + resolve: { + alias: { + 'blake3/browser': resolve(__dirname, '../', 'browser.js'), + }, + }, + }, (err, stats) => (err ? rej(err) : res(stats)))); + if (stats.hasErrors()) { + throw stats.toString('errors-only'); + } + writeFileSync(resolve(testDir, 'index.html'), ``); + }); + } + function serve() { + return __awaiter(this, void 0, void 0, function* () { + server = createServer((req, res) => handler(req, res, { public: testDir })); + yield new Promise(resolve => server.listen(0, resolve)); + }); + } + before(function () { + return __awaiter(this, void 0, void 0, function* () { + yield buildWebpack(); + yield serve(); + this.timeout(20 * 1000); + const { port } = server.address(); + const browser = yield puppeteer.launch({ + executablePath: 'google-chrome-stable', + args: ['--no-sandbox'], + }); + page = yield browser.newPage(); + yield page.goto(`http://localhost:${port}`); + yield page.waitForFunction('!!window.blake3'); + yield page.evaluate(addInputs); + }); + }); + runTests({ + get page() { + return page; + }, + }); + after(() => { + page === null || page === void 0 ? void 0 : page.browser().close(); + server === null || server === void 0 ? void 0 : server.close(); + }); + }); + describe('native browser', () => { + let server; + let page; + function serve() { + return __awaiter(this, void 0, void 0, function* () { + server = createServer((req, res) => handler(req, res, { public: resolve(__dirname, '..') })); + yield new Promise(resolve => server.listen(0, resolve)); + }); + } + before(function () { + return __awaiter(this, void 0, void 0, function* () { + yield serve(); + this.timeout(20 * 1000); + const { port } = server.address(); + const browser = yield puppeteer.launch({ + executablePath: 'google-chrome-stable', + args: ['--no-sandbox'], + }); + page = yield browser.newPage(); + page.on('console', console.log); + page.on('pageerror', console.log); + page.on('error', console.log); + yield page.goto(`http://localhost:${port}/browser-async.test.html`); + yield page.waitForFunction('!!window.blake3'); + yield page.evaluate(addInputs); + }); + }); + runTests({ + get page() { + return page; + }, + }); + after(() => { + page === null || page === void 0 ? void 0 : page.browser().close(); + server.close(); + }); + }); +}); +function runTests(opts) { + it('hashes a string', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.large.input).toString("hex")'); + expect(result).to.equal(inputs.large.hash.toString('hex')); + })); + describe('input encoding', () => { + it('hashes a uint8array', () => __awaiter(this, void 0, void 0, function* () { + const contents = [...new Uint8Array(Buffer.from(inputs.hello.input))]; + const result = yield opts.page.evaluate(`blake3.hash(new Uint8Array([${contents.join(',')}])).toString("hex")`); + expect(result).to.equal(inputs.hello.hash.toString('hex')); + })); + it('hashes a string', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.large.input).toString("hex")'); + expect(result).to.equal(inputs.large.hash.toString('hex')); + })); + it('customizes output length', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.hello.input, { length: 16 }).toString("hex")'); + expect(result).to.equal(inputs.hello.hash.slice(0, 16).toString('hex')); + })); + }); + describe('output encoding', () => { + const tcases = [ + { encoding: 'hex', expected: inputs.hello.hash.toString('hex') }, + { encoding: 'base64', expected: inputs.hello.hash.toString('base64') }, + { encoding: 'utf8', expected: inputs.hello.hash.toString('utf8') }, + ]; + tcases.forEach(({ encoding, expected }) => it(encoding, () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.hash(inputs.hello.input).toString("${encoding}")`); + expect(result).to.equal(expected); + }))); + it('raw', () => __awaiter(this, void 0, void 0, function* () { + const result = (yield opts.page.evaluate(`blake3.hash(inputs.hello.input)`)); + const actual = Buffer.alloc(32); + for (let i = 0; i < actual.length; i++) { + actual[i] = result[i]; // it comes as a plain object, we need to convert it to a buffer + } + expect(actual).to.deep.equal(inputs.hello.hash); + })); + }); + describe('hash class', () => { + it('digests', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + ${[...Buffer.from(inputs.hello.input)] + .map(byte => `hash.update(new Uint8Array([${byte}]));`) + .join('\n')} + return hash.digest('hex'); + })()`); + expect(result).to.equal(inputs.hello.hash.toString('hex')); + })); + it('customizes the output length', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + hash.update(${JSON.stringify(inputs.hello.input)}); + return hash.digest('hex', { length: 16 }); + })()`); + expect(result).to.equal(inputs.hello.hash.slice(0, 16).toString('hex')); + })); + it('returns a hash instance from digest', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + ${[...Buffer.from(inputs.hello.input)] + .map(byte => `hash.update(new Uint8Array([${byte}]));`) + .join('\n')} + return hash.digest('hex'); + })()`); + expect(result).to.equal(inputs.hello.hash.toString('hex')); + })); + }); + describe('reader', () => { + it('is sane with a Hash', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + hash.update("hello"); + + return blake3.using(hash.reader(), reader => [ + reader.read(48).toString('hex'), + reader.toArray().toString('hex'), + reader.toString('hex'), + ]); + })()`); + expect(result).to.deep.equal([ + hello48.toString('hex'), + inputs.hello.hash.toString('hex'), + inputs.hello.hash.toString('hex'), + ]); + })); + }); + describe('original test vectors', () => { + for (const { inputLen, expectedDerive, expectedHash, expectedKeyed, } of ogTestVectors.cases.slice(0, 6)) { + describe(`${inputLen}`, () => __awaiter(this, void 0, void 0, function* () { + const input = Buffer.alloc(inputLen); + for (let i = 0; i < inputLen; i++) { + input[i] = i % 251; + } + const inputStr = `new Uint8Array([${input.join(',')}])`; + it('hash()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.hash( + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + expect(result).to.equal(expectedHash); + })); + it('deriveKey()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.deriveKey( + ${JSON.stringify(ogTestVectors.context)}, + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + expect(result).to.equal(expectedDerive); + })); + it('createKeyed()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hasher = blake3.createKeyed(new Uint8Array([${Buffer.from(ogTestVectors.key).join(',')}])); + hasher.update(${inputStr}); + return hasher.digest({ length: ${expectedHash.length / 2} }).toString('hex'); + })()`); + expect(result).to.equal(expectedKeyed); + })); + it('keyedHash()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.keyedHash( + new Uint8Array([${Buffer.from(ogTestVectors.key).join(',')}]), + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + expect(result).to.equal(expectedKeyed); + })); + })); + } + }); +} +//# sourceMappingURL=browser.test.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser.test.js.map b/node_modules/blake3-wasm/esm/browser.test.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b73ffc063f550ddd903e4154f54d2abd7be3c48b --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.test.js","sourceRoot":"","sources":["../ts/browser.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,aAAa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oBAEpB,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBACzC,CAAC,CAAA,CAAC,CAAC;YACL,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/encoding.d.ts b/node_modules/blake3-wasm/esm/browser/encoding.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c8b547c7c98d5265a56ea6619415890fbd35120 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/encoding.d.ts @@ -0,0 +1,5 @@ +export declare type BrowserEncoding = 'hex' | 'base64' | 'utf8'; +/** + * @hidden + */ +export declare const mustGetEncoder: (encoding: BrowserEncoding) => (data: Uint8Array) => string; diff --git a/node_modules/blake3-wasm/esm/browser/encoding.js b/node_modules/blake3-wasm/esm/browser/encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..0b6d1e44fbebf0726c1edcd3c8b9128a886b8a0b --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/encoding.js @@ -0,0 +1,28 @@ +// A small collection of encodings for convenience of use in the browser. +const decoder = new TextDecoder(); +const encoders = { + // certainly not the fastest, but hashes are pretty small + base64: data => btoa(String.fromCharCode(...data)), + hex: data => { + let out = ''; + for (const byte of data) { + if (byte < 0x10) { + out += '0'; + } + out += byte.toString(16); + } + return out; + }, + utf8: data => decoder.decode(data), +}; +/** + * @hidden + */ +export const mustGetEncoder = (encoding) => { + const encoder = encoders[encoding]; + if (!encoder) { + throw new Error(`Unknown encoding ${encoding}`); + } + return encoder; +}; +//# sourceMappingURL=encoding.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/encoding.js.map b/node_modules/blake3-wasm/esm/browser/encoding.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2a6cfe6c649e5d66ba2f48873fd62fd21dff59d9 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/encoding.js.map @@ -0,0 +1 @@ +{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../ts/browser/encoding.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAIzE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,QAAQ,GAA6D;IACzE,yDAAyD;IACzD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IAElD,GAAG,EAAE,IAAI,CAAC,EAAE;QACV,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;YACvB,IAAI,IAAI,GAAG,IAAI,EAAE;gBACf,GAAG,IAAI,GAAG,CAAC;aACZ;YAED,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SAC1B;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAyB,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;KACjD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-fn.d.ts b/node_modules/blake3-wasm/esm/browser/hash-fn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a341ea25f10048223542053a90bf0bd52cdc0bec --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-fn.d.ts @@ -0,0 +1,24 @@ +import { BaseHashInput, IBaseHashOptions } from '../base/hash-fn'; +import { Hash } from './hash'; +/** + * Input used for browser-based hashes. + */ +export declare type HashInput = BaseHashInput | string; +/** + * @hidden + */ +export declare const normalizeInput: (input: import("..").HashInput) => Uint8Array; +/** + * Returns a blake3 hash of the input. + */ +export declare function hash(input: HashInput, { length }?: IBaseHashOptions): Hash; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Hash; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export declare function keyedHash(key: Uint8Array, input: HashInput, { length }?: IBaseHashOptions): Hash; diff --git a/node_modules/blake3-wasm/esm/browser/hash-fn.js b/node_modules/blake3-wasm/esm/browser/hash-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..8306eed65bdd926e1e08776fe1c7191b46b3dae4 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-fn.js @@ -0,0 +1,42 @@ +import { inputToArray, defaultHashLength } from '../base/hash-fn.js'; +import { Hash } from './hash.js'; +import { getWasm } from './wasm.js'; +const textEncoder = new TextEncoder(); +/** + * @hidden + */ +export const normalizeInput = (input) => inputToArray(typeof input === 'string' ? textEncoder.encode(input) : input); +/** + * Returns a blake3 hash of the input. + */ +export function hash(input, { length = defaultHashLength } = {}) { + const result = new Hash(length); + getWasm().hash(normalizeInput(input), result); + return result; +} +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export function deriveKey(context, material, { length = defaultHashLength } = {}) { + const derive = getWasm().create_derive(context); + derive.update(normalizeInput(material)); + const result = new Hash(length); + derive.digest(result); + return result; +} +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export function keyedHash(key, input, { length = defaultHashLength } = {}) { + if (key.length !== 32) { + throw new Error(`key provided to keyedHash must be 32 bytes, got ${key.length}`); + } + const derive = getWasm().create_keyed(key); + derive.update(normalizeInput(input)); + const result = new Hash(length); + derive.digest(result); + return result; +} +//# sourceMappingURL=hash-fn.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-fn.js.map b/node_modules/blake3-wasm/esm/browser/hash-fn.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d43aa6b2b8314c62dbbaa734b1a0ee5c4c055a7f --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/browser/hash-fn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAOjC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAgB,EAAc,EAAE,CAC7D,YAAY,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,UAAU,IAAI,CAClB,KAAgB,EAChB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,OAAe,EACf,QAAmB,EACnB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,GAAe,EACf,KAAgB,EAChB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClF;IAED,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-instance.d.ts b/node_modules/blake3-wasm/esm/browser/hash-instance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a706b3e154ce9331bcc02b18ea0e4e62a63682c --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-instance.d.ts @@ -0,0 +1,31 @@ +import { BaseHash as BaseHasher } from '../base/index'; +import { HashInput } from './hash-fn'; +import { BrowserEncoding } from './encoding'; +import { IBaseHashOptions } from '../base/hash-fn'; +import { BrowserHashReader } from './hash-reader'; +import { IInternalReader } from '../base/hash-reader'; +import { Hash } from './hash'; +/** + * @inheritdoc + */ +export declare class BrowserHasher extends BaseHasher { + /** + * @inheritdoc + * @override + */ + update(data: HashInput): this; + /** + * Returns a digest of the hash with the given encoding. + */ + digest(options?: IBaseHashOptions): Hash; + digest(encoding: undefined, options: IBaseHashOptions): Hash; + digest(encoding: BrowserEncoding, options?: IBaseHashOptions): string; +} +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => BrowserHasher; +/** + * A Node.js crypto-like createHash method. + */ +export declare const createKeyed: (key: Uint8Array) => BrowserHasher; diff --git a/node_modules/blake3-wasm/esm/browser/hash-instance.js b/node_modules/blake3-wasm/esm/browser/hash-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..6f93c204ea93c161db11e0e0c8bd4e6cc7312b8b --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-instance.js @@ -0,0 +1,41 @@ +import { BaseHash as BaseHasher } from '../base/index.js'; +import { normalizeInput } from './hash-fn.js'; +import { mustGetEncoder } from './encoding.js'; +import { BrowserHashReader } from './hash-reader.js'; +import { Hash } from './hash.js'; +import { getWasm } from './wasm.js'; +/** + * @inheritdoc + */ +export class BrowserHasher extends BaseHasher { + /** + * @inheritdoc + * @override + */ + update(data) { + return super.update(normalizeInput(data)); + } + digest(encoding, options) { + let resolvedOpts; + let resolvedEnc; + if (encoding && typeof encoding === 'object') { + resolvedOpts = encoding; + resolvedEnc = undefined; + } + else { + resolvedOpts = options; + resolvedEnc = encoding; + } + const result = super.digest(resolvedOpts); + return resolvedEnc ? mustGetEncoder(resolvedEnc)(result) : result; + } +} +/** + * A Node.js crypto-like createHash method. + */ +export const createHash = () => new BrowserHasher(getWasm().create_hasher(), l => new Hash(l), r => new BrowserHashReader(r)); +/** + * A Node.js crypto-like createHash method. + */ +export const createKeyed = (key) => new BrowserHasher(getWasm().create_keyed(key), l => new Hash(l), r => new BrowserHashReader(r)); +//# sourceMappingURL=hash-instance.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-instance.js.map b/node_modules/blake3-wasm/esm/browser/hash-instance.js.map new file mode 100644 index 0000000000000000000000000000000000000000..717166f3a14825cb30024359686adfc6007c8d20 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/browser/hash-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAa,MAAM,WAAW,CAAC;AACtD,OAAO,EAAmB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAoD;IACrF;;;OAGG;IACI,MAAM,CAAC,IAAe;QAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAQM,MAAM,CACX,QAA6C,EAC7C,OAA0B;QAE1B,IAAI,YAA0C,CAAC;QAC/C,IAAI,WAAwC,CAAC;QAC7C,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAC5C,YAAY,GAAG,QAAQ,CAAC;YACxB,WAAW,GAAG,SAAS,CAAC;SACzB;aAAM;YACL,YAAY,GAAG,OAAO,CAAC;YACvB,WAAW,GAAG,QAAQ,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACpE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAC7B,IAAI,aAAa,CACf,OAAO,EAAE,CAAC,aAAa,EAAE,EACzB,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAChB,CAAC,CAAC,EAAE,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAC9B,CAAC;AAEJ;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAe,EAAE,EAAE,CAC7C,IAAI,aAAa,CACf,OAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAC3B,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAChB,CAAC,CAAC,EAAE,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAC9B,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-reader.d.ts b/node_modules/blake3-wasm/esm/browser/hash-reader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f2a75c7cf1f3d64ba02e9e5773db0ad9cdfe5711 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-reader.d.ts @@ -0,0 +1,17 @@ +import { BaseHashReader } from '../base/hash-reader'; +import { BrowserEncoding } from './encoding'; +import { Hash } from './hash'; +/** + * A hash reader for WebAssembly targets. + */ +export declare class BrowserHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding?: BrowserEncoding): string; + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray(): Hash; + protected alloc(bytes: number): Hash; +} diff --git a/node_modules/blake3-wasm/esm/browser/hash-reader.js b/node_modules/blake3-wasm/esm/browser/hash-reader.js new file mode 100644 index 0000000000000000000000000000000000000000..1843eb07f71980ad6b544c88f49bd1540d27d596 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-reader.js @@ -0,0 +1,25 @@ +import { BaseHashReader } from '../base/hash-reader.js'; +import { Hash } from './hash.js'; +import { defaultHashLength } from '../base/index.js'; +/** + * A hash reader for WebAssembly targets. + */ +export class BrowserHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toArray().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray() { + this.position = BigInt(0); + return this.read(defaultHashLength); + } + alloc(bytes) { + return new Hash(bytes); + } +} +//# sourceMappingURL=hash-reader.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-reader.js.map b/node_modules/blake3-wasm/esm/browser/hash-reader.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e4549e0a0fbfcca68c803dfeafa0809778e0ac51 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/browser/hash-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAoB;IACzD;;OAEG;IACI,QAAQ,CAAC,WAA4B,KAAK;QAC/C,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,KAAa;QAC3B,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACF"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash.d.ts b/node_modules/blake3-wasm/esm/browser/hash.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6487771755ba014a52333bc5413d28a10d5f67c6 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash.d.ts @@ -0,0 +1,11 @@ +import { BrowserEncoding } from './encoding'; +/** + * Hash returned from functions in the browser. + */ +export declare class Hash extends Uint8Array { + /** + * A constant-time comparison against the other hash/array. + */ + equals(other: unknown): boolean; + toString(encoding?: BrowserEncoding): string; +} diff --git a/node_modules/blake3-wasm/esm/browser/hash.js b/node_modules/blake3-wasm/esm/browser/hash.js new file mode 100644 index 0000000000000000000000000000000000000000..9940c74bb154eee94e5f0937e3fcacbdd990be00 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash.js @@ -0,0 +1,26 @@ +import { mustGetEncoder } from './encoding.js'; +/** + * Hash returned from functions in the browser. + */ +export class Hash extends Uint8Array { + /** + * A constant-time comparison against the other hash/array. + */ + equals(other) { + if (!(other instanceof Uint8Array)) { + return false; + } + if (other.length !== this.length) { + return false; + } + let cmp = 0; + for (let i = 0; i < this.length; i++) { + cmp |= this[i] ^ other[i]; + } + return cmp === 0; + } + toString(encoding = 'hex') { + return mustGetEncoder(encoding)(this); + } +} +//# sourceMappingURL=hash.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash.js.map b/node_modules/blake3-wasm/esm/browser/hash.js.map new file mode 100644 index 0000000000000000000000000000000000000000..0012b8b2054b298294576c5debefd5454c27ef26 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../ts/browser/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IAClC;;OAEG;IACI,MAAM,CAAC,KAAc;QAC1B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;YAClC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3B;QAED,OAAO,GAAG,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,QAAQ,CAAC,WAA4B,KAAK;QAC/C,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/index.d.ts b/node_modules/blake3-wasm/esm/browser/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f44c7ede6aebba6bb85bcfd6f8bc9c9ce3422d8d --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/index.d.ts @@ -0,0 +1,3 @@ +export { hash, HashInput, deriveKey, keyedHash } from './hash-fn'; +export * from './hash-instance'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/esm/browser/index.js b/node_modules/blake3-wasm/esm/browser/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e9de3ec3c64362f63b6d790758de2370c93d97ad --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/index.js @@ -0,0 +1,4 @@ +export { hash, deriveKey, keyedHash } from './hash-fn.js'; +export * from './hash-instance.js'; +export * from '../base/index.js'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/index.js.map b/node_modules/blake3-wasm/esm/browser/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..cefc8f5b5b57fc02ace34fe4426064c7cd003143 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAa,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAClE,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/wasm.d.ts b/node_modules/blake3-wasm/esm/browser/wasm.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..559b61e1b407ac945602c0bc6c49fb4b3e800cc9 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/wasm.d.ts @@ -0,0 +1,10 @@ +import * as rawWasm from '../../dist/wasm/browser/blake3_js'; +/** + * Gets the webassembly module provided in provideWasm. + */ +export declare const getWasm: () => typeof rawWasm; +/** + * Sets the webassembly module used for the browser build. This indirection is + * needed to provide compatibility between the "browser" and "browser-async" modes. + */ +export declare const provideWasm: (w: typeof rawWasm) => void; diff --git a/node_modules/blake3-wasm/esm/browser/wasm.js b/node_modules/blake3-wasm/esm/browser/wasm.js new file mode 100644 index 0000000000000000000000000000000000000000..2fe61f348f7a6326dcf4b46060ecb25b553ccaf1 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/wasm.js @@ -0,0 +1,18 @@ +let wasm; +/** + * Gets the webassembly module provided in provideWasm. + */ +export const getWasm = () => { + if (!wasm) { + throw new Error('BLAKE3 webassembly not loaded. Please import the module via `blake3/browser` or `blake3/browser-async`'); + } + return wasm; +}; +/** + * Sets the webassembly module used for the browser build. This indirection is + * needed to provide compatibility between the "browser" and "browser-async" modes. + */ +export const provideWasm = (w) => { + wasm = w; +}; +//# sourceMappingURL=wasm.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/wasm.js.map b/node_modules/blake3-wasm/esm/browser/wasm.js.map new file mode 100644 index 0000000000000000000000000000000000000000..40ec9373ccd32b698f2e9f0536ae648012de8a20 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/wasm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../ts/browser/wasm.ts"],"names":[],"mappings":"AAEA,IAAI,IAAoB,CAAC;AAEzB;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAiB,EAAE,EAAE;IAC/C,IAAI,GAAG,CAAC,CAAC;AACX,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/add-js-extensions.d.ts b/node_modules/blake3-wasm/esm/build/add-js-extensions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/add-js-extensions.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/build/add-js-extensions.js b/node_modules/blake3-wasm/esm/build/add-js-extensions.js new file mode 100644 index 0000000000000000000000000000000000000000..d7f4b40ee9466ff3787de0e17fb5b76ac9452f2f --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/add-js-extensions.js @@ -0,0 +1,40 @@ +import * as ts from 'typescript.js'; +import { readFileSync, writeFileSync, readdirSync, statSync } from 'fs.js'; +import { extname, basename, join, resolve } from 'path.js'; +/** + * Script that adds .js extension to imports so that it's compatible with plain + * browser/non-webpack bundlers. TS doesn't support this natively yet. + * @see https://github.com/microsoft/TypeScript/issues/16577 + */ +function processFile(file) { + let source = readFileSync(file, 'utf-8'); + const program = ts.createSourceFile(basename(file), source, ts.ScriptTarget.ES2015, true); + let offset = 0; + const process = (node) => { + if ((!ts.isImportDeclaration(node) && !ts.isExportDeclaration(node)) || !node.moduleSpecifier) { + return ts.forEachChild(node, process); + } + const specifier = node.moduleSpecifier; + if (extname(specifier.getText()) === '') { + const idx = specifier.end + offset - 1; + source = source.slice(0, idx) + '.js' + source.slice(idx); + offset += 3; + } + }; + process(program); + writeFileSync(file, source); +} +function processDir(dir) { + const entries = readdirSync(dir); + for (const entry of entries) { + const path = join(dir, entry); + if (path.endsWith('.js')) { + processFile(path); + } + else if (statSync(path).isDirectory()) { + processDir(path); + } + } +} +processDir(resolve(__dirname, '..', '..', 'esm')); +//# sourceMappingURL=add-js-extensions.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/add-js-extensions.js.map b/node_modules/blake3-wasm/esm/build/add-js-extensions.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a953f5d8edd0d71c05604268d97944eb4a4ba290 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/add-js-extensions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"add-js-extensions.js","sourceRoot":"","sources":["../../ts/build/add-js-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAExD;;;;GAIG;AAEH,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE1F,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,OAAO,GAAG,CAAC,IAAa,EAAQ,EAAE;QACtC,IAAI,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YAC7F,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SACvC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC;QACvC,IAAI,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACvC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;YACvC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1D,MAAM,IAAI,CAAC,CAAC;SACb;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACxB,WAAW,CAAC,IAAI,CAAC,CAAC;SACnB;aAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;YACvC,UAAU,CAAC,IAAI,CAAC,CAAC;SAClB;KACF;AACH,CAAC;AAED,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/generate-tasks.d.ts b/node_modules/blake3-wasm/esm/build/generate-tasks.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/generate-tasks.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/build/generate-tasks.js b/node_modules/blake3-wasm/esm/build/generate-tasks.js new file mode 100644 index 0000000000000000000000000000000000000000..0993219fbbd6bf6d32e261599294821e3d024360 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/generate-tasks.js @@ -0,0 +1,83 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { writeFileSync } from 'fs.js'; +import { dump } from 'js-yaml.js'; +import fetch from 'node-fetch.js'; +import { join } from 'path.js'; +const minVersion = 64; +(() => __awaiter(void 0, void 0, void 0, function* () { + const res = yield fetch('https://nodejs.org/dist/index.json'); + if (!res.ok) { + throw new Error(`${res.status} error from Node.js releases page`); + } + const releases = yield res.json(); + const buildVersion = new Map(); + const versionMap = {}; + for (const release of releases) { + const moduleVersion = Number(release.modules); + if (!moduleVersion || moduleVersion < minVersion) { + break; + } + versionMap[release.version] = Number(moduleVersion); + if (buildVersion.has(moduleVersion)) { + continue; + } + buildVersion.set(moduleVersion, release.version); + } + const buildYaml = { + name: 'Generate Binaries', + on: { + push: { + branches: ['generate-binary'], + }, + }, + jobs: { + build: { + name: 'Build', + 'runs-on': '${{ matrix.os }}', + strategy: { + matrix: { os: ['macos-latest', 'ubuntu-latest', 'windows-latest'] }, + }, + steps: [ + { uses: 'actions/checkout@master' }, + { run: 'mkdir dist' }, + { + uses: 'actions-rs/toolchain@v1', + with: { target: 'wasm32-unknown-unknown', toolchain: 'nightly' }, + }, + ...[...buildVersion.entries()] + .map(([moduleVersion, nodeVersion], i) => [ + { uses: 'actions/setup-node@v1', with: { 'node-version': nodeVersion } }, + { + // See: https://github.com/actions/setup-node/issues/68 + shell: 'powershell', + name: 'patch node-gyp for VS 2019', + run: 'npm install --global node-gyp@latest\r\nnpm prefix -g | % {npm config set node_gyp "$_\\node_modules\\node-gyp\\bin\\node-gyp.js"}', + if: "matrix.os == 'windows-latest'", + }, + i === 0 + ? { run: 'npm install neon-cli rimraf' } + : { run: './node_modules/.bin/rimraf rs/native/target' }, + { run: '../node_modules/.bin/neon build --release', 'working-directory': 'rs' }, + { run: `mv rs/native/index.node dist/\${{ matrix.os }}-${moduleVersion}.node` }, + ]) + .reduce((acc, v) => [...acc, ...v], []), + { + uses: 'actions/upload-artifact@v1', + with: { name: 'dist', path: 'dist' }, + }, + ], + }, + }, + }; + writeFileSync(join(__dirname, '..', '..', '.github', 'workflows', 'build-neon.yml'), dump(buildYaml)); + writeFileSync(join(__dirname, '..', '..', 'targets.json'), JSON.stringify(versionMap)); +}))(); +//# sourceMappingURL=generate-tasks.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/generate-tasks.js.map b/node_modules/blake3-wasm/esm/build/generate-tasks.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a7e23b7b4c184fadff7b1a51489a25023d3243b9 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/generate-tasks.js.map @@ -0,0 +1 @@ +{"version":3,"file":"generate-tasks.js","sourceRoot":"","sources":["../../ts/build/generate-tasks.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,CAAC,GAAS,EAAE;IACV,MAAM,GAAG,GAAG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AAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/install.d.ts b/node_modules/blake3-wasm/esm/build/install.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/install.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/build/install.js b/node_modules/blake3-wasm/esm/build/install.js new file mode 100644 index 0000000000000000000000000000000000000000..21102849ddf2685ee899f6c02d100e8aa93a9907 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/install.js @@ -0,0 +1,98 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { createWriteStream, readFileSync, writeFileSync } from 'fs.js'; +import { get } from 'https.js'; +import { join } from 'path.js'; +import { pipeline } from 'stream.js'; +import { compareVersion, parseVersion } from './versions.js'; +/** + * Post-install script. Downloads the binary for the current Node.js version + * from the Gitub releases page, if it's available. + */ +const builtPlatforms = { + win32: 'windows-latest', + linux: 'ubuntu-latest', + darwin: 'macos-latest', +}; +const { version } = require('../../package.json'); +const repoUrl = process.env.BLAKE3_REPO_URL || 'https://github.com/connor4312/blake3'; +const targets = require('../../targets.json'); +const bindingPath = join(__dirname, '..', 'native.node'); +function install() { + return __awaiter(this, void 0, void 0, function* () { + const current = parseVersion(process.version); + const api = getBestAbiVersion(current); + if (!api) { + console.error('Your Node.js release is out of LTS and BLAKE3 bindings are not built for it. Update it to use native BLAKE3 bindings.'); + return fallback(); + } + const platform = builtPlatforms[process.platform]; + if (!platform) { + console.error(`BLAKE3 bindings are not built for your platform (${process.platform})`); + return fallback(); + } + console.log(`Retrieving native BLAKE3 bindings for Node ${api.nodeVersion} on ${process.platform}...`); + yield download(`${repoUrl}/releases/download/v${version}/${platform}-${api.abiVersion}.node`); + try { + require(bindingPath); + } + catch (e) { + console.log(`Error trying to import bindings: ${e.message}`); + return fallback(); + } + useNativeImport(); + console.log('BLAKE3 bindings retrieved'); + }); +} +function getBestAbiVersion(current) { + for (const targetVersion of Object.keys(targets)) { + const parsed = parseVersion(targetVersion); + if (compareVersion(current, parsed) >= 0) { + return { nodeVersion: targetVersion, abiVersion: targets[targetVersion] }; + } + } + return undefined; +} +function fallback() { + console.error('BLAKE3 will use slower WebAssembly bindings when required in Node.js'); +} +function download(url) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise(resolve => { + const onError = (err) => { + console.error(`Could not download binding from ${url}: ${err.stack || err.message}`); + resolve(false); + }; + const req = get(url, res => { + if (res.headers.location) { + resolve(download(res.headers.location)); + return; + } + if (!res.statusCode || res.statusCode >= 300) { + console.error(`Unexpected ${res.statusCode} from ${url}`); + resolve(false); + return; + } + pipeline(res, createWriteStream(bindingPath), err => (err ? onError(err) : resolve(true))); + }); + req.on('error', onError); + }); + }); +} +function useNativeImport() { + const indexFile = join(__dirname, '..', 'index.js'); + const contents = readFileSync(indexFile, 'utf-8'); + writeFileSync(indexFile, contents.replace('"./node"', '"./node-native"')); +} +install().catch(err => { + console.error(`There was an uncaught error installing native bindings: ${err.stack}`); + fallback(); +}); +//# sourceMappingURL=install.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/install.js.map b/node_modules/blake3-wasm/esm/build/install.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ebdb3b2ff1e1f4526890011ae32fa4390b5f3535 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/install.js.map @@ -0,0 +1 @@ +{"version":3,"file":"install.js","sourceRoot":"","sources":["../../ts/build/install.ts"],"names":[],"mappings":";;;;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100644 index 0000000000000000000000000000000000000000..17d98415f31576e8d3aa5e8d161a7fbed71cff0b --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/versions.d.ts @@ -0,0 +1,14 @@ +export declare const minNodeVersion = 10; +/** + * @hidden + */ +export interface IVersion { + major: number; + minor: number; + patch: number; +} +/** + * @hidden + */ +export declare const parseVersion: (version: string) => IVersion; +export declare const compareVersion: (a: IVersion, b: IVersion) => number; diff --git a/node_modules/blake3-wasm/esm/build/versions.js b/node_modules/blake3-wasm/esm/build/versions.js new file mode 100644 index 0000000000000000000000000000000000000000..be5ab4b4949d0a61fd5082fa824de8299a41c82f --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/versions.js @@ -0,0 +1,10 @@ +export const minNodeVersion = 10; +/** + * @hidden + */ +export const parseVersion = (version) => { + const [, major, minor, patch] = /^v([0-9]+)\.([0-9]+)\.([0-9]+)/.exec(version) || []; + return { major: Number(major), minor: Number(minor), patch: Number(patch) }; +}; +export const compareVersion = (a, b) => a.major - b.major || a.minor - b.minor || a.patch - b.patch; +//# sourceMappingURL=versions.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/versions.js.map b/node_modules/blake3-wasm/esm/build/versions.js.map new file mode 100644 index 0000000000000000000000000000000000000000..fef0d7e10fc04cb94fd073d569bae53dcf3e9bf6 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/versions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../ts/build/versions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAWjC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAY,EAAE;IACxD,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,gCAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACrF,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC9E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAW,EAAE,CAAW,EAAE,EAAE,CACzD,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/index.d.ts b/node_modules/blake3-wasm/esm/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0dddb69c011f6c534050580097bb28d927fad16 --- /dev/null +++ b/node_modules/blake3-wasm/esm/index.d.ts @@ -0,0 +1 @@ +export * from './node'; diff --git a/node_modules/blake3-wasm/esm/index.js b/node_modules/blake3-wasm/esm/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8d88eda5a38c1fe7f5a1e997431fc459d7e3be85 --- /dev/null +++ b/node_modules/blake3-wasm/esm/index.js @@ -0,0 +1,14 @@ +// Bunlers add the `process.browser` flag to indicate the build enviroment. +// Throw a verbose error if we see people bundling the Node.js build in their +// browser, since it probably won't work for them (or at least not give them) +// nice tree shaking and such. +// +// Note that we don't check the presence of window/document, since those can +// be emulated in common test scenarios (e.g. jest's default setup with jsdom). +if (process.browser) { + throw new Error('You tried to import the Node.js version of blake3, instead of the browser ' + + 'version, in your build. You can fix this by importing "blake3/browser" ' + + 'instead of "blake3"'); +} +export * from './node.js'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/index.js.map b/node_modules/blake3-wasm/esm/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d44991f94c21170bfb2792137551f86c904e21cd --- /dev/null +++ b/node_modules/blake3-wasm/esm/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,8BAA8B;AAC9B,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,IAAK,OAAe,CAAC,OAAO,EAAE;IAC5B,MAAM,IAAI,KAAK,CACb,4EAA4E;QAC1E,yEAAyE;QACzE,qBAAqB,CACxB,CAAC;CACH;AAED,cAAc,QAAQ,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/hash-fn.d.ts b/node_modules/blake3-wasm/esm/node-native/hash-fn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..573cb22c7d1688ec38c55ea4df1a7aab2b761da8 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-fn.d.ts @@ -0,0 +1,21 @@ +/// +import { HashInput } from '../node/hash-fn'; +import { IBaseHashOptions } from '../base/hash-fn'; +/** + * @hidden + */ +export declare const normalizeInput: (input: HashInput, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Buffer; +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +export declare function hash(input: HashInput, { length }?: IBaseHashOptions): Buffer | string; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Buffer; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export declare function keyedHash(key: Buffer, input: HashInput, { length }?: IBaseHashOptions): Buffer; diff --git a/node_modules/blake3-wasm/esm/node-native/hash-fn.js b/node_modules/blake3-wasm/esm/node-native/hash-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..a38d8c11411268913f0bcb09aa4208b356111df5 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-fn.js @@ -0,0 +1,43 @@ +import native from './native.js'; +import { defaultHashLength } from '../base/hash-fn.js'; +/** + * @hidden + */ +export const normalizeInput = (input, encoding) => { + if (input instanceof Buffer) { + return input; + } + if (typeof input === 'string') { + return Buffer.from(input, encoding); + } + return Buffer.from(input); +}; +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +export function hash(input, { length = defaultHashLength } = {}) { + return native.hash(normalizeInput(input), length); +} +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export function deriveKey(context, material, { length = defaultHashLength } = {}) { + const hasher = new native.Hasher(undefined, context); + hasher.update(normalizeInput(material)); + const result = Buffer.alloc(length); + hasher.digest(result); + return result; +} +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export function keyedHash(key, input, { length = defaultHashLength } = {}) { + const hasher = new native.Hasher(key); + hasher.update(normalizeInput(input)); + const result = Buffer.alloc(length); + hasher.digest(result); + return result; +} +//# sourceMappingURL=hash-fn.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/hash-fn.js.map b/node_modules/blake3-wasm/esm/node-native/hash-fn.js.map new file mode 100644 index 0000000000000000000000000000000000000000..96b02af08e8e831fba4ce2c397b2c47ce9914a76 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/node-native/hash-fn.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAoB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAgB,EAAE,QAAyB,EAAU,EAAE;IACpF,IAAI,KAAK,YAAY,MAAM,EAAE;QAC3B,OAAO,KAAK,CAAC;KACd;IAED,IAAI,OAAO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blake3-wasm/esm/node-native/hash-instance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f1d97ba18574b1e7f833c8b30f45494f25fe927c --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-instance.d.ts @@ -0,0 +1,15 @@ +/// +import { INativeReader } from './native'; +import { NodeHash } from '../node/hash-instance'; +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => NodeHash; +/** + * Construct a new Hasher for the keyed hash function. + */ +export declare const createKeyed: (key: Buffer) => NodeHash; +/** + * Construct a new Hasher for the key derivation function. + */ +export declare const createDeriveKey: (context: string) => NodeHash; diff --git a/node_modules/blake3-wasm/esm/node-native/hash-instance.js b/node_modules/blake3-wasm/esm/node-native/hash-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..86da52d012d8b824b2ec42c4042893ddaa1bf61d --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-instance.js @@ -0,0 +1,26 @@ +import native from './native.js'; +import { NodeHash } from '../node/hash-instance.js'; +import { NodeHashReader } from '../node/hash-reader.js'; +// A buffer we reuse for sending bigints. set_position is synchronous, so +// this just saves creating garbage. +const bigIntBuffer = Buffer.alloc(8); +const readerFactory = (r) => new NodeHashReader({ + fill: target => r.fill(target), + set_position: position => { + bigIntBuffer.writeBigUInt64BE(position); + r.set_position(bigIntBuffer); + }, +}); +/** + * A Node.js crypto-like createHash method. + */ +export const createHash = () => new NodeHash(new native.Hasher(), readerFactory); +/** + * Construct a new Hasher for the keyed hash function. + */ +export const createKeyed = (key) => new NodeHash(new native.Hasher(key), readerFactory); +/** + * Construct a new Hasher for the key derivation function. + */ +export const createDeriveKey = (context) => new NodeHash(new native.Hasher(undefined, context), readerFactory); +//# sourceMappingURL=hash-instance.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/hash-instance.js.map b/node_modules/blake3-wasm/esm/node-native/hash-instance.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9339845d62f573b1cb2e89605e42a25c588cbd3b --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/node-native/hash-instance.ts"],"names":[],"mappings":"AAAA,OAAO,MAAyB,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,yEAAyE;AACzE,oCAAoC;AACpC,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAErC,MAAM,aAAa,GAAG,CAAC,CAAgB,EAAE,EAAE,CACzC,IAAI,cAAc,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B,YAAY,EAAE,QAAQ,CAAC,EAAE;QACvB,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC;AAEjF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;AAEhG;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CACjD,IAAI,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/index.d.ts b/node_modules/blake3-wasm/esm/node-native/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e37c80edc011842f54de2497496ce1c7793c7fd5 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/index.d.ts @@ -0,0 +1,5 @@ +export { HashInput } from '../node/hash-fn'; +export { hash, deriveKey, keyedHash } from './hash-fn'; +export * from '../node/hash-reader'; +export * from './hash-instance'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/esm/node-native/index.js b/node_modules/blake3-wasm/esm/node-native/index.js new file mode 100644 index 0000000000000000000000000000000000000000..52595eef3ed56a12f5c203c08797e874db1e1600 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/index.js @@ -0,0 +1,5 @@ +export { hash, deriveKey, keyedHash } from './hash-fn.js'; +export * from '../node/hash-reader.js'; +export * from './hash-instance.js'; +export * from '../base/index.js'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/index.js.map b/node_modules/blake3-wasm/esm/node-native/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a46564a34991ba2be55f70c5e6de99b9d3c5086d --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/node-native/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/native.d.ts b/node_modules/blake3-wasm/esm/node-native/native.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..be1a909d730fa530b70eb85390929bd02bf4a9d4 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/native.d.ts @@ -0,0 +1,16 @@ +/// +import { IInternalHash } from '../base/index'; +export interface INativeReader { + free?(): void; + fill(target: Uint8Array): void; + set_position(position: Buffer): void; +} +export interface INativeHash extends IInternalHash { + new (hashKey?: Buffer, context?: string): INativeHash; +} +export interface INativeModule { + Hasher: INativeHash; + hash(input: Buffer, length: number): Buffer; +} +declare const native: INativeModule; +export default native; diff --git a/node_modules/blake3-wasm/esm/node-native/native.js b/node_modules/blake3-wasm/esm/node-native/native.js new file mode 100644 index 0000000000000000000000000000000000000000..d8583190ccc83a59450f4c38bfce78453c4aa379 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/native.js @@ -0,0 +1,3 @@ +const native = require('../native.node'); +export default native; +//# sourceMappingURL=native.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/native.js.map b/node_modules/blake3-wasm/esm/node-native/native.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5fdca1c02f45dd14572fe595026b1b7573364455 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"native.js","sourceRoot":"","sources":["../../ts/node-native/native.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,GAAkB,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAExD,eAAe,MAAM,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node.test.d.ts b/node_modules/blake3-wasm/esm/node.test.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/node_modules/blake3-wasm/esm/node.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/node.test.js b/node_modules/blake3-wasm/esm/node.test.js new file mode 100644 index 0000000000000000000000000000000000000000..4523c31b1be13afa570b7d82d9755f7b6d3ccb14 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node.test.js @@ -0,0 +1,198 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import * as wasm from './node.js'; +import * as native from './node-native.js'; +import { expect } from 'chai.js'; +import { inputs, hello48, ogTestVectors } from './base/test-helpers.js'; +import { ReadableStreamBuffer } from 'stream-buffers.js'; +import { maxHashBytes } from './base/hash-reader.js'; +function suite({ hash, createHash, keyedHash, deriveKey, createDeriveKey, createKeyed, }) { + describe('encoding', () => { + it('hashes a buffer', () => { + expect(hash(Buffer.from(inputs.hello.input))).to.deep.equal(inputs.hello.hash); + }); + it('hashes a string', () => { + expect(hash(inputs.hello.input)).to.deep.equal(inputs.hello.hash); + }); + it('hashes an arraybuffer', () => { + const buf = Buffer.from(inputs.hello.input); + expect(hash(new Uint8Array(buf).buffer)).to.deep.equal(inputs.hello.hash); + }); + it('customizes the output length', () => { + expect(hash(inputs.hello.input, { length: 16 })).to.deep.equal(inputs.hello.hash.slice(0, 16)); + }); + }); + describe('memory-safety (#5)', () => { + it('hash', () => { + const hashA = hash('hello'); + const hashB = hash('goodbye'); + expect(hashA.toString('hex')).to.equal('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f'); + expect(hashB.toString('hex')).to.equal('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69'); + }); + it('hasher', () => { + const hasherA = createHash(); + const hasherB = createHash(); + hasherA.update('hel'); + hasherB.update('good'); + hasherA.update('lo'); + hasherB.update('bye'); + const hashA = hasherA.digest(); + const hashB = hasherB.digest(); + expect(hashA.toString('hex')).to.equal('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f'); + expect(hashB.toString('hex')).to.equal('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69'); + }); + }); + describe('hasher', () => { + it('digests', callback => { + const buffer = new ReadableStreamBuffer(); + buffer.put(Buffer.from(inputs.large.input)); + buffer.stop(); + const hash = createHash(); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest(); + expect(actual).to.deep.equal(inputs.large.hash); + callback(); + }); + }); + it('is a transform stream', callback => { + const buffer = new ReadableStreamBuffer(); + buffer.put(Buffer.from(inputs.large.input)); + buffer.stop(); + buffer + .pipe(createHash()) + .on('error', callback) + .on('data', hash => { + expect(hash).to.deep.equal(inputs.large.hash); + callback(); + }); + }); + it('customizes the output length', () => { + const hash = createHash(); + hash.update(inputs.hello.input); + expect(hash.digest('hex', { length: 16 })).to.equal(inputs.hello.hash.slice(0, 16).toString('hex')); + }); + it('throws on write after dispose', () => { + const hash = createHash(); + hash.dispose(); + expect(() => hash.update('')).to.throw(/after dispose/); + }); + it('allows taking incremental hashes', () => { + const hasher = createHash(); + hasher.update('hel'); + const hashA = hasher.digest(undefined, { dispose: false }); + const readA = hasher.reader({ dispose: false }); + hasher.update('lo'); + const hashB = hasher.digest(undefined, { dispose: false }); + const readB = hasher.reader({ dispose: false }); + const expectedA = Buffer.from('3121c5bb1b9193123447ac7cfda042f67f967e7a8cf5c12e7570e25529746e4a', 'hex'); + expect(hashA).to.deep.equal(expectedA); + expect(readA.toBuffer()).to.deep.equal(expectedA); + expect(hashB).to.deep.equal(inputs.hello.hash); + expect(readB.toBuffer()).to.deep.equal(inputs.hello.hash); + hasher.dispose(); + readA.dispose(); + readB.dispose(); + }); + }); + describe('reader', () => { + let reader; + beforeEach(() => { + const hash = createHash(); + hash.update(inputs.hello.input); + reader = hash.reader(); + }); + afterEach(() => reader.dispose()); + it('implements toString()', () => { + expect(reader.toString('hex')).to.equal(inputs.hello.hash.toString('hex')); + reader.position = BigInt(42); + expect(reader.toString('hex')).to.equal(inputs.hello.hash.toString('hex')); + }); + it('implements toBuffer()', () => { + expect(reader.toBuffer()).to.deep.equal(inputs.hello.hash); + reader.position = BigInt(42); + expect(reader.toBuffer()).to.deep.equal(inputs.hello.hash); + }); + it('implements readInto() and advances', () => { + const actual = Buffer.alloc(32); + reader.readInto(actual.slice(0, 10)); + reader.readInto(actual.slice(10)); + expect(actual).to.deep.equal(inputs.hello.hash); + expect(reader.position).to.equal(BigInt(32)); + }); + it('implements read() and advances', () => { + const actual = reader.read(32); + expect(actual).to.deep.equal(inputs.hello.hash); + expect(reader.position).to.equal(BigInt(32)); + const actualNext = reader.read(16); + expect(actualNext).to.deep.equal(hello48.slice(32)); + expect(reader.position).to.equal(BigInt(48)); + }); + it('manually sets position', () => { + reader.position = BigInt(32); + const actual = reader.read(16); + expect(actual).to.deep.equal(hello48.slice(32)); + }); + it('throws if set out of range', () => { + expect(() => (reader.position = BigInt(-1))).to.throw(RangeError); + expect(() => (reader.position = BigInt('18446744073709551616'))).to.throw(RangeError); + reader.position = maxHashBytes - BigInt(1); + expect(() => reader.read(2)).to.throw(RangeError); + }); + }); + describe('original test vectors', () => { + for (const { inputLen, expectedDerive, expectedKeyed, expectedHash } of ogTestVectors.cases) { + describe(`${inputLen}`, () => __awaiter(this, void 0, void 0, function* () { + const input = Buffer.alloc(inputLen); + for (let i = 0; i < inputLen; i++) { + input[i] = i % 251; + } + it('hash()', () => { + expect(hash(input, { length: expectedHash.length / 2 }).toString('hex')).to.equal(expectedHash); + }); + it('deriveKey()', () => { + expect(deriveKey(ogTestVectors.context, input, { length: expectedDerive.length / 2 }).toString('hex')).to.equal(expectedDerive); + }); + it('createDeriveKey()', callback => { + const buffer = new ReadableStreamBuffer(); + buffer.put(Buffer.from(input)); + buffer.stop(); + const hash = createDeriveKey(ogTestVectors.context); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest({ length: expectedDerive.length / 2 }).toString('hex'); + expect(actual).to.equal(expectedDerive); + callback(); + }); + }); + it('keyedHash()', () => { + expect(keyedHash(Buffer.from(ogTestVectors.key), input, { + length: expectedKeyed.length / 2, + }).toString('hex')).to.equal(expectedKeyed); + }); + it('createKeyed()', callback => { + const buffer = new ReadableStreamBuffer(); + buffer.put(Buffer.from(input)); + buffer.stop(); + const hash = createKeyed(Buffer.from(ogTestVectors.key)); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest({ length: expectedDerive.length / 2 }).toString('hex'); + expect(actual).to.equal(expectedKeyed); + callback(); + }); + }); + })); + } + }); +} +describe('node.js wasm', () => suite(wasm)); +describe('node.js native', () => suite(native)); +//# sourceMappingURL=node.test.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node.test.js.map b/node_modules/blake3-wasm/esm/node.test.js.map new file mode 100644 index 0000000000000000000000000000000000000000..836aa6ba2bd5f3067ff8688b539e9c3bd164fdff --- /dev/null +++ b/node_modules/blake3-wasm/esm/node.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"node.test.js","sourceRoot":"","sources":["../ts/node.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,SAAS,KAAK,CAAC,EACb,IAAI,EACJ,UAAU,EACV,SAAS,EACT,SAAS,EACT,eAAe,EACf,WAAW,GACiB;IAC5B,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;QACxB,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;YACzB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC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AC;oBACzD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;oBACvC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;wBACpB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;wBAClF,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;wBACvC,QAAQ,EAAE,CAAC;oBACb,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-fn.d.ts b/node_modules/blake3-wasm/esm/node/hash-fn.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..33d792731c3092fb8d5138b050cf9b7ee68989c8 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-fn.d.ts @@ -0,0 +1,24 @@ +/// +import { BaseHashInput, IBaseHashOptions } from '../base/hash-fn'; +/** + * Input used for node-based hashes. + */ +export declare type HashInput = BaseHashInput | string; +/** + * @hidden + */ +export declare const normalizeInput: (input: HashInput, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Uint8Array; +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +export declare function hash(input: HashInput, { length }?: IBaseHashOptions): Buffer | string; +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Buffer; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export declare function keyedHash(key: Buffer, input: HashInput, { length }?: IBaseHashOptions): Buffer; diff --git a/node_modules/blake3-wasm/esm/node/hash-fn.js b/node_modules/blake3-wasm/esm/node/hash-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..6c47599124013e15c7452a203d3b41d8bfd0a4c4 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-fn.js @@ -0,0 +1,40 @@ +import { inputToArray, defaultHashLength } from '../base/hash-fn.js'; +import { hash as rawHash, create_derive as createDerive, create_keyed as createKeyed, } from '../../dist/wasm/nodejs/blake3_js.js'; +/** + * @hidden + */ +export const normalizeInput = (input, encoding) => inputToArray(typeof input === 'string' ? Buffer.from(input, encoding) : input); +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +export function hash(input, { length = defaultHashLength } = {}) { + const result = Buffer.alloc(length); + rawHash(normalizeInput(input), result); + return result; +} +/** + * Given cryptographic key material and a context string, services a subkey of + * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html} + * for more information. + */ +export function deriveKey(context, material, { length = defaultHashLength } = {}) { + const derive = createDerive(context); + derive.update(normalizeInput(material)); + const result = Buffer.alloc(length); + derive.digest(result); + return result; +} +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export function keyedHash(key, input, { length = defaultHashLength } = {}) { + if (key.length !== 32) { + throw new Error(`key provided to keyedHash must be 32 bytes, got ${key.length}`); + } + const derive = createKeyed(key); + derive.update(normalizeInput(input)); + const result = Buffer.alloc(length); + derive.digest(result); + return result; +} +//# sourceMappingURL=hash-fn.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-fn.js.map b/node_modules/blake3-wasm/esm/node/hash-fn.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f8d886e76230131b46743a082d6f1bad7caa9557 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/node/hash-fn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAoB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EACL,IAAI,IAAI,OAAO,EACf,aAAa,IAAI,YAAY,EAC7B,YAAY,IAAI,WAAW,GAC5B,MAAM,kCAAkC,CAAC;AAO1C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAgB,EAAE,QAAyB,EAAc,EAAE,CACxF,YAAY,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAEjF;;GAEG;AACH,MAAM,UAAU,IAAI,CAClB,KAAgB,EAChB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,OAAe,EACf,QAAmB,EACnB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,GAAW,EACX,KAAgB,EAChB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClF;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-instance.d.ts b/node_modules/blake3-wasm/esm/node/hash-instance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a72c9f90a420210905ec55b14d17af995f9625a --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-instance.d.ts @@ -0,0 +1,75 @@ +/// +import { HashInput } from './hash-fn'; +import { IHasher, IInternalHash, IHasherDigestOptions } from '../base/index'; +import { Transform, TransformCallback } from 'stream'; +import { IBaseHashOptions } from '../base/hash-fn'; +import { NodeHashReader } from './hash-reader'; +export interface INodeHash extends IHasher { + /** + * @inheritdoc + * @override + */ + update(data: HashInput, encoding?: BufferEncoding): this; + /** + * @inheritdoc + * @override + */ + digest(options?: IBaseHashOptions): Buffer; + /** + * Returns a digest of the hash with the given set of hash options. + */ + digest(encoding: undefined, options: IBaseHashOptions): Buffer; + /** + * Returns a digest of the hash with the given encoding. + */ + digest(encoding: BufferEncoding, options?: IBaseHashOptions): string; +} +/** + * @inheritdoc + */ +export declare class NodeHash extends Transform implements IHasher { + private readonly hash; + constructor(implementation: IInternalHash, getReader: (r: Reader) => NodeHashReader); + /** + * @reader + */ + reader(options?: { + dispose?: boolean; + }): NodeHashReader; + /** + * @inheritdoc + */ + update(data: HashInput, encoding?: BufferEncoding): this; + /** + * @inheritdoc + */ + digest(encoding?: IHasherDigestOptions): Buffer; + digest(encoding: undefined, options: IHasherDigestOptions): Buffer; + digest(encoding: BufferEncoding, options?: IHasherDigestOptions): string; + /** + * @inheritdoc + */ + dispose(): void; + /** + * @inheritdoc + * @hidden + */ + _transform(chunk: Buffer | string, encoding: string, callback: TransformCallback): void; + /** + * @inheritdoc + * @hidden + */ + _flush(callback: TransformCallback): void; +} +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => NodeHash; +/** + * Construct a new Hasher for the keyed hash function. + */ +export declare const createKeyed: (key: Buffer) => NodeHash; +/** + * Construct a new Hasher for the key derivation function. + */ +export declare const createDeriveKey: (context: string) => NodeHash; diff --git a/node_modules/blake3-wasm/esm/node/hash-instance.js b/node_modules/blake3-wasm/esm/node/hash-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..4e08d4fc66d9460b0006447eb88f045bdf6e5308 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-instance.js @@ -0,0 +1,76 @@ +import { normalizeInput } from './hash-fn.js'; +import { BaseHash } from '../base/index.js'; +import { Transform } from 'stream.js'; +import { getWasm } from './wasm.js'; +import { NodeHashReader } from './hash-reader.js'; +/** + * @inheritdoc + */ +export class NodeHash extends Transform { + constructor(implementation, getReader) { + super(); + this.hash = new BaseHash(implementation, l => Buffer.alloc(l), getReader); + } + /** + * @reader + */ + reader(options) { + const reader = this.hash.reader(options); + return reader; + } + /** + * @inheritdoc + */ + update(data, encoding) { + this.hash.update(normalizeInput(data, encoding)); + return this; + } + digest(encoding, options) { + let resolvedOpts; + let resolvedEnc; + if (encoding && typeof encoding === 'object') { + resolvedOpts = encoding; + resolvedEnc = undefined; + } + else { + resolvedOpts = options; + resolvedEnc = encoding; + } + const result = this.hash.digest(resolvedOpts); + return resolvedEnc ? result.toString(resolvedEnc) : result; + } + /** + * @inheritdoc + */ + dispose() { + this.hash.dispose(); + } + /** + * @inheritdoc + * @hidden + */ + _transform(chunk, encoding, callback) { + this.update(chunk, encoding); + callback(); + } + /** + * @inheritdoc + * @hidden + */ + _flush(callback) { + callback(null, this.digest()); + } +} +/** + * A Node.js crypto-like createHash method. + */ +export const createHash = () => new NodeHash(getWasm().create_hasher(), r => new NodeHashReader(r)); +/** + * Construct a new Hasher for the keyed hash function. + */ +export const createKeyed = (key) => new NodeHash(getWasm().create_keyed(key), r => new NodeHashReader(r)); +/** + * Construct a new Hasher for the key derivation function. + */ +export const createDeriveKey = (context) => new NodeHash(getWasm().create_derive(context), r => new NodeHashReader(r)); +//# sourceMappingURL=hash-instance.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-instance.js.map b/node_modules/blake3-wasm/esm/node/hash-instance.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a5679a855ade8b5c924d4ab604a09435facb2cf2 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/node/hash-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAa,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAgD,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,SAAS,EAAqB,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA0B/C;;GAEG;AACH,MAAM,OAAO,QAAiB,SAAQ,SAAS;IAG7C,YAAY,cAAqC,EAAE,SAAwC;QACzF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,cAAc,EAA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AAC,MAAM,EAAE,CAAC,CAAC;IAChC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CACzC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CACjD,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-reader.d.ts b/node_modules/blake3-wasm/esm/node/hash-reader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f217f7d2136daf630a669e8ec8d65e6a87c46fff --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-reader.d.ts @@ -0,0 +1,16 @@ +/// +import { BaseHashReader } from '../base/hash-reader'; +/** + * A hash reader for WebAssembly targets. + */ +export declare class NodeHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding?: BufferEncoding): string; + /** + * Converts first 32 bytes of the hash to an array. + */ + toBuffer(): Buffer; + protected alloc(bytes: number): Buffer; +} diff --git a/node_modules/blake3-wasm/esm/node/hash-reader.js b/node_modules/blake3-wasm/esm/node/hash-reader.js new file mode 100644 index 0000000000000000000000000000000000000000..fdb6d9733b309d47a0c8ee51521f662f1800b87e --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-reader.js @@ -0,0 +1,24 @@ +import { BaseHashReader } from '../base/hash-reader.js'; +import { defaultHashLength } from '../base/hash-fn.js'; +/** + * A hash reader for WebAssembly targets. + */ +export class NodeHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toBuffer().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toBuffer() { + this.position = BigInt(0); + return this.read(defaultHashLength); + } + alloc(bytes) { + return Buffer.alloc(bytes); + } +} +//# sourceMappingURL=hash-reader.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-reader.js.map b/node_modules/blake3-wasm/esm/node/hash-reader.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d84088d888579d45d134fd32638e79c7a0fb0351 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/node/hash-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,cAAsB;IACxD;;OAEG;IACI,QAAQ,CAAC,WAA2B,KAAK;QAC9C,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,KAAa;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/index.d.ts b/node_modules/blake3-wasm/esm/node/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7cd09cc3ff28cf3ee158d148d73119f76265e017 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/index.d.ts @@ -0,0 +1,4 @@ +export { hash, deriveKey, keyedHash, HashInput } from './hash-fn'; +export * from './hash-instance'; +export * from './hash-reader'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/esm/node/index.js b/node_modules/blake3-wasm/esm/node/index.js new file mode 100644 index 0000000000000000000000000000000000000000..86df7832de342873a1c988d55dcf76a46214821f --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/index.js @@ -0,0 +1,5 @@ +export { hash, deriveKey, keyedHash } from './hash-fn.js'; +export * from './hash-instance.js'; +export * from './hash-reader.js'; +export * from '../base/index.js'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/index.js.map b/node_modules/blake3-wasm/esm/node/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..22c4bc7ef479a74f911ac351ba599667536f1456 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAa,MAAM,WAAW,CAAC;AAClE,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/wasm.d.ts b/node_modules/blake3-wasm/esm/node/wasm.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..41e73fd9be7866665be2cfdbf46ff834e195d148 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/wasm.d.ts @@ -0,0 +1,6 @@ +import * as wasm from '../../dist/wasm/nodejs/blake3_js'; +/** + * Lazyily get the WebAssembly module. Used to avoid unnecessarily importing + * the wasm when extending the WebAssembly node code for native bindings. + */ +export declare const getWasm: () => typeof wasm; diff --git a/node_modules/blake3-wasm/esm/node/wasm.js b/node_modules/blake3-wasm/esm/node/wasm.js new file mode 100644 index 0000000000000000000000000000000000000000..026a37453888d09b8f1a2fcac85344967882e566 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/wasm.js @@ -0,0 +1,12 @@ +let w; +/** + * Lazyily get the WebAssembly module. Used to avoid unnecessarily importing + * the wasm when extending the WebAssembly node code for native bindings. + */ +export const getWasm = () => { + if (!w) { + w = require('../../dist/wasm/nodejs/blake3_js'); + } + return w; +}; +//# sourceMappingURL=wasm.js.map \ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/wasm.js.map b/node_modules/blake3-wasm/esm/node/wasm.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5249d6cefb3b818cb186c7ac34ced53b2d471cbf --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/wasm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../ts/node/wasm.ts"],"names":[],"mappings":"AAEA,IAAI,CAA0B,CAAC;AAE/B;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,CAAC,GAAG,OAAO,CAAC,kCAAkC,CAAgB,CAAC;KAChE;IAED,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/blake3-wasm/package.json b/node_modules/blake3-wasm/package.json new file mode 100644 index 0000000000000000000000000000000000000000..eeeb80f4240f5925eb83d45543ce341e710169dd --- /dev/null +++ b/node_modules/blake3-wasm/package.json @@ -0,0 +1,63 @@ +{ + "name": "blake3-wasm", + "version": "2.1.5", + "description": "BLAKE3 hashing for JavaScript: native Node bindings (where available) and WebAssembly", + "keywords": [ + "blake3", + "node-addon", + "hash", + "webassembly", + "wasm" + ], + "module": "./esm/index", + "browser": "./esm/browser/index", + "main": "./dist/index", + "scripts": { + "prepack": "make clean && make MODE=release && npm test && rimraf dist/native.node", + "test": "mocha --require source-map-support/register --recursive \"dist/**/*.test.js\" --timeout 5000", + "fmt": "make fmt", + "compile": "tsc && tsc -p tsconfig.esm.json && node dist/build/add-js-extensions", + "watch": "tsc --watch" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/connor4312/blake3.git" + }, + "bugs": { + "url": "https://github.com/connor4312/blake3/issues" + }, + "homepage": "https://github.com/connor4312/blake3#readme", + "author": "Connor Peet ", + "license": "MIT", + "devDependencies": { + "@types/chai": "^4.2.7", + "@types/js-yaml": "^3.12.1", + "@types/mocha": "^5.2.7", + "@types/node": "^13.1.6", + "@types/node-fetch": "^2.5.4", + "@types/puppeteer": "^2.0.0", + "@types/serve-handler": "^6.1.0", + "@types/stream-buffers": "^3.0.3", + "@types/webpack": "^4.41.2", + "chai": "^4.2.0", + "js-yaml": "^3.13.1", + "mocha": "^7.0.0", + "neon-cli": "^0.3.3", + "node-fetch": "^2.6.0", + "prettier": "^1.19.1", + "puppeteer": "^2.0.0", + "remark-cli": "^7.0.1", + "remark-toc": "^6.0.0", + "rimraf": "^3.0.0", + "serve-handler": "^6.1.2", + "source-map-support": "^0.5.16", + "stream-buffers": "^3.0.2", + "typescript": "^3.8.0-beta", + "webpack": "^4.41.5" + }, + "prettier": { + "printWidth": 100, + "singleQuote": true, + "trailingComma": "all" + } +} diff --git a/node_modules/blake3-wasm/readme.md b/node_modules/blake3-wasm/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..5ce9c73e9ee5217b6c635cf6af4cf284bba16a96 --- /dev/null +++ b/node_modules/blake3-wasm/readme.md @@ -0,0 +1,406 @@ +# BLAKE3 + +[BLAKE3](https://github.com/BLAKE3-team/BLAKE3) running in JavaScript (node.js and browsers) via native bindings, where available, or WebAssembly. + + npm install blake3 + +Additionally, there's a flavor of the package which is identical except that it will not download native Node.js bindings: + + npm install blake3-wasm + +## Table of Contents + +- [Quickstart](#quickstart) +- [API](#api) + - [Node.js](#nodejs) + - [`hash(data: BinaryLike, options?: { length: number }): Buffer`](#hashdata-binarylike-options--length-number--buffer) + - [`keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Buffer`](#keyedhashkey-buffer-data-binarylike-options--length-number--buffer) + - [`deriveKey(context: string, material: BinaryLike, options?: { length: number }): Buffer`](#derivekeycontext-string-material-binarylike-options--length-number--buffer) + - [Hasher](#hasher) + - [`createHash(): Hasher`](#createhash-hasher) + - [`createKeyed(key: Buffer): Hasher`](#createkeyedkey-buffer-hasher) + - [`createDeriveKey(context: string): Hasher`](#createderivekeycontext-string-hasher) + - [`hasher.update(data: BinaryLike): this`](#hasherupdatedata-binarylike-this) + - [`hasher.digest(encoding?: string, options?: { length: number, dispose: boolean })): Buffer | string`](#hasherdigestencoding-string-options--length-number-dispose-boolean--buffer--string) + - [`hasher.reader(options?: { dispose: boolean }): HashReader`](#hasherreaderoptions--dispose-boolean--hashreader) + - [`hasher.dispose()`](#hasherdispose) + - [HashReader](#hashreader) + - [`reader.position: bigint`](#readerposition-bigint) + - [`reader.readInto(target: Buffer): void`](#readerreadintotarget-buffer-void) + - [`reader.read(bytes: number): Buffer`](#readerreadbytes-number-buffer) + - [`reader.toString([encoding]): string`](#readertostringencoding-string) + - [`reader.toBuffer(): Buffer`](#readertobuffer-buffer) + - [`reader.dispose()`](#readerdispose) + - [`using(disposable: IDisposable, fn: disposable => T): T`](#usingdisposable-idisposable-fn-disposable--t-t) + - [Browser](#browser) + - [`hash(data: BinaryLike, options?: { length: number }): Hash`](#hashdata-binarylike-options--length-number--hash) + - [`keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Hash`](#keyedhashkey-buffer-data-binarylike-options--length-number--hash) + - [`deriveKey(context: string, material: BinaryLike, options?: { length: number }): Hash`](#derivekeycontext-string-material-binarylike-options--length-number--hash) + - [`Hash`](#hash) + - [`hash.equals(other: Uint8Array)`](#hashequalsother-uint8array) + - [`hash.toString(encoding: 'hex' | 'base64' | 'utf8'): string`](#hashtostringencoding-hex--base64--utf8-string) + - [Hasher](#hasher-1) + - [`createHash(): Hasher`](#createhash-hasher-1) + - [`createKeyed(key: Buffer): Hasher`](#createkeyedkey-buffer-hasher-1) + - [`createDeriveKey(context: string): Hasher`](#createderivekeycontext-string-hasher-1) + - [`hasher.update(data: BinaryLike): this`](#hasherupdatedata-binarylike-this-1) + - [`hasher.digest(encoding?: 'hex' | 'base64' | 'utf8', options?: { length: number, dispose: boolean })): Hash | string`](#hasherdigestencoding-hex--base64--utf8-options--length-number-dispose-boolean--hash--string) + - [`hasher.reader(options?: { dispose: boolean }): HashReader`](#hasherreaderoptions--dispose-boolean--hashreader-1) + - [`hasher.dispose()`](#hasherdispose-1) + - [HashReader](#hashreader-1) + - [`reader.position: bigint`](#readerposition-bigint-1) + - [`reader.readInto(target: Uint8Array): void`](#readerreadintotarget-uint8array-void) + - [`reader.read(bytes: number): Hash`](#readerreadbytes-number-hash) + - [`reader.toString(encoding?: string): string`](#readertostringencoding-string-string) + - [`reader.toArray(): Uint8Array`](#readertoarray-uint8array) + - [`reader.dispose()`](#readerdispose-1) + - [`using(disposable: IDisposable, fn: disposable => T): T`](#usingdisposable-idisposable-fn-disposable--t-t-1) +- [Speed](#speed) +- [Contributing](#contributing) + - [Publishing](#publishing) + +## Quickstart + +If you're on Node, import the module via + +```js +const blake3 = require('blake3'); + +blake3.hash('foo'); // => Buffer +``` + +If you're in the browser, import `blake3/browser`. This includes a WebAssembly binary, so you probably want to import it asynchronously, like so: + +```js +import('blake3/browser').then(blake3 => { + blake3.hash('foo'); // => Uint8Array +}); +``` + +The API is very similar in Node.js and browsers, but Node supports and returns Buffers and a wider range of input and output encoding. + +More complete example: + +```js +const { hash, createHash } = require('blake3'); + +hash('some string'); // => hash a string to a uint8array + +// Update incrementally (Node and Browsers): +const hash = createHash(); +stream.on('data', d => hash.update(d)); +stream.on('error', err => { + // hashes use unmanaged memory in WebAssembly, always free them if you don't digest()! + hash.dispose(); + throw err; +}); +stream.on('end', () => finishedHash(hash.digest())); + +// Or, in Node, it's also a transform stream: +createReadStream('file.txt') + .pipe(createHash()) + .on('data', hash => console.log(hash.toString('hex'))); +``` + +## API + +### Node.js + +The Node API can be imported via `require('blake3')`. + +#### `hash(data: BinaryLike, options?: { length: number }): Buffer` + +Returns a hash for the given data. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer. + +#### `keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Buffer` + +Returns keyed a hash for the given data. The key must be exactly 32 bytes. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer. + +For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html). + +#### `deriveKey(context: string, material: BinaryLike, options?: { length: number }): Buffer` + +The key derivation function. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer. + +For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html). + +#### Hasher + +The hasher is a type that lets you incrementally build a hash. It's compatible with Node's crypto hash instance. For instance, it implements a transform stream, so you could do something like: + +```js +createReadStream('file.txt') + .pipe(createHash()) + .on('data', hash => console.log(hash.toString('hex'))); +``` + +##### `createHash(): Hasher` + +Creates a new hasher instance using the standard hash function. + +##### `createKeyed(key: Buffer): Hasher` + +Creates a new hasher instance for a keyed hash. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html). + +##### `createDeriveKey(context: string): Hasher` + +Creates a new hasher instance for the key derivation function. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html). + +##### `hasher.update(data: BinaryLike): this` + +Adds data to a hash. The data can be a string, buffer, typedarray, array buffer, or array. This will throw if called after `digest()` or `dispose()`. + +##### `hasher.digest(encoding?: string, options?: { length: number, dispose: boolean })): Buffer | string` + +Returns the hash of the data. If an `encoding` is given, a string will be returned. Otherwise, a Buffer is returned. Optionally, you can specify the requested byte length of the hash. + +If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader. + +##### `hasher.reader(options?: { dispose: boolean }): HashReader` + +Returns a [HashReader](#HashReader) for the current hash. + +If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader. + +##### `hasher.dispose()` + +Disposes of unmanaged resources. You should _always_ call this if you don't call `digest()` to free umanaged (WebAssembly-based) memory. + +#### HashReader + +The hash reader can be returned from hashing functions. Up to 264-1 bytes of data can be read from BLAKE3 hashes; this structure lets you read those. Note that, like `hash`, this is an object which needs to be manually disposed of. + +##### `reader.position: bigint` + +A property which gets or sets the position of the reader in the output stream. A `RangeError` is thrown if setting this to a value less than 0 or greater than 264-1. Note that this is a bigint, not a standard number. + +```js +reader.position += 32n; // advance the reader 32 bytes +``` + +##### `reader.readInto(target: Buffer): void` + +Reads bytes into the target array, filling it up and advancing the reader's position. A `RangeError` is thrown if reading this data puts the reader past 264-1 bytes. + +##### `reader.read(bytes: number): Buffer` + +Reads and returns the given number of bytes from the reader, and advances the position. A `RangeError` is thrown if reading this data puts the reader past 264-1 bytes. + +##### `reader.toString([encoding]): string` + +Converts first 32 bytes of the hash to a string with the given encoding. Defaults to hex encoding. + +##### `reader.toBuffer(): Buffer` + +Converts first 32 bytes of the hash to a Buffer. + +##### `reader.dispose()` + +Disposes of unmanaged resources. You should _always_ call this to free umanaged (WebAssembly-based) memory, or you application will leak memory. + +#### `using(disposable: IDisposable, fn: disposable => T): T` + +A helper method that takes a disposable, and automatically calls the dispose method when the function returns, or the promise returned from the function is settled. + +```js +// read and auto-dispose the first 64 bytes +const first64Bytes = using(hash.reader(), reader => reader.toBuffer(64)); + +// you can also return promises/use async methods: +using(hash.reader(), async reader => { + do { + await send(reader.read(64)); + } while (needsMoreData()); +}); +``` + +### Browser + +The browser API can be imported via `import('blake3/browser')`, which works well with Webpack. + +If you aren't using a bundler or using a more "pure" bundler like Parcel, you can import `blake3/browser-async` which exports a function to asynchronously load the WebAssembly code and resolves to the package contents. + +```js +import load from 'blake3/browser-async'; + +load().then(blake3 => { + console.log(blake3.hash('hello world')); +}); +``` + +#### `hash(data: BinaryLike, options?: { length: number }): Hash` + +Returns a hash for the given data. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance. + +#### `keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Hash` + +Returns keyed a hash for the given data. The key must be exactly 32 bytes. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance. + +For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html). + +#### `deriveKey(context: string, material: BinaryLike, options?: { length: number }): Hash` + +The key derivation function. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance. + +For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html). + +#### `Hash` + +A Hash is the type returned from hash functions and the hasher in the browser. It's a `Uint8Array` with a few additional helper methods. + +##### `hash.equals(other: Uint8Array)` + +Returns whether this hash equals the other hash, via a constant-time equality check. + +##### `hash.toString(encoding: 'hex' | 'base64' | 'utf8'): string` + +#### Hasher + +The hasher is a type that lets you incrementally build a hash. For instance, you can hash a `fetch`ed page like: + +```js +const res = await fetch('https://example.com'); +const body = await res.body; + +const hasher = blake3.createHash(); +const reader = body.getReader(); + +while (true) { + const { done, value } = await reader.read(); + if (done) { + break; + } + + hasher.update(value); +} + +console.log('Hash of', res.url, 'is', hasher.digest('hex')); +``` + +Converts the hash to a string with the given encoding. + +##### `createHash(): Hasher` + +Creates a new hasher instance using the standard hash function. + +##### `createKeyed(key: Buffer): Hasher` + +Creates a new hasher instance for a keyed hash. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html). + +##### `createDeriveKey(context: string): Hasher` + +Creates a new hasher instance for the key derivation function. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html). + +##### `hasher.update(data: BinaryLike): this` + +Adds data to a hash. The data can be a string, buffer, typedarray, array buffer, or array. This will throw if called after `digest()` or `dispose()`. + +##### `hasher.digest(encoding?: 'hex' | 'base64' | 'utf8', options?: { length: number, dispose: boolean })): Hash | string` + +Returns the hash of the data. If an `encoding` is given, a string will be returned. Otherwise, a [Hash](#hash) is returned. Optionally, you can specify the requested byte length of the hash. + +If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader. + +##### `hasher.reader(options?: { dispose: boolean }): HashReader` + +Returns a [HashReader](#HashReader) for the current hash. + +If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader. + +##### `hasher.dispose()` + +Disposes of unmanaged resources. You should _always_ call this if you don't call `digest()` to free umanaged (WebAssembly-based) memory. + +#### HashReader + +The hash reader can be returned from hashing functions. Up to 264-1 bytes of data can be read from BLAKE3 hashes; this structure lets you read those. Note that, like `hash`, this is an object which needs to be manually disposed of. + +##### `reader.position: bigint` + +A property which gets or sets the position of the reader in the output stream. A `RangeError` is thrown if setting this to a value less than 0 or greater than 264-1. Note that this is a bigint, not a standard number. + +```js +reader.position += 32n; // advance the reader 32 bytes +``` + +##### `reader.readInto(target: Uint8Array): void` + +Reads bytes into the target array, filling it up and advancing the reader's position. A `RangeError` is thrown if reading this data puts the reader past 264-1 bytes. + +##### `reader.read(bytes: number): Hash` + +Reads and returns the given number of bytes from the reader, and advances the position. A `RangeError` is thrown if reading this data puts the reader past 264-1 bytes. + +##### `reader.toString(encoding?: string): string` + +Converts first 32 bytes of the hash to a string with the given encoding. Defaults to hex encoding. + +##### `reader.toArray(): Uint8Array` + +Converts first 32 bytes of the hash to an array. + +##### `reader.dispose()` + +Disposes of unmanaged resources. You should _always_ call this to free umanaged (WebAssembly-based) memory, or you application will leak memory. + +#### `using(disposable: IDisposable, fn: disposable => T): T` + +A helper method that takes a disposable, and automatically calls the dispose method when the function returns, or the promise returned from the function is settled. + +```js +// read and auto-dispose the first 64 bytes +const first64Bytes = using(hash.reader(), reader => reader.toArray(64)); + +// you can also return promises/use async methods: +using(hash.reader(), async reader => { + do { + await send(reader.read(64)); + } while (needsMoreData()); +}); +``` + +## Speed + +> Native Node.js bindings are a work in progress. + +You can run benchmarks by installing `npm install -g @c4312/matcha`, then running `matcha benchmark.js`. These are the results running on Node 12 on my MacBook. Blake3 is significantly faster than Node's built-in hashing. + + 276,000 ops/sec > 64B#md5 (4,240x) + 263,000 ops/sec > 64B#sha1 (4,040x) + 271,000 ops/sec > 64B#sha256 (4,160x) + 1,040,000 ops/sec > 64B#blake3 wasm (15,900x) + 625,000 ops/sec > 64B#blake3 native (9,590x) + + 9,900 ops/sec > 64KB#md5 (152x) + 13,900 ops/sec > 64KB#sha1 (214x) + 6,470 ops/sec > 64KB#sha256 (99.2x) + 6,410 ops/sec > 64KB#blake3 wasm (98.4x) + 48,900 ops/sec > 64KB#blake3 native (750x) + + 106 ops/sec > 6MB#md5 (1.63x) + 150 ops/sec > 6MB#sha1 (2.3x) + 69.2 ops/sec > 6MB#sha256 (1.06x) + 65.2 ops/sec > 6MB#blake3 wasm (1x) + 502 ops/sec > 6MB#blake3 native (7.7x) + +## Contributing + +This build is a little esoteric due to the mixing of languages. We use a `Makefile` to coodinate things. + +To get set up, you'll want to open the repository in VS Code. Make sure you have [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed, and then accept the "Reopen in Container" prompt when opening the folder. This will get the environment set up with everything you need. Then, run `make prepare` to install local dependencies. + +Finally, `make` will create a build for you; you can run `make MODE=release` for a production release, and certainly should if you want to [benchmark it](#speed). + +- Rust code is compiled from `src/lib.rs` to `pkg/browser` and `pkg/node` +- TypeScript code is compiled from `ts/*.ts` into `dist` + +### Publishing + +In case I get hit by a bus or get other contributors, these are the steps for publishing: + +1. Get all your code ready to go in master, pushed up to Github. +2. Run `make prepare-binaries`. This will update the branch `generate-binary`, which kicks off a build via Github actions to create `.node` binaries for every relevant Node.js version. +3. When the build completes, it'll generate a zip file of artifacts. Download those. +4. Back on master, run `npm version ` to update the version in git. `git push --tags`. +5. On Github, upload the contents of the artifacts folder to the release for the newly tagged version. +6. Run `npm publish`. diff --git a/node_modules/blake3-wasm/targets.json b/node_modules/blake3-wasm/targets.json new file mode 100644 index 0000000000000000000000000000000000000000..0e439169e086e44d7d9875945fd90487ff79cceb --- /dev/null +++ b/node_modules/blake3-wasm/targets.json @@ -0,0 +1 @@ +{"v15.3.0":88,"v15.2.1":88,"v15.2.0":88,"v15.1.0":88,"v15.0.1":88,"v15.0.0":88,"v14.15.1":83,"v14.15.0":83,"v14.14.0":83,"v14.13.1":83,"v14.13.0":83,"v14.12.0":83,"v14.11.0":83,"v14.10.1":83,"v14.10.0":83,"v14.9.0":83,"v14.8.0":83,"v14.7.0":83,"v14.6.0":83,"v14.5.0":83,"v14.4.0":83,"v14.3.0":83,"v14.2.0":83,"v14.1.0":83,"v14.0.0":83,"v13.14.0":79,"v13.13.0":79,"v13.12.0":79,"v13.11.0":79,"v13.10.1":79,"v13.10.0":79,"v13.9.0":79,"v13.8.0":79,"v13.7.0":79,"v13.6.0":79,"v13.5.0":79,"v13.4.0":79,"v13.3.0":79,"v13.2.0":79,"v13.1.0":79,"v13.0.1":79,"v13.0.0":79,"v12.20.0":72,"v12.19.1":72,"v12.19.0":72,"v12.18.4":72,"v12.18.3":72,"v12.18.2":72,"v12.18.1":72,"v12.18.0":72,"v12.17.0":72,"v12.16.3":72,"v12.16.2":72,"v12.16.1":72,"v12.16.0":72,"v12.15.0":72,"v12.14.1":72,"v12.14.0":72,"v12.13.1":72,"v12.13.0":72,"v12.12.0":72,"v12.11.1":72,"v12.11.0":72,"v12.10.0":72,"v12.9.1":72,"v12.9.0":72,"v12.8.1":72,"v12.8.0":72,"v12.7.0":72,"v12.6.0":72,"v12.5.0":72,"v12.4.0":72,"v12.3.1":72,"v12.3.0":72,"v12.2.0":72,"v12.1.0":72,"v12.0.0":72,"v11.15.0":67,"v11.14.0":67,"v11.13.0":67,"v11.12.0":67,"v11.11.0":67,"v11.10.1":67,"v11.10.0":67,"v11.9.0":67,"v11.8.0":67,"v11.7.0":67,"v11.6.0":67,"v11.5.0":67,"v11.4.0":67,"v11.3.0":67,"v11.2.0":67,"v11.1.0":67,"v11.0.0":67,"v10.23.0":64,"v10.22.1":64,"v10.22.0":64,"v10.21.0":64,"v10.20.1":64,"v10.20.0":64,"v10.19.0":64,"v10.18.1":64,"v10.18.0":64,"v10.17.0":64,"v10.16.3":64,"v10.16.2":64,"v10.16.1":64,"v10.16.0":64,"v10.15.3":64,"v10.15.2":64,"v10.15.1":64,"v10.15.0":64,"v10.14.2":64,"v10.14.1":64,"v10.14.0":64,"v10.13.0":64,"v10.12.0":64,"v10.11.0":64,"v10.10.0":64,"v10.9.0":64,"v10.8.0":64,"v10.7.0":64,"v10.6.0":64,"v10.5.0":64,"v10.4.1":64,"v10.4.0":64,"v10.3.0":64,"v10.2.1":64,"v10.2.0":64,"v10.1.0":64,"v10.0.0":64} \ No newline at end of file diff --git a/node_modules/call-bind/.eslintignore b/node_modules/call-bind/.eslintignore new file mode 100644 index 0000000000000000000000000000000000000000..404abb22121cdcbb710c56f4ba2684789cb2868c --- /dev/null +++ b/node_modules/call-bind/.eslintignore @@ -0,0 +1 @@ +coverage/ diff --git a/node_modules/call-bind/.eslintrc b/node_modules/call-bind/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..dfa9a6cdcf03e3f611cb91a59c68327d040a5d58 --- /dev/null +++ b/node_modules/call-bind/.eslintrc @@ -0,0 +1,16 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "func-name-matching": 0, + "id-length": 0, + "new-cap": [2, { + "capIsNewExceptions": [ + "GetIntrinsic", + ], + }], + "no-magic-numbers": 0, + }, +} diff --git a/node_modules/call-bind/.github/FUNDING.yml b/node_modules/call-bind/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..c70c2ecdb216df098ffbaba7773e6d8cf52e9bf3 --- /dev/null +++ b/node_modules/call-bind/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/call-bind +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/call-bind/.nycrc b/node_modules/call-bind/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/call-bind/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/call-bind/CHANGELOG.md b/node_modules/call-bind/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..717bcc3e9b0ac10c3b66c26871f6547190010c41 --- /dev/null +++ b/node_modules/call-bind/CHANGELOG.md @@ -0,0 +1,77 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.5](https://github.com/ljharb/call-bind/compare/v1.0.4...v1.0.5) - 2023-10-19 + +### Commits + +- [Fix] throw an error on non-functions as early as possible [`f262408`](https://github.com/ljharb/call-bind/commit/f262408f822c840fbc268080f3ad7c429611066d) +- [Deps] update `set-function-length` [`3fff271`](https://github.com/ljharb/call-bind/commit/3fff27145a1e3a76a5b74f1d7c3c43d0fa3b9871) + +## [v1.0.4](https://github.com/ljharb/call-bind/compare/v1.0.3...v1.0.4) - 2023-10-19 + +## [v1.0.3](https://github.com/ljharb/call-bind/compare/v1.0.2...v1.0.3) - 2023-10-19 + +### Commits + +- [actions] reuse common workflows [`a994df6`](https://github.com/ljharb/call-bind/commit/a994df69f401f4bf735a4ccd77029b85d1549453) +- [meta] use `npmignore` to autogenerate an npmignore file [`eef3ef2`](https://github.com/ljharb/call-bind/commit/eef3ef21e1f002790837fedb8af2679c761fbdf5) +- [readme] flesh out content [`1845ccf`](https://github.com/ljharb/call-bind/commit/1845ccfd9976a607884cfc7157c93192cc16cf22) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`5b47d53`](https://github.com/ljharb/call-bind/commit/5b47d53d2fd74af5ea0a44f1d51e503cd42f7a90) +- [Refactor] use `set-function-length` [`a0e165c`](https://github.com/ljharb/call-bind/commit/a0e165c5dc61db781cbc919b586b1c2b8da0b150) +- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`9c50103`](https://github.com/ljharb/call-bind/commit/9c50103f44137279a817317cf6cc421a658f85b4) +- [meta] simplify "exports" [`019c6d0`](https://github.com/ljharb/call-bind/commit/019c6d06b0e1246ceed8e579f57e44441cbbf6d9) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `safe-publish-latest`, `tape` [`23bd718`](https://github.com/ljharb/call-bind/commit/23bd718a288d3b03042062b4ef5153b3cea83f11) +- [actions] update codecov uploader [`62552d7`](https://github.com/ljharb/call-bind/commit/62552d79cc79e05825e99aaba134ae5b37f33da5) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`ec81665`](https://github.com/ljharb/call-bind/commit/ec81665b300f87eabff597afdc8b8092adfa7afd) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `tape` [`35d67fc`](https://github.com/ljharb/call-bind/commit/35d67fcea883e686650f736f61da5ddca2592de8) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`0266d8d`](https://github.com/ljharb/call-bind/commit/0266d8d2a45086a922db366d0c2932fa463662ff) +- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`43a5b28`](https://github.com/ljharb/call-bind/commit/43a5b28a444e710e1bbf92adb8afb5cf7523a223) +- [Deps] update `define-data-property`, `function-bind`, `get-intrinsic` [`780eb36`](https://github.com/ljharb/call-bind/commit/780eb36552514f8cc99c70821ce698697c2726a5) +- [Dev Deps] update `aud`, `tape` [`90d50ad`](https://github.com/ljharb/call-bind/commit/90d50ad03b061e0268b3380b0065fcaec183dc05) +- [meta] use `prepublishOnly` script for npm 7+ [`44c5433`](https://github.com/ljharb/call-bind/commit/44c5433b7980e02b4870007046407cf6fc543329) +- [Deps] update `get-intrinsic` [`86bfbfc`](https://github.com/ljharb/call-bind/commit/86bfbfcf34afdc6eabc93ce3d408548d0e27d958) +- [Deps] update `get-intrinsic` [`5c53354`](https://github.com/ljharb/call-bind/commit/5c5335489be0294c18cd7a8bb6e08226ee019ff5) +- [actions] update checkout action [`4c393a8`](https://github.com/ljharb/call-bind/commit/4c393a8173b3c8e5b30d5b3297b3b94d48bf87f3) +- [Deps] update `get-intrinsic` [`4e70bde`](https://github.com/ljharb/call-bind/commit/4e70bdec0626acb11616d66250fc14565e716e91) +- [Deps] update `get-intrinsic` [`55ae803`](https://github.com/ljharb/call-bind/commit/55ae803a920bd93c369cd798c20de31f91e9fc60) + +## [v1.0.2](https://github.com/ljharb/call-bind/compare/v1.0.1...v1.0.2) - 2021-01-11 + +### Commits + +- [Fix] properly include the receiver in the bound length [`dbae7bc`](https://github.com/ljharb/call-bind/commit/dbae7bc676c079a0d33c0a43e9ef92cb7b01345d) + +## [v1.0.1](https://github.com/ljharb/call-bind/compare/v1.0.0...v1.0.1) - 2021-01-08 + +### Commits + +- [Tests] migrate tests to Github Actions [`b6db284`](https://github.com/ljharb/call-bind/commit/b6db284c36f8ccd195b88a6764fe84b7223a0da1) +- [meta] do not publish github action workflow files [`ec7fe46`](https://github.com/ljharb/call-bind/commit/ec7fe46e60cfa4764ee943d2755f5e5a366e578e) +- [Fix] preserve original function’s length when possible [`adbceaa`](https://github.com/ljharb/call-bind/commit/adbceaa3cac4b41ea78bb19d7ccdbaaf7e0bdadb) +- [Tests] gather coverage data on every job [`d69e23c`](https://github.com/ljharb/call-bind/commit/d69e23cc65f101ba1d4c19bb07fa8eb0ec624be8) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`2fd3586`](https://github.com/ljharb/call-bind/commit/2fd3586c5d47b335364c14293114c6b625ae1f71) +- [Deps] update `get-intrinsic` [`f23e931`](https://github.com/ljharb/call-bind/commit/f23e9318cc271c2add8bb38cfded85ee7baf8eee) +- [Deps] update `get-intrinsic` [`72d9f44`](https://github.com/ljharb/call-bind/commit/72d9f44e184465ba8dd3fb48260bbcff234985f2) +- [meta] fix FUNDING.yml [`e723573`](https://github.com/ljharb/call-bind/commit/e723573438c5a68dcec31fb5d96ea6b7e4a93be8) +- [eslint] ignore coverage output [`15e76d2`](https://github.com/ljharb/call-bind/commit/15e76d28a5f43e504696401e5b31ebb78ee1b532) +- [meta] add Automatic Rebase and Require Allow Edits workflows [`8fa4dab`](https://github.com/ljharb/call-bind/commit/8fa4dabb23ba3dd7bb92c9571c1241c08b56e4b6) + +## v1.0.0 - 2020-10-30 + +### Commits + +- Initial commit [`306cf98`](https://github.com/ljharb/call-bind/commit/306cf98c7ec9e7ef66b653ec152277ac1381eb50) +- Tests [`e10d0bb`](https://github.com/ljharb/call-bind/commit/e10d0bbdadc7a10ecedc9a1c035112d3e368b8df) +- Implementation [`43852ed`](https://github.com/ljharb/call-bind/commit/43852eda0f187327b7fad2423ca972149a52bd65) +- npm init [`408f860`](https://github.com/ljharb/call-bind/commit/408f860b773a2f610805fd3613d0d71bac1b6249) +- [meta] add Automatic Rebase and Require Allow Edits workflows [`fb349b2`](https://github.com/ljharb/call-bind/commit/fb349b2e48defbec8b5ec8a8395cc8f69f220b13) +- [meta] add `auto-changelog` [`c4001fc`](https://github.com/ljharb/call-bind/commit/c4001fc43031799ef908211c98d3b0fb2b60fde4) +- [meta] add "funding"; create `FUNDING.yml` [`d4d6d29`](https://github.com/ljharb/call-bind/commit/d4d6d2974a14bc2e98830468eda7fe6d6a776717) +- [Tests] add `npm run lint` [`dedfb98`](https://github.com/ljharb/call-bind/commit/dedfb98bd0ecefb08ddb9a94061bd10cde4332af) +- Only apps should have lockfiles [`54ac776`](https://github.com/ljharb/call-bind/commit/54ac77653db45a7361dc153d2f478e743f110650) +- [meta] add `safe-publish-latest` [`9ea8e43`](https://github.com/ljharb/call-bind/commit/9ea8e435b950ce9b705559cd651039f9bf40140f) diff --git a/node_modules/call-bind/LICENSE b/node_modules/call-bind/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..48f05d01d0acae75acada5bd42a3442d0699d067 --- /dev/null +++ b/node_modules/call-bind/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Jordan Harband + +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. diff --git a/node_modules/call-bind/README.md b/node_modules/call-bind/README.md new file mode 100644 index 0000000000000000000000000000000000000000..48e9047f0c02b482bdd43a9a1c08192f9d6a8208 --- /dev/null +++ b/node_modules/call-bind/README.md @@ -0,0 +1,64 @@ +# call-bind [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Robustly `.call.bind()` a function. + +## Getting started + +```sh +npm install --save call-bind +``` + +## Usage/Examples + +```js +const assert = require('assert'); +const callBind = require('call-bind'); +const callBound = require('call-bind/callBound'); + +function f(a, b) { + assert.equal(this, 1); + assert.equal(a, 2); + assert.equal(b, 3); + assert.equal(arguments.length, 2); +} + +const fBound = callBind(f); + +const slice = callBound('Array.prototype.slice'); + +delete Function.prototype.call; +delete Function.prototype.bind; + +fBound(1, 2, 3); + +assert.deepEqual(slice([1, 2, 3, 4], 1, -1), [2, 3]); +``` + +## Tests + +Clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/call-bind +[npm-version-svg]: https://versionbadg.es/ljharb/call-bind.svg +[deps-svg]: https://david-dm.org/ljharb/call-bind.svg +[deps-url]: https://david-dm.org/ljharb/call-bind +[dev-deps-svg]: https://david-dm.org/ljharb/call-bind/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/call-bind#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/call-bind.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/call-bind.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/call-bind.svg +[downloads-url]: https://npm-stat.com/charts.html?package=call-bind +[codecov-image]: https://codecov.io/gh/ljharb/call-bind/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/ljharb/call-bind/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/call-bind +[actions-url]: https://github.com/ljharb/call-bind/actions diff --git a/node_modules/call-bind/callBound.js b/node_modules/call-bind/callBound.js new file mode 100644 index 0000000000000000000000000000000000000000..8374adfd0549fef7cc678ab66089596afb7f8172 --- /dev/null +++ b/node_modules/call-bind/callBound.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var callBind = require('./'); + +var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf')); + +module.exports = function callBoundIntrinsic(name, allowMissing) { + var intrinsic = GetIntrinsic(name, !!allowMissing); + if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { + return callBind(intrinsic); + } + return intrinsic; +}; diff --git a/node_modules/call-bind/index.js b/node_modules/call-bind/index.js new file mode 100644 index 0000000000000000000000000000000000000000..184ee2be39fe96c285414b2af0fc9cc6c253f219 --- /dev/null +++ b/node_modules/call-bind/index.js @@ -0,0 +1,44 @@ +'use strict'; + +var bind = require('function-bind'); +var GetIntrinsic = require('get-intrinsic'); +var setFunctionLength = require('set-function-length'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $apply = GetIntrinsic('%Function.prototype.apply%'); +var $call = GetIntrinsic('%Function.prototype.call%'); +var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); + +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); +var $max = GetIntrinsic('%Math.max%'); + +if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + } catch (e) { + // IE 8 has a broken defineProperty + $defineProperty = null; + } +} + +module.exports = function callBind(originalFunction) { + if (typeof originalFunction !== 'function') { + throw new $TypeError('a function is required'); + } + var func = $reflectApply(bind, $call, arguments); + return setFunctionLength( + func, + 1 + $max(0, originalFunction.length - (arguments.length - 1)), + true + ); +}; + +var applyBind = function applyBind() { + return $reflectApply(bind, $apply, arguments); +}; + +if ($defineProperty) { + $defineProperty(module.exports, 'apply', { value: applyBind }); +} else { + module.exports.apply = applyBind; +} diff --git a/node_modules/call-bind/package.json b/node_modules/call-bind/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f946e1a919cb0e3c64424f8605150585396d4f27 --- /dev/null +++ b/node_modules/call-bind/package.json @@ -0,0 +1,90 @@ +{ + "name": "call-bind", + "version": "1.0.5", + "description": "Robustly `.call.bind()` a function", + "main": "index.js", + "exports": { + ".": "./index.js", + "./callBound": "./callBound.js", + "./package.json": "./package.json" + }, + "scripts": { + "prepack": "npmignore --auto --commentLines=auto", + "prepublish": "not-in-publish || npm run prepublishOnly", + "prepublishOnly": "safe-publish-latest", + "lint": "eslint --ext=.js,.mjs .", + "postlint": "evalmd README.md", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ljharb/call-bind.git" + }, + "keywords": [ + "javascript", + "ecmascript", + "es", + "js", + "callbind", + "callbound", + "call", + "bind", + "bound", + "call-bind", + "call-bound", + "function", + "es-abstract" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/ljharb/call-bind/issues" + }, + "homepage": "https://github.com/ljharb/call-bind#readme", + "devDependencies": { + "@ljharb/eslint-config": "^21.1.0", + "aud": "^2.0.3", + "auto-changelog": "^2.4.0", + "es-value-fixtures": "^1.4.2", + "eslint": "=8.8.0", + "evalmd": "^0.0.19", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-strict-mode": "^1.0.1", + "in-publish": "^2.0.1", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "object-inspect": "^1.13.1", + "safe-publish-latest": "^2.0.0", + "tape": "^5.7.1" + }, + "dependencies": { + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" + }, + "testling": { + "files": "test/index.js" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] + } +} diff --git a/node_modules/call-bind/test/callBound.js b/node_modules/call-bind/test/callBound.js new file mode 100644 index 0000000000000000000000000000000000000000..c32319d70d3e3f75b6c9b046666af68ed52e8ce6 --- /dev/null +++ b/node_modules/call-bind/test/callBound.js @@ -0,0 +1,54 @@ +'use strict'; + +var test = require('tape'); + +var callBound = require('../callBound'); + +test('callBound', function (t) { + // static primitive + t.equal(callBound('Array.length'), Array.length, 'Array.length yields itself'); + t.equal(callBound('%Array.length%'), Array.length, '%Array.length% yields itself'); + + // static non-function object + t.equal(callBound('Array.prototype'), Array.prototype, 'Array.prototype yields itself'); + t.equal(callBound('%Array.prototype%'), Array.prototype, '%Array.prototype% yields itself'); + t.equal(callBound('Array.constructor'), Array.constructor, 'Array.constructor yields itself'); + t.equal(callBound('%Array.constructor%'), Array.constructor, '%Array.constructor% yields itself'); + + // static function + t.equal(callBound('Date.parse'), Date.parse, 'Date.parse yields itself'); + t.equal(callBound('%Date.parse%'), Date.parse, '%Date.parse% yields itself'); + + // prototype primitive + t.equal(callBound('Error.prototype.message'), Error.prototype.message, 'Error.prototype.message yields itself'); + t.equal(callBound('%Error.prototype.message%'), Error.prototype.message, '%Error.prototype.message% yields itself'); + + // prototype function + t.notEqual(callBound('Object.prototype.toString'), Object.prototype.toString, 'Object.prototype.toString does not yield itself'); + t.notEqual(callBound('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% does not yield itself'); + t.equal(callBound('Object.prototype.toString')(true), Object.prototype.toString.call(true), 'call-bound Object.prototype.toString calls into the original'); + t.equal(callBound('%Object.prototype.toString%')(true), Object.prototype.toString.call(true), 'call-bound %Object.prototype.toString% calls into the original'); + + t['throws']( + function () { callBound('does not exist'); }, + SyntaxError, + 'nonexistent intrinsic throws' + ); + t['throws']( + function () { callBound('does not exist', true); }, + SyntaxError, + 'allowMissing arg still throws for unknown intrinsic' + ); + + t.test('real but absent intrinsic', { skip: typeof WeakRef !== 'undefined' }, function (st) { + st['throws']( + function () { callBound('WeakRef'); }, + TypeError, + 'real but absent intrinsic throws' + ); + st.equal(callBound('WeakRef', true), undefined, 'allowMissing arg avoids exception'); + st.end(); + }); + + t.end(); +}); diff --git a/node_modules/call-bind/test/index.js b/node_modules/call-bind/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1fd46689ef778887c4e91ca705529c79b2ebb05e --- /dev/null +++ b/node_modules/call-bind/test/index.js @@ -0,0 +1,80 @@ +'use strict'; + +var callBind = require('../'); +var bind = require('function-bind'); +var gOPD = require('gopd'); +var hasStrictMode = require('has-strict-mode')(); +var forEach = require('for-each'); +var inspect = require('object-inspect'); +var v = require('es-value-fixtures'); + +var test = require('tape'); + +/* + * older engines have length nonconfigurable + * in io.js v3, it is configurable except on bound functions, hence the .bind() + */ +var functionsHaveConfigurableLengths = !!( + gOPD + && Object.getOwnPropertyDescriptor + && Object.getOwnPropertyDescriptor(bind.call(function () {}), 'length').configurable +); + +test('callBind', function (t) { + forEach(v.nonFunctions, function (nonFunction) { + t['throws']( + function () { callBind(nonFunction); }, + TypeError, + inspect(nonFunction) + ' is not a function' + ); + }); + + var sentinel = { sentinel: true }; + var func = function (a, b) { + // eslint-disable-next-line no-invalid-this + return [!hasStrictMode && this === global ? undefined : this, a, b]; + }; + t.equal(func.length, 2, 'original function length is 2'); + t.deepEqual(func(), [undefined, undefined, undefined], 'unbound func with too few args'); + t.deepEqual(func(1, 2), [undefined, 1, 2], 'unbound func with right args'); + t.deepEqual(func(1, 2, 3), [undefined, 1, 2], 'unbound func with too many args'); + + var bound = callBind(func); + t.equal(bound.length, func.length + 1, 'function length is preserved', { skip: !functionsHaveConfigurableLengths }); + t.deepEqual(bound(), [undefined, undefined, undefined], 'bound func with too few args'); + t.deepEqual(bound(1, 2), [hasStrictMode ? 1 : Object(1), 2, undefined], 'bound func with right args'); + t.deepEqual(bound(1, 2, 3), [hasStrictMode ? 1 : Object(1), 2, 3], 'bound func with too many args'); + + var boundR = callBind(func, sentinel); + t.equal(boundR.length, func.length, 'function length is preserved', { skip: !functionsHaveConfigurableLengths }); + t.deepEqual(boundR(), [sentinel, undefined, undefined], 'bound func with receiver, with too few args'); + t.deepEqual(boundR(1, 2), [sentinel, 1, 2], 'bound func with receiver, with right args'); + t.deepEqual(boundR(1, 2, 3), [sentinel, 1, 2], 'bound func with receiver, with too many args'); + + var boundArg = callBind(func, sentinel, 1); + t.equal(boundArg.length, func.length - 1, 'function length is preserved', { skip: !functionsHaveConfigurableLengths }); + t.deepEqual(boundArg(), [sentinel, 1, undefined], 'bound func with receiver and arg, with too few args'); + t.deepEqual(boundArg(2), [sentinel, 1, 2], 'bound func with receiver and arg, with right arg'); + t.deepEqual(boundArg(2, 3), [sentinel, 1, 2], 'bound func with receiver and arg, with too many args'); + + t.test('callBind.apply', function (st) { + var aBound = callBind.apply(func); + st.deepEqual(aBound(sentinel), [sentinel, undefined, undefined], 'apply-bound func with no args'); + st.deepEqual(aBound(sentinel, [1], 4), [sentinel, 1, undefined], 'apply-bound func with too few args'); + st.deepEqual(aBound(sentinel, [1, 2], 4), [sentinel, 1, 2], 'apply-bound func with right args'); + + var aBoundArg = callBind.apply(func); + st.deepEqual(aBoundArg(sentinel, [1, 2, 3], 4), [sentinel, 1, 2], 'apply-bound func with too many args'); + st.deepEqual(aBoundArg(sentinel, [1, 2], 4), [sentinel, 1, 2], 'apply-bound func with right args'); + st.deepEqual(aBoundArg(sentinel, [1], 4), [sentinel, 1, undefined], 'apply-bound func with too few args'); + + var aBoundR = callBind.apply(func, sentinel); + st.deepEqual(aBoundR([1, 2, 3], 4), [sentinel, 1, 2], 'apply-bound func with receiver and too many args'); + st.deepEqual(aBoundR([1, 2], 4), [sentinel, 1, 2], 'apply-bound func with receiver and right args'); + st.deepEqual(aBoundR([1], 4), [sentinel, 1, undefined], 'apply-bound func with receiver and too few args'); + + st.end(); + }); + + t.end(); +}); diff --git a/node_modules/capnp-ts/CHANGELOG.md b/node_modules/capnp-ts/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..8bccb0a0a48d22b9524e8ea044a9959426e6176d --- /dev/null +++ b/node_modules/capnp-ts/CHANGELOG.md @@ -0,0 +1,59 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + + +# [0.4.0](https://github.com/jdiaz5513/capnp-ts/compare/v0.3.1...v0.4.0) (2018-09-26) + + +### Bug Fixes + +* revert botched import paths ([#111](https://github.com/jdiaz5513/capnp-ts/issues/111)) ([e280020](https://github.com/jdiaz5513/capnp-ts/commit/e280020)) + + +### Features + +* **compiler:** add support for capnpc v0.7.0 ([#110](https://github.com/jdiaz5513/capnp-ts/issues/110)) ([22bd14d](https://github.com/jdiaz5513/capnp-ts/commit/22bd14d)) + + + + + + +## [0.3.1](https://github.com/jdiaz5513/capnp-ts/compare/v0.3.0...v0.3.1) (2018-09-25) + + +### Bug Fixes + +* **serialization:** fix parse crash on null pointer dereference in resize ([#107](https://github.com/jdiaz5513/capnp-ts/issues/107)) ([3f8b307](https://github.com/jdiaz5513/capnp-ts/commit/3f8b307)), closes [#78](https://github.com/jdiaz5513/capnp-ts/issues/78) + + + + + + +# [0.3.0](https://github.com/jdiaz5513/capnp-ts/compare/v0.2.4...v0.3.0) (2018-08-29) + + +### Bug Fixes + +* **build:** avoid use of debug script for capnpc build step ([#101](https://github.com/jdiaz5513/capnp-ts/issues/101)) ([f1d606a](https://github.com/jdiaz5513/capnp-ts/commit/f1d606a)) +* **serialization:** set instance variables before they may be referenced ([#106](https://github.com/jdiaz5513/capnp-ts/issues/106)) ([21deff5](https://github.com/jdiaz5513/capnp-ts/commit/21deff5)) + + +### Features + +* **compiler:** implement remaining serialization features ([#98](https://github.com/jdiaz5513/capnp-ts/issues/98)) ([524b6bd](https://github.com/jdiaz5513/capnp-ts/commit/524b6bd)) + + + + + + +## [0.2.4](https://github.com/jdiaz5513/capnp-ts/compare/v0.2.3...v0.2.4) (2017-11-24) + + + + +**Note:** Version bump only for package capnp-ts diff --git a/node_modules/capnp-ts/README.md b/node_modules/capnp-ts/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a5c67234dd4455f8473f7786002b24e2ddc34cd7 --- /dev/null +++ b/node_modules/capnp-ts/README.md @@ -0,0 +1,21 @@ +# capnp-ts + +A strongly typed [Cap'n Proto](https://capnproto.org/) implementation for the browser and Node.js using TypeScript. + +Here's a quick usage example: + +```typescript +import * as capnp from 'capnp-ts'; + +import {MyStruct} from './myschema.capnp'; + +export function loadMessage(buffer: ArrayBuffer): MyStruct { + + const message = capnp.Message.fromArrayBuffer(buffer); + + return message.getRoot(MyStruct); + +} +``` + +An extended readme is available on the project site: [https://github.com/jdiaz5513/capnp-ts](https://github.com/jdiaz5513/capnp-ts). diff --git a/node_modules/capnp-ts/package.json b/node_modules/capnp-ts/package.json new file mode 100644 index 0000000000000000000000000000000000000000..73fac9ac64ffcc52aad488772edcda78846e36ba --- /dev/null +++ b/node_modules/capnp-ts/package.json @@ -0,0 +1,26 @@ +{ + "author": "jdiaz5513", + "bugs": { + "url": "https://github.com/jdiaz5513/capnp-ts/issues" + }, + "dependencies": { + "debug": "^4.3.1", + "tslib": "^2.2.0" + }, + "description": "Strongly typed Cap'n Proto implementation for the browser and Node.js using TypeScript", + "homepage": "https://github.com/jdiaz5513/capnp-ts#readme", + "keywords": [ + "capnp", + "rpc", + "typescript" + ], + "license": "MIT", + "main": "./src/index.js", + "name": "capnp-ts", + "repository": { + "type": "git", + "url": "git+https://github.com/jdiaz5513/capnp-ts.git" + }, + "types": "./src/index.d.ts", + "version": "0.7.0" +} diff --git a/node_modules/capnp-ts/src/constants.d.ts b/node_modules/capnp-ts/src/constants.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b70cbbf8d4a1283495b3d0d94e75c8bc22995ead --- /dev/null +++ b/node_modules/capnp-ts/src/constants.d.ts @@ -0,0 +1,75 @@ +/** + * @author jdiaz5513 + */ +/** Default size (in bytes) for newly allocated segments. */ +export declare const DEFAULT_BUFFER_SIZE = 4096; +export declare const DEFAULT_DECODE_LIMIT: number; +/** + * Limit to how deeply nested pointers are allowed to be. The root struct of a message will start at this value, and it + * is decremented as pointers are dereferenced. + */ +export declare const DEFAULT_DEPTH_LIMIT = 64; +/** + * Limit to the number of **bytes** that can be traversed in a single message. This is necessary to prevent certain + * classes of DoS attacks where maliciously crafted data can be self-referencing in a way that wouldn't trigger the + * depth limit. + * + * For this reason, it is advised to cache pointers into variables and not constantly dereference them since the + * message's traversal limit gets decremented each time. + */ +export declare const DEFAULT_TRAVERSE_LIMIT: number; +/** + * When allocating array buffers dynamically (while packing or in certain Arena implementations) the previous buffer's + * size is multiplied by this number to determine the next buffer's size. This is chosen to keep both time spent + * reallocating and wasted memory to a minimum. + * + * Smaller numbers would save memory at the expense of CPU time. + */ +export declare const GROWTH_FACTOR = 1.5; +/** A bitmask applied to obtain the size of a list pointer. */ +export declare const LIST_SIZE_MASK = 7; +/** Maximum number of bytes to dump at once when dumping array buffers to string. */ +export declare const MAX_BUFFER_DUMP_BYTES = 8192; +/** The maximum value for a 32-bit integer. */ +export declare const MAX_INT32 = 2147483647; +/** The maximum value for a 32-bit unsigned integer. */ +export declare const MAX_UINT32 = 4294967295; +/** The largest integer that can be precisely represented in JavaScript. */ +export declare const MAX_SAFE_INTEGER = 9007199254740991; +/** Maximum limit on the number of segments in a message stream. */ +export declare const MAX_STREAM_SEGMENTS = 512; +/** The smallest integer that can be precisely represented in JavaScript. */ +export declare const MIN_SAFE_INTEGER = -9007199254740991; +/** Minimum growth increment for a SingleSegmentArena. */ +export declare const MIN_SINGLE_SEGMENT_GROWTH = 4096; +/** + * This will be `true` if the machine running this code stores numbers natively in little-endian format. This is useful + * for some numeric type conversions when the endianness does not affect the output. Using the native endianness for + * these operations is _slightly_ faster. + */ +export declare const NATIVE_LITTLE_ENDIAN: boolean; +/** + * When packing a message, this is the number of zero bytes required after a SPAN (0xff) tag is written to the packed + * message before the span is terminated. + * + * This little detail is left up to the implementation because it can be tuned for performance. Setting this to a higher + * value may help with messages that contain a ton of text/data. + * + * It is imperative to never set this below 1 or else BAD THINGS. You have been warned. + */ +export declare const PACK_SPAN_THRESHOLD = 2; +/** + * How far to travel into a nested pointer structure during a deep copy; when this limit is exhausted the copy + * operation will throw an error. + */ +export declare const POINTER_COPY_LIMIT = 32; +/** A bitmask for looking up the double-far flag on a far pointer. */ +export declare const POINTER_DOUBLE_FAR_MASK = 4; +/** A bitmask for looking up the pointer type. */ +export declare const POINTER_TYPE_MASK = 3; +/** Used for some 64-bit conversions, equal to Math.pow(2, 32). */ +export declare const VAL32 = 4294967296; +/** The maximum value allowed for depth traversal limits. */ +export declare const MAX_DEPTH = 2147483647; +/** The maximum byte length for a single segment. */ +export declare const MAX_SEGMENT_LENGTH = 4294967295; diff --git a/node_modules/capnp-ts/src/constants.js b/node_modules/capnp-ts/src/constants.js new file mode 100644 index 0000000000000000000000000000000000000000..90e168ba3f7588d088b455d2ab000c7f0e995333 --- /dev/null +++ b/node_modules/capnp-ts/src/constants.js @@ -0,0 +1,82 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MAX_SEGMENT_LENGTH = exports.MAX_DEPTH = exports.VAL32 = exports.POINTER_TYPE_MASK = exports.POINTER_DOUBLE_FAR_MASK = exports.POINTER_COPY_LIMIT = exports.PACK_SPAN_THRESHOLD = exports.NATIVE_LITTLE_ENDIAN = exports.MIN_SINGLE_SEGMENT_GROWTH = exports.MIN_SAFE_INTEGER = exports.MAX_STREAM_SEGMENTS = exports.MAX_SAFE_INTEGER = exports.MAX_UINT32 = exports.MAX_INT32 = exports.MAX_BUFFER_DUMP_BYTES = exports.LIST_SIZE_MASK = exports.GROWTH_FACTOR = exports.DEFAULT_TRAVERSE_LIMIT = exports.DEFAULT_DEPTH_LIMIT = exports.DEFAULT_DECODE_LIMIT = exports.DEFAULT_BUFFER_SIZE = void 0; +// Perform some bit gymnastics to determine the native endian format. +const tmpWord = new DataView(new ArrayBuffer(8)); +new Uint16Array(tmpWord.buffer)[0] = 0x0102; +/** Default size (in bytes) for newly allocated segments. */ +exports.DEFAULT_BUFFER_SIZE = 4096; +exports.DEFAULT_DECODE_LIMIT = 64 << 20; // 64 MiB +/** + * Limit to how deeply nested pointers are allowed to be. The root struct of a message will start at this value, and it + * is decremented as pointers are dereferenced. + */ +exports.DEFAULT_DEPTH_LIMIT = 64; +/** + * Limit to the number of **bytes** that can be traversed in a single message. This is necessary to prevent certain + * classes of DoS attacks where maliciously crafted data can be self-referencing in a way that wouldn't trigger the + * depth limit. + * + * For this reason, it is advised to cache pointers into variables and not constantly dereference them since the + * message's traversal limit gets decremented each time. + */ +exports.DEFAULT_TRAVERSE_LIMIT = 64 << 20; // 64 MiB +/** + * When allocating array buffers dynamically (while packing or in certain Arena implementations) the previous buffer's + * size is multiplied by this number to determine the next buffer's size. This is chosen to keep both time spent + * reallocating and wasted memory to a minimum. + * + * Smaller numbers would save memory at the expense of CPU time. + */ +exports.GROWTH_FACTOR = 1.5; +/** A bitmask applied to obtain the size of a list pointer. */ +exports.LIST_SIZE_MASK = 0x00000007; +/** Maximum number of bytes to dump at once when dumping array buffers to string. */ +exports.MAX_BUFFER_DUMP_BYTES = 8192; +/** The maximum value for a 32-bit integer. */ +exports.MAX_INT32 = 0x7fffffff; +/** The maximum value for a 32-bit unsigned integer. */ +exports.MAX_UINT32 = 0xffffffff; +/** The largest integer that can be precisely represented in JavaScript. */ +exports.MAX_SAFE_INTEGER = 9007199254740991; +/** Maximum limit on the number of segments in a message stream. */ +exports.MAX_STREAM_SEGMENTS = 512; +/** The smallest integer that can be precisely represented in JavaScript. */ +exports.MIN_SAFE_INTEGER = -9007199254740991; +/** Minimum growth increment for a SingleSegmentArena. */ +exports.MIN_SINGLE_SEGMENT_GROWTH = 4096; +/** + * This will be `true` if the machine running this code stores numbers natively in little-endian format. This is useful + * for some numeric type conversions when the endianness does not affect the output. Using the native endianness for + * these operations is _slightly_ faster. + */ +exports.NATIVE_LITTLE_ENDIAN = tmpWord.getUint8(0) === 0x02; +/** + * When packing a message, this is the number of zero bytes required after a SPAN (0xff) tag is written to the packed + * message before the span is terminated. + * + * This little detail is left up to the implementation because it can be tuned for performance. Setting this to a higher + * value may help with messages that contain a ton of text/data. + * + * It is imperative to never set this below 1 or else BAD THINGS. You have been warned. + */ +exports.PACK_SPAN_THRESHOLD = 2; +/** + * How far to travel into a nested pointer structure during a deep copy; when this limit is exhausted the copy + * operation will throw an error. + */ +exports.POINTER_COPY_LIMIT = 32; +/** A bitmask for looking up the double-far flag on a far pointer. */ +exports.POINTER_DOUBLE_FAR_MASK = 0x00000004; +/** A bitmask for looking up the pointer type. */ +exports.POINTER_TYPE_MASK = 0x00000003; +/** Used for some 64-bit conversions, equal to Math.pow(2, 32). */ +exports.VAL32 = 0x100000000; +/** The maximum value allowed for depth traversal limits. */ +exports.MAX_DEPTH = exports.MAX_INT32; +/** The maximum byte length for a single segment. */ +exports.MAX_SEGMENT_LENGTH = exports.MAX_UINT32; +//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/constants.js.map b/node_modules/capnp-ts/src/constants.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6d0eb636b40523a12dd86c561ad0441be3ae3f87 --- /dev/null +++ b/node_modules/capnp-ts/src/constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.js","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qEAAqE;AAErE,MAAM,OAAO,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CA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AAEjC,4DAA4D;AAE/C,QAAA,SAAS,GAAG,iBAAS,CAAC;AAEnC,oDAAoD;AAEvC,QAAA,kBAAkB,GAAG,kBAAU,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/constants.ts b/node_modules/capnp-ts/src/constants.ts new file mode 100644 index 0000000000000000000000000000000000000000..24315de96492c638d3edefc183cff91bf874b09d --- /dev/null +++ b/node_modules/capnp-ts/src/constants.ts @@ -0,0 +1,121 @@ +/** + * @author jdiaz5513 + */ + +// Perform some bit gymnastics to determine the native endian format. + +const tmpWord = new DataView(new ArrayBuffer(8)); +new Uint16Array(tmpWord.buffer)[0] = 0x0102; + +/** Default size (in bytes) for newly allocated segments. */ + +export const DEFAULT_BUFFER_SIZE = 4096; + +export const DEFAULT_DECODE_LIMIT = 64 << 20; // 64 MiB + +/** + * Limit to how deeply nested pointers are allowed to be. The root struct of a message will start at this value, and it + * is decremented as pointers are dereferenced. + */ + +export const DEFAULT_DEPTH_LIMIT = 64; + +/** + * Limit to the number of **bytes** that can be traversed in a single message. This is necessary to prevent certain + * classes of DoS attacks where maliciously crafted data can be self-referencing in a way that wouldn't trigger the + * depth limit. + * + * For this reason, it is advised to cache pointers into variables and not constantly dereference them since the + * message's traversal limit gets decremented each time. + */ + +export const DEFAULT_TRAVERSE_LIMIT = 64 << 20; // 64 MiB + +/** + * When allocating array buffers dynamically (while packing or in certain Arena implementations) the previous buffer's + * size is multiplied by this number to determine the next buffer's size. This is chosen to keep both time spent + * reallocating and wasted memory to a minimum. + * + * Smaller numbers would save memory at the expense of CPU time. + */ + +export const GROWTH_FACTOR = 1.5; + +/** A bitmask applied to obtain the size of a list pointer. */ + +export const LIST_SIZE_MASK = 0x00000007; + +/** Maximum number of bytes to dump at once when dumping array buffers to string. */ + +export const MAX_BUFFER_DUMP_BYTES = 8192; + +/** The maximum value for a 32-bit integer. */ + +export const MAX_INT32 = 0x7fffffff; + +/** The maximum value for a 32-bit unsigned integer. */ + +export const MAX_UINT32 = 0xffffffff; + +/** The largest integer that can be precisely represented in JavaScript. */ + +export const MAX_SAFE_INTEGER = 9007199254740991; + +/** Maximum limit on the number of segments in a message stream. */ + +export const MAX_STREAM_SEGMENTS = 512; + +/** The smallest integer that can be precisely represented in JavaScript. */ + +export const MIN_SAFE_INTEGER = -9007199254740991; + +/** Minimum growth increment for a SingleSegmentArena. */ + +export const MIN_SINGLE_SEGMENT_GROWTH = 4096; + +/** + * This will be `true` if the machine running this code stores numbers natively in little-endian format. This is useful + * for some numeric type conversions when the endianness does not affect the output. Using the native endianness for + * these operations is _slightly_ faster. + */ + +export const NATIVE_LITTLE_ENDIAN = tmpWord.getUint8(0) === 0x02; + +/** + * When packing a message, this is the number of zero bytes required after a SPAN (0xff) tag is written to the packed + * message before the span is terminated. + * + * This little detail is left up to the implementation because it can be tuned for performance. Setting this to a higher + * value may help with messages that contain a ton of text/data. + * + * It is imperative to never set this below 1 or else BAD THINGS. You have been warned. + */ + +export const PACK_SPAN_THRESHOLD = 2; + +/** + * How far to travel into a nested pointer structure during a deep copy; when this limit is exhausted the copy + * operation will throw an error. + */ + +export const POINTER_COPY_LIMIT = 32; + +/** A bitmask for looking up the double-far flag on a far pointer. */ + +export const POINTER_DOUBLE_FAR_MASK = 0x00000004; + +/** A bitmask for looking up the pointer type. */ + +export const POINTER_TYPE_MASK = 0x00000003; + +/** Used for some 64-bit conversions, equal to Math.pow(2, 32). */ + +export const VAL32 = 0x100000000; + +/** The maximum value allowed for depth traversal limits. */ + +export const MAX_DEPTH = MAX_INT32; + +/** The maximum byte length for a single segment. */ + +export const MAX_SEGMENT_LENGTH = MAX_UINT32; diff --git a/node_modules/capnp-ts/src/errors.d.ts b/node_modules/capnp-ts/src/errors.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8dcefc6bdf2a62db6afbec805e100d2647a57e7 --- /dev/null +++ b/node_modules/capnp-ts/src/errors.d.ts @@ -0,0 +1,51 @@ +/** + * This file contains all the error strings used in the library. Also contains silliness. + * + * @author jdiaz5513 + */ +export declare const INVARIANT_UNREACHABLE_CODE = "CAPNP-TS000 Unreachable code detected."; +export declare function assertNever(n: never): never; +export declare const MSG_INVALID_FRAME_HEADER = "CAPNP-TS001 Attempted to parse an invalid message frame header; are you sure this is a Cap'n Proto message?"; +export declare const MSG_NO_SEGMENTS_IN_ARENA = "CAPNP-TS002 Attempted to preallocate a message with no segments in the arena."; +export declare const MSG_PACK_NOT_WORD_ALIGNED = "CAPNP-TS003 Attempted to pack a message that was not word-aligned."; +export declare const MSG_SEGMENT_OUT_OF_BOUNDS = "CAPNP-TS004 Segment ID %X is out of bounds for message %s."; +export declare const MSG_SEGMENT_TOO_SMALL = "CAPNP-TS005 First segment must have at least enough room to hold the root pointer (8 bytes)."; +export declare const NOT_IMPLEMENTED = "CAPNP-TS006 %s is not implemented."; +export declare const PTR_ADOPT_COMPOSITE_STRUCT = "CAPNP-TS007 Attempted to adopt a struct into a composite list (%s)."; +export declare const PTR_ADOPT_WRONG_MESSAGE = "CAPNP-TS008 Attempted to adopt %s into a pointer in a different message %s."; +export declare const PTR_ALREADY_ADOPTED = "CAPNP-TS009 Attempted to adopt %s more than once."; +export declare const PTR_COMPOSITE_SIZE_UNDEFINED = "CAPNP-TS010 Attempted to set a composite list without providing a composite element size."; +export declare const PTR_DEPTH_LIMIT_EXCEEDED = "CAPNP-TS011 Nesting depth limit exceeded for %s."; +export declare const PTR_DISOWN_COMPOSITE_STRUCT = "CAPNP-TS012 Attempted to disown a struct member from a composite list (%s)."; +export declare const PTR_INIT_COMPOSITE_STRUCT = "CAPNP-TS013 Attempted to initialize a struct member from a composite list (%s)."; +export declare const PTR_INIT_NON_GROUP = "CAPNP-TS014 Attempted to initialize a group field with a non-group struct class."; +export declare const PTR_INVALID_FAR_TARGET = "CAPNP-TS015 Target of a far pointer (%s) is another far pointer."; +export declare const PTR_INVALID_LIST_SIZE = "CAPNP-TS016 Invalid list element size: %x."; +export declare const PTR_INVALID_POINTER_TYPE = "CAPNP-TS017 Invalid pointer type: %x."; +export declare const PTR_INVALID_UNION_ACCESS = "CAPNP-TS018 Attempted to access getter on %s for union field %s that is not currently set (wanted: %d, found: %d)."; +export declare const PTR_OFFSET_OUT_OF_BOUNDS = "CAPNP-TS019 Pointer offset %a is out of bounds for underlying buffer."; +export declare const PTR_STRUCT_DATA_OUT_OF_BOUNDS = "CAPNP-TS020 Attempted to access out-of-bounds struct data (struct: %s, %d bytes at %a, data words: %d)."; +export declare const PTR_STRUCT_POINTER_OUT_OF_BOUNDS = "CAPNP-TS021 Attempted to access out-of-bounds struct pointer (%s, index: %d, length: %d)."; +export declare const PTR_TRAVERSAL_LIMIT_EXCEEDED = "CAPNP-TS022 Traversal limit exceeded! Slow down! %s"; +export declare const PTR_WRONG_LIST_TYPE = "CAPNP-TS023 Cannot convert %s to a %s list."; +export declare const PTR_WRONG_POINTER_TYPE = "CAPNP-TS024 Attempted to convert pointer %s to a %s type."; +export declare const PTR_WRONG_COMPOSITE_DATA_SIZE = "CAPNP-TS025 Attempted to convert %s to a composite list with the wrong data size (found: %d)."; +export declare const PTR_WRONG_COMPOSITE_PTR_SIZE = "CAPNP-TS026 Attempted to convert %s to a composite list with the wrong pointer size (found: %d)."; +export declare const PTR_WRONG_STRUCT_DATA_SIZE = "CAPNP-TS027 Attempted to convert %s to a struct with the wrong data size (found: %d)."; +export declare const PTR_WRONG_STRUCT_PTR_SIZE = "CAPNP-TS028 Attempted to convert %s to a struct with the wrong pointer size (found: %d)."; +export declare const RANGE_INT32_OVERFLOW = "CAPNP-TS029 32-bit signed integer overflow detected."; +export declare const RANGE_INT64_UNDERFLOW = "CAPNP-TS030 Buffer is not large enough to hold a word."; +export declare const RANGE_INVALID_UTF8 = "CAPNP-TS031 Invalid UTF-8 code sequence detected."; +export declare const RANGE_SIZE_OVERFLOW: string; +export declare const RANGE_UINT32_OVERFLOW = "CAPNP-TS033 32-bit unsigned integer overflow detected."; +export declare const SEG_BUFFER_NOT_ALLOCATED = "CAPNP-TS034 allocate() needs to be called at least once before getting a buffer."; +export declare const SEG_GET_NON_ZERO_SINGLE = "CAPNP-TS035 Attempted to get a segment other than 0 (%d) from a single segment arena."; +export declare const SEG_ID_OUT_OF_BOUNDS = "CAPNP-TS036 Attempted to get an out-of-bounds segment (%d)."; +export declare const SEG_NOT_WORD_ALIGNED = "CAPNP-TS037 Segment buffer length %d is not a multiple of 8."; +export declare const SEG_REPLACEMENT_BUFFER_TOO_SMALL = "CAPNP-TS038 Attempted to replace a segment buffer with one that is smaller than the allocated space."; +export declare const SEG_SIZE_OVERFLOW: string; +export declare const TYPE_COMPOSITE_SIZE_UNDEFINED = "CAPNP-TS040 Must provide a composite element size for composite list pointers."; +export declare const TYPE_GET_GENERIC_LIST = "CAPNP-TS041 Attempted to call get() on a generic list."; +export declare const TYPE_SET_GENERIC_LIST = "CAPNP-TS042 Attempted to call set() on a generic list."; +export declare const PTR_WRITE_CONST_LIST = "CAPNP-TS043 Attempted to write to a const list."; +export declare const PTR_WRITE_CONST_STRUCT = "CAPNP-TS044 Attempted to write to a const struct."; diff --git a/node_modules/capnp-ts/src/errors.js b/node_modules/capnp-ts/src/errors.js new file mode 100644 index 0000000000000000000000000000000000000000..348d3adcca9db11deb2c3c4c1e38b27e3044bae4 --- /dev/null +++ b/node_modules/capnp-ts/src/errors.js @@ -0,0 +1,86 @@ +"use strict"; +/** + * This file contains all the error strings used in the library. Also contains silliness. + * + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PTR_WRITE_CONST_STRUCT = exports.PTR_WRITE_CONST_LIST = exports.TYPE_SET_GENERIC_LIST = exports.TYPE_GET_GENERIC_LIST = exports.TYPE_COMPOSITE_SIZE_UNDEFINED = exports.SEG_SIZE_OVERFLOW = exports.SEG_REPLACEMENT_BUFFER_TOO_SMALL = exports.SEG_NOT_WORD_ALIGNED = exports.SEG_ID_OUT_OF_BOUNDS = exports.SEG_GET_NON_ZERO_SINGLE = exports.SEG_BUFFER_NOT_ALLOCATED = exports.RANGE_UINT32_OVERFLOW = exports.RANGE_SIZE_OVERFLOW = exports.RANGE_INVALID_UTF8 = exports.RANGE_INT64_UNDERFLOW = exports.RANGE_INT32_OVERFLOW = exports.PTR_WRONG_STRUCT_PTR_SIZE = exports.PTR_WRONG_STRUCT_DATA_SIZE = exports.PTR_WRONG_COMPOSITE_PTR_SIZE = exports.PTR_WRONG_COMPOSITE_DATA_SIZE = exports.PTR_WRONG_POINTER_TYPE = exports.PTR_WRONG_LIST_TYPE = exports.PTR_TRAVERSAL_LIMIT_EXCEEDED = exports.PTR_STRUCT_POINTER_OUT_OF_BOUNDS = exports.PTR_STRUCT_DATA_OUT_OF_BOUNDS = exports.PTR_OFFSET_OUT_OF_BOUNDS = exports.PTR_INVALID_UNION_ACCESS = exports.PTR_INVALID_POINTER_TYPE = exports.PTR_INVALID_LIST_SIZE = exports.PTR_INVALID_FAR_TARGET = exports.PTR_INIT_NON_GROUP = exports.PTR_INIT_COMPOSITE_STRUCT = exports.PTR_DISOWN_COMPOSITE_STRUCT = exports.PTR_DEPTH_LIMIT_EXCEEDED = exports.PTR_COMPOSITE_SIZE_UNDEFINED = exports.PTR_ALREADY_ADOPTED = exports.PTR_ADOPT_WRONG_MESSAGE = exports.PTR_ADOPT_COMPOSITE_STRUCT = exports.NOT_IMPLEMENTED = exports.MSG_SEGMENT_TOO_SMALL = exports.MSG_SEGMENT_OUT_OF_BOUNDS = exports.MSG_PACK_NOT_WORD_ALIGNED = exports.MSG_NO_SEGMENTS_IN_ARENA = exports.MSG_INVALID_FRAME_HEADER = exports.assertNever = exports.INVARIANT_UNREACHABLE_CODE = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("./constants"); +const trace = debug_1.default("capnp:errors"); +trace("load"); +// Invariant violations (sometimes known as "precondition failed"). +// +// All right, hold up the brakes. This is a serious 1 === 0 WHAT THE FAILURE moment here. Tell the SO's you won't be +// home for dinner. +exports.INVARIANT_UNREACHABLE_CODE = "CAPNP-TS000 Unreachable code detected."; +function assertNever(n) { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + throw new Error(exports.INVARIANT_UNREACHABLE_CODE + ` (never block hit with: ${n})`); +} +exports.assertNever = assertNever; +// Message errors. +// +// Now who told you it would be a good idea to fuzz the inputs? You just made the program sad. +exports.MSG_INVALID_FRAME_HEADER = "CAPNP-TS001 Attempted to parse an invalid message frame header; are you sure this is a Cap'n Proto message?"; +exports.MSG_NO_SEGMENTS_IN_ARENA = "CAPNP-TS002 Attempted to preallocate a message with no segments in the arena."; +exports.MSG_PACK_NOT_WORD_ALIGNED = "CAPNP-TS003 Attempted to pack a message that was not word-aligned."; +exports.MSG_SEGMENT_OUT_OF_BOUNDS = "CAPNP-TS004 Segment ID %X is out of bounds for message %s."; +exports.MSG_SEGMENT_TOO_SMALL = "CAPNP-TS005 First segment must have at least enough room to hold the root pointer (8 bytes)."; +// Used for methods that are not yet implemented. +// +// My bad. I'll get to it. Eventually. +exports.NOT_IMPLEMENTED = "CAPNP-TS006 %s is not implemented."; +// Pointer-related errors. +// +// Look, this is probably the hardest part of the code. Cut some slack here! You probably found a bug. +exports.PTR_ADOPT_COMPOSITE_STRUCT = "CAPNP-TS007 Attempted to adopt a struct into a composite list (%s)."; +exports.PTR_ADOPT_WRONG_MESSAGE = "CAPNP-TS008 Attempted to adopt %s into a pointer in a different message %s."; +exports.PTR_ALREADY_ADOPTED = "CAPNP-TS009 Attempted to adopt %s more than once."; +exports.PTR_COMPOSITE_SIZE_UNDEFINED = "CAPNP-TS010 Attempted to set a composite list without providing a composite element size."; +exports.PTR_DEPTH_LIMIT_EXCEEDED = "CAPNP-TS011 Nesting depth limit exceeded for %s."; +exports.PTR_DISOWN_COMPOSITE_STRUCT = "CAPNP-TS012 Attempted to disown a struct member from a composite list (%s)."; +exports.PTR_INIT_COMPOSITE_STRUCT = "CAPNP-TS013 Attempted to initialize a struct member from a composite list (%s)."; +exports.PTR_INIT_NON_GROUP = "CAPNP-TS014 Attempted to initialize a group field with a non-group struct class."; +exports.PTR_INVALID_FAR_TARGET = "CAPNP-TS015 Target of a far pointer (%s) is another far pointer."; +exports.PTR_INVALID_LIST_SIZE = "CAPNP-TS016 Invalid list element size: %x."; +exports.PTR_INVALID_POINTER_TYPE = "CAPNP-TS017 Invalid pointer type: %x."; +exports.PTR_INVALID_UNION_ACCESS = "CAPNP-TS018 Attempted to access getter on %s for union field %s that is not currently set (wanted: %d, found: %d)."; +exports.PTR_OFFSET_OUT_OF_BOUNDS = "CAPNP-TS019 Pointer offset %a is out of bounds for underlying buffer."; +exports.PTR_STRUCT_DATA_OUT_OF_BOUNDS = "CAPNP-TS020 Attempted to access out-of-bounds struct data (struct: %s, %d bytes at %a, data words: %d)."; +exports.PTR_STRUCT_POINTER_OUT_OF_BOUNDS = "CAPNP-TS021 Attempted to access out-of-bounds struct pointer (%s, index: %d, length: %d)."; +exports.PTR_TRAVERSAL_LIMIT_EXCEEDED = "CAPNP-TS022 Traversal limit exceeded! Slow down! %s"; +exports.PTR_WRONG_LIST_TYPE = "CAPNP-TS023 Cannot convert %s to a %s list."; +exports.PTR_WRONG_POINTER_TYPE = "CAPNP-TS024 Attempted to convert pointer %s to a %s type."; +exports.PTR_WRONG_COMPOSITE_DATA_SIZE = "CAPNP-TS025 Attempted to convert %s to a composite list with the wrong data size (found: %d)."; +exports.PTR_WRONG_COMPOSITE_PTR_SIZE = "CAPNP-TS026 Attempted to convert %s to a composite list with the wrong pointer size (found: %d)."; +exports.PTR_WRONG_STRUCT_DATA_SIZE = "CAPNP-TS027 Attempted to convert %s to a struct with the wrong data size (found: %d)."; +exports.PTR_WRONG_STRUCT_PTR_SIZE = "CAPNP-TS028 Attempted to convert %s to a struct with the wrong pointer size (found: %d)."; +// Custom error messages for the built-in `RangeError` class. +// +// You don't get a witty comment with these. +exports.RANGE_INT32_OVERFLOW = "CAPNP-TS029 32-bit signed integer overflow detected."; +exports.RANGE_INT64_UNDERFLOW = "CAPNP-TS030 Buffer is not large enough to hold a word."; +exports.RANGE_INVALID_UTF8 = "CAPNP-TS031 Invalid UTF-8 code sequence detected."; +exports.RANGE_SIZE_OVERFLOW = `CAPNP-TS032 Size %x exceeds maximum ${constants_1.MAX_SEGMENT_LENGTH.toString(16)}.`; +exports.RANGE_UINT32_OVERFLOW = "CAPNP-TS033 32-bit unsigned integer overflow detected."; +// Segment-related errors. +// +// These suck. Deal with it. +exports.SEG_BUFFER_NOT_ALLOCATED = "CAPNP-TS034 allocate() needs to be called at least once before getting a buffer."; +exports.SEG_GET_NON_ZERO_SINGLE = "CAPNP-TS035 Attempted to get a segment other than 0 (%d) from a single segment arena."; +exports.SEG_ID_OUT_OF_BOUNDS = "CAPNP-TS036 Attempted to get an out-of-bounds segment (%d)."; +exports.SEG_NOT_WORD_ALIGNED = "CAPNP-TS037 Segment buffer length %d is not a multiple of 8."; +exports.SEG_REPLACEMENT_BUFFER_TOO_SMALL = "CAPNP-TS038 Attempted to replace a segment buffer with one that is smaller than the allocated space."; +exports.SEG_SIZE_OVERFLOW = `CAPNP-TS039 Requested size %x exceeds maximum value (${constants_1.MAX_SEGMENT_LENGTH}).`; +// Custom error messages for the built-in `TypeError` class. +// +// If it looks like a duck, quacks like an elephant, and has hooves for feet, it's probably JavaScript. +exports.TYPE_COMPOSITE_SIZE_UNDEFINED = "CAPNP-TS040 Must provide a composite element size for composite list pointers."; +exports.TYPE_GET_GENERIC_LIST = "CAPNP-TS041 Attempted to call get() on a generic list."; +exports.TYPE_SET_GENERIC_LIST = "CAPNP-TS042 Attempted to call set() on a generic list."; +exports.PTR_WRITE_CONST_LIST = "CAPNP-TS043 Attempted to write to a const list."; +exports.PTR_WRITE_CONST_STRUCT = "CAPNP-TS044 Attempted to write to a const struct."; +//# sourceMappingURL=errors.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/errors.js.map b/node_modules/capnp-ts/src/errors.js.map new file mode 100644 index 0000000000000000000000000000000000000000..74a463d962157a7b9abca68486d4c19e9580d988 --- /dev/null +++ b/node_modules/capnp-ts/src/errors.js.map @@ -0,0 +1 @@ +{"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,0DAA8B;AAE9B,2CAAiD;AAEjD,MAAM,KAAK,GAAG,eAAS,CAAC,cAAc,CAAC,CAAC;AACxC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,mEAAmE;AACnE,EAAE;AACF,oHAAoH;AACpH,mBAAmB;AAEN,QAAA,0BAA0B,GAAG,wCAAwC,CAAC;AAEnF,SAAgB,WAAW,CAAC,CAAQ;IAClC,4EAA4E;IAC5E,MAAM,IAAI,KAAK,CAAC,kCAA0B,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAC;AAChF,CAAC;AAHD,kCAGC;AAED,kBAAkB;AAClB,EAAE;AACF,8FAA8F;AAEjF,QAAA,wBAAwB,GACnC,6GAA6G,CAAC;AACnG,QAAA,wBAAwB,GAAG,+EAA+E,CAAC;AAC3G,QAAA,yBAAyB,GAAG,oEAAoE,CAAC;AACjG,QAAA,yBAAyB,GAAG,4DAA4D,CAAC;AACzF,QAAA,qBAAqB,GAChC,8FAA8F,CAAC;AAEjG,iDAAiD;AACjD,EAAE;AACF,sCAAsC;AAEzB,QAAA,eAAe,GAAG,oCAAoC,CAAC;AAEpE,0BAA0B;AAC1B,EAAE;AACF,sGAAsG;AAEzF,QAAA,0BAA0B,GAAG,qEAAqE,CAAC;AACnG,QAAA,uBAAuB,GAAG,6EAA6E,CAAC;AACxG,QAAA,mBAAmB,GAAG,mDAAmD,CAAC;AAC1E,QAAA,4BAA4B,GACvC,2FAA2F,CAAC;AACjF,QAAA,wBAAwB,GAAG,kDAAkD,CAAC;AAC9E,QAAA,2BAA2B,GACtC,6EAA6E,CAAC;AACnE,QAAA,yBAAyB,GACpC,iFAAiF,CAAC;AACvE,QAAA,kBAAkB,GAAG,kFAAkF,CAAC;AACxG,QAAA,sBAAsB,GAAG,kEAAkE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tE,QAAA,qBAAqB,GAAG,wDAAwD,CAAC;AACjF,QAAA,qBAAqB,GAAG,wDAAwD,CAAC;AAEjF,QAAA,oBAAoB,GAAG,iDAAiD,CAAC;AACzE,QAAA,sBAAsB,GAAG,mDAAmD,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/errors.ts b/node_modules/capnp-ts/src/errors.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fce404f5956e08552b174326ac3960cc917dc2a --- /dev/null +++ b/node_modules/capnp-ts/src/errors.ts @@ -0,0 +1,115 @@ +/** + * This file contains all the error strings used in the library. Also contains silliness. + * + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { MAX_SEGMENT_LENGTH } from "./constants"; + +const trace = initTrace("capnp:errors"); +trace("load"); + +// Invariant violations (sometimes known as "precondition failed"). +// +// All right, hold up the brakes. This is a serious 1 === 0 WHAT THE FAILURE moment here. Tell the SO's you won't be +// home for dinner. + +export const INVARIANT_UNREACHABLE_CODE = "CAPNP-TS000 Unreachable code detected."; + +export function assertNever(n: never): never { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + throw new Error(INVARIANT_UNREACHABLE_CODE + ` (never block hit with: ${n})`); +} + +// Message errors. +// +// Now who told you it would be a good idea to fuzz the inputs? You just made the program sad. + +export const MSG_INVALID_FRAME_HEADER = + "CAPNP-TS001 Attempted to parse an invalid message frame header; are you sure this is a Cap'n Proto message?"; +export const MSG_NO_SEGMENTS_IN_ARENA = "CAPNP-TS002 Attempted to preallocate a message with no segments in the arena."; +export const MSG_PACK_NOT_WORD_ALIGNED = "CAPNP-TS003 Attempted to pack a message that was not word-aligned."; +export const MSG_SEGMENT_OUT_OF_BOUNDS = "CAPNP-TS004 Segment ID %X is out of bounds for message %s."; +export const MSG_SEGMENT_TOO_SMALL = + "CAPNP-TS005 First segment must have at least enough room to hold the root pointer (8 bytes)."; + +// Used for methods that are not yet implemented. +// +// My bad. I'll get to it. Eventually. + +export const NOT_IMPLEMENTED = "CAPNP-TS006 %s is not implemented."; + +// Pointer-related errors. +// +// Look, this is probably the hardest part of the code. Cut some slack here! You probably found a bug. + +export const PTR_ADOPT_COMPOSITE_STRUCT = "CAPNP-TS007 Attempted to adopt a struct into a composite list (%s)."; +export const PTR_ADOPT_WRONG_MESSAGE = "CAPNP-TS008 Attempted to adopt %s into a pointer in a different message %s."; +export const PTR_ALREADY_ADOPTED = "CAPNP-TS009 Attempted to adopt %s more than once."; +export const PTR_COMPOSITE_SIZE_UNDEFINED = + "CAPNP-TS010 Attempted to set a composite list without providing a composite element size."; +export const PTR_DEPTH_LIMIT_EXCEEDED = "CAPNP-TS011 Nesting depth limit exceeded for %s."; +export const PTR_DISOWN_COMPOSITE_STRUCT = + "CAPNP-TS012 Attempted to disown a struct member from a composite list (%s)."; +export const PTR_INIT_COMPOSITE_STRUCT = + "CAPNP-TS013 Attempted to initialize a struct member from a composite list (%s)."; +export const PTR_INIT_NON_GROUP = "CAPNP-TS014 Attempted to initialize a group field with a non-group struct class."; +export const PTR_INVALID_FAR_TARGET = "CAPNP-TS015 Target of a far pointer (%s) is another far pointer."; +export const PTR_INVALID_LIST_SIZE = "CAPNP-TS016 Invalid list element size: %x."; +export const PTR_INVALID_POINTER_TYPE = "CAPNP-TS017 Invalid pointer type: %x."; +export const PTR_INVALID_UNION_ACCESS = + "CAPNP-TS018 Attempted to access getter on %s for union field %s that is not currently set (wanted: %d, found: %d)."; +export const PTR_OFFSET_OUT_OF_BOUNDS = "CAPNP-TS019 Pointer offset %a is out of bounds for underlying buffer."; +export const PTR_STRUCT_DATA_OUT_OF_BOUNDS = + "CAPNP-TS020 Attempted to access out-of-bounds struct data (struct: %s, %d bytes at %a, data words: %d)."; +export const PTR_STRUCT_POINTER_OUT_OF_BOUNDS = + "CAPNP-TS021 Attempted to access out-of-bounds struct pointer (%s, index: %d, length: %d)."; +export const PTR_TRAVERSAL_LIMIT_EXCEEDED = "CAPNP-TS022 Traversal limit exceeded! Slow down! %s"; +export const PTR_WRONG_LIST_TYPE = "CAPNP-TS023 Cannot convert %s to a %s list."; +export const PTR_WRONG_POINTER_TYPE = "CAPNP-TS024 Attempted to convert pointer %s to a %s type."; +export const PTR_WRONG_COMPOSITE_DATA_SIZE = + "CAPNP-TS025 Attempted to convert %s to a composite list with the wrong data size (found: %d)."; +export const PTR_WRONG_COMPOSITE_PTR_SIZE = + "CAPNP-TS026 Attempted to convert %s to a composite list with the wrong pointer size (found: %d)."; +export const PTR_WRONG_STRUCT_DATA_SIZE = + "CAPNP-TS027 Attempted to convert %s to a struct with the wrong data size (found: %d)."; +export const PTR_WRONG_STRUCT_PTR_SIZE = + "CAPNP-TS028 Attempted to convert %s to a struct with the wrong pointer size (found: %d)."; + +// Custom error messages for the built-in `RangeError` class. +// +// You don't get a witty comment with these. + +export const RANGE_INT32_OVERFLOW = "CAPNP-TS029 32-bit signed integer overflow detected."; +export const RANGE_INT64_UNDERFLOW = "CAPNP-TS030 Buffer is not large enough to hold a word."; +export const RANGE_INVALID_UTF8 = "CAPNP-TS031 Invalid UTF-8 code sequence detected."; +export const RANGE_SIZE_OVERFLOW = `CAPNP-TS032 Size %x exceeds maximum ${MAX_SEGMENT_LENGTH.toString(16)}.`; +export const RANGE_UINT32_OVERFLOW = "CAPNP-TS033 32-bit unsigned integer overflow detected."; + +// Segment-related errors. +// +// These suck. Deal with it. + +export const SEG_BUFFER_NOT_ALLOCATED = + "CAPNP-TS034 allocate() needs to be called at least once before getting a buffer."; +export const SEG_GET_NON_ZERO_SINGLE = + "CAPNP-TS035 Attempted to get a segment other than 0 (%d) from a single segment arena."; +export const SEG_ID_OUT_OF_BOUNDS = "CAPNP-TS036 Attempted to get an out-of-bounds segment (%d)."; +export const SEG_NOT_WORD_ALIGNED = "CAPNP-TS037 Segment buffer length %d is not a multiple of 8."; +export const SEG_REPLACEMENT_BUFFER_TOO_SMALL = + "CAPNP-TS038 Attempted to replace a segment buffer with one that is smaller than the allocated space."; +export const SEG_SIZE_OVERFLOW = `CAPNP-TS039 Requested size %x exceeds maximum value (${MAX_SEGMENT_LENGTH}).`; + +// Custom error messages for the built-in `TypeError` class. +// +// If it looks like a duck, quacks like an elephant, and has hooves for feet, it's probably JavaScript. + +export const TYPE_COMPOSITE_SIZE_UNDEFINED = + "CAPNP-TS040 Must provide a composite element size for composite list pointers."; +export const TYPE_GET_GENERIC_LIST = "CAPNP-TS041 Attempted to call get() on a generic list."; +export const TYPE_SET_GENERIC_LIST = "CAPNP-TS042 Attempted to call set() on a generic list."; + +export const PTR_WRITE_CONST_LIST = "CAPNP-TS043 Attempted to write to a const list."; +export const PTR_WRITE_CONST_STRUCT = "CAPNP-TS044 Attempted to write to a const struct."; diff --git a/node_modules/capnp-ts/src/index.d.ts b/node_modules/capnp-ts/src/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5795ab41e01c7a19587f6ff934471de0cc7afbba --- /dev/null +++ b/node_modules/capnp-ts/src/index.d.ts @@ -0,0 +1,5 @@ +/** + * @author jdiaz5513 + */ +export { ListElementSize, Message, ObjectSize, readRawPointer, AnyPointerList, BoolList, CompositeList, Data, DataList, Float32List, Float64List, Int16List, Int32List, Int64List, Int8List, Interface, InterfaceList, List, ListCtor, Orphan, PointerList, PointerType, Pointer, Struct, StructCtor, Text, TextList, Uint16List, Uint32List, Uint64List, Uint8List, VoidList, Void, getBitMask, getFloat32Mask, getFloat64Mask, getInt16Mask, getInt32Mask, getInt64Mask, getInt8Mask, getUint16Mask, getUint32Mask, getUint64Mask, getUint8Mask, } from "./serialization"; +export { Int64, Uint64 } from "./types"; diff --git a/node_modules/capnp-ts/src/index.js b/node_modules/capnp-ts/src/index.js new file mode 100644 index 0000000000000000000000000000000000000000..6cedf6063aa9cb4a6f5e2e0ca716b8a5e1346863 --- /dev/null +++ b/node_modules/capnp-ts/src/index.js @@ -0,0 +1,53 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Uint64 = exports.Int64 = exports.getUint8Mask = exports.getUint64Mask = exports.getUint32Mask = exports.getUint16Mask = exports.getInt8Mask = exports.getInt64Mask = exports.getInt32Mask = exports.getInt16Mask = exports.getFloat64Mask = exports.getFloat32Mask = exports.getBitMask = exports.Void = exports.VoidList = exports.Uint8List = exports.Uint64List = exports.Uint32List = exports.Uint16List = exports.TextList = exports.Text = exports.Struct = exports.Pointer = exports.PointerType = exports.PointerList = exports.Orphan = exports.List = exports.InterfaceList = exports.Interface = exports.Int8List = exports.Int64List = exports.Int32List = exports.Int16List = exports.Float64List = exports.Float32List = exports.DataList = exports.Data = exports.CompositeList = exports.BoolList = exports.AnyPointerList = exports.readRawPointer = exports.ObjectSize = exports.Message = exports.ListElementSize = void 0; +var serialization_1 = require("./serialization"); +Object.defineProperty(exports, "ListElementSize", { enumerable: true, get: function () { return serialization_1.ListElementSize; } }); +Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return serialization_1.Message; } }); +Object.defineProperty(exports, "ObjectSize", { enumerable: true, get: function () { return serialization_1.ObjectSize; } }); +Object.defineProperty(exports, "readRawPointer", { enumerable: true, get: function () { return serialization_1.readRawPointer; } }); +Object.defineProperty(exports, "AnyPointerList", { enumerable: true, get: function () { return serialization_1.AnyPointerList; } }); +Object.defineProperty(exports, "BoolList", { enumerable: true, get: function () { return serialization_1.BoolList; } }); +Object.defineProperty(exports, "CompositeList", { enumerable: true, get: function () { return serialization_1.CompositeList; } }); +Object.defineProperty(exports, "Data", { enumerable: true, get: function () { return serialization_1.Data; } }); +Object.defineProperty(exports, "DataList", { enumerable: true, get: function () { return serialization_1.DataList; } }); +Object.defineProperty(exports, "Float32List", { enumerable: true, get: function () { return serialization_1.Float32List; } }); +Object.defineProperty(exports, "Float64List", { enumerable: true, get: function () { return serialization_1.Float64List; } }); +Object.defineProperty(exports, "Int16List", { enumerable: true, get: function () { return serialization_1.Int16List; } }); +Object.defineProperty(exports, "Int32List", { enumerable: true, get: function () { return serialization_1.Int32List; } }); +Object.defineProperty(exports, "Int64List", { enumerable: true, get: function () { return serialization_1.Int64List; } }); +Object.defineProperty(exports, "Int8List", { enumerable: true, get: function () { return serialization_1.Int8List; } }); +Object.defineProperty(exports, "Interface", { enumerable: true, get: function () { return serialization_1.Interface; } }); +Object.defineProperty(exports, "InterfaceList", { enumerable: true, get: function () { return serialization_1.InterfaceList; } }); +Object.defineProperty(exports, "List", { enumerable: true, get: function () { return serialization_1.List; } }); +Object.defineProperty(exports, "Orphan", { enumerable: true, get: function () { return serialization_1.Orphan; } }); +Object.defineProperty(exports, "PointerList", { enumerable: true, get: function () { return serialization_1.PointerList; } }); +Object.defineProperty(exports, "PointerType", { enumerable: true, get: function () { return serialization_1.PointerType; } }); +Object.defineProperty(exports, "Pointer", { enumerable: true, get: function () { return serialization_1.Pointer; } }); +Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return serialization_1.Struct; } }); +Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return serialization_1.Text; } }); +Object.defineProperty(exports, "TextList", { enumerable: true, get: function () { return serialization_1.TextList; } }); +Object.defineProperty(exports, "Uint16List", { enumerable: true, get: function () { return serialization_1.Uint16List; } }); +Object.defineProperty(exports, "Uint32List", { enumerable: true, get: function () { return serialization_1.Uint32List; } }); +Object.defineProperty(exports, "Uint64List", { enumerable: true, get: function () { return serialization_1.Uint64List; } }); +Object.defineProperty(exports, "Uint8List", { enumerable: true, get: function () { return serialization_1.Uint8List; } }); +Object.defineProperty(exports, "VoidList", { enumerable: true, get: function () { return serialization_1.VoidList; } }); +Object.defineProperty(exports, "Void", { enumerable: true, get: function () { return serialization_1.Void; } }); +Object.defineProperty(exports, "getBitMask", { enumerable: true, get: function () { return serialization_1.getBitMask; } }); +Object.defineProperty(exports, "getFloat32Mask", { enumerable: true, get: function () { return serialization_1.getFloat32Mask; } }); +Object.defineProperty(exports, "getFloat64Mask", { enumerable: true, get: function () { return serialization_1.getFloat64Mask; } }); +Object.defineProperty(exports, "getInt16Mask", { enumerable: true, get: function () { return serialization_1.getInt16Mask; } }); +Object.defineProperty(exports, "getInt32Mask", { enumerable: true, get: function () { return serialization_1.getInt32Mask; } }); +Object.defineProperty(exports, "getInt64Mask", { enumerable: true, get: function () { return serialization_1.getInt64Mask; } }); +Object.defineProperty(exports, "getInt8Mask", { enumerable: true, get: function () { return serialization_1.getInt8Mask; } }); +Object.defineProperty(exports, "getUint16Mask", { enumerable: true, get: function () { return serialization_1.getUint16Mask; } }); +Object.defineProperty(exports, "getUint32Mask", { enumerable: true, get: function () { return serialization_1.getUint32Mask; } }); +Object.defineProperty(exports, "getUint64Mask", { enumerable: true, get: function () { return serialization_1.getUint64Mask; } }); +Object.defineProperty(exports, "getUint8Mask", { enumerable: true, get: function () { return serialization_1.getUint8Mask; } }); +var types_1 = require("./types"); +Object.defineProperty(exports, "Int64", { enumerable: true, get: function () { return types_1.Int64; } }); +Object.defineProperty(exports, "Uint64", { enumerable: true, get: function () { return types_1.Uint64; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/index.js.map b/node_modules/capnp-ts/src/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c24915bb6f700c94e574027eda3e83b7144fa38f --- /dev/null +++ b/node_modules/capnp-ts/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDA6CyB;AA5CvB,gHAAA,eAAe,OAAA;AACf,wGAAA,OAAO,OAAA;AACP,2GAAA,UAAU,OAAA;AACV,+GAAA,cAAc,OAAA;AACd,+GAAA,cAAc,OAAA;AACd,yGAAA,QAAQ,OAAA;AACR,8GAAA,aAAa,OAAA;AACb,qGAAA,IAAI,OAAA;AACJ,yGAAA,QAAQ,OAAA;AACR,4GAAA,WAAW,OAAA;AACX,4GAAA,WAAW,OAAA;AACX,0GAAA,SAAS,OAAA;AACT,0GAAA,SAAS,OAAA;AACT,0GAAA,SAAS,OAAA;AACT,yGAAA,QAAQ,OAAA;AACR,0GAAA,SAAS,OAAA;AACT,8GAAA,aAAa,OAAA;AACb,qGAAA,IAAI,OAAA;AAEJ,uGAAA,MAAM,OAAA;AACN,4GAAA,WAAW,OAAA;AACX,4GAAA,WAAW,OAAA;AACX,wGAAA,OAAO,OAAA;AACP,uGAAA,MAAM,OAAA;AAEN,qGAAA,IAAI,OAAA;AACJ,yGAAA,QAAQ,OAAA;AACR,2GAAA,UAAU,OAAA;AACV,2GAAA,UAAU,OAAA;AACV,2GAAA,UAAU,OAAA;AACV,0GAAA,SAAS,OAAA;AACT,yGAAA,QAAQ,OAAA;AACR,qGAAA,IAAI,OAAA;AACJ,2GAAA,UAAU,OAAA;AACV,+GAAA,cAAc,OAAA;AACd,+GAAA,cAAc,OAAA;AACd,6GAAA,YAAY,OAAA;AACZ,6GAAA,YAAY,OAAA;AACZ,6GAAA,YAAY,OAAA;AACZ,4GAAA,WAAW,OAAA;AACX,8GAAA,aAAa,OAAA;AACb,8GAAA,aAAa,OAAA;AACb,8GAAA,aAAa,OAAA;AACb,6GAAA,YAAY,OAAA;AAGd,iCAAwC;AAA/B,8FAAA,KAAK,OAAA;AAAE,+FAAA,MAAM,OAAA"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/index.ts b/node_modules/capnp-ts/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..714d3eed8218d3866280a82daa577f04ab215940 --- /dev/null +++ b/node_modules/capnp-ts/src/index.ts @@ -0,0 +1,52 @@ +/** + * @author jdiaz5513 + */ + +export { + ListElementSize, + Message, + ObjectSize, + readRawPointer, + AnyPointerList, + BoolList, + CompositeList, + Data, + DataList, + Float32List, + Float64List, + Int16List, + Int32List, + Int64List, + Int8List, + Interface, + InterfaceList, + List, + ListCtor, + Orphan, + PointerList, + PointerType, + Pointer, + Struct, + StructCtor, + Text, + TextList, + Uint16List, + Uint32List, + Uint64List, + Uint8List, + VoidList, + Void, + getBitMask, + getFloat32Mask, + getFloat64Mask, + getInt16Mask, + getInt32Mask, + getInt64Mask, + getInt8Mask, + getUint16Mask, + getUint32Mask, + getUint64Mask, + getUint8Mask, +} from "./serialization"; + +export { Int64, Uint64 } from "./types"; diff --git a/node_modules/capnp-ts/src/serialization/arena/any-arena.d.ts b/node_modules/capnp-ts/src/serialization/arena/any-arena.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc7e62a807fa6c69a3140d121c349c2c52183c7b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/any-arena.d.ts @@ -0,0 +1,3 @@ +import { MultiSegmentArena } from "./multi-segment-arena"; +import { SingleSegmentArena } from "./single-segment-arena"; +export declare type AnyArena = MultiSegmentArena | SingleSegmentArena; diff --git a/node_modules/capnp-ts/src/serialization/arena/any-arena.js b/node_modules/capnp-ts/src/serialization/arena/any-arena.js new file mode 100644 index 0000000000000000000000000000000000000000..ce181cb2556b51e6791f3fe94e3cde30b6ee2c2c --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/any-arena.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=any-arena.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/any-arena.js.map b/node_modules/capnp-ts/src/serialization/arena/any-arena.js.map new file mode 100644 index 0000000000000000000000000000000000000000..151e5db5666560cf1d1ea27863a5adb6a2858027 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/any-arena.js.map @@ -0,0 +1 @@ +{"version":3,"file":"any-arena.js","sourceRoot":"","sources":["any-arena.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/any-arena.ts b/node_modules/capnp-ts/src/serialization/arena/any-arena.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f969220d20961b7dfec28fb5fb5e9838c241c50 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/any-arena.ts @@ -0,0 +1,4 @@ +import { MultiSegmentArena } from "./multi-segment-arena"; +import { SingleSegmentArena } from "./single-segment-arena"; + +export type AnyArena = MultiSegmentArena | SingleSegmentArena; diff --git a/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.d.ts b/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3099d3dcb387edb6f3d260783a0e72a17317384b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.d.ts @@ -0,0 +1,18 @@ +/** + * @author jdiaz5513 + */ +export declare class ArenaAllocationResult { + /** + * The newly allocated buffer. This buffer might be a copy of an existing segment's buffer with free space appended. + * + * @type {ArrayBuffer} + */ + readonly buffer: ArrayBuffer; + /** + * The id of the newly-allocated segment. + * + * @type {number} + */ + readonly id: number; + constructor(id: number, buffer: ArrayBuffer); +} diff --git a/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.js b/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.js new file mode 100644 index 0000000000000000000000000000000000000000..6984a193569f5ecb2f1956188d9364e88dc058cb --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.js @@ -0,0 +1,19 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ArenaAllocationResult = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const trace = debug_1.default("capnp:serialization:arena:arena-allocation-result"); +trace("load"); +class ArenaAllocationResult { + constructor(id, buffer) { + this.id = id; + this.buffer = buffer; + trace("new", this); + } +} +exports.ArenaAllocationResult = ArenaAllocationResult; +//# sourceMappingURL=arena-allocation-result.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.js.map b/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.js.map new file mode 100644 index 0000000000000000000000000000000000000000..062fcbbc3c1998b1cb269302ee43c73e745ef393 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.js.map @@ -0,0 +1 @@ +{"version":3,"file":"arena-allocation-result.js","sourceRoot":"","sources":["arena-allocation-result.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,MAAM,KAAK,GAAG,eAAS,CAAC,mDAAmD,CAAC,CAAC;AAC7E,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,qBAAqB;IAiBhC,YAAY,EAAU,EAAE,MAAmB;QACzC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACrB,CAAC;CACF;AAvBD,sDAuBC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.ts b/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2c746ccd98a7277725bd7d3c080953c3d42ac1c --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena-allocation-result.ts @@ -0,0 +1,33 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +const trace = initTrace("capnp:serialization:arena:arena-allocation-result"); +trace("load"); + +export class ArenaAllocationResult { + /** + * The newly allocated buffer. This buffer might be a copy of an existing segment's buffer with free space appended. + * + * @type {ArrayBuffer} + */ + + readonly buffer: ArrayBuffer; + + /** + * The id of the newly-allocated segment. + * + * @type {number} + */ + + readonly id: number; + + constructor(id: number, buffer: ArrayBuffer) { + this.id = id; + this.buffer = buffer; + + trace("new", this); + } +} diff --git a/node_modules/capnp-ts/src/serialization/arena/arena-kind.d.ts b/node_modules/capnp-ts/src/serialization/arena/arena-kind.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6437de16eba667838cc91ef39824fd9ff5e63221 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena-kind.d.ts @@ -0,0 +1,4 @@ +export declare enum ArenaKind { + SINGLE_SEGMENT = 0, + MULTI_SEGMENT = 1 +} diff --git a/node_modules/capnp-ts/src/serialization/arena/arena-kind.js b/node_modules/capnp-ts/src/serialization/arena/arena-kind.js new file mode 100644 index 0000000000000000000000000000000000000000..a01cb84f9d4898beacb173184fee601c62bebba5 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena-kind.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ArenaKind = void 0; +var ArenaKind; +(function (ArenaKind) { + ArenaKind[ArenaKind["SINGLE_SEGMENT"] = 0] = "SINGLE_SEGMENT"; + ArenaKind[ArenaKind["MULTI_SEGMENT"] = 1] = "MULTI_SEGMENT"; +})(ArenaKind = exports.ArenaKind || (exports.ArenaKind = {})); +//# sourceMappingURL=arena-kind.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/arena-kind.js.map b/node_modules/capnp-ts/src/serialization/arena/arena-kind.js.map new file mode 100644 index 0000000000000000000000000000000000000000..aec713921c925f3f2025d1169026b58d384d17a1 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena-kind.js.map @@ -0,0 +1 @@ +{"version":3,"file":"arena-kind.js","sourceRoot":"","sources":["arena-kind.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,6DAAc,CAAA;IACd,2DAAa,CAAA;AACf,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/arena-kind.ts b/node_modules/capnp-ts/src/serialization/arena/arena-kind.ts new file mode 100644 index 0000000000000000000000000000000000000000..66357be9581df18998ab4f5940a649ef262fd0cc --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena-kind.ts @@ -0,0 +1,4 @@ +export enum ArenaKind { + SINGLE_SEGMENT, + MULTI_SEGMENT +} diff --git a/node_modules/capnp-ts/src/serialization/arena/arena.d.ts b/node_modules/capnp-ts/src/serialization/arena/arena.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e14ec8120921940cb3d282e6fee35740e72f9d80 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena.d.ts @@ -0,0 +1,14 @@ +/** + * @author jdiaz5513 + */ +import { Segment } from "../segment"; +import { AnyArena } from "./any-arena"; +import { ArenaAllocationResult } from "./arena-allocation-result"; +export declare abstract class Arena { + static readonly allocate: typeof allocate; + static readonly getBuffer: typeof getBuffer; + static readonly getNumSegments: typeof getNumSegments; +} +export declare function allocate(minSize: number, segments: Segment[], a: AnyArena): ArenaAllocationResult; +export declare function getBuffer(id: number, a: AnyArena): ArrayBuffer; +export declare function getNumSegments(a: AnyArena): number; diff --git a/node_modules/capnp-ts/src/serialization/arena/arena.js b/node_modules/capnp-ts/src/serialization/arena/arena.js new file mode 100644 index 0000000000000000000000000000000000000000..bf2642e4a80f3181c33ba408a332bd1a8f2ea5c0 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena.js @@ -0,0 +1,54 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getNumSegments = exports.getBuffer = exports.allocate = exports.Arena = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const errors_1 = require("../../errors"); +const arena_kind_1 = require("./arena-kind"); +const multi_segment_arena_1 = require("./multi-segment-arena"); +const single_segment_arena_1 = require("./single-segment-arena"); +const trace = debug_1.default("capnp:arena"); +trace("load"); +class Arena { +} +exports.Arena = Arena; +Arena.allocate = allocate; +Arena.getBuffer = getBuffer; +Arena.getNumSegments = getNumSegments; +function allocate(minSize, segments, a) { + switch (a.kind) { + case arena_kind_1.ArenaKind.MULTI_SEGMENT: + return multi_segment_arena_1.MultiSegmentArena.allocate(minSize, a); + case arena_kind_1.ArenaKind.SINGLE_SEGMENT: + return single_segment_arena_1.SingleSegmentArena.allocate(minSize, segments, a); + default: + return errors_1.assertNever(a); + } +} +exports.allocate = allocate; +function getBuffer(id, a) { + switch (a.kind) { + case arena_kind_1.ArenaKind.MULTI_SEGMENT: + return multi_segment_arena_1.MultiSegmentArena.getBuffer(id, a); + case arena_kind_1.ArenaKind.SINGLE_SEGMENT: + return single_segment_arena_1.SingleSegmentArena.getBuffer(id, a); + default: + return errors_1.assertNever(a); + } +} +exports.getBuffer = getBuffer; +function getNumSegments(a) { + switch (a.kind) { + case arena_kind_1.ArenaKind.MULTI_SEGMENT: + return multi_segment_arena_1.MultiSegmentArena.getNumSegments(a); + case arena_kind_1.ArenaKind.SINGLE_SEGMENT: + return single_segment_arena_1.SingleSegmentArena.getNumSegments(); + default: + return errors_1.assertNever(a); + } +} +exports.getNumSegments = getNumSegments; +//# sourceMappingURL=arena.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/arena.js.map b/node_modules/capnp-ts/src/serialization/arena/arena.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2089f014664f9a9b5a3537d08bdc1c9bb12a2641 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena.js.map @@ -0,0 +1 @@ +{"version":3,"file":"arena.js","sourceRoot":"","sources":["arena.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAC9B,yCAA2C;AAI3C,6CAAyC;AACzC,+DAA0D;AAC1D,iEAA4D;AAE5D,MAAM,KAAK,GAAG,eAAS,CAAC,aAAa,CAAC,CAAC;AACvC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAsB,KAAK;;AAA3B,sBAIC;AAHiB,cAAQ,GAAG,QAAQ,CAAC;AACpB,eAAS,GAAG,SAAS,CAAC;AACtB,oBAAc,GAAG,cAAc,CAAC;AAGlD,SAAgB,QAAQ,CAAC,OAAe,EAAE,QAAmB,EAAE,CAAW;IACxE,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,sBAAS,CAAC,aAAa;YAC1B,OAAO,uCAAiB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAEhD,KAAK,sBAAS,CAAC,cAAc;YAC3B,OAAO,yCAAkB,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAE3D;YACE,OAAO,oBAAW,CAAC,CAAC,CAAC,CAAC;KACzB;AACH,CAAC;AAXD,4BAWC;AAED,SAAgB,SAAS,CAAC,EAAU,EAAE,CAAW;IAC/C,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,sBAAS,CAAC,aAAa;YAC1B,OAAO,uCAAiB,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAE5C,KAAK,sBAAS,CAAC,cAAc;YAC3B,OAAO,yCAAkB,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAE7C;YACE,OAAO,oBAAW,CAAC,CAAC,CAAC,CAAC;KACzB;AACH,CAAC;AAXD,8BAWC;AAED,SAAgB,cAAc,CAAC,CAAW;IACxC,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,sBAAS,CAAC,aAAa;YAC1B,OAAO,uCAAiB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QAE7C,KAAK,sBAAS,CAAC,cAAc;YAC3B,OAAO,yCAAkB,CAAC,cAAc,EAAE,CAAC;QAE7C;YACE,OAAO,oBAAW,CAAC,CAAC,CAAC,CAAC;KACzB;AACH,CAAC;AAXD,wCAWC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/arena.ts b/node_modules/capnp-ts/src/serialization/arena/arena.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c888593c5d87fa1969c5737ddc225af6687da40 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/arena.ts @@ -0,0 +1,60 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; +import { assertNever } from "../../errors"; +import { Segment } from "../segment"; +import { AnyArena } from "./any-arena"; +import { ArenaAllocationResult } from "./arena-allocation-result"; +import { ArenaKind } from "./arena-kind"; +import { MultiSegmentArena } from "./multi-segment-arena"; +import { SingleSegmentArena } from "./single-segment-arena"; + +const trace = initTrace("capnp:arena"); +trace("load"); + +export abstract class Arena { + static readonly allocate = allocate; + static readonly getBuffer = getBuffer; + static readonly getNumSegments = getNumSegments; +} + +export function allocate(minSize: number, segments: Segment[], a: AnyArena): ArenaAllocationResult { + switch (a.kind) { + case ArenaKind.MULTI_SEGMENT: + return MultiSegmentArena.allocate(minSize, a); + + case ArenaKind.SINGLE_SEGMENT: + return SingleSegmentArena.allocate(minSize, segments, a); + + default: + return assertNever(a); + } +} + +export function getBuffer(id: number, a: AnyArena): ArrayBuffer { + switch (a.kind) { + case ArenaKind.MULTI_SEGMENT: + return MultiSegmentArena.getBuffer(id, a); + + case ArenaKind.SINGLE_SEGMENT: + return SingleSegmentArena.getBuffer(id, a); + + default: + return assertNever(a); + } +} + +export function getNumSegments(a: AnyArena): number { + switch (a.kind) { + case ArenaKind.MULTI_SEGMENT: + return MultiSegmentArena.getNumSegments(a); + + case ArenaKind.SINGLE_SEGMENT: + return SingleSegmentArena.getNumSegments(); + + default: + return assertNever(a); + } +} diff --git a/node_modules/capnp-ts/src/serialization/arena/index.d.ts b/node_modules/capnp-ts/src/serialization/arena/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..86f6210387fc832609209f992a1db951cc488fcc --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/index.d.ts @@ -0,0 +1,8 @@ +/** + * @author jdiaz5513 + */ +export { AnyArena } from "./any-arena"; +export { Arena } from "./arena"; +export { ArenaKind } from "./arena-kind"; +export { MultiSegmentArena } from "./multi-segment-arena"; +export { SingleSegmentArena } from "./single-segment-arena"; diff --git a/node_modules/capnp-ts/src/serialization/arena/index.js b/node_modules/capnp-ts/src/serialization/arena/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e2ee4e55866976ac26cf0f3bc437074cd1b496ca --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/index.js @@ -0,0 +1,15 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SingleSegmentArena = exports.MultiSegmentArena = exports.ArenaKind = exports.Arena = void 0; +var arena_1 = require("./arena"); +Object.defineProperty(exports, "Arena", { enumerable: true, get: function () { return arena_1.Arena; } }); +var arena_kind_1 = require("./arena-kind"); +Object.defineProperty(exports, "ArenaKind", { enumerable: true, get: function () { return arena_kind_1.ArenaKind; } }); +var multi_segment_arena_1 = require("./multi-segment-arena"); +Object.defineProperty(exports, "MultiSegmentArena", { enumerable: true, get: function () { return multi_segment_arena_1.MultiSegmentArena; } }); +var single_segment_arena_1 = require("./single-segment-arena"); +Object.defineProperty(exports, "SingleSegmentArena", { enumerable: true, get: function () { return single_segment_arena_1.SingleSegmentArena; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/index.js.map b/node_modules/capnp-ts/src/serialization/arena/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..aef7b57fecc530b3886211a21c761e02b1144e29 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAGH,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/index.ts b/node_modules/capnp-ts/src/serialization/arena/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..5128c6ed5bb0ba309e4e0462a540b0dde957010e --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/index.ts @@ -0,0 +1,9 @@ +/** + * @author jdiaz5513 + */ + +export { AnyArena } from "./any-arena"; +export { Arena } from "./arena"; +export { ArenaKind } from "./arena-kind"; +export { MultiSegmentArena } from "./multi-segment-arena"; +export { SingleSegmentArena } from "./single-segment-arena"; diff --git a/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.d.ts b/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..84b5412e529525bfbaddba64ded9abfe675a7daa --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.d.ts @@ -0,0 +1,17 @@ +/** + * @author jdiaz5513 + */ +import { ArenaAllocationResult } from "./arena-allocation-result"; +import { ArenaKind } from "./arena-kind"; +export declare class MultiSegmentArena { + static readonly allocate: typeof allocate; + static readonly getBuffer: typeof getBuffer; + static readonly getNumSegments: typeof getNumSegments; + readonly buffers: ArrayBuffer[]; + readonly kind = ArenaKind.MULTI_SEGMENT; + constructor(buffers?: ArrayBuffer[]); + toString(): string; +} +export declare function allocate(minSize: number, m: MultiSegmentArena): ArenaAllocationResult; +export declare function getBuffer(id: number, m: MultiSegmentArena): ArrayBuffer; +export declare function getNumSegments(m: MultiSegmentArena): number; diff --git a/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.js b/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.js new file mode 100644 index 0000000000000000000000000000000000000000..8e5d0646ccd54bb06d24fbc76420582564e674c7 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.js @@ -0,0 +1,47 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getNumSegments = exports.getBuffer = exports.allocate = exports.MultiSegmentArena = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("../../constants"); +const errors_1 = require("../../errors"); +const util_1 = require("../../util"); +const arena_allocation_result_1 = require("./arena-allocation-result"); +const arena_kind_1 = require("./arena-kind"); +const trace = debug_1.default("capnp:arena:multi"); +trace("load"); +class MultiSegmentArena { + constructor(buffers = []) { + this.kind = arena_kind_1.ArenaKind.MULTI_SEGMENT; + this.buffers = buffers; + trace("new %s", this); + } + toString() { + return util_1.format("MultiSegmentArena_segments:%d", getNumSegments(this)); + } +} +exports.MultiSegmentArena = MultiSegmentArena; +MultiSegmentArena.allocate = allocate; +MultiSegmentArena.getBuffer = getBuffer; +MultiSegmentArena.getNumSegments = getNumSegments; +function allocate(minSize, m) { + const b = new ArrayBuffer(util_1.padToWord(Math.max(minSize, constants_1.DEFAULT_BUFFER_SIZE))); + m.buffers.push(b); + return new arena_allocation_result_1.ArenaAllocationResult(m.buffers.length - 1, b); +} +exports.allocate = allocate; +function getBuffer(id, m) { + if (id < 0 || id >= m.buffers.length) { + throw new Error(util_1.format(errors_1.SEG_ID_OUT_OF_BOUNDS, id)); + } + return m.buffers[id]; +} +exports.getBuffer = getBuffer; +function getNumSegments(m) { + return m.buffers.length; +} +exports.getNumSegments = getNumSegments; +//# sourceMappingURL=multi-segment-arena.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.js.map b/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b86b981c6f2f13bc2798c01c3fdba64dae7d7623 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.js.map @@ -0,0 +1 @@ +{"version":3,"file":"multi-segment-arena.js","sourceRoot":"","sources":["multi-segment-arena.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAC9B,+CAAsD;AACtD,yCAAoD;AACpD,qCAA+C;AAC/C,uEAAkE;AAClE,6CAAyC;AAEzC,MAAM,KAAK,GAAG,eAAS,CAAC,mBAAmB,CAAC,CAAC;AAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,iBAAiB;IAQ5B,YAAY,UAAyB,EAAE;QAF9B,SAAI,GAAG,sBAAS,CAAC,aAAa,CAAC;QAGtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,QAAQ;QACN,OAAO,aAAM,CAAC,+BAA+B,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IACvE,CAAC;;AAhBH,8CAiBC;AAhBiB,0BAAQ,GAAG,QAAQ,CAAC;AACpB,2BAAS,GAAG,SAAS,CAAC;AACtB,gCAAc,GAAG,cAAc,CAAC;AAgBlD,SAAgB,QAAQ,CAAC,OAAe,EAAE,CAAoB;IAC5D,MAAM,CAAC,GAAG,IAAI,WAAW,CAAC,gBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,+BAAmB,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAElB,OAAO,IAAI,+CAAqB,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5D,CAAC;AALD,4BAKC;AAED,SAAgB,SAAS,CAAC,EAAU,EAAE,CAAoB;IACxD,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE;QACpC,MAAM,IAAI,KAAK,CAAC,aAAM,CAAC,6BAAoB,EAAE,EAAE,CAAC,CAAC,CAAC;KACnD;IAED,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACvB,CAAC;AAND,8BAMC;AAED,SAAgB,cAAc,CAAC,CAAoB;IACjD,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;AAC1B,CAAC;AAFD,wCAEC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.ts b/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a53e1b710eef193af667a3abb0e4c590453e839 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/multi-segment-arena.ts @@ -0,0 +1,51 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; +import { DEFAULT_BUFFER_SIZE } from "../../constants"; +import { SEG_ID_OUT_OF_BOUNDS } from "../../errors"; +import { padToWord, format } from "../../util"; +import { ArenaAllocationResult } from "./arena-allocation-result"; +import { ArenaKind } from "./arena-kind"; + +const trace = initTrace("capnp:arena:multi"); +trace("load"); + +export class MultiSegmentArena { + static readonly allocate = allocate; + static readonly getBuffer = getBuffer; + static readonly getNumSegments = getNumSegments; + + readonly buffers: ArrayBuffer[]; + readonly kind = ArenaKind.MULTI_SEGMENT; + + constructor(buffers: ArrayBuffer[] = []) { + this.buffers = buffers; + + trace("new %s", this); + } + + toString(): string { + return format("MultiSegmentArena_segments:%d", getNumSegments(this)); + } +} + +export function allocate(minSize: number, m: MultiSegmentArena): ArenaAllocationResult { + const b = new ArrayBuffer(padToWord(Math.max(minSize, DEFAULT_BUFFER_SIZE))); + m.buffers.push(b); + + return new ArenaAllocationResult(m.buffers.length - 1, b); +} + +export function getBuffer(id: number, m: MultiSegmentArena): ArrayBuffer { + if (id < 0 || id >= m.buffers.length) { + throw new Error(format(SEG_ID_OUT_OF_BOUNDS, id)); + } + + return m.buffers[id]; +} + +export function getNumSegments(m: MultiSegmentArena): number { + return m.buffers.length; +} diff --git a/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.d.ts b/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..07b2950142a2fbdca6bdfa3686b3d26ff69e8db8 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.d.ts @@ -0,0 +1,18 @@ +/** + * @author jdiaz5513 + */ +import { Segment } from "../segment"; +import { ArenaAllocationResult } from "./arena-allocation-result"; +import { ArenaKind } from "./arena-kind"; +export declare class SingleSegmentArena { + static readonly allocate: typeof allocate; + static readonly getBuffer: typeof getBuffer; + static readonly getNumSegments: typeof getNumSegments; + buffer: ArrayBuffer; + readonly kind = ArenaKind.SINGLE_SEGMENT; + constructor(buffer?: ArrayBuffer); + toString(): string; +} +export declare function allocate(minSize: number, segments: Segment[], s: SingleSegmentArena): ArenaAllocationResult; +export declare function getBuffer(id: number, s: SingleSegmentArena): ArrayBuffer; +export declare function getNumSegments(): number; diff --git a/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.js b/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.js new file mode 100644 index 0000000000000000000000000000000000000000..3edc8b54e08d5ec01715648580c1b57db4b4f64e --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.js @@ -0,0 +1,59 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getNumSegments = exports.getBuffer = exports.allocate = exports.SingleSegmentArena = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("../../constants"); +const errors_1 = require("../../errors"); +const util_1 = require("../../util"); +const arena_allocation_result_1 = require("./arena-allocation-result"); +const arena_kind_1 = require("./arena-kind"); +const trace = debug_1.default("capnp:arena:single"); +trace("load"); +class SingleSegmentArena { + constructor(buffer = new ArrayBuffer(constants_1.DEFAULT_BUFFER_SIZE)) { + this.kind = arena_kind_1.ArenaKind.SINGLE_SEGMENT; + if ((buffer.byteLength & 7) !== 0) { + throw new Error(util_1.format(errors_1.SEG_NOT_WORD_ALIGNED, buffer.byteLength)); + } + this.buffer = buffer; + trace("new %s", this); + } + toString() { + return util_1.format("SingleSegmentArena_len:%x", this.buffer.byteLength); + } +} +exports.SingleSegmentArena = SingleSegmentArena; +SingleSegmentArena.allocate = allocate; +SingleSegmentArena.getBuffer = getBuffer; +SingleSegmentArena.getNumSegments = getNumSegments; +function allocate(minSize, segments, s) { + trace("Allocating %x bytes for segment 0 in %s.", minSize, s); + const srcBuffer = segments.length > 0 ? segments[0].buffer : s.buffer; + if (minSize < constants_1.MIN_SINGLE_SEGMENT_GROWTH) { + minSize = constants_1.MIN_SINGLE_SEGMENT_GROWTH; + } + else { + minSize = util_1.padToWord(minSize); + } + s.buffer = new ArrayBuffer(srcBuffer.byteLength + minSize); + // PERF: Assume that the source and destination buffers are word-aligned and use Float64Array to copy them one word + // at a time. + new Float64Array(s.buffer).set(new Float64Array(srcBuffer)); + return new arena_allocation_result_1.ArenaAllocationResult(0, s.buffer); +} +exports.allocate = allocate; +function getBuffer(id, s) { + if (id !== 0) + throw new Error(util_1.format(errors_1.SEG_GET_NON_ZERO_SINGLE, id)); + return s.buffer; +} +exports.getBuffer = getBuffer; +function getNumSegments() { + return 1; +} +exports.getNumSegments = getNumSegments; +//# sourceMappingURL=single-segment-arena.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.js.map b/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d150e0b785589b13bfaa8d7b49d1a1ca102f6732 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.js.map @@ -0,0 +1 @@ +{"version":3,"file":"single-segment-arena.js","sourceRoot":"","sources":["single-segment-arena.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAC9B,+CAAiF;AACjF,yCAA6E;AAC7E,qCAA+C;AAE/C,uEAAkE;AAClE,6CAAyC;AAEzC,MAAM,KAAK,GAAG,eAAS,CAAC,oBAAoB,CAAC,CAAC;AAC9C,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,kBAAkB;IAQ7B,YAAY,MAAM,GAAG,IAAI,WAAW,CAAC,+BAAmB,CAAC;QAFhD,SAAI,GAAG,sBAAS,CAAC,cAAc,CAAC;QAGvC,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,aAAM,CAAC,6BAAoB,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,C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nE,OAAO,CAAC,CAAC,MAAM,CAAC;AAClB,CAAC;AAJD,8BAIC;AAED,SAAgB,cAAc;IAC5B,OAAO,CAAC,CAAC;AACX,CAAC;AAFD,wCAEC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.ts b/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.ts new file mode 100644 index 0000000000000000000000000000000000000000..250568c6896cc826a956c48d76f693af3bd3e723 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/arena/single-segment-arena.ts @@ -0,0 +1,67 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; +import { DEFAULT_BUFFER_SIZE, MIN_SINGLE_SEGMENT_GROWTH } from "../../constants"; +import { SEG_GET_NON_ZERO_SINGLE, SEG_NOT_WORD_ALIGNED } from "../../errors"; +import { format, padToWord } from "../../util"; +import { Segment } from "../segment"; +import { ArenaAllocationResult } from "./arena-allocation-result"; +import { ArenaKind } from "./arena-kind"; + +const trace = initTrace("capnp:arena:single"); +trace("load"); + +export class SingleSegmentArena { + static readonly allocate = allocate; + static readonly getBuffer = getBuffer; + static readonly getNumSegments = getNumSegments; + + buffer: ArrayBuffer; + readonly kind = ArenaKind.SINGLE_SEGMENT; + + constructor(buffer = new ArrayBuffer(DEFAULT_BUFFER_SIZE)) { + if ((buffer.byteLength & 7) !== 0) { + throw new Error(format(SEG_NOT_WORD_ALIGNED, buffer.byteLength)); + } + + this.buffer = buffer; + + trace("new %s", this); + } + + toString(): string { + return format("SingleSegmentArena_len:%x", this.buffer.byteLength); + } +} + +export function allocate(minSize: number, segments: Segment[], s: SingleSegmentArena): ArenaAllocationResult { + trace("Allocating %x bytes for segment 0 in %s.", minSize, s); + + const srcBuffer = segments.length > 0 ? segments[0].buffer : s.buffer; + + if (minSize < MIN_SINGLE_SEGMENT_GROWTH) { + minSize = MIN_SINGLE_SEGMENT_GROWTH; + } else { + minSize = padToWord(minSize); + } + + s.buffer = new ArrayBuffer(srcBuffer.byteLength + minSize); + + // PERF: Assume that the source and destination buffers are word-aligned and use Float64Array to copy them one word + // at a time. + new Float64Array(s.buffer).set(new Float64Array(srcBuffer)); + + return new ArenaAllocationResult(0, s.buffer); +} + +export function getBuffer(id: number, s: SingleSegmentArena): ArrayBuffer { + if (id !== 0) throw new Error(format(SEG_GET_NON_ZERO_SINGLE, id)); + + return s.buffer; +} + +export function getNumSegments(): number { + return 1; +} diff --git a/node_modules/capnp-ts/src/serialization/index.d.ts b/node_modules/capnp-ts/src/serialization/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef08a7072d6ecf6f2a7f1aa87a6b422dfdfdd148 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/index.d.ts @@ -0,0 +1,8 @@ +/** + * @author jdiaz5513 + */ +export * from "./mask"; +export { ListElementSize } from "./list-element-size"; +export { Message, readRawPointer } from "./message"; +export { ObjectSize } from "./object-size"; +export * from "./pointers/index"; diff --git a/node_modules/capnp-ts/src/serialization/index.js b/node_modules/capnp-ts/src/serialization/index.js new file mode 100644 index 0000000000000000000000000000000000000000..16f2cea819780f768a13c03a5c0000c7b7ed2031 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/index.js @@ -0,0 +1,17 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ObjectSize = exports.readRawPointer = exports.Message = exports.ListElementSize = void 0; +const tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./mask"), exports); +var list_element_size_1 = require("./list-element-size"); +Object.defineProperty(exports, "ListElementSize", { enumerable: true, get: function () { return list_element_size_1.ListElementSize; } }); +var message_1 = require("./message"); +Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return message_1.Message; } }); +Object.defineProperty(exports, "readRawPointer", { enumerable: true, get: function () { return message_1.readRawPointer; } }); +var object_size_1 = require("./object-size"); +Object.defineProperty(exports, "ObjectSize", { enumerable: true, get: function () { return object_size_1.ObjectSize; } }); +tslib_1.__exportStar(require("./pointers/index"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/index.js.map b/node_modules/capnp-ts/src/serialization/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c68025b94681ef82f23e2427ab5e54e299e99ff4 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,iDAAuB;AACvB,yDAAsD;AAA7C,oHAAA,eAAe,OAAA;AACxB,qCAAoD;AAA3C,kGAAA,OAAO,OAAA;AAAE,yGAAA,cAAc,OAAA;AAChC,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2DAAiC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/index.ts b/node_modules/capnp-ts/src/serialization/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..805c2da486e09478c8f73fb57c1a88af147bebf7 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/index.ts @@ -0,0 +1,9 @@ +/** + * @author jdiaz5513 + */ + +export * from "./mask"; +export { ListElementSize } from "./list-element-size"; +export { Message, readRawPointer } from "./message"; +export { ObjectSize } from "./object-size"; +export * from "./pointers/index"; diff --git a/node_modules/capnp-ts/src/serialization/list-element-size.d.ts b/node_modules/capnp-ts/src/serialization/list-element-size.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..96f9a21213292a74ce29b38313a450e9b125f4a8 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/list-element-size.d.ts @@ -0,0 +1,14 @@ +/** + * @author jdiaz5513 + */ +export declare enum ListElementSize { + VOID = 0, + BIT = 1, + BYTE = 2, + BYTE_2 = 3, + BYTE_4 = 4, + BYTE_8 = 5, + POINTER = 6, + COMPOSITE = 7 +} +export declare const ListElementOffset: number[]; diff --git a/node_modules/capnp-ts/src/serialization/list-element-size.js b/node_modules/capnp-ts/src/serialization/list-element-size.js new file mode 100644 index 0000000000000000000000000000000000000000..35816c4cfa2dfb8b1165414202e9f6e8da2aec0b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/list-element-size.js @@ -0,0 +1,28 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ListElementOffset = exports.ListElementSize = void 0; +var ListElementSize; +(function (ListElementSize) { + ListElementSize[ListElementSize["VOID"] = 0] = "VOID"; + ListElementSize[ListElementSize["BIT"] = 1] = "BIT"; + ListElementSize[ListElementSize["BYTE"] = 2] = "BYTE"; + ListElementSize[ListElementSize["BYTE_2"] = 3] = "BYTE_2"; + ListElementSize[ListElementSize["BYTE_4"] = 4] = "BYTE_4"; + ListElementSize[ListElementSize["BYTE_8"] = 5] = "BYTE_8"; + ListElementSize[ListElementSize["POINTER"] = 6] = "POINTER"; + ListElementSize[ListElementSize["COMPOSITE"] = 7] = "COMPOSITE"; +})(ListElementSize = exports.ListElementSize || (exports.ListElementSize = {})); +exports.ListElementOffset = [ + 0, + 0.125, + 1, + 2, + 4, + 8, + 8, + NaN // composite +]; +//# sourceMappingURL=list-element-size.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/list-element-size.js.map b/node_modules/capnp-ts/src/serialization/list-element-size.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ca2a42e21f2c5120e87af905e0106937ba65d163 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/list-element-size.js.map @@ -0,0 +1 @@ +{"version":3,"file":"list-element-size.js","sourceRoot":"","sources":["list-element-size.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,IAAY,eASX;AATD,WAAY,eAAe;IACzB,qDAAQ,CAAA;IACR,mDAAO,CAAA;IACP,qDAAQ,CAAA;IACR,yDAAU,CAAA;IACV,yDAAU,CAAA;IACV,yDAAU,CAAA;IACV,2DAAW,CAAA;IACX,+DAAa,CAAA;AACf,CAAC,EATW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAS1B;AAEY,QAAA,iBAAiB,GAAG;IAC/B,CAAC;IACD,KAAK;IACL,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,GAAG,CAAC,YAAY;CACjB,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/list-element-size.ts b/node_modules/capnp-ts/src/serialization/list-element-size.ts new file mode 100644 index 0000000000000000000000000000000000000000..0aaac25d533404a3429d07df67575c6761d054df --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/list-element-size.ts @@ -0,0 +1,25 @@ +/** + * @author jdiaz5513 + */ + +export enum ListElementSize { + VOID = 0, + BIT = 1, + BYTE = 2, + BYTE_2 = 3, + BYTE_4 = 4, + BYTE_8 = 5, + POINTER = 6, + COMPOSITE = 7 +} + +export const ListElementOffset = [ + 0, // void + 0.125, // bit + 1, // byte + 2, // two byte + 4, // four byte + 8, // eight byte + 8, // pointer + NaN // composite +]; diff --git a/node_modules/capnp-ts/src/serialization/mask.d.ts b/node_modules/capnp-ts/src/serialization/mask.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c0c71fe0e6cab6c532c7b409c0c80002fa6df8c4 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/mask.d.ts @@ -0,0 +1,16 @@ +/** + * @author jdiaz5513 + */ +import { Int64, Uint64 } from "../types/index"; +export declare const getFloat32Mask: (x: number) => DataView; +export declare const getFloat64Mask: (x: number) => DataView; +export declare const getInt16Mask: (x: number) => DataView; +export declare const getInt32Mask: (x: number) => DataView; +export declare const getInt8Mask: (x: number) => DataView; +export declare const getUint16Mask: (x: number) => DataView; +export declare const getUint32Mask: (x: number) => DataView; +export declare const getUint8Mask: (x: number) => DataView; +export declare function getBitMask(value: boolean, bitOffset: number): DataView; +export declare function getInt64Mask(x: Int64): DataView; +export declare function getUint64Mask(x: Uint64): DataView; +export declare function getVoidMask(): void; diff --git a/node_modules/capnp-ts/src/serialization/mask.js b/node_modules/capnp-ts/src/serialization/mask.js new file mode 100644 index 0000000000000000000000000000000000000000..784d6789de91699231c7e32892a50342fc681f92 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/mask.js @@ -0,0 +1,45 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getVoidMask = exports.getUint64Mask = exports.getInt64Mask = exports.getBitMask = exports.getUint8Mask = exports.getUint32Mask = exports.getUint16Mask = exports.getInt8Mask = exports.getInt32Mask = exports.getInt16Mask = exports.getFloat64Mask = exports.getFloat32Mask = void 0; +const errors_1 = require("../errors"); +function _makePrimitiveMaskFn(byteLength, setter) { + return (x) => { + const dv = new DataView(new ArrayBuffer(byteLength)); + setter.call(dv, 0, x, true); + return dv; + }; +} +/* eslint-disable @typescript-eslint/unbound-method */ +exports.getFloat32Mask = _makePrimitiveMaskFn(4, DataView.prototype.setFloat32); +exports.getFloat64Mask = _makePrimitiveMaskFn(8, DataView.prototype.setFloat64); +exports.getInt16Mask = _makePrimitiveMaskFn(2, DataView.prototype.setInt16); +exports.getInt32Mask = _makePrimitiveMaskFn(4, DataView.prototype.setInt32); +exports.getInt8Mask = _makePrimitiveMaskFn(1, DataView.prototype.setInt8); +exports.getUint16Mask = _makePrimitiveMaskFn(2, DataView.prototype.setUint16); +exports.getUint32Mask = _makePrimitiveMaskFn(4, DataView.prototype.setUint32); +exports.getUint8Mask = _makePrimitiveMaskFn(1, DataView.prototype.setUint8); +/* eslint-enable */ +function getBitMask(value, bitOffset) { + const dv = new DataView(new ArrayBuffer(1)); + if (!value) + return dv; + dv.setUint8(0, 1 << bitOffset % 8); + return dv; +} +exports.getBitMask = getBitMask; +function getInt64Mask(x) { + return x.toDataView(); +} +exports.getInt64Mask = getInt64Mask; +function getUint64Mask(x) { + return x.toDataView(); +} +exports.getUint64Mask = getUint64Mask; +function getVoidMask() { + throw new Error(errors_1.INVARIANT_UNREACHABLE_CODE); +} +exports.getVoidMask = getVoidMask; +//# sourceMappingURL=mask.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/mask.js.map b/node_modules/capnp-ts/src/serialization/mask.js.map new file mode 100644 index 0000000000000000000000000000000000000000..104b99a240928018e55c6fa746b1d1435e8afd21 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/mask.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mask.js","sourceRoot":"","sources":["mask.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAAuD;AAKvD,SAAS,oBAAoB,CAAC,UAAkB,EAAE,MAAsB;IACtE,OAAO,CAAC,CAAS,EAAY,EAAE;QAC7B,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC;AAED,sDAAsD;AACzC,QAAA,cAAc,GAAG,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACxE,QAAA,cAAc,GAAG,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACxE,QAAA,YAAY,GAAG,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AACpE,QAAA,YAAY,GAAG,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AACpE,QAAA,WAAW,GAAG,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAClE,QAAA,aAAa,GAAG,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AACtE,QAAA,aAAa,GAAG,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AACtE,QAAA,YAAY,GAAG,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AACjF,mBAAmB;AAEnB,SAAgB,UAAU,CAAC,KAAc,EAAE,SAAiB;IAC1D,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAE5C,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAEtB,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC;AACZ,CAAC;AAPD,gCAOC;AAED,SAAgB,YAAY,CAAC,CAAQ;IACnC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC;AACxB,CAAC;AAFD,oCAEC;AAED,SAAgB,aAAa,CAAC,CAAS;IACrC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC;AACxB,CAAC;AAFD,sCAEC;AAED,SAAgB,WAAW;IACzB,MAAM,IAAI,KAAK,CAAC,mCAA0B,CAAC,CAAC;AAC9C,CAAC;AAFD,kCAEC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/mask.ts b/node_modules/capnp-ts/src/serialization/mask.ts new file mode 100644 index 0000000000000000000000000000000000000000..dcaa9e9811e97c7b5b2ce8f1917d3ad3d388dbd6 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/mask.ts @@ -0,0 +1,48 @@ +/** + * @author jdiaz5513 + */ + +import { INVARIANT_UNREACHABLE_CODE } from "../errors"; +import { Int64, Uint64 } from "../types/index"; + +type DataViewSetter = (byteOffset: number, value: number, littleEndian?: boolean) => void; + +function _makePrimitiveMaskFn(byteLength: number, setter: DataViewSetter): (x: number) => DataView { + return (x: number): DataView => { + const dv = new DataView(new ArrayBuffer(byteLength)); + setter.call(dv, 0, x, true); + return dv; + }; +} + +/* eslint-disable @typescript-eslint/unbound-method */ +export const getFloat32Mask = _makePrimitiveMaskFn(4, DataView.prototype.setFloat32); +export const getFloat64Mask = _makePrimitiveMaskFn(8, DataView.prototype.setFloat64); +export const getInt16Mask = _makePrimitiveMaskFn(2, DataView.prototype.setInt16); +export const getInt32Mask = _makePrimitiveMaskFn(4, DataView.prototype.setInt32); +export const getInt8Mask = _makePrimitiveMaskFn(1, DataView.prototype.setInt8); +export const getUint16Mask = _makePrimitiveMaskFn(2, DataView.prototype.setUint16); +export const getUint32Mask = _makePrimitiveMaskFn(4, DataView.prototype.setUint32); +export const getUint8Mask = _makePrimitiveMaskFn(1, DataView.prototype.setUint8); +/* eslint-enable */ + +export function getBitMask(value: boolean, bitOffset: number): DataView { + const dv = new DataView(new ArrayBuffer(1)); + + if (!value) return dv; + + dv.setUint8(0, 1 << bitOffset % 8); + return dv; +} + +export function getInt64Mask(x: Int64): DataView { + return x.toDataView(); +} + +export function getUint64Mask(x: Uint64): DataView { + return x.toDataView(); +} + +export function getVoidMask(): void { + throw new Error(INVARIANT_UNREACHABLE_CODE); +} diff --git a/node_modules/capnp-ts/src/serialization/message.d.ts b/node_modules/capnp-ts/src/serialization/message.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4eafff5f5cbffb7defad748c095ec607dd2eab9d --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/message.d.ts @@ -0,0 +1,158 @@ +/** + * @author jdiaz5513 + */ +import { AnyArena } from "./arena"; +import { Pointer, StructCtor, Struct } from "./pointers"; +import { Segment } from "./segment"; +export interface _Message { + readonly arena: AnyArena; + segments: Segment[]; + traversalLimit: number; +} +export declare class Message { + static readonly allocateSegment: typeof allocateSegment; + static readonly dump: typeof dump; + static readonly getRoot: typeof getRoot; + static readonly getSegment: typeof getSegment; + static readonly initRoot: typeof initRoot; + static readonly readRawPointer: typeof readRawPointer; + static readonly toArrayBuffer: typeof toArrayBuffer; + static readonly toPackedArrayBuffer: typeof toPackedArrayBuffer; + readonly _capnp: _Message; + /** + * A Cap'n Proto message. + * + * SECURITY WARNING: In nodejs do not pass a Buffer's internal array buffer into this constructor. Pass the buffer + * directly and everything will be fine. If not, your message will potentially be initialized with random memory + * contents! + * + * The constructor method creates a new Message, optionally using a provided arena for segment allocation, or a buffer + * to read from. + * + * @constructor {Message} + * + * @param {AnyArena|ArrayBufferView|ArrayBuffer} [src] The source for the message. + * A value of `undefined` will cause the message to initialize with a single segment arena only big enough for the + * root pointer; it will expand as you go. This is a reasonable choice for most messages. + * + * Passing an arena will cause the message to use that arena for its segment allocation. Contents will be accepted + * as-is. + * + * Passing an array buffer view (like `DataView`, `Uint8Array` or `Buffer`) will create a **copy** of the source + * buffer; beware of the potential performance cost! + * + * @param {boolean} [packed] Whether or not the message is packed. If `true` (the default), the message will be + * unpacked. + * + * @param {boolean} [singleSegment] If true, `src` will be treated as a message consisting of a single segment without + * a framing header. + * + */ + constructor(src?: AnyArena | ArrayBufferView | ArrayBuffer, packed?: boolean, singleSegment?: boolean); + allocateSegment(byteLength: number): Segment; + /** + * Create a pretty-printed string dump of this message; incredibly useful for debugging. + * + * WARNING: Do not call this method on large messages! + * + * @returns {string} A big steaming pile of pretty hex digits. + */ + dump(): string; + /** + * Get a struct pointer for the root of this message. This is primarily used when reading a message; it will not + * overwrite existing data. + * + * @template T + * @param {StructCtor} RootStruct The struct type to use as the root. + * @returns {T} A struct representing the root of the message. + */ + getRoot(RootStruct: StructCtor): T; + /** + * Get a segment by its id. + * + * This will lazily allocate the first segment if it doesn't already exist. + * + * @param {number} id The segment id. + * @returns {Segment} The requested segment. + */ + getSegment(id: number): Segment; + /** + * Initialize a new message using the provided struct type as the root. + * + * @template T + * @param {StructCtor} RootStruct The struct type to use as the root. + * @returns {T} An initialized struct pointing to the root of the message. + */ + initRoot(RootStruct: StructCtor): T; + /** + * Set the root of the message to a copy of the given pointer. Used internally + * to make copies of pointers for default values. + * + * @param {Pointer} src The source pointer to copy. + * @returns {void} + */ + setRoot(src: Pointer): void; + /** + * Combine the contents of this message's segments into a single array buffer and prepend a stream framing header + * containing information about the following segment data. + * + * @returns {ArrayBuffer} An ArrayBuffer with the contents of this message. + */ + toArrayBuffer(): ArrayBuffer; + /** + * Like `toArrayBuffer()`, but also applies the packing algorithm to the output. This is typically what you want to + * use if you're sending the message over a network link or other slow I/O interface where size matters. + * + * @returns {ArrayBuffer} A packed message. + */ + toPackedArrayBuffer(): ArrayBuffer; + toString(): string; +} +export interface CreateMessageOptions { + packed?: boolean; + singleSegment?: boolean; +} +export declare function initMessage(src?: AnyArena | ArrayBufferView | ArrayBuffer, packed?: boolean, singleSegment?: boolean): _Message; +/** + * Given an _unpacked_ message with a segment framing header, this will generate an ArrayBuffer for each segment in + * the message. + * + * This method is not typically called directly, but can be useful in certain cases. + * + * @static + * @param {ArrayBuffer} message An unpacked message with a framing header. + * @returns {ArrayBuffer[]} An array of buffers containing the segment data. + */ +export declare function getFramedSegments(message: ArrayBuffer): ArrayBuffer[]; +/** + * This method is called on messages that were constructed with existing data to prepopulate the segments array with + * everything we can find in the arena. Each segment will have it's `byteLength` set to the size of its buffer. + * + * Technically speaking, the message's segments will be "full" after calling this function. Calling this on your own + * may void your warranty. + * + * @param {Message} m The message to allocate. + * @returns {void} + */ +export declare function preallocateSegments(m: Message): void; +export declare function allocateSegment(byteLength: number, m: Message): Segment; +export declare function dump(m: Message): string; +export declare function getRoot(RootStruct: StructCtor, m: Message): T; +export declare function getSegment(id: number, m: Message): Segment; +export declare function initRoot(RootStruct: StructCtor, m: Message): T; +/** + * Read a pointer in raw form (a packed message with framing headers). Does not + * care or attempt to validate the input beyond parsing the message + * segments. + * + * This is typically used by the compiler to load default values, but can be + * useful to work with messages with an unknown schema. + * + * @param {ArrayBuffer} data The raw data to read. + * @returns {Pointer} A root pointer. + */ +export declare function readRawPointer(data: ArrayBuffer): Pointer; +export declare function setRoot(src: Pointer, m: Message): void; +export declare function toArrayBuffer(m: Message): ArrayBuffer; +export declare function toPackedArrayBuffer(m: Message): ArrayBuffer; +export declare function getStreamFrame(m: Message): ArrayBuffer; diff --git a/node_modules/capnp-ts/src/serialization/message.js b/node_modules/capnp-ts/src/serialization/message.js new file mode 100644 index 0000000000000000000000000000000000000000..818c9129619e7583a6a574ef3f9e750ebc45127a --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/message.js @@ -0,0 +1,392 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getStreamFrame = exports.toPackedArrayBuffer = exports.toArrayBuffer = exports.setRoot = exports.readRawPointer = exports.initRoot = exports.getSegment = exports.getRoot = exports.dump = exports.allocateSegment = exports.preallocateSegments = exports.getFramedSegments = exports.initMessage = exports.Message = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("../constants"); +const errors_1 = require("../errors"); +const util_1 = require("../util"); +const arena_1 = require("./arena"); +const packing_1 = require("./packing"); +const pointers_1 = require("./pointers"); +const segment_1 = require("./segment"); +const pointer_1 = require("./pointers/pointer"); +const struct_1 = require("./pointers/struct"); +const trace = debug_1.default("capnp:message"); +trace("load"); +class Message { + /** + * A Cap'n Proto message. + * + * SECURITY WARNING: In nodejs do not pass a Buffer's internal array buffer into this constructor. Pass the buffer + * directly and everything will be fine. If not, your message will potentially be initialized with random memory + * contents! + * + * The constructor method creates a new Message, optionally using a provided arena for segment allocation, or a buffer + * to read from. + * + * @constructor {Message} + * + * @param {AnyArena|ArrayBufferView|ArrayBuffer} [src] The source for the message. + * A value of `undefined` will cause the message to initialize with a single segment arena only big enough for the + * root pointer; it will expand as you go. This is a reasonable choice for most messages. + * + * Passing an arena will cause the message to use that arena for its segment allocation. Contents will be accepted + * as-is. + * + * Passing an array buffer view (like `DataView`, `Uint8Array` or `Buffer`) will create a **copy** of the source + * buffer; beware of the potential performance cost! + * + * @param {boolean} [packed] Whether or not the message is packed. If `true` (the default), the message will be + * unpacked. + * + * @param {boolean} [singleSegment] If true, `src` will be treated as a message consisting of a single segment without + * a framing header. + * + */ + constructor(src, packed = true, singleSegment = false) { + this._capnp = initMessage(src, packed, singleSegment); + if (src && !isAnyArena(src)) + preallocateSegments(this); + trace("new %s", this); + } + allocateSegment(byteLength) { + return allocateSegment(byteLength, this); + } + /** + * Create a pretty-printed string dump of this message; incredibly useful for debugging. + * + * WARNING: Do not call this method on large messages! + * + * @returns {string} A big steaming pile of pretty hex digits. + */ + dump() { + return dump(this); + } + /** + * Get a struct pointer for the root of this message. This is primarily used when reading a message; it will not + * overwrite existing data. + * + * @template T + * @param {StructCtor} RootStruct The struct type to use as the root. + * @returns {T} A struct representing the root of the message. + */ + getRoot(RootStruct) { + return getRoot(RootStruct, this); + } + /** + * Get a segment by its id. + * + * This will lazily allocate the first segment if it doesn't already exist. + * + * @param {number} id The segment id. + * @returns {Segment} The requested segment. + */ + getSegment(id) { + return getSegment(id, this); + } + /** + * Initialize a new message using the provided struct type as the root. + * + * @template T + * @param {StructCtor} RootStruct The struct type to use as the root. + * @returns {T} An initialized struct pointing to the root of the message. + */ + initRoot(RootStruct) { + return initRoot(RootStruct, this); + } + /** + * Set the root of the message to a copy of the given pointer. Used internally + * to make copies of pointers for default values. + * + * @param {Pointer} src The source pointer to copy. + * @returns {void} + */ + setRoot(src) { + setRoot(src, this); + } + /** + * Combine the contents of this message's segments into a single array buffer and prepend a stream framing header + * containing information about the following segment data. + * + * @returns {ArrayBuffer} An ArrayBuffer with the contents of this message. + */ + toArrayBuffer() { + return toArrayBuffer(this); + } + /** + * Like `toArrayBuffer()`, but also applies the packing algorithm to the output. This is typically what you want to + * use if you're sending the message over a network link or other slow I/O interface where size matters. + * + * @returns {ArrayBuffer} A packed message. + */ + toPackedArrayBuffer() { + return toPackedArrayBuffer(this); + } + toString() { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + return `Message_arena:${this._capnp.arena}`; + } +} +exports.Message = Message; +Message.allocateSegment = allocateSegment; +Message.dump = dump; +Message.getRoot = getRoot; +Message.getSegment = getSegment; +Message.initRoot = initRoot; +Message.readRawPointer = readRawPointer; +Message.toArrayBuffer = toArrayBuffer; +Message.toPackedArrayBuffer = toPackedArrayBuffer; +function initMessage(src, packed = true, singleSegment = false) { + if (src === undefined) { + return { + arena: new arena_1.SingleSegmentArena(), + segments: [], + traversalLimit: constants_1.DEFAULT_TRAVERSE_LIMIT, + }; + } + if (isAnyArena(src)) { + return { arena: src, segments: [], traversalLimit: constants_1.DEFAULT_TRAVERSE_LIMIT }; + } + let buf = src; + if (isArrayBufferView(buf)) { + buf = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + } + if (packed) + buf = packing_1.unpack(buf); + if (singleSegment) { + return { + arena: new arena_1.SingleSegmentArena(buf), + segments: [], + traversalLimit: constants_1.DEFAULT_TRAVERSE_LIMIT, + }; + } + return { + arena: new arena_1.MultiSegmentArena(getFramedSegments(buf)), + segments: [], + traversalLimit: constants_1.DEFAULT_TRAVERSE_LIMIT, + }; +} +exports.initMessage = initMessage; +/** + * Given an _unpacked_ message with a segment framing header, this will generate an ArrayBuffer for each segment in + * the message. + * + * This method is not typically called directly, but can be useful in certain cases. + * + * @static + * @param {ArrayBuffer} message An unpacked message with a framing header. + * @returns {ArrayBuffer[]} An array of buffers containing the segment data. + */ +function getFramedSegments(message) { + const dv = new DataView(message); + const segmentCount = dv.getUint32(0, true) + 1; + const segments = new Array(segmentCount); + trace("reading %d framed segments from stream", segmentCount); + let byteOffset = 4 + segmentCount * 4; + byteOffset += byteOffset % 8; + if (byteOffset + segmentCount * 4 > message.byteLength) { + throw new Error(errors_1.MSG_INVALID_FRAME_HEADER); + } + for (let i = 0; i < segmentCount; i++) { + const byteLength = dv.getUint32(4 + i * 4, true) * 8; + if (byteOffset + byteLength > message.byteLength) { + throw new Error(errors_1.MSG_INVALID_FRAME_HEADER); + } + segments[i] = message.slice(byteOffset, byteOffset + byteLength); + byteOffset += byteLength; + } + return segments; +} +exports.getFramedSegments = getFramedSegments; +/** + * This method is called on messages that were constructed with existing data to prepopulate the segments array with + * everything we can find in the arena. Each segment will have it's `byteLength` set to the size of its buffer. + * + * Technically speaking, the message's segments will be "full" after calling this function. Calling this on your own + * may void your warranty. + * + * @param {Message} m The message to allocate. + * @returns {void} + */ +function preallocateSegments(m) { + const numSegments = arena_1.Arena.getNumSegments(m._capnp.arena); + if (numSegments < 1) + throw new Error(errors_1.MSG_NO_SEGMENTS_IN_ARENA); + m._capnp.segments = new Array(numSegments); + for (let i = 0; i < numSegments; i++) { + // Set up each segment so that they're fully allocated to the extents of the existing buffers. + const buffer = arena_1.Arena.getBuffer(i, m._capnp.arena); + const segment = new segment_1.Segment(i, m, buffer, buffer.byteLength); + m._capnp.segments[i] = segment; + } +} +exports.preallocateSegments = preallocateSegments; +function isArrayBufferView(src) { + return src.byteOffset !== undefined; +} +function isAnyArena(o) { + return o.kind !== undefined; +} +function allocateSegment(byteLength, m) { + trace("allocating %x bytes for %s", byteLength, m); + const res = arena_1.Arena.allocate(byteLength, m._capnp.segments, m._capnp.arena); + let s; + if (res.id === m._capnp.segments.length) { + // Note how we're only allowing new segments in if they're exactly the next one in the array. There is no logical + // reason for segments to be created out of order. + s = new segment_1.Segment(res.id, m, res.buffer); + trace("adding new segment %s", s); + m._capnp.segments.push(s); + } + else if (res.id < 0 || res.id > m._capnp.segments.length) { + throw new Error(util_1.format(errors_1.MSG_SEGMENT_OUT_OF_BOUNDS, res.id, m)); + } + else { + s = m._capnp.segments[res.id]; + trace("replacing segment %s with buffer (len:%d)", s, res.buffer.byteLength); + s.replaceBuffer(res.buffer); + } + return s; +} +exports.allocateSegment = allocateSegment; +function dump(m) { + let r = ""; + if (m._capnp.segments.length === 0) { + return "================\nNo Segments\n================\n"; + } + for (let i = 0; i < m._capnp.segments.length; i++) { + r += `================\nSegment #${i}\n================\n`; + const { buffer, byteLength } = m._capnp.segments[i]; + const b = new Uint8Array(buffer, 0, byteLength); + r += util_1.dumpBuffer(b); + } + return r; +} +exports.dump = dump; +function getRoot(RootStruct, m) { + const root = new RootStruct(m.getSegment(0), 0); + pointer_1.validate(pointers_1.PointerType.STRUCT, root); + const ts = pointer_1.getTargetStructSize(root); + // Make sure the underlying pointer is actually big enough to hold the data and pointers as specified in the schema. + // If not a shallow copy of the struct contents needs to be made before returning. + if (ts.dataByteLength < RootStruct._capnp.size.dataByteLength || + ts.pointerLength < RootStruct._capnp.size.pointerLength) { + trace("need to resize root struct %s", root); + struct_1.resize(RootStruct._capnp.size, root); + } + return root; +} +exports.getRoot = getRoot; +function getSegment(id, m) { + const segmentLength = m._capnp.segments.length; + if (id === 0 && segmentLength === 0) { + // Segment zero is special. If we have no segments in the arena we'll want to allocate a new one and leave room + // for the root pointer. + const arenaSegments = arena_1.Arena.getNumSegments(m._capnp.arena); + if (arenaSegments === 0) { + allocateSegment(constants_1.DEFAULT_BUFFER_SIZE, m); + } + else { + // Okay, the arena already has a buffer we can use. This is totally fine. + m._capnp.segments[0] = new segment_1.Segment(0, m, arena_1.Arena.getBuffer(0, m._capnp.arena)); + } + if (!m._capnp.segments[0].hasCapacity(8)) { + throw new Error(errors_1.MSG_SEGMENT_TOO_SMALL); + } + // This will leave room for the root pointer. + m._capnp.segments[0].allocate(8); + return m._capnp.segments[0]; + } + if (id < 0 || id >= segmentLength) { + throw new Error(util_1.format(errors_1.MSG_SEGMENT_OUT_OF_BOUNDS, id, m)); + } + return m._capnp.segments[id]; +} +exports.getSegment = getSegment; +function initRoot(RootStruct, m) { + const root = new RootStruct(m.getSegment(0), 0); + struct_1.initStruct(RootStruct._capnp.size, root); + trace("Initialized root pointer %s for %s.", root, m); + return root; +} +exports.initRoot = initRoot; +/** + * Read a pointer in raw form (a packed message with framing headers). Does not + * care or attempt to validate the input beyond parsing the message + * segments. + * + * This is typically used by the compiler to load default values, but can be + * useful to work with messages with an unknown schema. + * + * @param {ArrayBuffer} data The raw data to read. + * @returns {Pointer} A root pointer. + */ +function readRawPointer(data) { + return new pointers_1.Pointer(new Message(data).getSegment(0), 0); +} +exports.readRawPointer = readRawPointer; +function setRoot(src, m) { + pointers_1.Pointer.copyFrom(src, new pointers_1.Pointer(m.getSegment(0), 0)); +} +exports.setRoot = setRoot; +function toArrayBuffer(m) { + const streamFrame = getStreamFrame(m); + // Make sure the first segment is allocated. + if (m._capnp.segments.length === 0) + getSegment(0, m); + const segments = m._capnp.segments; + // Add space for the stream framing. + const totalLength = streamFrame.byteLength + segments.reduce((l, s) => l + util_1.padToWord(s.byteLength), 0); + const out = new Uint8Array(new ArrayBuffer(totalLength)); + let o = streamFrame.byteLength; + out.set(new Uint8Array(streamFrame)); + segments.forEach((s) => { + const segmentLength = util_1.padToWord(s.byteLength); + out.set(new Uint8Array(s.buffer, 0, segmentLength), o); + o += segmentLength; + }); + return out.buffer; +} +exports.toArrayBuffer = toArrayBuffer; +function toPackedArrayBuffer(m) { + const streamFrame = packing_1.pack(getStreamFrame(m)); + // Make sure the first segment is allocated. + if (m._capnp.segments.length === 0) + m.getSegment(0); + // NOTE: A copy operation can be avoided here if we capture the intermediate array and use that directly in the copy + // loop below, rather than have `pack()` copy it to an ArrayBuffer just to have to copy it again later. If the + // intermediate array can be avoided altogether that's even better! + const segments = m._capnp.segments.map((s) => packing_1.pack(s.buffer, 0, util_1.padToWord(s.byteLength))); + const totalLength = streamFrame.byteLength + segments.reduce((l, s) => l + s.byteLength, 0); + const out = new Uint8Array(new ArrayBuffer(totalLength)); + let o = streamFrame.byteLength; + out.set(new Uint8Array(streamFrame)); + segments.forEach((s) => { + out.set(new Uint8Array(s), o); + o += s.byteLength; + }); + return out.buffer; +} +exports.toPackedArrayBuffer = toPackedArrayBuffer; +function getStreamFrame(m) { + const length = m._capnp.segments.length; + if (length === 0) { + // Don't bother allocating the first segment, just return a single zero word for the frame header. + return new Float64Array(1).buffer; + } + const frameLength = 4 + length * 4 + (1 - (length % 2)) * 4; + const out = new DataView(new ArrayBuffer(frameLength)); + trace("Writing message stream frame with segment count: %d.", length); + out.setUint32(0, length - 1, true); + m._capnp.segments.forEach((s, i) => { + trace("Message segment %d word count: %d.", s.id, s.byteLength / 8); + out.setUint32(i * 4 + 4, s.byteLength / 8, true); + }); + return out.buffer; +} +exports.getStreamFrame = getStreamFrame; +//# sourceMappingURL=message.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/message.js.map b/node_modules/capnp-ts/src/serialization/message.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9d42066258cc4028c63f558e5db2b5d88e24dd16 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/message.js.map @@ -0,0 +1 @@ +{"version":3,"file":"message.js","sourceRoot":"","sources":["message.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAC9B,4CAA2E;AAC3E,sCAKmB;AACnB,kCAAwD;AACxD,mCAA4F;AAC5F,uCAAyC;AACzC,yCAAsE;AACtE,uCAAoC;AACpC,gDAAmE;AACnE,8CAAuD;AAEvD,MAAM,KAAK,GAAG,eAAS,CAAC,eAAe,CAAC,CAAC;AACzC,KAAK,CAAC,MAAM,CAAC,CAAC;AAQd,MAAa,OAAO;IAYlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,YAAY,GAA8C,EAAE,MAAM,GAAG,IAAI,EAAE,aAAa,GAAG,KAAK;QAC9F,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;QAEtD,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAEvD,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,eAAe,CAAC,UAAkB;QAChC,OAAO,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IAEH,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IAEH,OAAO,CAAmB,UAAyB;QACjD,OAAO,OAAO,C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,EAAE,CAAC,EAAE,EAAE;QACjC,KAAK,CAAC,oCAAoC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;QAEpE,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC;AAvBD,wCAuBC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/message.ts b/node_modules/capnp-ts/src/serialization/message.ts new file mode 100644 index 0000000000000000000000000000000000000000..20e56a2b29ab4c8897b94b32261f6bf19dc67afd --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/message.ts @@ -0,0 +1,507 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; +import { DEFAULT_TRAVERSE_LIMIT, DEFAULT_BUFFER_SIZE } from "../constants"; +import { + MSG_INVALID_FRAME_HEADER, + MSG_SEGMENT_OUT_OF_BOUNDS, + MSG_SEGMENT_TOO_SMALL, + MSG_NO_SEGMENTS_IN_ARENA, +} from "../errors"; +import { dumpBuffer, format, padToWord } from "../util"; +import { AnyArena, Arena, MultiSegmentArena, SingleSegmentArena, ArenaKind } from "./arena"; +import { pack, unpack } from "./packing"; +import { Pointer, StructCtor, PointerType, Struct } from "./pointers"; +import { Segment } from "./segment"; +import { getTargetStructSize, validate } from "./pointers/pointer"; +import { resize, initStruct } from "./pointers/struct"; + +const trace = initTrace("capnp:message"); +trace("load"); + +export interface _Message { + readonly arena: AnyArena; + segments: Segment[]; + traversalLimit: number; +} + +export class Message { + static readonly allocateSegment = allocateSegment; + static readonly dump = dump; + static readonly getRoot = getRoot; + static readonly getSegment = getSegment; + static readonly initRoot = initRoot; + static readonly readRawPointer = readRawPointer; + static readonly toArrayBuffer = toArrayBuffer; + static readonly toPackedArrayBuffer = toPackedArrayBuffer; + + readonly _capnp: _Message; + + /** + * A Cap'n Proto message. + * + * SECURITY WARNING: In nodejs do not pass a Buffer's internal array buffer into this constructor. Pass the buffer + * directly and everything will be fine. If not, your message will potentially be initialized with random memory + * contents! + * + * The constructor method creates a new Message, optionally using a provided arena for segment allocation, or a buffer + * to read from. + * + * @constructor {Message} + * + * @param {AnyArena|ArrayBufferView|ArrayBuffer} [src] The source for the message. + * A value of `undefined` will cause the message to initialize with a single segment arena only big enough for the + * root pointer; it will expand as you go. This is a reasonable choice for most messages. + * + * Passing an arena will cause the message to use that arena for its segment allocation. Contents will be accepted + * as-is. + * + * Passing an array buffer view (like `DataView`, `Uint8Array` or `Buffer`) will create a **copy** of the source + * buffer; beware of the potential performance cost! + * + * @param {boolean} [packed] Whether or not the message is packed. If `true` (the default), the message will be + * unpacked. + * + * @param {boolean} [singleSegment] If true, `src` will be treated as a message consisting of a single segment without + * a framing header. + * + */ + constructor(src?: AnyArena | ArrayBufferView | ArrayBuffer, packed = true, singleSegment = false) { + this._capnp = initMessage(src, packed, singleSegment); + + if (src && !isAnyArena(src)) preallocateSegments(this); + + trace("new %s", this); + } + + allocateSegment(byteLength: number): Segment { + return allocateSegment(byteLength, this); + } + + /** + * Create a pretty-printed string dump of this message; incredibly useful for debugging. + * + * WARNING: Do not call this method on large messages! + * + * @returns {string} A big steaming pile of pretty hex digits. + */ + + dump(): string { + return dump(this); + } + + /** + * Get a struct pointer for the root of this message. This is primarily used when reading a message; it will not + * overwrite existing data. + * + * @template T + * @param {StructCtor} RootStruct The struct type to use as the root. + * @returns {T} A struct representing the root of the message. + */ + + getRoot(RootStruct: StructCtor): T { + return getRoot(RootStruct, this); + } + + /** + * Get a segment by its id. + * + * This will lazily allocate the first segment if it doesn't already exist. + * + * @param {number} id The segment id. + * @returns {Segment} The requested segment. + */ + + getSegment(id: number): Segment { + return getSegment(id, this); + } + + /** + * Initialize a new message using the provided struct type as the root. + * + * @template T + * @param {StructCtor} RootStruct The struct type to use as the root. + * @returns {T} An initialized struct pointing to the root of the message. + */ + + initRoot(RootStruct: StructCtor): T { + return initRoot(RootStruct, this); + } + + /** + * Set the root of the message to a copy of the given pointer. Used internally + * to make copies of pointers for default values. + * + * @param {Pointer} src The source pointer to copy. + * @returns {void} + */ + + setRoot(src: Pointer): void { + setRoot(src, this); + } + + /** + * Combine the contents of this message's segments into a single array buffer and prepend a stream framing header + * containing information about the following segment data. + * + * @returns {ArrayBuffer} An ArrayBuffer with the contents of this message. + */ + + toArrayBuffer(): ArrayBuffer { + return toArrayBuffer(this); + } + + /** + * Like `toArrayBuffer()`, but also applies the packing algorithm to the output. This is typically what you want to + * use if you're sending the message over a network link or other slow I/O interface where size matters. + * + * @returns {ArrayBuffer} A packed message. + */ + + toPackedArrayBuffer(): ArrayBuffer { + return toPackedArrayBuffer(this); + } + + toString(): string { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + return `Message_arena:${this._capnp.arena}`; + } +} + +export interface CreateMessageOptions { + packed?: boolean; + singleSegment?: boolean; +} + +export function initMessage( + src?: AnyArena | ArrayBufferView | ArrayBuffer, + packed = true, + singleSegment = false +): _Message { + if (src === undefined) { + return { + arena: new SingleSegmentArena(), + segments: [], + traversalLimit: DEFAULT_TRAVERSE_LIMIT, + }; + } + + if (isAnyArena(src)) { + return { arena: src, segments: [], traversalLimit: DEFAULT_TRAVERSE_LIMIT }; + } + + let buf: ArrayBuffer = src as ArrayBuffer; + + if (isArrayBufferView(buf)) { + buf = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + } + + if (packed) buf = unpack(buf); + + if (singleSegment) { + return { + arena: new SingleSegmentArena(buf), + segments: [], + traversalLimit: DEFAULT_TRAVERSE_LIMIT, + }; + } + + return { + arena: new MultiSegmentArena(getFramedSegments(buf)), + segments: [], + traversalLimit: DEFAULT_TRAVERSE_LIMIT, + }; +} + +/** + * Given an _unpacked_ message with a segment framing header, this will generate an ArrayBuffer for each segment in + * the message. + * + * This method is not typically called directly, but can be useful in certain cases. + * + * @static + * @param {ArrayBuffer} message An unpacked message with a framing header. + * @returns {ArrayBuffer[]} An array of buffers containing the segment data. + */ + +export function getFramedSegments(message: ArrayBuffer): ArrayBuffer[] { + const dv = new DataView(message); + + const segmentCount = dv.getUint32(0, true) + 1; + + const segments = new Array(segmentCount) as ArrayBuffer[]; + + trace("reading %d framed segments from stream", segmentCount); + + let byteOffset = 4 + segmentCount * 4; + byteOffset += byteOffset % 8; + + if (byteOffset + segmentCount * 4 > message.byteLength) { + throw new Error(MSG_INVALID_FRAME_HEADER); + } + + for (let i = 0; i < segmentCount; i++) { + const byteLength = dv.getUint32(4 + i * 4, true) * 8; + + if (byteOffset + byteLength > message.byteLength) { + throw new Error(MSG_INVALID_FRAME_HEADER); + } + + segments[i] = message.slice(byteOffset, byteOffset + byteLength); + + byteOffset += byteLength; + } + + return segments; +} + +/** + * This method is called on messages that were constructed with existing data to prepopulate the segments array with + * everything we can find in the arena. Each segment will have it's `byteLength` set to the size of its buffer. + * + * Technically speaking, the message's segments will be "full" after calling this function. Calling this on your own + * may void your warranty. + * + * @param {Message} m The message to allocate. + * @returns {void} + */ + +export function preallocateSegments(m: Message): void { + const numSegments = Arena.getNumSegments(m._capnp.arena); + + if (numSegments < 1) throw new Error(MSG_NO_SEGMENTS_IN_ARENA); + + m._capnp.segments = new Array(numSegments) as Segment[]; + + for (let i = 0; i < numSegments; i++) { + // Set up each segment so that they're fully allocated to the extents of the existing buffers. + + const buffer = Arena.getBuffer(i, m._capnp.arena); + const segment = new Segment(i, m, buffer, buffer.byteLength); + + m._capnp.segments[i] = segment; + } +} + +function isArrayBufferView(src: ArrayBuffer | ArrayBufferView): src is ArrayBufferView { + return (src as { byteOffset?: number }).byteOffset !== undefined; +} + +function isAnyArena(o: unknown): o is AnyArena { + return (o as { kind?: ArenaKind }).kind !== undefined; +} + +export function allocateSegment(byteLength: number, m: Message): Segment { + trace("allocating %x bytes for %s", byteLength, m); + + const res = Arena.allocate(byteLength, m._capnp.segments, m._capnp.arena); + let s: Segment; + + if (res.id === m._capnp.segments.length) { + // Note how we're only allowing new segments in if they're exactly the next one in the array. There is no logical + // reason for segments to be created out of order. + + s = new Segment(res.id, m, res.buffer); + + trace("adding new segment %s", s); + + m._capnp.segments.push(s); + } else if (res.id < 0 || res.id > m._capnp.segments.length) { + throw new Error(format(MSG_SEGMENT_OUT_OF_BOUNDS, res.id, m)); + } else { + s = m._capnp.segments[res.id]; + + trace("replacing segment %s with buffer (len:%d)", s, res.buffer.byteLength); + + s.replaceBuffer(res.buffer); + } + + return s; +} + +export function dump(m: Message): string { + let r = ""; + + if (m._capnp.segments.length === 0) { + return "================\nNo Segments\n================\n"; + } + + for (let i = 0; i < m._capnp.segments.length; i++) { + r += `================\nSegment #${i}\n================\n`; + + const { buffer, byteLength } = m._capnp.segments[i]; + const b = new Uint8Array(buffer, 0, byteLength); + + r += dumpBuffer(b); + } + + return r; +} + +export function getRoot(RootStruct: StructCtor, m: Message): T { + const root = new RootStruct(m.getSegment(0), 0); + + validate(PointerType.STRUCT, root); + + const ts = getTargetStructSize(root); + + // Make sure the underlying pointer is actually big enough to hold the data and pointers as specified in the schema. + // If not a shallow copy of the struct contents needs to be made before returning. + + if ( + ts.dataByteLength < RootStruct._capnp.size.dataByteLength || + ts.pointerLength < RootStruct._capnp.size.pointerLength + ) { + trace("need to resize root struct %s", root); + + resize(RootStruct._capnp.size, root); + } + + return root; +} + +export function getSegment(id: number, m: Message): Segment { + const segmentLength = m._capnp.segments.length; + + if (id === 0 && segmentLength === 0) { + // Segment zero is special. If we have no segments in the arena we'll want to allocate a new one and leave room + // for the root pointer. + + const arenaSegments = Arena.getNumSegments(m._capnp.arena); + + if (arenaSegments === 0) { + allocateSegment(DEFAULT_BUFFER_SIZE, m); + } else { + // Okay, the arena already has a buffer we can use. This is totally fine. + + m._capnp.segments[0] = new Segment(0, m, Arena.getBuffer(0, m._capnp.arena)); + } + + if (!m._capnp.segments[0].hasCapacity(8)) { + throw new Error(MSG_SEGMENT_TOO_SMALL); + } + + // This will leave room for the root pointer. + + m._capnp.segments[0].allocate(8); + + return m._capnp.segments[0]; + } + + if (id < 0 || id >= segmentLength) { + throw new Error(format(MSG_SEGMENT_OUT_OF_BOUNDS, id, m)); + } + + return m._capnp.segments[id]; +} + +export function initRoot(RootStruct: StructCtor, m: Message): T { + const root = new RootStruct(m.getSegment(0), 0); + + initStruct(RootStruct._capnp.size, root); + + trace("Initialized root pointer %s for %s.", root, m); + + return root; +} + +/** + * Read a pointer in raw form (a packed message with framing headers). Does not + * care or attempt to validate the input beyond parsing the message + * segments. + * + * This is typically used by the compiler to load default values, but can be + * useful to work with messages with an unknown schema. + * + * @param {ArrayBuffer} data The raw data to read. + * @returns {Pointer} A root pointer. + */ + +export function readRawPointer(data: ArrayBuffer): Pointer { + return new Pointer(new Message(data).getSegment(0), 0); +} + +export function setRoot(src: Pointer, m: Message): void { + Pointer.copyFrom(src, new Pointer(m.getSegment(0), 0)); +} + +export function toArrayBuffer(m: Message): ArrayBuffer { + const streamFrame = getStreamFrame(m); + + // Make sure the first segment is allocated. + + if (m._capnp.segments.length === 0) getSegment(0, m); + + const segments = m._capnp.segments; + + // Add space for the stream framing. + + const totalLength = streamFrame.byteLength + segments.reduce((l, s) => l + padToWord(s.byteLength), 0); + const out = new Uint8Array(new ArrayBuffer(totalLength)); + let o = streamFrame.byteLength; + + out.set(new Uint8Array(streamFrame)); + + segments.forEach((s) => { + const segmentLength = padToWord(s.byteLength); + out.set(new Uint8Array(s.buffer, 0, segmentLength), o); + + o += segmentLength; + }); + + return out.buffer; +} + +export function toPackedArrayBuffer(m: Message): ArrayBuffer { + const streamFrame = pack(getStreamFrame(m)); + + // Make sure the first segment is allocated. + + if (m._capnp.segments.length === 0) m.getSegment(0); + + // NOTE: A copy operation can be avoided here if we capture the intermediate array and use that directly in the copy + // loop below, rather than have `pack()` copy it to an ArrayBuffer just to have to copy it again later. If the + // intermediate array can be avoided altogether that's even better! + const segments = m._capnp.segments.map((s) => pack(s.buffer, 0, padToWord(s.byteLength))); + + const totalLength = streamFrame.byteLength + segments.reduce((l, s) => l + s.byteLength, 0); + const out = new Uint8Array(new ArrayBuffer(totalLength)); + let o = streamFrame.byteLength; + + out.set(new Uint8Array(streamFrame)); + + segments.forEach((s) => { + out.set(new Uint8Array(s), o); + + o += s.byteLength; + }); + + return out.buffer; +} + +export function getStreamFrame(m: Message): ArrayBuffer { + const length = m._capnp.segments.length; + + if (length === 0) { + // Don't bother allocating the first segment, just return a single zero word for the frame header. + + return new Float64Array(1).buffer; + } + + const frameLength = 4 + length * 4 + (1 - (length % 2)) * 4; + const out = new DataView(new ArrayBuffer(frameLength)); + + trace("Writing message stream frame with segment count: %d.", length); + + out.setUint32(0, length - 1, true); + + m._capnp.segments.forEach((s, i) => { + trace("Message segment %d word count: %d.", s.id, s.byteLength / 8); + + out.setUint32(i * 4 + 4, s.byteLength / 8, true); + }); + + return out.buffer; +} diff --git a/node_modules/capnp-ts/src/serialization/object-size.d.ts b/node_modules/capnp-ts/src/serialization/object-size.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd56f04e3bb1fd593ea72f45db326a56d2d08a54 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/object-size.d.ts @@ -0,0 +1,21 @@ +/** + * @author jdiaz5513 + */ +/** + * A simple object that describes the size of a struct. + * + * @export + * @class ObjectSize + */ +export declare class ObjectSize { + /** The number of bytes required for the data section. */ + readonly dataByteLength: number; + /** The number of pointers in the object. */ + readonly pointerLength: number; + constructor(dataByteLength: number, pointerCount: number); + toString(): string; +} +export declare function getByteLength(o: ObjectSize): number; +export declare function getDataWordLength(o: ObjectSize): number; +export declare function getWordLength(o: ObjectSize): number; +export declare function padToWord(o: ObjectSize): ObjectSize; diff --git a/node_modules/capnp-ts/src/serialization/object-size.js b/node_modules/capnp-ts/src/serialization/object-size.js new file mode 100644 index 0000000000000000000000000000000000000000..2a41040f7ce256ac74a7add641facf6f97f42b4d --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/object-size.js @@ -0,0 +1,44 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.padToWord = exports.getWordLength = exports.getDataWordLength = exports.getByteLength = exports.ObjectSize = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const _ = tslib_1.__importStar(require("../util")); +const trace = debug_1.default("capnp:object-size"); +trace("load"); +/** + * A simple object that describes the size of a struct. + * + * @export + * @class ObjectSize + */ +class ObjectSize { + constructor(dataByteLength, pointerCount) { + this.dataByteLength = dataByteLength; + this.pointerLength = pointerCount; + } + toString() { + return _.format("ObjectSize_dw:%d,pc:%d", getDataWordLength(this), this.pointerLength); + } +} +exports.ObjectSize = ObjectSize; +function getByteLength(o) { + return o.dataByteLength + o.pointerLength * 8; +} +exports.getByteLength = getByteLength; +function getDataWordLength(o) { + return o.dataByteLength / 8; +} +exports.getDataWordLength = getDataWordLength; +function getWordLength(o) { + return o.dataByteLength / 8 + o.pointerLength; +} +exports.getWordLength = getWordLength; +function padToWord(o) { + return new ObjectSize(_.padToWord(o.dataByteLength), o.pointerLength); +} +exports.padToWord = padToWord; +//# sourceMappingURL=object-size.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/object-size.js.map b/node_modules/capnp-ts/src/serialization/object-size.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f0960e6965b45be6b7efb21bdb51c9575071966b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/object-size.js.map @@ -0,0 +1 @@ +{"version":3,"file":"object-size.js","sourceRoot":"","sources":["object-size.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,mDAA6B;AAE7B,MAAM,KAAK,GAAG,eAAS,CAAC,mBAAmB,CAAC,CAAC;AAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd;;;;;GAKG;AAEH,MAAa,UAAU;IASrB,YAAY,cAAsB,EAAE,YAAoB;QACtD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,CAAC,MAAM,CACb,wBAAwB,EACxB,iBAAiB,CAAC,IAAI,CAAC,EACvB,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;CACF;AArBD,gCAqBC;AAED,SAAgB,aAAa,CAAC,CAAa;IACzC,OAAO,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC;AAChD,CAAC;AAFD,sCAEC;AAED,SAAgB,iBAAiB,CAAC,CAAa;IAC7C,OAAO,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC;AAC9B,CAAC;AAFD,8CAEC;AAED,SAAgB,aAAa,CAAC,CAAa;IACzC,OAAO,CAAC,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC;AAChD,CAAC;AAFD,sCAEC;AAED,SAAgB,SAAS,CAAC,CAAa;IACrC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC;AACxE,CAAC;AAFD,8BAEC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/object-size.ts b/node_modules/capnp-ts/src/serialization/object-size.ts new file mode 100644 index 0000000000000000000000000000000000000000..1051a07582d3b3adbc760858f1926fe76aca8b0e --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/object-size.ts @@ -0,0 +1,56 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import * as _ from "../util"; + +const trace = initTrace("capnp:object-size"); +trace("load"); + +/** + * A simple object that describes the size of a struct. + * + * @export + * @class ObjectSize + */ + +export class ObjectSize { + /** The number of bytes required for the data section. */ + + readonly dataByteLength: number; + + /** The number of pointers in the object. */ + + readonly pointerLength: number; + + constructor(dataByteLength: number, pointerCount: number) { + this.dataByteLength = dataByteLength; + this.pointerLength = pointerCount; + } + + toString(): string { + return _.format( + "ObjectSize_dw:%d,pc:%d", + getDataWordLength(this), + this.pointerLength + ); + } +} + +export function getByteLength(o: ObjectSize): number { + return o.dataByteLength + o.pointerLength * 8; +} + +export function getDataWordLength(o: ObjectSize): number { + return o.dataByteLength / 8; +} + +export function getWordLength(o: ObjectSize): number { + return o.dataByteLength / 8 + o.pointerLength; +} + +export function padToWord(o: ObjectSize): ObjectSize { + return new ObjectSize(_.padToWord(o.dataByteLength), o.pointerLength); +} diff --git a/node_modules/capnp-ts/src/serialization/packing.d.ts b/node_modules/capnp-ts/src/serialization/packing.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7127bdaad6e5cf5a610236cb27257853986a426a --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/packing.d.ts @@ -0,0 +1,78 @@ +/** + * @author jdiaz5513 + */ +/** + * Compute the Hamming weight (number of bits set to 1) of a number. Used to figure out how many bytes follow a tag byte + * while computing the size of a packed message. + * + * WARNING: Using this with floating point numbers will void your warranty. + * + * @param {number} x A real integer. + * @returns {number} The hamming weight (integer). + */ +export declare function getHammingWeight(x: number): number; +export declare type byte = number; +/** + * Compute the tag byte from the 8 bytes of a 64-bit word. + * + * @param {byte} a The first byte. + * @param {byte} b The second byte. + * @param {byte} c The third byte. + * @param {byte} d The fourth byte. + * @param {byte} e The fifth byte. + * @param {byte} f The sixth byte. + * @param {byte} g The seventh byte. + * @param {byte} h The eighth byte (phew!). + * @returns {number} The tag byte. + */ +export declare function getTagByte(a: byte, b: byte, c: byte, d: byte, e: byte, f: byte, g: byte, h: byte): number; +/** + * Efficiently calculate the length of a packed Cap'n Proto message. + * + * @export + * @param {ArrayBuffer} packed The packed message. + * @returns {number} The length of the unpacked message in bytes. + */ +export declare function getUnpackedByteLength(packed: ArrayBuffer): number; +/** + * Compute the number of zero bytes that occur in a given 64-bit word, provided as eight separate bytes. + * + * @param {byte} a The first byte. + * @param {byte} b The second byte. + * @param {byte} c The third byte. + * @param {byte} d The fourth byte. + * @param {byte} e The fifth byte. + * @param {byte} f The sixth byte. + * @param {byte} g The seventh byte. + * @param {byte} h The eighth byte (phew!). + * @returns {number} The number of these bytes that are zero. + */ +export declare function getZeroByteCount(a: byte, b: byte, c: byte, d: byte, e: byte, f: byte, g: byte, h: byte): number; +/** + * Pack a section of a Cap'n Proto message into a compressed format. This will efficiently compress zero bytes (which + * are common in idiomatic Cap'n Proto messages) into a compact form. + * + * For stream-framed messages this is called once for the frame header and once again for each segment in the message. + * + * The returned array buffer is trimmed to the exact size of the packed message with a single copy operation at the end. + * This should be decent on CPU time but does require quite a lot of memory (a normal array is filled up with each + * packed byte until the packing is complete). + * + * @export + * @param {ArrayBuffer} unpacked The message to pack. + * @param {number} [byteOffset] Starting byte offset to read bytes from, defaults to 0. + * @param {number} [byteLength] Total number of bytes to read, defaults to the remainder of the buffer contents. + * @returns {ArrayBuffer} A packed version of the message. + */ +export declare function pack(unpacked: ArrayBuffer, byteOffset?: number, byteLength?: number): ArrayBuffer; +/** + * Unpack a compressed Cap'n Proto message into a new ArrayBuffer. + * + * Unlike the `pack` function, this is able to efficiently determine the exact size needed for the output buffer and + * runs considerably more efficiently. + * + * @export + * @param {ArrayBuffer} packed An array buffer containing the packed message. + * @returns {ArrayBuffer} The unpacked message. + */ +export declare function unpack(packed: ArrayBuffer): ArrayBuffer; diff --git a/node_modules/capnp-ts/src/serialization/packing.js b/node_modules/capnp-ts/src/serialization/packing.js new file mode 100644 index 0000000000000000000000000000000000000000..ac359d31428875b2d567c36255fd00426e7704a6 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/packing.js @@ -0,0 +1,274 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.unpack = exports.pack = exports.getZeroByteCount = exports.getUnpackedByteLength = exports.getTagByte = exports.getHammingWeight = void 0; +const constants_1 = require("../constants"); +const errors_1 = require("../errors"); +/** + * Compute the Hamming weight (number of bits set to 1) of a number. Used to figure out how many bytes follow a tag byte + * while computing the size of a packed message. + * + * WARNING: Using this with floating point numbers will void your warranty. + * + * @param {number} x A real integer. + * @returns {number} The hamming weight (integer). + */ +function getHammingWeight(x) { + // Thanks, HACKMEM! + let w = x - ((x >> 1) & 0x55555555); + w = (w & 0x33333333) + ((w >> 2) & 0x33333333); + return (((w + (w >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24; +} +exports.getHammingWeight = getHammingWeight; +/** + * Compute the tag byte from the 8 bytes of a 64-bit word. + * + * @param {byte} a The first byte. + * @param {byte} b The second byte. + * @param {byte} c The third byte. + * @param {byte} d The fourth byte. + * @param {byte} e The fifth byte. + * @param {byte} f The sixth byte. + * @param {byte} g The seventh byte. + * @param {byte} h The eighth byte (phew!). + * @returns {number} The tag byte. + */ +function getTagByte(a, b, c, d, e, f, g, h) { + // Yes, it's pretty. Don't touch it. + return ((a === 0 ? 0 : 0b00000001) | + (b === 0 ? 0 : 0b00000010) | + (c === 0 ? 0 : 0b00000100) | + (d === 0 ? 0 : 0b00001000) | + (e === 0 ? 0 : 0b00010000) | + (f === 0 ? 0 : 0b00100000) | + (g === 0 ? 0 : 0b01000000) | + (h === 0 ? 0 : 0b10000000)); +} +exports.getTagByte = getTagByte; +/** + * Efficiently calculate the length of a packed Cap'n Proto message. + * + * @export + * @param {ArrayBuffer} packed The packed message. + * @returns {number} The length of the unpacked message in bytes. + */ +function getUnpackedByteLength(packed) { + const p = new Uint8Array(packed); + let wordLength = 0; + let lastTag = 0x77; + for (let i = 0; i < p.byteLength;) { + const tag = p[i]; + if (lastTag === 0 /* ZERO */) { + wordLength += tag; + i++; + lastTag = 0x77; + } + else if (lastTag === 255 /* SPAN */) { + wordLength += tag; + i += tag * 8 + 1; + lastTag = 0x77; + } + else { + wordLength++; + i += getHammingWeight(tag) + 1; + lastTag = tag; + } + } + return wordLength * 8; +} +exports.getUnpackedByteLength = getUnpackedByteLength; +/** + * Compute the number of zero bytes that occur in a given 64-bit word, provided as eight separate bytes. + * + * @param {byte} a The first byte. + * @param {byte} b The second byte. + * @param {byte} c The third byte. + * @param {byte} d The fourth byte. + * @param {byte} e The fifth byte. + * @param {byte} f The sixth byte. + * @param {byte} g The seventh byte. + * @param {byte} h The eighth byte (phew!). + * @returns {number} The number of these bytes that are zero. + */ +function getZeroByteCount(a, b, c, d, e, f, g, h) { + return ((a === 0 ? 1 : 0) + + (b === 0 ? 1 : 0) + + (c === 0 ? 1 : 0) + + (d === 0 ? 1 : 0) + + (e === 0 ? 1 : 0) + + (f === 0 ? 1 : 0) + + (g === 0 ? 1 : 0) + + (h === 0 ? 1 : 0)); +} +exports.getZeroByteCount = getZeroByteCount; +/** + * Pack a section of a Cap'n Proto message into a compressed format. This will efficiently compress zero bytes (which + * are common in idiomatic Cap'n Proto messages) into a compact form. + * + * For stream-framed messages this is called once for the frame header and once again for each segment in the message. + * + * The returned array buffer is trimmed to the exact size of the packed message with a single copy operation at the end. + * This should be decent on CPU time but does require quite a lot of memory (a normal array is filled up with each + * packed byte until the packing is complete). + * + * @export + * @param {ArrayBuffer} unpacked The message to pack. + * @param {number} [byteOffset] Starting byte offset to read bytes from, defaults to 0. + * @param {number} [byteLength] Total number of bytes to read, defaults to the remainder of the buffer contents. + * @returns {ArrayBuffer} A packed version of the message. + */ +function pack(unpacked, byteOffset = 0, byteLength) { + if (unpacked.byteLength % 8 !== 0) + throw new Error(errors_1.MSG_PACK_NOT_WORD_ALIGNED); + const src = new Uint8Array(unpacked, byteOffset, byteLength); + // TODO: Maybe we should do this with buffers? This costs more than 8x the final compressed size in temporary RAM. + const dst = []; + /* Just have to be sure it's neither ZERO nor SPAN. */ + let lastTag = 0x77; + /** This is where we need to remember to write the SPAN tag (0xff). */ + let spanTagOffset = NaN; + /** How many words have been copied during the current span. */ + let spanWordLength = 0; + /** + * When this hits zero, we've had PACK_SPAN_THRESHOLD zero bytes pass by and it's time to bail from the span. + */ + let spanThreshold = constants_1.PACK_SPAN_THRESHOLD; + for (let srcByteOffset = 0; srcByteOffset < src.byteLength; srcByteOffset += 8) { + /** Read in the entire word. Yes, this feels silly but it's fast! */ + const a = src[srcByteOffset]; + const b = src[srcByteOffset + 1]; + const c = src[srcByteOffset + 2]; + const d = src[srcByteOffset + 3]; + const e = src[srcByteOffset + 4]; + const f = src[srcByteOffset + 5]; + const g = src[srcByteOffset + 6]; + const h = src[srcByteOffset + 7]; + const tag = getTagByte(a, b, c, d, e, f, g, h); + /** If this is true we'll skip the normal word write logic after the switch statement. */ + let skipWriteWord = true; + switch (lastTag) { + case 0 /* ZERO */: + // We're writing a span of words with all zeroes in them. See if we need to bail out of the fast path. + if (tag !== 0 /* ZERO */ || spanWordLength >= 0xff) { + // There's a bit in there or we got too many zeroes. Damn, we need to bail. + dst.push(spanWordLength); + spanWordLength = 0; + skipWriteWord = false; + } + else { + // Kay, let's quickly inc this and go. + spanWordLength++; + } + break; + case 255 /* SPAN */: { + // We're writing a span of nonzero words. + const zeroCount = getZeroByteCount(a, b, c, d, e, f, g, h); + // See if we need to bail now. + spanThreshold -= zeroCount; + if (spanThreshold <= 0 || spanWordLength >= 0xff) { + // Alright, time to get packing again. Write the number of words we skipped to the beginning of the span. + dst[spanTagOffset] = spanWordLength; + spanWordLength = 0; + spanThreshold = constants_1.PACK_SPAN_THRESHOLD; + // We have to write this word normally. + skipWriteWord = false; + } + else { + // Just write this word verbatim. + dst.push(a, b, c, d, e, f, g, h); + spanWordLength++; + } + break; + } + default: + // Didn't get a special tag last time, let's write this as normal. + skipWriteWord = false; + break; + } + // A goto is fast, idk why people keep hatin'. + if (skipWriteWord) + continue; + dst.push(tag); + lastTag = tag; + if (a !== 0) + dst.push(a); + if (b !== 0) + dst.push(b); + if (c !== 0) + dst.push(c); + if (d !== 0) + dst.push(d); + if (e !== 0) + dst.push(e); + if (f !== 0) + dst.push(f); + if (g !== 0) + dst.push(g); + if (h !== 0) + dst.push(h); + // Record the span tag offset if needed, making sure to actually leave room for it. + if (tag === 255 /* SPAN */) { + spanTagOffset = dst.length; + dst.push(0); + } + } + // We're done. If we were writing a span let's finish it. + if (lastTag === 0 /* ZERO */) { + dst.push(spanWordLength); + } + else if (lastTag === 255 /* SPAN */) { + dst[spanTagOffset] = spanWordLength; + } + return new Uint8Array(dst).buffer; +} +exports.pack = pack; +/** + * Unpack a compressed Cap'n Proto message into a new ArrayBuffer. + * + * Unlike the `pack` function, this is able to efficiently determine the exact size needed for the output buffer and + * runs considerably more efficiently. + * + * @export + * @param {ArrayBuffer} packed An array buffer containing the packed message. + * @returns {ArrayBuffer} The unpacked message. + */ +function unpack(packed) { + // We have no choice but to read the packed buffer one byte at a time. + const src = new Uint8Array(packed); + const dst = new Uint8Array(new ArrayBuffer(getUnpackedByteLength(packed))); + /** The last tag byte that we've seen - it starts at a "neutral" value. */ + let lastTag = 0x77; + for (let srcByteOffset = 0, dstByteOffset = 0; srcByteOffset < src.byteLength;) { + const tag = src[srcByteOffset]; + if (lastTag === 0 /* ZERO */) { + // We have a span of zeroes. New array buffers are guaranteed to be initialized to zero so we just seek ahead. + dstByteOffset += tag * 8; + srcByteOffset++; + lastTag = 0x77; + } + else if (lastTag === 255 /* SPAN */) { + // We have a span of unpacked bytes. Copy them verbatim from the source buffer. + const spanByteLength = tag * 8; + dst.set(src.subarray(srcByteOffset + 1, srcByteOffset + 1 + spanByteLength), dstByteOffset); + dstByteOffset += spanByteLength; + srcByteOffset += 1 + spanByteLength; + lastTag = 0x77; + } + else { + // Okay, a normal tag. Let's read past the tag and copy bytes that have a bit set in the tag. + srcByteOffset++; + for (let i = 1; i <= 0b10000000; i <<= 1) { + // We only need to actually touch `dst` if there's a nonzero byte (it's already initialized to zeroes). + if ((tag & i) !== 0) + dst[dstByteOffset] = src[srcByteOffset++]; + dstByteOffset++; + } + lastTag = tag; + } + } + return dst.buffer; +} +exports.unpack = unpack; +//# sourceMappingURL=packing.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/packing.js.map b/node_modules/capnp-ts/src/serialization/packing.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ce5c80d5420a5bfb6d0fd7a1ea61f06a9841213b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/packing.js.map @@ -0,0 +1 @@ +{"version":3,"file":"packing.js","sourceRoot":"","sources":["packing.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,4CAAmD;AACnD,sCAAsD;AAmCtD;;;;;;;;GAQG;AAEH,SAAgB,gBAAgB,CAAC,CAAS;IACxC,mBAAmB;IAEnB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;IACpC,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC;AAND,4CAMC;AAID;;;;;;;;;;;;GAYG;AAEH,SAAgB,UAAU,CAAC,CAAO,EAAE,CAAO,EAAE,CAAO,EAAE,CAAO,EAAE,CAAO,EAAE,CAAO,EAAE,CAAO,EAAE,CAAO;IAC/F,oCAAoC;IAEpC,OAAO,CACL,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAC1B,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAC1B,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAC1B,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAC1B,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,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,aAAa,EAAE,CAAC;YAEhB,OAAO,GAAG,IAAI,CAAC;SAChB;aAAM,IAAI,OAAO,mBAAmB,EAAE;YACrC,+EAA+E;YAE/E,MAAM,cAAc,GAAG,GAAG,GAAG,CAAC,CAAC;YAE/B,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,GAAG,CAAC,EAAE,aAAa,GAAG,CAAC,GAAG,cAAc,CAAC,EAAE,aAAa,CAAC,CAAC;YAE5F,aAAa,IAAI,cAAc,CAAC;YAChC,aAAa,IAAI,CAAC,GAAG,cAAc,CAAC;YAEpC,OAAO,GAAG,IAAI,CAAC;SAChB;aAAM;YACL,6FAA6F;YAE7F,aAAa,EAAE,CAAC;YAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE;gBACxC,uGAAuG;gBAEvG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC;oBAAE,GAAG,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;gBAE/D,aAAa,EAAE,CAAC;aACjB;YAED,OAAO,GAAG,GAAG,CAAC;SACf;KACF;IAED,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC;AAlDD,wBAkDC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/packing.ts b/node_modules/capnp-ts/src/serialization/packing.ts new file mode 100644 index 0000000000000000000000000000000000000000..31e9b6dc5b06ace7770205e1f944929935f8fd2d --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/packing.ts @@ -0,0 +1,372 @@ +/** + * @author jdiaz5513 + */ + +import { PACK_SPAN_THRESHOLD } from "../constants"; +import { MSG_PACK_NOT_WORD_ALIGNED } from "../errors"; + +/** + * When packing a message there are two tags that are interpreted in a special way: `0x00` and `0xff`. + * + * @enum {number} + */ + +const enum PackedTag { + /** + * The tag is followed by a single byte which indicates a count of consecutive zero-valued words, minus 1. E.g. if the + * tag 0x00 is followed by 0x05, the sequence unpacks to 6 words of zero. + * + * Or, put another way: the tag is first decoded as if it were not special. Since none of the bits are set, it is + * followed by no bytes and expands to a word full of zeros. After that, the next byte is interpreted as a count of + * additional words that are also all-zero. + */ + + ZERO = 0x00, + + /** + * The tag is followed by the bytes of the word (as if it weren’t special), but after those bytes is another byte with + * value N. Following that byte is N unpacked words that should be copied directly. + * + * These unpacked words may contain zeroes; in this implementation a minimum of PACK_SPAN_THRESHOLD zero bytes are + * written before ending the span. + * + * The purpose of this rule is to minimize the impact of packing on data that doesn’t contain any zeros – in + * particular, long text blobs. Because of this rule, the worst-case space overhead of packing is 2 bytes per 2 KiB of + * input (256 words = 2KiB). + */ + + SPAN = 0xff, +} + +/** + * Compute the Hamming weight (number of bits set to 1) of a number. Used to figure out how many bytes follow a tag byte + * while computing the size of a packed message. + * + * WARNING: Using this with floating point numbers will void your warranty. + * + * @param {number} x A real integer. + * @returns {number} The hamming weight (integer). + */ + +export function getHammingWeight(x: number): number { + // Thanks, HACKMEM! + + let w = x - ((x >> 1) & 0x55555555); + w = (w & 0x33333333) + ((w >> 2) & 0x33333333); + return (((w + (w >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24; +} + +export type byte = number; + +/** + * Compute the tag byte from the 8 bytes of a 64-bit word. + * + * @param {byte} a The first byte. + * @param {byte} b The second byte. + * @param {byte} c The third byte. + * @param {byte} d The fourth byte. + * @param {byte} e The fifth byte. + * @param {byte} f The sixth byte. + * @param {byte} g The seventh byte. + * @param {byte} h The eighth byte (phew!). + * @returns {number} The tag byte. + */ + +export function getTagByte(a: byte, b: byte, c: byte, d: byte, e: byte, f: byte, g: byte, h: byte): number { + // Yes, it's pretty. Don't touch it. + + return ( + (a === 0 ? 0 : 0b00000001) | + (b === 0 ? 0 : 0b00000010) | + (c === 0 ? 0 : 0b00000100) | + (d === 0 ? 0 : 0b00001000) | + (e === 0 ? 0 : 0b00010000) | + (f === 0 ? 0 : 0b00100000) | + (g === 0 ? 0 : 0b01000000) | + (h === 0 ? 0 : 0b10000000) + ); +} + +/** + * Efficiently calculate the length of a packed Cap'n Proto message. + * + * @export + * @param {ArrayBuffer} packed The packed message. + * @returns {number} The length of the unpacked message in bytes. + */ + +export function getUnpackedByteLength(packed: ArrayBuffer): number { + const p = new Uint8Array(packed); + let wordLength = 0; + let lastTag = 0x77; + + for (let i = 0; i < p.byteLength; ) { + const tag = p[i]; + + if (lastTag === PackedTag.ZERO) { + wordLength += tag; + + i++; + + lastTag = 0x77; + } else if (lastTag === PackedTag.SPAN) { + wordLength += tag; + + i += tag * 8 + 1; + + lastTag = 0x77; + } else { + wordLength++; + + i += getHammingWeight(tag) + 1; + + lastTag = tag; + } + } + + return wordLength * 8; +} + +/** + * Compute the number of zero bytes that occur in a given 64-bit word, provided as eight separate bytes. + * + * @param {byte} a The first byte. + * @param {byte} b The second byte. + * @param {byte} c The third byte. + * @param {byte} d The fourth byte. + * @param {byte} e The fifth byte. + * @param {byte} f The sixth byte. + * @param {byte} g The seventh byte. + * @param {byte} h The eighth byte (phew!). + * @returns {number} The number of these bytes that are zero. + */ + +export function getZeroByteCount(a: byte, b: byte, c: byte, d: byte, e: byte, f: byte, g: byte, h: byte): number { + return ( + (a === 0 ? 1 : 0) + + (b === 0 ? 1 : 0) + + (c === 0 ? 1 : 0) + + (d === 0 ? 1 : 0) + + (e === 0 ? 1 : 0) + + (f === 0 ? 1 : 0) + + (g === 0 ? 1 : 0) + + (h === 0 ? 1 : 0) + ); +} + +/** + * Pack a section of a Cap'n Proto message into a compressed format. This will efficiently compress zero bytes (which + * are common in idiomatic Cap'n Proto messages) into a compact form. + * + * For stream-framed messages this is called once for the frame header and once again for each segment in the message. + * + * The returned array buffer is trimmed to the exact size of the packed message with a single copy operation at the end. + * This should be decent on CPU time but does require quite a lot of memory (a normal array is filled up with each + * packed byte until the packing is complete). + * + * @export + * @param {ArrayBuffer} unpacked The message to pack. + * @param {number} [byteOffset] Starting byte offset to read bytes from, defaults to 0. + * @param {number} [byteLength] Total number of bytes to read, defaults to the remainder of the buffer contents. + * @returns {ArrayBuffer} A packed version of the message. + */ + +export function pack(unpacked: ArrayBuffer, byteOffset = 0, byteLength?: number): ArrayBuffer { + if (unpacked.byteLength % 8 !== 0) throw new Error(MSG_PACK_NOT_WORD_ALIGNED); + + const src = new Uint8Array(unpacked, byteOffset, byteLength); + + // TODO: Maybe we should do this with buffers? This costs more than 8x the final compressed size in temporary RAM. + + const dst: number[] = []; + + /* Just have to be sure it's neither ZERO nor SPAN. */ + + let lastTag = 0x77; + + /** This is where we need to remember to write the SPAN tag (0xff). */ + + let spanTagOffset = NaN; + + /** How many words have been copied during the current span. */ + + let spanWordLength = 0; + + /** + * When this hits zero, we've had PACK_SPAN_THRESHOLD zero bytes pass by and it's time to bail from the span. + */ + + let spanThreshold = PACK_SPAN_THRESHOLD; + + for (let srcByteOffset = 0; srcByteOffset < src.byteLength; srcByteOffset += 8) { + /** Read in the entire word. Yes, this feels silly but it's fast! */ + + const a = src[srcByteOffset]; + const b = src[srcByteOffset + 1]; + const c = src[srcByteOffset + 2]; + const d = src[srcByteOffset + 3]; + const e = src[srcByteOffset + 4]; + const f = src[srcByteOffset + 5]; + const g = src[srcByteOffset + 6]; + const h = src[srcByteOffset + 7]; + + const tag = getTagByte(a, b, c, d, e, f, g, h); + + /** If this is true we'll skip the normal word write logic after the switch statement. */ + + let skipWriteWord = true; + + switch (lastTag) { + case PackedTag.ZERO: + // We're writing a span of words with all zeroes in them. See if we need to bail out of the fast path. + + if (tag !== PackedTag.ZERO || spanWordLength >= 0xff) { + // There's a bit in there or we got too many zeroes. Damn, we need to bail. + + dst.push(spanWordLength); + spanWordLength = 0; + + skipWriteWord = false; + } else { + // Kay, let's quickly inc this and go. + + spanWordLength++; + } + + break; + + case PackedTag.SPAN: { + // We're writing a span of nonzero words. + + const zeroCount = getZeroByteCount(a, b, c, d, e, f, g, h); + + // See if we need to bail now. + + spanThreshold -= zeroCount; + + if (spanThreshold <= 0 || spanWordLength >= 0xff) { + // Alright, time to get packing again. Write the number of words we skipped to the beginning of the span. + + dst[spanTagOffset] = spanWordLength; + spanWordLength = 0; + + spanThreshold = PACK_SPAN_THRESHOLD; + + // We have to write this word normally. + + skipWriteWord = false; + } else { + // Just write this word verbatim. + + dst.push(a, b, c, d, e, f, g, h); + + spanWordLength++; + } + + break; + } + default: + // Didn't get a special tag last time, let's write this as normal. + + skipWriteWord = false; + + break; + } + + // A goto is fast, idk why people keep hatin'. + if (skipWriteWord) continue; + + dst.push(tag); + lastTag = tag; + + if (a !== 0) dst.push(a); + if (b !== 0) dst.push(b); + if (c !== 0) dst.push(c); + if (d !== 0) dst.push(d); + if (e !== 0) dst.push(e); + if (f !== 0) dst.push(f); + if (g !== 0) dst.push(g); + if (h !== 0) dst.push(h); + + // Record the span tag offset if needed, making sure to actually leave room for it. + + if (tag === PackedTag.SPAN) { + spanTagOffset = dst.length; + + dst.push(0); + } + } + + // We're done. If we were writing a span let's finish it. + + if (lastTag === PackedTag.ZERO) { + dst.push(spanWordLength); + } else if (lastTag === PackedTag.SPAN) { + dst[spanTagOffset] = spanWordLength; + } + + return new Uint8Array(dst).buffer; +} + +/** + * Unpack a compressed Cap'n Proto message into a new ArrayBuffer. + * + * Unlike the `pack` function, this is able to efficiently determine the exact size needed for the output buffer and + * runs considerably more efficiently. + * + * @export + * @param {ArrayBuffer} packed An array buffer containing the packed message. + * @returns {ArrayBuffer} The unpacked message. + */ + +export function unpack(packed: ArrayBuffer): ArrayBuffer { + // We have no choice but to read the packed buffer one byte at a time. + + const src = new Uint8Array(packed); + const dst = new Uint8Array(new ArrayBuffer(getUnpackedByteLength(packed))); + + /** The last tag byte that we've seen - it starts at a "neutral" value. */ + + let lastTag = 0x77; + + for (let srcByteOffset = 0, dstByteOffset = 0; srcByteOffset < src.byteLength; ) { + const tag = src[srcByteOffset]; + + if (lastTag === PackedTag.ZERO) { + // We have a span of zeroes. New array buffers are guaranteed to be initialized to zero so we just seek ahead. + + dstByteOffset += tag * 8; + + srcByteOffset++; + + lastTag = 0x77; + } else if (lastTag === PackedTag.SPAN) { + // We have a span of unpacked bytes. Copy them verbatim from the source buffer. + + const spanByteLength = tag * 8; + + dst.set(src.subarray(srcByteOffset + 1, srcByteOffset + 1 + spanByteLength), dstByteOffset); + + dstByteOffset += spanByteLength; + srcByteOffset += 1 + spanByteLength; + + lastTag = 0x77; + } else { + // Okay, a normal tag. Let's read past the tag and copy bytes that have a bit set in the tag. + + srcByteOffset++; + + for (let i = 1; i <= 0b10000000; i <<= 1) { + // We only need to actually touch `dst` if there's a nonzero byte (it's already initialized to zeroes). + + if ((tag & i) !== 0) dst[dstByteOffset] = src[srcByteOffset++]; + + dstByteOffset++; + } + + lastTag = tag; + } + } + + return dst.buffer; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..742faf14ab642bfa2b47588ff393fcbbf26b6db4 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.d.ts @@ -0,0 +1,6 @@ +/** + * @author jdiaz5513 + */ +import { ListCtor } from "./list"; +import { Pointer } from "./pointer"; +export declare const AnyPointerList: ListCtor; diff --git a/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.js b/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.js new file mode 100644 index 0000000000000000000000000000000000000000..cfc67c2ea95ce723757ee0154dce5a40b30f52f5 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.js @@ -0,0 +1,10 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AnyPointerList = void 0; +const pointer_1 = require("./pointer"); +const pointer_list_1 = require("./pointer-list"); +exports.AnyPointerList = pointer_list_1.PointerList(pointer_1.Pointer); +//# sourceMappingURL=any-pointer-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3338c884b00d87f9b73921a2b8489a6bd3b46a57 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/any-pointer-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"any-pointer-list.js","sourceRoot":"","sources":["any-pointer-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAGH,uCAAoC;AACpC,iDAA6C;AAEhC,QAAA,cAAc,GAAsB,0BAAW,CAAC,iBAAO,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/bool-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/bool-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a6548fd3698e3ddbe6e4667e189cb0cd411d319 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/bool-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class BoolList extends List { + static readonly _capnp: _ListCtor; + get(index: number): boolean; + set(index: number, value: boolean): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/bool-list.js b/node_modules/capnp-ts/src/serialization/pointers/bool-list.js new file mode 100644 index 0000000000000000000000000000000000000000..e9ff3ca76f674b94a8bf001078f86ebc18a72726 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/bool-list.js @@ -0,0 +1,38 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BoolList = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class BoolList extends list_1.List { + get(index) { + const bitMask = 1 << index % 8; + const byteOffset = index >>> 3; + const c = pointer_1.getContent(this); + const v = c.segment.getUint8(c.byteOffset + byteOffset); + return (v & bitMask) !== 0; + } + set(index, value) { + const bitMask = 1 << index % 8; + const c = pointer_1.getContent(this); + const byteOffset = c.byteOffset + (index >>> 3); + const v = c.segment.getUint8(byteOffset); + c.segment.setUint8(byteOffset, value ? v | bitMask : v & ~bitMask); + } + toString() { + return `Bool_${super.toString()}`; + } +} +exports.BoolList = BoolList; +BoolList._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BIT +}; +//# sourceMappingURL=bool-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/bool-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/bool-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c280878a024580ef1d99c9f4bba0d92e416e6de4 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/bool-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bool-list.js","sourceRoot":"","sources":["bool-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,QAAS,SAAQ,WAAa;IAMzC,GAAG,CAAC,KAAa;QACf,MAAM,OAAO,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;QAC/B,MAAM,UAAU,GAAG,KAAK,KAAK,CAAC,CAAC;QAC/B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC;QAExD,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAc;QAC/B,MAAM,OAAO,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,UAAU,GAAG,CAAC,CAAC,UAAU,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEzC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,QAAQ;QACN,OAAO,QAAQ,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACpC,CAAC;;AA1BH,4BA2BC;AA1BiB,eAAM,GAAc;IAClC,WAAW,EAAE,eAAyB;IACtC,IAAI,EAAE,mCAAe,CAAC,GAAG;CAC1B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/bool-list.ts b/node_modules/capnp-ts/src/serialization/pointers/bool-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..26836bcc605d4af5773e6120c02b03e893e5d533 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/bool-list.ts @@ -0,0 +1,41 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class BoolList extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.BIT + }; + + get(index: number): boolean { + const bitMask = 1 << index % 8; + const byteOffset = index >>> 3; + const c = getContent(this); + const v = c.segment.getUint8(c.byteOffset + byteOffset); + + return (v & bitMask) !== 0; + } + + set(index: number, value: boolean): void { + const bitMask = 1 << index % 8; + const c = getContent(this); + const byteOffset = c.byteOffset + (index >>> 3); + const v = c.segment.getUint8(byteOffset); + + c.segment.setUint8(byteOffset, value ? v | bitMask : v & ~bitMask); + } + + toString(): string { + return `Bool_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/composite-list.js b/node_modules/capnp-ts/src/serialization/pointers/composite-list.js new file mode 100644 index 0000000000000000000000000000000000000000..5e831177b38940cb08274e4b21b8e902a11a6a17 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/composite-list.js @@ -0,0 +1,35 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CompositeList = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +function CompositeList(CompositeClass) { + var _a; + return _a = class extends list_1.List { + get(index) { + return new CompositeClass(this.segment, this.byteOffset, this._capnp.depthLimit - 1, index); + } + set(index, value) { + pointer_1.copyFrom(value, this.get(index)); + } + toString() { + return `Composite_${super.toString()},cls:${CompositeClass.toString()}`; + } + }, + _a._capnp = { + compositeSize: CompositeClass._capnp.size, + displayName: `List<${CompositeClass._capnp.displayName}>`, + size: list_element_size_1.ListElementSize.COMPOSITE, + }, + _a; +} +exports.CompositeList = CompositeList; +//# sourceMappingURL=composite-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/composite-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/composite-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..359c5e621483a8a835c5a34bc681b13e17d94fc5 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/composite-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"composite-list.js","sourceRoot":"","sources":["composite-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAmD;AAEnD,uCAAqC;AAErC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,SAAgB,aAAa,CAAmB,cAA6B;;IAC3E,YAAO,KAAM,SAAQ,WAAO;YAO1B,GAAG,CAAC,KAAa;gBACf,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;YAC9F,CAAC;YAED,GAAG,CAAC,KAAa,EAAE,KAAQ;gBACzB,kBAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YACnC,CAAC;YAED,QAAQ;gBACN,OAAO,aAAa,KAAK,CAAC,QAAQ,EAAE,QAAQ,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC1E,CAAC;SACF;QAjBiB,SAAM,GAAc;YAClC,aAAa,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI;YACzC,WAAW,EAAE,QAAQ,cAAc,CAAC,MAAM,CAAC,WAAW,GAAG;YACzD,IAAI,EAAE,mCAAe,CAAC,SAAS;SAC/B;WAaF;AACJ,CAAC;AApBD,sCAoBC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/composite-list.ts b/node_modules/capnp-ts/src/serialization/pointers/composite-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..6338244c1f1b2f8b4a62a90c20191e7a9b23e4bf --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/composite-list.ts @@ -0,0 +1,35 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List, ListCtor } from "./list"; +import { Struct, StructCtor } from "./struct"; +import { copyFrom } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export function CompositeList(CompositeClass: StructCtor): ListCtor { + return class extends List { + static readonly _capnp: _ListCtor = { + compositeSize: CompositeClass._capnp.size, + displayName: `List<${CompositeClass._capnp.displayName}>`, + size: ListElementSize.COMPOSITE, + }; + + get(index: number): T { + return new CompositeClass(this.segment, this.byteOffset, this._capnp.depthLimit - 1, index); + } + + set(index: number, value: T): void { + copyFrom(value, this.get(index)); + } + + toString(): string { + return `Composite_${super.toString()},cls:${CompositeClass.toString()}`; + } + }; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/data-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/data-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f1381fa5d815c06c52a5c012855293f6cbbe6750 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/data-list.d.ts @@ -0,0 +1,6 @@ +/** + * @author jdiaz5513 + */ +import { Data } from "./data"; +import { ListCtor } from "./list"; +export declare const DataList: ListCtor; diff --git a/node_modules/capnp-ts/src/serialization/pointers/data-list.js b/node_modules/capnp-ts/src/serialization/pointers/data-list.js new file mode 100644 index 0000000000000000000000000000000000000000..62a66cb43b269285cc238c7b9149c3f2ba2d78ba --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/data-list.js @@ -0,0 +1,10 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DataList = void 0; +const data_1 = require("./data"); +const pointer_list_1 = require("./pointer-list"); +exports.DataList = pointer_list_1.PointerList(data_1.Data); +//# sourceMappingURL=data-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/data-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/data-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..aac57621417cc82d6f0d8372ae0bd27a98bc8665 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/data-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"data-list.js","sourceRoot":"","sources":["data-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iCAA8B;AAE9B,iDAA6C;AAEhC,QAAA,QAAQ,GAAmB,0BAAW,CAAC,WAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/data-list.ts b/node_modules/capnp-ts/src/serialization/pointers/data-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..5115de7138ee7d4c2e3def8a64f66184db9e8684 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/data-list.ts @@ -0,0 +1,9 @@ +/** + * @author jdiaz5513 + */ + +import { Data } from "./data"; +import { ListCtor } from "./list"; +import { PointerList } from "./pointer-list"; + +export const DataList: ListCtor = PointerList(Data); diff --git a/node_modules/capnp-ts/src/serialization/pointers/data.d.ts b/node_modules/capnp-ts/src/serialization/pointers/data.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0055412eb85fe85223a8cacc4676f872c1651fec --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/data.d.ts @@ -0,0 +1,67 @@ +/** + * @author jdiaz5513 + */ +import { List } from "./list"; +import { Pointer } from "./pointer"; +/** + * A generic blob of bytes. Can be converted to a DataView or Uint8Array to access its contents using `toDataView()` and + * `toUint8Array()`. Use `copyBuffer()` to copy an entire buffer at once. + * + * @export + * @class Data + * @extends {List} + */ +export declare class Data extends List { + static fromPointer(pointer: Pointer): Data; + protected static _fromPointerUnchecked(pointer: Pointer): Data; + /** + * Copy the contents of `src` into this Data pointer. If `src` is smaller than the length of this pointer then the + * remaining bytes will be zeroed out. Extra bytes in `src` are ignored. + * + * @param {(ArrayBuffer | ArrayBufferView)} src The source buffer. + * @returns {void} + */ + copyBuffer(src: ArrayBuffer | ArrayBufferView): void; + /** + * Read a byte from the specified offset. + * + * @param {number} byteOffset The byte offset to read. + * @returns {number} The byte value. + */ + get(byteOffset: number): number; + /** + * Write a byte at the specified offset. + * + * @param {number} byteOffset The byte offset to set. + * @param {number} value The byte value to set. + * @returns {void} + */ + set(byteOffset: number, value: number): void; + /** + * Creates a **copy** of the underlying buffer data and returns it as an ArrayBuffer. + * + * To obtain a reference to the underlying buffer instead, use `toUint8Array()` or `toDataView()`. + * + * @returns {ArrayBuffer} A copy of this data buffer. + */ + toArrayBuffer(): ArrayBuffer; + /** + * Convert this Data pointer to a DataView representing the pointer's contents. + * + * WARNING: The DataView references memory from a message segment, so do not venture outside the bounds of the + * DataView or else BAD THINGS. + * + * @returns {DataView} A live reference to the underlying buffer. + */ + toDataView(): DataView; + toString(): string; + /** + * Convert this Data pointer to a Uint8Array representing the pointer's contents. + * + * WARNING: The Uint8Array references memory from a message segment, so do not venture outside the bounds of the + * Uint8Array or else BAD THINGS. + * + * @returns {DataView} A live reference to the underlying buffer. + */ + toUint8Array(): Uint8Array; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/data.js b/node_modules/capnp-ts/src/serialization/pointers/data.js new file mode 100644 index 0000000000000000000000000000000000000000..6ea484dc619e021fc43f08369dfd98f2f9437e2a --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/data.js @@ -0,0 +1,118 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Data = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const pointer_type_1 = require("./pointer-type"); +const trace = debug_1.default("capnp:data"); +trace("load"); +/** + * A generic blob of bytes. Can be converted to a DataView or Uint8Array to access its contents using `toDataView()` and + * `toUint8Array()`. Use `copyBuffer()` to copy an entire buffer at once. + * + * @export + * @class Data + * @extends {List} + */ +class Data extends list_1.List { + static fromPointer(pointer) { + pointer_1.validate(pointer_type_1.PointerType.LIST, pointer, list_element_size_1.ListElementSize.BYTE); + return this._fromPointerUnchecked(pointer); + } + static _fromPointerUnchecked(pointer) { + return new this(pointer.segment, pointer.byteOffset, pointer._capnp.depthLimit); + } + /** + * Copy the contents of `src` into this Data pointer. If `src` is smaller than the length of this pointer then the + * remaining bytes will be zeroed out. Extra bytes in `src` are ignored. + * + * @param {(ArrayBuffer | ArrayBufferView)} src The source buffer. + * @returns {void} + */ + // TODO: Would be nice to have a way to zero-copy a buffer by allocating a new segment into the message with that + // buffer data. + copyBuffer(src) { + const c = pointer_1.getContent(this); + const dstLength = this.getLength(); + const srcLength = src.byteLength; + const i = src instanceof ArrayBuffer + ? new Uint8Array(src) + : new Uint8Array(src.buffer, src.byteOffset, Math.min(dstLength, srcLength)); + const o = new Uint8Array(c.segment.buffer, c.byteOffset, this.getLength()); + o.set(i); + if (dstLength > srcLength) { + trace("Zeroing out remaining %d bytes after copy into %s.", dstLength - srcLength, this); + o.fill(0, srcLength, dstLength); + } + else if (dstLength < srcLength) { + trace("Truncated %d bytes from source buffer while copying to %s.", srcLength - dstLength, this); + } + } + /** + * Read a byte from the specified offset. + * + * @param {number} byteOffset The byte offset to read. + * @returns {number} The byte value. + */ + get(byteOffset) { + const c = pointer_1.getContent(this); + return c.segment.getUint8(c.byteOffset + byteOffset); + } + /** + * Write a byte at the specified offset. + * + * @param {number} byteOffset The byte offset to set. + * @param {number} value The byte value to set. + * @returns {void} + */ + set(byteOffset, value) { + const c = pointer_1.getContent(this); + c.segment.setUint8(c.byteOffset + byteOffset, value); + } + /** + * Creates a **copy** of the underlying buffer data and returns it as an ArrayBuffer. + * + * To obtain a reference to the underlying buffer instead, use `toUint8Array()` or `toDataView()`. + * + * @returns {ArrayBuffer} A copy of this data buffer. + */ + toArrayBuffer() { + const c = pointer_1.getContent(this); + return c.segment.buffer.slice(c.byteOffset, c.byteOffset + this.getLength()); + } + /** + * Convert this Data pointer to a DataView representing the pointer's contents. + * + * WARNING: The DataView references memory from a message segment, so do not venture outside the bounds of the + * DataView or else BAD THINGS. + * + * @returns {DataView} A live reference to the underlying buffer. + */ + toDataView() { + const c = pointer_1.getContent(this); + return new DataView(c.segment.buffer, c.byteOffset, this.getLength()); + } + toString() { + return `Data_${super.toString()}`; + } + /** + * Convert this Data pointer to a Uint8Array representing the pointer's contents. + * + * WARNING: The Uint8Array references memory from a message segment, so do not venture outside the bounds of the + * Uint8Array or else BAD THINGS. + * + * @returns {DataView} A live reference to the underlying buffer. + */ + toUint8Array() { + const c = pointer_1.getContent(this); + return new Uint8Array(c.segment.buffer, c.byteOffset, this.getLength()); + } +} +exports.Data = Data; +//# sourceMappingURL=data.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/data.js.map b/node_modules/capnp-ts/src/serialization/pointers/data.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d7d2a8017588a311436dba6cb069c57524d5c445 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/data.js.map @@ -0,0 +1 @@ +{"version":3,"file":"data.js","sourceRoot":"","sources":["data.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAA8B;AAC9B,uCAA0D;AAC1D,iDAA6C;AAE7C,MAAM,KAAK,GAAG,eAAS,CAAC,YAAY,CAAC,CAAC;AACtC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd;;;;;;;GAOG;AAEH,MAAa,IAAK,SAAQ,WAAY;IACpC,MAAM,CAAC,WAAW,CAAC,OAAgB;QACjC,kBAAQ,CAAC,0BAAW,CAAC,IAAI,EAAE,OAAO,EAAE,mCAAe,CAAC,IAAI,CAAC,CAAC;QAE1D,OAAO,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IAES,MAAM,CAAC,qBAAqB,CAAC,OAAgB;QACrD,OAAO,IAAI,IAAI,CACb,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,MAAM,CAAC,UAAU,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IAEH,iHAAiH;IACjH,eAAe;IAEf,UAAU,CAAC,GAAkC;QAC3C,MAAM,CAAC,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CAAC,UAAU,GAAG,UAAU,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;OAMG;IAEH,aAAa;QACX,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAC3B,CAAC,CAAC,UAAU,EACZ,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,CAChC,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IAEH,UAAU;QACR,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,QAAQ;QACN,OAAO,QAAQ,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IAEH,YAAY;QACV,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF;AAtID,oBAsIC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/data.ts b/node_modules/capnp-ts/src/serialization/pointers/data.ts new file mode 100644 index 0000000000000000000000000000000000000000..bec7df1016ec8645c476ff1d1638042c93d91296 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/data.ts @@ -0,0 +1,158 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { List } from "./list"; +import { Pointer, validate, getContent } from "./pointer"; +import { PointerType } from "./pointer-type"; + +const trace = initTrace("capnp:data"); +trace("load"); + +/** + * A generic blob of bytes. Can be converted to a DataView or Uint8Array to access its contents using `toDataView()` and + * `toUint8Array()`. Use `copyBuffer()` to copy an entire buffer at once. + * + * @export + * @class Data + * @extends {List} + */ + +export class Data extends List { + static fromPointer(pointer: Pointer): Data { + validate(PointerType.LIST, pointer, ListElementSize.BYTE); + + return this._fromPointerUnchecked(pointer); + } + + protected static _fromPointerUnchecked(pointer: Pointer): Data { + return new this( + pointer.segment, + pointer.byteOffset, + pointer._capnp.depthLimit + ); + } + + /** + * Copy the contents of `src` into this Data pointer. If `src` is smaller than the length of this pointer then the + * remaining bytes will be zeroed out. Extra bytes in `src` are ignored. + * + * @param {(ArrayBuffer | ArrayBufferView)} src The source buffer. + * @returns {void} + */ + + // TODO: Would be nice to have a way to zero-copy a buffer by allocating a new segment into the message with that + // buffer data. + + copyBuffer(src: ArrayBuffer | ArrayBufferView): void { + const c = getContent(this); + + const dstLength = this.getLength(); + const srcLength = src.byteLength; + + const i = + src instanceof ArrayBuffer + ? new Uint8Array(src) + : new Uint8Array( + src.buffer, + src.byteOffset, + Math.min(dstLength, srcLength) + ); + + const o = new Uint8Array(c.segment.buffer, c.byteOffset, this.getLength()); + + o.set(i); + + if (dstLength > srcLength) { + trace( + "Zeroing out remaining %d bytes after copy into %s.", + dstLength - srcLength, + this + ); + + o.fill(0, srcLength, dstLength); + } else if (dstLength < srcLength) { + trace( + "Truncated %d bytes from source buffer while copying to %s.", + srcLength - dstLength, + this + ); + } + } + + /** + * Read a byte from the specified offset. + * + * @param {number} byteOffset The byte offset to read. + * @returns {number} The byte value. + */ + + get(byteOffset: number): number { + const c = getContent(this); + return c.segment.getUint8(c.byteOffset + byteOffset); + } + + /** + * Write a byte at the specified offset. + * + * @param {number} byteOffset The byte offset to set. + * @param {number} value The byte value to set. + * @returns {void} + */ + + set(byteOffset: number, value: number): void { + const c = getContent(this); + c.segment.setUint8(c.byteOffset + byteOffset, value); + } + + /** + * Creates a **copy** of the underlying buffer data and returns it as an ArrayBuffer. + * + * To obtain a reference to the underlying buffer instead, use `toUint8Array()` or `toDataView()`. + * + * @returns {ArrayBuffer} A copy of this data buffer. + */ + + toArrayBuffer(): ArrayBuffer { + const c = getContent(this); + return c.segment.buffer.slice( + c.byteOffset, + c.byteOffset + this.getLength() + ); + } + + /** + * Convert this Data pointer to a DataView representing the pointer's contents. + * + * WARNING: The DataView references memory from a message segment, so do not venture outside the bounds of the + * DataView or else BAD THINGS. + * + * @returns {DataView} A live reference to the underlying buffer. + */ + + toDataView(): DataView { + const c = getContent(this); + return new DataView(c.segment.buffer, c.byteOffset, this.getLength()); + } + + toString(): string { + return `Data_${super.toString()}`; + } + + /** + * Convert this Data pointer to a Uint8Array representing the pointer's contents. + * + * WARNING: The Uint8Array references memory from a message segment, so do not venture outside the bounds of the + * Uint8Array or else BAD THINGS. + * + * @returns {DataView} A live reference to the underlying buffer. + */ + + toUint8Array(): Uint8Array { + const c = getContent(this); + return new Uint8Array(c.segment.buffer, c.byteOffset, this.getLength()); + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/float32-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/float32-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b109a22a4186068764b8848c3620f13479e7fe91 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/float32-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class Float32List extends List { + static readonly _capnp: _ListCtor; + get(index: number): number; + set(index: number, value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/float32-list.js b/node_modules/capnp-ts/src/serialization/pointers/float32-list.js new file mode 100644 index 0000000000000000000000000000000000000000..8c33da12fb8ed1564ff08ef8ef56f32b52dec4b9 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/float32-list.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Float32List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class Float32List extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + return c.segment.getFloat32(c.byteOffset + index * 4); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.segment.setFloat32(c.byteOffset + index * 4, value); + } + toString() { + return `Float32_${super.toString()}`; + } +} +exports.Float32List = Float32List; +Float32List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BYTE_4 +}; +//# sourceMappingURL=float32-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/float32-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/float32-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..dd79ac8ca4a26554f3aec2669f4dfa27b6cb2846 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/float32-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"float32-list.js","sourceRoot":"","sources":["float32-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,WAAY,SAAQ,WAAY;IAM3C,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,QAAQ;QACN,OAAO,WAAW,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACvC,CAAC;;AApBH,kCAqBC;AApBiB,kBAAM,GAAc;IAClC,WAAW,EAAE,eAAyB;IACtC,IAAI,EAAE,mCAAe,CAAC,MAAM;CAC7B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/float64-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/float64-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..877c0f5eda496142f20c21d6d66b0aa4ae2c72b8 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/float64-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class Float64List extends List { + static readonly _capnp: _ListCtor; + get(index: number): number; + set(index: number, value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/float64-list.js b/node_modules/capnp-ts/src/serialization/pointers/float64-list.js new file mode 100644 index 0000000000000000000000000000000000000000..7f681e016dce137b6e4f2694f4a4d53285ea682e --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/float64-list.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Float64List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class Float64List extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + return c.segment.getFloat64(c.byteOffset + index * 8); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.segment.setFloat64(c.byteOffset + index * 8, value); + } + toString() { + return `Float64_${super.toString()}`; + } +} +exports.Float64List = Float64List; +Float64List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BYTE_8 +}; +//# sourceMappingURL=float64-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/float64-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/float64-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f382c12f52844db2c11f7413844077ac5f5d8186 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/float64-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"float64-list.js","sourceRoot":"","sources":["float64-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,WAAY,SAAQ,WAAY;IAM3C,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,QAAQ;QACN,OAAO,WAAW,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACvC,CAAC;;AApBH,kCAqBC;AApBiB,kBAAM,GAAc;IAClC,WAAW,EAAE,eAAyB;IACtC,IAAI,EAAE,mCAAe,CAAC,MAAM;CAC7B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/float64-list.ts b/node_modules/capnp-ts/src/serialization/pointers/float64-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..3dfd4b2864d1f1c7147cf6ba664b68ec7b323740 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/float64-list.ts @@ -0,0 +1,35 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class Float64List extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.BYTE_8 + }; + + get(index: number): number { + const c = getContent(this); + + return c.segment.getFloat64(c.byteOffset + index * 8); + } + + set(index: number, value: number): void { + const c = getContent(this); + + c.segment.setFloat64(c.byteOffset + index * 8, value); + } + + toString(): string { + return `Float64_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/group.d.ts b/node_modules/capnp-ts/src/serialization/pointers/group.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/node_modules/capnp-ts/src/serialization/pointers/group.js.map b/node_modules/capnp-ts/src/serialization/pointers/group.js.map new file mode 100644 index 0000000000000000000000000000000000000000..60a20037a67c6c2271327465191a1b9064fd408c --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/group.js.map @@ -0,0 +1 @@ +{"version":3,"file":"group.js","sourceRoot":"","sources":["group.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/group.ts b/node_modules/capnp-ts/src/serialization/pointers/group.ts new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/node_modules/capnp-ts/src/serialization/pointers/index.js b/node_modules/capnp-ts/src/serialization/pointers/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b5902c978081d2eb6d2b060e5ab673e8c8fe1963 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/index.js @@ -0,0 +1,62 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VoidList = exports.VOID = exports.Void = exports.Uint64List = exports.Uint32List = exports.Uint16List = exports.Uint8List = exports.TextList = exports.Text = exports.Struct = exports.Pointer = exports.PointerType = exports.PointerList = exports.Orphan = exports.List = exports.InterfaceList = exports.Interface = exports.Int64List = exports.Int32List = exports.Int16List = exports.Int8List = exports.Float64List = exports.Float32List = exports.DataList = exports.Data = exports.CompositeList = exports.BoolList = exports.AnyPointerList = void 0; +var any_pointer_list_1 = require("./any-pointer-list"); +Object.defineProperty(exports, "AnyPointerList", { enumerable: true, get: function () { return any_pointer_list_1.AnyPointerList; } }); +var bool_list_1 = require("./bool-list"); +Object.defineProperty(exports, "BoolList", { enumerable: true, get: function () { return bool_list_1.BoolList; } }); +var composite_list_1 = require("./composite-list"); +Object.defineProperty(exports, "CompositeList", { enumerable: true, get: function () { return composite_list_1.CompositeList; } }); +var data_1 = require("./data"); +Object.defineProperty(exports, "Data", { enumerable: true, get: function () { return data_1.Data; } }); +var data_list_1 = require("./data-list"); +Object.defineProperty(exports, "DataList", { enumerable: true, get: function () { return data_list_1.DataList; } }); +var float32_list_1 = require("./float32-list"); +Object.defineProperty(exports, "Float32List", { enumerable: true, get: function () { return float32_list_1.Float32List; } }); +var float64_list_1 = require("./float64-list"); +Object.defineProperty(exports, "Float64List", { enumerable: true, get: function () { return float64_list_1.Float64List; } }); +var int8_list_1 = require("./int8-list"); +Object.defineProperty(exports, "Int8List", { enumerable: true, get: function () { return int8_list_1.Int8List; } }); +var int16_list_1 = require("./int16-list"); +Object.defineProperty(exports, "Int16List", { enumerable: true, get: function () { return int16_list_1.Int16List; } }); +var int32_list_1 = require("./int32-list"); +Object.defineProperty(exports, "Int32List", { enumerable: true, get: function () { return int32_list_1.Int32List; } }); +var int64_list_1 = require("./int64-list"); +Object.defineProperty(exports, "Int64List", { enumerable: true, get: function () { return int64_list_1.Int64List; } }); +var interface_1 = require("./interface"); +Object.defineProperty(exports, "Interface", { enumerable: true, get: function () { return interface_1.Interface; } }); +var interface_list_1 = require("./interface-list"); +Object.defineProperty(exports, "InterfaceList", { enumerable: true, get: function () { return interface_list_1.InterfaceList; } }); +var list_1 = require("./list"); +Object.defineProperty(exports, "List", { enumerable: true, get: function () { return list_1.List; } }); +var orphan_1 = require("./orphan"); +Object.defineProperty(exports, "Orphan", { enumerable: true, get: function () { return orphan_1.Orphan; } }); +var pointer_list_1 = require("./pointer-list"); +Object.defineProperty(exports, "PointerList", { enumerable: true, get: function () { return pointer_list_1.PointerList; } }); +var pointer_type_1 = require("./pointer-type"); +Object.defineProperty(exports, "PointerType", { enumerable: true, get: function () { return pointer_type_1.PointerType; } }); +var pointer_1 = require("./pointer"); +Object.defineProperty(exports, "Pointer", { enumerable: true, get: function () { return pointer_1.Pointer; } }); +var struct_1 = require("./struct"); +Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return struct_1.Struct; } }); +var text_1 = require("./text"); +Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return text_1.Text; } }); +var text_list_1 = require("./text-list"); +Object.defineProperty(exports, "TextList", { enumerable: true, get: function () { return text_list_1.TextList; } }); +var uint8_list_1 = require("./uint8-list"); +Object.defineProperty(exports, "Uint8List", { enumerable: true, get: function () { return uint8_list_1.Uint8List; } }); +var uint16_list_1 = require("./uint16-list"); +Object.defineProperty(exports, "Uint16List", { enumerable: true, get: function () { return uint16_list_1.Uint16List; } }); +var uint32_list_1 = require("./uint32-list"); +Object.defineProperty(exports, "Uint32List", { enumerable: true, get: function () { return uint32_list_1.Uint32List; } }); +var uint64_list_1 = require("./uint64-list"); +Object.defineProperty(exports, "Uint64List", { enumerable: true, get: function () { return uint64_list_1.Uint64List; } }); +var void_1 = require("./void"); +Object.defineProperty(exports, "Void", { enumerable: true, get: function () { return void_1.Void; } }); +Object.defineProperty(exports, "VOID", { enumerable: true, get: function () { return void_1.VOID; } }); +var void_list_1 = require("./void-list"); +Object.defineProperty(exports, "VoidList", { enumerable: true, get: function () { return void_list_1.VoidList; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/index.js.map b/node_modules/capnp-ts/src/serialization/pointers/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..959c7d6f4342ae9b5676cdea37dce77ebbf30e21 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uDAAoD;AAA3C,kHAAA,cAAc,OAAA;AACvB,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AACjB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AACjB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AACjB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,+BAAwC;AAA/B,4FAAA,IAAI,OAAA;AACb,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,mCAA2D;AAArC,gGAAA,MAAM,OAAA;AAC5B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AACjB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,+BAAoC;AAA3B,4FAAA,IAAI,OAAA;AAAE,4FAAA,IAAI,OAAA;AACnB,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/index.ts b/node_modules/capnp-ts/src/serialization/pointers/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a94ada76b013c4d23b2a6edfb966d93bceed6fd --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/index.ts @@ -0,0 +1,31 @@ +/** + * @author jdiaz5513 + */ + +export { AnyPointerList } from "./any-pointer-list"; +export { BoolList } from "./bool-list"; +export { CompositeList } from "./composite-list"; +export { Data } from "./data"; +export { DataList } from "./data-list"; +export { Float32List } from "./float32-list"; +export { Float64List } from "./float64-list"; +export { Int8List } from "./int8-list"; +export { Int16List } from "./int16-list"; +export { Int32List } from "./int32-list"; +export { Int64List } from "./int64-list"; +export { Interface } from "./interface"; +export { InterfaceList } from "./interface-list"; +export { List, ListCtor } from "./list"; +export { Orphan } from "./orphan"; +export { PointerList } from "./pointer-list"; +export { PointerType } from "./pointer-type"; +export { Pointer } from "./pointer"; +export { _StructCtor, Struct, StructCtor } from "./struct"; +export { Text } from "./text"; +export { TextList } from "./text-list"; +export { Uint8List } from "./uint8-list"; +export { Uint16List } from "./uint16-list"; +export { Uint32List } from "./uint32-list"; +export { Uint64List } from "./uint64-list"; +export { Void, VOID } from "./void"; +export { VoidList } from "./void-list"; diff --git a/node_modules/capnp-ts/src/serialization/pointers/int16-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/int16-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..62d4ae8791e44c254c01dae61fc05429e5ef69b2 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int16-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class Int16List extends List { + static readonly _capnp: _ListCtor; + get(index: number): number; + set(index: number, value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/int16-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/int16-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e39e88f1cdcfc03be60dbb3426844c3a91bf7f2d --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int16-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"int16-list.js","sourceRoot":"","sources":["int16-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,SAAU,SAAQ,WAAY;IAMzC,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,QAAQ;QACN,OAAO,SAAS,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACrC,CAAC;;AApBH,8BAqBC;AApBiB,gBAAM,GAAc;IAClC,WAAW,EAAE,aAAuB;IACpC,IAAI,EAAE,mCAAe,CAAC,MAAM;CAC7B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/int16-list.ts b/node_modules/capnp-ts/src/serialization/pointers/int16-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..45ec4a53a793a0c33de354d9332204931cc695a3 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int16-list.ts @@ -0,0 +1,35 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class Int16List extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.BYTE_2 + }; + + get(index: number): number { + const c = getContent(this); + + return c.segment.getInt16(c.byteOffset + index * 2); + } + + set(index: number, value: number): void { + const c = getContent(this); + + c.segment.setInt16(c.byteOffset + index * 2, value); + } + + toString(): string { + return `Int16_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/int32-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/int32-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..56024104c8c36524c33657afbf5cf5195a6fadf2 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int32-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class Int32List extends List { + static readonly _capnp: _ListCtor; + get(index: number): number; + set(index: number, value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/int32-list.js b/node_modules/capnp-ts/src/serialization/pointers/int32-list.js new file mode 100644 index 0000000000000000000000000000000000000000..c41cdf048344dbc05bc39bccd1db3b6e2c9e2f5f --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int32-list.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Int32List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class Int32List extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + return c.segment.getInt32(c.byteOffset + index * 4); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.segment.setInt32(c.byteOffset + index * 4, value); + } + toString() { + return `Int32_${super.toString()}`; + } +} +exports.Int32List = Int32List; +Int32List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BYTE_4 +}; +//# sourceMappingURL=int32-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/int32-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/int32-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ce50721161c40aa6232c92c04d45c003fc682b5b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int32-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"int32-list.js","sourceRoot":"","sources":["int32-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,SAAU,SAAQ,WAAY;IAMzC,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,QAAQ;QACN,OAAO,SAAS,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACrC,CAAC;;AAlBH,8BAmBC;AAlBiB,gBAAM,GAAc;IAClC,WAAW,EAAE,aAAuB;IACpC,IAAI,EAAE,mCAAe,CAAC,MAAM;CAC7B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/int32-list.ts b/node_modules/capnp-ts/src/serialization/pointers/int32-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e65ad27c205274854cc09da76022a1608763eb9 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int32-list.ts @@ -0,0 +1,33 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class Int32List extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.BYTE_4 + }; + + get(index: number): number { + const c = getContent(this); + return c.segment.getInt32(c.byteOffset + index * 4); + } + + set(index: number, value: number): void { + const c = getContent(this); + c.segment.setInt32(c.byteOffset + index * 4, value); + } + + toString(): string { + return `Int32_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/int64-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/int64-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e25d900f861edc2b0107ae73b45736feff3a8a4a --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int64-list.d.ts @@ -0,0 +1,11 @@ +/** + * @author jdiaz5513 + */ +import { Int64 } from "../../types"; +import { _ListCtor, List } from "./list"; +export declare class Int64List extends List { + static readonly _capnp: _ListCtor; + get(index: number): Int64; + set(index: number, value: Int64): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/int64-list.ts b/node_modules/capnp-ts/src/serialization/pointers/int64-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ad12363517a9fcab3995e9a47d390600b5bc01e --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int64-list.ts @@ -0,0 +1,34 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { Int64 } from "../../types"; +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class Int64List extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.BYTE_8, + }; + + get(index: number): Int64 { + const c = getContent(this); + return c.segment.getInt64(c.byteOffset + index * 8); + } + + set(index: number, value: Int64): void { + const c = getContent(this); + c.segment.setInt64(c.byteOffset + index * 8, value); + } + + toString(): string { + return `Int64_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/int8-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/int8-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f35140c26a765b51515b80ec5ce3eaeb3761227d --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int8-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class Int8List extends List { + static readonly _capnp: _ListCtor; + get(index: number): number; + set(index: number, value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/int8-list.js b/node_modules/capnp-ts/src/serialization/pointers/int8-list.js new file mode 100644 index 0000000000000000000000000000000000000000..0da8ec5f4f95d9eeb25a75686f0741c01b92d3d0 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int8-list.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Int8List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class Int8List extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + return c.segment.getInt8(c.byteOffset + index); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.segment.setInt8(c.byteOffset + index, value); + } + toString() { + return `Int8_${super.toString()}`; + } +} +exports.Int8List = Int8List; +Int8List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BYTE +}; +//# sourceMappingURL=int8-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/int8-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/int8-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..42b05a5902935af3fe07f4a5d3506180af0b62ab --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int8-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"int8-list.js","sourceRoot":"","sources":["int8-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,QAAS,SAAQ,WAAY;IAMxC,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,QAAQ;QACN,OAAO,QAAQ,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACpC,CAAC;;AAlBH,4BAmBC;AAlBiB,eAAM,GAAc;IAClC,WAAW,EAAE,YAAsB;IACnC,IAAI,EAAE,mCAAe,CAAC,IAAI;CAC3B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/int8-list.ts b/node_modules/capnp-ts/src/serialization/pointers/int8-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..ccf99eb53efb70497bd78d1657566e2e6959df3b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/int8-list.ts @@ -0,0 +1,33 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class Int8List extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.BYTE + }; + + get(index: number): number { + const c = getContent(this); + return c.segment.getInt8(c.byteOffset + index); + } + + set(index: number, value: number): void { + const c = getContent(this); + c.segment.setInt8(c.byteOffset + index, value); + } + + toString(): string { + return `Int8_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/interface-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/interface-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..982bef3c3c506adb610025cd058b64f4cea04939 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/interface-list.d.ts @@ -0,0 +1,6 @@ +/** + * @author jdiaz5513 + */ +import { Interface } from "./interface"; +import { ListCtor } from "./list"; +export declare const InterfaceList: ListCtor; diff --git a/node_modules/capnp-ts/src/serialization/pointers/interface-list.js b/node_modules/capnp-ts/src/serialization/pointers/interface-list.js new file mode 100644 index 0000000000000000000000000000000000000000..d607915eca6ab0d7a62164741bffd46c2243ec49 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/interface-list.js @@ -0,0 +1,10 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InterfaceList = void 0; +const interface_1 = require("./interface"); +const pointer_list_1 = require("./pointer-list"); +exports.InterfaceList = pointer_list_1.PointerList(interface_1.Interface); +//# sourceMappingURL=interface-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/interface-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/interface-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b439f574555195ed0117b7fc6f4ef8e74b4d64d3 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/interface-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"interface-list.js","sourceRoot":"","sources":["interface-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2CAAwC;AAExC,iDAA6C;AAEhC,QAAA,aAAa,GAAwB,0BAAW,CAAC,qBAAS,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/interface-list.ts b/node_modules/capnp-ts/src/serialization/pointers/interface-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..6dc35c136156c9addfa5da167849eba03162b6d8 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/interface-list.ts @@ -0,0 +1,9 @@ +/** + * @author jdiaz5513 + */ + +import { Interface } from "./interface"; +import { ListCtor } from "./list"; +import { PointerList } from "./pointer-list"; + +export const InterfaceList: ListCtor = PointerList(Interface); diff --git a/node_modules/capnp-ts/src/serialization/pointers/interface.d.ts b/node_modules/capnp-ts/src/serialization/pointers/interface.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..89a3b727394284976e6c5716ebcc75c03dfe955a --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/interface.d.ts @@ -0,0 +1,8 @@ +/** + * @author jdiaz5513 + */ +import { Segment } from "../segment"; +import { Pointer } from "./pointer"; +export declare class Interface extends Pointer { + constructor(segment: Segment, byteOffset: number, depthLimit?: number); +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/interface.js b/node_modules/capnp-ts/src/serialization/pointers/interface.js new file mode 100644 index 0000000000000000000000000000000000000000..d4607e940f61568b88fa922ad66d9bdeaedcd582 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/interface.js @@ -0,0 +1,18 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Interface = void 0; +const constants_1 = require("../../constants"); +const errors_1 = require("../../errors"); +const util_1 = require("../../util"); +const pointer_1 = require("./pointer"); +class Interface extends pointer_1.Pointer { + constructor(segment, byteOffset, depthLimit = constants_1.MAX_DEPTH) { + super(segment, byteOffset, depthLimit); + throw new Error(util_1.format(errors_1.NOT_IMPLEMENTED, "new Interface")); + } +} +exports.Interface = Interface; +//# sourceMappingURL=interface.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/interface.js.map b/node_modules/capnp-ts/src/serialization/pointers/interface.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8d8c1d510342e405cc040512213b9de41e7dacc8 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/interface.js.map @@ -0,0 +1 @@ +{"version":3,"file":"interface.js","sourceRoot":"","sources":["interface.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,+CAA4C;AAC5C,yCAA+C;AAC/C,qCAAoC;AAEpC,uCAAoC;AAEpC,MAAa,SAAU,SAAQ,iBAAO;IACpC,YAAY,OAAgB,EAAE,UAAkB,EAAE,UAAU,GAAG,qBAAS;QACtE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QAEvC,MAAM,IAAI,KAAK,CAAC,aAAM,CAAC,wBAAe,EAAE,eAAe,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF;AAND,8BAMC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/interface.ts b/node_modules/capnp-ts/src/serialization/pointers/interface.ts new file mode 100644 index 0000000000000000000000000000000000000000..b283869c05757e0b9b8797c3cd57cdf6b7e992f5 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/interface.ts @@ -0,0 +1,17 @@ +/** + * @author jdiaz5513 + */ + +import { MAX_DEPTH } from "../../constants"; +import { NOT_IMPLEMENTED } from "../../errors"; +import { format } from "../../util"; +import { Segment } from "../segment"; +import { Pointer } from "./pointer"; + +export class Interface extends Pointer { + constructor(segment: Segment, byteOffset: number, depthLimit = MAX_DEPTH) { + super(segment, byteOffset, depthLimit); + + throw new Error(format(NOT_IMPLEMENTED, "new Interface")); + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bd69fc370749406cb24535c8dbf08df28106620 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/list.d.ts @@ -0,0 +1,76 @@ +/** + * @author jdiaz5513 + */ +import { ListElementSize } from "../list-element-size"; +import { ObjectSize } from "../object-size"; +import { Segment } from "../segment"; +import { Pointer } from "./pointer"; +export interface _ListCtor { + readonly compositeSize?: ObjectSize; + readonly displayName: string; + readonly size: ListElementSize; +} +export interface ListCtor { + readonly _capnp: _ListCtor; + new (segment: Segment, byteOffset: number, depthLimit?: number): List; +} +export declare type FilterCallback = (this: void, value: T, index: number) => boolean; +export declare type IndexedCallback = (this: void, value: T, index: number) => U; +export interface Group { + [k: string]: T; +} +/** + * A generic list class. Implements Filterable, + */ +export declare class List extends Pointer { + static readonly _capnp: _ListCtor; + static readonly get: typeof get; + static readonly initList: typeof initList; + static readonly set: typeof set; + static toString(): string; + all(callbackfn: FilterCallback): boolean; + any(callbackfn: FilterCallback): boolean; + ap(callbackfns: Array>): U[]; + concat(other: List): T[]; + drop(n: number): T[]; + dropWhile(callbackfn: FilterCallback): T[]; + empty(): T[]; + every(callbackfn: FilterCallback): boolean; + filter(callbackfn: FilterCallback): T[]; + find(callbackfn: FilterCallback): T | undefined; + findIndex(callbackfn: FilterCallback): number; + forEach(callbackfn: (this: void, value: T, index: number) => void): void; + get(_index: number): T; + /** + * Get the length of this list. + * + * @returns {number} The number of elements in this list. + */ + getLength(): number; + groupBy(callbackfn: IndexedCallback): Group; + intersperse(sep: T): T[]; + map(callbackfn: IndexedCallback): U[]; + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + set(_index: number, _value: T): void; + slice(start?: number, end?: number): T[]; + some(callbackfn: FilterCallback): boolean; + take(n: number): T[]; + takeWhile(callbackfn: FilterCallback): T[]; + toArray(): T[]; + toString(): string; +} +/** + * Initialize the list with the given element size and length. This will allocate new space for the list, ideally in + * the same segment as this pointer. + * + * @param {ListElementSize} elementSize The size of each element in the list. + * @param {number} length The number of elements in the list. + * @param {List} l The list to initialize. + * @param {ObjectSize} [compositeSize] The size of each element in a composite list. This value is required for + * composite lists. + * @returns {void} + */ +export declare function initList(elementSize: ListElementSize, length: number, l: List, compositeSize?: ObjectSize): void; +export declare function get(_index: number, _l: List): T; +export declare function set(_index: number, _value: T, _l: List): void; diff --git a/node_modules/capnp-ts/src/serialization/pointers/list.js b/node_modules/capnp-ts/src/serialization/pointers/list.js new file mode 100644 index 0000000000000000000000000000000000000000..0e002cd677394d22c118ed80464e0eee1c906461 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/list.js @@ -0,0 +1,274 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.set = exports.get = exports.initList = exports.List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const errors_1 = require("../../errors"); +const util_1 = require("../../util"); +const list_element_size_1 = require("../list-element-size"); +const object_size_1 = require("../object-size"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list"); +trace("load"); +/** + * A generic list class. Implements Filterable, + */ +class List extends pointer_1.Pointer { + static toString() { + return this._capnp.displayName; + } + all(callbackfn) { + const length = this.getLength(); + for (let i = 0; i < length; i++) { + if (!callbackfn(this.get(i), i)) + return false; + } + return true; + } + any(callbackfn) { + const length = this.getLength(); + for (let i = 0; i < length; i++) { + if (callbackfn(this.get(i), i)) + return true; + } + return false; + } + ap(callbackfns) { + const length = this.getLength(); + const res = []; + for (let i = 0; i < length; i++) { + res.push(...callbackfns.map((f) => f(this.get(i), i))); + } + return res; + } + concat(other) { + const length = this.getLength(); + const otherLength = other.getLength(); + const res = new Array(length + otherLength); + for (let i = 0; i < length; i++) + res[i] = this.get(i); + for (let i = 0; i < otherLength; i++) + res[i + length] = other.get(i); + return res; + } + drop(n) { + const length = this.getLength(); + const res = new Array(length); + for (let i = n; i < length; i++) + res[i] = this.get(i); + return res; + } + dropWhile(callbackfn) { + const length = this.getLength(); + const res = []; + let drop = true; + for (let i = 0; i < length; i++) { + const v = this.get(i); + if (drop) + drop = callbackfn(v, i); + if (!drop) + res.push(v); + } + return res; + } + empty() { + return []; + } + every(callbackfn) { + return this.all(callbackfn); + } + filter(callbackfn) { + const length = this.getLength(); + const res = []; + for (let i = 0; i < length; i++) { + const value = this.get(i); + if (callbackfn(value, i)) + res.push(value); + } + return res; + } + find(callbackfn) { + const length = this.getLength(); + for (let i = 0; i < length; i++) { + const value = this.get(i); + if (callbackfn(value, i)) + return value; + } + return undefined; + } + findIndex(callbackfn) { + const length = this.getLength(); + for (let i = 0; i < length; i++) { + const value = this.get(i); + if (callbackfn(value, i)) + return i; + } + return -1; + } + forEach(callbackfn) { + const length = this.getLength(); + for (let i = 0; i < length; i++) + callbackfn(this.get(i), i); + } + get(_index) { + return get(_index, this); + } + /** + * Get the length of this list. + * + * @returns {number} The number of elements in this list. + */ + getLength() { + return pointer_1.getTargetListLength(this); + } + groupBy(callbackfn) { + const length = this.getLength(); + const res = {}; + for (let i = 0; i < length; i++) { + const v = this.get(i); + res[callbackfn(v, i)] = v; + } + return res; + } + intersperse(sep) { + const length = this.getLength(); + const res = new Array(length); + for (let i = 0; i < length; i++) { + if (i > 0) + res.push(sep); + res.push(this.get(i)); + } + return res; + } + map(callbackfn) { + const length = this.getLength(); + const res = new Array(length); + for (let i = 0; i < length; i++) + res[i] = callbackfn(this.get(i), i); + return res; + } + reduce(callbackfn, initialValue) { + let i = 0; + let res; + if (initialValue === undefined) { + res = this.get(0); + i++; + } + else { + res = initialValue; + } + for (; i < this.getLength(); i++) + res = callbackfn(res, this.get(i), i); + return res; + } + set(_index, _value) { + set(_index, _value, this); + } + slice(start = 0, end) { + const length = end ? Math.min(this.getLength(), end) : this.getLength(); + const res = new Array(length - start); + for (let i = start; i < length; i++) + res[i] = this.get(i); + return res; + } + some(callbackfn) { + return this.any(callbackfn); + } + take(n) { + const length = Math.min(this.getLength(), n); + const res = new Array(length); + for (let i = 0; i < length; i++) + res[i] = this.get(i); + return res; + } + takeWhile(callbackfn) { + const length = this.getLength(); + const res = []; + let take; + for (let i = 0; i < length; i++) { + const v = this.get(i); + take = callbackfn(v, i); + if (!take) + return res; + res.push(v); + } + return res; + } + toArray() { + return this.map(util_1.identity); + } + toString() { + return `List_${super.toString()}`; + } +} +exports.List = List; +List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.VOID, +}; +List.get = get; +List.initList = initList; +List.set = set; +/** + * Initialize the list with the given element size and length. This will allocate new space for the list, ideally in + * the same segment as this pointer. + * + * @param {ListElementSize} elementSize The size of each element in the list. + * @param {number} length The number of elements in the list. + * @param {List} l The list to initialize. + * @param {ObjectSize} [compositeSize] The size of each element in a composite list. This value is required for + * composite lists. + * @returns {void} + */ +function initList(elementSize, length, l, compositeSize) { + let c; + switch (elementSize) { + case list_element_size_1.ListElementSize.BIT: + c = l.segment.allocate(Math.ceil(length / 8)); + break; + case list_element_size_1.ListElementSize.BYTE: + case list_element_size_1.ListElementSize.BYTE_2: + case list_element_size_1.ListElementSize.BYTE_4: + case list_element_size_1.ListElementSize.BYTE_8: + case list_element_size_1.ListElementSize.POINTER: + c = l.segment.allocate(length * pointer_1.getListElementByteLength(elementSize)); + break; + case list_element_size_1.ListElementSize.COMPOSITE: { + if (compositeSize === undefined) { + throw new Error(util_1.format(errors_1.PTR_COMPOSITE_SIZE_UNDEFINED)); + } + compositeSize = object_size_1.padToWord(compositeSize); + const byteLength = object_size_1.getByteLength(compositeSize) * length; + // We need to allocate an extra 8 bytes for the tag word, then make sure we write the length to it. We advance + // the content pointer by 8 bytes so that it then points to the first list element as intended. Everything + // starts off zeroed out so these nested structs don't need to be initialized in any way. + c = l.segment.allocate(byteLength + 8); + pointer_1.setStructPointer(length, compositeSize, c); + trace("Wrote composite tag word %s for %s.", c, l); + break; + } + case list_element_size_1.ListElementSize.VOID: + // No need to allocate anything, we can write the list pointer right here. + pointer_1.setListPointer(0, elementSize, length, l); + return; + default: + throw new Error(util_1.format(errors_1.PTR_INVALID_LIST_SIZE, elementSize)); + } + const res = pointer_1.initPointer(c.segment, c.byteOffset, l); + pointer_1.setListPointer(res.offsetWords, elementSize, length, res.pointer, compositeSize); +} +exports.initList = initList; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function get(_index, _l) { + throw new TypeError(); +} +exports.get = get; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function set(_index, _value, _l) { + throw new TypeError(); +} +exports.set = set; +//# sourceMappingURL=list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/list.js.map b/node_modules/capnp-ts/src/serialization/pointers/list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..89bc46184939868f8b296d030eafef8fef948a54 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"list.js","sourceRoot":"","sources":["list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,yCAAmF;AACnF,qCAA8C;AAC9C,4DAAuD;AACvD,gDAAsE;AAEtE,uCAOmB;AAEnB,MAAM,KAAK,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a,GAAG,uBAAS,CAAC,aAAa,CAAC,CAAC;YAEzC,MAAM,UAAU,GAAG,2BAAa,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC;YAEzD,8GAA8G;YAC9G,0GAA0G;YAC1G,yFAAyF;YAEzF,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YAEvC,0BAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;YAE3C,KAAK,CAAC,qCAAqC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAEnD,MAAM;SACP;QACD,KAAK,mCAAe,CAAC,IAAI;YACvB,0EAA0E;YAE1E,wBAAc,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;YAE1C,OAAO;QAET;YACE,MAAM,IAAI,KAAK,CAAC,aAAM,CAAC,8BAAqB,EAAE,WAAW,CAAC,CAAC,CAAC;KAC/D;IAED,MAAM,GAAG,GAAG,qBAAW,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAEpD,wBAAc,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AACnF,CAAC;AA1DD,4BA0DC;AAED,6DAA6D;AAC7D,SAAgB,GAAG,CAAI,MAAc,EAAE,EAAW;IAChD,MAAM,IAAI,SAAS,EAAE,CAAC;AACxB,CAAC;AAFD,kBAEC;AAED,6DAA6D;AAC7D,SAAgB,GAAG,CAAI,MAAc,EAAE,MAAS,EAAE,EAAW;IAC3D,MAAM,IAAI,SAAS,EAAE,CAAC;AACxB,CAAC;AAFD,kBAEC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/orphan.d.ts b/node_modules/capnp-ts/src/serialization/pointers/orphan.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..236305f930a645c174ef3ce14a104f5f5c860e44 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/orphan.d.ts @@ -0,0 +1,38 @@ +import { ListElementSize } from "../list-element-size"; +import { ObjectSize } from "../object-size"; +import { Segment } from "../segment"; +import { Pointer } from "./pointer"; +import { PointerType } from "./pointer-type"; +export interface _Orphan { + capId: number; + elementSize: ListElementSize; + length: number; + size: ObjectSize; + type: PointerType; +} +/** + * An orphaned pointer. This object itself is technically a pointer to the original pointer's content, which was left + * untouched in its original message. The original pointer data is encoded as attributes on the Orphan object, ready to + * be reconstructed once another pointer is ready to adopt it. + * + * @export + * @class Orphan + * @extends {Pointer} + * @template T + */ +export declare class Orphan { + /** If this member is not present then the orphan has already been adopted, or something went very wrong. */ + _capnp?: _Orphan; + byteOffset: number; + segment: Segment; + constructor(src: T); + /** + * Adopt (move) this orphan into the target pointer location. This will allocate far pointers in `dst` as needed. + * + * @param {T} dst The destination pointer. + * @returns {void} + */ + _moveTo(dst: T): void; + dispose(): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/orphan.js b/node_modules/capnp-ts/src/serialization/pointers/orphan.js new file mode 100644 index 0000000000000000000000000000000000000000..6641afacf65bf4e9f031df85342a8e6e26dbb718 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/orphan.js @@ -0,0 +1,120 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Orphan = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const errors_1 = require("../../errors"); +const util_1 = require("../../util"); +const list_element_size_1 = require("../list-element-size"); +const object_size_1 = require("../object-size"); +const pointer_1 = require("./pointer"); +const pointer_type_1 = require("./pointer-type"); +const trace = debug_1.default("capnp:orphan"); +trace("load"); +// Technically speaking this class doesn't need to be generic, but the extra type checking enforced by this helps to +// make sure you don't accidentally adopt a pointer of the wrong type. +/** + * An orphaned pointer. This object itself is technically a pointer to the original pointer's content, which was left + * untouched in its original message. The original pointer data is encoded as attributes on the Orphan object, ready to + * be reconstructed once another pointer is ready to adopt it. + * + * @export + * @class Orphan + * @extends {Pointer} + * @template T + */ +class Orphan { + constructor(src) { + const c = pointer_1.getContent(src); + this.segment = c.segment; + this.byteOffset = c.byteOffset; + this._capnp = {}; + // Read vital info from the src pointer so we can reconstruct it during adoption. + this._capnp.type = pointer_1.getTargetPointerType(src); + switch (this._capnp.type) { + case pointer_type_1.PointerType.STRUCT: + this._capnp.size = pointer_1.getTargetStructSize(src); + break; + case pointer_type_1.PointerType.LIST: + this._capnp.length = pointer_1.getTargetListLength(src); + this._capnp.elementSize = pointer_1.getTargetListElementSize(src); + if (this._capnp.elementSize === list_element_size_1.ListElementSize.COMPOSITE) { + this._capnp.size = pointer_1.getTargetCompositeListSize(src); + } + break; + case pointer_type_1.PointerType.OTHER: + this._capnp.capId = pointer_1.getCapabilityId(src); + break; + default: + // COVERAGE: Unreachable code. + /* istanbul ignore next */ + throw new Error(errors_1.PTR_INVALID_POINTER_TYPE); + } + // Zero out the source pointer (but not the contents!). + pointer_1.erasePointer(src); + } + /** + * Adopt (move) this orphan into the target pointer location. This will allocate far pointers in `dst` as needed. + * + * @param {T} dst The destination pointer. + * @returns {void} + */ + _moveTo(dst) { + if (this._capnp === undefined) { + throw new Error(util_1.format(errors_1.PTR_ALREADY_ADOPTED, this)); + } + // TODO: Implement copy semantics when this happens. + if (this.segment.message !== dst.segment.message) { + throw new Error(util_1.format(errors_1.PTR_ADOPT_WRONG_MESSAGE, this, dst)); + } + // Recursively wipe out the destination pointer first. + pointer_1.erase(dst); + const res = pointer_1.initPointer(this.segment, this.byteOffset, dst); + switch (this._capnp.type) { + case pointer_type_1.PointerType.STRUCT: + pointer_1.setStructPointer(res.offsetWords, this._capnp.size, res.pointer); + break; + case pointer_type_1.PointerType.LIST: { + let offsetWords = res.offsetWords; + if (this._capnp.elementSize === list_element_size_1.ListElementSize.COMPOSITE) { + offsetWords--; // The tag word gets skipped. + } + pointer_1.setListPointer(offsetWords, this._capnp.elementSize, this._capnp.length, res.pointer, this._capnp.size); + break; + } + case pointer_type_1.PointerType.OTHER: + pointer_1.setInterfacePointer(this._capnp.capId, res.pointer); + break; + /* istanbul ignore next */ + default: + throw new Error(errors_1.PTR_INVALID_POINTER_TYPE); + } + this._capnp = undefined; + } + dispose() { + // FIXME: Should this throw? + if (this._capnp === undefined) { + trace("not disposing an already disposed orphan", this); + return; + } + switch (this._capnp.type) { + case pointer_type_1.PointerType.STRUCT: + this.segment.fillZeroWords(this.byteOffset, object_size_1.getWordLength(this._capnp.size)); + break; + case pointer_type_1.PointerType.LIST: { + const byteLength = pointer_1.getListByteLength(this._capnp.elementSize, this._capnp.length, this._capnp.size); + this.segment.fillZeroWords(this.byteOffset, byteLength); + break; + } + default: + // Other pointer types don't actually have any content. + break; + } + this._capnp = undefined; + } + toString() { + return util_1.format("Orphan_%d@%a,type:%s", this.segment.id, this.byteOffset, this._capnp && this._capnp.type); + } +} +exports.Orphan = Orphan; +//# sourceMappingURL=orphan.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/orphan.js.map b/node_modules/capnp-ts/src/serialization/pointers/orphan.js.map new file mode 100644 index 0000000000000000000000000000000000000000..668ceceeeca492c1c6a0bfe298ae0d85d268e5fa --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/orphan.js.map @@ -0,0 +1 @@ +{"version":3,"file":"orphan.js","sourceRoot":"","sources":["orphan.ts"],"names":[],"mappings":";;;;AAAA,0DAA8B;AAE9B,yCAAsG;AACtG,qCAAoC;AACpC,4DAAuD;AACvD,gDAA2D;AAE3D,uCAgBmB;AACnB,iDAA6C;AAE7C,MAAM,KAAK,GAAG,eAAS,CAAC,cAAc,CAAC,CAAC;AACxC,KAAK,CAAC,MAAM,CAAC,CAAC;AAUd,oHAAoH;AACpH,sEAAsE;AAEtE;;;;;;;;;GASG;AAEH,MAAa,MAAM;IAOjB,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AED,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED,OAAO;QACL,4BAA4B;QAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,KAAK,CAAC,0CAA0C,EAAE,IAAI,CAAC,CAAC;YAExD,OAAO;SACR;QAED,QAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YACxB,KAAK,0BAAW,CAAC,MAAM;gBACrB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,2BAAa,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBAE7E,MAAM;YAER,KAAK,0BAAW,CAAC,IAAI,CAAC,CAAC;gBACrB,MAAM,UAAU,GAAG,2BAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACpG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;gBAExD,MAAM;aACP;YACD;gBACE,uDAAuD;gBAEvD,MAAM;SACT;QAED,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED,QAAQ;QACN,OAAO,aAAM,CAAC,sBAAsB,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3G,CAAC;CACF;AAxID,wBAwIC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/orphan.ts b/node_modules/capnp-ts/src/serialization/pointers/orphan.ts new file mode 100644 index 0000000000000000000000000000000000000000..76c480c9d2b4d5d056b2e4b46df5ae728256117c --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/orphan.ts @@ -0,0 +1,188 @@ +import initTrace from "debug"; + +import { PTR_ADOPT_WRONG_MESSAGE, PTR_ALREADY_ADOPTED, PTR_INVALID_POINTER_TYPE } from "../../errors"; +import { format } from "../../util"; +import { ListElementSize } from "../list-element-size"; +import { ObjectSize, getWordLength } from "../object-size"; +import { Segment } from "../segment"; +import { + Pointer, + getTargetListLength, + getTargetStructSize, + getTargetPointerType, + getTargetListElementSize, + getTargetCompositeListSize, + getCapabilityId, + getContent, + erasePointer, + initPointer, + erase, + setStructPointer, + setListPointer, + setInterfacePointer, + getListByteLength, +} from "./pointer"; +import { PointerType } from "./pointer-type"; + +const trace = initTrace("capnp:orphan"); +trace("load"); + +export interface _Orphan { + capId: number; + elementSize: ListElementSize; + length: number; + size: ObjectSize; + type: PointerType; +} + +// Technically speaking this class doesn't need to be generic, but the extra type checking enforced by this helps to +// make sure you don't accidentally adopt a pointer of the wrong type. + +/** + * An orphaned pointer. This object itself is technically a pointer to the original pointer's content, which was left + * untouched in its original message. The original pointer data is encoded as attributes on the Orphan object, ready to + * be reconstructed once another pointer is ready to adopt it. + * + * @export + * @class Orphan + * @extends {Pointer} + * @template T + */ + +export class Orphan { + /** If this member is not present then the orphan has already been adopted, or something went very wrong. */ + _capnp?: _Orphan; + + byteOffset: number; + segment: Segment; + + constructor(src: T) { + const c = getContent(src); + + this.segment = c.segment; + this.byteOffset = c.byteOffset; + + this._capnp = {} as _Orphan; + + // Read vital info from the src pointer so we can reconstruct it during adoption. + + this._capnp.type = getTargetPointerType(src); + + switch (this._capnp.type) { + case PointerType.STRUCT: + this._capnp.size = getTargetStructSize(src); + + break; + + case PointerType.LIST: + this._capnp.length = getTargetListLength(src); + this._capnp.elementSize = getTargetListElementSize(src); + + if (this._capnp.elementSize === ListElementSize.COMPOSITE) { + this._capnp.size = getTargetCompositeListSize(src); + } + + break; + + case PointerType.OTHER: + this._capnp.capId = getCapabilityId(src); + + break; + + default: + // COVERAGE: Unreachable code. + /* istanbul ignore next */ + throw new Error(PTR_INVALID_POINTER_TYPE); + } + + // Zero out the source pointer (but not the contents!). + + erasePointer(src); + } + + /** + * Adopt (move) this orphan into the target pointer location. This will allocate far pointers in `dst` as needed. + * + * @param {T} dst The destination pointer. + * @returns {void} + */ + + _moveTo(dst: T): void { + if (this._capnp === undefined) { + throw new Error(format(PTR_ALREADY_ADOPTED, this)); + } + + // TODO: Implement copy semantics when this happens. + if (this.segment.message !== dst.segment.message) { + throw new Error(format(PTR_ADOPT_WRONG_MESSAGE, this, dst)); + } + + // Recursively wipe out the destination pointer first. + + erase(dst); + + const res = initPointer(this.segment, this.byteOffset, dst); + + switch (this._capnp.type) { + case PointerType.STRUCT: + setStructPointer(res.offsetWords, this._capnp.size, res.pointer); + + break; + + case PointerType.LIST: { + let offsetWords = res.offsetWords; + + if (this._capnp.elementSize === ListElementSize.COMPOSITE) { + offsetWords--; // The tag word gets skipped. + } + + setListPointer(offsetWords, this._capnp.elementSize, this._capnp.length, res.pointer, this._capnp.size); + + break; + } + case PointerType.OTHER: + setInterfacePointer(this._capnp.capId, res.pointer); + + break; + + /* istanbul ignore next */ + default: + throw new Error(PTR_INVALID_POINTER_TYPE); + } + + this._capnp = undefined; + } + + dispose(): void { + // FIXME: Should this throw? + if (this._capnp === undefined) { + trace("not disposing an already disposed orphan", this); + + return; + } + + switch (this._capnp.type) { + case PointerType.STRUCT: + this.segment.fillZeroWords(this.byteOffset, getWordLength(this._capnp.size)); + + break; + + case PointerType.LIST: { + const byteLength = getListByteLength(this._capnp.elementSize, this._capnp.length, this._capnp.size); + this.segment.fillZeroWords(this.byteOffset, byteLength); + + break; + } + default: + // Other pointer types don't actually have any content. + + break; + } + + this._capnp = undefined; + } + + toString(): string { + return format("Orphan_%d@%a,type:%s", this.segment.id, this.byteOffset, this._capnp && this._capnp.type); + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.d.ts b/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d00486850739ed96fdeca3676d26533df6898621 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.d.ts @@ -0,0 +1,18 @@ +/** + * @author jdiaz5513 + */ +import { Pointer } from "./pointer"; +/** + * This is used as the return value for `Pointer.prototype.initPointer`. Turns out using a class in V8 for multiple + * return values is faster than using an array or anonymous object. + * + * http://jsben.ch/#/zTdbD + * + * @export + * @class PointerAllocationResult + */ +export declare class PointerAllocationResult { + readonly offsetWords: number; + readonly pointer: Pointer; + constructor(pointer: Pointer, offsetWords: number); +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.js b/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.js new file mode 100644 index 0000000000000000000000000000000000000000..7d5e928b1d93525d034f25a084301d721451d46b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.js @@ -0,0 +1,27 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PointerAllocationResult = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const trace = debug_1.default("capnp:pointer-allocation-result"); +trace("load"); +/** + * This is used as the return value for `Pointer.prototype.initPointer`. Turns out using a class in V8 for multiple + * return values is faster than using an array or anonymous object. + * + * http://jsben.ch/#/zTdbD + * + * @export + * @class PointerAllocationResult + */ +class PointerAllocationResult { + constructor(pointer, offsetWords) { + this.pointer = pointer; + this.offsetWords = offsetWords; + } +} +exports.PointerAllocationResult = PointerAllocationResult; +//# sourceMappingURL=pointer-allocation-result.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.js.map b/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.js.map new file mode 100644 index 0000000000000000000000000000000000000000..fe7418fe83f8a0f42a0c4c6b9bdd95a951336198 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-allocation-result.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pointer-allocation-result.js","sourceRoot":"","sources":["pointer-allocation-result.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAI9B,MAAM,KAAK,GAAG,eAAS,CAAC,iCAAiC,CAAC,CAAC;AAC3D,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd;;;;;;;;GAQG;AAEH,MAAa,uBAAuB;IAKlC,YAAY,OAAgB,EAAE,WAAmB;QAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AATD,0DASC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/pointer-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c1303bda4f3d16c017c3ce59a46ef9debb31843 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-list.d.ts @@ -0,0 +1,6 @@ +/** + * @author jdiaz5513 + */ +import { ListCtor } from "./list"; +import { Pointer, PointerCtor } from "./pointer"; +export declare function PointerList(PointerClass: PointerCtor): ListCtor; diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/pointer-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..165aabaa9491d202a1d587e2c6e8124b7896ead8 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pointer-list.js","sourceRoot":"","sources":["pointer-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAmD;AACnD,uCAAuE;AAEvE,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,SAAgB,WAAW,CAAoB,YAA4B;;IACzE,YAAO,KAAM,SAAQ,WAAO;YAM1B,GAAG,CAAC,KAAa;gBACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;gBAC3B,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YAC3F,CAAC;YAED,GAAG,CAAC,KAAa,EAAE,KAAQ;gBACzB,kBAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YACnC,CAAC;YAED,QAAQ;gBACN,OAAO,WAAW,KAAK,CAAC,QAAQ,EAAE,QAAQ,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC;YACtE,CAAC;SACF;QAjBiB,SAAM,GAAc;YAClC,WAAW,EAAE,QAAQ,YAAY,CAAC,MAAM,CAAC,WAAW,GAAG;YACvD,IAAI,EAAE,mCAAe,CAAC,OAAO;SAC7B;WAcF;AACJ,CAAC;AApBD,kCAoBC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-list.ts b/node_modules/capnp-ts/src/serialization/pointers/pointer-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..d71f8b10865b67195ed023b353163fdf20cbaf5f --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-list.ts @@ -0,0 +1,34 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List, ListCtor } from "./list"; +import { Pointer, PointerCtor, getContent, copyFrom } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export function PointerList(PointerClass: PointerCtor): ListCtor { + return class extends List { + static readonly _capnp: _ListCtor = { + displayName: `List<${PointerClass._capnp.displayName}>`, + size: ListElementSize.POINTER, + }; + + get(index: number): T { + const c = getContent(this); + return new PointerClass(c.segment, c.byteOffset + index * 8, this._capnp.depthLimit - 1); + } + + set(index: number, value: T): void { + copyFrom(value, this.get(index)); + } + + toString(): string { + return `Pointer_${super.toString()},cls:${PointerClass.toString()}`; + } + }; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-type.d.ts b/node_modules/capnp-ts/src/serialization/pointers/pointer-type.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8b3c4ca6036463694a976b8576a9ef4a2d05211 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-type.d.ts @@ -0,0 +1,9 @@ +/** + * @author jdiaz5513 + */ +export declare enum PointerType { + STRUCT = 0, + LIST = 1, + FAR = 2, + OTHER = 3 +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-type.js b/node_modules/capnp-ts/src/serialization/pointers/pointer-type.js new file mode 100644 index 0000000000000000000000000000000000000000..c81c2fc37b95ff199e78d5e9b0a08693ce7f2a93 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-type.js @@ -0,0 +1,14 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PointerType = void 0; +var PointerType; +(function (PointerType) { + PointerType[PointerType["STRUCT"] = 0] = "STRUCT"; + PointerType[PointerType["LIST"] = 1] = "LIST"; + PointerType[PointerType["FAR"] = 2] = "FAR"; + PointerType[PointerType["OTHER"] = 3] = "OTHER"; +})(PointerType = exports.PointerType || (exports.PointerType = {})); +//# sourceMappingURL=pointer-type.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-type.js.map b/node_modules/capnp-ts/src/serialization/pointers/pointer-type.js.map new file mode 100644 index 0000000000000000000000000000000000000000..02591b4aa91772aebce42403b4944990ca3470a0 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-type.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pointer-type.js","sourceRoot":"","sources":["pointer-type.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,iDAAU,CAAA;IACV,6CAAQ,CAAA;IACR,2CAAO,CAAA;IACP,+CAAS,CAAA;AACX,CAAC,EALW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAKtB"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer-type.ts b/node_modules/capnp-ts/src/serialization/pointers/pointer-type.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad8f91dc22156cfb6ed75a182af647088ec1db65 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer-type.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ + +export enum PointerType { + STRUCT = 0, + LIST = 1, + FAR = 2, + OTHER = 3 +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer.js b/node_modules/capnp-ts/src/serialization/pointers/pointer.js new file mode 100644 index 0000000000000000000000000000000000000000..711bfbc497d93781f314579d274a78a73c3db858 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer.js @@ -0,0 +1,795 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.trackPointerAllocation = exports.copyFromStruct = exports.copyFromList = exports.validate = exports.setStructPointer = exports.setListPointer = exports.setInterfacePointer = exports.setFarPointer = exports.relocateTo = exports.isNull = exports.isDoubleFar = exports.initPointer = exports.getTargetStructSize = exports.getTargetPointerType = exports.getTargetListLength = exports.getTargetListElementSize = exports.getTargetCompositeListSize = exports.getTargetCompositeListTag = exports.getStructSize = exports.getStructPointerLength = exports.getStructDataWords = exports.getPointerType = exports.getOffsetWords = exports.getListLength = exports.getListElementSize = exports.getFarSegmentId = exports.getContent = exports.getCapabilityId = exports.followFars = exports.followFar = exports.erasePointer = exports.erase = exports.copyFrom = exports.add = exports.getListElementByteLength = exports.getListByteLength = exports.dump = exports.disown = exports.adopt = exports.Pointer = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("../../constants"); +const util_1 = require("../../util"); +const list_element_size_1 = require("../list-element-size"); +const object_size_1 = require("../object-size"); +const orphan_1 = require("./orphan"); +const pointer_allocation_result_1 = require("./pointer-allocation-result"); +const pointer_type_1 = require("./pointer-type"); +const errors_1 = require("../../errors"); +const trace = debug_1.default("capnp:pointer"); +trace("load"); +/** + * A pointer referencing a single byte location in a segment. This is typically used for Cap'n Proto pointers, but is + * also sometimes used to reference an offset to a pointer's content or tag words. + * + * @export + * @class Pointer + */ +class Pointer { + constructor(segment, byteOffset, depthLimit = constants_1.MAX_DEPTH) { + this._capnp = { compositeList: false, depthLimit }; + this.segment = segment; + this.byteOffset = byteOffset; + if (depthLimit === 0) { + throw new Error(util_1.format(errors_1.PTR_DEPTH_LIMIT_EXCEEDED, this)); + } + // Make sure we keep track of all pointer allocations; there's a limit per message (prevent DoS). + trackPointerAllocation(segment.message, this); + // NOTE: It's okay to have a pointer to the end of the segment; you'll see this when creating pointers to the + // beginning of the content of a newly-allocated composite list with zero elements. Unlike other language + // implementations buffer over/underflows are not a big issue since all buffer access is bounds checked in native + // code anyway. + if (byteOffset < 0 || byteOffset > segment.byteLength) { + throw new Error(util_1.format(errors_1.PTR_OFFSET_OUT_OF_BOUNDS, byteOffset)); + } + trace("new %s", this); + } + toString() { + return util_1.format("Pointer_%d@%a,%s,limit:%x", this.segment.id, this.byteOffset, dump(this), this._capnp.depthLimit); + } +} +exports.Pointer = Pointer; +Pointer.adopt = adopt; +Pointer.copyFrom = copyFrom; +Pointer.disown = disown; +Pointer.dump = dump; +Pointer.isNull = isNull; +Pointer._capnp = { + displayName: "Pointer", +}; +/** + * Adopt an orphaned pointer, making the pointer point to the orphaned content without copying it. + * + * @param {Orphan} src The orphan to adopt. + * @param {Pointer} p The the pointer to adopt into. + * @returns {void} + */ +function adopt(src, p) { + src._moveTo(p); +} +exports.adopt = adopt; +/** + * Convert a pointer to an Orphan, zeroing out the pointer and leaving its content untouched. If the content is no + * longer needed, call `disown()` on the orphaned pointer to erase the contents as well. + * + * Call `adopt()` on the orphan with the new target pointer location to move it back into the message; the orphan + * object is then invalidated after adoption (can only adopt once!). + * + * @param {T} p The pointer to turn into an Orphan. + * @returns {Orphan} An orphaned pointer. + */ +function disown(p) { + return new orphan_1.Orphan(p); +} +exports.disown = disown; +function dump(p) { + return util_1.bufferToHex(p.segment.buffer.slice(p.byteOffset, p.byteOffset + 8)); +} +exports.dump = dump; +/** + * Get the total number of bytes required to hold a list of the provided size with the given length, rounded up to the + * nearest word. + * + * @param {ListElementSize} elementSize A number describing the size of the list elements. + * @param {number} length The length of the list. + * @param {ObjectSize} [compositeSize] The size of each element in a composite list; required if + * `elementSize === ListElementSize.COMPOSITE`. + * @returns {number} The number of bytes required to hold an element of that size, or `NaN` if that is undefined. + */ +function getListByteLength(elementSize, length, compositeSize) { + switch (elementSize) { + case list_element_size_1.ListElementSize.BIT: + return util_1.padToWord((length + 7) >>> 3); + case list_element_size_1.ListElementSize.BYTE: + case list_element_size_1.ListElementSize.BYTE_2: + case list_element_size_1.ListElementSize.BYTE_4: + case list_element_size_1.ListElementSize.BYTE_8: + case list_element_size_1.ListElementSize.POINTER: + case list_element_size_1.ListElementSize.VOID: + return util_1.padToWord(getListElementByteLength(elementSize) * length); + /* istanbul ignore next */ + case list_element_size_1.ListElementSize.COMPOSITE: + if (compositeSize === undefined) { + throw new Error(util_1.format(errors_1.PTR_INVALID_LIST_SIZE, NaN)); + } + return length * util_1.padToWord(object_size_1.getByteLength(compositeSize)); + /* istanbul ignore next */ + default: + throw new Error(errors_1.PTR_INVALID_LIST_SIZE); + } +} +exports.getListByteLength = getListByteLength; +/** + * Get the number of bytes required to hold a list element of the provided size. `COMPOSITE` elements do not have a + * fixed size, and `BIT` elements are packed into exactly a single bit, so these both return `NaN`. + * + * @param {ListElementSize} elementSize A number describing the size of the list elements. + * @returns {number} The number of bytes required to hold an element of that size, or `NaN` if that is undefined. + */ +function getListElementByteLength(elementSize) { + switch (elementSize) { + /* istanbul ignore next */ + case list_element_size_1.ListElementSize.BIT: + return NaN; + case list_element_size_1.ListElementSize.BYTE: + return 1; + case list_element_size_1.ListElementSize.BYTE_2: + return 2; + case list_element_size_1.ListElementSize.BYTE_4: + return 4; + case list_element_size_1.ListElementSize.BYTE_8: + case list_element_size_1.ListElementSize.POINTER: + return 8; + /* istanbul ignore next */ + case list_element_size_1.ListElementSize.COMPOSITE: + // Caller has to figure it out based on the tag word. + return NaN; + /* istanbul ignore next */ + case list_element_size_1.ListElementSize.VOID: + return 0; + /* istanbul ignore next */ + default: + throw new Error(util_1.format(errors_1.PTR_INVALID_LIST_SIZE, elementSize)); + } +} +exports.getListElementByteLength = getListElementByteLength; +/** + * Add an offset to the pointer's offset and return a new Pointer for that address. + * + * @param {number} offset The number of bytes to add to the offset. + * @param {Pointer} p The pointer to add from. + * @returns {Pointer} A new pointer to the address. + */ +function add(offset, p) { + return new Pointer(p.segment, p.byteOffset + offset, p._capnp.depthLimit); +} +exports.add = add; +/** + * Replace a pointer with a deep copy of the pointer at `src` and all of its contents. + * + * @param {Pointer} src The pointer to copy. + * @param {Pointer} p The pointer to copy into. + * @returns {void} + */ +function copyFrom(src, p) { + // If the pointer is the same then this is a noop. + if (p.segment === src.segment && p.byteOffset === src.byteOffset) { + trace("ignoring copy operation from identical pointer %s", src); + return; + } + // Make sure we erase this pointer's contents before moving on. If src is null, that's all we do. + erase(p); // noop if null + if (isNull(src)) + return; + switch (getTargetPointerType(src)) { + case pointer_type_1.PointerType.STRUCT: + copyFromStruct(src, p); + break; + case pointer_type_1.PointerType.LIST: + copyFromList(src, p); + break; + /* istanbul ignore next */ + default: + throw new Error(util_1.format(errors_1.PTR_INVALID_POINTER_TYPE, getTargetPointerType(p))); + } +} +exports.copyFrom = copyFrom; +/** + * Recursively erase a pointer, any far pointers/landing pads/tag words, and the content it points to. + * + * Note that this will leave "holes" of zeroes in the message, since the space cannot be reclaimed. With packing this + * will have a negligible effect on the final message size. + * + * FIXME: This may need protection against infinite recursion... + * + * @param {Pointer} p The pointer to erase. + * @returns {void} + */ +function erase(p) { + if (isNull(p)) + return; + // First deal with the contents. + let c; + switch (getTargetPointerType(p)) { + case pointer_type_1.PointerType.STRUCT: { + const size = getTargetStructSize(p); + c = getContent(p); + // Wipe the data section. + c.segment.fillZeroWords(c.byteOffset, size.dataByteLength / 8); + // Iterate over all the pointers and nuke them. + for (let i = 0; i < size.pointerLength; i++) { + erase(add(i * 8, c)); + } + break; + } + case pointer_type_1.PointerType.LIST: { + const elementSize = getTargetListElementSize(p); + const length = getTargetListLength(p); + let contentWords = util_1.padToWord(length * getListElementByteLength(elementSize)); + c = getContent(p); + if (elementSize === list_element_size_1.ListElementSize.POINTER) { + for (let i = 0; i < length; i++) { + erase(new Pointer(c.segment, c.byteOffset + i * 8, p._capnp.depthLimit - 1)); + } + // Calling erase on each pointer takes care of the content, nothing left to do here. + break; + } + else if (elementSize === list_element_size_1.ListElementSize.COMPOSITE) { + // Read some stuff from the tag word. + const tag = add(-8, c); + const compositeSize = getStructSize(tag); + const compositeByteLength = object_size_1.getByteLength(compositeSize); + contentWords = getOffsetWords(tag); + // Kill the tag word. + c.segment.setWordZero(c.byteOffset - 8); + // Recursively erase each pointer. + for (let i = 0; i < length; i++) { + for (let j = 0; j < compositeSize.pointerLength; j++) { + erase(new Pointer(c.segment, c.byteOffset + i * compositeByteLength + j * 8, p._capnp.depthLimit - 1)); + } + } + } + c.segment.fillZeroWords(c.byteOffset, contentWords); + break; + } + case pointer_type_1.PointerType.OTHER: + // No content. + break; + default: + throw new Error(util_1.format(errors_1.PTR_INVALID_POINTER_TYPE, getTargetPointerType(p))); + } + erasePointer(p); +} +exports.erase = erase; +/** + * Set the pointer (and far pointer landing pads, if applicable) to zero. Does not touch the pointer's content. + * + * @param {Pointer} p The pointer to erase. + * @returns {void} + */ +function erasePointer(p) { + if (getPointerType(p) === pointer_type_1.PointerType.FAR) { + const landingPad = followFar(p); + if (isDoubleFar(p)) { + // Kill the double-far tag word. + landingPad.segment.setWordZero(landingPad.byteOffset + 8); + } + // Kill the landing pad. + landingPad.segment.setWordZero(landingPad.byteOffset); + } + // Finally! Kill the pointer itself... + p.segment.setWordZero(p.byteOffset); +} +exports.erasePointer = erasePointer; +/** + * Interpret the pointer as a far pointer, returning its target segment and offset. + * + * @param {Pointer} p The pointer to read from. + * @returns {Pointer} A pointer to the far target. + */ +function followFar(p) { + const targetSegment = p.segment.message.getSegment(p.segment.getUint32(p.byteOffset + 4)); + const targetWordOffset = p.segment.getUint32(p.byteOffset) >>> 3; + return new Pointer(targetSegment, targetWordOffset * 8, p._capnp.depthLimit - 1); +} +exports.followFar = followFar; +/** + * If the pointer address references a far pointer, follow it to the location where the actual pointer data is written. + * Otherwise, returns the pointer unmodified. + * + * @param {Pointer} p The pointer to read from. + * @returns {Pointer} A new pointer representing the target location, or `p` if it is not a far pointer. + */ +function followFars(p) { + if (getPointerType(p) === pointer_type_1.PointerType.FAR) { + const landingPad = followFar(p); + if (isDoubleFar(p)) + landingPad.byteOffset += 8; + return landingPad; + } + return p; +} +exports.followFars = followFars; +function getCapabilityId(p) { + return p.segment.getUint32(p.byteOffset + 4); +} +exports.getCapabilityId = getCapabilityId; +function isCompositeList(p) { + return getTargetPointerType(p) === pointer_type_1.PointerType.LIST && getTargetListElementSize(p) === list_element_size_1.ListElementSize.COMPOSITE; +} +/** + * Obtain the location of the pointer's content, following far pointers as needed. + * If the pointer is a struct pointer and `compositeIndex` is set, it will be offset by a multiple of the struct's size. + * + * @param {Pointer} p The pointer to read from. + * @param {boolean} [ignoreCompositeIndex] If true, will not follow the composite struct pointer's composite index and + * instead return a pointer to the parent list's contents (also the beginning of the first struct). + * @returns {Pointer} A pointer to the beginning of the pointer's content. + */ +function getContent(p, ignoreCompositeIndex) { + let c; + if (isDoubleFar(p)) { + const landingPad = followFar(p); + c = new Pointer(p.segment.message.getSegment(getFarSegmentId(landingPad)), getOffsetWords(landingPad) * 8); + } + else { + const target = followFars(p); + c = new Pointer(target.segment, target.byteOffset + 8 + getOffsetWords(target) * 8); + } + if (isCompositeList(p)) + c.byteOffset += 8; + if (!ignoreCompositeIndex && p._capnp.compositeIndex !== undefined) { + // Seek backwards by one word so we can read the struct size off the tag word. + c.byteOffset -= 8; + // Seek ahead by `compositeIndex` multiples of the struct's total size. + c.byteOffset += 8 + p._capnp.compositeIndex * object_size_1.getByteLength(object_size_1.padToWord(getStructSize(c))); + } + return c; +} +exports.getContent = getContent; +/** + * Read the target segment ID from a far pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The target segment ID. + */ +function getFarSegmentId(p) { + return p.segment.getUint32(p.byteOffset + 4); +} +exports.getFarSegmentId = getFarSegmentId; +/** + * Get a number indicating the size of the list's elements. + * + * @param {Pointer} p The pointer to read from. + * @returns {ListElementSize} The size of the list's elements. + */ +function getListElementSize(p) { + return p.segment.getUint32(p.byteOffset + 4) & constants_1.LIST_SIZE_MASK; +} +exports.getListElementSize = getListElementSize; +/** + * Get the number of elements in a list pointer. For composite lists, it instead represents the total number of words in + * the list (not counting the tag word). + * + * This method does **not** attempt to distinguish between composite and non-composite lists. To get the correct + * length for composite lists use `getTargetListLength()` instead. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The length of the list, or total number of words for composite lists. + */ +function getListLength(p) { + return p.segment.getUint32(p.byteOffset + 4) >>> 3; +} +exports.getListLength = getListLength; +/** + * Get the offset (in words) from the end of a pointer to the start of its content. For struct pointers, this is the + * beginning of the data section, and for list pointers it is the location of the first element. The value should + * always be zero for interface pointers. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The offset, in words, from the end of the pointer to the start of the data section. + */ +function getOffsetWords(p) { + const o = p.segment.getInt32(p.byteOffset); + // Far pointers only have 29 offset bits. + return o & 2 ? o >> 3 : o >> 2; +} +exports.getOffsetWords = getOffsetWords; +/** + * Look up the pointer's type. + * + * @param {Pointer} p The pointer to read from. + * @returns {PointerType} The type of pointer. + */ +function getPointerType(p) { + return p.segment.getUint32(p.byteOffset) & constants_1.POINTER_TYPE_MASK; +} +exports.getPointerType = getPointerType; +/** + * Read the number of data words from this struct pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The number of data words in the struct. + */ +function getStructDataWords(p) { + return p.segment.getUint16(p.byteOffset + 4); +} +exports.getStructDataWords = getStructDataWords; +/** + * Read the number of pointers contained in this struct pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The number of pointers in this struct. + */ +function getStructPointerLength(p) { + return p.segment.getUint16(p.byteOffset + 6); +} +exports.getStructPointerLength = getStructPointerLength; +/** + * Get an object describing this struct pointer's size. + * + * @param {Pointer} p The pointer to read from. + * @returns {ObjectSize} The size of the struct. + */ +function getStructSize(p) { + return new object_size_1.ObjectSize(getStructDataWords(p) * 8, getStructPointerLength(p)); +} +exports.getStructSize = getStructSize; +/** + * Get a pointer to this pointer's composite list tag word, following far pointers as needed. + * + * @param {Pointer} p The pointer to read from. + * @returns {Pointer} A pointer to the list's composite tag word. + */ +function getTargetCompositeListTag(p) { + const c = getContent(p); + // The composite list tag is always one word before the content. + c.byteOffset -= 8; + return c; +} +exports.getTargetCompositeListTag = getTargetCompositeListTag; +/** + * Get the object size for the target composite list, following far pointers as needed. + * + * @param {Pointer} p The pointer to read from. + * @returns {ObjectSize} An object describing the size of each struct in the list. + */ +function getTargetCompositeListSize(p) { + return getStructSize(getTargetCompositeListTag(p)); +} +exports.getTargetCompositeListSize = getTargetCompositeListSize; +/** + * Get the size of the list elements referenced by this pointer, following far pointers if necessary. + * + * @param {Pointer} p The pointer to read from. + * @returns {ListElementSize} The size of the elements in the list. + */ +function getTargetListElementSize(p) { + return getListElementSize(followFars(p)); +} +exports.getTargetListElementSize = getTargetListElementSize; +/** + * Get the length of the list referenced by this pointer, following far pointers if necessary. If the list is a + * composite list, it will look up the tag word and read the length from there. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The number of elements in the list. + */ +function getTargetListLength(p) { + const t = followFars(p); + if (getListElementSize(t) === list_element_size_1.ListElementSize.COMPOSITE) { + // The content is prefixed by a tag word; it's a struct pointer whose offset contains the list's length. + return getOffsetWords(getTargetCompositeListTag(p)); + } + return getListLength(t); +} +exports.getTargetListLength = getTargetListLength; +/** + * Get the type of a pointer, following far pointers if necessary. For non-far pointers this is equivalent to calling + * `getPointerType()`. + * + * The target of a far pointer can never be another far pointer, and this method will throw if such a situation is + * encountered. + * + * @param {Pointer} p The pointer to read from. + * @returns {PointerType} The type of pointer referenced by this pointer. + */ +function getTargetPointerType(p) { + const t = getPointerType(followFars(p)); + if (t === pointer_type_1.PointerType.FAR) + throw new Error(util_1.format(errors_1.PTR_INVALID_FAR_TARGET, p)); + return t; +} +exports.getTargetPointerType = getTargetPointerType; +/** + * Get the size of the struct referenced by a pointer, following far pointers if necessary. + * + * @param {Pointer} p The poiner to read from. + * @returns {ObjectSize} The size of the struct referenced by this pointer. + */ +function getTargetStructSize(p) { + return getStructSize(followFars(p)); +} +exports.getTargetStructSize = getTargetStructSize; +/** + * Initialize a pointer to point at the data in the content segment. If the content segment is not the same as the + * pointer's segment, this will allocate and write far pointers as needed. Nothing is written otherwise. + * + * The return value includes a pointer to write the pointer's actual data to (the eventual far target), and the offset + * value (in words) to use for that pointer. In the case of double-far pointers this offset will always be zero. + * + * @param {Segment} contentSegment The segment containing this pointer's content. + * @param {number} contentOffset The offset within the content segment for the beginning of this pointer's content. + * @param {Pointer} p The pointer to initialize. + * @returns {PointerAllocationResult} An object containing a pointer (where the pointer data should be written), and + * the value to use as the offset for that pointer. + */ +function initPointer(contentSegment, contentOffset, p) { + if (p.segment !== contentSegment) { + // Need a far pointer. + trace("Initializing far pointer %s -> %s.", p, contentSegment); + if (!contentSegment.hasCapacity(8)) { + // GAH! Not enough space in the content segment for a landing pad so we need a double far pointer. + const landingPad = p.segment.allocate(16); + trace("GAH! Initializing double-far pointer in %s from %s -> %s.", p, contentSegment, landingPad); + setFarPointer(true, landingPad.byteOffset / 8, landingPad.segment.id, p); + setFarPointer(false, contentOffset / 8, contentSegment.id, landingPad); + landingPad.byteOffset += 8; + return new pointer_allocation_result_1.PointerAllocationResult(landingPad, 0); + } + // Allocate a far pointer landing pad in the target segment. + const landingPad = contentSegment.allocate(8); + if (landingPad.segment.id !== contentSegment.id) { + throw new Error(errors_1.INVARIANT_UNREACHABLE_CODE); + } + setFarPointer(false, landingPad.byteOffset / 8, landingPad.segment.id, p); + return new pointer_allocation_result_1.PointerAllocationResult(landingPad, (contentOffset - landingPad.byteOffset - 8) / 8); + } + trace("Initializing intra-segment pointer %s -> %a.", p, contentOffset); + return new pointer_allocation_result_1.PointerAllocationResult(p, (contentOffset - p.byteOffset - 8) / 8); +} +exports.initPointer = initPointer; +/** + * Check if the pointer is a double-far pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {boolean} `true` if it is a double-far pointer, `false` otherwise. + */ +function isDoubleFar(p) { + return getPointerType(p) === pointer_type_1.PointerType.FAR && (p.segment.getUint32(p.byteOffset) & constants_1.POINTER_DOUBLE_FAR_MASK) !== 0; +} +exports.isDoubleFar = isDoubleFar; +/** + * Quickly check to see if the pointer is "null". A "null" pointer is a zero word, equivalent to an empty struct + * pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {boolean} `true` if the pointer is "null". + */ +function isNull(p) { + return p.segment.isWordZero(p.byteOffset); +} +exports.isNull = isNull; +/** + * Relocate a pointer to the given destination, ensuring that it points to the same content. This will create far + * pointers as needed if the content is in a different segment than the destination. After the relocation the source + * pointer will be erased and is no longer valid. + * + * @param {Pointer} dst The desired location for the `src` pointer. Any existing contents will be erased before + * relocating! + * @param {Pointer} src The pointer to relocate. + * @returns {void} + */ +function relocateTo(dst, src) { + const t = followFars(src); + const lo = t.segment.getUint8(t.byteOffset) & 0x03; // discard the offset + const hi = t.segment.getUint32(t.byteOffset + 4); + // Make sure anything dst was pointing to is wiped out. + erase(dst); + const res = initPointer(t.segment, t.byteOffset + 8 + getOffsetWords(t) * 8, dst); + // Keep the low 2 bits and write the new offset. + res.pointer.segment.setUint32(res.pointer.byteOffset, lo | (res.offsetWords << 2)); + // Keep the high 32 bits intact. + res.pointer.segment.setUint32(res.pointer.byteOffset + 4, hi); + erasePointer(src); +} +exports.relocateTo = relocateTo; +/** + * Write a far pointer. + * + * @param {boolean} doubleFar Set to `true` if this is a double far pointer. + * @param {number} offsetWords The offset, in words, to the target pointer. + * @param {number} segmentId The segment the target pointer is located in. + * @param {Pointer} p The pointer to write to. + * @returns {void} + */ +function setFarPointer(doubleFar, offsetWords, segmentId, p) { + const A = pointer_type_1.PointerType.FAR; + const B = doubleFar ? 1 : 0; + const C = offsetWords; + const D = segmentId; + p.segment.setUint32(p.byteOffset, A | (B << 2) | (C << 3)); + p.segment.setUint32(p.byteOffset + 4, D); +} +exports.setFarPointer = setFarPointer; +/** + * Write a raw interface pointer. + * + * @param {number} capId The capability ID. + * @param {Pointer} p The pointer to write to. + * @returns {void} + */ +function setInterfacePointer(capId, p) { + p.segment.setUint32(p.byteOffset, pointer_type_1.PointerType.OTHER); + p.segment.setUint32(p.byteOffset + 4, capId); +} +exports.setInterfacePointer = setInterfacePointer; +/** + * Write a raw list pointer. + * + * @param {number} offsetWords The number of words from the end of this pointer to the beginning of the list content. + * @param {ListElementSize} size The size of each element in the list. + * @param {number} length The number of elements in the list. + * @param {Pointer} p The pointer to write to. + * @param {ObjectSize} [compositeSize] For composite lists this describes the size of each element in this list. This + * is required for composite lists. + * @returns {void} + */ +function setListPointer(offsetWords, size, length, p, compositeSize) { + const A = pointer_type_1.PointerType.LIST; + const B = offsetWords; + const C = size; + let D = length; + if (size === list_element_size_1.ListElementSize.COMPOSITE) { + if (compositeSize === undefined) { + throw new TypeError(errors_1.TYPE_COMPOSITE_SIZE_UNDEFINED); + } + D *= object_size_1.getWordLength(compositeSize); + } + p.segment.setUint32(p.byteOffset, A | (B << 2)); + p.segment.setUint32(p.byteOffset + 4, C | (D << 3)); +} +exports.setListPointer = setListPointer; +/** + * Write a raw struct pointer. + * + * @param {number} offsetWords The number of words from the end of this pointer to the beginning of the struct's data + * section. + * @param {ObjectSize} size An object describing the size of the struct. + * @param {Pointer} p The pointer to write to. + * @returns {void} + */ +function setStructPointer(offsetWords, size, p) { + const A = pointer_type_1.PointerType.STRUCT; + const B = offsetWords; + const C = object_size_1.getDataWordLength(size); + const D = size.pointerLength; + p.segment.setUint32(p.byteOffset, A | (B << 2)); + p.segment.setUint16(p.byteOffset + 4, C); + p.segment.setUint16(p.byteOffset + 6, D); +} +exports.setStructPointer = setStructPointer; +/** + * Read some bits off a pointer to make sure it has the right pointer data. + * + * @param {PointerType} pointerType The expected pointer type. + * @param {Pointer} p The pointer to validate. + * @param {ListElementSize} [elementSize] For list pointers, the expected element size. Leave this + * undefined for struct pointers. + * @returns {void} + */ +function validate(pointerType, p, elementSize) { + if (isNull(p)) + return; + const t = followFars(p); + // Check the pointer type. + const A = t.segment.getUint32(t.byteOffset) & constants_1.POINTER_TYPE_MASK; + if (A !== pointerType) { + throw new Error(util_1.format(errors_1.PTR_WRONG_POINTER_TYPE, p, pointerType)); + } + // Check the list element size, if provided. + if (elementSize !== undefined) { + const C = t.segment.getUint32(t.byteOffset + 4) & constants_1.LIST_SIZE_MASK; + if (C !== elementSize) { + throw new Error(util_1.format(errors_1.PTR_WRONG_LIST_TYPE, p, list_element_size_1.ListElementSize[elementSize])); + } + } +} +exports.validate = validate; +function copyFromList(src, dst) { + if (dst._capnp.depthLimit <= 0) + throw new Error(errors_1.PTR_DEPTH_LIMIT_EXCEEDED); + const srcContent = getContent(src); + const srcElementSize = getTargetListElementSize(src); + const srcLength = getTargetListLength(src); + let srcCompositeSize; + let srcStructByteLength; + let dstContent; + if (srcElementSize === list_element_size_1.ListElementSize.POINTER) { + dstContent = dst.segment.allocate(srcLength << 3); + // Recursively copy each pointer in the list. + for (let i = 0; i < srcLength; i++) { + const srcPtr = new Pointer(srcContent.segment, srcContent.byteOffset + (i << 3), src._capnp.depthLimit - 1); + const dstPtr = new Pointer(dstContent.segment, dstContent.byteOffset + (i << 3), dst._capnp.depthLimit - 1); + copyFrom(srcPtr, dstPtr); + } + } + else if (srcElementSize === list_element_size_1.ListElementSize.COMPOSITE) { + srcCompositeSize = object_size_1.padToWord(getTargetCompositeListSize(src)); + srcStructByteLength = object_size_1.getByteLength(srcCompositeSize); + dstContent = dst.segment.allocate(object_size_1.getByteLength(srcCompositeSize) * srcLength + 8); + // Copy the tag word. + dstContent.segment.copyWord(dstContent.byteOffset, srcContent.segment, srcContent.byteOffset - 8); + // Copy the entire contents, including all pointers. This should be more efficient than making `srcLength` + // copies to skip the pointer sections, and we're about to rewrite all those pointers anyway. + // PERF: Skip this step if the composite struct only contains pointers. + if (srcCompositeSize.dataByteLength > 0) { + const wordLength = object_size_1.getWordLength(srcCompositeSize) * srcLength; + dstContent.segment.copyWords(dstContent.byteOffset + 8, srcContent.segment, srcContent.byteOffset, wordLength); + } + // Recursively copy all the pointers in each struct. + for (let i = 0; i < srcLength; i++) { + for (let j = 0; j < srcCompositeSize.pointerLength; j++) { + const offset = i * srcStructByteLength + srcCompositeSize.dataByteLength + (j << 3); + const srcPtr = new Pointer(srcContent.segment, srcContent.byteOffset + offset, src._capnp.depthLimit - 1); + const dstPtr = new Pointer(dstContent.segment, dstContent.byteOffset + offset + 8, dst._capnp.depthLimit - 1); + copyFrom(srcPtr, dstPtr); + } + } + } + else { + const byteLength = util_1.padToWord(srcElementSize === list_element_size_1.ListElementSize.BIT + ? (srcLength + 7) >>> 3 + : getListElementByteLength(srcElementSize) * srcLength); + const wordLength = byteLength >>> 3; + dstContent = dst.segment.allocate(byteLength); + // Copy all of the list contents word-by-word. + dstContent.segment.copyWords(dstContent.byteOffset, srcContent.segment, srcContent.byteOffset, wordLength); + } + // Initialize the list pointer. + const res = initPointer(dstContent.segment, dstContent.byteOffset, dst); + setListPointer(res.offsetWords, srcElementSize, srcLength, res.pointer, srcCompositeSize); +} +exports.copyFromList = copyFromList; +function copyFromStruct(src, dst) { + if (dst._capnp.depthLimit <= 0) + throw new Error(errors_1.PTR_DEPTH_LIMIT_EXCEEDED); + const srcContent = getContent(src); + const srcSize = getTargetStructSize(src); + const srcDataWordLength = object_size_1.getDataWordLength(srcSize); + // Allocate space for the destination content. + const dstContent = dst.segment.allocate(object_size_1.getByteLength(srcSize)); + // Copy the data section. + dstContent.segment.copyWords(dstContent.byteOffset, srcContent.segment, srcContent.byteOffset, srcDataWordLength); + // Copy the pointer section. + for (let i = 0; i < srcSize.pointerLength; i++) { + const offset = srcSize.dataByteLength + i * 8; + const srcPtr = new Pointer(srcContent.segment, srcContent.byteOffset + offset, src._capnp.depthLimit - 1); + const dstPtr = new Pointer(dstContent.segment, dstContent.byteOffset + offset, dst._capnp.depthLimit - 1); + copyFrom(srcPtr, dstPtr); + } + // Don't touch dst if it's already initialized as a composite list pointer. With composite struct pointers there's + // no pointer to copy here and we've already copied the contents. + if (dst._capnp.compositeList) + return; + // Initialize the struct pointer. + const res = initPointer(dstContent.segment, dstContent.byteOffset, dst); + setStructPointer(res.offsetWords, srcSize, res.pointer); +} +exports.copyFromStruct = copyFromStruct; +/** + * Track the allocation of a new Pointer object. + * + * This will decrement an internal counter tracking how many bytes have been traversed in the message so far. After + * a certain limit, this method will throw an error in order to prevent a certain class of DoS attacks. + * + * @param {Message} message The message the pointer belongs to. + * @param {Pointer} p The pointer being allocated. + * @returns {void} + */ +function trackPointerAllocation(message, p) { + message._capnp.traversalLimit -= 8; + if (message._capnp.traversalLimit <= 0) { + throw new Error(util_1.format(errors_1.PTR_TRAVERSAL_LIMIT_EXCEEDED, p)); + } +} +exports.trackPointerAllocation = trackPointerAllocation; +//# sourceMappingURL=pointer.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/pointer.ts b/node_modules/capnp-ts/src/serialization/pointers/pointer.ts new file mode 100644 index 0000000000000000000000000000000000000000..891382e9994808ae5c27caf261f5ae59213f5955 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/pointer.ts @@ -0,0 +1,1018 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { LIST_SIZE_MASK, MAX_DEPTH, POINTER_DOUBLE_FAR_MASK, POINTER_TYPE_MASK } from "../../constants"; +import { bufferToHex, format, padToWord } from "../../util"; +import { ListElementSize } from "../list-element-size"; +import { + ObjectSize, + getByteLength, + padToWord as padObjectToWord, + getWordLength, + getDataWordLength, +} from "../object-size"; +import { Segment } from "../segment"; +import { Orphan } from "./orphan"; +import { PointerAllocationResult } from "./pointer-allocation-result"; +import { PointerType } from "./pointer-type"; +import { Message } from "../message"; +import { + PTR_TRAVERSAL_LIMIT_EXCEEDED, + PTR_DEPTH_LIMIT_EXCEEDED, + PTR_OFFSET_OUT_OF_BOUNDS, + PTR_INVALID_LIST_SIZE, + PTR_INVALID_POINTER_TYPE, + PTR_INVALID_FAR_TARGET, + TYPE_COMPOSITE_SIZE_UNDEFINED, + PTR_WRONG_POINTER_TYPE, + PTR_WRONG_LIST_TYPE, + INVARIANT_UNREACHABLE_CODE, +} from "../../errors"; + +const trace = initTrace("capnp:pointer"); +trace("load"); + +export interface _PointerCtor { + readonly displayName: string; +} + +export interface PointerCtor { + readonly _capnp: _PointerCtor; + + new (segment: Segment, byteOffset: number, depthLimit?: number): T; +} + +export interface _Pointer { + compositeIndex?: number; + + compositeList: boolean; + + /** + * A number that is decremented as nested pointers are traversed. When this hits zero errors will be thrown. + */ + + depthLimit: number; +} + +/** + * A pointer referencing a single byte location in a segment. This is typically used for Cap'n Proto pointers, but is + * also sometimes used to reference an offset to a pointer's content or tag words. + * + * @export + * @class Pointer + */ + +export class Pointer { + static readonly adopt = adopt; + static readonly copyFrom = copyFrom; + static readonly disown = disown; + static readonly dump = dump; + static readonly isNull = isNull; + + static readonly _capnp: _PointerCtor = { + displayName: "Pointer" as string, + }; + + readonly _capnp: _Pointer; + + /** Offset, in bytes, from the start of the segment to the beginning of this pointer. */ + + byteOffset: number; + + /** + * The starting segment for this pointer's data. In the case of a far pointer, the actual content this pointer is + * referencing will be in another segment within the same message. + */ + + segment: Segment; + + constructor(segment: Segment, byteOffset: number, depthLimit = MAX_DEPTH) { + this._capnp = { compositeList: false, depthLimit }; + this.segment = segment; + this.byteOffset = byteOffset; + + if (depthLimit === 0) { + throw new Error(format(PTR_DEPTH_LIMIT_EXCEEDED, this)); + } + + // Make sure we keep track of all pointer allocations; there's a limit per message (prevent DoS). + + trackPointerAllocation(segment.message, this); + + // NOTE: It's okay to have a pointer to the end of the segment; you'll see this when creating pointers to the + // beginning of the content of a newly-allocated composite list with zero elements. Unlike other language + // implementations buffer over/underflows are not a big issue since all buffer access is bounds checked in native + // code anyway. + + if (byteOffset < 0 || byteOffset > segment.byteLength) { + throw new Error(format(PTR_OFFSET_OUT_OF_BOUNDS, byteOffset)); + } + + trace("new %s", this); + } + + toString(): string { + return format("Pointer_%d@%a,%s,limit:%x", this.segment.id, this.byteOffset, dump(this), this._capnp.depthLimit); + } +} + +/** + * Adopt an orphaned pointer, making the pointer point to the orphaned content without copying it. + * + * @param {Orphan} src The orphan to adopt. + * @param {Pointer} p The the pointer to adopt into. + * @returns {void} + */ + +export function adopt(src: Orphan, p: T): void { + src._moveTo(p); +} + +/** + * Convert a pointer to an Orphan, zeroing out the pointer and leaving its content untouched. If the content is no + * longer needed, call `disown()` on the orphaned pointer to erase the contents as well. + * + * Call `adopt()` on the orphan with the new target pointer location to move it back into the message; the orphan + * object is then invalidated after adoption (can only adopt once!). + * + * @param {T} p The pointer to turn into an Orphan. + * @returns {Orphan} An orphaned pointer. + */ + +export function disown(p: T): Orphan { + return new Orphan(p); +} + +export function dump(p: Pointer): string { + return bufferToHex(p.segment.buffer.slice(p.byteOffset, p.byteOffset + 8)); +} + +/** + * Get the total number of bytes required to hold a list of the provided size with the given length, rounded up to the + * nearest word. + * + * @param {ListElementSize} elementSize A number describing the size of the list elements. + * @param {number} length The length of the list. + * @param {ObjectSize} [compositeSize] The size of each element in a composite list; required if + * `elementSize === ListElementSize.COMPOSITE`. + * @returns {number} The number of bytes required to hold an element of that size, or `NaN` if that is undefined. + */ + +export function getListByteLength(elementSize: ListElementSize, length: number, compositeSize?: ObjectSize): number { + switch (elementSize) { + case ListElementSize.BIT: + return padToWord((length + 7) >>> 3); + + case ListElementSize.BYTE: + case ListElementSize.BYTE_2: + case ListElementSize.BYTE_4: + case ListElementSize.BYTE_8: + case ListElementSize.POINTER: + case ListElementSize.VOID: + return padToWord(getListElementByteLength(elementSize) * length); + + /* istanbul ignore next */ + case ListElementSize.COMPOSITE: + if (compositeSize === undefined) { + throw new Error(format(PTR_INVALID_LIST_SIZE, NaN)); + } + + return length * padToWord(getByteLength(compositeSize)); + + /* istanbul ignore next */ + default: + throw new Error(PTR_INVALID_LIST_SIZE); + } +} + +/** + * Get the number of bytes required to hold a list element of the provided size. `COMPOSITE` elements do not have a + * fixed size, and `BIT` elements are packed into exactly a single bit, so these both return `NaN`. + * + * @param {ListElementSize} elementSize A number describing the size of the list elements. + * @returns {number} The number of bytes required to hold an element of that size, or `NaN` if that is undefined. + */ + +export function getListElementByteLength(elementSize: ListElementSize): number { + switch (elementSize) { + /* istanbul ignore next */ + case ListElementSize.BIT: + return NaN; + + case ListElementSize.BYTE: + return 1; + + case ListElementSize.BYTE_2: + return 2; + + case ListElementSize.BYTE_4: + return 4; + + case ListElementSize.BYTE_8: + case ListElementSize.POINTER: + return 8; + + /* istanbul ignore next */ + case ListElementSize.COMPOSITE: + // Caller has to figure it out based on the tag word. + + return NaN; + + /* istanbul ignore next */ + case ListElementSize.VOID: + return 0; + + /* istanbul ignore next */ + default: + throw new Error(format(PTR_INVALID_LIST_SIZE, elementSize)); + } +} + +/** + * Add an offset to the pointer's offset and return a new Pointer for that address. + * + * @param {number} offset The number of bytes to add to the offset. + * @param {Pointer} p The pointer to add from. + * @returns {Pointer} A new pointer to the address. + */ + +export function add(offset: number, p: Pointer): Pointer { + return new Pointer(p.segment, p.byteOffset + offset, p._capnp.depthLimit); +} + +/** + * Replace a pointer with a deep copy of the pointer at `src` and all of its contents. + * + * @param {Pointer} src The pointer to copy. + * @param {Pointer} p The pointer to copy into. + * @returns {void} + */ + +export function copyFrom(src: Pointer, p: Pointer): void { + // If the pointer is the same then this is a noop. + + if (p.segment === src.segment && p.byteOffset === src.byteOffset) { + trace("ignoring copy operation from identical pointer %s", src); + + return; + } + + // Make sure we erase this pointer's contents before moving on. If src is null, that's all we do. + + erase(p); // noop if null + + if (isNull(src)) return; + + switch (getTargetPointerType(src)) { + case PointerType.STRUCT: + copyFromStruct(src, p); + + break; + + case PointerType.LIST: + copyFromList(src, p); + + break; + + /* istanbul ignore next */ + default: + throw new Error(format(PTR_INVALID_POINTER_TYPE, getTargetPointerType(p))); + } +} + +/** + * Recursively erase a pointer, any far pointers/landing pads/tag words, and the content it points to. + * + * Note that this will leave "holes" of zeroes in the message, since the space cannot be reclaimed. With packing this + * will have a negligible effect on the final message size. + * + * FIXME: This may need protection against infinite recursion... + * + * @param {Pointer} p The pointer to erase. + * @returns {void} + */ + +export function erase(p: Pointer): void { + if (isNull(p)) return; + + // First deal with the contents. + + let c: Pointer; + + switch (getTargetPointerType(p)) { + case PointerType.STRUCT: { + const size = getTargetStructSize(p); + c = getContent(p); + + // Wipe the data section. + + c.segment.fillZeroWords(c.byteOffset, size.dataByteLength / 8); + + // Iterate over all the pointers and nuke them. + + for (let i = 0; i < size.pointerLength; i++) { + erase(add(i * 8, c)); + } + + break; + } + case PointerType.LIST: { + const elementSize = getTargetListElementSize(p); + const length = getTargetListLength(p); + let contentWords = padToWord(length * getListElementByteLength(elementSize)); + c = getContent(p); + + if (elementSize === ListElementSize.POINTER) { + for (let i = 0; i < length; i++) { + erase(new Pointer(c.segment, c.byteOffset + i * 8, p._capnp.depthLimit - 1)); + } + + // Calling erase on each pointer takes care of the content, nothing left to do here. + + break; + } else if (elementSize === ListElementSize.COMPOSITE) { + // Read some stuff from the tag word. + const tag = add(-8, c); + const compositeSize = getStructSize(tag); + const compositeByteLength = getByteLength(compositeSize); + contentWords = getOffsetWords(tag); + + // Kill the tag word. + c.segment.setWordZero(c.byteOffset - 8); + + // Recursively erase each pointer. + for (let i = 0; i < length; i++) { + for (let j = 0; j < compositeSize.pointerLength; j++) { + erase(new Pointer(c.segment, c.byteOffset + i * compositeByteLength + j * 8, p._capnp.depthLimit - 1)); + } + } + } + + c.segment.fillZeroWords(c.byteOffset, contentWords); + + break; + } + case PointerType.OTHER: + // No content. + + break; + + default: + throw new Error(format(PTR_INVALID_POINTER_TYPE, getTargetPointerType(p))); + } + + erasePointer(p); +} + +/** + * Set the pointer (and far pointer landing pads, if applicable) to zero. Does not touch the pointer's content. + * + * @param {Pointer} p The pointer to erase. + * @returns {void} + */ + +export function erasePointer(p: Pointer): void { + if (getPointerType(p) === PointerType.FAR) { + const landingPad = followFar(p); + + if (isDoubleFar(p)) { + // Kill the double-far tag word. + + landingPad.segment.setWordZero(landingPad.byteOffset + 8); + } + + // Kill the landing pad. + + landingPad.segment.setWordZero(landingPad.byteOffset); + } + + // Finally! Kill the pointer itself... + + p.segment.setWordZero(p.byteOffset); +} + +/** + * Interpret the pointer as a far pointer, returning its target segment and offset. + * + * @param {Pointer} p The pointer to read from. + * @returns {Pointer} A pointer to the far target. + */ + +export function followFar(p: Pointer): Pointer { + const targetSegment = p.segment.message.getSegment(p.segment.getUint32(p.byteOffset + 4)); + const targetWordOffset = p.segment.getUint32(p.byteOffset) >>> 3; + + return new Pointer(targetSegment, targetWordOffset * 8, p._capnp.depthLimit - 1); +} + +/** + * If the pointer address references a far pointer, follow it to the location where the actual pointer data is written. + * Otherwise, returns the pointer unmodified. + * + * @param {Pointer} p The pointer to read from. + * @returns {Pointer} A new pointer representing the target location, or `p` if it is not a far pointer. + */ + +export function followFars(p: Pointer): Pointer { + if (getPointerType(p) === PointerType.FAR) { + const landingPad = followFar(p); + + if (isDoubleFar(p)) landingPad.byteOffset += 8; + + return landingPad; + } + + return p; +} + +export function getCapabilityId(p: Pointer): number { + return p.segment.getUint32(p.byteOffset + 4); +} + +function isCompositeList(p: Pointer): boolean { + return getTargetPointerType(p) === PointerType.LIST && getTargetListElementSize(p) === ListElementSize.COMPOSITE; +} + +/** + * Obtain the location of the pointer's content, following far pointers as needed. + * If the pointer is a struct pointer and `compositeIndex` is set, it will be offset by a multiple of the struct's size. + * + * @param {Pointer} p The pointer to read from. + * @param {boolean} [ignoreCompositeIndex] If true, will not follow the composite struct pointer's composite index and + * instead return a pointer to the parent list's contents (also the beginning of the first struct). + * @returns {Pointer} A pointer to the beginning of the pointer's content. + */ + +export function getContent(p: Pointer, ignoreCompositeIndex?: boolean): Pointer { + let c: Pointer; + + if (isDoubleFar(p)) { + const landingPad = followFar(p); + c = new Pointer(p.segment.message.getSegment(getFarSegmentId(landingPad)), getOffsetWords(landingPad) * 8); + } else { + const target = followFars(p); + c = new Pointer(target.segment, target.byteOffset + 8 + getOffsetWords(target) * 8); + } + + if (isCompositeList(p)) c.byteOffset += 8; + + if (!ignoreCompositeIndex && p._capnp.compositeIndex !== undefined) { + // Seek backwards by one word so we can read the struct size off the tag word. + + c.byteOffset -= 8; + + // Seek ahead by `compositeIndex` multiples of the struct's total size. + + c.byteOffset += 8 + p._capnp.compositeIndex * getByteLength(padObjectToWord(getStructSize(c))); + } + + return c; +} + +/** + * Read the target segment ID from a far pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The target segment ID. + */ + +export function getFarSegmentId(p: Pointer): number { + return p.segment.getUint32(p.byteOffset + 4); +} + +/** + * Get a number indicating the size of the list's elements. + * + * @param {Pointer} p The pointer to read from. + * @returns {ListElementSize} The size of the list's elements. + */ + +export function getListElementSize(p: Pointer): ListElementSize { + return p.segment.getUint32(p.byteOffset + 4) & LIST_SIZE_MASK; +} + +/** + * Get the number of elements in a list pointer. For composite lists, it instead represents the total number of words in + * the list (not counting the tag word). + * + * This method does **not** attempt to distinguish between composite and non-composite lists. To get the correct + * length for composite lists use `getTargetListLength()` instead. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The length of the list, or total number of words for composite lists. + */ + +export function getListLength(p: Pointer): number { + return p.segment.getUint32(p.byteOffset + 4) >>> 3; +} + +/** + * Get the offset (in words) from the end of a pointer to the start of its content. For struct pointers, this is the + * beginning of the data section, and for list pointers it is the location of the first element. The value should + * always be zero for interface pointers. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The offset, in words, from the end of the pointer to the start of the data section. + */ + +export function getOffsetWords(p: Pointer): number { + const o = p.segment.getInt32(p.byteOffset); + + // Far pointers only have 29 offset bits. + return o & 2 ? o >> 3 : o >> 2; +} + +/** + * Look up the pointer's type. + * + * @param {Pointer} p The pointer to read from. + * @returns {PointerType} The type of pointer. + */ + +export function getPointerType(p: Pointer): PointerType { + return p.segment.getUint32(p.byteOffset) & POINTER_TYPE_MASK; +} + +/** + * Read the number of data words from this struct pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The number of data words in the struct. + */ + +export function getStructDataWords(p: Pointer): number { + return p.segment.getUint16(p.byteOffset + 4); +} + +/** + * Read the number of pointers contained in this struct pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The number of pointers in this struct. + */ + +export function getStructPointerLength(p: Pointer): number { + return p.segment.getUint16(p.byteOffset + 6); +} + +/** + * Get an object describing this struct pointer's size. + * + * @param {Pointer} p The pointer to read from. + * @returns {ObjectSize} The size of the struct. + */ + +export function getStructSize(p: Pointer): ObjectSize { + return new ObjectSize(getStructDataWords(p) * 8, getStructPointerLength(p)); +} + +/** + * Get a pointer to this pointer's composite list tag word, following far pointers as needed. + * + * @param {Pointer} p The pointer to read from. + * @returns {Pointer} A pointer to the list's composite tag word. + */ + +export function getTargetCompositeListTag(p: Pointer): Pointer { + const c = getContent(p); + + // The composite list tag is always one word before the content. + + c.byteOffset -= 8; + + return c; +} + +/** + * Get the object size for the target composite list, following far pointers as needed. + * + * @param {Pointer} p The pointer to read from. + * @returns {ObjectSize} An object describing the size of each struct in the list. + */ + +export function getTargetCompositeListSize(p: Pointer): ObjectSize { + return getStructSize(getTargetCompositeListTag(p)); +} + +/** + * Get the size of the list elements referenced by this pointer, following far pointers if necessary. + * + * @param {Pointer} p The pointer to read from. + * @returns {ListElementSize} The size of the elements in the list. + */ + +export function getTargetListElementSize(p: Pointer): ListElementSize { + return getListElementSize(followFars(p)); +} + +/** + * Get the length of the list referenced by this pointer, following far pointers if necessary. If the list is a + * composite list, it will look up the tag word and read the length from there. + * + * @param {Pointer} p The pointer to read from. + * @returns {number} The number of elements in the list. + */ + +export function getTargetListLength(p: Pointer): number { + const t = followFars(p); + + if (getListElementSize(t) === ListElementSize.COMPOSITE) { + // The content is prefixed by a tag word; it's a struct pointer whose offset contains the list's length. + + return getOffsetWords(getTargetCompositeListTag(p)); + } + + return getListLength(t); +} + +/** + * Get the type of a pointer, following far pointers if necessary. For non-far pointers this is equivalent to calling + * `getPointerType()`. + * + * The target of a far pointer can never be another far pointer, and this method will throw if such a situation is + * encountered. + * + * @param {Pointer} p The pointer to read from. + * @returns {PointerType} The type of pointer referenced by this pointer. + */ + +export function getTargetPointerType(p: Pointer): PointerType { + const t = getPointerType(followFars(p)); + + if (t === PointerType.FAR) throw new Error(format(PTR_INVALID_FAR_TARGET, p)); + + return t; +} + +/** + * Get the size of the struct referenced by a pointer, following far pointers if necessary. + * + * @param {Pointer} p The poiner to read from. + * @returns {ObjectSize} The size of the struct referenced by this pointer. + */ + +export function getTargetStructSize(p: Pointer): ObjectSize { + return getStructSize(followFars(p)); +} + +/** + * Initialize a pointer to point at the data in the content segment. If the content segment is not the same as the + * pointer's segment, this will allocate and write far pointers as needed. Nothing is written otherwise. + * + * The return value includes a pointer to write the pointer's actual data to (the eventual far target), and the offset + * value (in words) to use for that pointer. In the case of double-far pointers this offset will always be zero. + * + * @param {Segment} contentSegment The segment containing this pointer's content. + * @param {number} contentOffset The offset within the content segment for the beginning of this pointer's content. + * @param {Pointer} p The pointer to initialize. + * @returns {PointerAllocationResult} An object containing a pointer (where the pointer data should be written), and + * the value to use as the offset for that pointer. + */ + +export function initPointer(contentSegment: Segment, contentOffset: number, p: Pointer): PointerAllocationResult { + if (p.segment !== contentSegment) { + // Need a far pointer. + + trace("Initializing far pointer %s -> %s.", p, contentSegment); + + if (!contentSegment.hasCapacity(8)) { + // GAH! Not enough space in the content segment for a landing pad so we need a double far pointer. + + const landingPad = p.segment.allocate(16); + + trace("GAH! Initializing double-far pointer in %s from %s -> %s.", p, contentSegment, landingPad); + + setFarPointer(true, landingPad.byteOffset / 8, landingPad.segment.id, p); + setFarPointer(false, contentOffset / 8, contentSegment.id, landingPad); + + landingPad.byteOffset += 8; + + return new PointerAllocationResult(landingPad, 0); + } + + // Allocate a far pointer landing pad in the target segment. + + const landingPad = contentSegment.allocate(8); + + if (landingPad.segment.id !== contentSegment.id) { + throw new Error(INVARIANT_UNREACHABLE_CODE); + } + + setFarPointer(false, landingPad.byteOffset / 8, landingPad.segment.id, p); + + return new PointerAllocationResult(landingPad, (contentOffset - landingPad.byteOffset - 8) / 8); + } + + trace("Initializing intra-segment pointer %s -> %a.", p, contentOffset); + + return new PointerAllocationResult(p, (contentOffset - p.byteOffset - 8) / 8); +} + +/** + * Check if the pointer is a double-far pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {boolean} `true` if it is a double-far pointer, `false` otherwise. + */ + +export function isDoubleFar(p: Pointer): boolean { + return getPointerType(p) === PointerType.FAR && (p.segment.getUint32(p.byteOffset) & POINTER_DOUBLE_FAR_MASK) !== 0; +} + +/** + * Quickly check to see if the pointer is "null". A "null" pointer is a zero word, equivalent to an empty struct + * pointer. + * + * @param {Pointer} p The pointer to read from. + * @returns {boolean} `true` if the pointer is "null". + */ + +export function isNull(p: Pointer): boolean { + return p.segment.isWordZero(p.byteOffset); +} + +/** + * Relocate a pointer to the given destination, ensuring that it points to the same content. This will create far + * pointers as needed if the content is in a different segment than the destination. After the relocation the source + * pointer will be erased and is no longer valid. + * + * @param {Pointer} dst The desired location for the `src` pointer. Any existing contents will be erased before + * relocating! + * @param {Pointer} src The pointer to relocate. + * @returns {void} + */ + +export function relocateTo(dst: Pointer, src: Pointer): void { + const t = followFars(src); + const lo = t.segment.getUint8(t.byteOffset) & 0x03; // discard the offset + const hi = t.segment.getUint32(t.byteOffset + 4); + + // Make sure anything dst was pointing to is wiped out. + erase(dst); + + const res = initPointer(t.segment, t.byteOffset + 8 + getOffsetWords(t) * 8, dst); + + // Keep the low 2 bits and write the new offset. + res.pointer.segment.setUint32(res.pointer.byteOffset, lo | (res.offsetWords << 2)); + // Keep the high 32 bits intact. + res.pointer.segment.setUint32(res.pointer.byteOffset + 4, hi); + + erasePointer(src); +} + +/** + * Write a far pointer. + * + * @param {boolean} doubleFar Set to `true` if this is a double far pointer. + * @param {number} offsetWords The offset, in words, to the target pointer. + * @param {number} segmentId The segment the target pointer is located in. + * @param {Pointer} p The pointer to write to. + * @returns {void} + */ + +export function setFarPointer(doubleFar: boolean, offsetWords: number, segmentId: number, p: Pointer): void { + const A = PointerType.FAR; + const B = doubleFar ? 1 : 0; + const C = offsetWords; + const D = segmentId; + + p.segment.setUint32(p.byteOffset, A | (B << 2) | (C << 3)); + p.segment.setUint32(p.byteOffset + 4, D); +} + +/** + * Write a raw interface pointer. + * + * @param {number} capId The capability ID. + * @param {Pointer} p The pointer to write to. + * @returns {void} + */ + +export function setInterfacePointer(capId: number, p: Pointer): void { + p.segment.setUint32(p.byteOffset, PointerType.OTHER); + p.segment.setUint32(p.byteOffset + 4, capId); +} + +/** + * Write a raw list pointer. + * + * @param {number} offsetWords The number of words from the end of this pointer to the beginning of the list content. + * @param {ListElementSize} size The size of each element in the list. + * @param {number} length The number of elements in the list. + * @param {Pointer} p The pointer to write to. + * @param {ObjectSize} [compositeSize] For composite lists this describes the size of each element in this list. This + * is required for composite lists. + * @returns {void} + */ + +export function setListPointer( + offsetWords: number, + size: ListElementSize, + length: number, + p: Pointer, + compositeSize?: ObjectSize +): void { + const A = PointerType.LIST; + const B = offsetWords; + const C = size; + let D = length; + + if (size === ListElementSize.COMPOSITE) { + if (compositeSize === undefined) { + throw new TypeError(TYPE_COMPOSITE_SIZE_UNDEFINED); + } + + D *= getWordLength(compositeSize); + } + + p.segment.setUint32(p.byteOffset, A | (B << 2)); + p.segment.setUint32(p.byteOffset + 4, C | (D << 3)); +} + +/** + * Write a raw struct pointer. + * + * @param {number} offsetWords The number of words from the end of this pointer to the beginning of the struct's data + * section. + * @param {ObjectSize} size An object describing the size of the struct. + * @param {Pointer} p The pointer to write to. + * @returns {void} + */ + +export function setStructPointer(offsetWords: number, size: ObjectSize, p: Pointer): void { + const A = PointerType.STRUCT; + const B = offsetWords; + const C = getDataWordLength(size); + const D = size.pointerLength; + + p.segment.setUint32(p.byteOffset, A | (B << 2)); + p.segment.setUint16(p.byteOffset + 4, C); + p.segment.setUint16(p.byteOffset + 6, D); +} + +/** + * Read some bits off a pointer to make sure it has the right pointer data. + * + * @param {PointerType} pointerType The expected pointer type. + * @param {Pointer} p The pointer to validate. + * @param {ListElementSize} [elementSize] For list pointers, the expected element size. Leave this + * undefined for struct pointers. + * @returns {void} + */ + +export function validate(pointerType: PointerType, p: Pointer, elementSize?: ListElementSize): void { + if (isNull(p)) return; + + const t = followFars(p); + + // Check the pointer type. + + const A = t.segment.getUint32(t.byteOffset) & POINTER_TYPE_MASK; + + if (A !== pointerType) { + throw new Error(format(PTR_WRONG_POINTER_TYPE, p, pointerType)); + } + + // Check the list element size, if provided. + + if (elementSize !== undefined) { + const C = t.segment.getUint32(t.byteOffset + 4) & LIST_SIZE_MASK; + + if (C !== elementSize) { + throw new Error(format(PTR_WRONG_LIST_TYPE, p, ListElementSize[elementSize])); + } + } +} + +export function copyFromList(src: Pointer, dst: Pointer): void { + if (dst._capnp.depthLimit <= 0) throw new Error(PTR_DEPTH_LIMIT_EXCEEDED); + + const srcContent = getContent(src); + const srcElementSize = getTargetListElementSize(src); + const srcLength = getTargetListLength(src); + let srcCompositeSize; + let srcStructByteLength; + let dstContent; + + if (srcElementSize === ListElementSize.POINTER) { + dstContent = dst.segment.allocate(srcLength << 3); + + // Recursively copy each pointer in the list. + + for (let i = 0; i < srcLength; i++) { + const srcPtr = new Pointer(srcContent.segment, srcContent.byteOffset + (i << 3), src._capnp.depthLimit - 1); + const dstPtr = new Pointer(dstContent.segment, dstContent.byteOffset + (i << 3), dst._capnp.depthLimit - 1); + + copyFrom(srcPtr, dstPtr); + } + } else if (srcElementSize === ListElementSize.COMPOSITE) { + srcCompositeSize = padObjectToWord(getTargetCompositeListSize(src)); + srcStructByteLength = getByteLength(srcCompositeSize); + + dstContent = dst.segment.allocate(getByteLength(srcCompositeSize) * srcLength + 8); + + // Copy the tag word. + + dstContent.segment.copyWord(dstContent.byteOffset, srcContent.segment, srcContent.byteOffset - 8); + + // Copy the entire contents, including all pointers. This should be more efficient than making `srcLength` + // copies to skip the pointer sections, and we're about to rewrite all those pointers anyway. + + // PERF: Skip this step if the composite struct only contains pointers. + if (srcCompositeSize.dataByteLength > 0) { + const wordLength = getWordLength(srcCompositeSize) * srcLength; + + dstContent.segment.copyWords(dstContent.byteOffset + 8, srcContent.segment, srcContent.byteOffset, wordLength); + } + + // Recursively copy all the pointers in each struct. + + for (let i = 0; i < srcLength; i++) { + for (let j = 0; j < srcCompositeSize.pointerLength; j++) { + const offset = i * srcStructByteLength + srcCompositeSize.dataByteLength + (j << 3); + + const srcPtr = new Pointer(srcContent.segment, srcContent.byteOffset + offset, src._capnp.depthLimit - 1); + const dstPtr = new Pointer(dstContent.segment, dstContent.byteOffset + offset + 8, dst._capnp.depthLimit - 1); + + copyFrom(srcPtr, dstPtr); + } + } + } else { + const byteLength = padToWord( + srcElementSize === ListElementSize.BIT + ? (srcLength + 7) >>> 3 + : getListElementByteLength(srcElementSize) * srcLength + ); + const wordLength = byteLength >>> 3; + + dstContent = dst.segment.allocate(byteLength); + + // Copy all of the list contents word-by-word. + + dstContent.segment.copyWords(dstContent.byteOffset, srcContent.segment, srcContent.byteOffset, wordLength); + } + + // Initialize the list pointer. + + const res = initPointer(dstContent.segment, dstContent.byteOffset, dst); + setListPointer(res.offsetWords, srcElementSize, srcLength, res.pointer, srcCompositeSize); +} + +export function copyFromStruct(src: Pointer, dst: Pointer): void { + if (dst._capnp.depthLimit <= 0) throw new Error(PTR_DEPTH_LIMIT_EXCEEDED); + + const srcContent = getContent(src); + const srcSize = getTargetStructSize(src); + const srcDataWordLength = getDataWordLength(srcSize); + + // Allocate space for the destination content. + + const dstContent = dst.segment.allocate(getByteLength(srcSize)); + + // Copy the data section. + + dstContent.segment.copyWords(dstContent.byteOffset, srcContent.segment, srcContent.byteOffset, srcDataWordLength); + + // Copy the pointer section. + + for (let i = 0; i < srcSize.pointerLength; i++) { + const offset = srcSize.dataByteLength + i * 8; + + const srcPtr = new Pointer(srcContent.segment, srcContent.byteOffset + offset, src._capnp.depthLimit - 1); + const dstPtr = new Pointer(dstContent.segment, dstContent.byteOffset + offset, dst._capnp.depthLimit - 1); + + copyFrom(srcPtr, dstPtr); + } + + // Don't touch dst if it's already initialized as a composite list pointer. With composite struct pointers there's + // no pointer to copy here and we've already copied the contents. + + if (dst._capnp.compositeList) return; + + // Initialize the struct pointer. + + const res = initPointer(dstContent.segment, dstContent.byteOffset, dst); + setStructPointer(res.offsetWords, srcSize, res.pointer); +} + +/** + * Track the allocation of a new Pointer object. + * + * This will decrement an internal counter tracking how many bytes have been traversed in the message so far. After + * a certain limit, this method will throw an error in order to prevent a certain class of DoS attacks. + * + * @param {Message} message The message the pointer belongs to. + * @param {Pointer} p The pointer being allocated. + * @returns {void} + */ + +export function trackPointerAllocation(message: Message, p: Pointer): void { + message._capnp.traversalLimit -= 8; + + if (message._capnp.traversalLimit <= 0) { + throw new Error(format(PTR_TRAVERSAL_LIMIT_EXCEEDED, p)); + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/struct.d.ts b/node_modules/capnp-ts/src/serialization/pointers/struct.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e6ef92c569f7bcaab4dc88d1f840b704b428b27 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/struct.d.ts @@ -0,0 +1,349 @@ +/** + * @author jdiaz5513 + */ +import { Int64, Uint64 } from "../../types/index"; +import { ObjectSize } from "../object-size"; +import { Segment } from "../segment"; +import { Data } from "./data"; +import { List, ListCtor } from "./list"; +import { Orphan } from "./orphan"; +import { _Pointer, _PointerCtor, Pointer, PointerCtor } from "./pointer"; +export interface _StructCtor extends _PointerCtor { + readonly id: string; + readonly size: ObjectSize; +} +export interface StructCtor { + readonly _capnp: _StructCtor; + new (segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number): T; +} +export interface _Struct extends _Pointer { + compositeIndex?: number; +} +export declare class Struct extends Pointer { + static readonly _capnp: { + displayName: string; + }; + static readonly getAs: typeof getAs; + static readonly getBit: typeof getBit; + static readonly getData: typeof getData; + static readonly getFloat32: typeof getFloat32; + static readonly getFloat64: typeof getFloat64; + static readonly getUint8: typeof getUint8; + static readonly getUint16: typeof getUint16; + static readonly getUint32: typeof getUint32; + static readonly getUint64: typeof getUint64; + static readonly getInt8: typeof getInt8; + static readonly getInt16: typeof getInt16; + static readonly getInt32: typeof getInt32; + static readonly getInt64: typeof getInt64; + static readonly getList: typeof getList; + static readonly getPointer: typeof getPointer; + static readonly getPointerAs: typeof getPointerAs; + static readonly getStruct: typeof getStruct; + static readonly getText: typeof getText; + static readonly initData: typeof initData; + static readonly initList: typeof initList; + static readonly initStruct: typeof initStruct; + static readonly initStructAt: typeof initStructAt; + static readonly setBit: typeof setBit; + static readonly setFloat32: typeof setFloat32; + static readonly setFloat64: typeof setFloat64; + static readonly setUint8: typeof setUint8; + static readonly setUint16: typeof setUint16; + static readonly setUint32: typeof setUint32; + static readonly setUint64: typeof setUint64; + static readonly setInt8: typeof setInt8; + static readonly setInt16: typeof setInt16; + static readonly setInt32: typeof setInt32; + static readonly setInt64: typeof setInt64; + static readonly setText: typeof setText; + static readonly testWhich: typeof testWhich; + readonly _capnp: _Struct; + /** + * Create a new pointer to a struct. + * + * @constructor {Struct} + * @param {Segment} segment The segment the pointer resides in. + * @param {number} byteOffset The offset from the beginning of the segment to the beginning of the pointer data. + * @param {any} [depthLimit=MAX_DEPTH] The nesting depth limit for this object. + * @param {number} [compositeIndex] If set, then this pointer is actually a reference to a composite list + * (`this._getPointerTargetType() === PointerType.LIST`), and this number is used as the index of the struct within + * the list. It is not valid to call `initStruct()` on a composite struct – the struct contents are initialized when + * the list pointer is initialized. + */ + constructor(segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number); + static toString(): string; + toString(): string; +} +/** + * Initialize a struct with the provided object size. This will allocate new space for the struct contents, ideally in + * the same segment as this pointer. + * + * @param {ObjectSize} size An object describing the size of the struct's data and pointer sections. + * @param {Struct} s The struct to initialize. + * @returns {void} + */ +export declare function initStruct(size: ObjectSize, s: Struct): void; +export declare function initStructAt(index: number, StructClass: StructCtor, p: Pointer): T; +/** + * Make a shallow copy of a struct's contents and update the pointer to point to the new content. The data and pointer + * sections will be resized to the provided size. + * + * WARNING: This method can cause data loss if `dstSize` is smaller than the original size! + * + * @param {ObjectSize} dstSize The desired size for the struct contents. + * @param {Struct} s The struct to resize. + * @returns {void} + */ +export declare function resize(dstSize: ObjectSize, s: Struct): void; +export declare function adopt(src: Orphan, s: Struct): void; +export declare function disown(s: Struct): Orphan; +/** + * Convert a struct to a struct of the provided class. Particularly useful when casting to nested group types. + * + * @protected + * @template T + * @param {StructCtor} StructClass The struct class to convert to. Not particularly useful if `Struct`. + * @param {Struct} s The struct to convert. + * @returns {T} A new instance of the desired struct class pointing to the same location. + */ +export declare function getAs(StructClass: StructCtor, s: Struct): T; +/** + * Read a boolean (bit) value out of a struct. + * + * @protected + * @param {number} bitOffset The offset in **bits** from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {boolean} The value. + */ +export declare function getBit(bitOffset: number, s: Struct, defaultMask?: DataView): boolean; +export declare function getData(index: number, s: Struct, defaultValue?: Pointer): Data; +export declare function getDataSection(s: Struct): Pointer; +/** + * Read a float32 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getFloat32(byteOffset: number, s: Struct, defaultMask?: DataView): number; +/** + * Read a float64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getFloat64(byteOffset: number, s: Struct, defaultMask?: DataView): number; +/** + * Read an int16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getInt16(byteOffset: number, s: Struct, defaultMask?: DataView): number; +/** + * Read an int32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getInt32(byteOffset: number, s: Struct, defaultMask?: DataView): number; +/** + * Read an int64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getInt64(byteOffset: number, s: Struct, defaultMask?: DataView): Int64; +/** + * Read an int8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getInt8(byteOffset: number, s: Struct, defaultMask?: DataView): number; +export declare function getList(index: number, ListClass: ListCtor, s: Struct, defaultValue?: Pointer): List; +export declare function getPointer(index: number, s: Struct): Pointer; +export declare function getPointerAs(index: number, PointerClass: PointerCtor, s: Struct): T; +export declare function getPointerSection(s: Struct): Pointer; +export declare function getSize(s: Struct): ObjectSize; +export declare function getStruct(index: number, StructClass: StructCtor, s: Struct, defaultValue?: Pointer): T; +export declare function getText(index: number, s: Struct, defaultValue?: string): string; +/** + * Read an uint16 value out of a struct.. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getUint16(byteOffset: number, s: Struct, defaultMask?: DataView): number; +/** + * Read an uint32 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getUint32(byteOffset: number, s: Struct, defaultMask?: DataView): number; +/** + * Read an uint64 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getUint64(byteOffset: number, s: Struct, defaultMask?: DataView): Uint64; +/** + * Read an uint8 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +export declare function getUint8(byteOffset: number, s: Struct, defaultMask?: DataView): number; +export declare function getVoid(): void; +export declare function initData(index: number, length: number, s: Struct): Data; +export declare function initList(index: number, ListClass: ListCtor, length: number, s: Struct): List; +/** + * Write a boolean (bit) value to the struct. + * + * @protected + * @param {number} bitOffset The offset in **bits** from the start of the data section. + * @param {boolean} value The value to write (writes a 0 for `false`, 1 for `true`). + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setBit(bitOffset: number, value: boolean, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive float32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setFloat32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive float64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setFloat64(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive int16 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setInt16(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive int32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setInt32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive int64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setInt64(byteOffset: number, value: Int64, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive int8 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setInt8(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; +export declare function setPointer(index: number, value: Pointer, s: Struct): void; +export declare function setText(index: number, value: string, s: Struct): void; +/** + * Write a primitive uint16 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setUint16(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive uint32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setUint32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive uint64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setUint64(byteOffset: number, value: Uint64, s: Struct, defaultMask?: DataView): void; +/** + * Write a primitive uint8 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +export declare function setUint8(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; +export declare function setVoid(): void; +export declare function testWhich(name: string, found: number, wanted: number, s: Struct): void; +export declare function checkDataBounds(byteOffset: number, byteLength: number, s: Struct): void; +export declare function checkPointerBounds(index: number, s: Struct): void; diff --git a/node_modules/capnp-ts/src/serialization/pointers/struct.js b/node_modules/capnp-ts/src/serialization/pointers/struct.js new file mode 100644 index 0000000000000000000000000000000000000000..bc14e52da956002d9191336a3da2a0752731bf6b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/struct.js @@ -0,0 +1,839 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.checkPointerBounds = exports.checkDataBounds = exports.testWhich = exports.setVoid = exports.setUint8 = exports.setUint64 = exports.setUint32 = exports.setUint16 = exports.setText = exports.setPointer = exports.setInt8 = exports.setInt64 = exports.setInt32 = exports.setInt16 = exports.setFloat64 = exports.setFloat32 = exports.setBit = exports.initList = exports.initData = exports.getVoid = exports.getUint8 = exports.getUint64 = exports.getUint32 = exports.getUint16 = exports.getText = exports.getStruct = exports.getSize = exports.getPointerSection = exports.getPointerAs = exports.getPointer = exports.getList = exports.getInt8 = exports.getInt64 = exports.getInt32 = exports.getInt16 = exports.getFloat64 = exports.getFloat32 = exports.getDataSection = exports.getData = exports.getBit = exports.getAs = exports.disown = exports.adopt = exports.resize = exports.initStructAt = exports.initStruct = exports.Struct = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("../../constants"); +const index_1 = require("../../types/index"); +const util_1 = require("../../util"); +const list_element_size_1 = require("../list-element-size"); +const object_size_1 = require("../object-size"); +const data_1 = require("./data"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const pointer_type_1 = require("./pointer-type"); +const text_1 = require("./text"); +const errors_1 = require("../../errors"); +const trace = debug_1.default("capnp:struct"); +trace("load"); +// Used to apply bit masks (default values). +const TMP_WORD = new DataView(new ArrayBuffer(8)); +class Struct extends pointer_1.Pointer { + /** + * Create a new pointer to a struct. + * + * @constructor {Struct} + * @param {Segment} segment The segment the pointer resides in. + * @param {number} byteOffset The offset from the beginning of the segment to the beginning of the pointer data. + * @param {any} [depthLimit=MAX_DEPTH] The nesting depth limit for this object. + * @param {number} [compositeIndex] If set, then this pointer is actually a reference to a composite list + * (`this._getPointerTargetType() === PointerType.LIST`), and this number is used as the index of the struct within + * the list. It is not valid to call `initStruct()` on a composite struct – the struct contents are initialized when + * the list pointer is initialized. + */ + constructor(segment, byteOffset, depthLimit = constants_1.MAX_DEPTH, compositeIndex) { + super(segment, byteOffset, depthLimit); + this._capnp.compositeIndex = compositeIndex; + this._capnp.compositeList = compositeIndex !== undefined; + } + static toString() { + return this._capnp.displayName; + } + toString() { + return (`Struct_${super.toString()}` + + `${this._capnp.compositeIndex === undefined ? "" : `,ci:${this._capnp.compositeIndex}`}`); + } +} +exports.Struct = Struct; +Struct._capnp = { + displayName: "Struct", +}; +Struct.getAs = getAs; +Struct.getBit = getBit; +Struct.getData = getData; +Struct.getFloat32 = getFloat32; +Struct.getFloat64 = getFloat64; +Struct.getUint8 = getUint8; +Struct.getUint16 = getUint16; +Struct.getUint32 = getUint32; +Struct.getUint64 = getUint64; +Struct.getInt8 = getInt8; +Struct.getInt16 = getInt16; +Struct.getInt32 = getInt32; +Struct.getInt64 = getInt64; +Struct.getList = getList; +Struct.getPointer = getPointer; +Struct.getPointerAs = getPointerAs; +Struct.getStruct = getStruct; +Struct.getText = getText; +Struct.initData = initData; +Struct.initList = initList; +Struct.initStruct = initStruct; +Struct.initStructAt = initStructAt; +Struct.setBit = setBit; +Struct.setFloat32 = setFloat32; +Struct.setFloat64 = setFloat64; +Struct.setUint8 = setUint8; +Struct.setUint16 = setUint16; +Struct.setUint32 = setUint32; +Struct.setUint64 = setUint64; +Struct.setInt8 = setInt8; +Struct.setInt16 = setInt16; +Struct.setInt32 = setInt32; +Struct.setInt64 = setInt64; +Struct.setText = setText; +Struct.testWhich = testWhich; +/** + * Initialize a struct with the provided object size. This will allocate new space for the struct contents, ideally in + * the same segment as this pointer. + * + * @param {ObjectSize} size An object describing the size of the struct's data and pointer sections. + * @param {Struct} s The struct to initialize. + * @returns {void} + */ +function initStruct(size, s) { + if (s._capnp.compositeIndex !== undefined) { + throw new Error(util_1.format(errors_1.PTR_INIT_COMPOSITE_STRUCT, s)); + } + // Make sure to clear existing contents before overwriting the pointer data (erase is a noop if already empty). + pointer_1.erase(s); + const c = s.segment.allocate(object_size_1.getByteLength(size)); + const res = pointer_1.initPointer(c.segment, c.byteOffset, s); + pointer_1.setStructPointer(res.offsetWords, size, res.pointer); +} +exports.initStruct = initStruct; +function initStructAt(index, StructClass, p) { + const s = getPointerAs(index, StructClass, p); + initStruct(StructClass._capnp.size, s); + return s; +} +exports.initStructAt = initStructAt; +/** + * Make a shallow copy of a struct's contents and update the pointer to point to the new content. The data and pointer + * sections will be resized to the provided size. + * + * WARNING: This method can cause data loss if `dstSize` is smaller than the original size! + * + * @param {ObjectSize} dstSize The desired size for the struct contents. + * @param {Struct} s The struct to resize. + * @returns {void} + */ +function resize(dstSize, s) { + const srcSize = getSize(s); + const srcContent = pointer_1.getContent(s); + const dstContent = s.segment.allocate(object_size_1.getByteLength(dstSize)); + // Only copy the data section for now. The pointer section will need to be rewritten. + dstContent.segment.copyWords(dstContent.byteOffset, srcContent.segment, srcContent.byteOffset, Math.min(object_size_1.getDataWordLength(srcSize), object_size_1.getDataWordLength(dstSize))); + const res = pointer_1.initPointer(dstContent.segment, dstContent.byteOffset, s); + pointer_1.setStructPointer(res.offsetWords, dstSize, res.pointer); + // Iterate through the new pointer section and update the offsets so they point to the right place. This is a bit + // more complicated than it appears due to the fact that the original pointers could have been far pointers, and + // the new pointers might need to be allocated as far pointers if the segment is full. + for (let i = 0; i < Math.min(srcSize.pointerLength, dstSize.pointerLength); i++) { + const srcPtr = new pointer_1.Pointer(srcContent.segment, srcContent.byteOffset + srcSize.dataByteLength + i * 8); + if (pointer_1.isNull(srcPtr)) { + // If source pointer is null, leave the destination pointer as default null. + continue; + } + const srcPtrTarget = pointer_1.followFars(srcPtr); + const srcPtrContent = pointer_1.getContent(srcPtr); + const dstPtr = new pointer_1.Pointer(dstContent.segment, dstContent.byteOffset + dstSize.dataByteLength + i * 8); + // For composite lists the offset needs to point to the tag word, not the first element which is what getContent + // returns. + if (pointer_1.getTargetPointerType(srcPtr) === pointer_type_1.PointerType.LIST && + pointer_1.getTargetListElementSize(srcPtr) === list_element_size_1.ListElementSize.COMPOSITE) { + srcPtrContent.byteOffset -= 8; + } + const r = pointer_1.initPointer(srcPtrContent.segment, srcPtrContent.byteOffset, dstPtr); + // Read the old pointer data, but discard the original offset. + const a = srcPtrTarget.segment.getUint8(srcPtrTarget.byteOffset) & 0x03; + const b = srcPtrTarget.segment.getUint32(srcPtrTarget.byteOffset + 4); + r.pointer.segment.setUint32(r.pointer.byteOffset, a | (r.offsetWords << 2)); + r.pointer.segment.setUint32(r.pointer.byteOffset + 4, b); + } + // Zero out the old data and pointer sections. + srcContent.segment.fillZeroWords(srcContent.byteOffset, object_size_1.getWordLength(srcSize)); +} +exports.resize = resize; +function adopt(src, s) { + if (s._capnp.compositeIndex !== undefined) { + throw new Error(util_1.format(errors_1.PTR_ADOPT_COMPOSITE_STRUCT, s)); + } + pointer_1.Pointer.adopt(src, s); +} +exports.adopt = adopt; +function disown(s) { + if (s._capnp.compositeIndex !== undefined) { + throw new Error(util_1.format(errors_1.PTR_DISOWN_COMPOSITE_STRUCT, s)); + } + return pointer_1.Pointer.disown(s); +} +exports.disown = disown; +/** + * Convert a struct to a struct of the provided class. Particularly useful when casting to nested group types. + * + * @protected + * @template T + * @param {StructCtor} StructClass The struct class to convert to. Not particularly useful if `Struct`. + * @param {Struct} s The struct to convert. + * @returns {T} A new instance of the desired struct class pointing to the same location. + */ +function getAs(StructClass, s) { + return new StructClass(s.segment, s.byteOffset, s._capnp.depthLimit, s._capnp.compositeIndex); +} +exports.getAs = getAs; +/** + * Read a boolean (bit) value out of a struct. + * + * @protected + * @param {number} bitOffset The offset in **bits** from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {boolean} The value. + */ +function getBit(bitOffset, s, defaultMask) { + const byteOffset = Math.floor(bitOffset / 8); + const bitMask = 1 << bitOffset % 8; + checkDataBounds(byteOffset, 1, s); + const ds = getDataSection(s); + const v = ds.segment.getUint8(ds.byteOffset + byteOffset); + if (defaultMask === undefined) + return (v & bitMask) !== 0; + const defaultValue = defaultMask.getUint8(0); + return ((v ^ defaultValue) & bitMask) !== 0; +} +exports.getBit = getBit; +function getData(index, s, defaultValue) { + checkPointerBounds(index, s); + const ps = getPointerSection(s); + ps.byteOffset += index * 8; + const l = new data_1.Data(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); + if (pointer_1.isNull(l)) { + if (defaultValue) { + pointer_1.Pointer.copyFrom(defaultValue, l); + } + else { + list_1.List.initList(list_element_size_1.ListElementSize.BYTE, 0, l); + } + } + return l; +} +exports.getData = getData; +function getDataSection(s) { + return pointer_1.getContent(s); +} +exports.getDataSection = getDataSection; +/** + * Read a float32 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getFloat32(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 4, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getFloat32(ds.byteOffset + byteOffset); + } + const v = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); + TMP_WORD.setUint32(0, v, constants_1.NATIVE_LITTLE_ENDIAN); + return TMP_WORD.getFloat32(0, constants_1.NATIVE_LITTLE_ENDIAN); +} +exports.getFloat32 = getFloat32; +/** + * Read a float64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getFloat64(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 8, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) { + const lo = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); + const hi = ds.segment.getUint32(ds.byteOffset + byteOffset + 4) ^ defaultMask.getUint32(4, true); + TMP_WORD.setUint32(0, lo, constants_1.NATIVE_LITTLE_ENDIAN); + TMP_WORD.setUint32(4, hi, constants_1.NATIVE_LITTLE_ENDIAN); + return TMP_WORD.getFloat64(0, constants_1.NATIVE_LITTLE_ENDIAN); + } + return ds.segment.getFloat64(ds.byteOffset + byteOffset); +} +exports.getFloat64 = getFloat64; +/** + * Read an int16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getInt16(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 2, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getInt16(ds.byteOffset + byteOffset); + } + const v = ds.segment.getUint16(ds.byteOffset + byteOffset) ^ defaultMask.getUint16(0, true); + TMP_WORD.setUint16(0, v, constants_1.NATIVE_LITTLE_ENDIAN); + return TMP_WORD.getInt16(0, constants_1.NATIVE_LITTLE_ENDIAN); +} +exports.getInt16 = getInt16; +/** + * Read an int32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getInt32(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 4, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getInt32(ds.byteOffset + byteOffset); + } + const v = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint16(0, true); + TMP_WORD.setUint32(0, v, constants_1.NATIVE_LITTLE_ENDIAN); + return TMP_WORD.getInt32(0, constants_1.NATIVE_LITTLE_ENDIAN); +} +exports.getInt32 = getInt32; +/** + * Read an int64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getInt64(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 8, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getInt64(ds.byteOffset + byteOffset); + } + const lo = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); + const hi = ds.segment.getUint32(ds.byteOffset + byteOffset + 4) ^ defaultMask.getUint32(4, true); + TMP_WORD.setUint32(0, lo, constants_1.NATIVE_LITTLE_ENDIAN); + TMP_WORD.setUint32(4, hi, constants_1.NATIVE_LITTLE_ENDIAN); + return new index_1.Int64(new Uint8Array(TMP_WORD.buffer.slice(0))); +} +exports.getInt64 = getInt64; +/** + * Read an int8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getInt8(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 1, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getInt8(ds.byteOffset + byteOffset); + } + const v = ds.segment.getUint8(ds.byteOffset + byteOffset) ^ defaultMask.getUint8(0); + TMP_WORD.setUint8(0, v); + return TMP_WORD.getInt8(0); +} +exports.getInt8 = getInt8; +function getList(index, ListClass, s, defaultValue) { + checkPointerBounds(index, s); + const ps = getPointerSection(s); + ps.byteOffset += index * 8; + const l = new ListClass(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); + if (pointer_1.isNull(l)) { + if (defaultValue) { + pointer_1.Pointer.copyFrom(defaultValue, l); + } + else { + list_1.List.initList(ListClass._capnp.size, 0, l, ListClass._capnp.compositeSize); + } + } + else if (ListClass._capnp.compositeSize !== undefined) { + // If this is a composite list we need to be sure the composite elements are big enough to hold everything as + // specified in the schema. If the new schema has added fields we'll need to "resize" (shallow-copy) the list so + // it has room for the new fields. + const srcSize = pointer_1.getTargetCompositeListSize(l); + const dstSize = ListClass._capnp.compositeSize; + if (dstSize.dataByteLength > srcSize.dataByteLength || dstSize.pointerLength > srcSize.pointerLength) { + const srcContent = pointer_1.getContent(l); + const srcLength = pointer_1.getTargetListLength(l); + trace("resizing composite list %s due to protocol upgrade, new size: %d", l, object_size_1.getByteLength(dstSize) * srcLength); + // Allocate an extra 8 bytes for the tag. + const dstContent = l.segment.allocate(object_size_1.getByteLength(dstSize) * srcLength + 8); + const res = pointer_1.initPointer(dstContent.segment, dstContent.byteOffset, l); + pointer_1.setListPointer(res.offsetWords, ListClass._capnp.size, srcLength, res.pointer, dstSize); + // Write the new tag word. + pointer_1.setStructPointer(srcLength, dstSize, dstContent); + // Seek ahead past the tag word before copying the content. + dstContent.byteOffset += 8; + for (let i = 0; i < srcLength; i++) { + const srcElementOffset = srcContent.byteOffset + i * object_size_1.getByteLength(srcSize); + const dstElementOffset = dstContent.byteOffset + i * object_size_1.getByteLength(dstSize); + // Copy the data section. + dstContent.segment.copyWords(dstElementOffset, srcContent.segment, srcElementOffset, object_size_1.getWordLength(srcSize)); + // Iterate through the pointers and update the offsets so they point to the right place. + for (let j = 0; j < srcSize.pointerLength; j++) { + const srcPtr = new pointer_1.Pointer(srcContent.segment, srcElementOffset + srcSize.dataByteLength + j * 8); + const dstPtr = new pointer_1.Pointer(dstContent.segment, dstElementOffset + dstSize.dataByteLength + j * 8); + const srcPtrTarget = pointer_1.followFars(srcPtr); + const srcPtrContent = pointer_1.getContent(srcPtr); + if (pointer_1.getTargetPointerType(srcPtr) === pointer_type_1.PointerType.LIST && + pointer_1.getTargetListElementSize(srcPtr) === list_element_size_1.ListElementSize.COMPOSITE) { + srcPtrContent.byteOffset -= 8; + } + const r = pointer_1.initPointer(srcPtrContent.segment, srcPtrContent.byteOffset, dstPtr); + // Read the old pointer data, but discard the original offset. + const a = srcPtrTarget.segment.getUint8(srcPtrTarget.byteOffset) & 0x03; + const b = srcPtrTarget.segment.getUint32(srcPtrTarget.byteOffset + 4); + r.pointer.segment.setUint32(r.pointer.byteOffset, a | (r.offsetWords << 2)); + r.pointer.segment.setUint32(r.pointer.byteOffset + 4, b); + } + } + // Zero out the old content. + srcContent.segment.fillZeroWords(srcContent.byteOffset, object_size_1.getWordLength(srcSize) * srcLength); + } + } + return l; +} +exports.getList = getList; +function getPointer(index, s) { + checkPointerBounds(index, s); + const ps = getPointerSection(s); + ps.byteOffset += index * 8; + return new pointer_1.Pointer(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); +} +exports.getPointer = getPointer; +function getPointerAs(index, PointerClass, s) { + checkPointerBounds(index, s); + const ps = getPointerSection(s); + ps.byteOffset += index * 8; + return new PointerClass(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); +} +exports.getPointerAs = getPointerAs; +function getPointerSection(s) { + const ps = pointer_1.getContent(s); + ps.byteOffset += util_1.padToWord(getSize(s).dataByteLength); + return ps; +} +exports.getPointerSection = getPointerSection; +function getSize(s) { + if (s._capnp.compositeIndex !== undefined) { + // For composite lists the object size is stored in a tag word right before the content. + const c = pointer_1.getContent(s, true); + c.byteOffset -= 8; + return pointer_1.getStructSize(c); + } + return pointer_1.getTargetStructSize(s); +} +exports.getSize = getSize; +function getStruct(index, StructClass, s, defaultValue) { + const t = getPointerAs(index, StructClass, s); + if (pointer_1.isNull(t)) { + if (defaultValue) { + pointer_1.Pointer.copyFrom(defaultValue, t); + } + else { + initStruct(StructClass._capnp.size, t); + } + } + else { + pointer_1.validate(pointer_type_1.PointerType.STRUCT, t); + const ts = pointer_1.getTargetStructSize(t); + // This can happen when reading a struct that was constructed with an older version of the same schema, and new + // fields were added to the struct. A shallow copy of the struct will be made so that there's enough room for the + // data and pointer sections. This will unfortunately leave a "hole" of zeroes in the message, but that hole will + // at least compress well. + if (ts.dataByteLength < StructClass._capnp.size.dataByteLength || + ts.pointerLength < StructClass._capnp.size.pointerLength) { + trace("need to resize child struct %s", t); + resize(StructClass._capnp.size, t); + } + } + return t; +} +exports.getStruct = getStruct; +function getText(index, s, defaultValue) { + const t = text_1.Text.fromPointer(getPointer(index, s)); + // FIXME: This will perform an unnecessary string<>ArrayBuffer roundtrip. + if (pointer_1.isNull(t) && defaultValue) + t.set(0, defaultValue); + return t.get(0); +} +exports.getText = getText; +/** + * Read an uint16 value out of a struct.. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getUint16(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 2, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getUint16(ds.byteOffset + byteOffset); + } + return ds.segment.getUint16(ds.byteOffset + byteOffset) ^ defaultMask.getUint16(0, true); +} +exports.getUint16 = getUint16; +/** + * Read an uint32 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getUint32(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 4, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getUint32(ds.byteOffset + byteOffset); + } + return ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); +} +exports.getUint32 = getUint32; +/** + * Read an uint64 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getUint64(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 8, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getUint64(ds.byteOffset + byteOffset); + } + const lo = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); + const hi = ds.segment.getUint32(ds.byteOffset + byteOffset + 4) ^ defaultMask.getUint32(4, true); + TMP_WORD.setUint32(0, lo, constants_1.NATIVE_LITTLE_ENDIAN); + TMP_WORD.setUint32(4, hi, constants_1.NATIVE_LITTLE_ENDIAN); + return new index_1.Uint64(new Uint8Array(TMP_WORD.buffer.slice(0))); +} +exports.getUint64 = getUint64; +/** + * Read an uint8 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ +function getUint8(byteOffset, s, defaultMask) { + checkDataBounds(byteOffset, 1, s); + const ds = getDataSection(s); + if (defaultMask === undefined) { + return ds.segment.getUint8(ds.byteOffset + byteOffset); + } + return ds.segment.getUint8(ds.byteOffset + byteOffset) ^ defaultMask.getUint8(0); +} +exports.getUint8 = getUint8; +function getVoid() { + throw new Error(errors_1.INVARIANT_UNREACHABLE_CODE); +} +exports.getVoid = getVoid; +function initData(index, length, s) { + checkPointerBounds(index, s); + const ps = getPointerSection(s); + ps.byteOffset += index * 8; + const l = new data_1.Data(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); + pointer_1.erase(l); + list_1.List.initList(list_element_size_1.ListElementSize.BYTE, length, l); + return l; +} +exports.initData = initData; +function initList(index, ListClass, length, s) { + checkPointerBounds(index, s); + const ps = getPointerSection(s); + ps.byteOffset += index * 8; + const l = new ListClass(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); + pointer_1.erase(l); + list_1.List.initList(ListClass._capnp.size, length, l, ListClass._capnp.compositeSize); + return l; +} +exports.initList = initList; +/** + * Write a boolean (bit) value to the struct. + * + * @protected + * @param {number} bitOffset The offset in **bits** from the start of the data section. + * @param {boolean} value The value to write (writes a 0 for `false`, 1 for `true`). + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setBit(bitOffset, value, s, defaultMask) { + const byteOffset = Math.floor(bitOffset / 8); + const bitMask = 1 << bitOffset % 8; + checkDataBounds(byteOffset, 1, s); + const ds = getDataSection(s); + const b = ds.segment.getUint8(ds.byteOffset + byteOffset); + // If the default mask bit is set, that means `true` values are actually written as `0`. + if (defaultMask !== undefined) { + value = (defaultMask.getUint8(0) & bitMask) !== 0 ? !value : value; + } + ds.segment.setUint8(ds.byteOffset + byteOffset, value ? b | bitMask : b & ~bitMask); +} +exports.setBit = setBit; +/** + * Write a primitive float32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setFloat32(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 4, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) { + TMP_WORD.setFloat32(0, value, constants_1.NATIVE_LITTLE_ENDIAN); + const v = TMP_WORD.getUint32(0, constants_1.NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint32(0, true); + ds.segment.setUint32(ds.byteOffset + byteOffset, v); + return; + } + ds.segment.setFloat32(ds.byteOffset + byteOffset, value); +} +exports.setFloat32 = setFloat32; +/** + * Write a primitive float64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setFloat64(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 8, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) { + TMP_WORD.setFloat64(0, value, constants_1.NATIVE_LITTLE_ENDIAN); + const lo = TMP_WORD.getUint32(0, constants_1.NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint32(0, true); + const hi = TMP_WORD.getUint32(4, constants_1.NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint32(4, true); + ds.segment.setUint32(ds.byteOffset + byteOffset, lo); + ds.segment.setUint32(ds.byteOffset + byteOffset + 4, hi); + return; + } + ds.segment.setFloat64(ds.byteOffset + byteOffset, value); +} +exports.setFloat64 = setFloat64; +/** + * Write a primitive int16 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setInt16(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 2, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) { + TMP_WORD.setInt16(0, value, constants_1.NATIVE_LITTLE_ENDIAN); + const v = TMP_WORD.getUint16(0, constants_1.NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint16(0, true); + ds.segment.setUint16(ds.byteOffset + byteOffset, v); + return; + } + ds.segment.setInt16(ds.byteOffset + byteOffset, value); +} +exports.setInt16 = setInt16; +/** + * Write a primitive int32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setInt32(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 4, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) { + TMP_WORD.setInt32(0, value, constants_1.NATIVE_LITTLE_ENDIAN); + const v = TMP_WORD.getUint32(0, constants_1.NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint32(0, true); + ds.segment.setUint32(ds.byteOffset + byteOffset, v); + return; + } + ds.segment.setInt32(ds.byteOffset + byteOffset, value); +} +exports.setInt32 = setInt32; +/** + * Write a primitive int64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setInt64(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 8, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) { + // PERF: We could cast the Int64 to a DataView to apply the mask using four 32-bit reads, but we already have a + // typed array so avoiding the object allocation turns out to be slightly faster. Int64 is guaranteed to be in + // little-endian format by design. + for (let i = 0; i < 8; i++) { + ds.segment.setUint8(ds.byteOffset + byteOffset + i, value.buffer[i] ^ defaultMask.getUint8(i)); + } + return; + } + ds.segment.setInt64(ds.byteOffset + byteOffset, value); +} +exports.setInt64 = setInt64; +/** + * Write a primitive int8 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setInt8(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 1, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) { + TMP_WORD.setInt8(0, value); + const v = TMP_WORD.getUint8(0) ^ defaultMask.getUint8(0); + ds.segment.setUint8(ds.byteOffset + byteOffset, v); + return; + } + ds.segment.setInt8(ds.byteOffset + byteOffset, value); +} +exports.setInt8 = setInt8; +function setPointer(index, value, s) { + pointer_1.copyFrom(value, getPointer(index, s)); +} +exports.setPointer = setPointer; +function setText(index, value, s) { + text_1.Text.fromPointer(getPointer(index, s)).set(0, value); +} +exports.setText = setText; +/** + * Write a primitive uint16 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setUint16(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 2, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) + value ^= defaultMask.getUint16(0, true); + ds.segment.setUint16(ds.byteOffset + byteOffset, value); +} +exports.setUint16 = setUint16; +/** + * Write a primitive uint32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setUint32(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 4, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) + value ^= defaultMask.getUint32(0, true); + ds.segment.setUint32(ds.byteOffset + byteOffset, value); +} +exports.setUint32 = setUint32; +/** + * Write a primitive uint64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setUint64(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 8, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) { + // PERF: We could cast the Uint64 to a DataView to apply the mask using four 32-bit reads, but we already have a + // typed array so avoiding the object allocation turns out to be slightly faster. Uint64 is guaranteed to be in + // little-endian format by design. + for (let i = 0; i < 8; i++) { + ds.segment.setUint8(ds.byteOffset + byteOffset + i, value.buffer[i] ^ defaultMask.getUint8(i)); + } + return; + } + ds.segment.setUint64(ds.byteOffset + byteOffset, value); +} +exports.setUint64 = setUint64; +/** + * Write a primitive uint8 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ +function setUint8(byteOffset, value, s, defaultMask) { + checkDataBounds(byteOffset, 1, s); + const ds = getDataSection(s); + if (defaultMask !== undefined) + value ^= defaultMask.getUint8(0); + ds.segment.setUint8(ds.byteOffset + byteOffset, value); +} +exports.setUint8 = setUint8; +function setVoid() { + throw new Error(errors_1.INVARIANT_UNREACHABLE_CODE); +} +exports.setVoid = setVoid; +function testWhich(name, found, wanted, s) { + if (found !== wanted) { + throw new Error(util_1.format(errors_1.PTR_INVALID_UNION_ACCESS, s, name, found, wanted)); + } +} +exports.testWhich = testWhich; +function checkDataBounds(byteOffset, byteLength, s) { + const dataByteLength = getSize(s).dataByteLength; + if (byteOffset < 0 || byteLength < 0 || byteOffset + byteLength > dataByteLength) { + throw new Error(util_1.format(errors_1.PTR_STRUCT_DATA_OUT_OF_BOUNDS, s, byteLength, byteOffset, dataByteLength)); + } +} +exports.checkDataBounds = checkDataBounds; +function checkPointerBounds(index, s) { + const pointerLength = getSize(s).pointerLength; + if (index < 0 || index >= pointerLength) { + throw new Error(util_1.format(errors_1.PTR_STRUCT_POINTER_OUT_OF_BOUNDS, s, index, pointerLength)); + } +} +exports.checkPointerBounds = checkPointerBounds; +//# sourceMappingURL=struct.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/struct.js.map b/node_modules/capnp-ts/src/serialization/pointers/struct.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a6233ff3c54a94cc31feed9e6f5c0d37f88387d3 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/struct.js.map @@ -0,0 +1 @@ +{"version":3,"file":"struct.js","sourceRoot":"","sources":["struct.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,+CAAkE;AAClE,6CAAkD;AAClD,qCAA+C;AAC/C,4DAAuD;AACvD,gDAA6F;AAE7F,iCAA8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ACpB,MAAM,IAAI,KAAK,CAAC,aAAM,CAAC,iCAAwB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;KAC3E;AACH,CAAC;AAJD,8BAIC;AAED,SAAgB,eAAe,CAAC,UAAkB,EAAE,UAAkB,EAAE,CAAS;IAC/E,MAAM,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IAEjD,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,UAAU,GAAG,cAAc,EAAE;QAChF,MAAM,IAAI,KAAK,CAAC,aAAM,CAAC,sCAA6B,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;KACnG;AACH,CAAC;AAND,0CAMC;AAED,SAAgB,kBAAkB,CAAC,KAAa,EAAE,CAAS;IACzD,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAE/C,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,aAAa,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,aAAM,CAAC,yCAAgC,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;KACpF;AACH,CAAC;AAND,gDAMC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/struct.ts b/node_modules/capnp-ts/src/serialization/pointers/struct.ts new file mode 100644 index 0000000000000000000000000000000000000000..30b3fc0d2b855e569e1b5d522fe7f76bde82050f --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/struct.ts @@ -0,0 +1,1090 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { MAX_DEPTH, NATIVE_LITTLE_ENDIAN } from "../../constants"; +import { Int64, Uint64 } from "../../types/index"; +import { format, padToWord } from "../../util"; +import { ListElementSize } from "../list-element-size"; +import { ObjectSize, getByteLength, getDataWordLength, getWordLength } from "../object-size"; +import { Segment } from "../segment"; +import { Data } from "./data"; +import { List, ListCtor } from "./list"; +import { Orphan } from "./orphan"; +import { + _Pointer, + _PointerCtor, + Pointer, + PointerCtor, + getContent, + getStructSize, + initPointer, + erase, + setStructPointer, + followFars, + getTargetListElementSize, + getTargetPointerType, + isNull, + getTargetCompositeListSize, + getTargetListLength, + setListPointer, + getTargetStructSize, + validate, + copyFrom, +} from "./pointer"; +import { PointerType } from "./pointer-type"; +import { Text } from "./text"; +import { + PTR_INIT_COMPOSITE_STRUCT, + PTR_ADOPT_COMPOSITE_STRUCT, + PTR_DISOWN_COMPOSITE_STRUCT, + PTR_INVALID_UNION_ACCESS, + PTR_STRUCT_DATA_OUT_OF_BOUNDS, + PTR_STRUCT_POINTER_OUT_OF_BOUNDS, + INVARIANT_UNREACHABLE_CODE, +} from "../../errors"; + +const trace = initTrace("capnp:struct"); +trace("load"); + +// Used to apply bit masks (default values). +const TMP_WORD = new DataView(new ArrayBuffer(8)); + +export interface _StructCtor extends _PointerCtor { + readonly id: string; + readonly size: ObjectSize; +} + +export interface StructCtor { + readonly _capnp: _StructCtor; + + new (segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number): T; +} + +export interface _Struct extends _Pointer { + compositeIndex?: number; +} + +export class Struct extends Pointer { + static readonly _capnp = { + displayName: "Struct" as string, + }; + static readonly getAs = getAs; + static readonly getBit = getBit; + static readonly getData = getData; + static readonly getFloat32 = getFloat32; + static readonly getFloat64 = getFloat64; + static readonly getUint8 = getUint8; + static readonly getUint16 = getUint16; + static readonly getUint32 = getUint32; + static readonly getUint64 = getUint64; + static readonly getInt8 = getInt8; + static readonly getInt16 = getInt16; + static readonly getInt32 = getInt32; + static readonly getInt64 = getInt64; + static readonly getList = getList; + static readonly getPointer = getPointer; + static readonly getPointerAs = getPointerAs; + static readonly getStruct = getStruct; + static readonly getText = getText; + static readonly initData = initData; + static readonly initList = initList; + static readonly initStruct = initStruct; + static readonly initStructAt = initStructAt; + static readonly setBit = setBit; + static readonly setFloat32 = setFloat32; + static readonly setFloat64 = setFloat64; + static readonly setUint8 = setUint8; + static readonly setUint16 = setUint16; + static readonly setUint32 = setUint32; + static readonly setUint64 = setUint64; + static readonly setInt8 = setInt8; + static readonly setInt16 = setInt16; + static readonly setInt32 = setInt32; + static readonly setInt64 = setInt64; + static readonly setText = setText; + static readonly testWhich = testWhich; + + readonly _capnp!: _Struct; + + /** + * Create a new pointer to a struct. + * + * @constructor {Struct} + * @param {Segment} segment The segment the pointer resides in. + * @param {number} byteOffset The offset from the beginning of the segment to the beginning of the pointer data. + * @param {any} [depthLimit=MAX_DEPTH] The nesting depth limit for this object. + * @param {number} [compositeIndex] If set, then this pointer is actually a reference to a composite list + * (`this._getPointerTargetType() === PointerType.LIST`), and this number is used as the index of the struct within + * the list. It is not valid to call `initStruct()` on a composite struct – the struct contents are initialized when + * the list pointer is initialized. + */ + + constructor(segment: Segment, byteOffset: number, depthLimit = MAX_DEPTH, compositeIndex?: number) { + super(segment, byteOffset, depthLimit); + + this._capnp.compositeIndex = compositeIndex; + this._capnp.compositeList = compositeIndex !== undefined; + } + + static toString(): string { + return this._capnp.displayName; + } + + toString(): string { + return ( + `Struct_${super.toString()}` + + `${this._capnp.compositeIndex === undefined ? "" : `,ci:${this._capnp.compositeIndex}`}` + ); + } +} + +/** + * Initialize a struct with the provided object size. This will allocate new space for the struct contents, ideally in + * the same segment as this pointer. + * + * @param {ObjectSize} size An object describing the size of the struct's data and pointer sections. + * @param {Struct} s The struct to initialize. + * @returns {void} + */ + +export function initStruct(size: ObjectSize, s: Struct): void { + if (s._capnp.compositeIndex !== undefined) { + throw new Error(format(PTR_INIT_COMPOSITE_STRUCT, s)); + } + + // Make sure to clear existing contents before overwriting the pointer data (erase is a noop if already empty). + + erase(s); + + const c = s.segment.allocate(getByteLength(size)); + + const res = initPointer(c.segment, c.byteOffset, s); + + setStructPointer(res.offsetWords, size, res.pointer); +} + +export function initStructAt(index: number, StructClass: StructCtor, p: Pointer): T { + const s = getPointerAs(index, StructClass, p); + + initStruct(StructClass._capnp.size, s); + + return s; +} + +/** + * Make a shallow copy of a struct's contents and update the pointer to point to the new content. The data and pointer + * sections will be resized to the provided size. + * + * WARNING: This method can cause data loss if `dstSize` is smaller than the original size! + * + * @param {ObjectSize} dstSize The desired size for the struct contents. + * @param {Struct} s The struct to resize. + * @returns {void} + */ + +export function resize(dstSize: ObjectSize, s: Struct): void { + const srcSize = getSize(s); + const srcContent = getContent(s); + const dstContent = s.segment.allocate(getByteLength(dstSize)); + + // Only copy the data section for now. The pointer section will need to be rewritten. + dstContent.segment.copyWords( + dstContent.byteOffset, + srcContent.segment, + srcContent.byteOffset, + Math.min(getDataWordLength(srcSize), getDataWordLength(dstSize)) + ); + + const res = initPointer(dstContent.segment, dstContent.byteOffset, s); + + setStructPointer(res.offsetWords, dstSize, res.pointer); + + // Iterate through the new pointer section and update the offsets so they point to the right place. This is a bit + // more complicated than it appears due to the fact that the original pointers could have been far pointers, and + // the new pointers might need to be allocated as far pointers if the segment is full. + + for (let i = 0; i < Math.min(srcSize.pointerLength, dstSize.pointerLength); i++) { + const srcPtr = new Pointer(srcContent.segment, srcContent.byteOffset + srcSize.dataByteLength + i * 8); + if (isNull(srcPtr)) { + // If source pointer is null, leave the destination pointer as default null. + continue; + } + const srcPtrTarget = followFars(srcPtr); + const srcPtrContent = getContent(srcPtr); + const dstPtr = new Pointer(dstContent.segment, dstContent.byteOffset + dstSize.dataByteLength + i * 8); + + // For composite lists the offset needs to point to the tag word, not the first element which is what getContent + // returns. + + if ( + getTargetPointerType(srcPtr) === PointerType.LIST && + getTargetListElementSize(srcPtr) === ListElementSize.COMPOSITE + ) { + srcPtrContent.byteOffset -= 8; + } + + const r = initPointer(srcPtrContent.segment, srcPtrContent.byteOffset, dstPtr); + + // Read the old pointer data, but discard the original offset. + + const a = srcPtrTarget.segment.getUint8(srcPtrTarget.byteOffset) & 0x03; + const b = srcPtrTarget.segment.getUint32(srcPtrTarget.byteOffset + 4); + + r.pointer.segment.setUint32(r.pointer.byteOffset, a | (r.offsetWords << 2)); + r.pointer.segment.setUint32(r.pointer.byteOffset + 4, b); + } + + // Zero out the old data and pointer sections. + + srcContent.segment.fillZeroWords(srcContent.byteOffset, getWordLength(srcSize)); +} + +export function adopt(src: Orphan, s: Struct): void { + if (s._capnp.compositeIndex !== undefined) { + throw new Error(format(PTR_ADOPT_COMPOSITE_STRUCT, s)); + } + + Pointer.adopt(src, s); +} + +export function disown(s: Struct): Orphan { + if (s._capnp.compositeIndex !== undefined) { + throw new Error(format(PTR_DISOWN_COMPOSITE_STRUCT, s)); + } + + return Pointer.disown(s); +} + +/** + * Convert a struct to a struct of the provided class. Particularly useful when casting to nested group types. + * + * @protected + * @template T + * @param {StructCtor} StructClass The struct class to convert to. Not particularly useful if `Struct`. + * @param {Struct} s The struct to convert. + * @returns {T} A new instance of the desired struct class pointing to the same location. + */ + +export function getAs(StructClass: StructCtor, s: Struct): T { + return new StructClass(s.segment, s.byteOffset, s._capnp.depthLimit, s._capnp.compositeIndex); +} + +/** + * Read a boolean (bit) value out of a struct. + * + * @protected + * @param {number} bitOffset The offset in **bits** from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {boolean} The value. + */ + +export function getBit(bitOffset: number, s: Struct, defaultMask?: DataView): boolean { + const byteOffset = Math.floor(bitOffset / 8); + const bitMask = 1 << bitOffset % 8; + + checkDataBounds(byteOffset, 1, s); + + const ds = getDataSection(s); + + const v = ds.segment.getUint8(ds.byteOffset + byteOffset); + + if (defaultMask === undefined) return (v & bitMask) !== 0; + + const defaultValue = defaultMask.getUint8(0); + return ((v ^ defaultValue) & bitMask) !== 0; +} + +export function getData(index: number, s: Struct, defaultValue?: Pointer): Data { + checkPointerBounds(index, s); + + const ps = getPointerSection(s); + + ps.byteOffset += index * 8; + + const l = new Data(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); + + if (isNull(l)) { + if (defaultValue) { + Pointer.copyFrom(defaultValue, l); + } else { + List.initList(ListElementSize.BYTE, 0, l); + } + } + + return l; +} + +export function getDataSection(s: Struct): Pointer { + return getContent(s); +} + +/** + * Read a float32 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getFloat32(byteOffset: number, s: Struct, defaultMask?: DataView): number { + checkDataBounds(byteOffset, 4, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getFloat32(ds.byteOffset + byteOffset); + } + + const v = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); + TMP_WORD.setUint32(0, v, NATIVE_LITTLE_ENDIAN); + return TMP_WORD.getFloat32(0, NATIVE_LITTLE_ENDIAN); +} + +/** + * Read a float64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getFloat64(byteOffset: number, s: Struct, defaultMask?: DataView): number { + checkDataBounds(byteOffset, 8, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) { + const lo = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); + const hi = ds.segment.getUint32(ds.byteOffset + byteOffset + 4) ^ defaultMask.getUint32(4, true); + TMP_WORD.setUint32(0, lo, NATIVE_LITTLE_ENDIAN); + TMP_WORD.setUint32(4, hi, NATIVE_LITTLE_ENDIAN); + return TMP_WORD.getFloat64(0, NATIVE_LITTLE_ENDIAN); + } + + return ds.segment.getFloat64(ds.byteOffset + byteOffset); +} + +/** + * Read an int16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getInt16(byteOffset: number, s: Struct, defaultMask?: DataView): number { + checkDataBounds(byteOffset, 2, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getInt16(ds.byteOffset + byteOffset); + } + + const v = ds.segment.getUint16(ds.byteOffset + byteOffset) ^ defaultMask.getUint16(0, true); + TMP_WORD.setUint16(0, v, NATIVE_LITTLE_ENDIAN); + return TMP_WORD.getInt16(0, NATIVE_LITTLE_ENDIAN); +} + +/** + * Read an int32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getInt32(byteOffset: number, s: Struct, defaultMask?: DataView): number { + checkDataBounds(byteOffset, 4, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getInt32(ds.byteOffset + byteOffset); + } + + const v = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint16(0, true); + TMP_WORD.setUint32(0, v, NATIVE_LITTLE_ENDIAN); + return TMP_WORD.getInt32(0, NATIVE_LITTLE_ENDIAN); +} + +/** + * Read an int64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getInt64(byteOffset: number, s: Struct, defaultMask?: DataView): Int64 { + checkDataBounds(byteOffset, 8, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getInt64(ds.byteOffset + byteOffset); + } + + const lo = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); + const hi = ds.segment.getUint32(ds.byteOffset + byteOffset + 4) ^ defaultMask.getUint32(4, true); + TMP_WORD.setUint32(0, lo, NATIVE_LITTLE_ENDIAN); + TMP_WORD.setUint32(4, hi, NATIVE_LITTLE_ENDIAN); + return new Int64(new Uint8Array(TMP_WORD.buffer.slice(0))); +} + +/** + * Read an int8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getInt8(byteOffset: number, s: Struct, defaultMask?: DataView): number { + checkDataBounds(byteOffset, 1, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getInt8(ds.byteOffset + byteOffset); + } + + const v = ds.segment.getUint8(ds.byteOffset + byteOffset) ^ defaultMask.getUint8(0); + TMP_WORD.setUint8(0, v); + return TMP_WORD.getInt8(0); +} + +export function getList(index: number, ListClass: ListCtor, s: Struct, defaultValue?: Pointer): List { + checkPointerBounds(index, s); + + const ps = getPointerSection(s); + + ps.byteOffset += index * 8; + + const l = new ListClass(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); + + if (isNull(l)) { + if (defaultValue) { + Pointer.copyFrom(defaultValue, l); + } else { + List.initList(ListClass._capnp.size, 0, l, ListClass._capnp.compositeSize); + } + } else if (ListClass._capnp.compositeSize !== undefined) { + // If this is a composite list we need to be sure the composite elements are big enough to hold everything as + // specified in the schema. If the new schema has added fields we'll need to "resize" (shallow-copy) the list so + // it has room for the new fields. + + const srcSize = getTargetCompositeListSize(l); + const dstSize = ListClass._capnp.compositeSize; + + if (dstSize.dataByteLength > srcSize.dataByteLength || dstSize.pointerLength > srcSize.pointerLength) { + const srcContent = getContent(l); + const srcLength = getTargetListLength(l); + + trace("resizing composite list %s due to protocol upgrade, new size: %d", l, getByteLength(dstSize) * srcLength); + + // Allocate an extra 8 bytes for the tag. + const dstContent = l.segment.allocate(getByteLength(dstSize) * srcLength + 8); + + const res = initPointer(dstContent.segment, dstContent.byteOffset, l); + + setListPointer(res.offsetWords, ListClass._capnp.size, srcLength, res.pointer, dstSize); + + // Write the new tag word. + + setStructPointer(srcLength, dstSize, dstContent); + + // Seek ahead past the tag word before copying the content. + dstContent.byteOffset += 8; + + for (let i = 0; i < srcLength; i++) { + const srcElementOffset = srcContent.byteOffset + i * getByteLength(srcSize); + const dstElementOffset = dstContent.byteOffset + i * getByteLength(dstSize); + + // Copy the data section. + + dstContent.segment.copyWords(dstElementOffset, srcContent.segment, srcElementOffset, getWordLength(srcSize)); + + // Iterate through the pointers and update the offsets so they point to the right place. + + for (let j = 0; j < srcSize.pointerLength; j++) { + const srcPtr = new Pointer(srcContent.segment, srcElementOffset + srcSize.dataByteLength + j * 8); + const dstPtr = new Pointer(dstContent.segment, dstElementOffset + dstSize.dataByteLength + j * 8); + + const srcPtrTarget = followFars(srcPtr); + const srcPtrContent = getContent(srcPtr); + + if ( + getTargetPointerType(srcPtr) === PointerType.LIST && + getTargetListElementSize(srcPtr) === ListElementSize.COMPOSITE + ) { + srcPtrContent.byteOffset -= 8; + } + + const r = initPointer(srcPtrContent.segment, srcPtrContent.byteOffset, dstPtr); + + // Read the old pointer data, but discard the original offset. + + const a = srcPtrTarget.segment.getUint8(srcPtrTarget.byteOffset) & 0x03; + const b = srcPtrTarget.segment.getUint32(srcPtrTarget.byteOffset + 4); + + r.pointer.segment.setUint32(r.pointer.byteOffset, a | (r.offsetWords << 2)); + r.pointer.segment.setUint32(r.pointer.byteOffset + 4, b); + } + } + + // Zero out the old content. + + srcContent.segment.fillZeroWords(srcContent.byteOffset, getWordLength(srcSize) * srcLength); + } + } + + return l; +} + +export function getPointer(index: number, s: Struct): Pointer { + checkPointerBounds(index, s); + + const ps = getPointerSection(s); + + ps.byteOffset += index * 8; + + return new Pointer(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); +} + +export function getPointerAs(index: number, PointerClass: PointerCtor, s: Struct): T { + checkPointerBounds(index, s); + + const ps = getPointerSection(s); + + ps.byteOffset += index * 8; + + return new PointerClass(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); +} + +export function getPointerSection(s: Struct): Pointer { + const ps = getContent(s); + + ps.byteOffset += padToWord(getSize(s).dataByteLength); + + return ps; +} + +export function getSize(s: Struct): ObjectSize { + if (s._capnp.compositeIndex !== undefined) { + // For composite lists the object size is stored in a tag word right before the content. + + const c = getContent(s, true); + + c.byteOffset -= 8; + + return getStructSize(c); + } + + return getTargetStructSize(s); +} + +export function getStruct( + index: number, + StructClass: StructCtor, + s: Struct, + defaultValue?: Pointer +): T { + const t = getPointerAs(index, StructClass, s); + + if (isNull(t)) { + if (defaultValue) { + Pointer.copyFrom(defaultValue, t); + } else { + initStruct(StructClass._capnp.size, t); + } + } else { + validate(PointerType.STRUCT, t); + + const ts = getTargetStructSize(t); + + // This can happen when reading a struct that was constructed with an older version of the same schema, and new + // fields were added to the struct. A shallow copy of the struct will be made so that there's enough room for the + // data and pointer sections. This will unfortunately leave a "hole" of zeroes in the message, but that hole will + // at least compress well. + if ( + ts.dataByteLength < StructClass._capnp.size.dataByteLength || + ts.pointerLength < StructClass._capnp.size.pointerLength + ) { + trace("need to resize child struct %s", t); + + resize(StructClass._capnp.size, t); + } + } + + return t; +} + +export function getText(index: number, s: Struct, defaultValue?: string): string { + const t = Text.fromPointer(getPointer(index, s)); + + // FIXME: This will perform an unnecessary string<>ArrayBuffer roundtrip. + if (isNull(t) && defaultValue) t.set(0, defaultValue); + + return t.get(0); +} + +/** + * Read an uint16 value out of a struct.. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getUint16(byteOffset: number, s: Struct, defaultMask?: DataView): number { + checkDataBounds(byteOffset, 2, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getUint16(ds.byteOffset + byteOffset); + } + + return ds.segment.getUint16(ds.byteOffset + byteOffset) ^ defaultMask.getUint16(0, true); +} + +/** + * Read an uint32 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getUint32(byteOffset: number, s: Struct, defaultMask?: DataView): number { + checkDataBounds(byteOffset, 4, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getUint32(ds.byteOffset + byteOffset); + } + + return ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); +} + +/** + * Read an uint64 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getUint64(byteOffset: number, s: Struct, defaultMask?: DataView): Uint64 { + checkDataBounds(byteOffset, 8, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getUint64(ds.byteOffset + byteOffset); + } + + const lo = ds.segment.getUint32(ds.byteOffset + byteOffset) ^ defaultMask.getUint32(0, true); + const hi = ds.segment.getUint32(ds.byteOffset + byteOffset + 4) ^ defaultMask.getUint32(4, true); + TMP_WORD.setUint32(0, lo, NATIVE_LITTLE_ENDIAN); + TMP_WORD.setUint32(4, hi, NATIVE_LITTLE_ENDIAN); + return new Uint64(new Uint8Array(TMP_WORD.buffer.slice(0))); +} + +/** + * Read an uint8 value out of a struct. + * + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {Struct} s The struct to read from. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {number} The value. + */ + +export function getUint8(byteOffset: number, s: Struct, defaultMask?: DataView): number { + checkDataBounds(byteOffset, 1, s); + + const ds = getDataSection(s); + + if (defaultMask === undefined) { + return ds.segment.getUint8(ds.byteOffset + byteOffset); + } + + return ds.segment.getUint8(ds.byteOffset + byteOffset) ^ defaultMask.getUint8(0); +} + +export function getVoid(): void { + throw new Error(INVARIANT_UNREACHABLE_CODE); +} + +export function initData(index: number, length: number, s: Struct): Data { + checkPointerBounds(index, s); + + const ps = getPointerSection(s); + + ps.byteOffset += index * 8; + + const l = new Data(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); + + erase(l); + + List.initList(ListElementSize.BYTE, length, l); + + return l; +} + +export function initList(index: number, ListClass: ListCtor, length: number, s: Struct): List { + checkPointerBounds(index, s); + + const ps = getPointerSection(s); + + ps.byteOffset += index * 8; + + const l = new ListClass(ps.segment, ps.byteOffset, s._capnp.depthLimit - 1); + + erase(l); + + List.initList(ListClass._capnp.size, length, l, ListClass._capnp.compositeSize); + + return l; +} + +/** + * Write a boolean (bit) value to the struct. + * + * @protected + * @param {number} bitOffset The offset in **bits** from the start of the data section. + * @param {boolean} value The value to write (writes a 0 for `false`, 1 for `true`). + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setBit(bitOffset: number, value: boolean, s: Struct, defaultMask?: DataView): void { + const byteOffset = Math.floor(bitOffset / 8); + const bitMask = 1 << bitOffset % 8; + + checkDataBounds(byteOffset, 1, s); + + const ds = getDataSection(s); + + const b = ds.segment.getUint8(ds.byteOffset + byteOffset); + + // If the default mask bit is set, that means `true` values are actually written as `0`. + + if (defaultMask !== undefined) { + value = (defaultMask.getUint8(0) & bitMask) !== 0 ? !value : value; + } + + ds.segment.setUint8(ds.byteOffset + byteOffset, value ? b | bitMask : b & ~bitMask); +} + +/** + * Write a primitive float32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setFloat32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 4, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) { + TMP_WORD.setFloat32(0, value, NATIVE_LITTLE_ENDIAN); + const v = TMP_WORD.getUint32(0, NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint32(0, true); + ds.segment.setUint32(ds.byteOffset + byteOffset, v); + + return; + } + + ds.segment.setFloat32(ds.byteOffset + byteOffset, value); +} + +/** + * Write a primitive float64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setFloat64(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 8, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) { + TMP_WORD.setFloat64(0, value, NATIVE_LITTLE_ENDIAN); + const lo = TMP_WORD.getUint32(0, NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint32(0, true); + const hi = TMP_WORD.getUint32(4, NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint32(4, true); + ds.segment.setUint32(ds.byteOffset + byteOffset, lo); + ds.segment.setUint32(ds.byteOffset + byteOffset + 4, hi); + + return; + } + + ds.segment.setFloat64(ds.byteOffset + byteOffset, value); +} + +/** + * Write a primitive int16 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setInt16(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 2, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) { + TMP_WORD.setInt16(0, value, NATIVE_LITTLE_ENDIAN); + const v = TMP_WORD.getUint16(0, NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint16(0, true); + ds.segment.setUint16(ds.byteOffset + byteOffset, v); + + return; + } + + ds.segment.setInt16(ds.byteOffset + byteOffset, value); +} + +/** + * Write a primitive int32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setInt32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 4, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) { + TMP_WORD.setInt32(0, value, NATIVE_LITTLE_ENDIAN); + const v = TMP_WORD.getUint32(0, NATIVE_LITTLE_ENDIAN) ^ defaultMask.getUint32(0, true); + ds.segment.setUint32(ds.byteOffset + byteOffset, v); + + return; + } + + ds.segment.setInt32(ds.byteOffset + byteOffset, value); +} + +/** + * Write a primitive int64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setInt64(byteOffset: number, value: Int64, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 8, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) { + // PERF: We could cast the Int64 to a DataView to apply the mask using four 32-bit reads, but we already have a + // typed array so avoiding the object allocation turns out to be slightly faster. Int64 is guaranteed to be in + // little-endian format by design. + + for (let i = 0; i < 8; i++) { + ds.segment.setUint8(ds.byteOffset + byteOffset + i, value.buffer[i] ^ defaultMask.getUint8(i)); + } + + return; + } + + ds.segment.setInt64(ds.byteOffset + byteOffset, value); +} + +/** + * Write a primitive int8 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setInt8(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 1, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) { + TMP_WORD.setInt8(0, value); + const v = TMP_WORD.getUint8(0) ^ defaultMask.getUint8(0); + ds.segment.setUint8(ds.byteOffset + byteOffset, v); + + return; + } + + ds.segment.setInt8(ds.byteOffset + byteOffset, value); +} + +export function setPointer(index: number, value: Pointer, s: Struct): void { + copyFrom(value, getPointer(index, s)); +} + +export function setText(index: number, value: string, s: Struct): void { + Text.fromPointer(getPointer(index, s)).set(0, value); +} + +/** + * Write a primitive uint16 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setUint16(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 2, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) value ^= defaultMask.getUint16(0, true); + + ds.segment.setUint16(ds.byteOffset + byteOffset, value); +} + +/** + * Write a primitive uint32 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setUint32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 4, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) value ^= defaultMask.getUint32(0, true); + + ds.segment.setUint32(ds.byteOffset + byteOffset, value); +} + +/** + * Write a primitive uint64 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setUint64(byteOffset: number, value: Uint64, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 8, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) { + // PERF: We could cast the Uint64 to a DataView to apply the mask using four 32-bit reads, but we already have a + // typed array so avoiding the object allocation turns out to be slightly faster. Uint64 is guaranteed to be in + // little-endian format by design. + + for (let i = 0; i < 8; i++) { + ds.segment.setUint8(ds.byteOffset + byteOffset + i, value.buffer[i] ^ defaultMask.getUint8(i)); + } + + return; + } + + ds.segment.setUint64(ds.byteOffset + byteOffset, value); +} + +/** + * Write a primitive uint8 value to the struct. + * + * @protected + * @param {number} byteOffset The offset in bytes from the start of the data section. + * @param {number} value The value to write. + * @param {Struct} s The struct to write to. + * @param {DataView} [defaultMask] The default value as a DataView. + * @returns {void} + */ + +export function setUint8(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void { + checkDataBounds(byteOffset, 1, s); + + const ds = getDataSection(s); + + if (defaultMask !== undefined) value ^= defaultMask.getUint8(0); + + ds.segment.setUint8(ds.byteOffset + byteOffset, value); +} + +export function setVoid(): void { + throw new Error(INVARIANT_UNREACHABLE_CODE); +} + +export function testWhich(name: string, found: number, wanted: number, s: Struct): void { + if (found !== wanted) { + throw new Error(format(PTR_INVALID_UNION_ACCESS, s, name, found, wanted)); + } +} + +export function checkDataBounds(byteOffset: number, byteLength: number, s: Struct): void { + const dataByteLength = getSize(s).dataByteLength; + + if (byteOffset < 0 || byteLength < 0 || byteOffset + byteLength > dataByteLength) { + throw new Error(format(PTR_STRUCT_DATA_OUT_OF_BOUNDS, s, byteLength, byteOffset, dataByteLength)); + } +} + +export function checkPointerBounds(index: number, s: Struct): void { + const pointerLength = getSize(s).pointerLength; + + if (index < 0 || index >= pointerLength) { + throw new Error(format(PTR_STRUCT_POINTER_OUT_OF_BOUNDS, s, index, pointerLength)); + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/text-list.js b/node_modules/capnp-ts/src/serialization/pointers/text-list.js new file mode 100644 index 0000000000000000000000000000000000000000..0005b0ce2f03345c5244b2d528e07dbc794621ee --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/text-list.js @@ -0,0 +1,35 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TextList = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const text_1 = require("./text"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class TextList extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + c.byteOffset += index * 8; + return text_1.Text.fromPointer(c).get(0); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.byteOffset += index * 8; + text_1.Text.fromPointer(c).set(0, value); + } + toString() { + return `Text_${super.toString()}`; + } +} +exports.TextList = TextList; +TextList._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.POINTER +}; +//# sourceMappingURL=text-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/text-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/text-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..7c9c627695894d1b1e7cb24e6f7744d37ff9a312 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/text-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"text-list.js","sourceRoot":"","sources":["text-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,iCAA8B;AAC9B,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,QAAS,SAAQ,WAAY;IAMxC,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,CAAC,CAAC,UAAU,IAAI,KAAK,GAAG,CAAC,CAAC;QAE1B,OAAO,WAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,CAAC,CAAC,UAAU,IAAI,KAAK,GAAG,CAAC,CAAC;QAE1B,WAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,QAAQ;QACN,OAAO,QAAQ,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACpC,CAAC;;AAxBH,4BAyBC;AAxBiB,eAAM,GAAc;IAClC,WAAW,EAAE,YAAsB;IACnC,IAAI,EAAE,mCAAe,CAAC,OAAO;CAC9B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/text-list.ts b/node_modules/capnp-ts/src/serialization/pointers/text-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c2c8fd797c2f4edeb329e4b8f65c6135231fb78 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/text-list.ts @@ -0,0 +1,40 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { Text } from "./text"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class TextList extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.POINTER + }; + + get(index: number): string { + const c = getContent(this); + + c.byteOffset += index * 8; + + return Text.fromPointer(c).get(0); + } + + set(index: number, value: string): void { + const c = getContent(this); + + c.byteOffset += index * 8; + + Text.fromPointer(c).set(0, value); + } + + toString(): string { + return `Text_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/text.js.map b/node_modules/capnp-ts/src/serialization/pointers/text.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4cd6d295e2143d54073437f50a8d3dbeee3eea96 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/text.js.map @@ -0,0 +1 @@ +{"version":3,"file":"text.js","sourceRoot":"","sources":["text.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,qCAAoD;AACpD,4DAAuD;AACvD,iCAAwC;AACxC,uCAAyE;AACzE,iDAA6C;AAE7C,MAAM,KAAK,GAAG,eAAS,CAAC,YAAY,CAAC,CAAC;AACtC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,IAAK,SAAQ,WAAY;IACpC,MAAM,CAAC,WAAW,CAAC,OAAgB;QACjC,kBAAQ,CAAC,0BAAW,CAAC,IAAI,EAAE,OAAO,EAAE,mCAAe,CAAC,IAAI,CAAC,CAAC;QAE1D,OAAO,wBAAwB,CA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c,EACtB,IAAI,CACL,CAAC;aACH;YAED,QAAQ,GAAG,IAAI,UAAU,CACvB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACpB,CAAC,CAAC,UAAU,EACZ,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,CAC/C,CACF,CAAC;YAEF,eAAK,CAAC,IAAI,CAAC,CAAC;SACb;QAED,kDAAkD;QAElD,eAAQ,CAAC,mCAAe,CAAC,IAAI,EAAE,SAAS,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;QAEpD,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QACrB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAEtE,IAAI,QAAQ;YAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEhC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,QAAQ;QACN,OAAO,QAAQ,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACpC,CAAC;CACF;AA3GD,oBA2GC;AAED,SAAS,wBAAwB,CAAC,OAAgB;IAChD,OAAO,IAAI,IAAI,CACb,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,MAAM,CAAC,UAAU,CAC1B,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/text.ts b/node_modules/capnp-ts/src/serialization/pointers/text.ts new file mode 100644 index 0000000000000000000000000000000000000000..2804097df8a2d7918e98ecb002b594515da17d9a --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/text.ts @@ -0,0 +1,131 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { decodeUtf8, encodeUtf8 } from "../../util"; +import { ListElementSize } from "../list-element-size"; +import { List, initList } from "./list"; +import { Pointer, validate, isNull, getContent, erase } from "./pointer"; +import { PointerType } from "./pointer-type"; + +const trace = initTrace("capnp:text"); +trace("load"); + +export class Text extends List { + static fromPointer(pointer: Pointer): Text { + validate(PointerType.LIST, pointer, ListElementSize.BYTE); + + return textFromPointerUnchecked(pointer); + } + + /** + * Read a utf-8 encoded string value from this pointer. + * + * @param {number} [index] The index at which to start reading; defaults to zero. + * @returns {string} The string value. + */ + + get(index = 0): string { + if (index !== 0) { + trace("Called get() on %s with a strange index (%d).", this, index); + } + + if (isNull(this)) return ""; + + const c = getContent(this); + + // Remember to exclude the NUL byte. + + return decodeUtf8( + new Uint8Array( + c.segment.buffer, + c.byteOffset + index, + this.getLength() - index + ) + ); + } + + /** + * Get the number of utf-8 encoded bytes in this text. This does **not** include the NUL byte. + * + * @returns {number} The number of bytes allocated for the text. + */ + + getLength(): number { + return super.getLength() - 1; + } + + /** + * Write a utf-8 encoded string value starting at the specified index. + * + * @param {number} index The index at which to start copying the string. Note that if this is not zero the bytes + * before `index` will be left as-is. All bytes after `index` will be overwritten. + * @param {string} value The string value to set. + * @returns {void} + */ + + set(index: number, value: string): void { + if (index !== 0) { + trace("Called set() on %s with a strange index (%d).", this, index); + } + + const src = encodeUtf8(value); + const dstLength = src.byteLength + index; + let c: Pointer; + let original: Uint8Array | undefined; + + // TODO: Consider reusing existing space if list is already initialized and there's enough room for the value. + + if (!isNull(this)) { + c = getContent(this); + + // Only copy bytes that will remain after copying. Everything after `index` should end up truncated. + + let originalLength = this.getLength(); + + if (originalLength >= index) { + originalLength = index; + } else { + trace( + "%d byte gap exists between original text and new text in %s.", + index - originalLength, + this + ); + } + + original = new Uint8Array( + c.segment.buffer.slice( + c.byteOffset, + c.byteOffset + Math.min(originalLength, index) + ) + ); + + erase(this); + } + + // Always allocate an extra byte for the NUL byte. + + initList(ListElementSize.BYTE, dstLength + 1, this); + + c = getContent(this); + const dst = new Uint8Array(c.segment.buffer, c.byteOffset, dstLength); + + if (original) dst.set(original); + + dst.set(src, index); + } + + toString(): string { + return `Text_${super.toString()}`; + } +} + +function textFromPointerUnchecked(pointer: Pointer): Text { + return new Text( + pointer.segment, + pointer.byteOffset, + pointer._capnp.depthLimit + ); +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint16-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/uint16-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..02df3da156ded175af0c1d90b715ab8e7f2220c3 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint16-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class Uint16List extends List { + static readonly _capnp: _ListCtor; + get(index: number): number; + set(index: number, value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint16-list.js b/node_modules/capnp-ts/src/serialization/pointers/uint16-list.js new file mode 100644 index 0000000000000000000000000000000000000000..e6ca94e0dd024a5fb563164eff0292a7cb51346e --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint16-list.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Uint16List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class Uint16List extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + return c.segment.getUint16(c.byteOffset + index * 2); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.segment.setUint16(c.byteOffset + index * 2, value); + } + toString() { + return `Uint16_${super.toString()}`; + } +} +exports.Uint16List = Uint16List; +Uint16List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BYTE_2 +}; +//# sourceMappingURL=uint16-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint16-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/uint16-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e9c8dceff1636d55bc0037e3c9382be54037e0a2 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint16-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uint16-list.js","sourceRoot":"","sources":["uint16-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,UAAW,SAAQ,WAAY;IAM1C,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,QAAQ;QACN,OAAO,UAAU,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACtC,CAAC;;AAnBH,gCAoBC;AAnBiB,iBAAM,GAAc;IAClC,WAAW,EAAE,cAAc;IAC3B,IAAI,EAAE,mCAAe,CAAC,MAAM;CAC7B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint32-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/uint32-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..245b4aabf3307ccee2d0b07bf4ea4e185750c9f3 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint32-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class Uint32List extends List { + static readonly _capnp: _ListCtor; + get(index: number): number; + set(index: number, value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint32-list.js b/node_modules/capnp-ts/src/serialization/pointers/uint32-list.js new file mode 100644 index 0000000000000000000000000000000000000000..7ef3a02961844877688a1f56b8aabcd6fcae2f86 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint32-list.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Uint32List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class Uint32List extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + return c.segment.getUint32(c.byteOffset + index * 4); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.segment.setUint32(c.byteOffset + index * 4, value); + } + toString() { + return `Uint32_${super.toString()}`; + } +} +exports.Uint32List = Uint32List; +Uint32List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BYTE_4 +}; +//# sourceMappingURL=uint32-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint32-list.ts b/node_modules/capnp-ts/src/serialization/pointers/uint32-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a6eafcd8197f7fe50e4e3bdf3c41bd4e8762ab0 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint32-list.ts @@ -0,0 +1,33 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class Uint32List extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.BYTE_4 + }; + + get(index: number): number { + const c = getContent(this); + return c.segment.getUint32(c.byteOffset + index * 4); + } + + set(index: number, value: number): void { + const c = getContent(this); + c.segment.setUint32(c.byteOffset + index * 4, value); + } + + toString(): string { + return `Uint32_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint64-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/uint64-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..467e08dc176143b7caf525978bdb1b15f583c322 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint64-list.d.ts @@ -0,0 +1,11 @@ +/** + * @author jdiaz5513 + */ +import { Uint64 } from "../../types/index"; +import { _ListCtor, List } from "./list"; +export declare class Uint64List extends List { + static readonly _capnp: _ListCtor; + get(index: number): Uint64; + set(index: number, value: Uint64): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint64-list.js b/node_modules/capnp-ts/src/serialization/pointers/uint64-list.js new file mode 100644 index 0000000000000000000000000000000000000000..0e49e014c12cd5f8581c68c59a142cb473d6398a --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint64-list.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Uint64List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class Uint64List extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + return c.segment.getUint64(c.byteOffset + index * 8); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.segment.setUint64(c.byteOffset + index * 8, value); + } + toString() { + return `Uint64_${super.toString()}`; + } +} +exports.Uint64List = Uint64List; +Uint64List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BYTE_8, +}; +//# sourceMappingURL=uint64-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint64-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/uint64-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b5b010286b51e326a6631dc08768e2f3b4f03e10 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint64-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uint64-list.js","sourceRoot":"","sources":["uint64-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAG9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,UAAW,SAAQ,WAAY;IAM1C,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,QAAQ;QACN,OAAO,UAAU,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACtC,CAAC;;AAlBH,gCAmBC;AAlBiB,iBAAM,GAAc;IAClC,WAAW,EAAE,cAAwB;IACrC,IAAI,EAAE,mCAAe,CAAC,MAAM;CAC7B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint8-list.d.ts b/node_modules/capnp-ts/src/serialization/pointers/uint8-list.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3383f883714c99b8947a6e6da16ac6bce12580d6 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint8-list.d.ts @@ -0,0 +1,10 @@ +/** + * @author jdiaz5513 + */ +import { _ListCtor, List } from "./list"; +export declare class Uint8List extends List { + static readonly _capnp: _ListCtor; + get(index: number): number; + set(index: number, value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint8-list.js b/node_modules/capnp-ts/src/serialization/pointers/uint8-list.js new file mode 100644 index 0000000000000000000000000000000000000000..2387ad6fb1dc299eb8f2554bf838d7cba5ba6b57 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint8-list.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Uint8List = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const list_element_size_1 = require("../list-element-size"); +const list_1 = require("./list"); +const pointer_1 = require("./pointer"); +const trace = debug_1.default("capnp:list:composite"); +trace("load"); +class Uint8List extends list_1.List { + get(index) { + const c = pointer_1.getContent(this); + return c.segment.getUint8(c.byteOffset + index); + } + set(index, value) { + const c = pointer_1.getContent(this); + c.segment.setUint8(c.byteOffset + index, value); + } + toString() { + return `Uint8_${super.toString()}`; + } +} +exports.Uint8List = Uint8List; +Uint8List._capnp = { + displayName: "List", + size: list_element_size_1.ListElementSize.BYTE +}; +//# sourceMappingURL=uint8-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint8-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/uint8-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..aced68eb2515e38ce6d5610a362211c72623e7e3 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint8-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uint8-list.js","sourceRoot":"","sources":["uint8-list.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4DAAuD;AACvD,iCAAyC;AACzC,uCAAuC;AAEvC,MAAM,KAAK,GAAG,eAAS,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,SAAU,SAAQ,WAAY;IAMzC,GAAG,CAAC,KAAa;QACf,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;IAClD,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,KAAa;QAC9B,MAAM,CAAC,GAAG,oBAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IAED,QAAQ;QACN,OAAO,SAAS,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACrC,CAAC;;AAlBH,8BAmBC;AAlBiB,gBAAM,GAAc;IAClC,WAAW,EAAE,aAAuB;IACpC,IAAI,EAAE,mCAAe,CAAC,IAAI;CAC3B,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/uint8-list.ts b/node_modules/capnp-ts/src/serialization/pointers/uint8-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..524fd9d57d63548867dcec9a2564e6358dd82630 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/uint8-list.ts @@ -0,0 +1,33 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { ListElementSize } from "../list-element-size"; +import { _ListCtor, List } from "./list"; +import { getContent } from "./pointer"; + +const trace = initTrace("capnp:list:composite"); +trace("load"); + +export class Uint8List extends List { + static readonly _capnp: _ListCtor = { + displayName: "List" as string, + size: ListElementSize.BYTE + }; + + get(index: number): number { + const c = getContent(this); + return c.segment.getUint8(c.byteOffset + index); + } + + set(index: number, value: number): void { + const c = getContent(this); + c.segment.setUint8(c.byteOffset + index, value); + } + + toString(): string { + return `Uint8_${super.toString()}`; + } +} diff --git a/node_modules/capnp-ts/src/serialization/pointers/void-list.js b/node_modules/capnp-ts/src/serialization/pointers/void-list.js new file mode 100644 index 0000000000000000000000000000000000000000..68a75d36385a10a8b9ec9d0975bbdd89e3d95c4d --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/void-list.js @@ -0,0 +1,12 @@ +"use strict"; +/** + * Why would anyone **SANE** ever use this!? + * + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VoidList = void 0; +const pointer_list_1 = require("./pointer-list"); +const void_1 = require("./void"); +exports.VoidList = pointer_list_1.PointerList(void_1.Void); +//# sourceMappingURL=void-list.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/void-list.js.map b/node_modules/capnp-ts/src/serialization/pointers/void-list.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5706639734811be72d030e3fc6e7ef55ca21abae --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/void-list.js.map @@ -0,0 +1 @@ +{"version":3,"file":"void-list.js","sourceRoot":"","sources":["void-list.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,iDAA6C;AAC7C,iCAA8B;AAEjB,QAAA,QAAQ,GAAmB,0BAAW,CAAC,WAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/void-list.ts b/node_modules/capnp-ts/src/serialization/pointers/void-list.ts new file mode 100644 index 0000000000000000000000000000000000000000..07b4b6ef50af2ca83811851524bacf059fb939cb --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/void-list.ts @@ -0,0 +1,11 @@ +/** + * Why would anyone **SANE** ever use this!? + * + * @author jdiaz5513 + */ + +import { ListCtor } from "./list"; +import { PointerList } from "./pointer-list"; +import { Void } from "./void"; + +export const VoidList: ListCtor = PointerList(Void); diff --git a/node_modules/capnp-ts/src/serialization/pointers/void.d.ts b/node_modules/capnp-ts/src/serialization/pointers/void.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..798baa28b9121d0d4bc2cb4cff1ef77d635adf26 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/void.d.ts @@ -0,0 +1,8 @@ +/** + * @author jdiaz5513 + */ +import { _StructCtor, Struct } from "./struct"; +export declare class Void extends Struct { + static readonly _capnp: _StructCtor; +} +export declare const VOID: undefined; diff --git a/node_modules/capnp-ts/src/serialization/pointers/void.js b/node_modules/capnp-ts/src/serialization/pointers/void.js new file mode 100644 index 0000000000000000000000000000000000000000..15b9d2f4bcbee69dbcf569e3365f5678134e5017 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/void.js @@ -0,0 +1,19 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VOID = exports.Void = void 0; +const object_size_1 = require("../object-size"); +const struct_1 = require("./struct"); +class Void extends struct_1.Struct { +} +exports.Void = Void; +Void._capnp = { + displayName: "Void", + id: "0", + size: new object_size_1.ObjectSize(0, 0) +}; +// This following line makes a mysterious "whooshing" sound when it runs. +exports.VOID = undefined; +//# sourceMappingURL=void.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/void.js.map b/node_modules/capnp-ts/src/serialization/pointers/void.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3cd848a134fb6422001cbd9e9af0faa0a814b08c --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/void.js.map @@ -0,0 +1 @@ +{"version":3,"file":"void.js","sourceRoot":"","sources":["void.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,gDAA4C;AAC5C,qCAA+C;AAE/C,MAAa,IAAK,SAAQ,eAAM;;AAAhC,oBAMC;AALiB,WAAM,GAAgB;IACpC,WAAW,EAAE,MAAgB;IAC7B,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,IAAI,wBAAU,CAAC,CAAC,EAAE,CAAC,CAAC;CAC3B,CAAC;AAGJ,yEAAyE;AAE5D,QAAA,IAAI,GAAG,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/pointers/void.ts b/node_modules/capnp-ts/src/serialization/pointers/void.ts new file mode 100644 index 0000000000000000000000000000000000000000..a03c1ada9bdedd707d998ed69cc6c30699156d2c --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/pointers/void.ts @@ -0,0 +1,18 @@ +/** + * @author jdiaz5513 + */ + +import { ObjectSize } from "../object-size"; +import { _StructCtor, Struct } from "./struct"; + +export class Void extends Struct { + static readonly _capnp: _StructCtor = { + displayName: "Void" as string, + id: "0", + size: new ObjectSize(0, 0) + }; +} + +// This following line makes a mysterious "whooshing" sound when it runs. + +export const VOID = undefined; diff --git a/node_modules/capnp-ts/src/serialization/segment.d.ts b/node_modules/capnp-ts/src/serialization/segment.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bdc6737906e2916dff4b4dfffd262b77602b85de --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/segment.d.ts @@ -0,0 +1,256 @@ +/** + * @author jdiaz5513 + */ +import { Int64, Uint64 } from "../types"; +import { Message } from "./message"; +import { Pointer } from "./pointers"; +export declare class Segment implements DataView { + buffer: ArrayBuffer; + /** The number of bytes currently allocated in the segment. */ + byteLength: number; + /** + * This value should always be zero. It's only here to satisfy the DataView interface. + * + * In the future the Segment implementation (or a child class) may allow accessing the buffer from a nonzero offset, + * but that adds a lot of extra arithmetic. + */ + byteOffset: number; + readonly [Symbol.toStringTag]: "DataView"; + readonly id: number; + readonly message: Message; + private _dv; + constructor(id: number, message: Message, buffer: ArrayBuffer, byteLength?: number); + /** + * Attempt to allocate the requested number of bytes in this segment. If this segment is full this method will return + * a pointer to freshly allocated space in another segment from the same message. + * + * @param {number} byteLength The number of bytes to allocate, will be rounded up to the nearest word. + * @returns {Pointer} A pointer to the newly allocated space. + */ + allocate(byteLength: number): Pointer; + /** + * Quickly copy a word (8 bytes) from `srcSegment` into this one at the given offset. + * + * @param {number} byteOffset The offset to write the word to. + * @param {Segment} srcSegment The segment to copy the word from. + * @param {number} srcByteOffset The offset from the start of `srcSegment` to copy from. + * @returns {void} + */ + copyWord(byteOffset: number, srcSegment: Segment, srcByteOffset: number): void; + /** + * Quickly copy words from `srcSegment` into this one. + * + * @param {number} byteOffset The offset to start copying into. + * @param {Segment} srcSegment The segment to copy from. + * @param {number} srcByteOffset The start offset to copy from. + * @param {number} wordLength The number of words to copy. + * @returns {void} + */ + copyWords(byteOffset: number, srcSegment: Segment, srcByteOffset: number, wordLength: number): void; + /** + * Quickly fill a number of words in the buffer with zeroes. + * + * @param {number} byteOffset The first byte to set to zero. + * @param {number} wordLength The number of words (not bytes!) to zero out. + * @returns {void} + */ + fillZeroWords(byteOffset: number, wordLength: number): void; + /** WARNING: This function is not yet implemented. */ + getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; + /** WARNING: This function is not yet implemented. */ + getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; + /** + * Get the total number of bytes available in this segment (the size of its underlying buffer). + * + * @returns {number} The total number of bytes this segment can hold. + */ + getCapacity(): number; + /** + * Read a float32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getFloat32(byteOffset: number): number; + /** + * Read a float64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getFloat64(byteOffset: number): number; + /** + * Read an int16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getInt16(byteOffset: number): number; + /** + * Read an int32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getInt32(byteOffset: number): number; + /** + * Read an int64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getInt64(byteOffset: number): Int64; + /** + * Read an int8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getInt8(byteOffset: number): number; + /** + * Read a uint16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getUint16(byteOffset: number): number; + /** + * Read a uint32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getUint32(byteOffset: number): number; + /** + * Read a uint8 value out of this segment. + * NOTE: this does not copy the memory region, so updates to the underlying buffer will affect the Uint64 value! + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getUint64(byteOffset: number): Uint64; + /** + * Read a uint8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getUint8(byteOffset: number): number; + hasCapacity(byteLength: number): boolean; + /** + * Quickly check the word at the given offset to see if it is equal to zero. + * + * PERF_V8: Fastest way to do this is by reading the whole word as a `number` (float64) in the _native_ endian format + * and see if it's zero. + * + * Benchmark: http://jsben.ch/#/Pjooc + * + * @param {number} byteOffset The offset to the word. + * @returns {boolean} `true` if the word is zero. + */ + isWordZero(byteOffset: number): boolean; + /** + * Swap out this segment's underlying buffer with a new one. It's assumed that the new buffer has the same content but + * more free space, otherwise all existing pointers to this segment will be hilariously broken. + * + * @param {ArrayBuffer} buffer The new buffer to use. + * @returns {void} + */ + replaceBuffer(buffer: ArrayBuffer): void; + /** WARNING: This function is not yet implemented. */ + setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; + /** WARNING: This function is not yet implemented. */ + setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; + /** + * Write a float32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setFloat32(byteOffset: number, val: number): void; + /** + * Write an float64 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setFloat64(byteOffset: number, val: number): void; + /** + * Write an int16 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setInt16(byteOffset: number, val: number): void; + /** + * Write an int32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setInt32(byteOffset: number, val: number): void; + /** + * Write an int8 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setInt8(byteOffset: number, val: number): void; + /** + * Write an int64 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {Int64} val The value to store. + * @returns {void} + */ + setInt64(byteOffset: number, val: Int64): void; + /** + * Write a uint16 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setUint16(byteOffset: number, val: number): void; + /** + * Write a uint32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setUint32(byteOffset: number, val: number): void; + /** + * Write a uint64 value to the specified offset. + * TODO: benchmark other ways to perform this write operation. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {Uint64} val The value to store. + * @returns {void} + */ + setUint64(byteOffset: number, val: Uint64): void; + /** + * Write a uint8 (byte) value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setUint8(byteOffset: number, val: number): void; + /** + * Write a zero word (8 bytes) to the specified offset. This is slightly faster than calling `setUint64` or + * `setFloat64` with a zero value. + * + * Benchmark: http://jsben.ch/#/dUdPI + * + * @param {number} byteOffset The offset of the word to set to zero. + * @returns {void} + */ + setWordZero(byteOffset: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/serialization/segment.js b/node_modules/capnp-ts/src/serialization/segment.js new file mode 100644 index 0000000000000000000000000000000000000000..984a065681d05fda5b3de19788b65a5e92da300b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/segment.js @@ -0,0 +1,370 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Segment = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("../constants"); +const errors_1 = require("../errors"); +const types_1 = require("../types"); +const util_1 = require("../util"); +const pointers_1 = require("./pointers"); +const trace = debug_1.default("capnp:segment"); +trace("load"); +class Segment { + constructor(id, message, buffer, byteLength = 0) { + this[_a] = "Segment"; + this.id = id; + this.message = message; + this.buffer = buffer; + this._dv = new DataView(buffer); + this.byteOffset = 0; + this.byteLength = byteLength; + } + /** + * Attempt to allocate the requested number of bytes in this segment. If this segment is full this method will return + * a pointer to freshly allocated space in another segment from the same message. + * + * @param {number} byteLength The number of bytes to allocate, will be rounded up to the nearest word. + * @returns {Pointer} A pointer to the newly allocated space. + */ + allocate(byteLength) { + trace("allocate(%d)", byteLength); + // eslint-disable-next-line @typescript-eslint/no-this-alias + let segment = this; + byteLength = util_1.padToWord(byteLength); + if (byteLength > constants_1.MAX_SEGMENT_LENGTH - 8) { + throw new Error(util_1.format(errors_1.SEG_SIZE_OVERFLOW, byteLength)); + } + if (!segment.hasCapacity(byteLength)) { + segment = segment.message.allocateSegment(byteLength); + } + const byteOffset = segment.byteLength; + segment.byteLength = segment.byteLength + byteLength; + trace("Allocated %x bytes in %s (requested segment: %s).", byteLength, this, segment); + return new pointers_1.Pointer(segment, byteOffset); + } + /** + * Quickly copy a word (8 bytes) from `srcSegment` into this one at the given offset. + * + * @param {number} byteOffset The offset to write the word to. + * @param {Segment} srcSegment The segment to copy the word from. + * @param {number} srcByteOffset The offset from the start of `srcSegment` to copy from. + * @returns {void} + */ + copyWord(byteOffset, srcSegment, srcByteOffset) { + const value = srcSegment._dv.getFloat64(srcByteOffset, constants_1.NATIVE_LITTLE_ENDIAN); + this._dv.setFloat64(byteOffset, value, constants_1.NATIVE_LITTLE_ENDIAN); + } + /** + * Quickly copy words from `srcSegment` into this one. + * + * @param {number} byteOffset The offset to start copying into. + * @param {Segment} srcSegment The segment to copy from. + * @param {number} srcByteOffset The start offset to copy from. + * @param {number} wordLength The number of words to copy. + * @returns {void} + */ + copyWords(byteOffset, srcSegment, srcByteOffset, wordLength) { + const dst = new Float64Array(this.buffer, byteOffset, wordLength); + const src = new Float64Array(srcSegment.buffer, srcByteOffset, wordLength); + dst.set(src); + } + /** + * Quickly fill a number of words in the buffer with zeroes. + * + * @param {number} byteOffset The first byte to set to zero. + * @param {number} wordLength The number of words (not bytes!) to zero out. + * @returns {void} + */ + fillZeroWords(byteOffset, wordLength) { + new Float64Array(this.buffer, byteOffset, wordLength).fill(0); + } + /** WARNING: This function is not yet implemented. */ + getBigInt64(byteOffset, littleEndian) { + throw new Error(util_1.format(errors_1.NOT_IMPLEMENTED, byteOffset, littleEndian)); + } + /** WARNING: This function is not yet implemented. */ + getBigUint64(byteOffset, littleEndian) { + throw new Error(util_1.format(errors_1.NOT_IMPLEMENTED, byteOffset, littleEndian)); + } + /** + * Get the total number of bytes available in this segment (the size of its underlying buffer). + * + * @returns {number} The total number of bytes this segment can hold. + */ + getCapacity() { + return this.buffer.byteLength; + } + /** + * Read a float32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getFloat32(byteOffset) { + return this._dv.getFloat32(byteOffset, true); + } + /** + * Read a float64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getFloat64(byteOffset) { + return this._dv.getFloat64(byteOffset, true); + } + /** + * Read an int16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getInt16(byteOffset) { + return this._dv.getInt16(byteOffset, true); + } + /** + * Read an int32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getInt32(byteOffset) { + return this._dv.getInt32(byteOffset, true); + } + /** + * Read an int64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getInt64(byteOffset) { + return new types_1.Int64(new Uint8Array(this.buffer.slice(byteOffset, byteOffset + 8))); + } + /** + * Read an int8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getInt8(byteOffset) { + return this._dv.getInt8(byteOffset); + } + /** + * Read a uint16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getUint16(byteOffset) { + return this._dv.getUint16(byteOffset, true); + } + /** + * Read a uint32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getUint32(byteOffset) { + return this._dv.getUint32(byteOffset, true); + } + /** + * Read a uint8 value out of this segment. + * NOTE: this does not copy the memory region, so updates to the underlying buffer will affect the Uint64 value! + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getUint64(byteOffset) { + return new types_1.Uint64(new Uint8Array(this.buffer.slice(byteOffset, byteOffset + 8))); + } + /** + * Read a uint8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + getUint8(byteOffset) { + return this._dv.getUint8(byteOffset); + } + hasCapacity(byteLength) { + trace("hasCapacity(%d)", byteLength); + // capacity - allocated >= requested + return this.buffer.byteLength - this.byteLength >= byteLength; + } + /** + * Quickly check the word at the given offset to see if it is equal to zero. + * + * PERF_V8: Fastest way to do this is by reading the whole word as a `number` (float64) in the _native_ endian format + * and see if it's zero. + * + * Benchmark: http://jsben.ch/#/Pjooc + * + * @param {number} byteOffset The offset to the word. + * @returns {boolean} `true` if the word is zero. + */ + isWordZero(byteOffset) { + return this._dv.getFloat64(byteOffset, constants_1.NATIVE_LITTLE_ENDIAN) === 0; + } + /** + * Swap out this segment's underlying buffer with a new one. It's assumed that the new buffer has the same content but + * more free space, otherwise all existing pointers to this segment will be hilariously broken. + * + * @param {ArrayBuffer} buffer The new buffer to use. + * @returns {void} + */ + replaceBuffer(buffer) { + trace("replaceBuffer(%p)", buffer); + if (this.buffer === buffer) + return; + if (buffer.byteLength < this.byteLength) { + throw new Error(errors_1.SEG_REPLACEMENT_BUFFER_TOO_SMALL); + } + this._dv = new DataView(buffer); + this.buffer = buffer; + } + /** WARNING: This function is not yet implemented. */ + setBigInt64(byteOffset, value, littleEndian) { + throw new Error(util_1.format(errors_1.NOT_IMPLEMENTED, byteOffset, value, littleEndian)); + } + /** WARNING: This function is not yet implemented. */ + setBigUint64(byteOffset, value, littleEndian) { + throw new Error(util_1.format(errors_1.NOT_IMPLEMENTED, byteOffset, value, littleEndian)); + } + /** + * Write a float32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setFloat32(byteOffset, val) { + this._dv.setFloat32(byteOffset, val, true); + } + /** + * Write an float64 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setFloat64(byteOffset, val) { + this._dv.setFloat64(byteOffset, val, true); + } + /** + * Write an int16 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setInt16(byteOffset, val) { + this._dv.setInt16(byteOffset, val, true); + } + /** + * Write an int32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setInt32(byteOffset, val) { + this._dv.setInt32(byteOffset, val, true); + } + /** + * Write an int8 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setInt8(byteOffset, val) { + this._dv.setInt8(byteOffset, val); + } + /** + * Write an int64 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {Int64} val The value to store. + * @returns {void} + */ + setInt64(byteOffset, val) { + this._dv.setUint8(byteOffset, val.buffer[0]); + this._dv.setUint8(byteOffset + 1, val.buffer[1]); + this._dv.setUint8(byteOffset + 2, val.buffer[2]); + this._dv.setUint8(byteOffset + 3, val.buffer[3]); + this._dv.setUint8(byteOffset + 4, val.buffer[4]); + this._dv.setUint8(byteOffset + 5, val.buffer[5]); + this._dv.setUint8(byteOffset + 6, val.buffer[6]); + this._dv.setUint8(byteOffset + 7, val.buffer[7]); + } + /** + * Write a uint16 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setUint16(byteOffset, val) { + this._dv.setUint16(byteOffset, val, true); + } + /** + * Write a uint32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setUint32(byteOffset, val) { + this._dv.setUint32(byteOffset, val, true); + } + /** + * Write a uint64 value to the specified offset. + * TODO: benchmark other ways to perform this write operation. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {Uint64} val The value to store. + * @returns {void} + */ + setUint64(byteOffset, val) { + this._dv.setUint8(byteOffset + 0, val.buffer[0]); + this._dv.setUint8(byteOffset + 1, val.buffer[1]); + this._dv.setUint8(byteOffset + 2, val.buffer[2]); + this._dv.setUint8(byteOffset + 3, val.buffer[3]); + this._dv.setUint8(byteOffset + 4, val.buffer[4]); + this._dv.setUint8(byteOffset + 5, val.buffer[5]); + this._dv.setUint8(byteOffset + 6, val.buffer[6]); + this._dv.setUint8(byteOffset + 7, val.buffer[7]); + } + /** + * Write a uint8 (byte) value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + setUint8(byteOffset, val) { + this._dv.setUint8(byteOffset, val); + } + /** + * Write a zero word (8 bytes) to the specified offset. This is slightly faster than calling `setUint64` or + * `setFloat64` with a zero value. + * + * Benchmark: http://jsben.ch/#/dUdPI + * + * @param {number} byteOffset The offset of the word to set to zero. + * @returns {void} + */ + setWordZero(byteOffset) { + this._dv.setFloat64(byteOffset, 0, constants_1.NATIVE_LITTLE_ENDIAN); + } + toString() { + return util_1.format("Segment_id:%d,off:%a,len:%a,cap:%a", this.id, this.byteLength, this.byteOffset, this.buffer.byteLength); + } +} +exports.Segment = Segment; +_a = Symbol.toStringTag; +//# sourceMappingURL=segment.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/segment.js.map b/node_modules/capnp-ts/src/serialization/segment.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f97351815719a6d9a1371ce8e9f1c69c90ab864b --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/segment.js.map @@ -0,0 +1 @@ +{"version":3,"file":"segment.js","sourceRoot":"","sources":["segment.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AAEH,0DAA8B;AAE9B,4CAAwE;AACxE,sCAAiG;AACjG,oCAAyC;AACzC,kCAA4C;AAE5C,yCAAqC;AAErC,MAAM,KAAK,GAAG,eAAS,CAAC,eAAe,CAAC,CAAC;AACzC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,MAAa,OAAO;IAwBlB,YAAY,EAAU,EAAE,OAAgB,EAAE,MAAmB,EAAE,UAAU,GAAG,CAAC;QARpE,QAAoB,GAAG,SAAuB,CAAC;QAStD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEhC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IAEH,QAAQ,CAAC,UAAkB;QACzB,KAAK,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAElC,4DAA4D;QAC5D,IAAI,OAAO,GAAY,IAAI,CAAC;QAE5B,UAAU,GAAG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UAAU,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;OAQG;IAEH,WAAW,CAAC,UAAkB;QAC5B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,gCAAoB,CAAC,CAAC;IAC3D,CAAC;IAED,QAAQ;QACN,OAAO,aAAM,CACX,oCAAoC,EACpC,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,CAAC,UAAU,CACvB,CAAC;IACJ,CAAC;CACF;AA3cD,0BA2cC;KA3bW,MAAM,CAAC,WAAW"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/serialization/segment.ts b/node_modules/capnp-ts/src/serialization/segment.ts new file mode 100644 index 0000000000000000000000000000000000000000..b488451de3cc68346411071a641e3549c721b047 --- /dev/null +++ b/node_modules/capnp-ts/src/serialization/segment.ts @@ -0,0 +1,476 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { MAX_SEGMENT_LENGTH, NATIVE_LITTLE_ENDIAN } from "../constants"; +import { NOT_IMPLEMENTED, SEG_REPLACEMENT_BUFFER_TOO_SMALL, SEG_SIZE_OVERFLOW } from "../errors"; +import { Int64, Uint64 } from "../types"; +import { format, padToWord } from "../util"; +import { Message } from "./message"; +import { Pointer } from "./pointers"; + +const trace = initTrace("capnp:segment"); +trace("load"); + +export class Segment implements DataView { + buffer: ArrayBuffer; + + /** The number of bytes currently allocated in the segment. */ + + byteLength: number; + + /** + * This value should always be zero. It's only here to satisfy the DataView interface. + * + * In the future the Segment implementation (or a child class) may allow accessing the buffer from a nonzero offset, + * but that adds a lot of extra arithmetic. + */ + + byteOffset: number; + + readonly [Symbol.toStringTag] = "Segment" as "DataView"; + + readonly id: number; + + readonly message: Message; + + private _dv: DataView; + + constructor(id: number, message: Message, buffer: ArrayBuffer, byteLength = 0) { + this.id = id; + this.message = message; + this.buffer = buffer; + this._dv = new DataView(buffer); + + this.byteOffset = 0; + this.byteLength = byteLength; + } + + /** + * Attempt to allocate the requested number of bytes in this segment. If this segment is full this method will return + * a pointer to freshly allocated space in another segment from the same message. + * + * @param {number} byteLength The number of bytes to allocate, will be rounded up to the nearest word. + * @returns {Pointer} A pointer to the newly allocated space. + */ + + allocate(byteLength: number): Pointer { + trace("allocate(%d)", byteLength); + + // eslint-disable-next-line @typescript-eslint/no-this-alias + let segment: Segment = this; + + byteLength = padToWord(byteLength); + + if (byteLength > MAX_SEGMENT_LENGTH - 8) { + throw new Error(format(SEG_SIZE_OVERFLOW, byteLength)); + } + + if (!segment.hasCapacity(byteLength)) { + segment = segment.message.allocateSegment(byteLength); + } + + const byteOffset = segment.byteLength; + + segment.byteLength = segment.byteLength + byteLength; + + trace("Allocated %x bytes in %s (requested segment: %s).", byteLength, this, segment); + + return new Pointer(segment, byteOffset); + } + + /** + * Quickly copy a word (8 bytes) from `srcSegment` into this one at the given offset. + * + * @param {number} byteOffset The offset to write the word to. + * @param {Segment} srcSegment The segment to copy the word from. + * @param {number} srcByteOffset The offset from the start of `srcSegment` to copy from. + * @returns {void} + */ + + copyWord(byteOffset: number, srcSegment: Segment, srcByteOffset: number): void { + const value = srcSegment._dv.getFloat64(srcByteOffset, NATIVE_LITTLE_ENDIAN); + + this._dv.setFloat64(byteOffset, value, NATIVE_LITTLE_ENDIAN); + } + + /** + * Quickly copy words from `srcSegment` into this one. + * + * @param {number} byteOffset The offset to start copying into. + * @param {Segment} srcSegment The segment to copy from. + * @param {number} srcByteOffset The start offset to copy from. + * @param {number} wordLength The number of words to copy. + * @returns {void} + */ + + copyWords(byteOffset: number, srcSegment: Segment, srcByteOffset: number, wordLength: number): void { + const dst = new Float64Array(this.buffer, byteOffset, wordLength); + const src = new Float64Array(srcSegment.buffer, srcByteOffset, wordLength); + + dst.set(src); + } + + /** + * Quickly fill a number of words in the buffer with zeroes. + * + * @param {number} byteOffset The first byte to set to zero. + * @param {number} wordLength The number of words (not bytes!) to zero out. + * @returns {void} + */ + + fillZeroWords(byteOffset: number, wordLength: number): void { + new Float64Array(this.buffer, byteOffset, wordLength).fill(0); + } + + /** WARNING: This function is not yet implemented. */ + + getBigInt64(byteOffset: number, littleEndian?: boolean): bigint { + throw new Error(format(NOT_IMPLEMENTED, byteOffset, littleEndian)); + } + + /** WARNING: This function is not yet implemented. */ + + getBigUint64(byteOffset: number, littleEndian?: boolean): bigint { + throw new Error(format(NOT_IMPLEMENTED, byteOffset, littleEndian)); + } + + /** + * Get the total number of bytes available in this segment (the size of its underlying buffer). + * + * @returns {number} The total number of bytes this segment can hold. + */ + + getCapacity(): number { + return this.buffer.byteLength; + } + + /** + * Read a float32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getFloat32(byteOffset: number): number { + return this._dv.getFloat32(byteOffset, true); + } + + /** + * Read a float64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getFloat64(byteOffset: number): number { + return this._dv.getFloat64(byteOffset, true); + } + + /** + * Read an int16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getInt16(byteOffset: number): number { + return this._dv.getInt16(byteOffset, true); + } + + /** + * Read an int32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getInt32(byteOffset: number): number { + return this._dv.getInt32(byteOffset, true); + } + + /** + * Read an int64 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getInt64(byteOffset: number): Int64 { + return new Int64(new Uint8Array(this.buffer.slice(byteOffset, byteOffset + 8))); + } + + /** + * Read an int8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getInt8(byteOffset: number): number { + return this._dv.getInt8(byteOffset); + } + + /** + * Read a uint16 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getUint16(byteOffset: number): number { + return this._dv.getUint16(byteOffset, true); + } + + /** + * Read a uint32 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getUint32(byteOffset: number): number { + return this._dv.getUint32(byteOffset, true); + } + + /** + * Read a uint8 value out of this segment. + * NOTE: this does not copy the memory region, so updates to the underlying buffer will affect the Uint64 value! + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getUint64(byteOffset: number): Uint64 { + return new Uint64(new Uint8Array(this.buffer.slice(byteOffset, byteOffset + 8))); + } + + /** + * Read a uint8 value out of this segment. + * + * @param {number} byteOffset The offset in bytes to the value. + * @returns {number} The value. + */ + + getUint8(byteOffset: number): number { + return this._dv.getUint8(byteOffset); + } + + hasCapacity(byteLength: number): boolean { + trace("hasCapacity(%d)", byteLength); + + // capacity - allocated >= requested + + return this.buffer.byteLength - this.byteLength >= byteLength; + } + + /** + * Quickly check the word at the given offset to see if it is equal to zero. + * + * PERF_V8: Fastest way to do this is by reading the whole word as a `number` (float64) in the _native_ endian format + * and see if it's zero. + * + * Benchmark: http://jsben.ch/#/Pjooc + * + * @param {number} byteOffset The offset to the word. + * @returns {boolean} `true` if the word is zero. + */ + + isWordZero(byteOffset: number): boolean { + return this._dv.getFloat64(byteOffset, NATIVE_LITTLE_ENDIAN) === 0; + } + + /** + * Swap out this segment's underlying buffer with a new one. It's assumed that the new buffer has the same content but + * more free space, otherwise all existing pointers to this segment will be hilariously broken. + * + * @param {ArrayBuffer} buffer The new buffer to use. + * @returns {void} + */ + + replaceBuffer(buffer: ArrayBuffer): void { + trace("replaceBuffer(%p)", buffer); + + if (this.buffer === buffer) return; + + if (buffer.byteLength < this.byteLength) { + throw new Error(SEG_REPLACEMENT_BUFFER_TOO_SMALL); + } + + this._dv = new DataView(buffer); + this.buffer = buffer; + } + + /** WARNING: This function is not yet implemented. */ + + setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void { + throw new Error(format(NOT_IMPLEMENTED, byteOffset, value, littleEndian)); + } + + /** WARNING: This function is not yet implemented. */ + + setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void { + throw new Error(format(NOT_IMPLEMENTED, byteOffset, value, littleEndian)); + } + + /** + * Write a float32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + + setFloat32(byteOffset: number, val: number): void { + this._dv.setFloat32(byteOffset, val, true); + } + + /** + * Write an float64 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + + setFloat64(byteOffset: number, val: number): void { + this._dv.setFloat64(byteOffset, val, true); + } + + /** + * Write an int16 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + + setInt16(byteOffset: number, val: number): void { + this._dv.setInt16(byteOffset, val, true); + } + + /** + * Write an int32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + + setInt32(byteOffset: number, val: number): void { + this._dv.setInt32(byteOffset, val, true); + } + + /** + * Write an int8 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + + setInt8(byteOffset: number, val: number): void { + this._dv.setInt8(byteOffset, val); + } + + /** + * Write an int64 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {Int64} val The value to store. + * @returns {void} + */ + + setInt64(byteOffset: number, val: Int64): void { + this._dv.setUint8(byteOffset, val.buffer[0]); + this._dv.setUint8(byteOffset + 1, val.buffer[1]); + this._dv.setUint8(byteOffset + 2, val.buffer[2]); + this._dv.setUint8(byteOffset + 3, val.buffer[3]); + this._dv.setUint8(byteOffset + 4, val.buffer[4]); + this._dv.setUint8(byteOffset + 5, val.buffer[5]); + this._dv.setUint8(byteOffset + 6, val.buffer[6]); + this._dv.setUint8(byteOffset + 7, val.buffer[7]); + } + + /** + * Write a uint16 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + + setUint16(byteOffset: number, val: number): void { + this._dv.setUint16(byteOffset, val, true); + } + + /** + * Write a uint32 value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + + setUint32(byteOffset: number, val: number): void { + this._dv.setUint32(byteOffset, val, true); + } + + /** + * Write a uint64 value to the specified offset. + * TODO: benchmark other ways to perform this write operation. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {Uint64} val The value to store. + * @returns {void} + */ + + setUint64(byteOffset: number, val: Uint64): void { + this._dv.setUint8(byteOffset + 0, val.buffer[0]); + this._dv.setUint8(byteOffset + 1, val.buffer[1]); + this._dv.setUint8(byteOffset + 2, val.buffer[2]); + this._dv.setUint8(byteOffset + 3, val.buffer[3]); + this._dv.setUint8(byteOffset + 4, val.buffer[4]); + this._dv.setUint8(byteOffset + 5, val.buffer[5]); + this._dv.setUint8(byteOffset + 6, val.buffer[6]); + this._dv.setUint8(byteOffset + 7, val.buffer[7]); + } + + /** + * Write a uint8 (byte) value to the specified offset. + * + * @param {number} byteOffset The offset from the beginning of the buffer. + * @param {number} val The value to store. + * @returns {void} + */ + + setUint8(byteOffset: number, val: number): void { + this._dv.setUint8(byteOffset, val); + } + + /** + * Write a zero word (8 bytes) to the specified offset. This is slightly faster than calling `setUint64` or + * `setFloat64` with a zero value. + * + * Benchmark: http://jsben.ch/#/dUdPI + * + * @param {number} byteOffset The offset of the word to set to zero. + * @returns {void} + */ + + setWordZero(byteOffset: number): void { + this._dv.setFloat64(byteOffset, 0, NATIVE_LITTLE_ENDIAN); + } + + toString(): string { + return format( + "Segment_id:%d,off:%a,len:%a,cap:%a", + this.id, + this.byteLength, + this.byteOffset, + this.buffer.byteLength + ); + } +} diff --git a/node_modules/capnp-ts/src/std/README.md b/node_modules/capnp-ts/src/std/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8ed1ccc35ab862d52029005c2e88271939707d79 --- /dev/null +++ b/node_modules/capnp-ts/src/std/README.md @@ -0,0 +1,5 @@ +# Cap'n Proto Standard Libary Files + +These files are the underpinning of much of the RPC and code generation portions of the library. + +They were copied directly from https://github.com/sandstorm-io/capnproto/tree/41264ae6deb85ee9d9756e88293c856f7e9fe9d9/c%2B%2B/src/capnp. diff --git a/node_modules/capnp-ts/src/std/c++.capnp.d.ts b/node_modules/capnp-ts/src/std/c++.capnp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b16d4d1f1fddf4c8ddec3cb346c2ad74e402f0a --- /dev/null +++ b/node_modules/capnp-ts/src/std/c++.capnp.d.ts @@ -0,0 +1,5 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +export declare const _capnpFileId = "bdf87d7bb8304e81"; diff --git a/node_modules/capnp-ts/src/std/c++.capnp.js b/node_modules/capnp-ts/src/std/c++.capnp.js new file mode 100644 index 0000000000000000000000000000000000000000..838d5977b9f82a64c99576468896f4208afc621b --- /dev/null +++ b/node_modules/capnp-ts/src/std/c++.capnp.js @@ -0,0 +1,9 @@ +"use strict"; +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports._capnpFileId = void 0; +exports._capnpFileId = "bdf87d7bb8304e81"; +//# sourceMappingURL=c++.capnp.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/c++.capnp.js.map b/node_modules/capnp-ts/src/std/c++.capnp.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5cf44a81d350d07f6f9fe77182577f436409a58b --- /dev/null +++ b/node_modules/capnp-ts/src/std/c++.capnp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"c++.capnp.js","sourceRoot":"","sources":["c++.capnp.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIU,QAAA,YAAY,GAAG,kBAAkB,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/c++.capnp.ts b/node_modules/capnp-ts/src/std/c++.capnp.ts new file mode 100644 index 0000000000000000000000000000000000000000..334a0897aee0dcc2cc044ca7350b46e512925c71 --- /dev/null +++ b/node_modules/capnp-ts/src/std/c++.capnp.ts @@ -0,0 +1,8 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ + +import * as capnp from "../index"; +import { ObjectSize as __O, Struct as __S } from "../index"; +export const _capnpFileId = "bdf87d7bb8304e81"; diff --git a/node_modules/capnp-ts/src/std/persistent.capnp.d.ts b/node_modules/capnp-ts/src/std/persistent.capnp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b9e49a98af06f48d3d0dbcc593a5addf994ca16 --- /dev/null +++ b/node_modules/capnp-ts/src/std/persistent.capnp.d.ts @@ -0,0 +1,51 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +import * as capnp from "../index"; +import { Struct as __S } from "../index"; +export declare const _capnpFileId = "b8630836983feed7"; +export declare class Persistent_SaveParams extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + adoptSealFor(value: capnp.Orphan): void; + disownSealFor(): capnp.Orphan; + getSealFor(): capnp.Pointer; + hasSealFor(): boolean; + setSealFor(value: capnp.Pointer): void; + toString(): string; +} +export declare class Persistent_SaveResults extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + adoptSturdyRef(value: capnp.Orphan): void; + disownSturdyRef(): capnp.Orphan; + getSturdyRef(): capnp.Pointer; + hasSturdyRef(): boolean; + setSturdyRef(value: capnp.Pointer): void; + toString(): string; +} +export declare class Persistent extends __S { + static readonly SaveParams: typeof Persistent_SaveParams; + static readonly SaveResults: typeof Persistent_SaveResults; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + toString(): string; +} +export declare class RealmGateway extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/std/persistent.capnp.js b/node_modules/capnp-ts/src/std/persistent.capnp.js new file mode 100644 index 0000000000000000000000000000000000000000..51a72bc00d94a665f49cae7b528bf988b92b2c6b --- /dev/null +++ b/node_modules/capnp-ts/src/std/persistent.capnp.js @@ -0,0 +1,42 @@ +"use strict"; +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RealmGateway = exports.Persistent = exports.Persistent_SaveResults = exports.Persistent_SaveParams = exports._capnpFileId = void 0; +const index_1 = require("../index"); +exports._capnpFileId = "b8630836983feed7"; +class Persistent_SaveParams extends index_1.Struct { + adoptSealFor(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownSealFor() { return index_1.Struct.disown(this.getSealFor()); } + getSealFor() { return index_1.Struct.getPointer(0, this); } + hasSealFor() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + setSealFor(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Persistent_SaveParams_" + super.toString(); } +} +exports.Persistent_SaveParams = Persistent_SaveParams; +Persistent_SaveParams._capnp = { displayName: "SaveParams", id: "f76fba59183073a5", size: new index_1.ObjectSize(0, 1) }; +class Persistent_SaveResults extends index_1.Struct { + adoptSturdyRef(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownSturdyRef() { return index_1.Struct.disown(this.getSturdyRef()); } + getSturdyRef() { return index_1.Struct.getPointer(0, this); } + hasSturdyRef() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + setSturdyRef(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Persistent_SaveResults_" + super.toString(); } +} +exports.Persistent_SaveResults = Persistent_SaveResults; +Persistent_SaveResults._capnp = { displayName: "SaveResults", id: "b76848c18c40efbf", size: new index_1.ObjectSize(0, 1) }; +class Persistent extends index_1.Struct { + toString() { return "Persistent_" + super.toString(); } +} +exports.Persistent = Persistent; +Persistent.SaveParams = Persistent_SaveParams; +Persistent.SaveResults = Persistent_SaveResults; +Persistent._capnp = { displayName: "Persistent", id: "c8cb212fcd9f5691", size: new index_1.ObjectSize(0, 0) }; +class RealmGateway extends index_1.Struct { + toString() { return "RealmGateway_" + super.toString(); } +} +exports.RealmGateway = RealmGateway; +RealmGateway._capnp = { displayName: "RealmGateway", id: "84ff286cd00a3ed4", size: new index_1.ObjectSize(0, 0) }; +//# sourceMappingURL=persistent.capnp.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/persistent.capnp.js.map b/node_modules/capnp-ts/src/std/persistent.capnp.js.map new file mode 100644 index 0000000000000000000000000000000000000000..da62ae5491ec7823d3d70c8859b67516b131affe --- /dev/null +++ b/node_modules/capnp-ts/src/std/persistent.capnp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"persistent.capnp.js","sourceRoot":"","sources":["persistent.capnp.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,oCAA4D;AAC/C,QAAA,YAAY,GAAG,kBAAkB,CAAC;AAC/C,MAAa,qBAAsB,SAAQ,cAAG;IAE1C,YAAY,CAAC,KAAkC,IAAU,cAAG,CAAC,KAAK,CAAC,KAAK,EAAE,cAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACrG,aAAa,KAAkC,OAAO,cAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IACtF,UAAU,KAAoB,OAAO,cAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/D,UAAU,KAAc,OAAO,CAAC,cAAG,CAAC,MAAM,CAAC,cAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,UAA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,CAAC,EAAE,CAAC;AAQzG,MAAa,UAAW,SAAQ,cAAG;IAI/B,QAAQ,KAAa,OAAO,aAAa,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;;AAJnE,gCAKC;AAJmB,qBAAU,GAAG,qBAAqB,CAAC;AACnC,sBAAW,GAAG,sBAAsB,CAAC;AACrC,iBAAM,GAAG,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,kBAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAGxG,MAAa,YAAa,SAAQ,cAAG;IAEjC,QAAQ,KAAa,OAAO,eAAe,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;;AAFrE,oCAGC;AAFmB,mBAAM,GAAG,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,kBAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/persistent.capnp.ts b/node_modules/capnp-ts/src/std/persistent.capnp.ts new file mode 100644 index 0000000000000000000000000000000000000000..e0920a5d8701c7076a70bdd3324f32146b862f93 --- /dev/null +++ b/node_modules/capnp-ts/src/std/persistent.capnp.ts @@ -0,0 +1,36 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ + +import * as capnp from "../index"; +import { ObjectSize as __O, Struct as __S } from "../index"; +export const _capnpFileId = "b8630836983feed7"; +export class Persistent_SaveParams extends __S { + static readonly _capnp = { displayName: "SaveParams", id: "f76fba59183073a5", size: new __O(0, 1) }; + adoptSealFor(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownSealFor(): capnp.Orphan { return __S.disown(this.getSealFor()); } + getSealFor(): capnp.Pointer { return __S.getPointer(0, this); } + hasSealFor(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + setSealFor(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Persistent_SaveParams_" + super.toString(); } +} +export class Persistent_SaveResults extends __S { + static readonly _capnp = { displayName: "SaveResults", id: "b76848c18c40efbf", size: new __O(0, 1) }; + adoptSturdyRef(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownSturdyRef(): capnp.Orphan { return __S.disown(this.getSturdyRef()); } + getSturdyRef(): capnp.Pointer { return __S.getPointer(0, this); } + hasSturdyRef(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + setSturdyRef(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Persistent_SaveResults_" + super.toString(); } +} +export class Persistent extends __S { + static readonly SaveParams = Persistent_SaveParams; + static readonly SaveResults = Persistent_SaveResults; + static readonly _capnp = { displayName: "Persistent", id: "c8cb212fcd9f5691", size: new __O(0, 0) }; + toString(): string { return "Persistent_" + super.toString(); } +} +export class RealmGateway extends __S { + static readonly _capnp = { displayName: "RealmGateway", id: "84ff286cd00a3ed4", size: new __O(0, 0) }; + toString(): string { return "RealmGateway_" + super.toString(); } +} diff --git a/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.d.ts b/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6ff167c838b0b1aef1bd35f753252176bbdd278 --- /dev/null +++ b/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.d.ts @@ -0,0 +1,78 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +import * as capnp from "../index"; +import { Struct as __S } from "../index"; +export declare const _capnpFileId = "a184c7885cdaf2a1"; +export declare enum Side { + SERVER = 0, + CLIENT = 1 +} +export declare class VatId extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getSide(): Side; + setSide(value: Side): void; + toString(): string; +} +export declare class ProvisionId extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getJoinId(): number; + setJoinId(value: number): void; + toString(): string; +} +export declare class RecipientId extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + toString(): string; +} +export declare class ThirdPartyCapId extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + toString(): string; +} +export declare class JoinKeyPart extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getJoinId(): number; + setJoinId(value: number): void; + getPartCount(): number; + setPartCount(value: number): void; + getPartNum(): number; + setPartNum(value: number): void; + toString(): string; +} +export declare class JoinResult extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getJoinId(): number; + setJoinId(value: number): void; + getSucceeded(): boolean; + setSucceeded(value: boolean): void; + adoptCap(value: capnp.Orphan): void; + disownCap(): capnp.Orphan; + getCap(): capnp.Pointer; + hasCap(): boolean; + setCap(value: capnp.Pointer): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.js b/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.js new file mode 100644 index 0000000000000000000000000000000000000000..4ed0b3a42e31abe83424e34afcd2a19eb9c9df77 --- /dev/null +++ b/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.js @@ -0,0 +1,64 @@ +"use strict"; +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.JoinResult = exports.JoinKeyPart = exports.ThirdPartyCapId = exports.RecipientId = exports.ProvisionId = exports.VatId = exports.Side = exports._capnpFileId = void 0; +const index_1 = require("../index"); +exports._capnpFileId = "a184c7885cdaf2a1"; +var Side; +(function (Side) { + Side[Side["SERVER"] = 0] = "SERVER"; + Side[Side["CLIENT"] = 1] = "CLIENT"; +})(Side = exports.Side || (exports.Side = {})); +class VatId extends index_1.Struct { + getSide() { return index_1.Struct.getUint16(0, this); } + setSide(value) { index_1.Struct.setUint16(0, value, this); } + toString() { return "VatId_" + super.toString(); } +} +exports.VatId = VatId; +VatId._capnp = { displayName: "VatId", id: "d20b909fee733a8e", size: new index_1.ObjectSize(8, 0) }; +class ProvisionId extends index_1.Struct { + getJoinId() { return index_1.Struct.getUint32(0, this); } + setJoinId(value) { index_1.Struct.setUint32(0, value, this); } + toString() { return "ProvisionId_" + super.toString(); } +} +exports.ProvisionId = ProvisionId; +ProvisionId._capnp = { displayName: "ProvisionId", id: "b88d09a9c5f39817", size: new index_1.ObjectSize(8, 0) }; +class RecipientId extends index_1.Struct { + toString() { return "RecipientId_" + super.toString(); } +} +exports.RecipientId = RecipientId; +RecipientId._capnp = { displayName: "RecipientId", id: "89f389b6fd4082c1", size: new index_1.ObjectSize(0, 0) }; +class ThirdPartyCapId extends index_1.Struct { + toString() { return "ThirdPartyCapId_" + super.toString(); } +} +exports.ThirdPartyCapId = ThirdPartyCapId; +ThirdPartyCapId._capnp = { displayName: "ThirdPartyCapId", id: "b47f4979672cb59d", size: new index_1.ObjectSize(0, 0) }; +class JoinKeyPart extends index_1.Struct { + getJoinId() { return index_1.Struct.getUint32(0, this); } + setJoinId(value) { index_1.Struct.setUint32(0, value, this); } + getPartCount() { return index_1.Struct.getUint16(4, this); } + setPartCount(value) { index_1.Struct.setUint16(4, value, this); } + getPartNum() { return index_1.Struct.getUint16(6, this); } + setPartNum(value) { index_1.Struct.setUint16(6, value, this); } + toString() { return "JoinKeyPart_" + super.toString(); } +} +exports.JoinKeyPart = JoinKeyPart; +JoinKeyPart._capnp = { displayName: "JoinKeyPart", id: "95b29059097fca83", size: new index_1.ObjectSize(8, 0) }; +class JoinResult extends index_1.Struct { + getJoinId() { return index_1.Struct.getUint32(0, this); } + setJoinId(value) { index_1.Struct.setUint32(0, value, this); } + getSucceeded() { return index_1.Struct.getBit(32, this); } + setSucceeded(value) { index_1.Struct.setBit(32, value, this); } + adoptCap(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownCap() { return index_1.Struct.disown(this.getCap()); } + getCap() { return index_1.Struct.getPointer(0, this); } + hasCap() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + setCap(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "JoinResult_" + super.toString(); } +} +exports.JoinResult = JoinResult; +JoinResult._capnp = { displayName: "JoinResult", id: "9d263a3630b7ebee", size: new index_1.ObjectSize(8, 1) }; +//# sourceMappingURL=rpc-twoparty.capnp.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.js.map b/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.js.map new file mode 100644 index 0000000000000000000000000000000000000000..afde6d3f6172633a96efe407e439c631fe2538eb --- /dev/null +++ b/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"rpc-twoparty.capnp.js","sourceRoot":"","sources":["rpc-twoparty.capnp.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,oCAA4D;AAC/C,QAAA,YAAY,GAAG,kBAAkB,CAAC;AAC/C,IAAY,IAGX;AAHD,WAAY,IAAI;IACZ,mCAAM,CAAA;IACN,mCAAM,CAAA;AACV,CAAC,EAHW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAGf;AACD,MAAa,KAAM,SAAQ,cAAG;IAE1B,OAAO,KAAW,OAAO,cAAG,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,KAAW,IAAU,cAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7D,QAAQ,KAAa,OAAO,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;;AAJ9D,sBAKC;AAJmB,YAAM,GAAG,EAAE,WAAW,EAAE,OAAO,EA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,KAAK,CAAC,KAAK,EAAE,cAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,SAAS,KAAkC,OAAO,cAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9E,MAAM,KAAoB,OAAO,cAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,KAAc,OAAO,CAAC,cAAG,CAAC,MAAM,CAAC,cAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,CAAC,KAAoB,IAAU,cAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,QAAQ,KAAa,OAAO,aAAa,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;;AAXnE,gCAYC;AAXmB,iBAAM,GAAG,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,kBAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.ts b/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.ts new file mode 100644 index 0000000000000000000000000000000000000000..e56cf781c0e34483b02d25aed02c93c91b6b5b89 --- /dev/null +++ b/node_modules/capnp-ts/src/std/rpc-twoparty.capnp.ts @@ -0,0 +1,55 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ + +import * as capnp from "../index"; +import { ObjectSize as __O, Struct as __S } from "../index"; +export const _capnpFileId = "a184c7885cdaf2a1"; +export enum Side { + SERVER, + CLIENT +} +export class VatId extends __S { + static readonly _capnp = { displayName: "VatId", id: "d20b909fee733a8e", size: new __O(8, 0) }; + getSide(): Side { return __S.getUint16(0, this); } + setSide(value: Side): void { __S.setUint16(0, value, this); } + toString(): string { return "VatId_" + super.toString(); } +} +export class ProvisionId extends __S { + static readonly _capnp = { displayName: "ProvisionId", id: "b88d09a9c5f39817", size: new __O(8, 0) }; + getJoinId(): number { return __S.getUint32(0, this); } + setJoinId(value: number): void { __S.setUint32(0, value, this); } + toString(): string { return "ProvisionId_" + super.toString(); } +} +export class RecipientId extends __S { + static readonly _capnp = { displayName: "RecipientId", id: "89f389b6fd4082c1", size: new __O(0, 0) }; + toString(): string { return "RecipientId_" + super.toString(); } +} +export class ThirdPartyCapId extends __S { + static readonly _capnp = { displayName: "ThirdPartyCapId", id: "b47f4979672cb59d", size: new __O(0, 0) }; + toString(): string { return "ThirdPartyCapId_" + super.toString(); } +} +export class JoinKeyPart extends __S { + static readonly _capnp = { displayName: "JoinKeyPart", id: "95b29059097fca83", size: new __O(8, 0) }; + getJoinId(): number { return __S.getUint32(0, this); } + setJoinId(value: number): void { __S.setUint32(0, value, this); } + getPartCount(): number { return __S.getUint16(4, this); } + setPartCount(value: number): void { __S.setUint16(4, value, this); } + getPartNum(): number { return __S.getUint16(6, this); } + setPartNum(value: number): void { __S.setUint16(6, value, this); } + toString(): string { return "JoinKeyPart_" + super.toString(); } +} +export class JoinResult extends __S { + static readonly _capnp = { displayName: "JoinResult", id: "9d263a3630b7ebee", size: new __O(8, 1) }; + getJoinId(): number { return __S.getUint32(0, this); } + setJoinId(value: number): void { __S.setUint32(0, value, this); } + getSucceeded(): boolean { return __S.getBit(32, this); } + setSucceeded(value: boolean): void { __S.setBit(32, value, this); } + adoptCap(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownCap(): capnp.Orphan { return __S.disown(this.getCap()); } + getCap(): capnp.Pointer { return __S.getPointer(0, this); } + hasCap(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + setCap(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "JoinResult_" + super.toString(); } +} diff --git a/node_modules/capnp-ts/src/std/rpc.capnp.d.ts b/node_modules/capnp-ts/src/std/rpc.capnp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ce22eae1af6e413a4b568d872cda80e5587a094 --- /dev/null +++ b/node_modules/capnp-ts/src/std/rpc.capnp.d.ts @@ -0,0 +1,600 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +import * as capnp from "../index"; +import { Struct as __S } from "../index"; +export declare const _capnpFileId = "b312981b2552a250"; +export declare enum Message_Which { + UNIMPLEMENTED = 0, + ABORT = 1, + BOOTSTRAP = 8, + CALL = 2, + RETURN = 3, + FINISH = 4, + RESOLVE = 5, + RELEASE = 6, + DISEMBARGO = 13, + OBSOLETE_SAVE = 7, + OBSOLETE_DELETE = 9, + PROVIDE = 10, + ACCEPT = 11, + JOIN = 12 +} +export declare class Message extends __S { + static readonly UNIMPLEMENTED = Message_Which.UNIMPLEMENTED; + static readonly ABORT = Message_Which.ABORT; + static readonly BOOTSTRAP = Message_Which.BOOTSTRAP; + static readonly CALL = Message_Which.CALL; + static readonly RETURN = Message_Which.RETURN; + static readonly FINISH = Message_Which.FINISH; + static readonly RESOLVE = Message_Which.RESOLVE; + static readonly RELEASE = Message_Which.RELEASE; + static readonly DISEMBARGO = Message_Which.DISEMBARGO; + static readonly OBSOLETE_SAVE = Message_Which.OBSOLETE_SAVE; + static readonly OBSOLETE_DELETE = Message_Which.OBSOLETE_DELETE; + static readonly PROVIDE = Message_Which.PROVIDE; + static readonly ACCEPT = Message_Which.ACCEPT; + static readonly JOIN = Message_Which.JOIN; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + adoptUnimplemented(value: capnp.Orphan): void; + disownUnimplemented(): capnp.Orphan; + getUnimplemented(): Message; + hasUnimplemented(): boolean; + initUnimplemented(): Message; + isUnimplemented(): boolean; + setUnimplemented(value: Message): void; + adoptAbort(value: capnp.Orphan): void; + disownAbort(): capnp.Orphan; + getAbort(): Exception; + hasAbort(): boolean; + initAbort(): Exception; + isAbort(): boolean; + setAbort(value: Exception): void; + adoptBootstrap(value: capnp.Orphan): void; + disownBootstrap(): capnp.Orphan; + getBootstrap(): Bootstrap; + hasBootstrap(): boolean; + initBootstrap(): Bootstrap; + isBootstrap(): boolean; + setBootstrap(value: Bootstrap): void; + adoptCall(value: capnp.Orphan): void; + disownCall(): capnp.Orphan; + getCall(): Call; + hasCall(): boolean; + initCall(): Call; + isCall(): boolean; + setCall(value: Call): void; + adoptReturn(value: capnp.Orphan): void; + disownReturn(): capnp.Orphan; + getReturn(): Return; + hasReturn(): boolean; + initReturn(): Return; + isReturn(): boolean; + setReturn(value: Return): void; + adoptFinish(value: capnp.Orphan): void; + disownFinish(): capnp.Orphan; + getFinish(): Finish; + hasFinish(): boolean; + initFinish(): Finish; + isFinish(): boolean; + setFinish(value: Finish): void; + adoptResolve(value: capnp.Orphan): void; + disownResolve(): capnp.Orphan; + getResolve(): Resolve; + hasResolve(): boolean; + initResolve(): Resolve; + isResolve(): boolean; + setResolve(value: Resolve): void; + adoptRelease(value: capnp.Orphan): void; + disownRelease(): capnp.Orphan; + getRelease(): Release; + hasRelease(): boolean; + initRelease(): Release; + isRelease(): boolean; + setRelease(value: Release): void; + adoptDisembargo(value: capnp.Orphan): void; + disownDisembargo(): capnp.Orphan; + getDisembargo(): Disembargo; + hasDisembargo(): boolean; + initDisembargo(): Disembargo; + isDisembargo(): boolean; + setDisembargo(value: Disembargo): void; + adoptObsoleteSave(value: capnp.Orphan): void; + disownObsoleteSave(): capnp.Orphan; + getObsoleteSave(): capnp.Pointer; + hasObsoleteSave(): boolean; + isObsoleteSave(): boolean; + setObsoleteSave(value: capnp.Pointer): void; + adoptObsoleteDelete(value: capnp.Orphan): void; + disownObsoleteDelete(): capnp.Orphan; + getObsoleteDelete(): capnp.Pointer; + hasObsoleteDelete(): boolean; + isObsoleteDelete(): boolean; + setObsoleteDelete(value: capnp.Pointer): void; + adoptProvide(value: capnp.Orphan): void; + disownProvide(): capnp.Orphan; + getProvide(): Provide; + hasProvide(): boolean; + initProvide(): Provide; + isProvide(): boolean; + setProvide(value: Provide): void; + adoptAccept(value: capnp.Orphan): void; + disownAccept(): capnp.Orphan; + getAccept(): Accept; + hasAccept(): boolean; + initAccept(): Accept; + isAccept(): boolean; + setAccept(value: Accept): void; + adoptJoin(value: capnp.Orphan): void; + disownJoin(): capnp.Orphan; + getJoin(): Join; + hasJoin(): boolean; + initJoin(): Join; + isJoin(): boolean; + setJoin(value: Join): void; + toString(): string; + which(): Message_Which; +} +export declare class Bootstrap extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getQuestionId(): number; + setQuestionId(value: number): void; + adoptDeprecatedObjectId(value: capnp.Orphan): void; + disownDeprecatedObjectId(): capnp.Orphan; + getDeprecatedObjectId(): capnp.Pointer; + hasDeprecatedObjectId(): boolean; + setDeprecatedObjectId(value: capnp.Pointer): void; + toString(): string; +} +export declare enum Call_SendResultsTo_Which { + CALLER = 0, + YOURSELF = 1, + THIRD_PARTY = 2 +} +export declare class Call_SendResultsTo extends __S { + static readonly CALLER = Call_SendResultsTo_Which.CALLER; + static readonly YOURSELF = Call_SendResultsTo_Which.YOURSELF; + static readonly THIRD_PARTY = Call_SendResultsTo_Which.THIRD_PARTY; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + isCaller(): boolean; + setCaller(): void; + isYourself(): boolean; + setYourself(): void; + adoptThirdParty(value: capnp.Orphan): void; + disownThirdParty(): capnp.Orphan; + getThirdParty(): capnp.Pointer; + hasThirdParty(): boolean; + isThirdParty(): boolean; + setThirdParty(value: capnp.Pointer): void; + toString(): string; + which(): Call_SendResultsTo_Which; +} +export declare class Call extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + defaultAllowThirdPartyTailCall: DataView; + }; + getQuestionId(): number; + setQuestionId(value: number): void; + adoptTarget(value: capnp.Orphan): void; + disownTarget(): capnp.Orphan; + getTarget(): MessageTarget; + hasTarget(): boolean; + initTarget(): MessageTarget; + setTarget(value: MessageTarget): void; + getInterfaceId(): capnp.Uint64; + setInterfaceId(value: capnp.Uint64): void; + getMethodId(): number; + setMethodId(value: number): void; + getAllowThirdPartyTailCall(): boolean; + setAllowThirdPartyTailCall(value: boolean): void; + adoptParams(value: capnp.Orphan): void; + disownParams(): capnp.Orphan; + getParams(): Payload; + hasParams(): boolean; + initParams(): Payload; + setParams(value: Payload): void; + getSendResultsTo(): Call_SendResultsTo; + initSendResultsTo(): Call_SendResultsTo; + toString(): string; +} +export declare enum Return_Which { + RESULTS = 0, + EXCEPTION = 1, + CANCELED = 2, + RESULTS_SENT_ELSEWHERE = 3, + TAKE_FROM_OTHER_QUESTION = 4, + ACCEPT_FROM_THIRD_PARTY = 5 +} +export declare class Return extends __S { + static readonly RESULTS = Return_Which.RESULTS; + static readonly EXCEPTION = Return_Which.EXCEPTION; + static readonly CANCELED = Return_Which.CANCELED; + static readonly RESULTS_SENT_ELSEWHERE = Return_Which.RESULTS_SENT_ELSEWHERE; + static readonly TAKE_FROM_OTHER_QUESTION = Return_Which.TAKE_FROM_OTHER_QUESTION; + static readonly ACCEPT_FROM_THIRD_PARTY = Return_Which.ACCEPT_FROM_THIRD_PARTY; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + defaultReleaseParamCaps: DataView; + }; + getAnswerId(): number; + setAnswerId(value: number): void; + getReleaseParamCaps(): boolean; + setReleaseParamCaps(value: boolean): void; + adoptResults(value: capnp.Orphan): void; + disownResults(): capnp.Orphan; + getResults(): Payload; + hasResults(): boolean; + initResults(): Payload; + isResults(): boolean; + setResults(value: Payload): void; + adoptException(value: capnp.Orphan): void; + disownException(): capnp.Orphan; + getException(): Exception; + hasException(): boolean; + initException(): Exception; + isException(): boolean; + setException(value: Exception): void; + isCanceled(): boolean; + setCanceled(): void; + isResultsSentElsewhere(): boolean; + setResultsSentElsewhere(): void; + getTakeFromOtherQuestion(): number; + isTakeFromOtherQuestion(): boolean; + setTakeFromOtherQuestion(value: number): void; + adoptAcceptFromThirdParty(value: capnp.Orphan): void; + disownAcceptFromThirdParty(): capnp.Orphan; + getAcceptFromThirdParty(): capnp.Pointer; + hasAcceptFromThirdParty(): boolean; + isAcceptFromThirdParty(): boolean; + setAcceptFromThirdParty(value: capnp.Pointer): void; + toString(): string; + which(): Return_Which; +} +export declare class Finish extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + defaultReleaseResultCaps: DataView; + }; + getQuestionId(): number; + setQuestionId(value: number): void; + getReleaseResultCaps(): boolean; + setReleaseResultCaps(value: boolean): void; + toString(): string; +} +export declare enum Resolve_Which { + CAP = 0, + EXCEPTION = 1 +} +export declare class Resolve extends __S { + static readonly CAP = Resolve_Which.CAP; + static readonly EXCEPTION = Resolve_Which.EXCEPTION; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getPromiseId(): number; + setPromiseId(value: number): void; + adoptCap(value: capnp.Orphan): void; + disownCap(): capnp.Orphan; + getCap(): CapDescriptor; + hasCap(): boolean; + initCap(): CapDescriptor; + isCap(): boolean; + setCap(value: CapDescriptor): void; + adoptException(value: capnp.Orphan): void; + disownException(): capnp.Orphan; + getException(): Exception; + hasException(): boolean; + initException(): Exception; + isException(): boolean; + setException(value: Exception): void; + toString(): string; + which(): Resolve_Which; +} +export declare class Release extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getId(): number; + setId(value: number): void; + getReferenceCount(): number; + setReferenceCount(value: number): void; + toString(): string; +} +export declare enum Disembargo_Context_Which { + SENDER_LOOPBACK = 0, + RECEIVER_LOOPBACK = 1, + ACCEPT = 2, + PROVIDE = 3 +} +export declare class Disembargo_Context extends __S { + static readonly SENDER_LOOPBACK = Disembargo_Context_Which.SENDER_LOOPBACK; + static readonly RECEIVER_LOOPBACK = Disembargo_Context_Which.RECEIVER_LOOPBACK; + static readonly ACCEPT = Disembargo_Context_Which.ACCEPT; + static readonly PROVIDE = Disembargo_Context_Which.PROVIDE; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getSenderLoopback(): number; + isSenderLoopback(): boolean; + setSenderLoopback(value: number): void; + getReceiverLoopback(): number; + isReceiverLoopback(): boolean; + setReceiverLoopback(value: number): void; + isAccept(): boolean; + setAccept(): void; + getProvide(): number; + isProvide(): boolean; + setProvide(value: number): void; + toString(): string; + which(): Disembargo_Context_Which; +} +export declare class Disembargo extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + adoptTarget(value: capnp.Orphan): void; + disownTarget(): capnp.Orphan; + getTarget(): MessageTarget; + hasTarget(): boolean; + initTarget(): MessageTarget; + setTarget(value: MessageTarget): void; + getContext(): Disembargo_Context; + initContext(): Disembargo_Context; + toString(): string; +} +export declare class Provide extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getQuestionId(): number; + setQuestionId(value: number): void; + adoptTarget(value: capnp.Orphan): void; + disownTarget(): capnp.Orphan; + getTarget(): MessageTarget; + hasTarget(): boolean; + initTarget(): MessageTarget; + setTarget(value: MessageTarget): void; + adoptRecipient(value: capnp.Orphan): void; + disownRecipient(): capnp.Orphan; + getRecipient(): capnp.Pointer; + hasRecipient(): boolean; + setRecipient(value: capnp.Pointer): void; + toString(): string; +} +export declare class Accept extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getQuestionId(): number; + setQuestionId(value: number): void; + adoptProvision(value: capnp.Orphan): void; + disownProvision(): capnp.Orphan; + getProvision(): capnp.Pointer; + hasProvision(): boolean; + setProvision(value: capnp.Pointer): void; + getEmbargo(): boolean; + setEmbargo(value: boolean): void; + toString(): string; +} +export declare class Join extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getQuestionId(): number; + setQuestionId(value: number): void; + adoptTarget(value: capnp.Orphan): void; + disownTarget(): capnp.Orphan; + getTarget(): MessageTarget; + hasTarget(): boolean; + initTarget(): MessageTarget; + setTarget(value: MessageTarget): void; + adoptKeyPart(value: capnp.Orphan): void; + disownKeyPart(): capnp.Orphan; + getKeyPart(): capnp.Pointer; + hasKeyPart(): boolean; + setKeyPart(value: capnp.Pointer): void; + toString(): string; +} +export declare enum MessageTarget_Which { + IMPORTED_CAP = 0, + PROMISED_ANSWER = 1 +} +export declare class MessageTarget extends __S { + static readonly IMPORTED_CAP = MessageTarget_Which.IMPORTED_CAP; + static readonly PROMISED_ANSWER = MessageTarget_Which.PROMISED_ANSWER; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getImportedCap(): number; + isImportedCap(): boolean; + setImportedCap(value: number): void; + adoptPromisedAnswer(value: capnp.Orphan): void; + disownPromisedAnswer(): capnp.Orphan; + getPromisedAnswer(): PromisedAnswer; + hasPromisedAnswer(): boolean; + initPromisedAnswer(): PromisedAnswer; + isPromisedAnswer(): boolean; + setPromisedAnswer(value: PromisedAnswer): void; + toString(): string; + which(): MessageTarget_Which; +} +export declare class Payload extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _CapTable: capnp.ListCtor; + adoptContent(value: capnp.Orphan): void; + disownContent(): capnp.Orphan; + getContent(): capnp.Pointer; + hasContent(): boolean; + setContent(value: capnp.Pointer): void; + adoptCapTable(value: capnp.Orphan>): void; + disownCapTable(): capnp.Orphan>; + getCapTable(): capnp.List; + hasCapTable(): boolean; + initCapTable(length: number): capnp.List; + setCapTable(value: capnp.List): void; + toString(): string; +} +export declare enum CapDescriptor_Which { + NONE = 0, + SENDER_HOSTED = 1, + SENDER_PROMISE = 2, + RECEIVER_HOSTED = 3, + RECEIVER_ANSWER = 4, + THIRD_PARTY_HOSTED = 5 +} +export declare class CapDescriptor extends __S { + static readonly NONE = CapDescriptor_Which.NONE; + static readonly SENDER_HOSTED = CapDescriptor_Which.SENDER_HOSTED; + static readonly SENDER_PROMISE = CapDescriptor_Which.SENDER_PROMISE; + static readonly RECEIVER_HOSTED = CapDescriptor_Which.RECEIVER_HOSTED; + static readonly RECEIVER_ANSWER = CapDescriptor_Which.RECEIVER_ANSWER; + static readonly THIRD_PARTY_HOSTED = CapDescriptor_Which.THIRD_PARTY_HOSTED; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + isNone(): boolean; + setNone(): void; + getSenderHosted(): number; + isSenderHosted(): boolean; + setSenderHosted(value: number): void; + getSenderPromise(): number; + isSenderPromise(): boolean; + setSenderPromise(value: number): void; + getReceiverHosted(): number; + isReceiverHosted(): boolean; + setReceiverHosted(value: number): void; + adoptReceiverAnswer(value: capnp.Orphan): void; + disownReceiverAnswer(): capnp.Orphan; + getReceiverAnswer(): PromisedAnswer; + hasReceiverAnswer(): boolean; + initReceiverAnswer(): PromisedAnswer; + isReceiverAnswer(): boolean; + setReceiverAnswer(value: PromisedAnswer): void; + adoptThirdPartyHosted(value: capnp.Orphan): void; + disownThirdPartyHosted(): capnp.Orphan; + getThirdPartyHosted(): ThirdPartyCapDescriptor; + hasThirdPartyHosted(): boolean; + initThirdPartyHosted(): ThirdPartyCapDescriptor; + isThirdPartyHosted(): boolean; + setThirdPartyHosted(value: ThirdPartyCapDescriptor): void; + toString(): string; + which(): CapDescriptor_Which; +} +export declare enum PromisedAnswer_Op_Which { + NOOP = 0, + GET_POINTER_FIELD = 1 +} +export declare class PromisedAnswer_Op extends __S { + static readonly NOOP = PromisedAnswer_Op_Which.NOOP; + static readonly GET_POINTER_FIELD = PromisedAnswer_Op_Which.GET_POINTER_FIELD; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + isNoop(): boolean; + setNoop(): void; + getGetPointerField(): number; + isGetPointerField(): boolean; + setGetPointerField(value: number): void; + toString(): string; + which(): PromisedAnswer_Op_Which; +} +export declare class PromisedAnswer extends __S { + static readonly Op: typeof PromisedAnswer_Op; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Transform: capnp.ListCtor; + getQuestionId(): number; + setQuestionId(value: number): void; + adoptTransform(value: capnp.Orphan>): void; + disownTransform(): capnp.Orphan>; + getTransform(): capnp.List; + hasTransform(): boolean; + initTransform(length: number): capnp.List; + setTransform(value: capnp.List): void; + toString(): string; +} +export declare class ThirdPartyCapDescriptor extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + adoptId(value: capnp.Orphan): void; + disownId(): capnp.Orphan; + getId(): capnp.Pointer; + hasId(): boolean; + setId(value: capnp.Pointer): void; + getVineId(): number; + setVineId(value: number): void; + toString(): string; +} +export declare enum Exception_Type { + FAILED = 0, + OVERLOADED = 1, + DISCONNECTED = 2, + UNIMPLEMENTED = 3 +} +export declare class Exception extends __S { + static readonly Type: typeof Exception_Type; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getReason(): string; + setReason(value: string): void; + getType(): Exception_Type; + setType(value: Exception_Type): void; + getObsoleteIsCallersFault(): boolean; + setObsoleteIsCallersFault(value: boolean): void; + getObsoleteDurability(): number; + setObsoleteDurability(value: number): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/std/rpc.capnp.js b/node_modules/capnp-ts/src/std/rpc.capnp.js new file mode 100644 index 0000000000000000000000000000000000000000..4947725ce42d8874726b3f1840fe699d0362b8bc --- /dev/null +++ b/node_modules/capnp-ts/src/std/rpc.capnp.js @@ -0,0 +1,869 @@ +"use strict"; +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Exception = exports.Exception_Type = exports.ThirdPartyCapDescriptor = exports.PromisedAnswer = exports.PromisedAnswer_Op = exports.PromisedAnswer_Op_Which = exports.CapDescriptor = exports.CapDescriptor_Which = exports.Payload = exports.MessageTarget = exports.MessageTarget_Which = exports.Join = exports.Accept = exports.Provide = exports.Disembargo = exports.Disembargo_Context = exports.Disembargo_Context_Which = exports.Release = exports.Resolve = exports.Resolve_Which = exports.Finish = exports.Return = exports.Return_Which = exports.Call = exports.Call_SendResultsTo = exports.Call_SendResultsTo_Which = exports.Bootstrap = exports.Message = exports.Message_Which = exports._capnpFileId = void 0; +const tslib_1 = require("tslib"); +const capnp = tslib_1.__importStar(require("../index")); +const index_1 = require("../index"); +exports._capnpFileId = "b312981b2552a250"; +var Message_Which; +(function (Message_Which) { + Message_Which[Message_Which["UNIMPLEMENTED"] = 0] = "UNIMPLEMENTED"; + Message_Which[Message_Which["ABORT"] = 1] = "ABORT"; + Message_Which[Message_Which["BOOTSTRAP"] = 8] = "BOOTSTRAP"; + Message_Which[Message_Which["CALL"] = 2] = "CALL"; + Message_Which[Message_Which["RETURN"] = 3] = "RETURN"; + Message_Which[Message_Which["FINISH"] = 4] = "FINISH"; + Message_Which[Message_Which["RESOLVE"] = 5] = "RESOLVE"; + Message_Which[Message_Which["RELEASE"] = 6] = "RELEASE"; + Message_Which[Message_Which["DISEMBARGO"] = 13] = "DISEMBARGO"; + Message_Which[Message_Which["OBSOLETE_SAVE"] = 7] = "OBSOLETE_SAVE"; + Message_Which[Message_Which["OBSOLETE_DELETE"] = 9] = "OBSOLETE_DELETE"; + Message_Which[Message_Which["PROVIDE"] = 10] = "PROVIDE"; + Message_Which[Message_Which["ACCEPT"] = 11] = "ACCEPT"; + Message_Which[Message_Which["JOIN"] = 12] = "JOIN"; +})(Message_Which = exports.Message_Which || (exports.Message_Which = {})); +class Message extends index_1.Struct { + adoptUnimplemented(value) { + index_1.Struct.setUint16(0, 0, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownUnimplemented() { return index_1.Struct.disown(this.getUnimplemented()); } + getUnimplemented() { + index_1.Struct.testWhich("unimplemented", index_1.Struct.getUint16(0, this), 0, this); + return index_1.Struct.getStruct(0, Message, this); + } + hasUnimplemented() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initUnimplemented() { + index_1.Struct.setUint16(0, 0, this); + return index_1.Struct.initStructAt(0, Message, this); + } + isUnimplemented() { return index_1.Struct.getUint16(0, this) === 0; } + setUnimplemented(value) { + index_1.Struct.setUint16(0, 0, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptAbort(value) { + index_1.Struct.setUint16(0, 1, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownAbort() { return index_1.Struct.disown(this.getAbort()); } + getAbort() { + index_1.Struct.testWhich("abort", index_1.Struct.getUint16(0, this), 1, this); + return index_1.Struct.getStruct(0, Exception, this); + } + hasAbort() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initAbort() { + index_1.Struct.setUint16(0, 1, this); + return index_1.Struct.initStructAt(0, Exception, this); + } + isAbort() { return index_1.Struct.getUint16(0, this) === 1; } + setAbort(value) { + index_1.Struct.setUint16(0, 1, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptBootstrap(value) { + index_1.Struct.setUint16(0, 8, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownBootstrap() { return index_1.Struct.disown(this.getBootstrap()); } + getBootstrap() { + index_1.Struct.testWhich("bootstrap", index_1.Struct.getUint16(0, this), 8, this); + return index_1.Struct.getStruct(0, Bootstrap, this); + } + hasBootstrap() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initBootstrap() { + index_1.Struct.setUint16(0, 8, this); + return index_1.Struct.initStructAt(0, Bootstrap, this); + } + isBootstrap() { return index_1.Struct.getUint16(0, this) === 8; } + setBootstrap(value) { + index_1.Struct.setUint16(0, 8, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptCall(value) { + index_1.Struct.setUint16(0, 2, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownCall() { return index_1.Struct.disown(this.getCall()); } + getCall() { + index_1.Struct.testWhich("call", index_1.Struct.getUint16(0, this), 2, this); + return index_1.Struct.getStruct(0, Call, this); + } + hasCall() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initCall() { + index_1.Struct.setUint16(0, 2, this); + return index_1.Struct.initStructAt(0, Call, this); + } + isCall() { return index_1.Struct.getUint16(0, this) === 2; } + setCall(value) { + index_1.Struct.setUint16(0, 2, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptReturn(value) { + index_1.Struct.setUint16(0, 3, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownReturn() { return index_1.Struct.disown(this.getReturn()); } + getReturn() { + index_1.Struct.testWhich("return", index_1.Struct.getUint16(0, this), 3, this); + return index_1.Struct.getStruct(0, Return, this); + } + hasReturn() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initReturn() { + index_1.Struct.setUint16(0, 3, this); + return index_1.Struct.initStructAt(0, Return, this); + } + isReturn() { return index_1.Struct.getUint16(0, this) === 3; } + setReturn(value) { + index_1.Struct.setUint16(0, 3, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptFinish(value) { + index_1.Struct.setUint16(0, 4, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownFinish() { return index_1.Struct.disown(this.getFinish()); } + getFinish() { + index_1.Struct.testWhich("finish", index_1.Struct.getUint16(0, this), 4, this); + return index_1.Struct.getStruct(0, Finish, this); + } + hasFinish() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initFinish() { + index_1.Struct.setUint16(0, 4, this); + return index_1.Struct.initStructAt(0, Finish, this); + } + isFinish() { return index_1.Struct.getUint16(0, this) === 4; } + setFinish(value) { + index_1.Struct.setUint16(0, 4, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptResolve(value) { + index_1.Struct.setUint16(0, 5, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownResolve() { return index_1.Struct.disown(this.getResolve()); } + getResolve() { + index_1.Struct.testWhich("resolve", index_1.Struct.getUint16(0, this), 5, this); + return index_1.Struct.getStruct(0, Resolve, this); + } + hasResolve() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initResolve() { + index_1.Struct.setUint16(0, 5, this); + return index_1.Struct.initStructAt(0, Resolve, this); + } + isResolve() { return index_1.Struct.getUint16(0, this) === 5; } + setResolve(value) { + index_1.Struct.setUint16(0, 5, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptRelease(value) { + index_1.Struct.setUint16(0, 6, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownRelease() { return index_1.Struct.disown(this.getRelease()); } + getRelease() { + index_1.Struct.testWhich("release", index_1.Struct.getUint16(0, this), 6, this); + return index_1.Struct.getStruct(0, Release, this); + } + hasRelease() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initRelease() { + index_1.Struct.setUint16(0, 6, this); + return index_1.Struct.initStructAt(0, Release, this); + } + isRelease() { return index_1.Struct.getUint16(0, this) === 6; } + setRelease(value) { + index_1.Struct.setUint16(0, 6, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptDisembargo(value) { + index_1.Struct.setUint16(0, 13, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownDisembargo() { return index_1.Struct.disown(this.getDisembargo()); } + getDisembargo() { + index_1.Struct.testWhich("disembargo", index_1.Struct.getUint16(0, this), 13, this); + return index_1.Struct.getStruct(0, Disembargo, this); + } + hasDisembargo() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initDisembargo() { + index_1.Struct.setUint16(0, 13, this); + return index_1.Struct.initStructAt(0, Disembargo, this); + } + isDisembargo() { return index_1.Struct.getUint16(0, this) === 13; } + setDisembargo(value) { + index_1.Struct.setUint16(0, 13, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptObsoleteSave(value) { + index_1.Struct.setUint16(0, 7, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownObsoleteSave() { return index_1.Struct.disown(this.getObsoleteSave()); } + getObsoleteSave() { + index_1.Struct.testWhich("obsoleteSave", index_1.Struct.getUint16(0, this), 7, this); + return index_1.Struct.getPointer(0, this); + } + hasObsoleteSave() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + isObsoleteSave() { return index_1.Struct.getUint16(0, this) === 7; } + setObsoleteSave(value) { + index_1.Struct.setUint16(0, 7, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptObsoleteDelete(value) { + index_1.Struct.setUint16(0, 9, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownObsoleteDelete() { return index_1.Struct.disown(this.getObsoleteDelete()); } + getObsoleteDelete() { + index_1.Struct.testWhich("obsoleteDelete", index_1.Struct.getUint16(0, this), 9, this); + return index_1.Struct.getPointer(0, this); + } + hasObsoleteDelete() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + isObsoleteDelete() { return index_1.Struct.getUint16(0, this) === 9; } + setObsoleteDelete(value) { + index_1.Struct.setUint16(0, 9, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptProvide(value) { + index_1.Struct.setUint16(0, 10, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownProvide() { return index_1.Struct.disown(this.getProvide()); } + getProvide() { + index_1.Struct.testWhich("provide", index_1.Struct.getUint16(0, this), 10, this); + return index_1.Struct.getStruct(0, Provide, this); + } + hasProvide() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initProvide() { + index_1.Struct.setUint16(0, 10, this); + return index_1.Struct.initStructAt(0, Provide, this); + } + isProvide() { return index_1.Struct.getUint16(0, this) === 10; } + setProvide(value) { + index_1.Struct.setUint16(0, 10, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptAccept(value) { + index_1.Struct.setUint16(0, 11, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownAccept() { return index_1.Struct.disown(this.getAccept()); } + getAccept() { + index_1.Struct.testWhich("accept", index_1.Struct.getUint16(0, this), 11, this); + return index_1.Struct.getStruct(0, Accept, this); + } + hasAccept() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initAccept() { + index_1.Struct.setUint16(0, 11, this); + return index_1.Struct.initStructAt(0, Accept, this); + } + isAccept() { return index_1.Struct.getUint16(0, this) === 11; } + setAccept(value) { + index_1.Struct.setUint16(0, 11, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptJoin(value) { + index_1.Struct.setUint16(0, 12, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownJoin() { return index_1.Struct.disown(this.getJoin()); } + getJoin() { + index_1.Struct.testWhich("join", index_1.Struct.getUint16(0, this), 12, this); + return index_1.Struct.getStruct(0, Join, this); + } + hasJoin() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initJoin() { + index_1.Struct.setUint16(0, 12, this); + return index_1.Struct.initStructAt(0, Join, this); + } + isJoin() { return index_1.Struct.getUint16(0, this) === 12; } + setJoin(value) { + index_1.Struct.setUint16(0, 12, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + toString() { return "Message_" + super.toString(); } + which() { return index_1.Struct.getUint16(0, this); } +} +exports.Message = Message; +Message.UNIMPLEMENTED = Message_Which.UNIMPLEMENTED; +Message.ABORT = Message_Which.ABORT; +Message.BOOTSTRAP = Message_Which.BOOTSTRAP; +Message.CALL = Message_Which.CALL; +Message.RETURN = Message_Which.RETURN; +Message.FINISH = Message_Which.FINISH; +Message.RESOLVE = Message_Which.RESOLVE; +Message.RELEASE = Message_Which.RELEASE; +Message.DISEMBARGO = Message_Which.DISEMBARGO; +Message.OBSOLETE_SAVE = Message_Which.OBSOLETE_SAVE; +Message.OBSOLETE_DELETE = Message_Which.OBSOLETE_DELETE; +Message.PROVIDE = Message_Which.PROVIDE; +Message.ACCEPT = Message_Which.ACCEPT; +Message.JOIN = Message_Which.JOIN; +Message._capnp = { displayName: "Message", id: "91b79f1f808db032", size: new index_1.ObjectSize(8, 1) }; +class Bootstrap extends index_1.Struct { + getQuestionId() { return index_1.Struct.getUint32(0, this); } + setQuestionId(value) { index_1.Struct.setUint32(0, value, this); } + adoptDeprecatedObjectId(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownDeprecatedObjectId() { return index_1.Struct.disown(this.getDeprecatedObjectId()); } + getDeprecatedObjectId() { return index_1.Struct.getPointer(0, this); } + hasDeprecatedObjectId() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + setDeprecatedObjectId(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Bootstrap_" + super.toString(); } +} +exports.Bootstrap = Bootstrap; +Bootstrap._capnp = { displayName: "Bootstrap", id: "e94ccf8031176ec4", size: new index_1.ObjectSize(8, 1) }; +var Call_SendResultsTo_Which; +(function (Call_SendResultsTo_Which) { + Call_SendResultsTo_Which[Call_SendResultsTo_Which["CALLER"] = 0] = "CALLER"; + Call_SendResultsTo_Which[Call_SendResultsTo_Which["YOURSELF"] = 1] = "YOURSELF"; + Call_SendResultsTo_Which[Call_SendResultsTo_Which["THIRD_PARTY"] = 2] = "THIRD_PARTY"; +})(Call_SendResultsTo_Which = exports.Call_SendResultsTo_Which || (exports.Call_SendResultsTo_Which = {})); +class Call_SendResultsTo extends index_1.Struct { + isCaller() { return index_1.Struct.getUint16(6, this) === 0; } + setCaller() { index_1.Struct.setUint16(6, 0, this); } + isYourself() { return index_1.Struct.getUint16(6, this) === 1; } + setYourself() { index_1.Struct.setUint16(6, 1, this); } + adoptThirdParty(value) { + index_1.Struct.setUint16(6, 2, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(2, this)); + } + disownThirdParty() { return index_1.Struct.disown(this.getThirdParty()); } + getThirdParty() { + index_1.Struct.testWhich("thirdParty", index_1.Struct.getUint16(6, this), 2, this); + return index_1.Struct.getPointer(2, this); + } + hasThirdParty() { return !index_1.Struct.isNull(index_1.Struct.getPointer(2, this)); } + isThirdParty() { return index_1.Struct.getUint16(6, this) === 2; } + setThirdParty(value) { + index_1.Struct.setUint16(6, 2, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(2, this)); + } + toString() { return "Call_SendResultsTo_" + super.toString(); } + which() { return index_1.Struct.getUint16(6, this); } +} +exports.Call_SendResultsTo = Call_SendResultsTo; +Call_SendResultsTo.CALLER = Call_SendResultsTo_Which.CALLER; +Call_SendResultsTo.YOURSELF = Call_SendResultsTo_Which.YOURSELF; +Call_SendResultsTo.THIRD_PARTY = Call_SendResultsTo_Which.THIRD_PARTY; +Call_SendResultsTo._capnp = { displayName: "sendResultsTo", id: "dae8b0f61aab5f99", size: new index_1.ObjectSize(24, 3) }; +class Call extends index_1.Struct { + getQuestionId() { return index_1.Struct.getUint32(0, this); } + setQuestionId(value) { index_1.Struct.setUint32(0, value, this); } + adoptTarget(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownTarget() { return index_1.Struct.disown(this.getTarget()); } + getTarget() { return index_1.Struct.getStruct(0, MessageTarget, this); } + hasTarget() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initTarget() { return index_1.Struct.initStructAt(0, MessageTarget, this); } + setTarget(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + getInterfaceId() { return index_1.Struct.getUint64(8, this); } + setInterfaceId(value) { index_1.Struct.setUint64(8, value, this); } + getMethodId() { return index_1.Struct.getUint16(4, this); } + setMethodId(value) { index_1.Struct.setUint16(4, value, this); } + getAllowThirdPartyTailCall() { return index_1.Struct.getBit(128, this, Call._capnp.defaultAllowThirdPartyTailCall); } + setAllowThirdPartyTailCall(value) { index_1.Struct.setBit(128, value, this); } + adoptParams(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownParams() { return index_1.Struct.disown(this.getParams()); } + getParams() { return index_1.Struct.getStruct(1, Payload, this); } + hasParams() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initParams() { return index_1.Struct.initStructAt(1, Payload, this); } + setParams(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + getSendResultsTo() { return index_1.Struct.getAs(Call_SendResultsTo, this); } + initSendResultsTo() { return index_1.Struct.getAs(Call_SendResultsTo, this); } + toString() { return "Call_" + super.toString(); } +} +exports.Call = Call; +Call._capnp = { displayName: "Call", id: "836a53ce789d4cd4", size: new index_1.ObjectSize(24, 3), defaultAllowThirdPartyTailCall: capnp.getBitMask(false, 0) }; +var Return_Which; +(function (Return_Which) { + Return_Which[Return_Which["RESULTS"] = 0] = "RESULTS"; + Return_Which[Return_Which["EXCEPTION"] = 1] = "EXCEPTION"; + Return_Which[Return_Which["CANCELED"] = 2] = "CANCELED"; + Return_Which[Return_Which["RESULTS_SENT_ELSEWHERE"] = 3] = "RESULTS_SENT_ELSEWHERE"; + Return_Which[Return_Which["TAKE_FROM_OTHER_QUESTION"] = 4] = "TAKE_FROM_OTHER_QUESTION"; + Return_Which[Return_Which["ACCEPT_FROM_THIRD_PARTY"] = 5] = "ACCEPT_FROM_THIRD_PARTY"; +})(Return_Which = exports.Return_Which || (exports.Return_Which = {})); +class Return extends index_1.Struct { + getAnswerId() { return index_1.Struct.getUint32(0, this); } + setAnswerId(value) { index_1.Struct.setUint32(0, value, this); } + getReleaseParamCaps() { return index_1.Struct.getBit(32, this, Return._capnp.defaultReleaseParamCaps); } + setReleaseParamCaps(value) { index_1.Struct.setBit(32, value, this); } + adoptResults(value) { + index_1.Struct.setUint16(6, 0, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownResults() { return index_1.Struct.disown(this.getResults()); } + getResults() { + index_1.Struct.testWhich("results", index_1.Struct.getUint16(6, this), 0, this); + return index_1.Struct.getStruct(0, Payload, this); + } + hasResults() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initResults() { + index_1.Struct.setUint16(6, 0, this); + return index_1.Struct.initStructAt(0, Payload, this); + } + isResults() { return index_1.Struct.getUint16(6, this) === 0; } + setResults(value) { + index_1.Struct.setUint16(6, 0, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptException(value) { + index_1.Struct.setUint16(6, 1, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownException() { return index_1.Struct.disown(this.getException()); } + getException() { + index_1.Struct.testWhich("exception", index_1.Struct.getUint16(6, this), 1, this); + return index_1.Struct.getStruct(0, Exception, this); + } + hasException() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initException() { + index_1.Struct.setUint16(6, 1, this); + return index_1.Struct.initStructAt(0, Exception, this); + } + isException() { return index_1.Struct.getUint16(6, this) === 1; } + setException(value) { + index_1.Struct.setUint16(6, 1, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + isCanceled() { return index_1.Struct.getUint16(6, this) === 2; } + setCanceled() { index_1.Struct.setUint16(6, 2, this); } + isResultsSentElsewhere() { return index_1.Struct.getUint16(6, this) === 3; } + setResultsSentElsewhere() { index_1.Struct.setUint16(6, 3, this); } + getTakeFromOtherQuestion() { + index_1.Struct.testWhich("takeFromOtherQuestion", index_1.Struct.getUint16(6, this), 4, this); + return index_1.Struct.getUint32(8, this); + } + isTakeFromOtherQuestion() { return index_1.Struct.getUint16(6, this) === 4; } + setTakeFromOtherQuestion(value) { + index_1.Struct.setUint16(6, 4, this); + index_1.Struct.setUint32(8, value, this); + } + adoptAcceptFromThirdParty(value) { + index_1.Struct.setUint16(6, 5, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownAcceptFromThirdParty() { return index_1.Struct.disown(this.getAcceptFromThirdParty()); } + getAcceptFromThirdParty() { + index_1.Struct.testWhich("acceptFromThirdParty", index_1.Struct.getUint16(6, this), 5, this); + return index_1.Struct.getPointer(0, this); + } + hasAcceptFromThirdParty() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + isAcceptFromThirdParty() { return index_1.Struct.getUint16(6, this) === 5; } + setAcceptFromThirdParty(value) { + index_1.Struct.setUint16(6, 5, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + toString() { return "Return_" + super.toString(); } + which() { return index_1.Struct.getUint16(6, this); } +} +exports.Return = Return; +Return.RESULTS = Return_Which.RESULTS; +Return.EXCEPTION = Return_Which.EXCEPTION; +Return.CANCELED = Return_Which.CANCELED; +Return.RESULTS_SENT_ELSEWHERE = Return_Which.RESULTS_SENT_ELSEWHERE; +Return.TAKE_FROM_OTHER_QUESTION = Return_Which.TAKE_FROM_OTHER_QUESTION; +Return.ACCEPT_FROM_THIRD_PARTY = Return_Which.ACCEPT_FROM_THIRD_PARTY; +Return._capnp = { displayName: "Return", id: "9e19b28d3db3573a", size: new index_1.ObjectSize(16, 1), defaultReleaseParamCaps: capnp.getBitMask(true, 0) }; +class Finish extends index_1.Struct { + getQuestionId() { return index_1.Struct.getUint32(0, this); } + setQuestionId(value) { index_1.Struct.setUint32(0, value, this); } + getReleaseResultCaps() { return index_1.Struct.getBit(32, this, Finish._capnp.defaultReleaseResultCaps); } + setReleaseResultCaps(value) { index_1.Struct.setBit(32, value, this); } + toString() { return "Finish_" + super.toString(); } +} +exports.Finish = Finish; +Finish._capnp = { displayName: "Finish", id: "d37d2eb2c2f80e63", size: new index_1.ObjectSize(8, 0), defaultReleaseResultCaps: capnp.getBitMask(true, 0) }; +var Resolve_Which; +(function (Resolve_Which) { + Resolve_Which[Resolve_Which["CAP"] = 0] = "CAP"; + Resolve_Which[Resolve_Which["EXCEPTION"] = 1] = "EXCEPTION"; +})(Resolve_Which = exports.Resolve_Which || (exports.Resolve_Which = {})); +class Resolve extends index_1.Struct { + getPromiseId() { return index_1.Struct.getUint32(0, this); } + setPromiseId(value) { index_1.Struct.setUint32(0, value, this); } + adoptCap(value) { + index_1.Struct.setUint16(4, 0, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownCap() { return index_1.Struct.disown(this.getCap()); } + getCap() { + index_1.Struct.testWhich("cap", index_1.Struct.getUint16(4, this), 0, this); + return index_1.Struct.getStruct(0, CapDescriptor, this); + } + hasCap() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initCap() { + index_1.Struct.setUint16(4, 0, this); + return index_1.Struct.initStructAt(0, CapDescriptor, this); + } + isCap() { return index_1.Struct.getUint16(4, this) === 0; } + setCap(value) { + index_1.Struct.setUint16(4, 0, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptException(value) { + index_1.Struct.setUint16(4, 1, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownException() { return index_1.Struct.disown(this.getException()); } + getException() { + index_1.Struct.testWhich("exception", index_1.Struct.getUint16(4, this), 1, this); + return index_1.Struct.getStruct(0, Exception, this); + } + hasException() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initException() { + index_1.Struct.setUint16(4, 1, this); + return index_1.Struct.initStructAt(0, Exception, this); + } + isException() { return index_1.Struct.getUint16(4, this) === 1; } + setException(value) { + index_1.Struct.setUint16(4, 1, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + toString() { return "Resolve_" + super.toString(); } + which() { return index_1.Struct.getUint16(4, this); } +} +exports.Resolve = Resolve; +Resolve.CAP = Resolve_Which.CAP; +Resolve.EXCEPTION = Resolve_Which.EXCEPTION; +Resolve._capnp = { displayName: "Resolve", id: "bbc29655fa89086e", size: new index_1.ObjectSize(8, 1) }; +class Release extends index_1.Struct { + getId() { return index_1.Struct.getUint32(0, this); } + setId(value) { index_1.Struct.setUint32(0, value, this); } + getReferenceCount() { return index_1.Struct.getUint32(4, this); } + setReferenceCount(value) { index_1.Struct.setUint32(4, value, this); } + toString() { return "Release_" + super.toString(); } +} +exports.Release = Release; +Release._capnp = { displayName: "Release", id: "ad1a6c0d7dd07497", size: new index_1.ObjectSize(8, 0) }; +var Disembargo_Context_Which; +(function (Disembargo_Context_Which) { + Disembargo_Context_Which[Disembargo_Context_Which["SENDER_LOOPBACK"] = 0] = "SENDER_LOOPBACK"; + Disembargo_Context_Which[Disembargo_Context_Which["RECEIVER_LOOPBACK"] = 1] = "RECEIVER_LOOPBACK"; + Disembargo_Context_Which[Disembargo_Context_Which["ACCEPT"] = 2] = "ACCEPT"; + Disembargo_Context_Which[Disembargo_Context_Which["PROVIDE"] = 3] = "PROVIDE"; +})(Disembargo_Context_Which = exports.Disembargo_Context_Which || (exports.Disembargo_Context_Which = {})); +class Disembargo_Context extends index_1.Struct { + getSenderLoopback() { + index_1.Struct.testWhich("senderLoopback", index_1.Struct.getUint16(4, this), 0, this); + return index_1.Struct.getUint32(0, this); + } + isSenderLoopback() { return index_1.Struct.getUint16(4, this) === 0; } + setSenderLoopback(value) { + index_1.Struct.setUint16(4, 0, this); + index_1.Struct.setUint32(0, value, this); + } + getReceiverLoopback() { + index_1.Struct.testWhich("receiverLoopback", index_1.Struct.getUint16(4, this), 1, this); + return index_1.Struct.getUint32(0, this); + } + isReceiverLoopback() { return index_1.Struct.getUint16(4, this) === 1; } + setReceiverLoopback(value) { + index_1.Struct.setUint16(4, 1, this); + index_1.Struct.setUint32(0, value, this); + } + isAccept() { return index_1.Struct.getUint16(4, this) === 2; } + setAccept() { index_1.Struct.setUint16(4, 2, this); } + getProvide() { + index_1.Struct.testWhich("provide", index_1.Struct.getUint16(4, this), 3, this); + return index_1.Struct.getUint32(0, this); + } + isProvide() { return index_1.Struct.getUint16(4, this) === 3; } + setProvide(value) { + index_1.Struct.setUint16(4, 3, this); + index_1.Struct.setUint32(0, value, this); + } + toString() { return "Disembargo_Context_" + super.toString(); } + which() { return index_1.Struct.getUint16(4, this); } +} +exports.Disembargo_Context = Disembargo_Context; +Disembargo_Context.SENDER_LOOPBACK = Disembargo_Context_Which.SENDER_LOOPBACK; +Disembargo_Context.RECEIVER_LOOPBACK = Disembargo_Context_Which.RECEIVER_LOOPBACK; +Disembargo_Context.ACCEPT = Disembargo_Context_Which.ACCEPT; +Disembargo_Context.PROVIDE = Disembargo_Context_Which.PROVIDE; +Disembargo_Context._capnp = { displayName: "context", id: "d562b4df655bdd4d", size: new index_1.ObjectSize(8, 1) }; +class Disembargo extends index_1.Struct { + adoptTarget(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownTarget() { return index_1.Struct.disown(this.getTarget()); } + getTarget() { return index_1.Struct.getStruct(0, MessageTarget, this); } + hasTarget() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initTarget() { return index_1.Struct.initStructAt(0, MessageTarget, this); } + setTarget(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + getContext() { return index_1.Struct.getAs(Disembargo_Context, this); } + initContext() { return index_1.Struct.getAs(Disembargo_Context, this); } + toString() { return "Disembargo_" + super.toString(); } +} +exports.Disembargo = Disembargo; +Disembargo._capnp = { displayName: "Disembargo", id: "f964368b0fbd3711", size: new index_1.ObjectSize(8, 1) }; +class Provide extends index_1.Struct { + getQuestionId() { return index_1.Struct.getUint32(0, this); } + setQuestionId(value) { index_1.Struct.setUint32(0, value, this); } + adoptTarget(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownTarget() { return index_1.Struct.disown(this.getTarget()); } + getTarget() { return index_1.Struct.getStruct(0, MessageTarget, this); } + hasTarget() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initTarget() { return index_1.Struct.initStructAt(0, MessageTarget, this); } + setTarget(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + adoptRecipient(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownRecipient() { return index_1.Struct.disown(this.getRecipient()); } + getRecipient() { return index_1.Struct.getPointer(1, this); } + hasRecipient() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + setRecipient(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + toString() { return "Provide_" + super.toString(); } +} +exports.Provide = Provide; +Provide._capnp = { displayName: "Provide", id: "9c6a046bfbc1ac5a", size: new index_1.ObjectSize(8, 2) }; +class Accept extends index_1.Struct { + getQuestionId() { return index_1.Struct.getUint32(0, this); } + setQuestionId(value) { index_1.Struct.setUint32(0, value, this); } + adoptProvision(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownProvision() { return index_1.Struct.disown(this.getProvision()); } + getProvision() { return index_1.Struct.getPointer(0, this); } + hasProvision() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + setProvision(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + getEmbargo() { return index_1.Struct.getBit(32, this); } + setEmbargo(value) { index_1.Struct.setBit(32, value, this); } + toString() { return "Accept_" + super.toString(); } +} +exports.Accept = Accept; +Accept._capnp = { displayName: "Accept", id: "d4c9b56290554016", size: new index_1.ObjectSize(8, 1) }; +class Join extends index_1.Struct { + getQuestionId() { return index_1.Struct.getUint32(0, this); } + setQuestionId(value) { index_1.Struct.setUint32(0, value, this); } + adoptTarget(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownTarget() { return index_1.Struct.disown(this.getTarget()); } + getTarget() { return index_1.Struct.getStruct(0, MessageTarget, this); } + hasTarget() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initTarget() { return index_1.Struct.initStructAt(0, MessageTarget, this); } + setTarget(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + adoptKeyPart(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownKeyPart() { return index_1.Struct.disown(this.getKeyPart()); } + getKeyPart() { return index_1.Struct.getPointer(1, this); } + hasKeyPart() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + setKeyPart(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + toString() { return "Join_" + super.toString(); } +} +exports.Join = Join; +Join._capnp = { displayName: "Join", id: "fbe1980490e001af", size: new index_1.ObjectSize(8, 2) }; +var MessageTarget_Which; +(function (MessageTarget_Which) { + MessageTarget_Which[MessageTarget_Which["IMPORTED_CAP"] = 0] = "IMPORTED_CAP"; + MessageTarget_Which[MessageTarget_Which["PROMISED_ANSWER"] = 1] = "PROMISED_ANSWER"; +})(MessageTarget_Which = exports.MessageTarget_Which || (exports.MessageTarget_Which = {})); +class MessageTarget extends index_1.Struct { + getImportedCap() { + index_1.Struct.testWhich("importedCap", index_1.Struct.getUint16(4, this), 0, this); + return index_1.Struct.getUint32(0, this); + } + isImportedCap() { return index_1.Struct.getUint16(4, this) === 0; } + setImportedCap(value) { + index_1.Struct.setUint16(4, 0, this); + index_1.Struct.setUint32(0, value, this); + } + adoptPromisedAnswer(value) { + index_1.Struct.setUint16(4, 1, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownPromisedAnswer() { return index_1.Struct.disown(this.getPromisedAnswer()); } + getPromisedAnswer() { + index_1.Struct.testWhich("promisedAnswer", index_1.Struct.getUint16(4, this), 1, this); + return index_1.Struct.getStruct(0, PromisedAnswer, this); + } + hasPromisedAnswer() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initPromisedAnswer() { + index_1.Struct.setUint16(4, 1, this); + return index_1.Struct.initStructAt(0, PromisedAnswer, this); + } + isPromisedAnswer() { return index_1.Struct.getUint16(4, this) === 1; } + setPromisedAnswer(value) { + index_1.Struct.setUint16(4, 1, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + toString() { return "MessageTarget_" + super.toString(); } + which() { return index_1.Struct.getUint16(4, this); } +} +exports.MessageTarget = MessageTarget; +MessageTarget.IMPORTED_CAP = MessageTarget_Which.IMPORTED_CAP; +MessageTarget.PROMISED_ANSWER = MessageTarget_Which.PROMISED_ANSWER; +MessageTarget._capnp = { displayName: "MessageTarget", id: "95bc14545813fbc1", size: new index_1.ObjectSize(8, 1) }; +class Payload extends index_1.Struct { + adoptContent(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownContent() { return index_1.Struct.disown(this.getContent()); } + getContent() { return index_1.Struct.getPointer(0, this); } + hasContent() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + setContent(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + adoptCapTable(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownCapTable() { return index_1.Struct.disown(this.getCapTable()); } + getCapTable() { return index_1.Struct.getList(1, Payload._CapTable, this); } + hasCapTable() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initCapTable(length) { return index_1.Struct.initList(1, Payload._CapTable, length, this); } + setCapTable(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + toString() { return "Payload_" + super.toString(); } +} +exports.Payload = Payload; +Payload._capnp = { displayName: "Payload", id: "9a0e61223d96743b", size: new index_1.ObjectSize(0, 2) }; +var CapDescriptor_Which; +(function (CapDescriptor_Which) { + CapDescriptor_Which[CapDescriptor_Which["NONE"] = 0] = "NONE"; + CapDescriptor_Which[CapDescriptor_Which["SENDER_HOSTED"] = 1] = "SENDER_HOSTED"; + CapDescriptor_Which[CapDescriptor_Which["SENDER_PROMISE"] = 2] = "SENDER_PROMISE"; + CapDescriptor_Which[CapDescriptor_Which["RECEIVER_HOSTED"] = 3] = "RECEIVER_HOSTED"; + CapDescriptor_Which[CapDescriptor_Which["RECEIVER_ANSWER"] = 4] = "RECEIVER_ANSWER"; + CapDescriptor_Which[CapDescriptor_Which["THIRD_PARTY_HOSTED"] = 5] = "THIRD_PARTY_HOSTED"; +})(CapDescriptor_Which = exports.CapDescriptor_Which || (exports.CapDescriptor_Which = {})); +class CapDescriptor extends index_1.Struct { + isNone() { return index_1.Struct.getUint16(0, this) === 0; } + setNone() { index_1.Struct.setUint16(0, 0, this); } + getSenderHosted() { + index_1.Struct.testWhich("senderHosted", index_1.Struct.getUint16(0, this), 1, this); + return index_1.Struct.getUint32(4, this); + } + isSenderHosted() { return index_1.Struct.getUint16(0, this) === 1; } + setSenderHosted(value) { + index_1.Struct.setUint16(0, 1, this); + index_1.Struct.setUint32(4, value, this); + } + getSenderPromise() { + index_1.Struct.testWhich("senderPromise", index_1.Struct.getUint16(0, this), 2, this); + return index_1.Struct.getUint32(4, this); + } + isSenderPromise() { return index_1.Struct.getUint16(0, this) === 2; } + setSenderPromise(value) { + index_1.Struct.setUint16(0, 2, this); + index_1.Struct.setUint32(4, value, this); + } + getReceiverHosted() { + index_1.Struct.testWhich("receiverHosted", index_1.Struct.getUint16(0, this), 3, this); + return index_1.Struct.getUint32(4, this); + } + isReceiverHosted() { return index_1.Struct.getUint16(0, this) === 3; } + setReceiverHosted(value) { + index_1.Struct.setUint16(0, 3, this); + index_1.Struct.setUint32(4, value, this); + } + adoptReceiverAnswer(value) { + index_1.Struct.setUint16(0, 4, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownReceiverAnswer() { return index_1.Struct.disown(this.getReceiverAnswer()); } + getReceiverAnswer() { + index_1.Struct.testWhich("receiverAnswer", index_1.Struct.getUint16(0, this), 4, this); + return index_1.Struct.getStruct(0, PromisedAnswer, this); + } + hasReceiverAnswer() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initReceiverAnswer() { + index_1.Struct.setUint16(0, 4, this); + return index_1.Struct.initStructAt(0, PromisedAnswer, this); + } + isReceiverAnswer() { return index_1.Struct.getUint16(0, this) === 4; } + setReceiverAnswer(value) { + index_1.Struct.setUint16(0, 4, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptThirdPartyHosted(value) { + index_1.Struct.setUint16(0, 5, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownThirdPartyHosted() { return index_1.Struct.disown(this.getThirdPartyHosted()); } + getThirdPartyHosted() { + index_1.Struct.testWhich("thirdPartyHosted", index_1.Struct.getUint16(0, this), 5, this); + return index_1.Struct.getStruct(0, ThirdPartyCapDescriptor, this); + } + hasThirdPartyHosted() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initThirdPartyHosted() { + index_1.Struct.setUint16(0, 5, this); + return index_1.Struct.initStructAt(0, ThirdPartyCapDescriptor, this); + } + isThirdPartyHosted() { return index_1.Struct.getUint16(0, this) === 5; } + setThirdPartyHosted(value) { + index_1.Struct.setUint16(0, 5, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + toString() { return "CapDescriptor_" + super.toString(); } + which() { return index_1.Struct.getUint16(0, this); } +} +exports.CapDescriptor = CapDescriptor; +CapDescriptor.NONE = CapDescriptor_Which.NONE; +CapDescriptor.SENDER_HOSTED = CapDescriptor_Which.SENDER_HOSTED; +CapDescriptor.SENDER_PROMISE = CapDescriptor_Which.SENDER_PROMISE; +CapDescriptor.RECEIVER_HOSTED = CapDescriptor_Which.RECEIVER_HOSTED; +CapDescriptor.RECEIVER_ANSWER = CapDescriptor_Which.RECEIVER_ANSWER; +CapDescriptor.THIRD_PARTY_HOSTED = CapDescriptor_Which.THIRD_PARTY_HOSTED; +CapDescriptor._capnp = { displayName: "CapDescriptor", id: "8523ddc40b86b8b0", size: new index_1.ObjectSize(8, 1) }; +var PromisedAnswer_Op_Which; +(function (PromisedAnswer_Op_Which) { + PromisedAnswer_Op_Which[PromisedAnswer_Op_Which["NOOP"] = 0] = "NOOP"; + PromisedAnswer_Op_Which[PromisedAnswer_Op_Which["GET_POINTER_FIELD"] = 1] = "GET_POINTER_FIELD"; +})(PromisedAnswer_Op_Which = exports.PromisedAnswer_Op_Which || (exports.PromisedAnswer_Op_Which = {})); +class PromisedAnswer_Op extends index_1.Struct { + isNoop() { return index_1.Struct.getUint16(0, this) === 0; } + setNoop() { index_1.Struct.setUint16(0, 0, this); } + getGetPointerField() { + index_1.Struct.testWhich("getPointerField", index_1.Struct.getUint16(0, this), 1, this); + return index_1.Struct.getUint16(2, this); + } + isGetPointerField() { return index_1.Struct.getUint16(0, this) === 1; } + setGetPointerField(value) { + index_1.Struct.setUint16(0, 1, this); + index_1.Struct.setUint16(2, value, this); + } + toString() { return "PromisedAnswer_Op_" + super.toString(); } + which() { return index_1.Struct.getUint16(0, this); } +} +exports.PromisedAnswer_Op = PromisedAnswer_Op; +PromisedAnswer_Op.NOOP = PromisedAnswer_Op_Which.NOOP; +PromisedAnswer_Op.GET_POINTER_FIELD = PromisedAnswer_Op_Which.GET_POINTER_FIELD; +PromisedAnswer_Op._capnp = { displayName: "Op", id: "f316944415569081", size: new index_1.ObjectSize(8, 0) }; +class PromisedAnswer extends index_1.Struct { + getQuestionId() { return index_1.Struct.getUint32(0, this); } + setQuestionId(value) { index_1.Struct.setUint32(0, value, this); } + adoptTransform(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownTransform() { return index_1.Struct.disown(this.getTransform()); } + getTransform() { return index_1.Struct.getList(0, PromisedAnswer._Transform, this); } + hasTransform() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initTransform(length) { return index_1.Struct.initList(0, PromisedAnswer._Transform, length, this); } + setTransform(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "PromisedAnswer_" + super.toString(); } +} +exports.PromisedAnswer = PromisedAnswer; +PromisedAnswer.Op = PromisedAnswer_Op; +PromisedAnswer._capnp = { displayName: "PromisedAnswer", id: "d800b1d6cd6f1ca0", size: new index_1.ObjectSize(8, 1) }; +class ThirdPartyCapDescriptor extends index_1.Struct { + adoptId(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownId() { return index_1.Struct.disown(this.getId()); } + getId() { return index_1.Struct.getPointer(0, this); } + hasId() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + setId(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + getVineId() { return index_1.Struct.getUint32(0, this); } + setVineId(value) { index_1.Struct.setUint32(0, value, this); } + toString() { return "ThirdPartyCapDescriptor_" + super.toString(); } +} +exports.ThirdPartyCapDescriptor = ThirdPartyCapDescriptor; +ThirdPartyCapDescriptor._capnp = { displayName: "ThirdPartyCapDescriptor", id: "d37007fde1f0027d", size: new index_1.ObjectSize(8, 1) }; +var Exception_Type; +(function (Exception_Type) { + Exception_Type[Exception_Type["FAILED"] = 0] = "FAILED"; + Exception_Type[Exception_Type["OVERLOADED"] = 1] = "OVERLOADED"; + Exception_Type[Exception_Type["DISCONNECTED"] = 2] = "DISCONNECTED"; + Exception_Type[Exception_Type["UNIMPLEMENTED"] = 3] = "UNIMPLEMENTED"; +})(Exception_Type = exports.Exception_Type || (exports.Exception_Type = {})); +class Exception extends index_1.Struct { + getReason() { return index_1.Struct.getText(0, this); } + setReason(value) { index_1.Struct.setText(0, value, this); } + getType() { return index_1.Struct.getUint16(4, this); } + setType(value) { index_1.Struct.setUint16(4, value, this); } + getObsoleteIsCallersFault() { return index_1.Struct.getBit(0, this); } + setObsoleteIsCallersFault(value) { index_1.Struct.setBit(0, value, this); } + getObsoleteDurability() { return index_1.Struct.getUint16(2, this); } + setObsoleteDurability(value) { index_1.Struct.setUint16(2, value, this); } + toString() { return "Exception_" + super.toString(); } +} +exports.Exception = Exception; +Exception.Type = Exception_Type; +Exception._capnp = { displayName: "Exception", id: "d625b7063acf691a", size: new index_1.ObjectSize(8, 1) }; +Payload._CapTable = capnp.CompositeList(CapDescriptor); +PromisedAnswer._Transform = capnp.CompositeList(PromisedAnswer_Op); +//# sourceMappingURL=rpc.capnp.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/rpc.capnp.js.map b/node_modules/capnp-ts/src/std/rpc.capnp.js.map new file mode 100644 index 0000000000000000000000000000000000000000..63df0011f23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a,IAAU,cAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7E,QAAQ,KAAa,OAAO,YAAY,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;;AAXlE,8BAYC;AAXmB,cAAI,GAAG,cAAc,CAAC;AACtB,gBAAM,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,kBAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAWvG,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;AACvD,cAAc,CAAC,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/rpc.capnp.ts b/node_modules/capnp-ts/src/std/rpc.capnp.ts new file mode 100644 index 0000000000000000000000000000000000000000..e0b9ca1fda27e4254f34034e678c02330df7d13d --- /dev/null +++ b/node_modules/capnp-ts/src/std/rpc.capnp.ts @@ -0,0 +1,838 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ + +import * as capnp from "../index"; +import { ObjectSize as __O, Struct as __S } from "../index"; +export const _capnpFileId = "b312981b2552a250"; +export enum Message_Which { + UNIMPLEMENTED = 0, + ABORT = 1, + BOOTSTRAP = 8, + CALL = 2, + RETURN = 3, + FINISH = 4, + RESOLVE = 5, + RELEASE = 6, + DISEMBARGO = 13, + OBSOLETE_SAVE = 7, + OBSOLETE_DELETE = 9, + PROVIDE = 10, + ACCEPT = 11, + JOIN = 12 +} +export class Message extends __S { + static readonly UNIMPLEMENTED = Message_Which.UNIMPLEMENTED; + static readonly ABORT = Message_Which.ABORT; + static readonly BOOTSTRAP = Message_Which.BOOTSTRAP; + static readonly CALL = Message_Which.CALL; + static readonly RETURN = Message_Which.RETURN; + static readonly FINISH = Message_Which.FINISH; + static readonly RESOLVE = Message_Which.RESOLVE; + static readonly RELEASE = Message_Which.RELEASE; + static readonly DISEMBARGO = Message_Which.DISEMBARGO; + static readonly OBSOLETE_SAVE = Message_Which.OBSOLETE_SAVE; + static readonly OBSOLETE_DELETE = Message_Which.OBSOLETE_DELETE; + static readonly PROVIDE = Message_Which.PROVIDE; + static readonly ACCEPT = Message_Which.ACCEPT; + static readonly JOIN = Message_Which.JOIN; + static readonly _capnp = { displayName: "Message", id: "91b79f1f808db032", size: new __O(8, 1) }; + adoptUnimplemented(value: capnp.Orphan): void { + __S.setUint16(0, 0, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownUnimplemented(): capnp.Orphan { return __S.disown(this.getUnimplemented()); } + getUnimplemented(): Message { + __S.testWhich("unimplemented", __S.getUint16(0, this), 0, this); + return __S.getStruct(0, Message, this); + } + hasUnimplemented(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initUnimplemented(): Message { + __S.setUint16(0, 0, this); + return __S.initStructAt(0, Message, this); + } + isUnimplemented(): boolean { return __S.getUint16(0, this) === 0; } + setUnimplemented(value: Message): void { + __S.setUint16(0, 0, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptAbort(value: capnp.Orphan): void { + __S.setUint16(0, 1, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownAbort(): capnp.Orphan { return __S.disown(this.getAbort()); } + getAbort(): Exception { + __S.testWhich("abort", __S.getUint16(0, this), 1, this); + return __S.getStruct(0, Exception, this); + } + hasAbort(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initAbort(): Exception { + __S.setUint16(0, 1, this); + return __S.initStructAt(0, Exception, this); + } + isAbort(): boolean { return __S.getUint16(0, this) === 1; } + setAbort(value: Exception): void { + __S.setUint16(0, 1, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptBootstrap(value: capnp.Orphan): void { + __S.setUint16(0, 8, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownBootstrap(): capnp.Orphan { return __S.disown(this.getBootstrap()); } + getBootstrap(): Bootstrap { + __S.testWhich("bootstrap", __S.getUint16(0, this), 8, this); + return __S.getStruct(0, Bootstrap, this); + } + hasBootstrap(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initBootstrap(): Bootstrap { + __S.setUint16(0, 8, this); + return __S.initStructAt(0, Bootstrap, this); + } + isBootstrap(): boolean { return __S.getUint16(0, this) === 8; } + setBootstrap(value: Bootstrap): void { + __S.setUint16(0, 8, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptCall(value: capnp.Orphan): void { + __S.setUint16(0, 2, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownCall(): capnp.Orphan { return __S.disown(this.getCall()); } + getCall(): Call { + __S.testWhich("call", __S.getUint16(0, this), 2, this); + return __S.getStruct(0, Call, this); + } + hasCall(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initCall(): Call { + __S.setUint16(0, 2, this); + return __S.initStructAt(0, Call, this); + } + isCall(): boolean { return __S.getUint16(0, this) === 2; } + setCall(value: Call): void { + __S.setUint16(0, 2, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptReturn(value: capnp.Orphan): void { + __S.setUint16(0, 3, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownReturn(): capnp.Orphan { return __S.disown(this.getReturn()); } + getReturn(): Return { + __S.testWhich("return", __S.getUint16(0, this), 3, this); + return __S.getStruct(0, Return, this); + } + hasReturn(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initReturn(): Return { + __S.setUint16(0, 3, this); + return __S.initStructAt(0, Return, this); + } + isReturn(): boolean { return __S.getUint16(0, this) === 3; } + setReturn(value: Return): void { + __S.setUint16(0, 3, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptFinish(value: capnp.Orphan): void { + __S.setUint16(0, 4, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownFinish(): capnp.Orphan { return __S.disown(this.getFinish()); } + getFinish(): Finish { + __S.testWhich("finish", __S.getUint16(0, this), 4, this); + return __S.getStruct(0, Finish, this); + } + hasFinish(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initFinish(): Finish { + __S.setUint16(0, 4, this); + return __S.initStructAt(0, Finish, this); + } + isFinish(): boolean { return __S.getUint16(0, this) === 4; } + setFinish(value: Finish): void { + __S.setUint16(0, 4, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptResolve(value: capnp.Orphan): void { + __S.setUint16(0, 5, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownResolve(): capnp.Orphan { return __S.disown(this.getResolve()); } + getResolve(): Resolve { + __S.testWhich("resolve", __S.getUint16(0, this), 5, this); + return __S.getStruct(0, Resolve, this); + } + hasResolve(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initResolve(): Resolve { + __S.setUint16(0, 5, this); + return __S.initStructAt(0, Resolve, this); + } + isResolve(): boolean { return __S.getUint16(0, this) === 5; } + setResolve(value: Resolve): void { + __S.setUint16(0, 5, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptRelease(value: capnp.Orphan): void { + __S.setUint16(0, 6, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownRelease(): capnp.Orphan { return __S.disown(this.getRelease()); } + getRelease(): Release { + __S.testWhich("release", __S.getUint16(0, this), 6, this); + return __S.getStruct(0, Release, this); + } + hasRelease(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initRelease(): Release { + __S.setUint16(0, 6, this); + return __S.initStructAt(0, Release, this); + } + isRelease(): boolean { return __S.getUint16(0, this) === 6; } + setRelease(value: Release): void { + __S.setUint16(0, 6, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptDisembargo(value: capnp.Orphan): void { + __S.setUint16(0, 13, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownDisembargo(): capnp.Orphan { return __S.disown(this.getDisembargo()); } + getDisembargo(): Disembargo { + __S.testWhich("disembargo", __S.getUint16(0, this), 13, this); + return __S.getStruct(0, Disembargo, this); + } + hasDisembargo(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initDisembargo(): Disembargo { + __S.setUint16(0, 13, this); + return __S.initStructAt(0, Disembargo, this); + } + isDisembargo(): boolean { return __S.getUint16(0, this) === 13; } + setDisembargo(value: Disembargo): void { + __S.setUint16(0, 13, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptObsoleteSave(value: capnp.Orphan): void { + __S.setUint16(0, 7, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownObsoleteSave(): capnp.Orphan { return __S.disown(this.getObsoleteSave()); } + getObsoleteSave(): capnp.Pointer { + __S.testWhich("obsoleteSave", __S.getUint16(0, this), 7, this); + return __S.getPointer(0, this); + } + hasObsoleteSave(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + isObsoleteSave(): boolean { return __S.getUint16(0, this) === 7; } + setObsoleteSave(value: capnp.Pointer): void { + __S.setUint16(0, 7, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptObsoleteDelete(value: capnp.Orphan): void { + __S.setUint16(0, 9, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownObsoleteDelete(): capnp.Orphan { return __S.disown(this.getObsoleteDelete()); } + getObsoleteDelete(): capnp.Pointer { + __S.testWhich("obsoleteDelete", __S.getUint16(0, this), 9, this); + return __S.getPointer(0, this); + } + hasObsoleteDelete(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + isObsoleteDelete(): boolean { return __S.getUint16(0, this) === 9; } + setObsoleteDelete(value: capnp.Pointer): void { + __S.setUint16(0, 9, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptProvide(value: capnp.Orphan): void { + __S.setUint16(0, 10, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownProvide(): capnp.Orphan { return __S.disown(this.getProvide()); } + getProvide(): Provide { + __S.testWhich("provide", __S.getUint16(0, this), 10, this); + return __S.getStruct(0, Provide, this); + } + hasProvide(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initProvide(): Provide { + __S.setUint16(0, 10, this); + return __S.initStructAt(0, Provide, this); + } + isProvide(): boolean { return __S.getUint16(0, this) === 10; } + setProvide(value: Provide): void { + __S.setUint16(0, 10, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptAccept(value: capnp.Orphan): void { + __S.setUint16(0, 11, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownAccept(): capnp.Orphan { return __S.disown(this.getAccept()); } + getAccept(): Accept { + __S.testWhich("accept", __S.getUint16(0, this), 11, this); + return __S.getStruct(0, Accept, this); + } + hasAccept(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initAccept(): Accept { + __S.setUint16(0, 11, this); + return __S.initStructAt(0, Accept, this); + } + isAccept(): boolean { return __S.getUint16(0, this) === 11; } + setAccept(value: Accept): void { + __S.setUint16(0, 11, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptJoin(value: capnp.Orphan): void { + __S.setUint16(0, 12, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownJoin(): capnp.Orphan { return __S.disown(this.getJoin()); } + getJoin(): Join { + __S.testWhich("join", __S.getUint16(0, this), 12, this); + return __S.getStruct(0, Join, this); + } + hasJoin(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initJoin(): Join { + __S.setUint16(0, 12, this); + return __S.initStructAt(0, Join, this); + } + isJoin(): boolean { return __S.getUint16(0, this) === 12; } + setJoin(value: Join): void { + __S.setUint16(0, 12, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + toString(): string { return "Message_" + super.toString(); } + which(): Message_Which { return __S.getUint16(0, this); } +} +export class Bootstrap extends __S { + static readonly _capnp = { displayName: "Bootstrap", id: "e94ccf8031176ec4", size: new __O(8, 1) }; + getQuestionId(): number { return __S.getUint32(0, this); } + setQuestionId(value: number): void { __S.setUint32(0, value, this); } + adoptDeprecatedObjectId(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownDeprecatedObjectId(): capnp.Orphan { return __S.disown(this.getDeprecatedObjectId()); } + getDeprecatedObjectId(): capnp.Pointer { return __S.getPointer(0, this); } + hasDeprecatedObjectId(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + setDeprecatedObjectId(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Bootstrap_" + super.toString(); } +} +export enum Call_SendResultsTo_Which { + CALLER = 0, + YOURSELF = 1, + THIRD_PARTY = 2 +} +export class Call_SendResultsTo extends __S { + static readonly CALLER = Call_SendResultsTo_Which.CALLER; + static readonly YOURSELF = Call_SendResultsTo_Which.YOURSELF; + static readonly THIRD_PARTY = Call_SendResultsTo_Which.THIRD_PARTY; + static readonly _capnp = { displayName: "sendResultsTo", id: "dae8b0f61aab5f99", size: new __O(24, 3) }; + isCaller(): boolean { return __S.getUint16(6, this) === 0; } + setCaller(): void { __S.setUint16(6, 0, this); } + isYourself(): boolean { return __S.getUint16(6, this) === 1; } + setYourself(): void { __S.setUint16(6, 1, this); } + adoptThirdParty(value: capnp.Orphan): void { + __S.setUint16(6, 2, this); + __S.adopt(value, __S.getPointer(2, this)); + } + disownThirdParty(): capnp.Orphan { return __S.disown(this.getThirdParty()); } + getThirdParty(): capnp.Pointer { + __S.testWhich("thirdParty", __S.getUint16(6, this), 2, this); + return __S.getPointer(2, this); + } + hasThirdParty(): boolean { return !__S.isNull(__S.getPointer(2, this)); } + isThirdParty(): boolean { return __S.getUint16(6, this) === 2; } + setThirdParty(value: capnp.Pointer): void { + __S.setUint16(6, 2, this); + __S.copyFrom(value, __S.getPointer(2, this)); + } + toString(): string { return "Call_SendResultsTo_" + super.toString(); } + which(): Call_SendResultsTo_Which { return __S.getUint16(6, this); } +} +export class Call extends __S { + static readonly _capnp = { displayName: "Call", id: "836a53ce789d4cd4", size: new __O(24, 3), defaultAllowThirdPartyTailCall: capnp.getBitMask(false, 0) }; + getQuestionId(): number { return __S.getUint32(0, this); } + setQuestionId(value: number): void { __S.setUint32(0, value, this); } + adoptTarget(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownTarget(): capnp.Orphan { return __S.disown(this.getTarget()); } + getTarget(): MessageTarget { return __S.getStruct(0, MessageTarget, this); } + hasTarget(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initTarget(): MessageTarget { return __S.initStructAt(0, MessageTarget, this); } + setTarget(value: MessageTarget): void { __S.copyFrom(value, __S.getPointer(0, this)); } + getInterfaceId(): capnp.Uint64 { return __S.getUint64(8, this); } + setInterfaceId(value: capnp.Uint64): void { __S.setUint64(8, value, this); } + getMethodId(): number { return __S.getUint16(4, this); } + setMethodId(value: number): void { __S.setUint16(4, value, this); } + getAllowThirdPartyTailCall(): boolean { return __S.getBit(128, this, Call._capnp.defaultAllowThirdPartyTailCall); } + setAllowThirdPartyTailCall(value: boolean): void { __S.setBit(128, value, this); } + adoptParams(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(1, this)); } + disownParams(): capnp.Orphan { return __S.disown(this.getParams()); } + getParams(): Payload { return __S.getStruct(1, Payload, this); } + hasParams(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initParams(): Payload { return __S.initStructAt(1, Payload, this); } + setParams(value: Payload): void { __S.copyFrom(value, __S.getPointer(1, this)); } + getSendResultsTo(): Call_SendResultsTo { return __S.getAs(Call_SendResultsTo, this); } + initSendResultsTo(): Call_SendResultsTo { return __S.getAs(Call_SendResultsTo, this); } + toString(): string { return "Call_" + super.toString(); } +} +export enum Return_Which { + RESULTS = 0, + EXCEPTION = 1, + CANCELED = 2, + RESULTS_SENT_ELSEWHERE = 3, + TAKE_FROM_OTHER_QUESTION = 4, + ACCEPT_FROM_THIRD_PARTY = 5 +} +export class Return extends __S { + static readonly RESULTS = Return_Which.RESULTS; + static readonly EXCEPTION = Return_Which.EXCEPTION; + static readonly CANCELED = Return_Which.CANCELED; + static readonly RESULTS_SENT_ELSEWHERE = Return_Which.RESULTS_SENT_ELSEWHERE; + static readonly TAKE_FROM_OTHER_QUESTION = Return_Which.TAKE_FROM_OTHER_QUESTION; + static readonly ACCEPT_FROM_THIRD_PARTY = Return_Which.ACCEPT_FROM_THIRD_PARTY; + static readonly _capnp = { displayName: "Return", id: "9e19b28d3db3573a", size: new __O(16, 1), defaultReleaseParamCaps: capnp.getBitMask(true, 0) }; + getAnswerId(): number { return __S.getUint32(0, this); } + setAnswerId(value: number): void { __S.setUint32(0, value, this); } + getReleaseParamCaps(): boolean { return __S.getBit(32, this, Return._capnp.defaultReleaseParamCaps); } + setReleaseParamCaps(value: boolean): void { __S.setBit(32, value, this); } + adoptResults(value: capnp.Orphan): void { + __S.setUint16(6, 0, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownResults(): capnp.Orphan { return __S.disown(this.getResults()); } + getResults(): Payload { + __S.testWhich("results", __S.getUint16(6, this), 0, this); + return __S.getStruct(0, Payload, this); + } + hasResults(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initResults(): Payload { + __S.setUint16(6, 0, this); + return __S.initStructAt(0, Payload, this); + } + isResults(): boolean { return __S.getUint16(6, this) === 0; } + setResults(value: Payload): void { + __S.setUint16(6, 0, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptException(value: capnp.Orphan): void { + __S.setUint16(6, 1, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownException(): capnp.Orphan { return __S.disown(this.getException()); } + getException(): Exception { + __S.testWhich("exception", __S.getUint16(6, this), 1, this); + return __S.getStruct(0, Exception, this); + } + hasException(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initException(): Exception { + __S.setUint16(6, 1, this); + return __S.initStructAt(0, Exception, this); + } + isException(): boolean { return __S.getUint16(6, this) === 1; } + setException(value: Exception): void { + __S.setUint16(6, 1, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + isCanceled(): boolean { return __S.getUint16(6, this) === 2; } + setCanceled(): void { __S.setUint16(6, 2, this); } + isResultsSentElsewhere(): boolean { return __S.getUint16(6, this) === 3; } + setResultsSentElsewhere(): void { __S.setUint16(6, 3, this); } + getTakeFromOtherQuestion(): number { + __S.testWhich("takeFromOtherQuestion", __S.getUint16(6, this), 4, this); + return __S.getUint32(8, this); + } + isTakeFromOtherQuestion(): boolean { return __S.getUint16(6, this) === 4; } + setTakeFromOtherQuestion(value: number): void { + __S.setUint16(6, 4, this); + __S.setUint32(8, value, this); + } + adoptAcceptFromThirdParty(value: capnp.Orphan): void { + __S.setUint16(6, 5, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownAcceptFromThirdParty(): capnp.Orphan { return __S.disown(this.getAcceptFromThirdParty()); } + getAcceptFromThirdParty(): capnp.Pointer { + __S.testWhich("acceptFromThirdParty", __S.getUint16(6, this), 5, this); + return __S.getPointer(0, this); + } + hasAcceptFromThirdParty(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + isAcceptFromThirdParty(): boolean { return __S.getUint16(6, this) === 5; } + setAcceptFromThirdParty(value: capnp.Pointer): void { + __S.setUint16(6, 5, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + toString(): string { return "Return_" + super.toString(); } + which(): Return_Which { return __S.getUint16(6, this); } +} +export class Finish extends __S { + static readonly _capnp = { displayName: "Finish", id: "d37d2eb2c2f80e63", size: new __O(8, 0), defaultReleaseResultCaps: capnp.getBitMask(true, 0) }; + getQuestionId(): number { return __S.getUint32(0, this); } + setQuestionId(value: number): void { __S.setUint32(0, value, this); } + getReleaseResultCaps(): boolean { return __S.getBit(32, this, Finish._capnp.defaultReleaseResultCaps); } + setReleaseResultCaps(value: boolean): void { __S.setBit(32, value, this); } + toString(): string { return "Finish_" + super.toString(); } +} +export enum Resolve_Which { + CAP = 0, + EXCEPTION = 1 +} +export class Resolve extends __S { + static readonly CAP = Resolve_Which.CAP; + static readonly EXCEPTION = Resolve_Which.EXCEPTION; + static readonly _capnp = { displayName: "Resolve", id: "bbc29655fa89086e", size: new __O(8, 1) }; + getPromiseId(): number { return __S.getUint32(0, this); } + setPromiseId(value: number): void { __S.setUint32(0, value, this); } + adoptCap(value: capnp.Orphan): void { + __S.setUint16(4, 0, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownCap(): capnp.Orphan { return __S.disown(this.getCap()); } + getCap(): CapDescriptor { + __S.testWhich("cap", __S.getUint16(4, this), 0, this); + return __S.getStruct(0, CapDescriptor, this); + } + hasCap(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initCap(): CapDescriptor { + __S.setUint16(4, 0, this); + return __S.initStructAt(0, CapDescriptor, this); + } + isCap(): boolean { return __S.getUint16(4, this) === 0; } + setCap(value: CapDescriptor): void { + __S.setUint16(4, 0, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptException(value: capnp.Orphan): void { + __S.setUint16(4, 1, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownException(): capnp.Orphan { return __S.disown(this.getException()); } + getException(): Exception { + __S.testWhich("exception", __S.getUint16(4, this), 1, this); + return __S.getStruct(0, Exception, this); + } + hasException(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initException(): Exception { + __S.setUint16(4, 1, this); + return __S.initStructAt(0, Exception, this); + } + isException(): boolean { return __S.getUint16(4, this) === 1; } + setException(value: Exception): void { + __S.setUint16(4, 1, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + toString(): string { return "Resolve_" + super.toString(); } + which(): Resolve_Which { return __S.getUint16(4, this); } +} +export class Release extends __S { + static readonly _capnp = { displayName: "Release", id: "ad1a6c0d7dd07497", size: new __O(8, 0) }; + getId(): number { return __S.getUint32(0, this); } + setId(value: number): void { __S.setUint32(0, value, this); } + getReferenceCount(): number { return __S.getUint32(4, this); } + setReferenceCount(value: number): void { __S.setUint32(4, value, this); } + toString(): string { return "Release_" + super.toString(); } +} +export enum Disembargo_Context_Which { + SENDER_LOOPBACK = 0, + RECEIVER_LOOPBACK = 1, + ACCEPT = 2, + PROVIDE = 3 +} +export class Disembargo_Context extends __S { + static readonly SENDER_LOOPBACK = Disembargo_Context_Which.SENDER_LOOPBACK; + static readonly RECEIVER_LOOPBACK = Disembargo_Context_Which.RECEIVER_LOOPBACK; + static readonly ACCEPT = Disembargo_Context_Which.ACCEPT; + static readonly PROVIDE = Disembargo_Context_Which.PROVIDE; + static readonly _capnp = { displayName: "context", id: "d562b4df655bdd4d", size: new __O(8, 1) }; + getSenderLoopback(): number { + __S.testWhich("senderLoopback", __S.getUint16(4, this), 0, this); + return __S.getUint32(0, this); + } + isSenderLoopback(): boolean { return __S.getUint16(4, this) === 0; } + setSenderLoopback(value: number): void { + __S.setUint16(4, 0, this); + __S.setUint32(0, value, this); + } + getReceiverLoopback(): number { + __S.testWhich("receiverLoopback", __S.getUint16(4, this), 1, this); + return __S.getUint32(0, this); + } + isReceiverLoopback(): boolean { return __S.getUint16(4, this) === 1; } + setReceiverLoopback(value: number): void { + __S.setUint16(4, 1, this); + __S.setUint32(0, value, this); + } + isAccept(): boolean { return __S.getUint16(4, this) === 2; } + setAccept(): void { __S.setUint16(4, 2, this); } + getProvide(): number { + __S.testWhich("provide", __S.getUint16(4, this), 3, this); + return __S.getUint32(0, this); + } + isProvide(): boolean { return __S.getUint16(4, this) === 3; } + setProvide(value: number): void { + __S.setUint16(4, 3, this); + __S.setUint32(0, value, this); + } + toString(): string { return "Disembargo_Context_" + super.toString(); } + which(): Disembargo_Context_Which { return __S.getUint16(4, this); } +} +export class Disembargo extends __S { + static readonly _capnp = { displayName: "Disembargo", id: "f964368b0fbd3711", size: new __O(8, 1) }; + adoptTarget(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownTarget(): capnp.Orphan { return __S.disown(this.getTarget()); } + getTarget(): MessageTarget { return __S.getStruct(0, MessageTarget, this); } + hasTarget(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initTarget(): MessageTarget { return __S.initStructAt(0, MessageTarget, this); } + setTarget(value: MessageTarget): void { __S.copyFrom(value, __S.getPointer(0, this)); } + getContext(): Disembargo_Context { return __S.getAs(Disembargo_Context, this); } + initContext(): Disembargo_Context { return __S.getAs(Disembargo_Context, this); } + toString(): string { return "Disembargo_" + super.toString(); } +} +export class Provide extends __S { + static readonly _capnp = { displayName: "Provide", id: "9c6a046bfbc1ac5a", size: new __O(8, 2) }; + getQuestionId(): number { return __S.getUint32(0, this); } + setQuestionId(value: number): void { __S.setUint32(0, value, this); } + adoptTarget(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownTarget(): capnp.Orphan { return __S.disown(this.getTarget()); } + getTarget(): MessageTarget { return __S.getStruct(0, MessageTarget, this); } + hasTarget(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initTarget(): MessageTarget { return __S.initStructAt(0, MessageTarget, this); } + setTarget(value: MessageTarget): void { __S.copyFrom(value, __S.getPointer(0, this)); } + adoptRecipient(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(1, this)); } + disownRecipient(): capnp.Orphan { return __S.disown(this.getRecipient()); } + getRecipient(): capnp.Pointer { return __S.getPointer(1, this); } + hasRecipient(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + setRecipient(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(1, this)); } + toString(): string { return "Provide_" + super.toString(); } +} +export class Accept extends __S { + static readonly _capnp = { displayName: "Accept", id: "d4c9b56290554016", size: new __O(8, 1) }; + getQuestionId(): number { return __S.getUint32(0, this); } + setQuestionId(value: number): void { __S.setUint32(0, value, this); } + adoptProvision(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownProvision(): capnp.Orphan { return __S.disown(this.getProvision()); } + getProvision(): capnp.Pointer { return __S.getPointer(0, this); } + hasProvision(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + setProvision(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(0, this)); } + getEmbargo(): boolean { return __S.getBit(32, this); } + setEmbargo(value: boolean): void { __S.setBit(32, value, this); } + toString(): string { return "Accept_" + super.toString(); } +} +export class Join extends __S { + static readonly _capnp = { displayName: "Join", id: "fbe1980490e001af", size: new __O(8, 2) }; + getQuestionId(): number { return __S.getUint32(0, this); } + setQuestionId(value: number): void { __S.setUint32(0, value, this); } + adoptTarget(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownTarget(): capnp.Orphan { return __S.disown(this.getTarget()); } + getTarget(): MessageTarget { return __S.getStruct(0, MessageTarget, this); } + hasTarget(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initTarget(): MessageTarget { return __S.initStructAt(0, MessageTarget, this); } + setTarget(value: MessageTarget): void { __S.copyFrom(value, __S.getPointer(0, this)); } + adoptKeyPart(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(1, this)); } + disownKeyPart(): capnp.Orphan { return __S.disown(this.getKeyPart()); } + getKeyPart(): capnp.Pointer { return __S.getPointer(1, this); } + hasKeyPart(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + setKeyPart(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(1, this)); } + toString(): string { return "Join_" + super.toString(); } +} +export enum MessageTarget_Which { + IMPORTED_CAP = 0, + PROMISED_ANSWER = 1 +} +export class MessageTarget extends __S { + static readonly IMPORTED_CAP = MessageTarget_Which.IMPORTED_CAP; + static readonly PROMISED_ANSWER = MessageTarget_Which.PROMISED_ANSWER; + static readonly _capnp = { displayName: "MessageTarget", id: "95bc14545813fbc1", size: new __O(8, 1) }; + getImportedCap(): number { + __S.testWhich("importedCap", __S.getUint16(4, this), 0, this); + return __S.getUint32(0, this); + } + isImportedCap(): boolean { return __S.getUint16(4, this) === 0; } + setImportedCap(value: number): void { + __S.setUint16(4, 0, this); + __S.setUint32(0, value, this); + } + adoptPromisedAnswer(value: capnp.Orphan): void { + __S.setUint16(4, 1, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownPromisedAnswer(): capnp.Orphan { return __S.disown(this.getPromisedAnswer()); } + getPromisedAnswer(): PromisedAnswer { + __S.testWhich("promisedAnswer", __S.getUint16(4, this), 1, this); + return __S.getStruct(0, PromisedAnswer, this); + } + hasPromisedAnswer(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initPromisedAnswer(): PromisedAnswer { + __S.setUint16(4, 1, this); + return __S.initStructAt(0, PromisedAnswer, this); + } + isPromisedAnswer(): boolean { return __S.getUint16(4, this) === 1; } + setPromisedAnswer(value: PromisedAnswer): void { + __S.setUint16(4, 1, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + toString(): string { return "MessageTarget_" + super.toString(); } + which(): MessageTarget_Which { return __S.getUint16(4, this); } +} +export class Payload extends __S { + static readonly _capnp = { displayName: "Payload", id: "9a0e61223d96743b", size: new __O(0, 2) }; + static _CapTable: capnp.ListCtor; + adoptContent(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownContent(): capnp.Orphan { return __S.disown(this.getContent()); } + getContent(): capnp.Pointer { return __S.getPointer(0, this); } + hasContent(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + setContent(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(0, this)); } + adoptCapTable(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(1, this)); } + disownCapTable(): capnp.Orphan> { return __S.disown(this.getCapTable()); } + getCapTable(): capnp.List { return __S.getList(1, Payload._CapTable, this); } + hasCapTable(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initCapTable(length: number): capnp.List { return __S.initList(1, Payload._CapTable, length, this); } + setCapTable(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(1, this)); } + toString(): string { return "Payload_" + super.toString(); } +} +export enum CapDescriptor_Which { + NONE = 0, + SENDER_HOSTED = 1, + SENDER_PROMISE = 2, + RECEIVER_HOSTED = 3, + RECEIVER_ANSWER = 4, + THIRD_PARTY_HOSTED = 5 +} +export class CapDescriptor extends __S { + static readonly NONE = CapDescriptor_Which.NONE; + static readonly SENDER_HOSTED = CapDescriptor_Which.SENDER_HOSTED; + static readonly SENDER_PROMISE = CapDescriptor_Which.SENDER_PROMISE; + static readonly RECEIVER_HOSTED = CapDescriptor_Which.RECEIVER_HOSTED; + static readonly RECEIVER_ANSWER = CapDescriptor_Which.RECEIVER_ANSWER; + static readonly THIRD_PARTY_HOSTED = CapDescriptor_Which.THIRD_PARTY_HOSTED; + static readonly _capnp = { displayName: "CapDescriptor", id: "8523ddc40b86b8b0", size: new __O(8, 1) }; + isNone(): boolean { return __S.getUint16(0, this) === 0; } + setNone(): void { __S.setUint16(0, 0, this); } + getSenderHosted(): number { + __S.testWhich("senderHosted", __S.getUint16(0, this), 1, this); + return __S.getUint32(4, this); + } + isSenderHosted(): boolean { return __S.getUint16(0, this) === 1; } + setSenderHosted(value: number): void { + __S.setUint16(0, 1, this); + __S.setUint32(4, value, this); + } + getSenderPromise(): number { + __S.testWhich("senderPromise", __S.getUint16(0, this), 2, this); + return __S.getUint32(4, this); + } + isSenderPromise(): boolean { return __S.getUint16(0, this) === 2; } + setSenderPromise(value: number): void { + __S.setUint16(0, 2, this); + __S.setUint32(4, value, this); + } + getReceiverHosted(): number { + __S.testWhich("receiverHosted", __S.getUint16(0, this), 3, this); + return __S.getUint32(4, this); + } + isReceiverHosted(): boolean { return __S.getUint16(0, this) === 3; } + setReceiverHosted(value: number): void { + __S.setUint16(0, 3, this); + __S.setUint32(4, value, this); + } + adoptReceiverAnswer(value: capnp.Orphan): void { + __S.setUint16(0, 4, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownReceiverAnswer(): capnp.Orphan { return __S.disown(this.getReceiverAnswer()); } + getReceiverAnswer(): PromisedAnswer { + __S.testWhich("receiverAnswer", __S.getUint16(0, this), 4, this); + return __S.getStruct(0, PromisedAnswer, this); + } + hasReceiverAnswer(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initReceiverAnswer(): PromisedAnswer { + __S.setUint16(0, 4, this); + return __S.initStructAt(0, PromisedAnswer, this); + } + isReceiverAnswer(): boolean { return __S.getUint16(0, this) === 4; } + setReceiverAnswer(value: PromisedAnswer): void { + __S.setUint16(0, 4, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptThirdPartyHosted(value: capnp.Orphan): void { + __S.setUint16(0, 5, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownThirdPartyHosted(): capnp.Orphan { return __S.disown(this.getThirdPartyHosted()); } + getThirdPartyHosted(): ThirdPartyCapDescriptor { + __S.testWhich("thirdPartyHosted", __S.getUint16(0, this), 5, this); + return __S.getStruct(0, ThirdPartyCapDescriptor, this); + } + hasThirdPartyHosted(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initThirdPartyHosted(): ThirdPartyCapDescriptor { + __S.setUint16(0, 5, this); + return __S.initStructAt(0, ThirdPartyCapDescriptor, this); + } + isThirdPartyHosted(): boolean { return __S.getUint16(0, this) === 5; } + setThirdPartyHosted(value: ThirdPartyCapDescriptor): void { + __S.setUint16(0, 5, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + toString(): string { return "CapDescriptor_" + super.toString(); } + which(): CapDescriptor_Which { return __S.getUint16(0, this); } +} +export enum PromisedAnswer_Op_Which { + NOOP = 0, + GET_POINTER_FIELD = 1 +} +export class PromisedAnswer_Op extends __S { + static readonly NOOP = PromisedAnswer_Op_Which.NOOP; + static readonly GET_POINTER_FIELD = PromisedAnswer_Op_Which.GET_POINTER_FIELD; + static readonly _capnp = { displayName: "Op", id: "f316944415569081", size: new __O(8, 0) }; + isNoop(): boolean { return __S.getUint16(0, this) === 0; } + setNoop(): void { __S.setUint16(0, 0, this); } + getGetPointerField(): number { + __S.testWhich("getPointerField", __S.getUint16(0, this), 1, this); + return __S.getUint16(2, this); + } + isGetPointerField(): boolean { return __S.getUint16(0, this) === 1; } + setGetPointerField(value: number): void { + __S.setUint16(0, 1, this); + __S.setUint16(2, value, this); + } + toString(): string { return "PromisedAnswer_Op_" + super.toString(); } + which(): PromisedAnswer_Op_Which { return __S.getUint16(0, this); } +} +export class PromisedAnswer extends __S { + static readonly Op = PromisedAnswer_Op; + static readonly _capnp = { displayName: "PromisedAnswer", id: "d800b1d6cd6f1ca0", size: new __O(8, 1) }; + static _Transform: capnp.ListCtor; + getQuestionId(): number { return __S.getUint32(0, this); } + setQuestionId(value: number): void { __S.setUint32(0, value, this); } + adoptTransform(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(0, this)); } + disownTransform(): capnp.Orphan> { return __S.disown(this.getTransform()); } + getTransform(): capnp.List { return __S.getList(0, PromisedAnswer._Transform, this); } + hasTransform(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initTransform(length: number): capnp.List { return __S.initList(0, PromisedAnswer._Transform, length, this); } + setTransform(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "PromisedAnswer_" + super.toString(); } +} +export class ThirdPartyCapDescriptor extends __S { + static readonly _capnp = { displayName: "ThirdPartyCapDescriptor", id: "d37007fde1f0027d", size: new __O(8, 1) }; + adoptId(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownId(): capnp.Orphan { return __S.disown(this.getId()); } + getId(): capnp.Pointer { return __S.getPointer(0, this); } + hasId(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + setId(value: capnp.Pointer): void { __S.copyFrom(value, __S.getPointer(0, this)); } + getVineId(): number { return __S.getUint32(0, this); } + setVineId(value: number): void { __S.setUint32(0, value, this); } + toString(): string { return "ThirdPartyCapDescriptor_" + super.toString(); } +} +export enum Exception_Type { + FAILED, + OVERLOADED, + DISCONNECTED, + UNIMPLEMENTED +} +export class Exception extends __S { + static readonly Type = Exception_Type; + static readonly _capnp = { displayName: "Exception", id: "d625b7063acf691a", size: new __O(8, 1) }; + getReason(): string { return __S.getText(0, this); } + setReason(value: string): void { __S.setText(0, value, this); } + getType(): Exception_Type { return __S.getUint16(4, this); } + setType(value: Exception_Type): void { __S.setUint16(4, value, this); } + getObsoleteIsCallersFault(): boolean { return __S.getBit(0, this); } + setObsoleteIsCallersFault(value: boolean): void { __S.setBit(0, value, this); } + getObsoleteDurability(): number { return __S.getUint16(2, this); } + setObsoleteDurability(value: number): void { __S.setUint16(2, value, this); } + toString(): string { return "Exception_" + super.toString(); } +} +Payload._CapTable = capnp.CompositeList(CapDescriptor); +PromisedAnswer._Transform = capnp.CompositeList(PromisedAnswer_Op); diff --git a/node_modules/capnp-ts/src/std/schema.capnp.d.ts b/node_modules/capnp-ts/src/std/schema.capnp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b3477f6096b97fbaf86284e87f6a54dadf256fe --- /dev/null +++ b/node_modules/capnp-ts/src/std/schema.capnp.d.ts @@ -0,0 +1,929 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +import * as capnp from "../index"; +import { Struct as __S } from "../index"; +export declare const _capnpFileId = "a93fc509624c72d9"; +export declare class Node_Parameter extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getName(): string; + setName(value: string): void; + toString(): string; +} +export declare class Node_NestedNode extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getName(): string; + setName(value: string): void; + getId(): capnp.Uint64; + setId(value: capnp.Uint64): void; + toString(): string; +} +export declare class Node_Struct extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Fields: capnp.ListCtor; + getDataWordCount(): number; + setDataWordCount(value: number): void; + getPointerCount(): number; + setPointerCount(value: number): void; + getPreferredListEncoding(): ElementSize; + setPreferredListEncoding(value: ElementSize): void; + getIsGroup(): boolean; + setIsGroup(value: boolean): void; + getDiscriminantCount(): number; + setDiscriminantCount(value: number): void; + getDiscriminantOffset(): number; + setDiscriminantOffset(value: number): void; + adoptFields(value: capnp.Orphan>): void; + disownFields(): capnp.Orphan>; + getFields(): capnp.List; + hasFields(): boolean; + initFields(length: number): capnp.List; + setFields(value: capnp.List): void; + toString(): string; +} +export declare class Node_Enum extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Enumerants: capnp.ListCtor; + adoptEnumerants(value: capnp.Orphan>): void; + disownEnumerants(): capnp.Orphan>; + getEnumerants(): capnp.List; + hasEnumerants(): boolean; + initEnumerants(length: number): capnp.List; + setEnumerants(value: capnp.List): void; + toString(): string; +} +export declare class Node_Interface extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Methods: capnp.ListCtor; + static _Superclasses: capnp.ListCtor; + adoptMethods(value: capnp.Orphan>): void; + disownMethods(): capnp.Orphan>; + getMethods(): capnp.List; + hasMethods(): boolean; + initMethods(length: number): capnp.List; + setMethods(value: capnp.List): void; + adoptSuperclasses(value: capnp.Orphan>): void; + disownSuperclasses(): capnp.Orphan>; + getSuperclasses(): capnp.List; + hasSuperclasses(): boolean; + initSuperclasses(length: number): capnp.List; + setSuperclasses(value: capnp.List): void; + toString(): string; +} +export declare class Node_Const extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + adoptType(value: capnp.Orphan): void; + disownType(): capnp.Orphan; + getType(): Type; + hasType(): boolean; + initType(): Type; + setType(value: Type): void; + adoptValue(value: capnp.Orphan): void; + disownValue(): capnp.Orphan; + getValue(): Value; + hasValue(): boolean; + initValue(): Value; + setValue(value: Value): void; + toString(): string; +} +export declare class Node_Annotation extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + adoptType(value: capnp.Orphan): void; + disownType(): capnp.Orphan; + getType(): Type; + hasType(): boolean; + initType(): Type; + setType(value: Type): void; + getTargetsFile(): boolean; + setTargetsFile(value: boolean): void; + getTargetsConst(): boolean; + setTargetsConst(value: boolean): void; + getTargetsEnum(): boolean; + setTargetsEnum(value: boolean): void; + getTargetsEnumerant(): boolean; + setTargetsEnumerant(value: boolean): void; + getTargetsStruct(): boolean; + setTargetsStruct(value: boolean): void; + getTargetsField(): boolean; + setTargetsField(value: boolean): void; + getTargetsUnion(): boolean; + setTargetsUnion(value: boolean): void; + getTargetsGroup(): boolean; + setTargetsGroup(value: boolean): void; + getTargetsInterface(): boolean; + setTargetsInterface(value: boolean): void; + getTargetsMethod(): boolean; + setTargetsMethod(value: boolean): void; + getTargetsParam(): boolean; + setTargetsParam(value: boolean): void; + getTargetsAnnotation(): boolean; + setTargetsAnnotation(value: boolean): void; + toString(): string; +} +export declare enum Node_Which { + FILE = 0, + STRUCT = 1, + ENUM = 2, + INTERFACE = 3, + CONST = 4, + ANNOTATION = 5 +} +export declare class Node extends __S { + static readonly FILE = Node_Which.FILE; + static readonly STRUCT = Node_Which.STRUCT; + static readonly ENUM = Node_Which.ENUM; + static readonly INTERFACE = Node_Which.INTERFACE; + static readonly CONST = Node_Which.CONST; + static readonly ANNOTATION = Node_Which.ANNOTATION; + static readonly Parameter: typeof Node_Parameter; + static readonly NestedNode: typeof Node_NestedNode; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Parameters: capnp.ListCtor; + static _NestedNodes: capnp.ListCtor; + static _Annotations: capnp.ListCtor; + getId(): capnp.Uint64; + setId(value: capnp.Uint64): void; + getDisplayName(): string; + setDisplayName(value: string): void; + getDisplayNamePrefixLength(): number; + setDisplayNamePrefixLength(value: number): void; + getScopeId(): capnp.Uint64; + setScopeId(value: capnp.Uint64): void; + adoptParameters(value: capnp.Orphan>): void; + disownParameters(): capnp.Orphan>; + getParameters(): capnp.List; + hasParameters(): boolean; + initParameters(length: number): capnp.List; + setParameters(value: capnp.List): void; + getIsGeneric(): boolean; + setIsGeneric(value: boolean): void; + adoptNestedNodes(value: capnp.Orphan>): void; + disownNestedNodes(): capnp.Orphan>; + getNestedNodes(): capnp.List; + hasNestedNodes(): boolean; + initNestedNodes(length: number): capnp.List; + setNestedNodes(value: capnp.List): void; + adoptAnnotations(value: capnp.Orphan>): void; + disownAnnotations(): capnp.Orphan>; + getAnnotations(): capnp.List; + hasAnnotations(): boolean; + initAnnotations(length: number): capnp.List; + setAnnotations(value: capnp.List): void; + isFile(): boolean; + setFile(): void; + getStruct(): Node_Struct; + initStruct(): Node_Struct; + isStruct(): boolean; + setStruct(): void; + getEnum(): Node_Enum; + initEnum(): Node_Enum; + isEnum(): boolean; + setEnum(): void; + getInterface(): Node_Interface; + initInterface(): Node_Interface; + isInterface(): boolean; + setInterface(): void; + getConst(): Node_Const; + initConst(): Node_Const; + isConst(): boolean; + setConst(): void; + getAnnotation(): Node_Annotation; + initAnnotation(): Node_Annotation; + isAnnotation(): boolean; + setAnnotation(): void; + toString(): string; + which(): Node_Which; +} +export declare class Field_Slot extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getOffset(): number; + setOffset(value: number): void; + adoptType(value: capnp.Orphan): void; + disownType(): capnp.Orphan; + getType(): Type; + hasType(): boolean; + initType(): Type; + setType(value: Type): void; + adoptDefaultValue(value: capnp.Orphan): void; + disownDefaultValue(): capnp.Orphan; + getDefaultValue(): Value; + hasDefaultValue(): boolean; + initDefaultValue(): Value; + setDefaultValue(value: Value): void; + getHadExplicitDefault(): boolean; + setHadExplicitDefault(value: boolean): void; + toString(): string; +} +export declare class Field_Group extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getTypeId(): capnp.Uint64; + setTypeId(value: capnp.Uint64): void; + toString(): string; +} +export declare enum Field_Ordinal_Which { + IMPLICIT = 0, + EXPLICIT = 1 +} +export declare class Field_Ordinal extends __S { + static readonly IMPLICIT = Field_Ordinal_Which.IMPLICIT; + static readonly EXPLICIT = Field_Ordinal_Which.EXPLICIT; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + isImplicit(): boolean; + setImplicit(): void; + getExplicit(): number; + isExplicit(): boolean; + setExplicit(value: number): void; + toString(): string; + which(): Field_Ordinal_Which; +} +export declare enum Field_Which { + SLOT = 0, + GROUP = 1 +} +export declare class Field extends __S { + static readonly NO_DISCRIMINANT = 65535; + static readonly SLOT = Field_Which.SLOT; + static readonly GROUP = Field_Which.GROUP; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + defaultDiscriminantValue: DataView; + }; + static _Annotations: capnp.ListCtor; + getName(): string; + setName(value: string): void; + getCodeOrder(): number; + setCodeOrder(value: number): void; + adoptAnnotations(value: capnp.Orphan>): void; + disownAnnotations(): capnp.Orphan>; + getAnnotations(): capnp.List; + hasAnnotations(): boolean; + initAnnotations(length: number): capnp.List; + setAnnotations(value: capnp.List): void; + getDiscriminantValue(): number; + setDiscriminantValue(value: number): void; + getSlot(): Field_Slot; + initSlot(): Field_Slot; + isSlot(): boolean; + setSlot(): void; + getGroup(): Field_Group; + initGroup(): Field_Group; + isGroup(): boolean; + setGroup(): void; + getOrdinal(): Field_Ordinal; + initOrdinal(): Field_Ordinal; + toString(): string; + which(): Field_Which; +} +export declare class Enumerant extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Annotations: capnp.ListCtor; + getName(): string; + setName(value: string): void; + getCodeOrder(): number; + setCodeOrder(value: number): void; + adoptAnnotations(value: capnp.Orphan>): void; + disownAnnotations(): capnp.Orphan>; + getAnnotations(): capnp.List; + hasAnnotations(): boolean; + initAnnotations(length: number): capnp.List; + setAnnotations(value: capnp.List): void; + toString(): string; +} +export declare class Superclass extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getId(): capnp.Uint64; + setId(value: capnp.Uint64): void; + adoptBrand(value: capnp.Orphan): void; + disownBrand(): capnp.Orphan; + getBrand(): Brand; + hasBrand(): boolean; + initBrand(): Brand; + setBrand(value: Brand): void; + toString(): string; +} +export declare class Method extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _ImplicitParameters: capnp.ListCtor; + static _Annotations: capnp.ListCtor; + getName(): string; + setName(value: string): void; + getCodeOrder(): number; + setCodeOrder(value: number): void; + adoptImplicitParameters(value: capnp.Orphan>): void; + disownImplicitParameters(): capnp.Orphan>; + getImplicitParameters(): capnp.List; + hasImplicitParameters(): boolean; + initImplicitParameters(length: number): capnp.List; + setImplicitParameters(value: capnp.List): void; + getParamStructType(): capnp.Uint64; + setParamStructType(value: capnp.Uint64): void; + adoptParamBrand(value: capnp.Orphan): void; + disownParamBrand(): capnp.Orphan; + getParamBrand(): Brand; + hasParamBrand(): boolean; + initParamBrand(): Brand; + setParamBrand(value: Brand): void; + getResultStructType(): capnp.Uint64; + setResultStructType(value: capnp.Uint64): void; + adoptResultBrand(value: capnp.Orphan): void; + disownResultBrand(): capnp.Orphan; + getResultBrand(): Brand; + hasResultBrand(): boolean; + initResultBrand(): Brand; + setResultBrand(value: Brand): void; + adoptAnnotations(value: capnp.Orphan>): void; + disownAnnotations(): capnp.Orphan>; + getAnnotations(): capnp.List; + hasAnnotations(): boolean; + initAnnotations(length: number): capnp.List; + setAnnotations(value: capnp.List): void; + toString(): string; +} +export declare class Type_List extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + adoptElementType(value: capnp.Orphan): void; + disownElementType(): capnp.Orphan; + getElementType(): Type; + hasElementType(): boolean; + initElementType(): Type; + setElementType(value: Type): void; + toString(): string; +} +export declare class Type_Enum extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getTypeId(): capnp.Uint64; + setTypeId(value: capnp.Uint64): void; + adoptBrand(value: capnp.Orphan): void; + disownBrand(): capnp.Orphan; + getBrand(): Brand; + hasBrand(): boolean; + initBrand(): Brand; + setBrand(value: Brand): void; + toString(): string; +} +export declare class Type_Struct extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getTypeId(): capnp.Uint64; + setTypeId(value: capnp.Uint64): void; + adoptBrand(value: capnp.Orphan): void; + disownBrand(): capnp.Orphan; + getBrand(): Brand; + hasBrand(): boolean; + initBrand(): Brand; + setBrand(value: Brand): void; + toString(): string; +} +export declare class Type_Interface extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getTypeId(): capnp.Uint64; + setTypeId(value: capnp.Uint64): void; + adoptBrand(value: capnp.Orphan): void; + disownBrand(): capnp.Orphan; + getBrand(): Brand; + hasBrand(): boolean; + initBrand(): Brand; + setBrand(value: Brand): void; + toString(): string; +} +export declare enum Type_AnyPointer_Unconstrained_Which { + ANY_KIND = 0, + STRUCT = 1, + LIST = 2, + CAPABILITY = 3 +} +export declare class Type_AnyPointer_Unconstrained extends __S { + static readonly ANY_KIND = Type_AnyPointer_Unconstrained_Which.ANY_KIND; + static readonly STRUCT = Type_AnyPointer_Unconstrained_Which.STRUCT; + static readonly LIST = Type_AnyPointer_Unconstrained_Which.LIST; + static readonly CAPABILITY = Type_AnyPointer_Unconstrained_Which.CAPABILITY; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + isAnyKind(): boolean; + setAnyKind(): void; + isStruct(): boolean; + setStruct(): void; + isList(): boolean; + setList(): void; + isCapability(): boolean; + setCapability(): void; + toString(): string; + which(): Type_AnyPointer_Unconstrained_Which; +} +export declare class Type_AnyPointer_Parameter extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getScopeId(): capnp.Uint64; + setScopeId(value: capnp.Uint64): void; + getParameterIndex(): number; + setParameterIndex(value: number): void; + toString(): string; +} +export declare class Type_AnyPointer_ImplicitMethodParameter extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getParameterIndex(): number; + setParameterIndex(value: number): void; + toString(): string; +} +export declare enum Type_AnyPointer_Which { + UNCONSTRAINED = 0, + PARAMETER = 1, + IMPLICIT_METHOD_PARAMETER = 2 +} +export declare class Type_AnyPointer extends __S { + static readonly UNCONSTRAINED = Type_AnyPointer_Which.UNCONSTRAINED; + static readonly PARAMETER = Type_AnyPointer_Which.PARAMETER; + static readonly IMPLICIT_METHOD_PARAMETER = Type_AnyPointer_Which.IMPLICIT_METHOD_PARAMETER; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getUnconstrained(): Type_AnyPointer_Unconstrained; + initUnconstrained(): Type_AnyPointer_Unconstrained; + isUnconstrained(): boolean; + setUnconstrained(): void; + getParameter(): Type_AnyPointer_Parameter; + initParameter(): Type_AnyPointer_Parameter; + isParameter(): boolean; + setParameter(): void; + getImplicitMethodParameter(): Type_AnyPointer_ImplicitMethodParameter; + initImplicitMethodParameter(): Type_AnyPointer_ImplicitMethodParameter; + isImplicitMethodParameter(): boolean; + setImplicitMethodParameter(): void; + toString(): string; + which(): Type_AnyPointer_Which; +} +export declare enum Type_Which { + VOID = 0, + BOOL = 1, + INT8 = 2, + INT16 = 3, + INT32 = 4, + INT64 = 5, + UINT8 = 6, + UINT16 = 7, + UINT32 = 8, + UINT64 = 9, + FLOAT32 = 10, + FLOAT64 = 11, + TEXT = 12, + DATA = 13, + LIST = 14, + ENUM = 15, + STRUCT = 16, + INTERFACE = 17, + ANY_POINTER = 18 +} +export declare class Type extends __S { + static readonly VOID = Type_Which.VOID; + static readonly BOOL = Type_Which.BOOL; + static readonly INT8 = Type_Which.INT8; + static readonly INT16 = Type_Which.INT16; + static readonly INT32 = Type_Which.INT32; + static readonly INT64 = Type_Which.INT64; + static readonly UINT8 = Type_Which.UINT8; + static readonly UINT16 = Type_Which.UINT16; + static readonly UINT32 = Type_Which.UINT32; + static readonly UINT64 = Type_Which.UINT64; + static readonly FLOAT32 = Type_Which.FLOAT32; + static readonly FLOAT64 = Type_Which.FLOAT64; + static readonly TEXT = Type_Which.TEXT; + static readonly DATA = Type_Which.DATA; + static readonly LIST = Type_Which.LIST; + static readonly ENUM = Type_Which.ENUM; + static readonly STRUCT = Type_Which.STRUCT; + static readonly INTERFACE = Type_Which.INTERFACE; + static readonly ANY_POINTER = Type_Which.ANY_POINTER; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + isVoid(): boolean; + setVoid(): void; + isBool(): boolean; + setBool(): void; + isInt8(): boolean; + setInt8(): void; + isInt16(): boolean; + setInt16(): void; + isInt32(): boolean; + setInt32(): void; + isInt64(): boolean; + setInt64(): void; + isUint8(): boolean; + setUint8(): void; + isUint16(): boolean; + setUint16(): void; + isUint32(): boolean; + setUint32(): void; + isUint64(): boolean; + setUint64(): void; + isFloat32(): boolean; + setFloat32(): void; + isFloat64(): boolean; + setFloat64(): void; + isText(): boolean; + setText(): void; + isData(): boolean; + setData(): void; + getList(): Type_List; + initList(): Type_List; + isList(): boolean; + setList(): void; + getEnum(): Type_Enum; + initEnum(): Type_Enum; + isEnum(): boolean; + setEnum(): void; + getStruct(): Type_Struct; + initStruct(): Type_Struct; + isStruct(): boolean; + setStruct(): void; + getInterface(): Type_Interface; + initInterface(): Type_Interface; + isInterface(): boolean; + setInterface(): void; + getAnyPointer(): Type_AnyPointer; + initAnyPointer(): Type_AnyPointer; + isAnyPointer(): boolean; + setAnyPointer(): void; + toString(): string; + which(): Type_Which; +} +export declare enum Brand_Scope_Which { + BIND = 0, + INHERIT = 1 +} +export declare class Brand_Scope extends __S { + static readonly BIND = Brand_Scope_Which.BIND; + static readonly INHERIT = Brand_Scope_Which.INHERIT; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Bind: capnp.ListCtor; + getScopeId(): capnp.Uint64; + setScopeId(value: capnp.Uint64): void; + adoptBind(value: capnp.Orphan>): void; + disownBind(): capnp.Orphan>; + getBind(): capnp.List; + hasBind(): boolean; + initBind(length: number): capnp.List; + isBind(): boolean; + setBind(value: capnp.List): void; + isInherit(): boolean; + setInherit(): void; + toString(): string; + which(): Brand_Scope_Which; +} +export declare enum Brand_Binding_Which { + UNBOUND = 0, + TYPE = 1 +} +export declare class Brand_Binding extends __S { + static readonly UNBOUND = Brand_Binding_Which.UNBOUND; + static readonly TYPE = Brand_Binding_Which.TYPE; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + isUnbound(): boolean; + setUnbound(): void; + adoptType(value: capnp.Orphan): void; + disownType(): capnp.Orphan; + getType(): Type; + hasType(): boolean; + initType(): Type; + isType(): boolean; + setType(value: Type): void; + toString(): string; + which(): Brand_Binding_Which; +} +export declare class Brand extends __S { + static readonly Scope: typeof Brand_Scope; + static readonly Binding: typeof Brand_Binding; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Scopes: capnp.ListCtor; + adoptScopes(value: capnp.Orphan>): void; + disownScopes(): capnp.Orphan>; + getScopes(): capnp.List; + hasScopes(): boolean; + initScopes(length: number): capnp.List; + setScopes(value: capnp.List): void; + toString(): string; +} +export declare enum Value_Which { + VOID = 0, + BOOL = 1, + INT8 = 2, + INT16 = 3, + INT32 = 4, + INT64 = 5, + UINT8 = 6, + UINT16 = 7, + UINT32 = 8, + UINT64 = 9, + FLOAT32 = 10, + FLOAT64 = 11, + TEXT = 12, + DATA = 13, + LIST = 14, + ENUM = 15, + STRUCT = 16, + INTERFACE = 17, + ANY_POINTER = 18 +} +export declare class Value extends __S { + static readonly VOID = Value_Which.VOID; + static readonly BOOL = Value_Which.BOOL; + static readonly INT8 = Value_Which.INT8; + static readonly INT16 = Value_Which.INT16; + static readonly INT32 = Value_Which.INT32; + static readonly INT64 = Value_Which.INT64; + static readonly UINT8 = Value_Which.UINT8; + static readonly UINT16 = Value_Which.UINT16; + static readonly UINT32 = Value_Which.UINT32; + static readonly UINT64 = Value_Which.UINT64; + static readonly FLOAT32 = Value_Which.FLOAT32; + static readonly FLOAT64 = Value_Which.FLOAT64; + static readonly TEXT = Value_Which.TEXT; + static readonly DATA = Value_Which.DATA; + static readonly LIST = Value_Which.LIST; + static readonly ENUM = Value_Which.ENUM; + static readonly STRUCT = Value_Which.STRUCT; + static readonly INTERFACE = Value_Which.INTERFACE; + static readonly ANY_POINTER = Value_Which.ANY_POINTER; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + isVoid(): boolean; + setVoid(): void; + getBool(): boolean; + isBool(): boolean; + setBool(value: boolean): void; + getInt8(): number; + isInt8(): boolean; + setInt8(value: number): void; + getInt16(): number; + isInt16(): boolean; + setInt16(value: number): void; + getInt32(): number; + isInt32(): boolean; + setInt32(value: number): void; + getInt64(): capnp.Int64; + isInt64(): boolean; + setInt64(value: capnp.Int64): void; + getUint8(): number; + isUint8(): boolean; + setUint8(value: number): void; + getUint16(): number; + isUint16(): boolean; + setUint16(value: number): void; + getUint32(): number; + isUint32(): boolean; + setUint32(value: number): void; + getUint64(): capnp.Uint64; + isUint64(): boolean; + setUint64(value: capnp.Uint64): void; + getFloat32(): number; + isFloat32(): boolean; + setFloat32(value: number): void; + getFloat64(): number; + isFloat64(): boolean; + setFloat64(value: number): void; + getText(): string; + isText(): boolean; + setText(value: string): void; + adoptData(value: capnp.Orphan): void; + disownData(): capnp.Orphan; + getData(): capnp.Data; + hasData(): boolean; + initData(length: number): capnp.Data; + isData(): boolean; + setData(value: capnp.Data): void; + adoptList(value: capnp.Orphan): void; + disownList(): capnp.Orphan; + getList(): capnp.Pointer; + hasList(): boolean; + isList(): boolean; + setList(value: capnp.Pointer): void; + getEnum(): number; + isEnum(): boolean; + setEnum(value: number): void; + adoptStruct(value: capnp.Orphan): void; + disownStruct(): capnp.Orphan; + getStruct(): capnp.Pointer; + hasStruct(): boolean; + isStruct(): boolean; + setStruct(value: capnp.Pointer): void; + isInterface(): boolean; + setInterface(): void; + adoptAnyPointer(value: capnp.Orphan): void; + disownAnyPointer(): capnp.Orphan; + getAnyPointer(): capnp.Pointer; + hasAnyPointer(): boolean; + isAnyPointer(): boolean; + setAnyPointer(value: capnp.Pointer): void; + toString(): string; + which(): Value_Which; +} +export declare class Annotation extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getId(): capnp.Uint64; + setId(value: capnp.Uint64): void; + adoptBrand(value: capnp.Orphan): void; + disownBrand(): capnp.Orphan; + getBrand(): Brand; + hasBrand(): boolean; + initBrand(): Brand; + setBrand(value: Brand): void; + adoptValue(value: capnp.Orphan): void; + disownValue(): capnp.Orphan; + getValue(): Value; + hasValue(): boolean; + initValue(): Value; + setValue(value: Value): void; + toString(): string; +} +export declare enum ElementSize { + EMPTY = 0, + BIT = 1, + BYTE = 2, + TWO_BYTES = 3, + FOUR_BYTES = 4, + EIGHT_BYTES = 5, + POINTER = 6, + INLINE_COMPOSITE = 7 +} +export declare class CapnpVersion extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getMajor(): number; + setMajor(value: number): void; + getMinor(): number; + setMinor(value: number): void; + getMicro(): number; + setMicro(value: number): void; + toString(): string; +} +export declare class CodeGeneratorRequest_RequestedFile_Import extends __S { + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + getId(): capnp.Uint64; + setId(value: capnp.Uint64): void; + getName(): string; + setName(value: string): void; + toString(): string; +} +export declare class CodeGeneratorRequest_RequestedFile extends __S { + static readonly Import: typeof CodeGeneratorRequest_RequestedFile_Import; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Imports: capnp.ListCtor; + getId(): capnp.Uint64; + setId(value: capnp.Uint64): void; + getFilename(): string; + setFilename(value: string): void; + adoptImports(value: capnp.Orphan>): void; + disownImports(): capnp.Orphan>; + getImports(): capnp.List; + hasImports(): boolean; + initImports(length: number): capnp.List; + setImports(value: capnp.List): void; + toString(): string; +} +export declare class CodeGeneratorRequest extends __S { + static readonly RequestedFile: typeof CodeGeneratorRequest_RequestedFile; + static readonly _capnp: { + displayName: string; + id: string; + size: capnp.ObjectSize; + }; + static _Nodes: capnp.ListCtor; + static _RequestedFiles: capnp.ListCtor; + adoptCapnpVersion(value: capnp.Orphan): void; + disownCapnpVersion(): capnp.Orphan; + getCapnpVersion(): CapnpVersion; + hasCapnpVersion(): boolean; + initCapnpVersion(): CapnpVersion; + setCapnpVersion(value: CapnpVersion): void; + adoptNodes(value: capnp.Orphan>): void; + disownNodes(): capnp.Orphan>; + getNodes(): capnp.List; + hasNodes(): boolean; + initNodes(length: number): capnp.List; + setNodes(value: capnp.List): void; + adoptRequestedFiles(value: capnp.Orphan>): void; + disownRequestedFiles(): capnp.Orphan>; + getRequestedFiles(): capnp.List; + hasRequestedFiles(): boolean; + initRequestedFiles(length: number): capnp.List; + setRequestedFiles(value: capnp.List): void; + toString(): string; +} diff --git a/node_modules/capnp-ts/src/std/schema.capnp.js b/node_modules/capnp-ts/src/std/schema.capnp.js new file mode 100644 index 0000000000000000000000000000000000000000..c9861cfe70f8edf7cc9218e4edd4b2f50cea9780 --- /dev/null +++ b/node_modules/capnp-ts/src/std/schema.capnp.js @@ -0,0 +1,1081 @@ +"use strict"; +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CodeGeneratorRequest = exports.CodeGeneratorRequest_RequestedFile = exports.CodeGeneratorRequest_RequestedFile_Import = exports.CapnpVersion = exports.ElementSize = exports.Annotation = exports.Value = exports.Value_Which = exports.Brand = exports.Brand_Binding = exports.Brand_Binding_Which = exports.Brand_Scope = exports.Brand_Scope_Which = exports.Type = exports.Type_Which = exports.Type_AnyPointer = exports.Type_AnyPointer_Which = exports.Type_AnyPointer_ImplicitMethodParameter = exports.Type_AnyPointer_Parameter = exports.Type_AnyPointer_Unconstrained = exports.Type_AnyPointer_Unconstrained_Which = exports.Type_Interface = exports.Type_Struct = exports.Type_Enum = exports.Type_List = exports.Method = exports.Superclass = exports.Enumerant = exports.Field = exports.Field_Which = exports.Field_Ordinal = exports.Field_Ordinal_Which = exports.Field_Group = exports.Field_Slot = exports.Node = exports.Node_Which = exports.Node_Annotation = exports.Node_Const = exports.Node_Interface = exports.Node_Enum = exports.Node_Struct = exports.Node_NestedNode = exports.Node_Parameter = exports._capnpFileId = void 0; +const tslib_1 = require("tslib"); +const capnp = tslib_1.__importStar(require("../index")); +const index_1 = require("../index"); +exports._capnpFileId = "a93fc509624c72d9"; +class Node_Parameter extends index_1.Struct { + getName() { return index_1.Struct.getText(0, this); } + setName(value) { index_1.Struct.setText(0, value, this); } + toString() { return "Node_Parameter_" + super.toString(); } +} +exports.Node_Parameter = Node_Parameter; +Node_Parameter._capnp = { displayName: "Parameter", id: "b9521bccf10fa3b1", size: new index_1.ObjectSize(0, 1) }; +class Node_NestedNode extends index_1.Struct { + getName() { return index_1.Struct.getText(0, this); } + setName(value) { index_1.Struct.setText(0, value, this); } + getId() { return index_1.Struct.getUint64(0, this); } + setId(value) { index_1.Struct.setUint64(0, value, this); } + toString() { return "Node_NestedNode_" + super.toString(); } +} +exports.Node_NestedNode = Node_NestedNode; +Node_NestedNode._capnp = { displayName: "NestedNode", id: "debf55bbfa0fc242", size: new index_1.ObjectSize(8, 1) }; +class Node_Struct extends index_1.Struct { + getDataWordCount() { return index_1.Struct.getUint16(14, this); } + setDataWordCount(value) { index_1.Struct.setUint16(14, value, this); } + getPointerCount() { return index_1.Struct.getUint16(24, this); } + setPointerCount(value) { index_1.Struct.setUint16(24, value, this); } + getPreferredListEncoding() { return index_1.Struct.getUint16(26, this); } + setPreferredListEncoding(value) { index_1.Struct.setUint16(26, value, this); } + getIsGroup() { return index_1.Struct.getBit(224, this); } + setIsGroup(value) { index_1.Struct.setBit(224, value, this); } + getDiscriminantCount() { return index_1.Struct.getUint16(30, this); } + setDiscriminantCount(value) { index_1.Struct.setUint16(30, value, this); } + getDiscriminantOffset() { return index_1.Struct.getUint32(32, this); } + setDiscriminantOffset(value) { index_1.Struct.setUint32(32, value, this); } + adoptFields(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(3, this)); } + disownFields() { return index_1.Struct.disown(this.getFields()); } + getFields() { return index_1.Struct.getList(3, Node_Struct._Fields, this); } + hasFields() { return !index_1.Struct.isNull(index_1.Struct.getPointer(3, this)); } + initFields(length) { return index_1.Struct.initList(3, Node_Struct._Fields, length, this); } + setFields(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(3, this)); } + toString() { return "Node_Struct_" + super.toString(); } +} +exports.Node_Struct = Node_Struct; +Node_Struct._capnp = { displayName: "struct", id: "9ea0b19b37fb4435", size: new index_1.ObjectSize(40, 6) }; +class Node_Enum extends index_1.Struct { + adoptEnumerants(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(3, this)); } + disownEnumerants() { return index_1.Struct.disown(this.getEnumerants()); } + getEnumerants() { return index_1.Struct.getList(3, Node_Enum._Enumerants, this); } + hasEnumerants() { return !index_1.Struct.isNull(index_1.Struct.getPointer(3, this)); } + initEnumerants(length) { return index_1.Struct.initList(3, Node_Enum._Enumerants, length, this); } + setEnumerants(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(3, this)); } + toString() { return "Node_Enum_" + super.toString(); } +} +exports.Node_Enum = Node_Enum; +Node_Enum._capnp = { displayName: "enum", id: "b54ab3364333f598", size: new index_1.ObjectSize(40, 6) }; +class Node_Interface extends index_1.Struct { + adoptMethods(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(3, this)); } + disownMethods() { return index_1.Struct.disown(this.getMethods()); } + getMethods() { return index_1.Struct.getList(3, Node_Interface._Methods, this); } + hasMethods() { return !index_1.Struct.isNull(index_1.Struct.getPointer(3, this)); } + initMethods(length) { return index_1.Struct.initList(3, Node_Interface._Methods, length, this); } + setMethods(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(3, this)); } + adoptSuperclasses(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(4, this)); } + disownSuperclasses() { return index_1.Struct.disown(this.getSuperclasses()); } + getSuperclasses() { return index_1.Struct.getList(4, Node_Interface._Superclasses, this); } + hasSuperclasses() { return !index_1.Struct.isNull(index_1.Struct.getPointer(4, this)); } + initSuperclasses(length) { return index_1.Struct.initList(4, Node_Interface._Superclasses, length, this); } + setSuperclasses(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(4, this)); } + toString() { return "Node_Interface_" + super.toString(); } +} +exports.Node_Interface = Node_Interface; +Node_Interface._capnp = { displayName: "interface", id: "e82753cff0c2218f", size: new index_1.ObjectSize(40, 6) }; +class Node_Const extends index_1.Struct { + adoptType(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(3, this)); } + disownType() { return index_1.Struct.disown(this.getType()); } + getType() { return index_1.Struct.getStruct(3, Type, this); } + hasType() { return !index_1.Struct.isNull(index_1.Struct.getPointer(3, this)); } + initType() { return index_1.Struct.initStructAt(3, Type, this); } + setType(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(3, this)); } + adoptValue(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(4, this)); } + disownValue() { return index_1.Struct.disown(this.getValue()); } + getValue() { return index_1.Struct.getStruct(4, Value, this); } + hasValue() { return !index_1.Struct.isNull(index_1.Struct.getPointer(4, this)); } + initValue() { return index_1.Struct.initStructAt(4, Value, this); } + setValue(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(4, this)); } + toString() { return "Node_Const_" + super.toString(); } +} +exports.Node_Const = Node_Const; +Node_Const._capnp = { displayName: "const", id: "b18aa5ac7a0d9420", size: new index_1.ObjectSize(40, 6) }; +class Node_Annotation extends index_1.Struct { + adoptType(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(3, this)); } + disownType() { return index_1.Struct.disown(this.getType()); } + getType() { return index_1.Struct.getStruct(3, Type, this); } + hasType() { return !index_1.Struct.isNull(index_1.Struct.getPointer(3, this)); } + initType() { return index_1.Struct.initStructAt(3, Type, this); } + setType(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(3, this)); } + getTargetsFile() { return index_1.Struct.getBit(112, this); } + setTargetsFile(value) { index_1.Struct.setBit(112, value, this); } + getTargetsConst() { return index_1.Struct.getBit(113, this); } + setTargetsConst(value) { index_1.Struct.setBit(113, value, this); } + getTargetsEnum() { return index_1.Struct.getBit(114, this); } + setTargetsEnum(value) { index_1.Struct.setBit(114, value, this); } + getTargetsEnumerant() { return index_1.Struct.getBit(115, this); } + setTargetsEnumerant(value) { index_1.Struct.setBit(115, value, this); } + getTargetsStruct() { return index_1.Struct.getBit(116, this); } + setTargetsStruct(value) { index_1.Struct.setBit(116, value, this); } + getTargetsField() { return index_1.Struct.getBit(117, this); } + setTargetsField(value) { index_1.Struct.setBit(117, value, this); } + getTargetsUnion() { return index_1.Struct.getBit(118, this); } + setTargetsUnion(value) { index_1.Struct.setBit(118, value, this); } + getTargetsGroup() { return index_1.Struct.getBit(119, this); } + setTargetsGroup(value) { index_1.Struct.setBit(119, value, this); } + getTargetsInterface() { return index_1.Struct.getBit(120, this); } + setTargetsInterface(value) { index_1.Struct.setBit(120, value, this); } + getTargetsMethod() { return index_1.Struct.getBit(121, this); } + setTargetsMethod(value) { index_1.Struct.setBit(121, value, this); } + getTargetsParam() { return index_1.Struct.getBit(122, this); } + setTargetsParam(value) { index_1.Struct.setBit(122, value, this); } + getTargetsAnnotation() { return index_1.Struct.getBit(123, this); } + setTargetsAnnotation(value) { index_1.Struct.setBit(123, value, this); } + toString() { return "Node_Annotation_" + super.toString(); } +} +exports.Node_Annotation = Node_Annotation; +Node_Annotation._capnp = { displayName: "annotation", id: "ec1619d4400a0290", size: new index_1.ObjectSize(40, 6) }; +var Node_Which; +(function (Node_Which) { + Node_Which[Node_Which["FILE"] = 0] = "FILE"; + Node_Which[Node_Which["STRUCT"] = 1] = "STRUCT"; + Node_Which[Node_Which["ENUM"] = 2] = "ENUM"; + Node_Which[Node_Which["INTERFACE"] = 3] = "INTERFACE"; + Node_Which[Node_Which["CONST"] = 4] = "CONST"; + Node_Which[Node_Which["ANNOTATION"] = 5] = "ANNOTATION"; +})(Node_Which = exports.Node_Which || (exports.Node_Which = {})); +class Node extends index_1.Struct { + getId() { return index_1.Struct.getUint64(0, this); } + setId(value) { index_1.Struct.setUint64(0, value, this); } + getDisplayName() { return index_1.Struct.getText(0, this); } + setDisplayName(value) { index_1.Struct.setText(0, value, this); } + getDisplayNamePrefixLength() { return index_1.Struct.getUint32(8, this); } + setDisplayNamePrefixLength(value) { index_1.Struct.setUint32(8, value, this); } + getScopeId() { return index_1.Struct.getUint64(16, this); } + setScopeId(value) { index_1.Struct.setUint64(16, value, this); } + adoptParameters(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(5, this)); } + disownParameters() { return index_1.Struct.disown(this.getParameters()); } + getParameters() { return index_1.Struct.getList(5, Node._Parameters, this); } + hasParameters() { return !index_1.Struct.isNull(index_1.Struct.getPointer(5, this)); } + initParameters(length) { return index_1.Struct.initList(5, Node._Parameters, length, this); } + setParameters(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(5, this)); } + getIsGeneric() { return index_1.Struct.getBit(288, this); } + setIsGeneric(value) { index_1.Struct.setBit(288, value, this); } + adoptNestedNodes(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownNestedNodes() { return index_1.Struct.disown(this.getNestedNodes()); } + getNestedNodes() { return index_1.Struct.getList(1, Node._NestedNodes, this); } + hasNestedNodes() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initNestedNodes(length) { return index_1.Struct.initList(1, Node._NestedNodes, length, this); } + setNestedNodes(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + adoptAnnotations(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(2, this)); } + disownAnnotations() { return index_1.Struct.disown(this.getAnnotations()); } + getAnnotations() { return index_1.Struct.getList(2, Node._Annotations, this); } + hasAnnotations() { return !index_1.Struct.isNull(index_1.Struct.getPointer(2, this)); } + initAnnotations(length) { return index_1.Struct.initList(2, Node._Annotations, length, this); } + setAnnotations(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(2, this)); } + isFile() { return index_1.Struct.getUint16(12, this) === 0; } + setFile() { index_1.Struct.setUint16(12, 0, this); } + getStruct() { + index_1.Struct.testWhich("struct", index_1.Struct.getUint16(12, this), 1, this); + return index_1.Struct.getAs(Node_Struct, this); + } + initStruct() { + index_1.Struct.setUint16(12, 1, this); + return index_1.Struct.getAs(Node_Struct, this); + } + isStruct() { return index_1.Struct.getUint16(12, this) === 1; } + setStruct() { index_1.Struct.setUint16(12, 1, this); } + getEnum() { + index_1.Struct.testWhich("enum", index_1.Struct.getUint16(12, this), 2, this); + return index_1.Struct.getAs(Node_Enum, this); + } + initEnum() { + index_1.Struct.setUint16(12, 2, this); + return index_1.Struct.getAs(Node_Enum, this); + } + isEnum() { return index_1.Struct.getUint16(12, this) === 2; } + setEnum() { index_1.Struct.setUint16(12, 2, this); } + getInterface() { + index_1.Struct.testWhich("interface", index_1.Struct.getUint16(12, this), 3, this); + return index_1.Struct.getAs(Node_Interface, this); + } + initInterface() { + index_1.Struct.setUint16(12, 3, this); + return index_1.Struct.getAs(Node_Interface, this); + } + isInterface() { return index_1.Struct.getUint16(12, this) === 3; } + setInterface() { index_1.Struct.setUint16(12, 3, this); } + getConst() { + index_1.Struct.testWhich("const", index_1.Struct.getUint16(12, this), 4, this); + return index_1.Struct.getAs(Node_Const, this); + } + initConst() { + index_1.Struct.setUint16(12, 4, this); + return index_1.Struct.getAs(Node_Const, this); + } + isConst() { return index_1.Struct.getUint16(12, this) === 4; } + setConst() { index_1.Struct.setUint16(12, 4, this); } + getAnnotation() { + index_1.Struct.testWhich("annotation", index_1.Struct.getUint16(12, this), 5, this); + return index_1.Struct.getAs(Node_Annotation, this); + } + initAnnotation() { + index_1.Struct.setUint16(12, 5, this); + return index_1.Struct.getAs(Node_Annotation, this); + } + isAnnotation() { return index_1.Struct.getUint16(12, this) === 5; } + setAnnotation() { index_1.Struct.setUint16(12, 5, this); } + toString() { return "Node_" + super.toString(); } + which() { return index_1.Struct.getUint16(12, this); } +} +exports.Node = Node; +Node.FILE = Node_Which.FILE; +Node.STRUCT = Node_Which.STRUCT; +Node.ENUM = Node_Which.ENUM; +Node.INTERFACE = Node_Which.INTERFACE; +Node.CONST = Node_Which.CONST; +Node.ANNOTATION = Node_Which.ANNOTATION; +Node.Parameter = Node_Parameter; +Node.NestedNode = Node_NestedNode; +Node._capnp = { displayName: "Node", id: "e682ab4cf923a417", size: new index_1.ObjectSize(40, 6) }; +class Field_Slot extends index_1.Struct { + getOffset() { return index_1.Struct.getUint32(4, this); } + setOffset(value) { index_1.Struct.setUint32(4, value, this); } + adoptType(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(2, this)); } + disownType() { return index_1.Struct.disown(this.getType()); } + getType() { return index_1.Struct.getStruct(2, Type, this); } + hasType() { return !index_1.Struct.isNull(index_1.Struct.getPointer(2, this)); } + initType() { return index_1.Struct.initStructAt(2, Type, this); } + setType(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(2, this)); } + adoptDefaultValue(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(3, this)); } + disownDefaultValue() { return index_1.Struct.disown(this.getDefaultValue()); } + getDefaultValue() { return index_1.Struct.getStruct(3, Value, this); } + hasDefaultValue() { return !index_1.Struct.isNull(index_1.Struct.getPointer(3, this)); } + initDefaultValue() { return index_1.Struct.initStructAt(3, Value, this); } + setDefaultValue(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(3, this)); } + getHadExplicitDefault() { return index_1.Struct.getBit(128, this); } + setHadExplicitDefault(value) { index_1.Struct.setBit(128, value, this); } + toString() { return "Field_Slot_" + super.toString(); } +} +exports.Field_Slot = Field_Slot; +Field_Slot._capnp = { displayName: "slot", id: "c42305476bb4746f", size: new index_1.ObjectSize(24, 4) }; +class Field_Group extends index_1.Struct { + getTypeId() { return index_1.Struct.getUint64(16, this); } + setTypeId(value) { index_1.Struct.setUint64(16, value, this); } + toString() { return "Field_Group_" + super.toString(); } +} +exports.Field_Group = Field_Group; +Field_Group._capnp = { displayName: "group", id: "cafccddb68db1d11", size: new index_1.ObjectSize(24, 4) }; +var Field_Ordinal_Which; +(function (Field_Ordinal_Which) { + Field_Ordinal_Which[Field_Ordinal_Which["IMPLICIT"] = 0] = "IMPLICIT"; + Field_Ordinal_Which[Field_Ordinal_Which["EXPLICIT"] = 1] = "EXPLICIT"; +})(Field_Ordinal_Which = exports.Field_Ordinal_Which || (exports.Field_Ordinal_Which = {})); +class Field_Ordinal extends index_1.Struct { + isImplicit() { return index_1.Struct.getUint16(10, this) === 0; } + setImplicit() { index_1.Struct.setUint16(10, 0, this); } + getExplicit() { + index_1.Struct.testWhich("explicit", index_1.Struct.getUint16(10, this), 1, this); + return index_1.Struct.getUint16(12, this); + } + isExplicit() { return index_1.Struct.getUint16(10, this) === 1; } + setExplicit(value) { + index_1.Struct.setUint16(10, 1, this); + index_1.Struct.setUint16(12, value, this); + } + toString() { return "Field_Ordinal_" + super.toString(); } + which() { return index_1.Struct.getUint16(10, this); } +} +exports.Field_Ordinal = Field_Ordinal; +Field_Ordinal.IMPLICIT = Field_Ordinal_Which.IMPLICIT; +Field_Ordinal.EXPLICIT = Field_Ordinal_Which.EXPLICIT; +Field_Ordinal._capnp = { displayName: "ordinal", id: "bb90d5c287870be6", size: new index_1.ObjectSize(24, 4) }; +var Field_Which; +(function (Field_Which) { + Field_Which[Field_Which["SLOT"] = 0] = "SLOT"; + Field_Which[Field_Which["GROUP"] = 1] = "GROUP"; +})(Field_Which = exports.Field_Which || (exports.Field_Which = {})); +class Field extends index_1.Struct { + getName() { return index_1.Struct.getText(0, this); } + setName(value) { index_1.Struct.setText(0, value, this); } + getCodeOrder() { return index_1.Struct.getUint16(0, this); } + setCodeOrder(value) { index_1.Struct.setUint16(0, value, this); } + adoptAnnotations(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownAnnotations() { return index_1.Struct.disown(this.getAnnotations()); } + getAnnotations() { return index_1.Struct.getList(1, Field._Annotations, this); } + hasAnnotations() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initAnnotations(length) { return index_1.Struct.initList(1, Field._Annotations, length, this); } + setAnnotations(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + getDiscriminantValue() { return index_1.Struct.getUint16(2, this, Field._capnp.defaultDiscriminantValue); } + setDiscriminantValue(value) { index_1.Struct.setUint16(2, value, this); } + getSlot() { + index_1.Struct.testWhich("slot", index_1.Struct.getUint16(8, this), 0, this); + return index_1.Struct.getAs(Field_Slot, this); + } + initSlot() { + index_1.Struct.setUint16(8, 0, this); + return index_1.Struct.getAs(Field_Slot, this); + } + isSlot() { return index_1.Struct.getUint16(8, this) === 0; } + setSlot() { index_1.Struct.setUint16(8, 0, this); } + getGroup() { + index_1.Struct.testWhich("group", index_1.Struct.getUint16(8, this), 1, this); + return index_1.Struct.getAs(Field_Group, this); + } + initGroup() { + index_1.Struct.setUint16(8, 1, this); + return index_1.Struct.getAs(Field_Group, this); + } + isGroup() { return index_1.Struct.getUint16(8, this) === 1; } + setGroup() { index_1.Struct.setUint16(8, 1, this); } + getOrdinal() { return index_1.Struct.getAs(Field_Ordinal, this); } + initOrdinal() { return index_1.Struct.getAs(Field_Ordinal, this); } + toString() { return "Field_" + super.toString(); } + which() { return index_1.Struct.getUint16(8, this); } +} +exports.Field = Field; +Field.NO_DISCRIMINANT = 65535; +Field.SLOT = Field_Which.SLOT; +Field.GROUP = Field_Which.GROUP; +Field._capnp = { displayName: "Field", id: "9aad50a41f4af45f", size: new index_1.ObjectSize(24, 4), defaultDiscriminantValue: capnp.getUint16Mask(65535) }; +class Enumerant extends index_1.Struct { + getName() { return index_1.Struct.getText(0, this); } + setName(value) { index_1.Struct.setText(0, value, this); } + getCodeOrder() { return index_1.Struct.getUint16(0, this); } + setCodeOrder(value) { index_1.Struct.setUint16(0, value, this); } + adoptAnnotations(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownAnnotations() { return index_1.Struct.disown(this.getAnnotations()); } + getAnnotations() { return index_1.Struct.getList(1, Enumerant._Annotations, this); } + hasAnnotations() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initAnnotations(length) { return index_1.Struct.initList(1, Enumerant._Annotations, length, this); } + setAnnotations(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + toString() { return "Enumerant_" + super.toString(); } +} +exports.Enumerant = Enumerant; +Enumerant._capnp = { displayName: "Enumerant", id: "978a7cebdc549a4d", size: new index_1.ObjectSize(8, 2) }; +class Superclass extends index_1.Struct { + getId() { return index_1.Struct.getUint64(0, this); } + setId(value) { index_1.Struct.setUint64(0, value, this); } + adoptBrand(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownBrand() { return index_1.Struct.disown(this.getBrand()); } + getBrand() { return index_1.Struct.getStruct(0, Brand, this); } + hasBrand() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initBrand() { return index_1.Struct.initStructAt(0, Brand, this); } + setBrand(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Superclass_" + super.toString(); } +} +exports.Superclass = Superclass; +Superclass._capnp = { displayName: "Superclass", id: "a9962a9ed0a4d7f8", size: new index_1.ObjectSize(8, 1) }; +class Method extends index_1.Struct { + getName() { return index_1.Struct.getText(0, this); } + setName(value) { index_1.Struct.setText(0, value, this); } + getCodeOrder() { return index_1.Struct.getUint16(0, this); } + setCodeOrder(value) { index_1.Struct.setUint16(0, value, this); } + adoptImplicitParameters(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(4, this)); } + disownImplicitParameters() { return index_1.Struct.disown(this.getImplicitParameters()); } + getImplicitParameters() { return index_1.Struct.getList(4, Method._ImplicitParameters, this); } + hasImplicitParameters() { return !index_1.Struct.isNull(index_1.Struct.getPointer(4, this)); } + initImplicitParameters(length) { return index_1.Struct.initList(4, Method._ImplicitParameters, length, this); } + setImplicitParameters(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(4, this)); } + getParamStructType() { return index_1.Struct.getUint64(8, this); } + setParamStructType(value) { index_1.Struct.setUint64(8, value, this); } + adoptParamBrand(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(2, this)); } + disownParamBrand() { return index_1.Struct.disown(this.getParamBrand()); } + getParamBrand() { return index_1.Struct.getStruct(2, Brand, this); } + hasParamBrand() { return !index_1.Struct.isNull(index_1.Struct.getPointer(2, this)); } + initParamBrand() { return index_1.Struct.initStructAt(2, Brand, this); } + setParamBrand(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(2, this)); } + getResultStructType() { return index_1.Struct.getUint64(16, this); } + setResultStructType(value) { index_1.Struct.setUint64(16, value, this); } + adoptResultBrand(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(3, this)); } + disownResultBrand() { return index_1.Struct.disown(this.getResultBrand()); } + getResultBrand() { return index_1.Struct.getStruct(3, Brand, this); } + hasResultBrand() { return !index_1.Struct.isNull(index_1.Struct.getPointer(3, this)); } + initResultBrand() { return index_1.Struct.initStructAt(3, Brand, this); } + setResultBrand(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(3, this)); } + adoptAnnotations(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownAnnotations() { return index_1.Struct.disown(this.getAnnotations()); } + getAnnotations() { return index_1.Struct.getList(1, Method._Annotations, this); } + hasAnnotations() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initAnnotations(length) { return index_1.Struct.initList(1, Method._Annotations, length, this); } + setAnnotations(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + toString() { return "Method_" + super.toString(); } +} +exports.Method = Method; +Method._capnp = { displayName: "Method", id: "9500cce23b334d80", size: new index_1.ObjectSize(24, 5) }; +class Type_List extends index_1.Struct { + adoptElementType(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownElementType() { return index_1.Struct.disown(this.getElementType()); } + getElementType() { return index_1.Struct.getStruct(0, Type, this); } + hasElementType() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initElementType() { return index_1.Struct.initStructAt(0, Type, this); } + setElementType(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Type_List_" + super.toString(); } +} +exports.Type_List = Type_List; +Type_List._capnp = { displayName: "list", id: "87e739250a60ea97", size: new index_1.ObjectSize(24, 1) }; +class Type_Enum extends index_1.Struct { + getTypeId() { return index_1.Struct.getUint64(8, this); } + setTypeId(value) { index_1.Struct.setUint64(8, value, this); } + adoptBrand(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownBrand() { return index_1.Struct.disown(this.getBrand()); } + getBrand() { return index_1.Struct.getStruct(0, Brand, this); } + hasBrand() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initBrand() { return index_1.Struct.initStructAt(0, Brand, this); } + setBrand(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Type_Enum_" + super.toString(); } +} +exports.Type_Enum = Type_Enum; +Type_Enum._capnp = { displayName: "enum", id: "9e0e78711a7f87a9", size: new index_1.ObjectSize(24, 1) }; +class Type_Struct extends index_1.Struct { + getTypeId() { return index_1.Struct.getUint64(8, this); } + setTypeId(value) { index_1.Struct.setUint64(8, value, this); } + adoptBrand(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownBrand() { return index_1.Struct.disown(this.getBrand()); } + getBrand() { return index_1.Struct.getStruct(0, Brand, this); } + hasBrand() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initBrand() { return index_1.Struct.initStructAt(0, Brand, this); } + setBrand(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Type_Struct_" + super.toString(); } +} +exports.Type_Struct = Type_Struct; +Type_Struct._capnp = { displayName: "struct", id: "ac3a6f60ef4cc6d3", size: new index_1.ObjectSize(24, 1) }; +class Type_Interface extends index_1.Struct { + getTypeId() { return index_1.Struct.getUint64(8, this); } + setTypeId(value) { index_1.Struct.setUint64(8, value, this); } + adoptBrand(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownBrand() { return index_1.Struct.disown(this.getBrand()); } + getBrand() { return index_1.Struct.getStruct(0, Brand, this); } + hasBrand() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initBrand() { return index_1.Struct.initStructAt(0, Brand, this); } + setBrand(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Type_Interface_" + super.toString(); } +} +exports.Type_Interface = Type_Interface; +Type_Interface._capnp = { displayName: "interface", id: "ed8bca69f7fb0cbf", size: new index_1.ObjectSize(24, 1) }; +var Type_AnyPointer_Unconstrained_Which; +(function (Type_AnyPointer_Unconstrained_Which) { + Type_AnyPointer_Unconstrained_Which[Type_AnyPointer_Unconstrained_Which["ANY_KIND"] = 0] = "ANY_KIND"; + Type_AnyPointer_Unconstrained_Which[Type_AnyPointer_Unconstrained_Which["STRUCT"] = 1] = "STRUCT"; + Type_AnyPointer_Unconstrained_Which[Type_AnyPointer_Unconstrained_Which["LIST"] = 2] = "LIST"; + Type_AnyPointer_Unconstrained_Which[Type_AnyPointer_Unconstrained_Which["CAPABILITY"] = 3] = "CAPABILITY"; +})(Type_AnyPointer_Unconstrained_Which = exports.Type_AnyPointer_Unconstrained_Which || (exports.Type_AnyPointer_Unconstrained_Which = {})); +class Type_AnyPointer_Unconstrained extends index_1.Struct { + isAnyKind() { return index_1.Struct.getUint16(10, this) === 0; } + setAnyKind() { index_1.Struct.setUint16(10, 0, this); } + isStruct() { return index_1.Struct.getUint16(10, this) === 1; } + setStruct() { index_1.Struct.setUint16(10, 1, this); } + isList() { return index_1.Struct.getUint16(10, this) === 2; } + setList() { index_1.Struct.setUint16(10, 2, this); } + isCapability() { return index_1.Struct.getUint16(10, this) === 3; } + setCapability() { index_1.Struct.setUint16(10, 3, this); } + toString() { return "Type_AnyPointer_Unconstrained_" + super.toString(); } + which() { return index_1.Struct.getUint16(10, this); } +} +exports.Type_AnyPointer_Unconstrained = Type_AnyPointer_Unconstrained; +Type_AnyPointer_Unconstrained.ANY_KIND = Type_AnyPointer_Unconstrained_Which.ANY_KIND; +Type_AnyPointer_Unconstrained.STRUCT = Type_AnyPointer_Unconstrained_Which.STRUCT; +Type_AnyPointer_Unconstrained.LIST = Type_AnyPointer_Unconstrained_Which.LIST; +Type_AnyPointer_Unconstrained.CAPABILITY = Type_AnyPointer_Unconstrained_Which.CAPABILITY; +Type_AnyPointer_Unconstrained._capnp = { displayName: "unconstrained", id: "8e3b5f79fe593656", size: new index_1.ObjectSize(24, 1) }; +class Type_AnyPointer_Parameter extends index_1.Struct { + getScopeId() { return index_1.Struct.getUint64(16, this); } + setScopeId(value) { index_1.Struct.setUint64(16, value, this); } + getParameterIndex() { return index_1.Struct.getUint16(10, this); } + setParameterIndex(value) { index_1.Struct.setUint16(10, value, this); } + toString() { return "Type_AnyPointer_Parameter_" + super.toString(); } +} +exports.Type_AnyPointer_Parameter = Type_AnyPointer_Parameter; +Type_AnyPointer_Parameter._capnp = { displayName: "parameter", id: "9dd1f724f4614a85", size: new index_1.ObjectSize(24, 1) }; +class Type_AnyPointer_ImplicitMethodParameter extends index_1.Struct { + getParameterIndex() { return index_1.Struct.getUint16(10, this); } + setParameterIndex(value) { index_1.Struct.setUint16(10, value, this); } + toString() { return "Type_AnyPointer_ImplicitMethodParameter_" + super.toString(); } +} +exports.Type_AnyPointer_ImplicitMethodParameter = Type_AnyPointer_ImplicitMethodParameter; +Type_AnyPointer_ImplicitMethodParameter._capnp = { displayName: "implicitMethodParameter", id: "baefc9120c56e274", size: new index_1.ObjectSize(24, 1) }; +var Type_AnyPointer_Which; +(function (Type_AnyPointer_Which) { + Type_AnyPointer_Which[Type_AnyPointer_Which["UNCONSTRAINED"] = 0] = "UNCONSTRAINED"; + Type_AnyPointer_Which[Type_AnyPointer_Which["PARAMETER"] = 1] = "PARAMETER"; + Type_AnyPointer_Which[Type_AnyPointer_Which["IMPLICIT_METHOD_PARAMETER"] = 2] = "IMPLICIT_METHOD_PARAMETER"; +})(Type_AnyPointer_Which = exports.Type_AnyPointer_Which || (exports.Type_AnyPointer_Which = {})); +class Type_AnyPointer extends index_1.Struct { + getUnconstrained() { + index_1.Struct.testWhich("unconstrained", index_1.Struct.getUint16(8, this), 0, this); + return index_1.Struct.getAs(Type_AnyPointer_Unconstrained, this); + } + initUnconstrained() { + index_1.Struct.setUint16(8, 0, this); + return index_1.Struct.getAs(Type_AnyPointer_Unconstrained, this); + } + isUnconstrained() { return index_1.Struct.getUint16(8, this) === 0; } + setUnconstrained() { index_1.Struct.setUint16(8, 0, this); } + getParameter() { + index_1.Struct.testWhich("parameter", index_1.Struct.getUint16(8, this), 1, this); + return index_1.Struct.getAs(Type_AnyPointer_Parameter, this); + } + initParameter() { + index_1.Struct.setUint16(8, 1, this); + return index_1.Struct.getAs(Type_AnyPointer_Parameter, this); + } + isParameter() { return index_1.Struct.getUint16(8, this) === 1; } + setParameter() { index_1.Struct.setUint16(8, 1, this); } + getImplicitMethodParameter() { + index_1.Struct.testWhich("implicitMethodParameter", index_1.Struct.getUint16(8, this), 2, this); + return index_1.Struct.getAs(Type_AnyPointer_ImplicitMethodParameter, this); + } + initImplicitMethodParameter() { + index_1.Struct.setUint16(8, 2, this); + return index_1.Struct.getAs(Type_AnyPointer_ImplicitMethodParameter, this); + } + isImplicitMethodParameter() { return index_1.Struct.getUint16(8, this) === 2; } + setImplicitMethodParameter() { index_1.Struct.setUint16(8, 2, this); } + toString() { return "Type_AnyPointer_" + super.toString(); } + which() { return index_1.Struct.getUint16(8, this); } +} +exports.Type_AnyPointer = Type_AnyPointer; +Type_AnyPointer.UNCONSTRAINED = Type_AnyPointer_Which.UNCONSTRAINED; +Type_AnyPointer.PARAMETER = Type_AnyPointer_Which.PARAMETER; +Type_AnyPointer.IMPLICIT_METHOD_PARAMETER = Type_AnyPointer_Which.IMPLICIT_METHOD_PARAMETER; +Type_AnyPointer._capnp = { displayName: "anyPointer", id: "c2573fe8a23e49f1", size: new index_1.ObjectSize(24, 1) }; +var Type_Which; +(function (Type_Which) { + Type_Which[Type_Which["VOID"] = 0] = "VOID"; + Type_Which[Type_Which["BOOL"] = 1] = "BOOL"; + Type_Which[Type_Which["INT8"] = 2] = "INT8"; + Type_Which[Type_Which["INT16"] = 3] = "INT16"; + Type_Which[Type_Which["INT32"] = 4] = "INT32"; + Type_Which[Type_Which["INT64"] = 5] = "INT64"; + Type_Which[Type_Which["UINT8"] = 6] = "UINT8"; + Type_Which[Type_Which["UINT16"] = 7] = "UINT16"; + Type_Which[Type_Which["UINT32"] = 8] = "UINT32"; + Type_Which[Type_Which["UINT64"] = 9] = "UINT64"; + Type_Which[Type_Which["FLOAT32"] = 10] = "FLOAT32"; + Type_Which[Type_Which["FLOAT64"] = 11] = "FLOAT64"; + Type_Which[Type_Which["TEXT"] = 12] = "TEXT"; + Type_Which[Type_Which["DATA"] = 13] = "DATA"; + Type_Which[Type_Which["LIST"] = 14] = "LIST"; + Type_Which[Type_Which["ENUM"] = 15] = "ENUM"; + Type_Which[Type_Which["STRUCT"] = 16] = "STRUCT"; + Type_Which[Type_Which["INTERFACE"] = 17] = "INTERFACE"; + Type_Which[Type_Which["ANY_POINTER"] = 18] = "ANY_POINTER"; +})(Type_Which = exports.Type_Which || (exports.Type_Which = {})); +class Type extends index_1.Struct { + isVoid() { return index_1.Struct.getUint16(0, this) === 0; } + setVoid() { index_1.Struct.setUint16(0, 0, this); } + isBool() { return index_1.Struct.getUint16(0, this) === 1; } + setBool() { index_1.Struct.setUint16(0, 1, this); } + isInt8() { return index_1.Struct.getUint16(0, this) === 2; } + setInt8() { index_1.Struct.setUint16(0, 2, this); } + isInt16() { return index_1.Struct.getUint16(0, this) === 3; } + setInt16() { index_1.Struct.setUint16(0, 3, this); } + isInt32() { return index_1.Struct.getUint16(0, this) === 4; } + setInt32() { index_1.Struct.setUint16(0, 4, this); } + isInt64() { return index_1.Struct.getUint16(0, this) === 5; } + setInt64() { index_1.Struct.setUint16(0, 5, this); } + isUint8() { return index_1.Struct.getUint16(0, this) === 6; } + setUint8() { index_1.Struct.setUint16(0, 6, this); } + isUint16() { return index_1.Struct.getUint16(0, this) === 7; } + setUint16() { index_1.Struct.setUint16(0, 7, this); } + isUint32() { return index_1.Struct.getUint16(0, this) === 8; } + setUint32() { index_1.Struct.setUint16(0, 8, this); } + isUint64() { return index_1.Struct.getUint16(0, this) === 9; } + setUint64() { index_1.Struct.setUint16(0, 9, this); } + isFloat32() { return index_1.Struct.getUint16(0, this) === 10; } + setFloat32() { index_1.Struct.setUint16(0, 10, this); } + isFloat64() { return index_1.Struct.getUint16(0, this) === 11; } + setFloat64() { index_1.Struct.setUint16(0, 11, this); } + isText() { return index_1.Struct.getUint16(0, this) === 12; } + setText() { index_1.Struct.setUint16(0, 12, this); } + isData() { return index_1.Struct.getUint16(0, this) === 13; } + setData() { index_1.Struct.setUint16(0, 13, this); } + getList() { + index_1.Struct.testWhich("list", index_1.Struct.getUint16(0, this), 14, this); + return index_1.Struct.getAs(Type_List, this); + } + initList() { + index_1.Struct.setUint16(0, 14, this); + return index_1.Struct.getAs(Type_List, this); + } + isList() { return index_1.Struct.getUint16(0, this) === 14; } + setList() { index_1.Struct.setUint16(0, 14, this); } + getEnum() { + index_1.Struct.testWhich("enum", index_1.Struct.getUint16(0, this), 15, this); + return index_1.Struct.getAs(Type_Enum, this); + } + initEnum() { + index_1.Struct.setUint16(0, 15, this); + return index_1.Struct.getAs(Type_Enum, this); + } + isEnum() { return index_1.Struct.getUint16(0, this) === 15; } + setEnum() { index_1.Struct.setUint16(0, 15, this); } + getStruct() { + index_1.Struct.testWhich("struct", index_1.Struct.getUint16(0, this), 16, this); + return index_1.Struct.getAs(Type_Struct, this); + } + initStruct() { + index_1.Struct.setUint16(0, 16, this); + return index_1.Struct.getAs(Type_Struct, this); + } + isStruct() { return index_1.Struct.getUint16(0, this) === 16; } + setStruct() { index_1.Struct.setUint16(0, 16, this); } + getInterface() { + index_1.Struct.testWhich("interface", index_1.Struct.getUint16(0, this), 17, this); + return index_1.Struct.getAs(Type_Interface, this); + } + initInterface() { + index_1.Struct.setUint16(0, 17, this); + return index_1.Struct.getAs(Type_Interface, this); + } + isInterface() { return index_1.Struct.getUint16(0, this) === 17; } + setInterface() { index_1.Struct.setUint16(0, 17, this); } + getAnyPointer() { + index_1.Struct.testWhich("anyPointer", index_1.Struct.getUint16(0, this), 18, this); + return index_1.Struct.getAs(Type_AnyPointer, this); + } + initAnyPointer() { + index_1.Struct.setUint16(0, 18, this); + return index_1.Struct.getAs(Type_AnyPointer, this); + } + isAnyPointer() { return index_1.Struct.getUint16(0, this) === 18; } + setAnyPointer() { index_1.Struct.setUint16(0, 18, this); } + toString() { return "Type_" + super.toString(); } + which() { return index_1.Struct.getUint16(0, this); } +} +exports.Type = Type; +Type.VOID = Type_Which.VOID; +Type.BOOL = Type_Which.BOOL; +Type.INT8 = Type_Which.INT8; +Type.INT16 = Type_Which.INT16; +Type.INT32 = Type_Which.INT32; +Type.INT64 = Type_Which.INT64; +Type.UINT8 = Type_Which.UINT8; +Type.UINT16 = Type_Which.UINT16; +Type.UINT32 = Type_Which.UINT32; +Type.UINT64 = Type_Which.UINT64; +Type.FLOAT32 = Type_Which.FLOAT32; +Type.FLOAT64 = Type_Which.FLOAT64; +Type.TEXT = Type_Which.TEXT; +Type.DATA = Type_Which.DATA; +Type.LIST = Type_Which.LIST; +Type.ENUM = Type_Which.ENUM; +Type.STRUCT = Type_Which.STRUCT; +Type.INTERFACE = Type_Which.INTERFACE; +Type.ANY_POINTER = Type_Which.ANY_POINTER; +Type._capnp = { displayName: "Type", id: "d07378ede1f9cc60", size: new index_1.ObjectSize(24, 1) }; +var Brand_Scope_Which; +(function (Brand_Scope_Which) { + Brand_Scope_Which[Brand_Scope_Which["BIND"] = 0] = "BIND"; + Brand_Scope_Which[Brand_Scope_Which["INHERIT"] = 1] = "INHERIT"; +})(Brand_Scope_Which = exports.Brand_Scope_Which || (exports.Brand_Scope_Which = {})); +class Brand_Scope extends index_1.Struct { + getScopeId() { return index_1.Struct.getUint64(0, this); } + setScopeId(value) { index_1.Struct.setUint64(0, value, this); } + adoptBind(value) { + index_1.Struct.setUint16(8, 0, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownBind() { return index_1.Struct.disown(this.getBind()); } + getBind() { + index_1.Struct.testWhich("bind", index_1.Struct.getUint16(8, this), 0, this); + return index_1.Struct.getList(0, Brand_Scope._Bind, this); + } + hasBind() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initBind(length) { + index_1.Struct.setUint16(8, 0, this); + return index_1.Struct.initList(0, Brand_Scope._Bind, length, this); + } + isBind() { return index_1.Struct.getUint16(8, this) === 0; } + setBind(value) { + index_1.Struct.setUint16(8, 0, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + isInherit() { return index_1.Struct.getUint16(8, this) === 1; } + setInherit() { index_1.Struct.setUint16(8, 1, this); } + toString() { return "Brand_Scope_" + super.toString(); } + which() { return index_1.Struct.getUint16(8, this); } +} +exports.Brand_Scope = Brand_Scope; +Brand_Scope.BIND = Brand_Scope_Which.BIND; +Brand_Scope.INHERIT = Brand_Scope_Which.INHERIT; +Brand_Scope._capnp = { displayName: "Scope", id: "abd73485a9636bc9", size: new index_1.ObjectSize(16, 1) }; +var Brand_Binding_Which; +(function (Brand_Binding_Which) { + Brand_Binding_Which[Brand_Binding_Which["UNBOUND"] = 0] = "UNBOUND"; + Brand_Binding_Which[Brand_Binding_Which["TYPE"] = 1] = "TYPE"; +})(Brand_Binding_Which = exports.Brand_Binding_Which || (exports.Brand_Binding_Which = {})); +class Brand_Binding extends index_1.Struct { + isUnbound() { return index_1.Struct.getUint16(0, this) === 0; } + setUnbound() { index_1.Struct.setUint16(0, 0, this); } + adoptType(value) { + index_1.Struct.setUint16(0, 1, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownType() { return index_1.Struct.disown(this.getType()); } + getType() { + index_1.Struct.testWhich("type", index_1.Struct.getUint16(0, this), 1, this); + return index_1.Struct.getStruct(0, Type, this); + } + hasType() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initType() { + index_1.Struct.setUint16(0, 1, this); + return index_1.Struct.initStructAt(0, Type, this); + } + isType() { return index_1.Struct.getUint16(0, this) === 1; } + setType(value) { + index_1.Struct.setUint16(0, 1, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + toString() { return "Brand_Binding_" + super.toString(); } + which() { return index_1.Struct.getUint16(0, this); } +} +exports.Brand_Binding = Brand_Binding; +Brand_Binding.UNBOUND = Brand_Binding_Which.UNBOUND; +Brand_Binding.TYPE = Brand_Binding_Which.TYPE; +Brand_Binding._capnp = { displayName: "Binding", id: "c863cd16969ee7fc", size: new index_1.ObjectSize(8, 1) }; +class Brand extends index_1.Struct { + adoptScopes(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownScopes() { return index_1.Struct.disown(this.getScopes()); } + getScopes() { return index_1.Struct.getList(0, Brand._Scopes, this); } + hasScopes() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initScopes(length) { return index_1.Struct.initList(0, Brand._Scopes, length, this); } + setScopes(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Brand_" + super.toString(); } +} +exports.Brand = Brand; +Brand.Scope = Brand_Scope; +Brand.Binding = Brand_Binding; +Brand._capnp = { displayName: "Brand", id: "903455f06065422b", size: new index_1.ObjectSize(0, 1) }; +var Value_Which; +(function (Value_Which) { + Value_Which[Value_Which["VOID"] = 0] = "VOID"; + Value_Which[Value_Which["BOOL"] = 1] = "BOOL"; + Value_Which[Value_Which["INT8"] = 2] = "INT8"; + Value_Which[Value_Which["INT16"] = 3] = "INT16"; + Value_Which[Value_Which["INT32"] = 4] = "INT32"; + Value_Which[Value_Which["INT64"] = 5] = "INT64"; + Value_Which[Value_Which["UINT8"] = 6] = "UINT8"; + Value_Which[Value_Which["UINT16"] = 7] = "UINT16"; + Value_Which[Value_Which["UINT32"] = 8] = "UINT32"; + Value_Which[Value_Which["UINT64"] = 9] = "UINT64"; + Value_Which[Value_Which["FLOAT32"] = 10] = "FLOAT32"; + Value_Which[Value_Which["FLOAT64"] = 11] = "FLOAT64"; + Value_Which[Value_Which["TEXT"] = 12] = "TEXT"; + Value_Which[Value_Which["DATA"] = 13] = "DATA"; + Value_Which[Value_Which["LIST"] = 14] = "LIST"; + Value_Which[Value_Which["ENUM"] = 15] = "ENUM"; + Value_Which[Value_Which["STRUCT"] = 16] = "STRUCT"; + Value_Which[Value_Which["INTERFACE"] = 17] = "INTERFACE"; + Value_Which[Value_Which["ANY_POINTER"] = 18] = "ANY_POINTER"; +})(Value_Which = exports.Value_Which || (exports.Value_Which = {})); +class Value extends index_1.Struct { + isVoid() { return index_1.Struct.getUint16(0, this) === 0; } + setVoid() { index_1.Struct.setUint16(0, 0, this); } + getBool() { + index_1.Struct.testWhich("bool", index_1.Struct.getUint16(0, this), 1, this); + return index_1.Struct.getBit(16, this); + } + isBool() { return index_1.Struct.getUint16(0, this) === 1; } + setBool(value) { + index_1.Struct.setUint16(0, 1, this); + index_1.Struct.setBit(16, value, this); + } + getInt8() { + index_1.Struct.testWhich("int8", index_1.Struct.getUint16(0, this), 2, this); + return index_1.Struct.getInt8(2, this); + } + isInt8() { return index_1.Struct.getUint16(0, this) === 2; } + setInt8(value) { + index_1.Struct.setUint16(0, 2, this); + index_1.Struct.setInt8(2, value, this); + } + getInt16() { + index_1.Struct.testWhich("int16", index_1.Struct.getUint16(0, this), 3, this); + return index_1.Struct.getInt16(2, this); + } + isInt16() { return index_1.Struct.getUint16(0, this) === 3; } + setInt16(value) { + index_1.Struct.setUint16(0, 3, this); + index_1.Struct.setInt16(2, value, this); + } + getInt32() { + index_1.Struct.testWhich("int32", index_1.Struct.getUint16(0, this), 4, this); + return index_1.Struct.getInt32(4, this); + } + isInt32() { return index_1.Struct.getUint16(0, this) === 4; } + setInt32(value) { + index_1.Struct.setUint16(0, 4, this); + index_1.Struct.setInt32(4, value, this); + } + getInt64() { + index_1.Struct.testWhich("int64", index_1.Struct.getUint16(0, this), 5, this); + return index_1.Struct.getInt64(8, this); + } + isInt64() { return index_1.Struct.getUint16(0, this) === 5; } + setInt64(value) { + index_1.Struct.setUint16(0, 5, this); + index_1.Struct.setInt64(8, value, this); + } + getUint8() { + index_1.Struct.testWhich("uint8", index_1.Struct.getUint16(0, this), 6, this); + return index_1.Struct.getUint8(2, this); + } + isUint8() { return index_1.Struct.getUint16(0, this) === 6; } + setUint8(value) { + index_1.Struct.setUint16(0, 6, this); + index_1.Struct.setUint8(2, value, this); + } + getUint16() { + index_1.Struct.testWhich("uint16", index_1.Struct.getUint16(0, this), 7, this); + return index_1.Struct.getUint16(2, this); + } + isUint16() { return index_1.Struct.getUint16(0, this) === 7; } + setUint16(value) { + index_1.Struct.setUint16(0, 7, this); + index_1.Struct.setUint16(2, value, this); + } + getUint32() { + index_1.Struct.testWhich("uint32", index_1.Struct.getUint16(0, this), 8, this); + return index_1.Struct.getUint32(4, this); + } + isUint32() { return index_1.Struct.getUint16(0, this) === 8; } + setUint32(value) { + index_1.Struct.setUint16(0, 8, this); + index_1.Struct.setUint32(4, value, this); + } + getUint64() { + index_1.Struct.testWhich("uint64", index_1.Struct.getUint16(0, this), 9, this); + return index_1.Struct.getUint64(8, this); + } + isUint64() { return index_1.Struct.getUint16(0, this) === 9; } + setUint64(value) { + index_1.Struct.setUint16(0, 9, this); + index_1.Struct.setUint64(8, value, this); + } + getFloat32() { + index_1.Struct.testWhich("float32", index_1.Struct.getUint16(0, this), 10, this); + return index_1.Struct.getFloat32(4, this); + } + isFloat32() { return index_1.Struct.getUint16(0, this) === 10; } + setFloat32(value) { + index_1.Struct.setUint16(0, 10, this); + index_1.Struct.setFloat32(4, value, this); + } + getFloat64() { + index_1.Struct.testWhich("float64", index_1.Struct.getUint16(0, this), 11, this); + return index_1.Struct.getFloat64(8, this); + } + isFloat64() { return index_1.Struct.getUint16(0, this) === 11; } + setFloat64(value) { + index_1.Struct.setUint16(0, 11, this); + index_1.Struct.setFloat64(8, value, this); + } + getText() { + index_1.Struct.testWhich("text", index_1.Struct.getUint16(0, this), 12, this); + return index_1.Struct.getText(0, this); + } + isText() { return index_1.Struct.getUint16(0, this) === 12; } + setText(value) { + index_1.Struct.setUint16(0, 12, this); + index_1.Struct.setText(0, value, this); + } + adoptData(value) { + index_1.Struct.setUint16(0, 13, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownData() { return index_1.Struct.disown(this.getData()); } + getData() { + index_1.Struct.testWhich("data", index_1.Struct.getUint16(0, this), 13, this); + return index_1.Struct.getData(0, this); + } + hasData() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initData(length) { + index_1.Struct.setUint16(0, 13, this); + return index_1.Struct.initData(0, length, this); + } + isData() { return index_1.Struct.getUint16(0, this) === 13; } + setData(value) { + index_1.Struct.setUint16(0, 13, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + adoptList(value) { + index_1.Struct.setUint16(0, 14, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownList() { return index_1.Struct.disown(this.getList()); } + getList() { + index_1.Struct.testWhich("list", index_1.Struct.getUint16(0, this), 14, this); + return index_1.Struct.getPointer(0, this); + } + hasList() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + isList() { return index_1.Struct.getUint16(0, this) === 14; } + setList(value) { + index_1.Struct.setUint16(0, 14, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + getEnum() { + index_1.Struct.testWhich("enum", index_1.Struct.getUint16(0, this), 15, this); + return index_1.Struct.getUint16(2, this); + } + isEnum() { return index_1.Struct.getUint16(0, this) === 15; } + setEnum(value) { + index_1.Struct.setUint16(0, 15, this); + index_1.Struct.setUint16(2, value, this); + } + adoptStruct(value) { + index_1.Struct.setUint16(0, 16, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownStruct() { return index_1.Struct.disown(this.getStruct()); } + getStruct() { + index_1.Struct.testWhich("struct", index_1.Struct.getUint16(0, this), 16, this); + return index_1.Struct.getPointer(0, this); + } + hasStruct() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + isStruct() { return index_1.Struct.getUint16(0, this) === 16; } + setStruct(value) { + index_1.Struct.setUint16(0, 16, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + isInterface() { return index_1.Struct.getUint16(0, this) === 17; } + setInterface() { index_1.Struct.setUint16(0, 17, this); } + adoptAnyPointer(value) { + index_1.Struct.setUint16(0, 18, this); + index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); + } + disownAnyPointer() { return index_1.Struct.disown(this.getAnyPointer()); } + getAnyPointer() { + index_1.Struct.testWhich("anyPointer", index_1.Struct.getUint16(0, this), 18, this); + return index_1.Struct.getPointer(0, this); + } + hasAnyPointer() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + isAnyPointer() { return index_1.Struct.getUint16(0, this) === 18; } + setAnyPointer(value) { + index_1.Struct.setUint16(0, 18, this); + index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); + } + toString() { return "Value_" + super.toString(); } + which() { return index_1.Struct.getUint16(0, this); } +} +exports.Value = Value; +Value.VOID = Value_Which.VOID; +Value.BOOL = Value_Which.BOOL; +Value.INT8 = Value_Which.INT8; +Value.INT16 = Value_Which.INT16; +Value.INT32 = Value_Which.INT32; +Value.INT64 = Value_Which.INT64; +Value.UINT8 = Value_Which.UINT8; +Value.UINT16 = Value_Which.UINT16; +Value.UINT32 = Value_Which.UINT32; +Value.UINT64 = Value_Which.UINT64; +Value.FLOAT32 = Value_Which.FLOAT32; +Value.FLOAT64 = Value_Which.FLOAT64; +Value.TEXT = Value_Which.TEXT; +Value.DATA = Value_Which.DATA; +Value.LIST = Value_Which.LIST; +Value.ENUM = Value_Which.ENUM; +Value.STRUCT = Value_Which.STRUCT; +Value.INTERFACE = Value_Which.INTERFACE; +Value.ANY_POINTER = Value_Which.ANY_POINTER; +Value._capnp = { displayName: "Value", id: "ce23dcd2d7b00c9b", size: new index_1.ObjectSize(16, 1) }; +class Annotation extends index_1.Struct { + getId() { return index_1.Struct.getUint64(0, this); } + setId(value) { index_1.Struct.setUint64(0, value, this); } + adoptBrand(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownBrand() { return index_1.Struct.disown(this.getBrand()); } + getBrand() { return index_1.Struct.getStruct(1, Brand, this); } + hasBrand() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initBrand() { return index_1.Struct.initStructAt(1, Brand, this); } + setBrand(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + adoptValue(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownValue() { return index_1.Struct.disown(this.getValue()); } + getValue() { return index_1.Struct.getStruct(0, Value, this); } + hasValue() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initValue() { return index_1.Struct.initStructAt(0, Value, this); } + setValue(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + toString() { return "Annotation_" + super.toString(); } +} +exports.Annotation = Annotation; +Annotation._capnp = { displayName: "Annotation", id: "f1c8950dab257542", size: new index_1.ObjectSize(8, 2) }; +var ElementSize; +(function (ElementSize) { + ElementSize[ElementSize["EMPTY"] = 0] = "EMPTY"; + ElementSize[ElementSize["BIT"] = 1] = "BIT"; + ElementSize[ElementSize["BYTE"] = 2] = "BYTE"; + ElementSize[ElementSize["TWO_BYTES"] = 3] = "TWO_BYTES"; + ElementSize[ElementSize["FOUR_BYTES"] = 4] = "FOUR_BYTES"; + ElementSize[ElementSize["EIGHT_BYTES"] = 5] = "EIGHT_BYTES"; + ElementSize[ElementSize["POINTER"] = 6] = "POINTER"; + ElementSize[ElementSize["INLINE_COMPOSITE"] = 7] = "INLINE_COMPOSITE"; +})(ElementSize = exports.ElementSize || (exports.ElementSize = {})); +class CapnpVersion extends index_1.Struct { + getMajor() { return index_1.Struct.getUint16(0, this); } + setMajor(value) { index_1.Struct.setUint16(0, value, this); } + getMinor() { return index_1.Struct.getUint8(2, this); } + setMinor(value) { index_1.Struct.setUint8(2, value, this); } + getMicro() { return index_1.Struct.getUint8(3, this); } + setMicro(value) { index_1.Struct.setUint8(3, value, this); } + toString() { return "CapnpVersion_" + super.toString(); } +} +exports.CapnpVersion = CapnpVersion; +CapnpVersion._capnp = { displayName: "CapnpVersion", id: "d85d305b7d839963", size: new index_1.ObjectSize(8, 0) }; +class CodeGeneratorRequest_RequestedFile_Import extends index_1.Struct { + getId() { return index_1.Struct.getUint64(0, this); } + setId(value) { index_1.Struct.setUint64(0, value, this); } + getName() { return index_1.Struct.getText(0, this); } + setName(value) { index_1.Struct.setText(0, value, this); } + toString() { return "CodeGeneratorRequest_RequestedFile_Import_" + super.toString(); } +} +exports.CodeGeneratorRequest_RequestedFile_Import = CodeGeneratorRequest_RequestedFile_Import; +CodeGeneratorRequest_RequestedFile_Import._capnp = { displayName: "Import", id: "ae504193122357e5", size: new index_1.ObjectSize(8, 1) }; +class CodeGeneratorRequest_RequestedFile extends index_1.Struct { + getId() { return index_1.Struct.getUint64(0, this); } + setId(value) { index_1.Struct.setUint64(0, value, this); } + getFilename() { return index_1.Struct.getText(0, this); } + setFilename(value) { index_1.Struct.setText(0, value, this); } + adoptImports(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownImports() { return index_1.Struct.disown(this.getImports()); } + getImports() { return index_1.Struct.getList(1, CodeGeneratorRequest_RequestedFile._Imports, this); } + hasImports() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initImports(length) { return index_1.Struct.initList(1, CodeGeneratorRequest_RequestedFile._Imports, length, this); } + setImports(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + toString() { return "CodeGeneratorRequest_RequestedFile_" + super.toString(); } +} +exports.CodeGeneratorRequest_RequestedFile = CodeGeneratorRequest_RequestedFile; +CodeGeneratorRequest_RequestedFile.Import = CodeGeneratorRequest_RequestedFile_Import; +CodeGeneratorRequest_RequestedFile._capnp = { displayName: "RequestedFile", id: "cfea0eb02e810062", size: new index_1.ObjectSize(8, 2) }; +class CodeGeneratorRequest extends index_1.Struct { + adoptCapnpVersion(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(2, this)); } + disownCapnpVersion() { return index_1.Struct.disown(this.getCapnpVersion()); } + getCapnpVersion() { return index_1.Struct.getStruct(2, CapnpVersion, this); } + hasCapnpVersion() { return !index_1.Struct.isNull(index_1.Struct.getPointer(2, this)); } + initCapnpVersion() { return index_1.Struct.initStructAt(2, CapnpVersion, this); } + setCapnpVersion(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(2, this)); } + adoptNodes(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(0, this)); } + disownNodes() { return index_1.Struct.disown(this.getNodes()); } + getNodes() { return index_1.Struct.getList(0, CodeGeneratorRequest._Nodes, this); } + hasNodes() { return !index_1.Struct.isNull(index_1.Struct.getPointer(0, this)); } + initNodes(length) { return index_1.Struct.initList(0, CodeGeneratorRequest._Nodes, length, this); } + setNodes(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(0, this)); } + adoptRequestedFiles(value) { index_1.Struct.adopt(value, index_1.Struct.getPointer(1, this)); } + disownRequestedFiles() { return index_1.Struct.disown(this.getRequestedFiles()); } + getRequestedFiles() { return index_1.Struct.getList(1, CodeGeneratorRequest._RequestedFiles, this); } + hasRequestedFiles() { return !index_1.Struct.isNull(index_1.Struct.getPointer(1, this)); } + initRequestedFiles(length) { return index_1.Struct.initList(1, CodeGeneratorRequest._RequestedFiles, length, this); } + setRequestedFiles(value) { index_1.Struct.copyFrom(value, index_1.Struct.getPointer(1, this)); } + toString() { return "CodeGeneratorRequest_" + super.toString(); } +} +exports.CodeGeneratorRequest = CodeGeneratorRequest; +CodeGeneratorRequest.RequestedFile = CodeGeneratorRequest_RequestedFile; +CodeGeneratorRequest._capnp = { displayName: "CodeGeneratorRequest", id: "bfc546f6210ad7ce", size: new index_1.ObjectSize(0, 3) }; +Node_Struct._Fields = capnp.CompositeList(Field); +Node_Enum._Enumerants = capnp.CompositeList(Enumerant); +Node_Interface._Methods = capnp.CompositeList(Method); +Node_Interface._Superclasses = capnp.CompositeList(Superclass); +Node._Parameters = capnp.CompositeList(Node_Parameter); +Node._NestedNodes = capnp.CompositeList(Node_NestedNode); +Node._Annotations = capnp.CompositeList(Annotation); +Field._Annotations = capnp.CompositeList(Annotation); +Enumerant._Annotations = capnp.CompositeList(Annotation); +Method._ImplicitParameters = capnp.CompositeList(Node_Parameter); +Method._Annotations = capnp.CompositeList(Annotation); +Brand_Scope._Bind = capnp.CompositeList(Brand_Binding); +Brand._Scopes = capnp.CompositeList(Brand_Scope); +CodeGeneratorRequest_RequestedFile._Imports = capnp.CompositeList(CodeGeneratorRequest_RequestedFile_Import); +CodeGeneratorRequest._Nodes = capnp.CompositeList(Node); +CodeGeneratorRequest._RequestedFiles = capnp.CompositeList(CodeGeneratorRequest_RequestedFile); +//# sourceMappingURL=schema.capnp.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/schema.capnp.js.map b/node_modules/capnp-ts/src/std/schema.capnp.js.map new file mode 100644 index 0000000000000000000000000000000000000000..6fa4e1fe93b151a6241901e36e31336b10f55789 --- /dev/null +++ b/node_modules/capnp-ts/src/std/schema.capnp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.capnp.js","sourceRoot":"","sources":["schema.capnp.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,wDAAkC;AAClC,oCAA4D;AAC/C,QAAA,YAAY,GAAG,kBAAkB,CAAC;AAC/C,MAAa,cAAe,SAAQ,cAAG;IAEnC,OAAO,KAAa,OAAO,cAAG,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,KAAa,IAAU,cAAG,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7D,QAAQ,KAAa,OAAO,iBAAiB,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;;AAJvE,wCAKC;AAJmB,qBAAM,GAAG,EAAE,WAAW,EAAE,WAA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,aAAa,CAAC,SAAS,CAAC,CAAC;AACvD,cAAc,CAAC,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AACtD,cAAc,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AAC/D,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;AACvD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;AACzD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACpD,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACrD,SAAS,CAAC,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACzD,MAAM,CAAC,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;AACjE,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACtD,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;AACvD,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;AACjD,kCAAkC,CAAC,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,yCAAyC,CAAC,CAAC;AAC7G,oBAAoB,CAAC,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AACxD,oBAAoB,CAAC,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,kCAAkC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/schema.capnp.ts b/node_modules/capnp-ts/src/std/schema.capnp.ts new file mode 100644 index 0000000000000000000000000000000000000000..5b713f1d0d896f9a8a059dabfd00837e56309b21 --- /dev/null +++ b/node_modules/capnp-ts/src/std/schema.capnp.ts @@ -0,0 +1,1050 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ + +import * as capnp from "../index"; +import { ObjectSize as __O, Struct as __S } from "../index"; +export const _capnpFileId = "a93fc509624c72d9"; +export class Node_Parameter extends __S { + static readonly _capnp = { displayName: "Parameter", id: "b9521bccf10fa3b1", size: new __O(0, 1) }; + getName(): string { return __S.getText(0, this); } + setName(value: string): void { __S.setText(0, value, this); } + toString(): string { return "Node_Parameter_" + super.toString(); } +} +export class Node_NestedNode extends __S { + static readonly _capnp = { displayName: "NestedNode", id: "debf55bbfa0fc242", size: new __O(8, 1) }; + getName(): string { return __S.getText(0, this); } + setName(value: string): void { __S.setText(0, value, this); } + getId(): capnp.Uint64 { return __S.getUint64(0, this); } + setId(value: capnp.Uint64): void { __S.setUint64(0, value, this); } + toString(): string { return "Node_NestedNode_" + super.toString(); } +} +export class Node_Struct extends __S { + static readonly _capnp = { displayName: "struct", id: "9ea0b19b37fb4435", size: new __O(40, 6) }; + static _Fields: capnp.ListCtor; + getDataWordCount(): number { return __S.getUint16(14, this); } + setDataWordCount(value: number): void { __S.setUint16(14, value, this); } + getPointerCount(): number { return __S.getUint16(24, this); } + setPointerCount(value: number): void { __S.setUint16(24, value, this); } + getPreferredListEncoding(): ElementSize { return __S.getUint16(26, this); } + setPreferredListEncoding(value: ElementSize): void { __S.setUint16(26, value, this); } + getIsGroup(): boolean { return __S.getBit(224, this); } + setIsGroup(value: boolean): void { __S.setBit(224, value, this); } + getDiscriminantCount(): number { return __S.getUint16(30, this); } + setDiscriminantCount(value: number): void { __S.setUint16(30, value, this); } + getDiscriminantOffset(): number { return __S.getUint32(32, this); } + setDiscriminantOffset(value: number): void { __S.setUint32(32, value, this); } + adoptFields(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(3, this)); } + disownFields(): capnp.Orphan> { return __S.disown(this.getFields()); } + getFields(): capnp.List { return __S.getList(3, Node_Struct._Fields, this); } + hasFields(): boolean { return !__S.isNull(__S.getPointer(3, this)); } + initFields(length: number): capnp.List { return __S.initList(3, Node_Struct._Fields, length, this); } + setFields(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(3, this)); } + toString(): string { return "Node_Struct_" + super.toString(); } +} +export class Node_Enum extends __S { + static readonly _capnp = { displayName: "enum", id: "b54ab3364333f598", size: new __O(40, 6) }; + static _Enumerants: capnp.ListCtor; + adoptEnumerants(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(3, this)); } + disownEnumerants(): capnp.Orphan> { return __S.disown(this.getEnumerants()); } + getEnumerants(): capnp.List { return __S.getList(3, Node_Enum._Enumerants, this); } + hasEnumerants(): boolean { return !__S.isNull(__S.getPointer(3, this)); } + initEnumerants(length: number): capnp.List { return __S.initList(3, Node_Enum._Enumerants, length, this); } + setEnumerants(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(3, this)); } + toString(): string { return "Node_Enum_" + super.toString(); } +} +export class Node_Interface extends __S { + static readonly _capnp = { displayName: "interface", id: "e82753cff0c2218f", size: new __O(40, 6) }; + static _Methods: capnp.ListCtor; + static _Superclasses: capnp.ListCtor; + adoptMethods(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(3, this)); } + disownMethods(): capnp.Orphan> { return __S.disown(this.getMethods()); } + getMethods(): capnp.List { return __S.getList(3, Node_Interface._Methods, this); } + hasMethods(): boolean { return !__S.isNull(__S.getPointer(3, this)); } + initMethods(length: number): capnp.List { return __S.initList(3, Node_Interface._Methods, length, this); } + setMethods(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(3, this)); } + adoptSuperclasses(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(4, this)); } + disownSuperclasses(): capnp.Orphan> { return __S.disown(this.getSuperclasses()); } + getSuperclasses(): capnp.List { return __S.getList(4, Node_Interface._Superclasses, this); } + hasSuperclasses(): boolean { return !__S.isNull(__S.getPointer(4, this)); } + initSuperclasses(length: number): capnp.List { return __S.initList(4, Node_Interface._Superclasses, length, this); } + setSuperclasses(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(4, this)); } + toString(): string { return "Node_Interface_" + super.toString(); } +} +export class Node_Const extends __S { + static readonly _capnp = { displayName: "const", id: "b18aa5ac7a0d9420", size: new __O(40, 6) }; + adoptType(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(3, this)); } + disownType(): capnp.Orphan { return __S.disown(this.getType()); } + getType(): Type { return __S.getStruct(3, Type, this); } + hasType(): boolean { return !__S.isNull(__S.getPointer(3, this)); } + initType(): Type { return __S.initStructAt(3, Type, this); } + setType(value: Type): void { __S.copyFrom(value, __S.getPointer(3, this)); } + adoptValue(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(4, this)); } + disownValue(): capnp.Orphan { return __S.disown(this.getValue()); } + getValue(): Value { return __S.getStruct(4, Value, this); } + hasValue(): boolean { return !__S.isNull(__S.getPointer(4, this)); } + initValue(): Value { return __S.initStructAt(4, Value, this); } + setValue(value: Value): void { __S.copyFrom(value, __S.getPointer(4, this)); } + toString(): string { return "Node_Const_" + super.toString(); } +} +export class Node_Annotation extends __S { + static readonly _capnp = { displayName: "annotation", id: "ec1619d4400a0290", size: new __O(40, 6) }; + adoptType(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(3, this)); } + disownType(): capnp.Orphan { return __S.disown(this.getType()); } + getType(): Type { return __S.getStruct(3, Type, this); } + hasType(): boolean { return !__S.isNull(__S.getPointer(3, this)); } + initType(): Type { return __S.initStructAt(3, Type, this); } + setType(value: Type): void { __S.copyFrom(value, __S.getPointer(3, this)); } + getTargetsFile(): boolean { return __S.getBit(112, this); } + setTargetsFile(value: boolean): void { __S.setBit(112, value, this); } + getTargetsConst(): boolean { return __S.getBit(113, this); } + setTargetsConst(value: boolean): void { __S.setBit(113, value, this); } + getTargetsEnum(): boolean { return __S.getBit(114, this); } + setTargetsEnum(value: boolean): void { __S.setBit(114, value, this); } + getTargetsEnumerant(): boolean { return __S.getBit(115, this); } + setTargetsEnumerant(value: boolean): void { __S.setBit(115, value, this); } + getTargetsStruct(): boolean { return __S.getBit(116, this); } + setTargetsStruct(value: boolean): void { __S.setBit(116, value, this); } + getTargetsField(): boolean { return __S.getBit(117, this); } + setTargetsField(value: boolean): void { __S.setBit(117, value, this); } + getTargetsUnion(): boolean { return __S.getBit(118, this); } + setTargetsUnion(value: boolean): void { __S.setBit(118, value, this); } + getTargetsGroup(): boolean { return __S.getBit(119, this); } + setTargetsGroup(value: boolean): void { __S.setBit(119, value, this); } + getTargetsInterface(): boolean { return __S.getBit(120, this); } + setTargetsInterface(value: boolean): void { __S.setBit(120, value, this); } + getTargetsMethod(): boolean { return __S.getBit(121, this); } + setTargetsMethod(value: boolean): void { __S.setBit(121, value, this); } + getTargetsParam(): boolean { return __S.getBit(122, this); } + setTargetsParam(value: boolean): void { __S.setBit(122, value, this); } + getTargetsAnnotation(): boolean { return __S.getBit(123, this); } + setTargetsAnnotation(value: boolean): void { __S.setBit(123, value, this); } + toString(): string { return "Node_Annotation_" + super.toString(); } +} +export enum Node_Which { + FILE = 0, + STRUCT = 1, + ENUM = 2, + INTERFACE = 3, + CONST = 4, + ANNOTATION = 5 +} +export class Node extends __S { + static readonly FILE = Node_Which.FILE; + static readonly STRUCT = Node_Which.STRUCT; + static readonly ENUM = Node_Which.ENUM; + static readonly INTERFACE = Node_Which.INTERFACE; + static readonly CONST = Node_Which.CONST; + static readonly ANNOTATION = Node_Which.ANNOTATION; + static readonly Parameter = Node_Parameter; + static readonly NestedNode = Node_NestedNode; + static readonly _capnp = { displayName: "Node", id: "e682ab4cf923a417", size: new __O(40, 6) }; + static _Parameters: capnp.ListCtor; + static _NestedNodes: capnp.ListCtor; + static _Annotations: capnp.ListCtor; + getId(): capnp.Uint64 { return __S.getUint64(0, this); } + setId(value: capnp.Uint64): void { __S.setUint64(0, value, this); } + getDisplayName(): string { return __S.getText(0, this); } + setDisplayName(value: string): void { __S.setText(0, value, this); } + getDisplayNamePrefixLength(): number { return __S.getUint32(8, this); } + setDisplayNamePrefixLength(value: number): void { __S.setUint32(8, value, this); } + getScopeId(): capnp.Uint64 { return __S.getUint64(16, this); } + setScopeId(value: capnp.Uint64): void { __S.setUint64(16, value, this); } + adoptParameters(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(5, this)); } + disownParameters(): capnp.Orphan> { return __S.disown(this.getParameters()); } + getParameters(): capnp.List { return __S.getList(5, Node._Parameters, this); } + hasParameters(): boolean { return !__S.isNull(__S.getPointer(5, this)); } + initParameters(length: number): capnp.List { return __S.initList(5, Node._Parameters, length, this); } + setParameters(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(5, this)); } + getIsGeneric(): boolean { return __S.getBit(288, this); } + setIsGeneric(value: boolean): void { __S.setBit(288, value, this); } + adoptNestedNodes(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(1, this)); } + disownNestedNodes(): capnp.Orphan> { return __S.disown(this.getNestedNodes()); } + getNestedNodes(): capnp.List { return __S.getList(1, Node._NestedNodes, this); } + hasNestedNodes(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initNestedNodes(length: number): capnp.List { return __S.initList(1, Node._NestedNodes, length, this); } + setNestedNodes(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(1, this)); } + adoptAnnotations(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(2, this)); } + disownAnnotations(): capnp.Orphan> { return __S.disown(this.getAnnotations()); } + getAnnotations(): capnp.List { return __S.getList(2, Node._Annotations, this); } + hasAnnotations(): boolean { return !__S.isNull(__S.getPointer(2, this)); } + initAnnotations(length: number): capnp.List { return __S.initList(2, Node._Annotations, length, this); } + setAnnotations(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(2, this)); } + isFile(): boolean { return __S.getUint16(12, this) === 0; } + setFile(): void { __S.setUint16(12, 0, this); } + getStruct(): Node_Struct { + __S.testWhich("struct", __S.getUint16(12, this), 1, this); + return __S.getAs(Node_Struct, this); + } + initStruct(): Node_Struct { + __S.setUint16(12, 1, this); + return __S.getAs(Node_Struct, this); + } + isStruct(): boolean { return __S.getUint16(12, this) === 1; } + setStruct(): void { __S.setUint16(12, 1, this); } + getEnum(): Node_Enum { + __S.testWhich("enum", __S.getUint16(12, this), 2, this); + return __S.getAs(Node_Enum, this); + } + initEnum(): Node_Enum { + __S.setUint16(12, 2, this); + return __S.getAs(Node_Enum, this); + } + isEnum(): boolean { return __S.getUint16(12, this) === 2; } + setEnum(): void { __S.setUint16(12, 2, this); } + getInterface(): Node_Interface { + __S.testWhich("interface", __S.getUint16(12, this), 3, this); + return __S.getAs(Node_Interface, this); + } + initInterface(): Node_Interface { + __S.setUint16(12, 3, this); + return __S.getAs(Node_Interface, this); + } + isInterface(): boolean { return __S.getUint16(12, this) === 3; } + setInterface(): void { __S.setUint16(12, 3, this); } + getConst(): Node_Const { + __S.testWhich("const", __S.getUint16(12, this), 4, this); + return __S.getAs(Node_Const, this); + } + initConst(): Node_Const { + __S.setUint16(12, 4, this); + return __S.getAs(Node_Const, this); + } + isConst(): boolean { return __S.getUint16(12, this) === 4; } + setConst(): void { __S.setUint16(12, 4, this); } + getAnnotation(): Node_Annotation { + __S.testWhich("annotation", __S.getUint16(12, this), 5, this); + return __S.getAs(Node_Annotation, this); + } + initAnnotation(): Node_Annotation { + __S.setUint16(12, 5, this); + return __S.getAs(Node_Annotation, this); + } + isAnnotation(): boolean { return __S.getUint16(12, this) === 5; } + setAnnotation(): void { __S.setUint16(12, 5, this); } + toString(): string { return "Node_" + super.toString(); } + which(): Node_Which { return __S.getUint16(12, this); } +} +export class Field_Slot extends __S { + static readonly _capnp = { displayName: "slot", id: "c42305476bb4746f", size: new __O(24, 4) }; + getOffset(): number { return __S.getUint32(4, this); } + setOffset(value: number): void { __S.setUint32(4, value, this); } + adoptType(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(2, this)); } + disownType(): capnp.Orphan { return __S.disown(this.getType()); } + getType(): Type { return __S.getStruct(2, Type, this); } + hasType(): boolean { return !__S.isNull(__S.getPointer(2, this)); } + initType(): Type { return __S.initStructAt(2, Type, this); } + setType(value: Type): void { __S.copyFrom(value, __S.getPointer(2, this)); } + adoptDefaultValue(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(3, this)); } + disownDefaultValue(): capnp.Orphan { return __S.disown(this.getDefaultValue()); } + getDefaultValue(): Value { return __S.getStruct(3, Value, this); } + hasDefaultValue(): boolean { return !__S.isNull(__S.getPointer(3, this)); } + initDefaultValue(): Value { return __S.initStructAt(3, Value, this); } + setDefaultValue(value: Value): void { __S.copyFrom(value, __S.getPointer(3, this)); } + getHadExplicitDefault(): boolean { return __S.getBit(128, this); } + setHadExplicitDefault(value: boolean): void { __S.setBit(128, value, this); } + toString(): string { return "Field_Slot_" + super.toString(); } +} +export class Field_Group extends __S { + static readonly _capnp = { displayName: "group", id: "cafccddb68db1d11", size: new __O(24, 4) }; + getTypeId(): capnp.Uint64 { return __S.getUint64(16, this); } + setTypeId(value: capnp.Uint64): void { __S.setUint64(16, value, this); } + toString(): string { return "Field_Group_" + super.toString(); } +} +export enum Field_Ordinal_Which { + IMPLICIT = 0, + EXPLICIT = 1 +} +export class Field_Ordinal extends __S { + static readonly IMPLICIT = Field_Ordinal_Which.IMPLICIT; + static readonly EXPLICIT = Field_Ordinal_Which.EXPLICIT; + static readonly _capnp = { displayName: "ordinal", id: "bb90d5c287870be6", size: new __O(24, 4) }; + isImplicit(): boolean { return __S.getUint16(10, this) === 0; } + setImplicit(): void { __S.setUint16(10, 0, this); } + getExplicit(): number { + __S.testWhich("explicit", __S.getUint16(10, this), 1, this); + return __S.getUint16(12, this); + } + isExplicit(): boolean { return __S.getUint16(10, this) === 1; } + setExplicit(value: number): void { + __S.setUint16(10, 1, this); + __S.setUint16(12, value, this); + } + toString(): string { return "Field_Ordinal_" + super.toString(); } + which(): Field_Ordinal_Which { return __S.getUint16(10, this); } +} +export enum Field_Which { + SLOT = 0, + GROUP = 1 +} +export class Field extends __S { + static readonly NO_DISCRIMINANT = 65535; + static readonly SLOT = Field_Which.SLOT; + static readonly GROUP = Field_Which.GROUP; + static readonly _capnp = { displayName: "Field", id: "9aad50a41f4af45f", size: new __O(24, 4), defaultDiscriminantValue: capnp.getUint16Mask(65535) }; + static _Annotations: capnp.ListCtor; + getName(): string { return __S.getText(0, this); } + setName(value: string): void { __S.setText(0, value, this); } + getCodeOrder(): number { return __S.getUint16(0, this); } + setCodeOrder(value: number): void { __S.setUint16(0, value, this); } + adoptAnnotations(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(1, this)); } + disownAnnotations(): capnp.Orphan> { return __S.disown(this.getAnnotations()); } + getAnnotations(): capnp.List { return __S.getList(1, Field._Annotations, this); } + hasAnnotations(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initAnnotations(length: number): capnp.List { return __S.initList(1, Field._Annotations, length, this); } + setAnnotations(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(1, this)); } + getDiscriminantValue(): number { return __S.getUint16(2, this, Field._capnp.defaultDiscriminantValue); } + setDiscriminantValue(value: number): void { __S.setUint16(2, value, this); } + getSlot(): Field_Slot { + __S.testWhich("slot", __S.getUint16(8, this), 0, this); + return __S.getAs(Field_Slot, this); + } + initSlot(): Field_Slot { + __S.setUint16(8, 0, this); + return __S.getAs(Field_Slot, this); + } + isSlot(): boolean { return __S.getUint16(8, this) === 0; } + setSlot(): void { __S.setUint16(8, 0, this); } + getGroup(): Field_Group { + __S.testWhich("group", __S.getUint16(8, this), 1, this); + return __S.getAs(Field_Group, this); + } + initGroup(): Field_Group { + __S.setUint16(8, 1, this); + return __S.getAs(Field_Group, this); + } + isGroup(): boolean { return __S.getUint16(8, this) === 1; } + setGroup(): void { __S.setUint16(8, 1, this); } + getOrdinal(): Field_Ordinal { return __S.getAs(Field_Ordinal, this); } + initOrdinal(): Field_Ordinal { return __S.getAs(Field_Ordinal, this); } + toString(): string { return "Field_" + super.toString(); } + which(): Field_Which { return __S.getUint16(8, this); } +} +export class Enumerant extends __S { + static readonly _capnp = { displayName: "Enumerant", id: "978a7cebdc549a4d", size: new __O(8, 2) }; + static _Annotations: capnp.ListCtor; + getName(): string { return __S.getText(0, this); } + setName(value: string): void { __S.setText(0, value, this); } + getCodeOrder(): number { return __S.getUint16(0, this); } + setCodeOrder(value: number): void { __S.setUint16(0, value, this); } + adoptAnnotations(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(1, this)); } + disownAnnotations(): capnp.Orphan> { return __S.disown(this.getAnnotations()); } + getAnnotations(): capnp.List { return __S.getList(1, Enumerant._Annotations, this); } + hasAnnotations(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initAnnotations(length: number): capnp.List { return __S.initList(1, Enumerant._Annotations, length, this); } + setAnnotations(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(1, this)); } + toString(): string { return "Enumerant_" + super.toString(); } +} +export class Superclass extends __S { + static readonly _capnp = { displayName: "Superclass", id: "a9962a9ed0a4d7f8", size: new __O(8, 1) }; + getId(): capnp.Uint64 { return __S.getUint64(0, this); } + setId(value: capnp.Uint64): void { __S.setUint64(0, value, this); } + adoptBrand(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownBrand(): capnp.Orphan { return __S.disown(this.getBrand()); } + getBrand(): Brand { return __S.getStruct(0, Brand, this); } + hasBrand(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initBrand(): Brand { return __S.initStructAt(0, Brand, this); } + setBrand(value: Brand): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Superclass_" + super.toString(); } +} +export class Method extends __S { + static readonly _capnp = { displayName: "Method", id: "9500cce23b334d80", size: new __O(24, 5) }; + static _ImplicitParameters: capnp.ListCtor; + static _Annotations: capnp.ListCtor; + getName(): string { return __S.getText(0, this); } + setName(value: string): void { __S.setText(0, value, this); } + getCodeOrder(): number { return __S.getUint16(0, this); } + setCodeOrder(value: number): void { __S.setUint16(0, value, this); } + adoptImplicitParameters(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(4, this)); } + disownImplicitParameters(): capnp.Orphan> { return __S.disown(this.getImplicitParameters()); } + getImplicitParameters(): capnp.List { return __S.getList(4, Method._ImplicitParameters, this); } + hasImplicitParameters(): boolean { return !__S.isNull(__S.getPointer(4, this)); } + initImplicitParameters(length: number): capnp.List { return __S.initList(4, Method._ImplicitParameters, length, this); } + setImplicitParameters(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(4, this)); } + getParamStructType(): capnp.Uint64 { return __S.getUint64(8, this); } + setParamStructType(value: capnp.Uint64): void { __S.setUint64(8, value, this); } + adoptParamBrand(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(2, this)); } + disownParamBrand(): capnp.Orphan { return __S.disown(this.getParamBrand()); } + getParamBrand(): Brand { return __S.getStruct(2, Brand, this); } + hasParamBrand(): boolean { return !__S.isNull(__S.getPointer(2, this)); } + initParamBrand(): Brand { return __S.initStructAt(2, Brand, this); } + setParamBrand(value: Brand): void { __S.copyFrom(value, __S.getPointer(2, this)); } + getResultStructType(): capnp.Uint64 { return __S.getUint64(16, this); } + setResultStructType(value: capnp.Uint64): void { __S.setUint64(16, value, this); } + adoptResultBrand(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(3, this)); } + disownResultBrand(): capnp.Orphan { return __S.disown(this.getResultBrand()); } + getResultBrand(): Brand { return __S.getStruct(3, Brand, this); } + hasResultBrand(): boolean { return !__S.isNull(__S.getPointer(3, this)); } + initResultBrand(): Brand { return __S.initStructAt(3, Brand, this); } + setResultBrand(value: Brand): void { __S.copyFrom(value, __S.getPointer(3, this)); } + adoptAnnotations(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(1, this)); } + disownAnnotations(): capnp.Orphan> { return __S.disown(this.getAnnotations()); } + getAnnotations(): capnp.List { return __S.getList(1, Method._Annotations, this); } + hasAnnotations(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initAnnotations(length: number): capnp.List { return __S.initList(1, Method._Annotations, length, this); } + setAnnotations(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(1, this)); } + toString(): string { return "Method_" + super.toString(); } +} +export class Type_List extends __S { + static readonly _capnp = { displayName: "list", id: "87e739250a60ea97", size: new __O(24, 1) }; + adoptElementType(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownElementType(): capnp.Orphan { return __S.disown(this.getElementType()); } + getElementType(): Type { return __S.getStruct(0, Type, this); } + hasElementType(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initElementType(): Type { return __S.initStructAt(0, Type, this); } + setElementType(value: Type): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Type_List_" + super.toString(); } +} +export class Type_Enum extends __S { + static readonly _capnp = { displayName: "enum", id: "9e0e78711a7f87a9", size: new __O(24, 1) }; + getTypeId(): capnp.Uint64 { return __S.getUint64(8, this); } + setTypeId(value: capnp.Uint64): void { __S.setUint64(8, value, this); } + adoptBrand(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownBrand(): capnp.Orphan { return __S.disown(this.getBrand()); } + getBrand(): Brand { return __S.getStruct(0, Brand, this); } + hasBrand(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initBrand(): Brand { return __S.initStructAt(0, Brand, this); } + setBrand(value: Brand): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Type_Enum_" + super.toString(); } +} +export class Type_Struct extends __S { + static readonly _capnp = { displayName: "struct", id: "ac3a6f60ef4cc6d3", size: new __O(24, 1) }; + getTypeId(): capnp.Uint64 { return __S.getUint64(8, this); } + setTypeId(value: capnp.Uint64): void { __S.setUint64(8, value, this); } + adoptBrand(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownBrand(): capnp.Orphan { return __S.disown(this.getBrand()); } + getBrand(): Brand { return __S.getStruct(0, Brand, this); } + hasBrand(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initBrand(): Brand { return __S.initStructAt(0, Brand, this); } + setBrand(value: Brand): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Type_Struct_" + super.toString(); } +} +export class Type_Interface extends __S { + static readonly _capnp = { displayName: "interface", id: "ed8bca69f7fb0cbf", size: new __O(24, 1) }; + getTypeId(): capnp.Uint64 { return __S.getUint64(8, this); } + setTypeId(value: capnp.Uint64): void { __S.setUint64(8, value, this); } + adoptBrand(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownBrand(): capnp.Orphan { return __S.disown(this.getBrand()); } + getBrand(): Brand { return __S.getStruct(0, Brand, this); } + hasBrand(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initBrand(): Brand { return __S.initStructAt(0, Brand, this); } + setBrand(value: Brand): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Type_Interface_" + super.toString(); } +} +export enum Type_AnyPointer_Unconstrained_Which { + ANY_KIND = 0, + STRUCT = 1, + LIST = 2, + CAPABILITY = 3 +} +export class Type_AnyPointer_Unconstrained extends __S { + static readonly ANY_KIND = Type_AnyPointer_Unconstrained_Which.ANY_KIND; + static readonly STRUCT = Type_AnyPointer_Unconstrained_Which.STRUCT; + static readonly LIST = Type_AnyPointer_Unconstrained_Which.LIST; + static readonly CAPABILITY = Type_AnyPointer_Unconstrained_Which.CAPABILITY; + static readonly _capnp = { displayName: "unconstrained", id: "8e3b5f79fe593656", size: new __O(24, 1) }; + isAnyKind(): boolean { return __S.getUint16(10, this) === 0; } + setAnyKind(): void { __S.setUint16(10, 0, this); } + isStruct(): boolean { return __S.getUint16(10, this) === 1; } + setStruct(): void { __S.setUint16(10, 1, this); } + isList(): boolean { return __S.getUint16(10, this) === 2; } + setList(): void { __S.setUint16(10, 2, this); } + isCapability(): boolean { return __S.getUint16(10, this) === 3; } + setCapability(): void { __S.setUint16(10, 3, this); } + toString(): string { return "Type_AnyPointer_Unconstrained_" + super.toString(); } + which(): Type_AnyPointer_Unconstrained_Which { return __S.getUint16(10, this); } +} +export class Type_AnyPointer_Parameter extends __S { + static readonly _capnp = { displayName: "parameter", id: "9dd1f724f4614a85", size: new __O(24, 1) }; + getScopeId(): capnp.Uint64 { return __S.getUint64(16, this); } + setScopeId(value: capnp.Uint64): void { __S.setUint64(16, value, this); } + getParameterIndex(): number { return __S.getUint16(10, this); } + setParameterIndex(value: number): void { __S.setUint16(10, value, this); } + toString(): string { return "Type_AnyPointer_Parameter_" + super.toString(); } +} +export class Type_AnyPointer_ImplicitMethodParameter extends __S { + static readonly _capnp = { displayName: "implicitMethodParameter", id: "baefc9120c56e274", size: new __O(24, 1) }; + getParameterIndex(): number { return __S.getUint16(10, this); } + setParameterIndex(value: number): void { __S.setUint16(10, value, this); } + toString(): string { return "Type_AnyPointer_ImplicitMethodParameter_" + super.toString(); } +} +export enum Type_AnyPointer_Which { + UNCONSTRAINED = 0, + PARAMETER = 1, + IMPLICIT_METHOD_PARAMETER = 2 +} +export class Type_AnyPointer extends __S { + static readonly UNCONSTRAINED = Type_AnyPointer_Which.UNCONSTRAINED; + static readonly PARAMETER = Type_AnyPointer_Which.PARAMETER; + static readonly IMPLICIT_METHOD_PARAMETER = Type_AnyPointer_Which.IMPLICIT_METHOD_PARAMETER; + static readonly _capnp = { displayName: "anyPointer", id: "c2573fe8a23e49f1", size: new __O(24, 1) }; + getUnconstrained(): Type_AnyPointer_Unconstrained { + __S.testWhich("unconstrained", __S.getUint16(8, this), 0, this); + return __S.getAs(Type_AnyPointer_Unconstrained, this); + } + initUnconstrained(): Type_AnyPointer_Unconstrained { + __S.setUint16(8, 0, this); + return __S.getAs(Type_AnyPointer_Unconstrained, this); + } + isUnconstrained(): boolean { return __S.getUint16(8, this) === 0; } + setUnconstrained(): void { __S.setUint16(8, 0, this); } + getParameter(): Type_AnyPointer_Parameter { + __S.testWhich("parameter", __S.getUint16(8, this), 1, this); + return __S.getAs(Type_AnyPointer_Parameter, this); + } + initParameter(): Type_AnyPointer_Parameter { + __S.setUint16(8, 1, this); + return __S.getAs(Type_AnyPointer_Parameter, this); + } + isParameter(): boolean { return __S.getUint16(8, this) === 1; } + setParameter(): void { __S.setUint16(8, 1, this); } + getImplicitMethodParameter(): Type_AnyPointer_ImplicitMethodParameter { + __S.testWhich("implicitMethodParameter", __S.getUint16(8, this), 2, this); + return __S.getAs(Type_AnyPointer_ImplicitMethodParameter, this); + } + initImplicitMethodParameter(): Type_AnyPointer_ImplicitMethodParameter { + __S.setUint16(8, 2, this); + return __S.getAs(Type_AnyPointer_ImplicitMethodParameter, this); + } + isImplicitMethodParameter(): boolean { return __S.getUint16(8, this) === 2; } + setImplicitMethodParameter(): void { __S.setUint16(8, 2, this); } + toString(): string { return "Type_AnyPointer_" + super.toString(); } + which(): Type_AnyPointer_Which { return __S.getUint16(8, this); } +} +export enum Type_Which { + VOID = 0, + BOOL = 1, + INT8 = 2, + INT16 = 3, + INT32 = 4, + INT64 = 5, + UINT8 = 6, + UINT16 = 7, + UINT32 = 8, + UINT64 = 9, + FLOAT32 = 10, + FLOAT64 = 11, + TEXT = 12, + DATA = 13, + LIST = 14, + ENUM = 15, + STRUCT = 16, + INTERFACE = 17, + ANY_POINTER = 18 +} +export class Type extends __S { + static readonly VOID = Type_Which.VOID; + static readonly BOOL = Type_Which.BOOL; + static readonly INT8 = Type_Which.INT8; + static readonly INT16 = Type_Which.INT16; + static readonly INT32 = Type_Which.INT32; + static readonly INT64 = Type_Which.INT64; + static readonly UINT8 = Type_Which.UINT8; + static readonly UINT16 = Type_Which.UINT16; + static readonly UINT32 = Type_Which.UINT32; + static readonly UINT64 = Type_Which.UINT64; + static readonly FLOAT32 = Type_Which.FLOAT32; + static readonly FLOAT64 = Type_Which.FLOAT64; + static readonly TEXT = Type_Which.TEXT; + static readonly DATA = Type_Which.DATA; + static readonly LIST = Type_Which.LIST; + static readonly ENUM = Type_Which.ENUM; + static readonly STRUCT = Type_Which.STRUCT; + static readonly INTERFACE = Type_Which.INTERFACE; + static readonly ANY_POINTER = Type_Which.ANY_POINTER; + static readonly _capnp = { displayName: "Type", id: "d07378ede1f9cc60", size: new __O(24, 1) }; + isVoid(): boolean { return __S.getUint16(0, this) === 0; } + setVoid(): void { __S.setUint16(0, 0, this); } + isBool(): boolean { return __S.getUint16(0, this) === 1; } + setBool(): void { __S.setUint16(0, 1, this); } + isInt8(): boolean { return __S.getUint16(0, this) === 2; } + setInt8(): void { __S.setUint16(0, 2, this); } + isInt16(): boolean { return __S.getUint16(0, this) === 3; } + setInt16(): void { __S.setUint16(0, 3, this); } + isInt32(): boolean { return __S.getUint16(0, this) === 4; } + setInt32(): void { __S.setUint16(0, 4, this); } + isInt64(): boolean { return __S.getUint16(0, this) === 5; } + setInt64(): void { __S.setUint16(0, 5, this); } + isUint8(): boolean { return __S.getUint16(0, this) === 6; } + setUint8(): void { __S.setUint16(0, 6, this); } + isUint16(): boolean { return __S.getUint16(0, this) === 7; } + setUint16(): void { __S.setUint16(0, 7, this); } + isUint32(): boolean { return __S.getUint16(0, this) === 8; } + setUint32(): void { __S.setUint16(0, 8, this); } + isUint64(): boolean { return __S.getUint16(0, this) === 9; } + setUint64(): void { __S.setUint16(0, 9, this); } + isFloat32(): boolean { return __S.getUint16(0, this) === 10; } + setFloat32(): void { __S.setUint16(0, 10, this); } + isFloat64(): boolean { return __S.getUint16(0, this) === 11; } + setFloat64(): void { __S.setUint16(0, 11, this); } + isText(): boolean { return __S.getUint16(0, this) === 12; } + setText(): void { __S.setUint16(0, 12, this); } + isData(): boolean { return __S.getUint16(0, this) === 13; } + setData(): void { __S.setUint16(0, 13, this); } + getList(): Type_List { + __S.testWhich("list", __S.getUint16(0, this), 14, this); + return __S.getAs(Type_List, this); + } + initList(): Type_List { + __S.setUint16(0, 14, this); + return __S.getAs(Type_List, this); + } + isList(): boolean { return __S.getUint16(0, this) === 14; } + setList(): void { __S.setUint16(0, 14, this); } + getEnum(): Type_Enum { + __S.testWhich("enum", __S.getUint16(0, this), 15, this); + return __S.getAs(Type_Enum, this); + } + initEnum(): Type_Enum { + __S.setUint16(0, 15, this); + return __S.getAs(Type_Enum, this); + } + isEnum(): boolean { return __S.getUint16(0, this) === 15; } + setEnum(): void { __S.setUint16(0, 15, this); } + getStruct(): Type_Struct { + __S.testWhich("struct", __S.getUint16(0, this), 16, this); + return __S.getAs(Type_Struct, this); + } + initStruct(): Type_Struct { + __S.setUint16(0, 16, this); + return __S.getAs(Type_Struct, this); + } + isStruct(): boolean { return __S.getUint16(0, this) === 16; } + setStruct(): void { __S.setUint16(0, 16, this); } + getInterface(): Type_Interface { + __S.testWhich("interface", __S.getUint16(0, this), 17, this); + return __S.getAs(Type_Interface, this); + } + initInterface(): Type_Interface { + __S.setUint16(0, 17, this); + return __S.getAs(Type_Interface, this); + } + isInterface(): boolean { return __S.getUint16(0, this) === 17; } + setInterface(): void { __S.setUint16(0, 17, this); } + getAnyPointer(): Type_AnyPointer { + __S.testWhich("anyPointer", __S.getUint16(0, this), 18, this); + return __S.getAs(Type_AnyPointer, this); + } + initAnyPointer(): Type_AnyPointer { + __S.setUint16(0, 18, this); + return __S.getAs(Type_AnyPointer, this); + } + isAnyPointer(): boolean { return __S.getUint16(0, this) === 18; } + setAnyPointer(): void { __S.setUint16(0, 18, this); } + toString(): string { return "Type_" + super.toString(); } + which(): Type_Which { return __S.getUint16(0, this); } +} +export enum Brand_Scope_Which { + BIND = 0, + INHERIT = 1 +} +export class Brand_Scope extends __S { + static readonly BIND = Brand_Scope_Which.BIND; + static readonly INHERIT = Brand_Scope_Which.INHERIT; + static readonly _capnp = { displayName: "Scope", id: "abd73485a9636bc9", size: new __O(16, 1) }; + static _Bind: capnp.ListCtor; + getScopeId(): capnp.Uint64 { return __S.getUint64(0, this); } + setScopeId(value: capnp.Uint64): void { __S.setUint64(0, value, this); } + adoptBind(value: capnp.Orphan>): void { + __S.setUint16(8, 0, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownBind(): capnp.Orphan> { return __S.disown(this.getBind()); } + getBind(): capnp.List { + __S.testWhich("bind", __S.getUint16(8, this), 0, this); + return __S.getList(0, Brand_Scope._Bind, this); + } + hasBind(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initBind(length: number): capnp.List { + __S.setUint16(8, 0, this); + return __S.initList(0, Brand_Scope._Bind, length, this); + } + isBind(): boolean { return __S.getUint16(8, this) === 0; } + setBind(value: capnp.List): void { + __S.setUint16(8, 0, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + isInherit(): boolean { return __S.getUint16(8, this) === 1; } + setInherit(): void { __S.setUint16(8, 1, this); } + toString(): string { return "Brand_Scope_" + super.toString(); } + which(): Brand_Scope_Which { return __S.getUint16(8, this); } +} +export enum Brand_Binding_Which { + UNBOUND = 0, + TYPE = 1 +} +export class Brand_Binding extends __S { + static readonly UNBOUND = Brand_Binding_Which.UNBOUND; + static readonly TYPE = Brand_Binding_Which.TYPE; + static readonly _capnp = { displayName: "Binding", id: "c863cd16969ee7fc", size: new __O(8, 1) }; + isUnbound(): boolean { return __S.getUint16(0, this) === 0; } + setUnbound(): void { __S.setUint16(0, 0, this); } + adoptType(value: capnp.Orphan): void { + __S.setUint16(0, 1, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownType(): capnp.Orphan { return __S.disown(this.getType()); } + getType(): Type { + __S.testWhich("type", __S.getUint16(0, this), 1, this); + return __S.getStruct(0, Type, this); + } + hasType(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initType(): Type { + __S.setUint16(0, 1, this); + return __S.initStructAt(0, Type, this); + } + isType(): boolean { return __S.getUint16(0, this) === 1; } + setType(value: Type): void { + __S.setUint16(0, 1, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + toString(): string { return "Brand_Binding_" + super.toString(); } + which(): Brand_Binding_Which { return __S.getUint16(0, this); } +} +export class Brand extends __S { + static readonly Scope = Brand_Scope; + static readonly Binding = Brand_Binding; + static readonly _capnp = { displayName: "Brand", id: "903455f06065422b", size: new __O(0, 1) }; + static _Scopes: capnp.ListCtor; + adoptScopes(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(0, this)); } + disownScopes(): capnp.Orphan> { return __S.disown(this.getScopes()); } + getScopes(): capnp.List { return __S.getList(0, Brand._Scopes, this); } + hasScopes(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initScopes(length: number): capnp.List { return __S.initList(0, Brand._Scopes, length, this); } + setScopes(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Brand_" + super.toString(); } +} +export enum Value_Which { + VOID = 0, + BOOL = 1, + INT8 = 2, + INT16 = 3, + INT32 = 4, + INT64 = 5, + UINT8 = 6, + UINT16 = 7, + UINT32 = 8, + UINT64 = 9, + FLOAT32 = 10, + FLOAT64 = 11, + TEXT = 12, + DATA = 13, + LIST = 14, + ENUM = 15, + STRUCT = 16, + INTERFACE = 17, + ANY_POINTER = 18 +} +export class Value extends __S { + static readonly VOID = Value_Which.VOID; + static readonly BOOL = Value_Which.BOOL; + static readonly INT8 = Value_Which.INT8; + static readonly INT16 = Value_Which.INT16; + static readonly INT32 = Value_Which.INT32; + static readonly INT64 = Value_Which.INT64; + static readonly UINT8 = Value_Which.UINT8; + static readonly UINT16 = Value_Which.UINT16; + static readonly UINT32 = Value_Which.UINT32; + static readonly UINT64 = Value_Which.UINT64; + static readonly FLOAT32 = Value_Which.FLOAT32; + static readonly FLOAT64 = Value_Which.FLOAT64; + static readonly TEXT = Value_Which.TEXT; + static readonly DATA = Value_Which.DATA; + static readonly LIST = Value_Which.LIST; + static readonly ENUM = Value_Which.ENUM; + static readonly STRUCT = Value_Which.STRUCT; + static readonly INTERFACE = Value_Which.INTERFACE; + static readonly ANY_POINTER = Value_Which.ANY_POINTER; + static readonly _capnp = { displayName: "Value", id: "ce23dcd2d7b00c9b", size: new __O(16, 1) }; + isVoid(): boolean { return __S.getUint16(0, this) === 0; } + setVoid(): void { __S.setUint16(0, 0, this); } + getBool(): boolean { + __S.testWhich("bool", __S.getUint16(0, this), 1, this); + return __S.getBit(16, this); + } + isBool(): boolean { return __S.getUint16(0, this) === 1; } + setBool(value: boolean): void { + __S.setUint16(0, 1, this); + __S.setBit(16, value, this); + } + getInt8(): number { + __S.testWhich("int8", __S.getUint16(0, this), 2, this); + return __S.getInt8(2, this); + } + isInt8(): boolean { return __S.getUint16(0, this) === 2; } + setInt8(value: number): void { + __S.setUint16(0, 2, this); + __S.setInt8(2, value, this); + } + getInt16(): number { + __S.testWhich("int16", __S.getUint16(0, this), 3, this); + return __S.getInt16(2, this); + } + isInt16(): boolean { return __S.getUint16(0, this) === 3; } + setInt16(value: number): void { + __S.setUint16(0, 3, this); + __S.setInt16(2, value, this); + } + getInt32(): number { + __S.testWhich("int32", __S.getUint16(0, this), 4, this); + return __S.getInt32(4, this); + } + isInt32(): boolean { return __S.getUint16(0, this) === 4; } + setInt32(value: number): void { + __S.setUint16(0, 4, this); + __S.setInt32(4, value, this); + } + getInt64(): capnp.Int64 { + __S.testWhich("int64", __S.getUint16(0, this), 5, this); + return __S.getInt64(8, this); + } + isInt64(): boolean { return __S.getUint16(0, this) === 5; } + setInt64(value: capnp.Int64): void { + __S.setUint16(0, 5, this); + __S.setInt64(8, value, this); + } + getUint8(): number { + __S.testWhich("uint8", __S.getUint16(0, this), 6, this); + return __S.getUint8(2, this); + } + isUint8(): boolean { return __S.getUint16(0, this) === 6; } + setUint8(value: number): void { + __S.setUint16(0, 6, this); + __S.setUint8(2, value, this); + } + getUint16(): number { + __S.testWhich("uint16", __S.getUint16(0, this), 7, this); + return __S.getUint16(2, this); + } + isUint16(): boolean { return __S.getUint16(0, this) === 7; } + setUint16(value: number): void { + __S.setUint16(0, 7, this); + __S.setUint16(2, value, this); + } + getUint32(): number { + __S.testWhich("uint32", __S.getUint16(0, this), 8, this); + return __S.getUint32(4, this); + } + isUint32(): boolean { return __S.getUint16(0, this) === 8; } + setUint32(value: number): void { + __S.setUint16(0, 8, this); + __S.setUint32(4, value, this); + } + getUint64(): capnp.Uint64 { + __S.testWhich("uint64", __S.getUint16(0, this), 9, this); + return __S.getUint64(8, this); + } + isUint64(): boolean { return __S.getUint16(0, this) === 9; } + setUint64(value: capnp.Uint64): void { + __S.setUint16(0, 9, this); + __S.setUint64(8, value, this); + } + getFloat32(): number { + __S.testWhich("float32", __S.getUint16(0, this), 10, this); + return __S.getFloat32(4, this); + } + isFloat32(): boolean { return __S.getUint16(0, this) === 10; } + setFloat32(value: number): void { + __S.setUint16(0, 10, this); + __S.setFloat32(4, value, this); + } + getFloat64(): number { + __S.testWhich("float64", __S.getUint16(0, this), 11, this); + return __S.getFloat64(8, this); + } + isFloat64(): boolean { return __S.getUint16(0, this) === 11; } + setFloat64(value: number): void { + __S.setUint16(0, 11, this); + __S.setFloat64(8, value, this); + } + getText(): string { + __S.testWhich("text", __S.getUint16(0, this), 12, this); + return __S.getText(0, this); + } + isText(): boolean { return __S.getUint16(0, this) === 12; } + setText(value: string): void { + __S.setUint16(0, 12, this); + __S.setText(0, value, this); + } + adoptData(value: capnp.Orphan): void { + __S.setUint16(0, 13, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownData(): capnp.Orphan { return __S.disown(this.getData()); } + getData(): capnp.Data { + __S.testWhich("data", __S.getUint16(0, this), 13, this); + return __S.getData(0, this); + } + hasData(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initData(length: number): capnp.Data { + __S.setUint16(0, 13, this); + return __S.initData(0, length, this); + } + isData(): boolean { return __S.getUint16(0, this) === 13; } + setData(value: capnp.Data): void { + __S.setUint16(0, 13, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + adoptList(value: capnp.Orphan): void { + __S.setUint16(0, 14, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownList(): capnp.Orphan { return __S.disown(this.getList()); } + getList(): capnp.Pointer { + __S.testWhich("list", __S.getUint16(0, this), 14, this); + return __S.getPointer(0, this); + } + hasList(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + isList(): boolean { return __S.getUint16(0, this) === 14; } + setList(value: capnp.Pointer): void { + __S.setUint16(0, 14, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + getEnum(): number { + __S.testWhich("enum", __S.getUint16(0, this), 15, this); + return __S.getUint16(2, this); + } + isEnum(): boolean { return __S.getUint16(0, this) === 15; } + setEnum(value: number): void { + __S.setUint16(0, 15, this); + __S.setUint16(2, value, this); + } + adoptStruct(value: capnp.Orphan): void { + __S.setUint16(0, 16, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownStruct(): capnp.Orphan { return __S.disown(this.getStruct()); } + getStruct(): capnp.Pointer { + __S.testWhich("struct", __S.getUint16(0, this), 16, this); + return __S.getPointer(0, this); + } + hasStruct(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + isStruct(): boolean { return __S.getUint16(0, this) === 16; } + setStruct(value: capnp.Pointer): void { + __S.setUint16(0, 16, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + isInterface(): boolean { return __S.getUint16(0, this) === 17; } + setInterface(): void { __S.setUint16(0, 17, this); } + adoptAnyPointer(value: capnp.Orphan): void { + __S.setUint16(0, 18, this); + __S.adopt(value, __S.getPointer(0, this)); + } + disownAnyPointer(): capnp.Orphan { return __S.disown(this.getAnyPointer()); } + getAnyPointer(): capnp.Pointer { + __S.testWhich("anyPointer", __S.getUint16(0, this), 18, this); + return __S.getPointer(0, this); + } + hasAnyPointer(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + isAnyPointer(): boolean { return __S.getUint16(0, this) === 18; } + setAnyPointer(value: capnp.Pointer): void { + __S.setUint16(0, 18, this); + __S.copyFrom(value, __S.getPointer(0, this)); + } + toString(): string { return "Value_" + super.toString(); } + which(): Value_Which { return __S.getUint16(0, this); } +} +export class Annotation extends __S { + static readonly _capnp = { displayName: "Annotation", id: "f1c8950dab257542", size: new __O(8, 2) }; + getId(): capnp.Uint64 { return __S.getUint64(0, this); } + setId(value: capnp.Uint64): void { __S.setUint64(0, value, this); } + adoptBrand(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(1, this)); } + disownBrand(): capnp.Orphan { return __S.disown(this.getBrand()); } + getBrand(): Brand { return __S.getStruct(1, Brand, this); } + hasBrand(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initBrand(): Brand { return __S.initStructAt(1, Brand, this); } + setBrand(value: Brand): void { __S.copyFrom(value, __S.getPointer(1, this)); } + adoptValue(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(0, this)); } + disownValue(): capnp.Orphan { return __S.disown(this.getValue()); } + getValue(): Value { return __S.getStruct(0, Value, this); } + hasValue(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initValue(): Value { return __S.initStructAt(0, Value, this); } + setValue(value: Value): void { __S.copyFrom(value, __S.getPointer(0, this)); } + toString(): string { return "Annotation_" + super.toString(); } +} +export enum ElementSize { + EMPTY, + BIT, + BYTE, + TWO_BYTES, + FOUR_BYTES, + EIGHT_BYTES, + POINTER, + INLINE_COMPOSITE +} +export class CapnpVersion extends __S { + static readonly _capnp = { displayName: "CapnpVersion", id: "d85d305b7d839963", size: new __O(8, 0) }; + getMajor(): number { return __S.getUint16(0, this); } + setMajor(value: number): void { __S.setUint16(0, value, this); } + getMinor(): number { return __S.getUint8(2, this); } + setMinor(value: number): void { __S.setUint8(2, value, this); } + getMicro(): number { return __S.getUint8(3, this); } + setMicro(value: number): void { __S.setUint8(3, value, this); } + toString(): string { return "CapnpVersion_" + super.toString(); } +} +export class CodeGeneratorRequest_RequestedFile_Import extends __S { + static readonly _capnp = { displayName: "Import", id: "ae504193122357e5", size: new __O(8, 1) }; + getId(): capnp.Uint64 { return __S.getUint64(0, this); } + setId(value: capnp.Uint64): void { __S.setUint64(0, value, this); } + getName(): string { return __S.getText(0, this); } + setName(value: string): void { __S.setText(0, value, this); } + toString(): string { return "CodeGeneratorRequest_RequestedFile_Import_" + super.toString(); } +} +export class CodeGeneratorRequest_RequestedFile extends __S { + static readonly Import = CodeGeneratorRequest_RequestedFile_Import; + static readonly _capnp = { displayName: "RequestedFile", id: "cfea0eb02e810062", size: new __O(8, 2) }; + static _Imports: capnp.ListCtor; + getId(): capnp.Uint64 { return __S.getUint64(0, this); } + setId(value: capnp.Uint64): void { __S.setUint64(0, value, this); } + getFilename(): string { return __S.getText(0, this); } + setFilename(value: string): void { __S.setText(0, value, this); } + adoptImports(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(1, this)); } + disownImports(): capnp.Orphan> { return __S.disown(this.getImports()); } + getImports(): capnp.List { return __S.getList(1, CodeGeneratorRequest_RequestedFile._Imports, this); } + hasImports(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initImports(length: number): capnp.List { return __S.initList(1, CodeGeneratorRequest_RequestedFile._Imports, length, this); } + setImports(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(1, this)); } + toString(): string { return "CodeGeneratorRequest_RequestedFile_" + super.toString(); } +} +export class CodeGeneratorRequest extends __S { + static readonly RequestedFile = CodeGeneratorRequest_RequestedFile; + static readonly _capnp = { displayName: "CodeGeneratorRequest", id: "bfc546f6210ad7ce", size: new __O(0, 3) }; + static _Nodes: capnp.ListCtor; + static _RequestedFiles: capnp.ListCtor; + adoptCapnpVersion(value: capnp.Orphan): void { __S.adopt(value, __S.getPointer(2, this)); } + disownCapnpVersion(): capnp.Orphan { return __S.disown(this.getCapnpVersion()); } + getCapnpVersion(): CapnpVersion { return __S.getStruct(2, CapnpVersion, this); } + hasCapnpVersion(): boolean { return !__S.isNull(__S.getPointer(2, this)); } + initCapnpVersion(): CapnpVersion { return __S.initStructAt(2, CapnpVersion, this); } + setCapnpVersion(value: CapnpVersion): void { __S.copyFrom(value, __S.getPointer(2, this)); } + adoptNodes(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(0, this)); } + disownNodes(): capnp.Orphan> { return __S.disown(this.getNodes()); } + getNodes(): capnp.List { return __S.getList(0, CodeGeneratorRequest._Nodes, this); } + hasNodes(): boolean { return !__S.isNull(__S.getPointer(0, this)); } + initNodes(length: number): capnp.List { return __S.initList(0, CodeGeneratorRequest._Nodes, length, this); } + setNodes(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(0, this)); } + adoptRequestedFiles(value: capnp.Orphan>): void { __S.adopt(value, __S.getPointer(1, this)); } + disownRequestedFiles(): capnp.Orphan> { return __S.disown(this.getRequestedFiles()); } + getRequestedFiles(): capnp.List { return __S.getList(1, CodeGeneratorRequest._RequestedFiles, this); } + hasRequestedFiles(): boolean { return !__S.isNull(__S.getPointer(1, this)); } + initRequestedFiles(length: number): capnp.List { return __S.initList(1, CodeGeneratorRequest._RequestedFiles, length, this); } + setRequestedFiles(value: capnp.List): void { __S.copyFrom(value, __S.getPointer(1, this)); } + toString(): string { return "CodeGeneratorRequest_" + super.toString(); } +} +Node_Struct._Fields = capnp.CompositeList(Field); +Node_Enum._Enumerants = capnp.CompositeList(Enumerant); +Node_Interface._Methods = capnp.CompositeList(Method); +Node_Interface._Superclasses = capnp.CompositeList(Superclass); +Node._Parameters = capnp.CompositeList(Node_Parameter); +Node._NestedNodes = capnp.CompositeList(Node_NestedNode); +Node._Annotations = capnp.CompositeList(Annotation); +Field._Annotations = capnp.CompositeList(Annotation); +Enumerant._Annotations = capnp.CompositeList(Annotation); +Method._ImplicitParameters = capnp.CompositeList(Node_Parameter); +Method._Annotations = capnp.CompositeList(Annotation); +Brand_Scope._Bind = capnp.CompositeList(Brand_Binding); +Brand._Scopes = capnp.CompositeList(Brand_Scope); +CodeGeneratorRequest_RequestedFile._Imports = capnp.CompositeList(CodeGeneratorRequest_RequestedFile_Import); +CodeGeneratorRequest._Nodes = capnp.CompositeList(Node); +CodeGeneratorRequest._RequestedFiles = capnp.CompositeList(CodeGeneratorRequest_RequestedFile); diff --git a/node_modules/capnp-ts/src/std/ts.capnp.d.ts b/node_modules/capnp-ts/src/std/ts.capnp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c97581c3b7fbe16d275e7e568023e0f8a49338ce --- /dev/null +++ b/node_modules/capnp-ts/src/std/ts.capnp.d.ts @@ -0,0 +1,5 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +export declare const _capnpFileId = "e37ded525a68a7c9"; diff --git a/node_modules/capnp-ts/src/std/ts.capnp.js b/node_modules/capnp-ts/src/std/ts.capnp.js new file mode 100644 index 0000000000000000000000000000000000000000..b8429691ca5621c2a9954f78f5790af89bf0a51e --- /dev/null +++ b/node_modules/capnp-ts/src/std/ts.capnp.js @@ -0,0 +1,9 @@ +"use strict"; +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports._capnpFileId = void 0; +exports._capnpFileId = "e37ded525a68a7c9"; +//# sourceMappingURL=ts.capnp.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/ts.capnp.js.map b/node_modules/capnp-ts/src/std/ts.capnp.js.map new file mode 100644 index 0000000000000000000000000000000000000000..228bccba26a7fb1d933eb4a52c711e740aa2694f --- /dev/null +++ b/node_modules/capnp-ts/src/std/ts.capnp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ts.capnp.js","sourceRoot":"","sources":["ts.capnp.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIU,QAAA,YAAY,GAAG,kBAAkB,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/std/ts.capnp.ts b/node_modules/capnp-ts/src/std/ts.capnp.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8713de3e6bc86968dc52f7dc8acde0fafb02ae3 --- /dev/null +++ b/node_modules/capnp-ts/src/std/ts.capnp.ts @@ -0,0 +1,8 @@ +/** + * This file is generated by hand in order to bootstrap compiler development. It is intended to be an exact match to + * compiled output. + */ + +import * as capnp from "../index"; +import { ObjectSize as __O, Struct as __S } from "../index"; +export const _capnpFileId = "e37ded525a68a7c9"; diff --git a/node_modules/capnp-ts/src/types/index.d.ts b/node_modules/capnp-ts/src/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2bc6e94ac684203062daee3753b578f7f600532d --- /dev/null +++ b/node_modules/capnp-ts/src/types/index.d.ts @@ -0,0 +1,5 @@ +/** + * @author jdiaz5513 + */ +export { Int64 } from "./int64"; +export { Uint64 } from "./uint64"; diff --git a/node_modules/capnp-ts/src/types/index.js b/node_modules/capnp-ts/src/types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7bb7268a796264027537c5074c6b194218eb23b9 --- /dev/null +++ b/node_modules/capnp-ts/src/types/index.js @@ -0,0 +1,11 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Uint64 = exports.Int64 = void 0; +var int64_1 = require("./int64"); +Object.defineProperty(exports, "Int64", { enumerable: true, get: function () { return int64_1.Int64; } }); +var uint64_1 = require("./uint64"); +Object.defineProperty(exports, "Uint64", { enumerable: true, get: function () { return uint64_1.Uint64; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/types/index.js.map b/node_modules/capnp-ts/src/types/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..66d9975ada0e753cf3c4b9cacfab9ac7357c33a9 --- /dev/null +++ b/node_modules/capnp-ts/src/types/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/types/index.ts b/node_modules/capnp-ts/src/types/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..5abe946b9bd33348bf5802a243bdf318e1a624c4 --- /dev/null +++ b/node_modules/capnp-ts/src/types/index.ts @@ -0,0 +1,6 @@ +/** + * @author jdiaz5513 + */ + +export { Int64 } from "./int64"; +export { Uint64 } from "./uint64"; diff --git a/node_modules/capnp-ts/src/types/int64.d.ts b/node_modules/capnp-ts/src/types/int64.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a66e6338ac7c695d7bce1affe3cfe85c7be06dd4 --- /dev/null +++ b/node_modules/capnp-ts/src/types/int64.d.ts @@ -0,0 +1,43 @@ +/** + * @author jdiaz5513 + */ +import { Uint64 } from "./uint64"; +/** + * Represents a signed 64-bit integer stored using a Uint8Array in little-endian format. + * + * You may convert this to a primitive number by calling `toNumber()` but be wary of precision loss! + * + * The value passed in as the source buffer is expected to be in little-endian format. + */ +export declare class Int64 extends Uint64 { + static fromArrayBuffer(source: ArrayBuffer, offset?: number, noCopy?: boolean): Int64; + static fromDataView(source: DataView, offset?: number, noCopy?: boolean): Int64; + static fromNumber(source: number): Int64; + /** + * Parse a hexadecimal string in **big endian format** as an Int64 value. + * + * The value will be negative if the string is either preceded with a `-` sign, or already in the negative 2's + * complement form. + * + * @static + * @param {string} source The source string. + * @returns {Int64} The string parsed as a 64-bit signed integer. + */ + static fromHexString(source: string): Int64; + static fromUint8Array(source: Uint8Array, offset?: number, noCopy?: boolean): Int64; + equals(other: Int64): boolean; + inspect(): string; + negate(): void; + setValue(loWord: number, hiWord?: number): void; + toHexString(): string; + /** + * Convert to a native javascript number. + * + * WARNING: do not expect this number to be accurate to integer precision for large (positive or negative) numbers! + * + * @param {boolean} allowImprecise If `true`, no check is performed to verify the returned value is accurate; + * otherwise out-of-range values are clamped to +/-Infinity. + * @returns {number} A numeric representation of this integer. + */ + toNumber(allowImprecise?: boolean): number; +} diff --git a/node_modules/capnp-ts/src/types/int64.js b/node_modules/capnp-ts/src/types/int64.js new file mode 100644 index 0000000000000000000000000000000000000000..80d00b397b6fb88268b68ddaec5073e8340b1cdc --- /dev/null +++ b/node_modules/capnp-ts/src/types/int64.js @@ -0,0 +1,162 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Int64 = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("../constants"); +const util_1 = require("../util"); +const uint64_1 = require("./uint64"); +const trace = debug_1.default("capnp:int64"); +trace("load"); +/** + * Represents a signed 64-bit integer stored using a Uint8Array in little-endian format. + * + * You may convert this to a primitive number by calling `toNumber()` but be wary of precision loss! + * + * The value passed in as the source buffer is expected to be in little-endian format. + */ +class Int64 extends uint64_1.Uint64 { + static fromArrayBuffer(source, offset = 0, noCopy = false) { + if (noCopy) + return new this(new Uint8Array(source, offset, 8)); + return new this(new Uint8Array(source.slice(offset, offset + 8))); + } + static fromDataView(source, offset = 0, noCopy = false) { + if (noCopy) { + return new this(new Uint8Array(source.buffer, source.byteOffset + offset, 8)); + } + return new this(new Uint8Array(source.buffer.slice(source.byteOffset + offset, source.byteLength + offset + 8))); + } + static fromNumber(source) { + const ret = new this(new Uint8Array(8)); + ret.setValue(source); + return ret; + } + /** + * Parse a hexadecimal string in **big endian format** as an Int64 value. + * + * The value will be negative if the string is either preceded with a `-` sign, or already in the negative 2's + * complement form. + * + * @static + * @param {string} source The source string. + * @returns {Int64} The string parsed as a 64-bit signed integer. + */ + static fromHexString(source) { + if (source.substr(0, 2) === "0x") + source = source.substr(2); + if (source.length < 1) + return Int64.fromNumber(0); + const neg = source[0] === "-"; + if (neg) + source = source.substr(1); + source = util_1.pad(source, 16); + if (source.length !== 16) { + throw new RangeError("Source string must contain at most 16 hexadecimal digits."); + } + const bytes = source.toLowerCase().replace(/[^\da-f]/g, ""); + const buf = new Uint8Array(new ArrayBuffer(8)); + for (let i = 0; i < 8; i++) { + buf[7 - i] = parseInt(bytes.substr(i * 2, 2), 16); + } + const val = new Int64(buf); + if (neg) + val.negate(); + return val; + } + static fromUint8Array(source, offset = 0, noCopy = false) { + if (noCopy) + return new this(source.subarray(offset, offset + 8)); + return new this(new Uint8Array(source.buffer.slice(source.byteOffset + offset, source.byteOffset + offset + 8))); + } + equals(other) { + return super.equals(other); + } + inspect() { + return `[Int64 ${this.toString(10)} 0x${this.toHexString()}]`; + } + negate() { + for (let b = this.buffer, carry = 1, i = 0; i < 8; i++) { + const v = (b[i] ^ 0xff) + carry; + b[i] = v & 0xff; + carry = v >> 8; + } + } + setValue(loWord, hiWord) { + let negate = false; + let lo = loWord; + let hi = hiWord; + if (hi === undefined) { + hi = lo; + negate = hi < 0; + hi = Math.abs(hi); + lo = hi % constants_1.VAL32; + hi = hi / constants_1.VAL32; + if (hi > constants_1.VAL32) + throw new RangeError(`${loWord} is outside Int64 range`); + hi = hi >>> 0; + } + for (let i = 0; i < 8; i++) { + this.buffer[i] = lo & 0xff; + lo = i === 3 ? hi : lo >>> 8; + } + if (negate) + this.negate(); + } + toHexString() { + const b = this.buffer; + const negate = b[7] & 0x80; + if (negate) + this.negate(); + let hex = ""; + for (let i = 7; i >= 0; i--) { + let v = b[i].toString(16); + if (v.length === 1) + v = "0" + v; + hex += v; + } + if (negate) { + this.negate(); + hex = "-" + hex; + } + return hex; + } + /** + * Convert to a native javascript number. + * + * WARNING: do not expect this number to be accurate to integer precision for large (positive or negative) numbers! + * + * @param {boolean} allowImprecise If `true`, no check is performed to verify the returned value is accurate; + * otherwise out-of-range values are clamped to +/-Infinity. + * @returns {number} A numeric representation of this integer. + */ + toNumber(allowImprecise) { + const b = this.buffer; + const negate = b[7] & 0x80; + let x = 0; + let carry = 1; + let i = 0; + let m = 1; + while (i < 8) { + let v = b[i]; + if (negate) { + v = (v ^ 0xff) + carry; + carry = v >> 8; + v = v & 0xff; + } + x += v * m; + m *= 256; + i++; + } + if (!allowImprecise && x >= constants_1.MAX_SAFE_INTEGER) { + trace("Coercing out of range value %d to Infinity.", x); + return negate ? -Infinity : Infinity; + } + return negate ? -x : x; + } +} +exports.Int64 = Int64; +//# sourceMappingURL=int64.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/types/int64.js.map b/node_modules/capnp-ts/src/types/int64.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e04aee31d8c93f7359825fd4cef0a87c660fe2ee --- /dev/null +++ b/node_modules/capnp-ts/src/types/int64.js.map @@ -0,0 +1 @@ +{"version":3,"file":"int64.js","sourceRoot":"","sources":["int64.ts"],"names":[],"mappings":";AAAA;;GA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M,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAE3B,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,CAAC,CAAC;QAEV,OAAO,CAAC,GAAG,CAAC,EAAE;YACZ,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAEb,IAAI,MAAM,EAAE;gBACV,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;gBACvB,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC;gBACf,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;aACd;YAED,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACX,CAAC,IAAI,GAAG,CAAC;YACT,CAAC,EAAE,CAAC;SACL;QAED,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,4BAAgB,EAAE;YAC5C,KAAK,CAAC,6CAA6C,EAAE,CAAC,CAAC,CAAC;YAExD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;SACtC;QAED,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;CACF;AAlLD,sBAkLC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/types/int64.ts b/node_modules/capnp-ts/src/types/int64.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6b2410352e934c7ea6efdabc2e8c3792e39a7bb --- /dev/null +++ b/node_modules/capnp-ts/src/types/int64.ts @@ -0,0 +1,200 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { MAX_SAFE_INTEGER, VAL32 } from "../constants"; +import { pad } from "../util"; +import { Uint64 } from "./uint64"; + +const trace = initTrace("capnp:int64"); +trace("load"); + +/** + * Represents a signed 64-bit integer stored using a Uint8Array in little-endian format. + * + * You may convert this to a primitive number by calling `toNumber()` but be wary of precision loss! + * + * The value passed in as the source buffer is expected to be in little-endian format. + */ + +export class Int64 extends Uint64 { + static fromArrayBuffer(source: ArrayBuffer, offset = 0, noCopy = false): Int64 { + if (noCopy) return new this(new Uint8Array(source, offset, 8)); + + return new this(new Uint8Array(source.slice(offset, offset + 8))); + } + + static fromDataView(source: DataView, offset = 0, noCopy = false): Int64 { + if (noCopy) { + return new this(new Uint8Array(source.buffer, source.byteOffset + offset, 8)); + } + + return new this(new Uint8Array(source.buffer.slice(source.byteOffset + offset, source.byteLength + offset + 8))); + } + + static fromNumber(source: number): Int64 { + const ret = new this(new Uint8Array(8)); + + ret.setValue(source); + + return ret; + } + + /** + * Parse a hexadecimal string in **big endian format** as an Int64 value. + * + * The value will be negative if the string is either preceded with a `-` sign, or already in the negative 2's + * complement form. + * + * @static + * @param {string} source The source string. + * @returns {Int64} The string parsed as a 64-bit signed integer. + */ + + static fromHexString(source: string): Int64 { + if (source.substr(0, 2) === "0x") source = source.substr(2); + + if (source.length < 1) return Int64.fromNumber(0); + + const neg = source[0] === "-"; + + if (neg) source = source.substr(1); + + source = pad(source, 16); + + if (source.length !== 16) { + throw new RangeError("Source string must contain at most 16 hexadecimal digits."); + } + + const bytes = source.toLowerCase().replace(/[^\da-f]/g, ""); + const buf = new Uint8Array(new ArrayBuffer(8)); + + for (let i = 0; i < 8; i++) { + buf[7 - i] = parseInt(bytes.substr(i * 2, 2), 16); + } + + const val = new Int64(buf); + + if (neg) val.negate(); + + return val; + } + + static fromUint8Array(source: Uint8Array, offset = 0, noCopy = false): Int64 { + if (noCopy) return new this(source.subarray(offset, offset + 8)); + + return new this(new Uint8Array(source.buffer.slice(source.byteOffset + offset, source.byteOffset + offset + 8))); + } + + equals(other: Int64): boolean { + return super.equals(other); + } + + inspect(): string { + return `[Int64 ${this.toString(10)} 0x${this.toHexString()}]`; + } + + negate(): void { + for (let b = this.buffer, carry = 1, i = 0; i < 8; i++) { + const v = (b[i] ^ 0xff) + carry; + + b[i] = v & 0xff; + carry = v >> 8; + } + } + + setValue(loWord: number, hiWord?: number): void { + let negate = false; + let lo = loWord; + let hi = hiWord; + + if (hi === undefined) { + hi = lo; + negate = hi < 0; + hi = Math.abs(hi); + lo = hi % VAL32; + hi = hi / VAL32; + + if (hi > VAL32) throw new RangeError(`${loWord} is outside Int64 range`); + + hi = hi >>> 0; + } + + for (let i = 0; i < 8; i++) { + this.buffer[i] = lo & 0xff; + + lo = i === 3 ? hi : lo >>> 8; + } + + if (negate) this.negate(); + } + + toHexString(): string { + const b = this.buffer; + const negate = b[7] & 0x80; + + if (negate) this.negate(); + + let hex = ""; + + for (let i = 7; i >= 0; i--) { + let v = b[i].toString(16); + + if (v.length === 1) v = "0" + v; + + hex += v; + } + + if (negate) { + this.negate(); + + hex = "-" + hex; + } + + return hex; + } + + /** + * Convert to a native javascript number. + * + * WARNING: do not expect this number to be accurate to integer precision for large (positive or negative) numbers! + * + * @param {boolean} allowImprecise If `true`, no check is performed to verify the returned value is accurate; + * otherwise out-of-range values are clamped to +/-Infinity. + * @returns {number} A numeric representation of this integer. + */ + + toNumber(allowImprecise?: boolean): number { + const b = this.buffer; + const negate = b[7] & 0x80; + + let x = 0; + let carry = 1; + let i = 0; + let m = 1; + + while (i < 8) { + let v = b[i]; + + if (negate) { + v = (v ^ 0xff) + carry; + carry = v >> 8; + v = v & 0xff; + } + + x += v * m; + m *= 256; + i++; + } + + if (!allowImprecise && x >= MAX_SAFE_INTEGER) { + trace("Coercing out of range value %d to Infinity.", x); + + return negate ? -Infinity : Infinity; + } + + return negate ? -x : x; + } +} diff --git a/node_modules/capnp-ts/src/types/uint64.d.ts b/node_modules/capnp-ts/src/types/uint64.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f274f308bc9fa775ff09f9bc6812d3cdd89ca5bd --- /dev/null +++ b/node_modules/capnp-ts/src/types/uint64.d.ts @@ -0,0 +1,64 @@ +/** + * @author jdiaz5513 + */ +/** + * Represents an unsigned 64-bit integer stored using a Uint8Array in little-endian format. It's a little bit faster + * than int64 because we don't need to keep track of the sign bit or perform two's compliment operations on set. + * + * You may convert this to a primitive number by calling `toNumber()` but be wary of precision loss! + * + * Note that overflow is not implemented, so negative numbers passed into `setValue()` will be negated first. + * + * The value passed in as the source buffer is expected to be in little-endian format. + */ +export declare class Uint64 { + readonly buffer: Uint8Array; + /** + * Creates a new instance; this is a no-frills constructor for speed. Use the factory methods if you need to convert + * from other types or use a different offset into the buffer. + * + * Will throw if the buffer is not at least 8 bytes long. + * + * @constructor + * @param {Uint8Array} buffer The buffer to use for this 64-bit word; the bytes must be in little-endian order. + */ + constructor(buffer: Uint8Array); + static fromArrayBuffer(source: ArrayBuffer, offset?: number, noCopy?: boolean): Uint64; + static fromDataView(source: DataView, offset?: number, noCopy?: boolean): Uint64; + /** + * Parse a hexadecimal string in **big endian format** as a Uint64 value. + * + * @static + * @param {string} source The source string. + * @returns {Uint64} The string parsed as a 64-bit unsigned integer. + */ + static fromHexString(source: string): Uint64; + static fromNumber(source: number): Uint64; + static fromUint8Array(source: Uint8Array, offset?: number, noCopy?: boolean): Uint64; + equals(other: Uint64): boolean; + inspect(): string; + /** + * Faster way to check for zero values without converting to a number first. + * + * @returns {boolean} `true` if the contained value is zero. + * @memberOf Uint64 + */ + isZero(): boolean; + setValue(loWord: number, hiWord?: number): void; + /** + * Convert to a native javascript number. + * + * WARNING: do not expect this number to be accurate to integer precision for large (positive or negative) numbers! + * + * @param {boolean} allowImprecise If `true`, no check is performed to verify the returned value is accurate; + * otherwise out-of-range values are clamped to +Infinity. + * @returns {number} A numeric representation of this integer. + */ + toNumber(allowImprecise?: boolean): number; + valueOf(): number; + toArrayBuffer(): ArrayBuffer; + toDataView(): DataView; + toHexString(): string; + toString(radix?: number): string; + toUint8Array(): Uint8Array; +} diff --git a/node_modules/capnp-ts/src/types/uint64.js b/node_modules/capnp-ts/src/types/uint64.js new file mode 100644 index 0000000000000000000000000000000000000000..70e264fe11d133daff508b676277459ca1821b8a --- /dev/null +++ b/node_modules/capnp-ts/src/types/uint64.js @@ -0,0 +1,178 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Uint64 = void 0; +const tslib_1 = require("tslib"); +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("../constants"); +const errors_1 = require("../errors"); +const util_1 = require("../util"); +const trace = debug_1.default("capnp:uint64"); +trace("load"); +/** + * Represents an unsigned 64-bit integer stored using a Uint8Array in little-endian format. It's a little bit faster + * than int64 because we don't need to keep track of the sign bit or perform two's compliment operations on set. + * + * You may convert this to a primitive number by calling `toNumber()` but be wary of precision loss! + * + * Note that overflow is not implemented, so negative numbers passed into `setValue()` will be negated first. + * + * The value passed in as the source buffer is expected to be in little-endian format. + */ +class Uint64 { + /** + * Creates a new instance; this is a no-frills constructor for speed. Use the factory methods if you need to convert + * from other types or use a different offset into the buffer. + * + * Will throw if the buffer is not at least 8 bytes long. + * + * @constructor + * @param {Uint8Array} buffer The buffer to use for this 64-bit word; the bytes must be in little-endian order. + */ + constructor(buffer) { + if (buffer.byteLength < 8) + throw new RangeError(errors_1.RANGE_INT64_UNDERFLOW); + this.buffer = buffer; + } + static fromArrayBuffer(source, offset = 0, noCopy = false) { + if (noCopy) + return new this(new Uint8Array(source, offset, 8)); + return new this(new Uint8Array(source.slice(offset, offset + 8))); + } + static fromDataView(source, offset = 0, noCopy = false) { + if (noCopy) { + return new this(new Uint8Array(source.buffer, source.byteOffset + offset, 8)); + } + return new this(new Uint8Array(source.buffer.slice(source.byteOffset + offset, source.byteLength + offset + 8))); + } + /** + * Parse a hexadecimal string in **big endian format** as a Uint64 value. + * + * @static + * @param {string} source The source string. + * @returns {Uint64} The string parsed as a 64-bit unsigned integer. + */ + static fromHexString(source) { + if (source.substr(0, 2) === "0x") + source = source.substr(2); + if (source.length < 1) + return Uint64.fromNumber(0); + if (source[0] === "-") + throw new RangeError("Source must not be negative."); + source = util_1.pad(source, 16); + if (source.length !== 16) { + throw new RangeError("Source string must contain at most 16 hexadecimal digits."); + } + const bytes = source.toLowerCase().replace(/[^\da-f]/g, ""); + const buf = new Uint8Array(new ArrayBuffer(8)); + for (let i = 0; i < 8; i++) { + buf[7 - i] = parseInt(bytes.substr(i * 2, 2), 16); + } + return new Uint64(buf); + } + static fromNumber(source) { + const ret = new this(new Uint8Array(8)); + ret.setValue(source); + return ret; + } + static fromUint8Array(source, offset = 0, noCopy = false) { + if (noCopy) + return new this(source.subarray(offset, offset + 8)); + return new this(new Uint8Array(source.buffer.slice(source.byteOffset + offset, source.byteOffset + offset + 8))); + } + equals(other) { + for (let i = 0; i < 8; i++) { + if (this.buffer[i] !== other.buffer[i]) + return false; + } + return true; + } + inspect() { + return `[Uint64 ${this.toString(10)} 0x${this.toHexString()}]`; + } + /** + * Faster way to check for zero values without converting to a number first. + * + * @returns {boolean} `true` if the contained value is zero. + * @memberOf Uint64 + */ + isZero() { + for (let i = 0; i < 8; i++) { + if (this.buffer[i] !== 0) + return false; + } + return true; + } + setValue(loWord, hiWord) { + let lo = loWord; + let hi = hiWord; + if (hi === undefined) { + hi = lo; + hi = Math.abs(hi); + lo = hi % constants_1.VAL32; + hi = hi / constants_1.VAL32; + if (hi > constants_1.VAL32) + throw new RangeError(`${loWord} is outside Uint64 range`); + hi = hi >>> 0; + } + for (let i = 0; i < 8; i++) { + this.buffer[i] = lo & 0xff; + lo = i === 3 ? hi : lo >>> 8; + } + } + /** + * Convert to a native javascript number. + * + * WARNING: do not expect this number to be accurate to integer precision for large (positive or negative) numbers! + * + * @param {boolean} allowImprecise If `true`, no check is performed to verify the returned value is accurate; + * otherwise out-of-range values are clamped to +Infinity. + * @returns {number} A numeric representation of this integer. + */ + toNumber(allowImprecise) { + const b = this.buffer; + let x = 0; + let i = 0; + let m = 1; + while (i < 8) { + const v = b[i]; + x += v * m; + m *= 256; + i++; + } + if (!allowImprecise && x >= constants_1.MAX_SAFE_INTEGER) { + trace("Coercing out of range value %d to Infinity.", x); + return Infinity; + } + return x; + } + valueOf() { + return this.toNumber(false); + } + toArrayBuffer() { + return this.buffer.buffer; + } + toDataView() { + return new DataView(this.buffer.buffer); + } + toHexString() { + let hex = ""; + for (let i = 7; i >= 0; i--) { + let v = this.buffer[i].toString(16); + if (v.length === 1) + v = "0" + v; + hex += v; + } + return hex; + } + toString(radix) { + return this.toNumber(true).toString(radix); + } + toUint8Array() { + return this.buffer; + } +} +exports.Uint64 = Uint64; +//# sourceMappingURL=uint64.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/types/uint64.js.map b/node_modules/capnp-ts/src/types/uint64.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3bb25f2bd9ddf7755f3241e8fb9ff1a146c69f07 --- /dev/null +++ b/node_modules/capnp-ts/src/types/uint64.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uint64.js","sourceRoot":"","sources":["uint64.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,0DAA8B;AAE9B,4CAAuD;AACvD,sCAAkD;AAClD,kCAA8B;AAE9B,MAAM,KAAK,GAAG,eAAS,CAAC,cAAc,CAAC,CAAC;AACxC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd;;;;;;;;;GASG;AAEH,MAAa,MAAM;IAGjB;;;;;;;;OAQG;IAEH,YAAY,MAAkB;QAC5B,IAAI,MAAM,CAAC,UAAU,GAAG,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,8BAAqB,CAAC,CAAC;QAEvE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,MAAmB,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;QACpE,IAAI,MAAM;YAAE,OAAO,IAAI,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,C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,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAhMD,wBAgMC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/types/uint64.ts b/node_modules/capnp-ts/src/types/uint64.ts new file mode 100644 index 0000000000000000000000000000000000000000..a1ccc3a87197822d0f8938d40ab1bc2555c1b652 --- /dev/null +++ b/node_modules/capnp-ts/src/types/uint64.ts @@ -0,0 +1,217 @@ +/** + * @author jdiaz5513 + */ + +import initTrace from "debug"; + +import { MAX_SAFE_INTEGER, VAL32 } from "../constants"; +import { RANGE_INT64_UNDERFLOW } from "../errors"; +import { pad } from "../util"; + +const trace = initTrace("capnp:uint64"); +trace("load"); + +/** + * Represents an unsigned 64-bit integer stored using a Uint8Array in little-endian format. It's a little bit faster + * than int64 because we don't need to keep track of the sign bit or perform two's compliment operations on set. + * + * You may convert this to a primitive number by calling `toNumber()` but be wary of precision loss! + * + * Note that overflow is not implemented, so negative numbers passed into `setValue()` will be negated first. + * + * The value passed in as the source buffer is expected to be in little-endian format. + */ + +export class Uint64 { + readonly buffer: Uint8Array; + + /** + * Creates a new instance; this is a no-frills constructor for speed. Use the factory methods if you need to convert + * from other types or use a different offset into the buffer. + * + * Will throw if the buffer is not at least 8 bytes long. + * + * @constructor + * @param {Uint8Array} buffer The buffer to use for this 64-bit word; the bytes must be in little-endian order. + */ + + constructor(buffer: Uint8Array) { + if (buffer.byteLength < 8) throw new RangeError(RANGE_INT64_UNDERFLOW); + + this.buffer = buffer; + } + + static fromArrayBuffer(source: ArrayBuffer, offset = 0, noCopy = false): Uint64 { + if (noCopy) return new this(new Uint8Array(source, offset, 8)); + + return new this(new Uint8Array(source.slice(offset, offset + 8))); + } + + static fromDataView(source: DataView, offset = 0, noCopy = false): Uint64 { + if (noCopy) { + return new this(new Uint8Array(source.buffer, source.byteOffset + offset, 8)); + } + + return new this(new Uint8Array(source.buffer.slice(source.byteOffset + offset, source.byteLength + offset + 8))); + } + + /** + * Parse a hexadecimal string in **big endian format** as a Uint64 value. + * + * @static + * @param {string} source The source string. + * @returns {Uint64} The string parsed as a 64-bit unsigned integer. + */ + + static fromHexString(source: string): Uint64 { + if (source.substr(0, 2) === "0x") source = source.substr(2); + + if (source.length < 1) return Uint64.fromNumber(0); + + if (source[0] === "-") throw new RangeError("Source must not be negative."); + + source = pad(source, 16); + + if (source.length !== 16) { + throw new RangeError("Source string must contain at most 16 hexadecimal digits."); + } + + const bytes = source.toLowerCase().replace(/[^\da-f]/g, ""); + const buf = new Uint8Array(new ArrayBuffer(8)); + + for (let i = 0; i < 8; i++) { + buf[7 - i] = parseInt(bytes.substr(i * 2, 2), 16); + } + + return new Uint64(buf); + } + + static fromNumber(source: number): Uint64 { + const ret = new this(new Uint8Array(8)); + + ret.setValue(source); + + return ret; + } + + static fromUint8Array(source: Uint8Array, offset = 0, noCopy = false): Uint64 { + if (noCopy) return new this(source.subarray(offset, offset + 8)); + + return new this(new Uint8Array(source.buffer.slice(source.byteOffset + offset, source.byteOffset + offset + 8))); + } + + equals(other: Uint64): boolean { + for (let i = 0; i < 8; i++) { + if (this.buffer[i] !== other.buffer[i]) return false; + } + + return true; + } + + inspect(): string { + return `[Uint64 ${this.toString(10)} 0x${this.toHexString()}]`; + } + + /** + * Faster way to check for zero values without converting to a number first. + * + * @returns {boolean} `true` if the contained value is zero. + * @memberOf Uint64 + */ + + isZero(): boolean { + for (let i = 0; i < 8; i++) { + if (this.buffer[i] !== 0) return false; + } + + return true; + } + + setValue(loWord: number, hiWord?: number): void { + let lo = loWord; + let hi = hiWord; + + if (hi === undefined) { + hi = lo; + hi = Math.abs(hi); + lo = hi % VAL32; + hi = hi / VAL32; + + if (hi > VAL32) throw new RangeError(`${loWord} is outside Uint64 range`); + + hi = hi >>> 0; + } + + for (let i = 0; i < 8; i++) { + this.buffer[i] = lo & 0xff; + lo = i === 3 ? hi : lo >>> 8; + } + } + + /** + * Convert to a native javascript number. + * + * WARNING: do not expect this number to be accurate to integer precision for large (positive or negative) numbers! + * + * @param {boolean} allowImprecise If `true`, no check is performed to verify the returned value is accurate; + * otherwise out-of-range values are clamped to +Infinity. + * @returns {number} A numeric representation of this integer. + */ + + toNumber(allowImprecise?: boolean): number { + const b = this.buffer; + let x = 0; + let i = 0; + let m = 1; + + while (i < 8) { + const v = b[i]; + + x += v * m; + m *= 256; + i++; + } + + if (!allowImprecise && x >= MAX_SAFE_INTEGER) { + trace("Coercing out of range value %d to Infinity.", x); + + return Infinity; + } + + return x; + } + + valueOf(): number { + return this.toNumber(false); + } + + toArrayBuffer(): ArrayBuffer { + return this.buffer.buffer; + } + + toDataView(): DataView { + return new DataView(this.buffer.buffer); + } + + toHexString(): string { + let hex = ""; + + for (let i = 7; i >= 0; i--) { + let v = this.buffer[i].toString(16); + + if (v.length === 1) v = "0" + v; + + hex += v; + } + + return hex; + } + + toString(radix?: number): string { + return this.toNumber(true).toString(radix); + } + + toUint8Array(): Uint8Array { + return this.buffer; + } +} diff --git a/node_modules/capnp-ts/src/util.d.ts b/node_modules/capnp-ts/src/util.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..00c805e7b9b2bbf2e4ac5bbedf44b85b5befa546 --- /dev/null +++ b/node_modules/capnp-ts/src/util.d.ts @@ -0,0 +1,75 @@ +/** + * @author jdiaz5513 + */ +/** + * Dump a hex string from the given buffer. + * + * @export + * @param {ArrayBuffer} buffer The buffer to convert. + * @returns {string} A hexadecimal string representing the buffer. + */ +export declare function bufferToHex(buffer: ArrayBuffer): string; +/** + * Throw an error if the provided value cannot be represented as a 32-bit integer. + * + * @export + * @param {number} value The number to check. + * @returns {number} The same number if it is valid. + */ +export declare function checkInt32(value: number): number; +export declare function checkUint32(value: number): number; +/** + * Decode a UTF-8 encoded byte array into a JavaScript string (UCS-2). + * + * @export + * @param {Uint8Array} src A utf-8 encoded byte array. + * @returns {string} A string representation of the byte array. + */ +export declare function decodeUtf8(src: Uint8Array): string; +export declare function dumpBuffer(buffer: ArrayBuffer | ArrayBufferView): string; +/** + * Encode a JavaScript string (UCS-2) to a UTF-8 encoded string inside a Uint8Array. + * + * Note that the underlying buffer for the array will likely be larger than the actual contents; ignore the extra bytes. + * + * @export + * @param {string} src The input string. + * @returns {Uint8Array} A UTF-8 encoded buffer with the string's contents. + */ +export declare function encodeUtf8(src: string): Uint8Array; +/** + * Produce a `printf`-style string. Nice for providing arguments to `assert` without paying the cost for string + * concatenation up front. Precision is supported for floating point numbers. + * + * @param {string} s The format string. Supported format specifiers: b, c, d, f, j, o, s, x, and X. + * @param {...any} args Values to be formatted in the string. Arguments beyond what are consumed by the format string + * are ignored. + * @returns {string} The formatted string. + */ +export declare function format(s: string, ...args: unknown[]): string; +/** + * Return the thing that was passed in. Yaaaaawn. + * + * @export + * @template T + * @param {T} x A thing. + * @returns {T} The same thing. + */ +export declare function identity(x: T): T; +export declare function pad(v: string, width: number, pad?: string): string; +/** + * Add padding to a number to make it divisible by 8. Typically used to pad byte sizes so they align to a word boundary. + * + * @export + * @param {number} size The number to pad. + * @returns {number} The padded number. + */ +export declare function padToWord(size: number): number; +/** + * Repeat a string n times. Shamelessly copied from lodash.repeat. + * + * @param {number} times Number of times to repeat. + * @param {string} str The string to repeat. + * @returns {string} The repeated string. + */ +export declare function repeat(times: number, str: string): string; diff --git a/node_modules/capnp-ts/src/util.js b/node_modules/capnp-ts/src/util.js new file mode 100644 index 0000000000000000000000000000000000000000..e29e69e4211eae98d31b68ab63dee751b4d7cac7 --- /dev/null +++ b/node_modules/capnp-ts/src/util.js @@ -0,0 +1,349 @@ +"use strict"; +/** + * @author jdiaz5513 + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.repeat = exports.padToWord = exports.pad = exports.identity = exports.format = exports.encodeUtf8 = exports.dumpBuffer = exports.decodeUtf8 = exports.checkUint32 = exports.checkInt32 = exports.bufferToHex = void 0; +const tslib_1 = require("tslib"); +// LINT: a lot of the util functions need the any type. +/* tslint:disable:no-any no-unsafe-any */ +const debug_1 = tslib_1.__importDefault(require("debug")); +const constants_1 = require("./constants"); +const errors_1 = require("./errors"); +const trace = debug_1.default("capnp:util"); +trace("load"); +/** + * Dump a hex string from the given buffer. + * + * @export + * @param {ArrayBuffer} buffer The buffer to convert. + * @returns {string} A hexadecimal string representing the buffer. + */ +function bufferToHex(buffer) { + const a = new Uint8Array(buffer); + const h = []; + for (let i = 0; i < a.byteLength; i++) + h.push(pad(a[i].toString(16), 2)); + return `[${h.join(" ")}]`; +} +exports.bufferToHex = bufferToHex; +/** + * Throw an error if the provided value cannot be represented as a 32-bit integer. + * + * @export + * @param {number} value The number to check. + * @returns {number} The same number if it is valid. + */ +function checkInt32(value) { + if (value > constants_1.MAX_INT32 || value < -constants_1.MAX_INT32) { + throw new RangeError(errors_1.RANGE_INT32_OVERFLOW); + } + return value; +} +exports.checkInt32 = checkInt32; +function checkUint32(value) { + if (value < 0 || value > constants_1.MAX_UINT32) { + throw new RangeError(errors_1.RANGE_UINT32_OVERFLOW); + } + return value; +} +exports.checkUint32 = checkUint32; +/** + * Decode a UTF-8 encoded byte array into a JavaScript string (UCS-2). + * + * @export + * @param {Uint8Array} src A utf-8 encoded byte array. + * @returns {string} A string representation of the byte array. + */ +function decodeUtf8(src) { + // This ain't for the faint of heart, kids. If you suffer from seizures, heart palpitations, or have had a history of + // stroke you may want to look away now. + const l = src.byteLength; + let dst = ""; + let i = 0; + let cp = 0; + let a = 0; + let b = 0; + let c = 0; + let d = 0; + while (i < l) { + a = src[i++]; + if ((a & 0b10000000) === 0) { + cp = a; + } + else if ((a & 0b11100000) === 0b11000000) { + if (i >= l) + throw new RangeError(errors_1.RANGE_INVALID_UTF8); + b = src[i++]; + cp = ((a & 0b00011111) << 6) | (b & 0b00111111); + } + else if ((a & 0b11110000) === 0b11100000) { + if (i + 1 >= l) + throw new RangeError(errors_1.RANGE_INVALID_UTF8); + b = src[i++]; + c = src[i++]; + cp = ((a & 0b00001111) << 12) | ((b & 0b00111111) << 6) | (c & 0b00111111); + } + else if ((a & 0b11111000) === 0b11110000) { + if (i + 2 >= l) + throw new RangeError(errors_1.RANGE_INVALID_UTF8); + b = src[i++]; + c = src[i++]; + d = src[i++]; + cp = ((a & 0b00000111) << 18) | ((b & 0b00111111) << 12) | ((c & 0b00111111) << 6) | (d & 0b00111111); + } + else { + throw new RangeError(errors_1.RANGE_INVALID_UTF8); + } + if (cp <= 0xd7ff || (cp >= 0xe000 && cp <= 0xffff)) { + dst += String.fromCharCode(cp); + } + else { + // We must reach into the astral plane and construct the surrogate pair! + cp -= 0x00010000; + const hi = (cp >>> 10) + 0xd800; + const lo = (cp & 0x03ff) + 0xdc00; + if (hi < 0xd800 || hi > 0xdbff) + throw new RangeError(errors_1.RANGE_INVALID_UTF8); + dst += String.fromCharCode(hi, lo); + } + } + return dst; +} +exports.decodeUtf8 = decodeUtf8; +function dumpBuffer(buffer) { + const b = buffer instanceof ArrayBuffer + ? new Uint8Array(buffer) + : new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength); + const byteLength = Math.min(b.byteLength, constants_1.MAX_BUFFER_DUMP_BYTES); + let r = format("\n=== buffer[%d] ===", byteLength); + for (let j = 0; j < byteLength; j += 16) { + r += `\n${pad(j.toString(16), 8)}: `; + let s = ""; + let k; + for (k = 0; k < 16 && j + k < b.byteLength; k++) { + const v = b[j + k]; + r += `${pad(v.toString(16), 2)} `; + // Printable ASCII range. + s += v > 31 && v < 255 ? String.fromCharCode(v) : "·"; + if (k === 7) + r += " "; + } + r += `${repeat((17 - k) * 3, " ")}${s}`; + } + r += "\n"; + if (byteLength !== b.byteLength) { + r += format("=== (truncated %d bytes) ===\n", b.byteLength - byteLength); + } + return r; +} +exports.dumpBuffer = dumpBuffer; +/** + * Encode a JavaScript string (UCS-2) to a UTF-8 encoded string inside a Uint8Array. + * + * Note that the underlying buffer for the array will likely be larger than the actual contents; ignore the extra bytes. + * + * @export + * @param {string} src The input string. + * @returns {Uint8Array} A UTF-8 encoded buffer with the string's contents. + */ +function encodeUtf8(src) { + const l = src.length; + const dst = new Uint8Array(new ArrayBuffer(l * 4)); + let j = 0; + for (let i = 0; i < l; i++) { + const c = src.charCodeAt(i); + if (c <= 0x7f) { + dst[j++] = c; + } + else if (c <= 0x07ff) { + dst[j++] = 0b11000000 | (c >>> 6); + dst[j++] = 0b10000000 | ((c >>> 0) & 0b00111111); + } + else if (c <= 0xd7ff || c >= 0xe000) { + dst[j++] = 0b11100000 | (c >>> 12); + dst[j++] = 0b10000000 | ((c >>> 6) & 0b00111111); + dst[j++] = 0b10000000 | ((c >>> 0) & 0b00111111); + } + else { + // Make sure the surrogate pair is complete. + /* istanbul ignore next */ + if (i + 1 >= l) + throw new RangeError(errors_1.RANGE_INVALID_UTF8); + // I cast thee back into the astral plane. + const hi = c - 0xd800; + const lo = src.charCodeAt(++i) - 0xdc00; + const cp = ((hi << 10) | lo) + 0x00010000; + dst[j++] = 0b11110000 | (cp >>> 18); + dst[j++] = 0b10000000 | ((cp >>> 12) & 0b00111111); + dst[j++] = 0b10000000 | ((cp >>> 6) & 0b00111111); + dst[j++] = 0b10000000 | ((cp >>> 0) & 0b00111111); + } + } + return dst.subarray(0, j); +} +exports.encodeUtf8 = encodeUtf8; +/** + * Produce a `printf`-style string. Nice for providing arguments to `assert` without paying the cost for string + * concatenation up front. Precision is supported for floating point numbers. + * + * @param {string} s The format string. Supported format specifiers: b, c, d, f, j, o, s, x, and X. + * @param {...any} args Values to be formatted in the string. Arguments beyond what are consumed by the format string + * are ignored. + * @returns {string} The formatted string. + */ +function format(s, ...args) { + const n = s.length; + let arg; + let argIndex = 0; + let c; + let escaped = false; + let i = 0; + let leadingZero = false; + let precision; + let result = ""; + function nextArg() { + return args[argIndex++]; + } + function slurpNumber() { + let digits = ""; + while (/\d/.test(s[i])) { + digits += s[i++]; + c = s[i]; + } + return digits.length > 0 ? parseInt(digits, 10) : null; + } + for (; i < n; ++i) { + c = s[i]; + if (escaped) { + escaped = false; + if (c === ".") { + leadingZero = false; + c = s[++i]; + } + else if (c === "0" && s[i + 1] === ".") { + leadingZero = true; + i += 2; + c = s[i]; + } + else { + leadingZero = true; + } + precision = slurpNumber(); + switch (c) { + case "a": // number in hex with padding + result += "0x" + pad(parseInt(String(nextArg()), 10).toString(16), 8); + break; + case "b": // number in binary + result += parseInt(String(nextArg()), 10).toString(2); + break; + case "c": // character + arg = nextArg(); + if (typeof arg === "string" || arg instanceof String) { + result += arg; + } + else { + result += String.fromCharCode(parseInt(String(arg), 10)); + } + break; + case "d": // number in decimal + result += parseInt(String(nextArg()), 10); + break; + case "f": { + // floating point number + const tmp = parseFloat(String(nextArg())).toFixed(precision || 6); + result += leadingZero ? tmp : tmp.replace(/^0/, ""); + break; + } + case "j": // JSON + result += JSON.stringify(nextArg()); + break; + case "o": // number in octal + result += "0" + parseInt(String(nextArg()), 10).toString(8); + break; + case "s": // string + result += nextArg(); + break; + case "x": // lowercase hexadecimal + result += "0x" + parseInt(String(nextArg()), 10).toString(16); + break; + case "X": // uppercase hexadecimal + result += "0x" + parseInt(String(nextArg()), 10).toString(16).toUpperCase(); + break; + default: + result += c; + break; + } + } + else if (c === "%") { + escaped = true; + } + else { + result += c; + } + } + return result; +} +exports.format = format; +/** + * Return the thing that was passed in. Yaaaaawn. + * + * @export + * @template T + * @param {T} x A thing. + * @returns {T} The same thing. + */ +function identity(x) { + return x; +} +exports.identity = identity; +function pad(v, width, pad = "0") { + return v.length >= width ? v : new Array(width - v.length + 1).join(pad) + v; +} +exports.pad = pad; +/** + * Add padding to a number to make it divisible by 8. Typically used to pad byte sizes so they align to a word boundary. + * + * @export + * @param {number} size The number to pad. + * @returns {number} The padded number. + */ +function padToWord(size) { + return (size + 7) & ~7; +} +exports.padToWord = padToWord; +/** + * Repeat a string n times. Shamelessly copied from lodash.repeat. + * + * @param {number} times Number of times to repeat. + * @param {string} str The string to repeat. + * @returns {string} The repeated string. + */ +function repeat(times, str) { + let out = ""; + let n = times; + let s = str; + if (n < 1 || n > Number.MAX_VALUE) + return out; + // https://en.wikipedia.org/wiki/Exponentiation_by_squaring + do { + if (n % 2) + out += s; + n = Math.floor(n / 2); + if (n) + s += s; + } while (n); + return out; +} +exports.repeat = repeat; +const hex = (v) => parseInt(String(v)).toString(16); +// Set up custom debug formatters. +/* istanbul ignore next */ +debug_1.default.formatters["h"] = hex; +/* istanbul ignore next */ +debug_1.default.formatters["x"] = (v) => `0x${hex(v)}`; +/* istanbul ignore next */ +debug_1.default.formatters["a"] = (v) => `0x${pad(hex(v), 8)}`; +/* istanbul ignore next */ +debug_1.default.formatters["X"] = (v) => `0x${hex(v).toUpperCase()}`; +//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/node_modules/capnp-ts/src/util.js.map b/node_modules/capnp-ts/src/util.js.map new file mode 100644 index 0000000000000000000000000000000000000000..de4780ee1a870b0a49e83c4dd88661e034f019f9 --- /dev/null +++ b/node_modules/capnp-ts/src/util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,uDAAuD;AACvD,yCAAyC;AACzC,0DAA8B;AAE9B,2CAA2E;AAC3E,qCAA2F;AAE3F,MAAM,KAAK,GAAG,eAAS,CAAC,YAAY,CAAC,CAAC;AACtC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd;;;;;;GAMG;AAEH,SAAgB,WAAW,CAAC,MAAmB;IAC7C,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,GAAG,EAAE,CAAC;IAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE;QAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEzE,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAC5B,CAAC;AAPD,kCAOC;AAED;;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AED,MAAM,GAAG,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAE7D,kCAAkC;AAElC,0BAA0B;AAC1B,eAAS,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAChC,0BAA0B;AAC1B,eAAS,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,0BAA0B;AAC1B,eAAS,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAClE,0BAA0B;AAC1B,eAAS,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/capnp-ts/src/util.ts b/node_modules/capnp-ts/src/util.ts new file mode 100644 index 0000000000000000000000000000000000000000..dae1daccd6e1cfb8df69ff3d3f5ad234eb62ecab --- /dev/null +++ b/node_modules/capnp-ts/src/util.ts @@ -0,0 +1,413 @@ +/** + * @author jdiaz5513 + */ + +// LINT: a lot of the util functions need the any type. +/* tslint:disable:no-any no-unsafe-any */ +import initTrace from "debug"; + +import { MAX_BUFFER_DUMP_BYTES, MAX_INT32, MAX_UINT32 } from "./constants"; +import { RANGE_INT32_OVERFLOW, RANGE_INVALID_UTF8, RANGE_UINT32_OVERFLOW } from "./errors"; + +const trace = initTrace("capnp:util"); +trace("load"); + +/** + * Dump a hex string from the given buffer. + * + * @export + * @param {ArrayBuffer} buffer The buffer to convert. + * @returns {string} A hexadecimal string representing the buffer. + */ + +export function bufferToHex(buffer: ArrayBuffer): string { + const a = new Uint8Array(buffer); + const h = []; + + for (let i = 0; i < a.byteLength; i++) h.push(pad(a[i].toString(16), 2)); + + return `[${h.join(" ")}]`; +} + +/** + * Throw an error if the provided value cannot be represented as a 32-bit integer. + * + * @export + * @param {number} value The number to check. + * @returns {number} The same number if it is valid. + */ + +export function checkInt32(value: number): number { + if (value > MAX_INT32 || value < -MAX_INT32) { + throw new RangeError(RANGE_INT32_OVERFLOW); + } + + return value; +} + +export function checkUint32(value: number): number { + if (value < 0 || value > MAX_UINT32) { + throw new RangeError(RANGE_UINT32_OVERFLOW); + } + + return value; +} + +/** + * Decode a UTF-8 encoded byte array into a JavaScript string (UCS-2). + * + * @export + * @param {Uint8Array} src A utf-8 encoded byte array. + * @returns {string} A string representation of the byte array. + */ + +export function decodeUtf8(src: Uint8Array): string { + // This ain't for the faint of heart, kids. If you suffer from seizures, heart palpitations, or have had a history of + // stroke you may want to look away now. + + const l = src.byteLength; + let dst = ""; + let i = 0; + let cp = 0; + let a = 0; + let b = 0; + let c = 0; + let d = 0; + + while (i < l) { + a = src[i++]; + + if ((a & 0b10000000) === 0) { + cp = a; + } else if ((a & 0b11100000) === 0b11000000) { + if (i >= l) throw new RangeError(RANGE_INVALID_UTF8); + + b = src[i++]; + + cp = ((a & 0b00011111) << 6) | (b & 0b00111111); + } else if ((a & 0b11110000) === 0b11100000) { + if (i + 1 >= l) throw new RangeError(RANGE_INVALID_UTF8); + + b = src[i++]; + c = src[i++]; + + cp = ((a & 0b00001111) << 12) | ((b & 0b00111111) << 6) | (c & 0b00111111); + } else if ((a & 0b11111000) === 0b11110000) { + if (i + 2 >= l) throw new RangeError(RANGE_INVALID_UTF8); + + b = src[i++]; + c = src[i++]; + d = src[i++]; + + cp = ((a & 0b00000111) << 18) | ((b & 0b00111111) << 12) | ((c & 0b00111111) << 6) | (d & 0b00111111); + } else { + throw new RangeError(RANGE_INVALID_UTF8); + } + + if (cp <= 0xd7ff || (cp >= 0xe000 && cp <= 0xffff)) { + dst += String.fromCharCode(cp); + } else { + // We must reach into the astral plane and construct the surrogate pair! + + cp -= 0x00010000; + + const hi = (cp >>> 10) + 0xd800; + const lo = (cp & 0x03ff) + 0xdc00; + + if (hi < 0xd800 || hi > 0xdbff) throw new RangeError(RANGE_INVALID_UTF8); + + dst += String.fromCharCode(hi, lo); + } + } + + return dst; +} + +export function dumpBuffer(buffer: ArrayBuffer | ArrayBufferView): string { + const b = + buffer instanceof ArrayBuffer + ? new Uint8Array(buffer) + : new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength); + + const byteLength = Math.min(b.byteLength, MAX_BUFFER_DUMP_BYTES); + + let r = format("\n=== buffer[%d] ===", byteLength); + + for (let j = 0; j < byteLength; j += 16) { + r += `\n${pad(j.toString(16), 8)}: `; + let s = ""; + let k; + + for (k = 0; k < 16 && j + k < b.byteLength; k++) { + const v = b[j + k]; + + r += `${pad(v.toString(16), 2)} `; + + // Printable ASCII range. + + s += v > 31 && v < 255 ? String.fromCharCode(v) : "·"; + + if (k === 7) r += " "; + } + + r += `${repeat((17 - k) * 3, " ")}${s}`; + } + + r += "\n"; + + if (byteLength !== b.byteLength) { + r += format("=== (truncated %d bytes) ===\n", b.byteLength - byteLength); + } + + return r; +} + +/** + * Encode a JavaScript string (UCS-2) to a UTF-8 encoded string inside a Uint8Array. + * + * Note that the underlying buffer for the array will likely be larger than the actual contents; ignore the extra bytes. + * + * @export + * @param {string} src The input string. + * @returns {Uint8Array} A UTF-8 encoded buffer with the string's contents. + */ + +export function encodeUtf8(src: string): Uint8Array { + const l = src.length; + const dst = new Uint8Array(new ArrayBuffer(l * 4)); + let j = 0; + + for (let i = 0; i < l; i++) { + const c = src.charCodeAt(i); + + if (c <= 0x7f) { + dst[j++] = c; + } else if (c <= 0x07ff) { + dst[j++] = 0b11000000 | (c >>> 6); + dst[j++] = 0b10000000 | ((c >>> 0) & 0b00111111); + } else if (c <= 0xd7ff || c >= 0xe000) { + dst[j++] = 0b11100000 | (c >>> 12); + dst[j++] = 0b10000000 | ((c >>> 6) & 0b00111111); + dst[j++] = 0b10000000 | ((c >>> 0) & 0b00111111); + } else { + // Make sure the surrogate pair is complete. + /* istanbul ignore next */ + if (i + 1 >= l) throw new RangeError(RANGE_INVALID_UTF8); + + // I cast thee back into the astral plane. + + const hi = c - 0xd800; + const lo = src.charCodeAt(++i) - 0xdc00; + const cp = ((hi << 10) | lo) + 0x00010000; + + dst[j++] = 0b11110000 | (cp >>> 18); + dst[j++] = 0b10000000 | ((cp >>> 12) & 0b00111111); + dst[j++] = 0b10000000 | ((cp >>> 6) & 0b00111111); + dst[j++] = 0b10000000 | ((cp >>> 0) & 0b00111111); + } + } + + return dst.subarray(0, j); +} + +/** + * Produce a `printf`-style string. Nice for providing arguments to `assert` without paying the cost for string + * concatenation up front. Precision is supported for floating point numbers. + * + * @param {string} s The format string. Supported format specifiers: b, c, d, f, j, o, s, x, and X. + * @param {...any} args Values to be formatted in the string. Arguments beyond what are consumed by the format string + * are ignored. + * @returns {string} The formatted string. + */ + +export function format(s: string, ...args: unknown[]): string { + const n = s.length; + let arg: unknown; + let argIndex = 0; + let c: string; + let escaped = false; + let i = 0; + let leadingZero = false; + let precision: number | null; + let result = ""; + + function nextArg() { + return args[argIndex++]; + } + + function slurpNumber() { + let digits = ""; + + while (/\d/.test(s[i])) { + digits += s[i++]; + c = s[i]; + } + + return digits.length > 0 ? parseInt(digits, 10) : null; + } + + for (; i < n; ++i) { + c = s[i]; + + if (escaped) { + escaped = false; + + if (c === ".") { + leadingZero = false; + + c = s[++i]; + } else if (c === "0" && s[i + 1] === ".") { + leadingZero = true; + + i += 2; + c = s[i]; + } else { + leadingZero = true; + } + + precision = slurpNumber(); + + switch (c) { + case "a": // number in hex with padding + result += "0x" + pad(parseInt(String(nextArg()), 10).toString(16), 8); + + break; + + case "b": // number in binary + result += parseInt(String(nextArg()), 10).toString(2); + + break; + + case "c": // character + arg = nextArg(); + + if (typeof arg === "string" || arg instanceof String) { + result += arg; + } else { + result += String.fromCharCode(parseInt(String(arg), 10)); + } + + break; + + case "d": // number in decimal + result += parseInt(String(nextArg()), 10); + + break; + + case "f": { + // floating point number + const tmp = parseFloat(String(nextArg())).toFixed(precision || 6); + + result += leadingZero ? tmp : tmp.replace(/^0/, ""); + + break; + } + case "j": // JSON + result += JSON.stringify(nextArg()); + + break; + + case "o": // number in octal + result += "0" + parseInt(String(nextArg()), 10).toString(8); + + break; + + case "s": // string + result += nextArg(); + + break; + + case "x": // lowercase hexadecimal + result += "0x" + parseInt(String(nextArg()), 10).toString(16); + + break; + + case "X": // uppercase hexadecimal + result += "0x" + parseInt(String(nextArg()), 10).toString(16).toUpperCase(); + + break; + + default: + result += c; + + break; + } + } else if (c === "%") { + escaped = true; + } else { + result += c; + } + } + + return result; +} + +/** + * Return the thing that was passed in. Yaaaaawn. + * + * @export + * @template T + * @param {T} x A thing. + * @returns {T} The same thing. + */ + +export function identity(x: T): T { + return x; +} + +export function pad(v: string, width: number, pad = "0"): string { + return v.length >= width ? v : new Array(width - v.length + 1).join(pad) + v; +} + +/** + * Add padding to a number to make it divisible by 8. Typically used to pad byte sizes so they align to a word boundary. + * + * @export + * @param {number} size The number to pad. + * @returns {number} The padded number. + */ + +export function padToWord(size: number): number { + return (size + 7) & ~7; +} + +/** + * Repeat a string n times. Shamelessly copied from lodash.repeat. + * + * @param {number} times Number of times to repeat. + * @param {string} str The string to repeat. + * @returns {string} The repeated string. + */ + +export function repeat(times: number, str: string): string { + let out = ""; + let n = times; + let s = str; + + if (n < 1 || n > Number.MAX_VALUE) return out; + + // https://en.wikipedia.org/wiki/Exponentiation_by_squaring + + do { + if (n % 2) out += s; + + n = Math.floor(n / 2); + + if (n) s += s; + } while (n); + + return out; +} + +const hex = (v: unknown) => parseInt(String(v)).toString(16); + +// Set up custom debug formatters. + +/* istanbul ignore next */ +initTrace.formatters["h"] = hex; +/* istanbul ignore next */ +initTrace.formatters["x"] = (v: unknown) => `0x${hex(v)}`; +/* istanbul ignore next */ +initTrace.formatters["a"] = (v: unknown) => `0x${pad(hex(v), 8)}`; +/* istanbul ignore next */ +initTrace.formatters["X"] = (v: unknown) => `0x${hex(v).toUpperCase()}`; diff --git a/node_modules/capnp-ts/tsconfig.json b/node_modules/capnp-ts/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..3eec3f63d088a67a8f4a6828d687bbab642f9458 --- /dev/null +++ b/node_modules/capnp-ts/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "noEmit": false + }, + "extends": "../../tsconfig.json", + "include": ["src/**/*", "test/**/*"] +} diff --git a/node_modules/caseless/LICENSE b/node_modules/caseless/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..61789f4a4f858613c6926b69b8d5869c3c211b3d --- /dev/null +++ b/node_modules/caseless/LICENSE @@ -0,0 +1,28 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +1. Definitions. +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/node_modules/caseless/README.md b/node_modules/caseless/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e5077a21659b2505d2516d74cad91cb1268cc9eb --- /dev/null +++ b/node_modules/caseless/README.md @@ -0,0 +1,45 @@ +## Caseless -- wrap an object to set and get property with caseless semantics but also preserve caseing. + +This library is incredibly useful when working with HTTP headers. It allows you to get/set/check for headers in a caseless manner while also preserving the caseing of headers the first time they are set. + +## Usage + +```javascript +var headers = {} + , c = caseless(headers) + ; +c.set('a-Header', 'asdf') +c.get('a-header') === 'asdf' +``` + +## has(key) + +Has takes a name and if it finds a matching header will return that header name with the preserved caseing it was set with. + +```javascript +c.has('a-header') === 'a-Header' +``` + +## set(key, value[, clobber=true]) + +Set is fairly straight forward except that if the header exists and clobber is disabled it will add `','+value` to the existing header. + +```javascript +c.set('a-Header', 'fdas') +c.set('a-HEADER', 'more', false) +c.get('a-header') === 'fdsa,more' +``` + +## swap(key) + +Swaps the casing of a header with the new one that is passed in. + +```javascript +var headers = {} + , c = caseless(headers) + ; +c.set('a-Header', 'fdas') +c.swap('a-HEADER') +c.has('a-header') === 'a-HEADER' +headers === {'a-HEADER': 'fdas'} +``` diff --git a/node_modules/caseless/index.js b/node_modules/caseless/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b194734ee4e8dbf69413a2dd70175fced771894b --- /dev/null +++ b/node_modules/caseless/index.js @@ -0,0 +1,67 @@ +function Caseless (dict) { + this.dict = dict || {} +} +Caseless.prototype.set = function (name, value, clobber) { + if (typeof name === 'object') { + for (var i in name) { + this.set(i, name[i], value) + } + } else { + if (typeof clobber === 'undefined') clobber = true + var has = this.has(name) + + if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value + else this.dict[has || name] = value + return has + } +} +Caseless.prototype.has = function (name) { + var keys = Object.keys(this.dict) + , name = name.toLowerCase() + ; + for (var i=0;i", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/mikeal/caseless/issues" + }, + "devDependencies": { + "tape": "^2.10.2" + } +} diff --git a/node_modules/caseless/test.js b/node_modules/caseless/test.js new file mode 100644 index 0000000000000000000000000000000000000000..f55196cc079490970f52904851d17673a995fa2e --- /dev/null +++ b/node_modules/caseless/test.js @@ -0,0 +1,67 @@ +var tape = require('tape') + , caseless = require('./') + ; + +tape('set get has', function (t) { + var headers = {} + , c = caseless(headers) + ; + t.plan(17) + c.set('a-Header', 'asdf') + t.equal(c.get('a-header'), 'asdf') + t.equal(c.has('a-header'), 'a-Header') + t.ok(!c.has('nothing')) + // old bug where we used the wrong regex + t.ok(!c.has('a-hea')) + c.set('a-header', 'fdsa') + t.equal(c.get('a-header'), 'fdsa') + t.equal(c.get('a-Header'), 'fdsa') + c.set('a-HEADER', 'more', false) + t.equal(c.get('a-header'), 'fdsa,more') + + t.deepEqual(headers, {'a-Header': 'fdsa,more'}) + c.swap('a-HEADER') + t.deepEqual(headers, {'a-HEADER': 'fdsa,more'}) + + c.set('deleteme', 'foobar') + t.ok(c.has('deleteme')) + t.ok(c.del('deleteme')) + t.notOk(c.has('deleteme')) + t.notOk(c.has('idonotexist')) + t.ok(c.del('idonotexist')) + + c.set('tva', 'test1') + c.set('tva-header', 'test2') + t.equal(c.has('tva'), 'tva') + t.notOk(c.has('header')) + + t.equal(c.get('tva'), 'test1') + +}) + +tape('swap', function (t) { + var headers = {} + , c = caseless(headers) + ; + t.plan(4) + // No Header to Swap. + t.throws(function () { + c.swap('content-type') + }) + // Set Header. + c.set('content-type', 'application/json') + // Swap Header With Itself. + c.swap('content-type') + // Does Not Delete Itself. + t.ok(c.has('content-type')) + // Swap Header With a Different Header. + c.swap('Content-Type') + // Still Has Header. + t.ok(c.has('Content-Type')) + // Delete Header. + c.del('Content-Type') + // No Header to Swap. + t.throws(function () { + c.swap('content-type') + }) +}) diff --git a/node_modules/chokidar/LICENSE b/node_modules/chokidar/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..fa9162b51acb582ac3b63c75552db2ca9b9d9bb2 --- /dev/null +++ b/node_modules/chokidar/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2012-2019 Paul Miller (https://paulmillr.com), Elan Shanker + +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. diff --git a/node_modules/chokidar/README.md b/node_modules/chokidar/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d6a57fd9c58dec945cc830267499fc5f6448eeea --- /dev/null +++ b/node_modules/chokidar/README.md @@ -0,0 +1,308 @@ +# Chokidar [![Weekly downloads](https://img.shields.io/npm/dw/chokidar.svg)](https://github.com/paulmillr/chokidar) [![Yearly downloads](https://img.shields.io/npm/dy/chokidar.svg)](https://github.com/paulmillr/chokidar) + +> Minimal and efficient cross-platform file watching library + +[![NPM](https://nodei.co/npm/chokidar.png)](https://www.npmjs.com/package/chokidar) + +## Why? + +Node.js `fs.watch`: + +* Doesn't report filenames on MacOS. +* Doesn't report events at all when using editors like Sublime on MacOS. +* Often reports events twice. +* Emits most changes as `rename`. +* Does not provide an easy way to recursively watch file trees. +* Does not support recursive watching on Linux. + +Node.js `fs.watchFile`: + +* Almost as bad at event handling. +* Also does not provide any recursive watching. +* Results in high CPU utilization. + +Chokidar resolves these problems. + +Initially made for **[Brunch](https://brunch.io/)** (an ultra-swift web app build tool), it is now used in +[Microsoft's Visual Studio Code](https://github.com/microsoft/vscode), +[gulp](https://github.com/gulpjs/gulp/), +[karma](https://karma-runner.github.io/), +[PM2](https://github.com/Unitech/PM2), +[browserify](http://browserify.org/), +[webpack](https://webpack.github.io/), +[BrowserSync](https://www.browsersync.io/), +and [many others](https://www.npmjs.com/browse/depended/chokidar). +It has proven itself in production environments. + +Version 3 is out! Check out our blog post about it: [Chokidar 3: How to save 32TB of traffic every week](https://paulmillr.com/posts/chokidar-3-save-32tb-of-traffic/) + +## How? + +Chokidar does still rely on the Node.js core `fs` module, but when using +`fs.watch` and `fs.watchFile` for watching, it normalizes the events it +receives, often checking for truth by getting file stats and/or dir contents. + +On MacOS, chokidar by default uses a native extension exposing the Darwin +`FSEvents` API. This provides very efficient recursive watching compared with +implementations like `kqueue` available on most \*nix platforms. Chokidar still +does have to do some work to normalize the events received that way as well. + +On most other platforms, the `fs.watch`-based implementation is the default, which +avoids polling and keeps CPU usage down. Be advised that chokidar will initiate +watchers recursively for everything within scope of the paths that have been +specified, so be judicious about not wasting system resources by watching much +more than needed. + +## Getting started + +Install with npm: + +```sh +npm install chokidar +``` + +Then `require` and use it in your code: + +```javascript +const chokidar = require('chokidar'); + +// One-liner for current directory +chokidar.watch('.').on('all', (event, path) => { + console.log(event, path); +}); +``` + +## API + +```javascript +// Example of a more typical implementation structure + +// Initialize watcher. +const watcher = chokidar.watch('file, dir, glob, or array', { + ignored: /(^|[\/\\])\../, // ignore dotfiles + persistent: true +}); + +// Something to use when events are received. +const log = console.log.bind(console); +// Add event listeners. +watcher + .on('add', path => log(`File ${path} has been added`)) + .on('change', path => log(`File ${path} has been changed`)) + .on('unlink', path => log(`File ${path} has been removed`)); + +// More possible events. +watcher + .on('addDir', path => log(`Directory ${path} has been added`)) + .on('unlinkDir', path => log(`Directory ${path} has been removed`)) + .on('error', error => log(`Watcher error: ${error}`)) + .on('ready', () => log('Initial scan complete. Ready for changes')) + .on('raw', (event, path, details) => { // internal + log('Raw event info:', event, path, details); + }); + +// 'add', 'addDir' and 'change' events also receive stat() results as second +// argument when available: https://nodejs.org/api/fs.html#fs_class_fs_stats +watcher.on('change', (path, stats) => { + if (stats) console.log(`File ${path} changed size to ${stats.size}`); +}); + +// Watch new files. +watcher.add('new-file'); +watcher.add(['new-file-2', 'new-file-3', '**/other-file*']); + +// Get list of actual paths being watched on the filesystem +var watchedPaths = watcher.getWatched(); + +// Un-watch some files. +await watcher.unwatch('new-file*'); + +// Stop watching. +// The method is async! +watcher.close().then(() => console.log('closed')); + +// Full list of options. See below for descriptions. +// Do not use this example! +chokidar.watch('file', { + persistent: true, + + ignored: '*.txt', + ignoreInitial: false, + followSymlinks: true, + cwd: '.', + disableGlobbing: false, + + usePolling: false, + interval: 100, + binaryInterval: 300, + alwaysStat: false, + depth: 99, + awaitWriteFinish: { + stabilityThreshold: 2000, + pollInterval: 100 + }, + + ignorePermissionErrors: false, + atomic: true // or a custom 'atomicity delay', in milliseconds (default 100) +}); + +``` + +`chokidar.watch(paths, [options])` + +* `paths` (string or array of strings). Paths to files, dirs to be watched +recursively, or glob patterns. + - Note: globs must not contain windows separators (`\`), + because that's how they work by the standard — + you'll need to replace them with forward slashes (`/`). + - Note 2: for additional glob documentation, check out low-level + library: [picomatch](https://github.com/micromatch/picomatch). +* `options` (object) Options object as defined below: + +#### Persistence + +* `persistent` (default: `true`). Indicates whether the process +should continue to run as long as files are being watched. If set to +`false` when using `fsevents` to watch, no more events will be emitted +after `ready`, even if the process continues to run. + +#### Path filtering + +* `ignored` ([anymatch](https://github.com/es128/anymatch)-compatible definition) +Defines files/paths to be ignored. The whole relative or absolute path is +tested, not just filename. If a function with two arguments is provided, it +gets called twice per path - once with a single argument (the path), second +time with two arguments (the path and the +[`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) +object of that path). +* `ignoreInitial` (default: `false`). If set to `false` then `add`/`addDir` events are also emitted for matching paths while +instantiating the watching as chokidar discovers these file paths (before the `ready` event). +* `followSymlinks` (default: `true`). When `false`, only the +symlinks themselves will be watched for changes instead of following +the link references and bubbling events through the link's path. +* `cwd` (no default). The base directory from which watch `paths` are to be +derived. Paths emitted with events will be relative to this. +* `disableGlobbing` (default: `false`). If set to `true` then the strings passed to `.watch()` and `.add()` are treated as +literal path names, even if they look like globs. + +#### Performance + +* `usePolling` (default: `false`). +Whether to use fs.watchFile (backed by polling), or fs.watch. If polling +leads to high CPU utilization, consider setting this to `false`. It is +typically necessary to **set this to `true` to successfully watch files over +a network**, and it may be necessary to successfully watch files in other +non-standard situations. Setting to `true` explicitly on MacOS overrides the +`useFsEvents` default. You may also set the CHOKIDAR_USEPOLLING env variable +to true (1) or false (0) in order to override this option. +* _Polling-specific settings_ (effective when `usePolling: true`) + * `interval` (default: `100`). Interval of file system polling, in milliseconds. You may also + set the CHOKIDAR_INTERVAL env variable to override this option. + * `binaryInterval` (default: `300`). Interval of file system + polling for binary files. + ([see list of binary extensions](https://github.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json)) +* `useFsEvents` (default: `true` on MacOS). Whether to use the +`fsevents` watching interface if available. When set to `true` explicitly +and `fsevents` is available this supercedes the `usePolling` setting. When +set to `false` on MacOS, `usePolling: true` becomes the default. +* `alwaysStat` (default: `false`). If relying upon the +[`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) +object that may get passed with `add`, `addDir`, and `change` events, set +this to `true` to ensure it is provided even in cases where it wasn't +already available from the underlying watch events. +* `depth` (default: `undefined`). If set, limits how many levels of +subdirectories will be traversed. +* `awaitWriteFinish` (default: `false`). +By default, the `add` event will fire when a file first appears on disk, before +the entire file has been written. Furthermore, in some cases some `change` +events will be emitted while the file is being written. In some cases, +especially when watching for large files there will be a need to wait for the +write operation to finish before responding to a file creation or modification. +Setting `awaitWriteFinish` to `true` (or a truthy value) will poll file size, +holding its `add` and `change` events until the size does not change for a +configurable amount of time. The appropriate duration setting is heavily +dependent on the OS and hardware. For accurate detection this parameter should +be relatively high, making file watching much less responsive. +Use with caution. + * *`options.awaitWriteFinish` can be set to an object in order to adjust + timing params:* + * `awaitWriteFinish.stabilityThreshold` (default: 2000). Amount of time in + milliseconds for a file size to remain constant before emitting its event. + * `awaitWriteFinish.pollInterval` (default: 100). File size polling interval, in milliseconds. + +#### Errors + +* `ignorePermissionErrors` (default: `false`). Indicates whether to watch files +that don't have read permissions if possible. If watching fails due to `EPERM` +or `EACCES` with this set to `true`, the errors will be suppressed silently. +* `atomic` (default: `true` if `useFsEvents` and `usePolling` are `false`). +Automatically filters out artifacts that occur when using editors that use +"atomic writes" instead of writing directly to the source file. If a file is +re-added within 100 ms of being deleted, Chokidar emits a `change` event +rather than `unlink` then `add`. If the default of 100 ms does not work well +for you, you can override it by setting `atomic` to a custom value, in +milliseconds. + +### Methods & Events + +`chokidar.watch()` produces an instance of `FSWatcher`. Methods of `FSWatcher`: + +* `.add(path / paths)`: Add files, directories, or glob patterns for tracking. +Takes an array of strings or just one string. +* `.on(event, callback)`: Listen for an FS event. +Available events: `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `ready`, +`raw`, `error`. +Additionally `all` is available which gets emitted with the underlying event +name and path for every event other than `ready`, `raw`, and `error`. `raw` is internal, use it carefully. +* `.unwatch(path / paths)`: Stop watching files, directories, or glob patterns. +Takes an array of strings or just one string. +* `.close()`: **async** Removes all listeners from watched files. Asynchronous, returns Promise. Use with `await` to ensure bugs don't happen. +* `.getWatched()`: Returns an object representing all the paths on the file +system being watched by this `FSWatcher` instance. The object's keys are all the +directories (using absolute paths unless the `cwd` option was used), and the +values are arrays of the names of the items contained in each directory. + +## CLI + +If you need a CLI interface for your file watching, check out +[chokidar-cli](https://github.com/open-cli-tools/chokidar-cli), allowing you to +execute a command on each change, or get a stdio stream of change events. + +## Install Troubleshooting + +* `npm WARN optional dep failed, continuing fsevents@n.n.n` + * This message is normal part of how `npm` handles optional dependencies and is + not indicative of a problem. Even if accompanied by other related error messages, + Chokidar should function properly. + +* `TypeError: fsevents is not a constructor` + * Update chokidar by doing `rm -rf node_modules package-lock.json yarn.lock && npm install`, or update your dependency that uses chokidar. + +* Chokidar is producing `ENOSP` error on Linux, like this: + * `bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell` + `Error: watch /home/ ENOSPC` + * This means Chokidar ran out of file handles and you'll need to increase their count by executing the following command in Terminal: + `echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p` + +## Changelog + +For more detailed changelog, see [`full_changelog.md`](.github/full_changelog.md). +- **v3.5 (Jan 6, 2021):** Support for ARM Macs with Apple Silicon. Fixes for deleted symlinks. +- **v3.4 (Apr 26, 2020):** Support for directory-based symlinks. Fixes for macos file replacement. +- **v3.3 (Nov 2, 2019):** `FSWatcher#close()` method became async. That fixes IO race conditions related to close method. +- **v3.2 (Oct 1, 2019):** Improve Linux RAM usage by 50%. Race condition fixes. Windows glob fixes. Improve stability by using tight range of dependency versions. +- **v3.1 (Sep 16, 2019):** dotfiles are no longer filtered out by default. Use `ignored` option if needed. Improve initial Linux scan time by 50%. +- **v3 (Apr 30, 2019):** massive CPU & RAM consumption improvements; reduces deps / package size by a factor of 17x and bumps Node.js requirement to v8.16 and higher. +- **v2 (Dec 29, 2017):** Globs are now posix-style-only; without windows support. Tons of bugfixes. +- **v1 (Apr 7, 2015):** Glob support, symlink support, tons of bugfixes. Node 0.8+ is supported +- **v0.1 (Apr 20, 2012):** Initial release, extracted from [Brunch](https://github.com/brunch/brunch/blob/9847a065aea300da99bd0753f90354cde9de1261/src/helpers.coffee#L66) + +## Also + +Why was chokidar named this way? What's the meaning behind it? + +>Chowkidar is a transliteration of a Hindi word meaning 'watchman, gatekeeper', चौकीदार. This ultimately comes from Sanskrit _ चतुष्क_ (crossway, quadrangle, consisting-of-four). + +## License + +MIT (c) Paul Miller (), see [LICENSE](LICENSE) file. diff --git a/node_modules/chokidar/index.js b/node_modules/chokidar/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ed4b6d5b6cbabee76c879c6eedcc7bf6ba46d38d --- /dev/null +++ b/node_modules/chokidar/index.js @@ -0,0 +1,973 @@ +'use strict'; + +const { EventEmitter } = require('events'); +const fs = require('fs'); +const sysPath = require('path'); +const { promisify } = require('util'); +const readdirp = require('readdirp'); +const anymatch = require('anymatch').default; +const globParent = require('glob-parent'); +const isGlob = require('is-glob'); +const braces = require('braces'); +const normalizePath = require('normalize-path'); + +const NodeFsHandler = require('./lib/nodefs-handler'); +const FsEventsHandler = require('./lib/fsevents-handler'); +const { + EV_ALL, + EV_READY, + EV_ADD, + EV_CHANGE, + EV_UNLINK, + EV_ADD_DIR, + EV_UNLINK_DIR, + EV_RAW, + EV_ERROR, + + STR_CLOSE, + STR_END, + + BACK_SLASH_RE, + DOUBLE_SLASH_RE, + SLASH_OR_BACK_SLASH_RE, + DOT_RE, + REPLACER_RE, + + SLASH, + SLASH_SLASH, + BRACE_START, + BANG, + ONE_DOT, + TWO_DOTS, + GLOBSTAR, + SLASH_GLOBSTAR, + ANYMATCH_OPTS, + STRING_TYPE, + FUNCTION_TYPE, + EMPTY_STR, + EMPTY_FN, + + isWindows, + isMacos, + isIBMi +} = require('./lib/constants'); + +const stat = promisify(fs.stat); +const readdir = promisify(fs.readdir); + +/** + * @typedef {String} Path + * @typedef {'all'|'add'|'addDir'|'change'|'unlink'|'unlinkDir'|'raw'|'error'|'ready'} EventName + * @typedef {'readdir'|'watch'|'add'|'remove'|'change'} ThrottleType + */ + +/** + * + * @typedef {Object} WatchHelpers + * @property {Boolean} followSymlinks + * @property {'stat'|'lstat'} statMethod + * @property {Path} path + * @property {Path} watchPath + * @property {Function} entryPath + * @property {Boolean} hasGlob + * @property {Object} globFilter + * @property {Function} filterPath + * @property {Function} filterDir + */ + +const arrify = (value = []) => Array.isArray(value) ? value : [value]; +const flatten = (list, result = []) => { + list.forEach(item => { + if (Array.isArray(item)) { + flatten(item, result); + } else { + result.push(item); + } + }); + return result; +}; + +const unifyPaths = (paths_) => { + /** + * @type {Array} + */ + const paths = flatten(arrify(paths_)); + if (!paths.every(p => typeof p === STRING_TYPE)) { + throw new TypeError(`Non-string provided as watch path: ${paths}`); + } + return paths.map(normalizePathToUnix); +}; + +// If SLASH_SLASH occurs at the beginning of path, it is not replaced +// because "//StoragePC/DrivePool/Movies" is a valid network path +const toUnix = (string) => { + let str = string.replace(BACK_SLASH_RE, SLASH); + let prepend = false; + if (str.startsWith(SLASH_SLASH)) { + prepend = true; + } + while (str.match(DOUBLE_SLASH_RE)) { + str = str.replace(DOUBLE_SLASH_RE, SLASH); + } + if (prepend) { + str = SLASH + str; + } + return str; +}; + +// Our version of upath.normalize +// TODO: this is not equal to path-normalize module - investigate why +const normalizePathToUnix = (path) => toUnix(sysPath.normalize(toUnix(path))); + +const normalizeIgnored = (cwd = EMPTY_STR) => (path) => { + if (typeof path !== STRING_TYPE) return path; + return normalizePathToUnix(sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path)); +}; + +const getAbsolutePath = (path, cwd) => { + if (sysPath.isAbsolute(path)) { + return path; + } + if (path.startsWith(BANG)) { + return BANG + sysPath.join(cwd, path.slice(1)); + } + return sysPath.join(cwd, path); +}; + +const undef = (opts, key) => opts[key] === undefined; + +/** + * Directory entry. + * @property {Path} path + * @property {Set} items + */ +class DirEntry { + /** + * @param {Path} dir + * @param {Function} removeWatcher + */ + constructor(dir, removeWatcher) { + this.path = dir; + this._removeWatcher = removeWatcher; + /** @type {Set} */ + this.items = new Set(); + } + + add(item) { + const {items} = this; + if (!items) return; + if (item !== ONE_DOT && item !== TWO_DOTS) items.add(item); + } + + async remove(item) { + const {items} = this; + if (!items) return; + items.delete(item); + if (items.size > 0) return; + + const dir = this.path; + try { + await readdir(dir); + } catch (err) { + if (this._removeWatcher) { + this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir)); + } + } + } + + has(item) { + const {items} = this; + if (!items) return; + return items.has(item); + } + + /** + * @returns {Array} + */ + getChildren() { + const {items} = this; + if (!items) return; + return [...items.values()]; + } + + dispose() { + this.items.clear(); + delete this.path; + delete this._removeWatcher; + delete this.items; + Object.freeze(this); + } +} + +const STAT_METHOD_F = 'stat'; +const STAT_METHOD_L = 'lstat'; +class WatchHelper { + constructor(path, watchPath, follow, fsw) { + this.fsw = fsw; + this.path = path = path.replace(REPLACER_RE, EMPTY_STR); + this.watchPath = watchPath; + this.fullWatchPath = sysPath.resolve(watchPath); + this.hasGlob = watchPath !== path; + /** @type {object|boolean} */ + if (path === EMPTY_STR) this.hasGlob = false; + this.globSymlink = this.hasGlob && follow ? undefined : false; + this.globFilter = this.hasGlob ? anymatch(path, undefined, ANYMATCH_OPTS) : false; + this.dirParts = this.getDirParts(path); + this.dirParts.forEach((parts) => { + if (parts.length > 1) parts.pop(); + }); + this.followSymlinks = follow; + this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L; + } + + checkGlobSymlink(entry) { + // only need to resolve once + // first entry should always have entry.parentDir === EMPTY_STR + if (this.globSymlink === undefined) { + this.globSymlink = entry.fullParentDir === this.fullWatchPath ? + false : {realPath: entry.fullParentDir, linkPath: this.fullWatchPath}; + } + + if (this.globSymlink) { + return entry.fullPath.replace(this.globSymlink.realPath, this.globSymlink.linkPath); + } + + return entry.fullPath; + } + + entryPath(entry) { + return sysPath.join(this.watchPath, + sysPath.relative(this.watchPath, this.checkGlobSymlink(entry)) + ); + } + + filterPath(entry) { + const {stats} = entry; + if (stats && stats.isSymbolicLink()) return this.filterDir(entry); + const resolvedPath = this.entryPath(entry); + const matchesGlob = this.hasGlob && typeof this.globFilter === FUNCTION_TYPE ? + this.globFilter(resolvedPath) : true; + return matchesGlob && + this.fsw._isntIgnored(resolvedPath, stats) && + this.fsw._hasReadPermissions(stats); + } + + getDirParts(path) { + if (!this.hasGlob) return []; + const parts = []; + const expandedPath = path.includes(BRACE_START) ? braces.expand(path) : [path]; + expandedPath.forEach((path) => { + parts.push(sysPath.relative(this.watchPath, path).split(SLASH_OR_BACK_SLASH_RE)); + }); + return parts; + } + + filterDir(entry) { + if (this.hasGlob) { + const entryParts = this.getDirParts(this.checkGlobSymlink(entry)); + let globstar = false; + this.unmatchedGlob = !this.dirParts.some((parts) => { + return parts.every((part, i) => { + if (part === GLOBSTAR) globstar = true; + return globstar || !entryParts[0][i] || anymatch(part, entryParts[0][i], ANYMATCH_OPTS); + }); + }); + } + return !this.unmatchedGlob && this.fsw._isntIgnored(this.entryPath(entry), entry.stats); + } +} + +/** + * Watches files & directories for changes. Emitted events: + * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error` + * + * new FSWatcher() + * .add(directories) + * .on('add', path => log('File', path, 'was added')) + */ +class FSWatcher extends EventEmitter { +// Not indenting methods for history sake; for now. +constructor(_opts) { + super(); + + const opts = {}; + if (_opts) Object.assign(opts, _opts); // for frozen objects + + /** @type {Map} */ + this._watched = new Map(); + /** @type {Map} */ + this._closers = new Map(); + /** @type {Set} */ + this._ignoredPaths = new Set(); + + /** @type {Map} */ + this._throttled = new Map(); + + /** @type {Map} */ + this._symlinkPaths = new Map(); + + this._streams = new Set(); + this.closed = false; + + // Set up default options. + if (undef(opts, 'persistent')) opts.persistent = true; + if (undef(opts, 'ignoreInitial')) opts.ignoreInitial = false; + if (undef(opts, 'ignorePermissionErrors')) opts.ignorePermissionErrors = false; + if (undef(opts, 'interval')) opts.interval = 100; + if (undef(opts, 'binaryInterval')) opts.binaryInterval = 300; + if (undef(opts, 'disableGlobbing')) opts.disableGlobbing = false; + opts.enableBinaryInterval = opts.binaryInterval !== opts.interval; + + // Enable fsevents on OS X when polling isn't explicitly enabled. + if (undef(opts, 'useFsEvents')) opts.useFsEvents = !opts.usePolling; + + // If we can't use fsevents, ensure the options reflect it's disabled. + const canUseFsEvents = FsEventsHandler.canUse(); + if (!canUseFsEvents) opts.useFsEvents = false; + + // Use polling on Mac if not using fsevents. + // Other platforms use non-polling fs_watch. + if (undef(opts, 'usePolling') && !opts.useFsEvents) { + opts.usePolling = isMacos; + } + + // Always default to polling on IBM i because fs.watch() is not available on IBM i. + if(isIBMi) { + opts.usePolling = true; + } + + // Global override (useful for end-developers that need to force polling for all + // instances of chokidar, regardless of usage/dependency depth) + const envPoll = process.env.CHOKIDAR_USEPOLLING; + if (envPoll !== undefined) { + const envLower = envPoll.toLowerCase(); + + if (envLower === 'false' || envLower === '0') { + opts.usePolling = false; + } else if (envLower === 'true' || envLower === '1') { + opts.usePolling = true; + } else { + opts.usePolling = !!envLower; + } + } + const envInterval = process.env.CHOKIDAR_INTERVAL; + if (envInterval) { + opts.interval = Number.parseInt(envInterval, 10); + } + + // Editor atomic write normalization enabled by default with fs.watch + if (undef(opts, 'atomic')) opts.atomic = !opts.usePolling && !opts.useFsEvents; + if (opts.atomic) this._pendingUnlinks = new Map(); + + if (undef(opts, 'followSymlinks')) opts.followSymlinks = true; + + if (undef(opts, 'awaitWriteFinish')) opts.awaitWriteFinish = false; + if (opts.awaitWriteFinish === true) opts.awaitWriteFinish = {}; + const awf = opts.awaitWriteFinish; + if (awf) { + if (!awf.stabilityThreshold) awf.stabilityThreshold = 2000; + if (!awf.pollInterval) awf.pollInterval = 100; + this._pendingWrites = new Map(); + } + if (opts.ignored) opts.ignored = arrify(opts.ignored); + + let readyCalls = 0; + this._emitReady = () => { + readyCalls++; + if (readyCalls >= this._readyCount) { + this._emitReady = EMPTY_FN; + this._readyEmitted = true; + // use process.nextTick to allow time for listener to be bound + process.nextTick(() => this.emit(EV_READY)); + } + }; + this._emitRaw = (...args) => this.emit(EV_RAW, ...args); + this._readyEmitted = false; + this.options = opts; + + // Initialize with proper watcher. + if (opts.useFsEvents) { + this._fsEventsHandler = new FsEventsHandler(this); + } else { + this._nodeFsHandler = new NodeFsHandler(this); + } + + // You’re frozen when your heart’s not open. + Object.freeze(opts); +} + +// Public methods + +/** + * Adds paths to be watched on an existing FSWatcher instance + * @param {Path|Array} paths_ + * @param {String=} _origAdd private; for handling non-existent paths to be watched + * @param {Boolean=} _internal private; indicates a non-user add + * @returns {FSWatcher} for chaining + */ +add(paths_, _origAdd, _internal) { + const {cwd, disableGlobbing} = this.options; + this.closed = false; + let paths = unifyPaths(paths_); + if (cwd) { + paths = paths.map((path) => { + const absPath = getAbsolutePath(path, cwd); + + // Check `path` instead of `absPath` because the cwd portion can't be a glob + if (disableGlobbing || !isGlob(path)) { + return absPath; + } + return normalizePath(absPath); + }); + } + + // set aside negated glob strings + paths = paths.filter((path) => { + if (path.startsWith(BANG)) { + this._ignoredPaths.add(path.slice(1)); + return false; + } + + // if a path is being added that was previously ignored, stop ignoring it + this._ignoredPaths.delete(path); + this._ignoredPaths.delete(path + SLASH_GLOBSTAR); + + // reset the cached userIgnored anymatch fn + // to make ignoredPaths changes effective + this._userIgnored = undefined; + + return true; + }); + + if (this.options.useFsEvents && this._fsEventsHandler) { + if (!this._readyCount) this._readyCount = paths.length; + if (this.options.persistent) this._readyCount *= 2; + paths.forEach((path) => this._fsEventsHandler._addToFsEvents(path)); + } else { + if (!this._readyCount) this._readyCount = 0; + this._readyCount += paths.length; + Promise.all( + paths.map(async path => { + const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, 0, 0, _origAdd); + if (res) this._emitReady(); + return res; + }) + ).then(results => { + if (this.closed) return; + results.filter(item => item).forEach(item => { + this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item)); + }); + }); + } + + return this; +} + +/** + * Close watchers or start ignoring events from specified paths. + * @param {Path|Array} paths_ - string or array of strings, file/directory paths and/or globs + * @returns {FSWatcher} for chaining +*/ +unwatch(paths_) { + if (this.closed) return this; + const paths = unifyPaths(paths_); + const {cwd} = this.options; + + paths.forEach((path) => { + // convert to absolute path unless relative path already matches + if (!sysPath.isAbsolute(path) && !this._closers.has(path)) { + if (cwd) path = sysPath.join(cwd, path); + path = sysPath.resolve(path); + } + + this._closePath(path); + + this._ignoredPaths.add(path); + if (this._watched.has(path)) { + this._ignoredPaths.add(path + SLASH_GLOBSTAR); + } + + // reset the cached userIgnored anymatch fn + // to make ignoredPaths changes effective + this._userIgnored = undefined; + }); + + return this; +} + +/** + * Close watchers and remove all listeners from watched paths. + * @returns {Promise}. +*/ +close() { + if (this.closed) return this._closePromise; + this.closed = true; + + // Memory management. + this.removeAllListeners(); + const closers = []; + this._closers.forEach(closerList => closerList.forEach(closer => { + const promise = closer(); + if (promise instanceof Promise) closers.push(promise); + })); + this._streams.forEach(stream => stream.destroy()); + this._userIgnored = undefined; + this._readyCount = 0; + this._readyEmitted = false; + this._watched.forEach(dirent => dirent.dispose()); + ['closers', 'watched', 'streams', 'symlinkPaths', 'throttled'].forEach(key => { + this[`_${key}`].clear(); + }); + + this._closePromise = closers.length ? Promise.all(closers).then(() => undefined) : Promise.resolve(); + return this._closePromise; +} + +/** + * Expose list of watched paths + * @returns {Object} for chaining +*/ +getWatched() { + const watchList = {}; + this._watched.forEach((entry, dir) => { + const key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir; + watchList[key || ONE_DOT] = entry.getChildren().sort(); + }); + return watchList; +} + +emitWithAll(event, args) { + this.emit(...args); + if (event !== EV_ERROR) this.emit(EV_ALL, ...args); +} + +// Common helpers +// -------------- + +/** + * Normalize and emit events. + * Calling _emit DOES NOT MEAN emit() would be called! + * @param {EventName} event Type of event + * @param {Path} path File or directory path + * @param {*=} val1 arguments to be passed with event + * @param {*=} val2 + * @param {*=} val3 + * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag + */ +async _emit(event, path, val1, val2, val3) { + if (this.closed) return; + + const opts = this.options; + if (isWindows) path = sysPath.normalize(path); + if (opts.cwd) path = sysPath.relative(opts.cwd, path); + /** @type Array */ + const args = [event, path]; + if (val3 !== undefined) args.push(val1, val2, val3); + else if (val2 !== undefined) args.push(val1, val2); + else if (val1 !== undefined) args.push(val1); + + const awf = opts.awaitWriteFinish; + let pw; + if (awf && (pw = this._pendingWrites.get(path))) { + pw.lastChange = new Date(); + return this; + } + + if (opts.atomic) { + if (event === EV_UNLINK) { + this._pendingUnlinks.set(path, args); + setTimeout(() => { + this._pendingUnlinks.forEach((entry, path) => { + this.emit(...entry); + this.emit(EV_ALL, ...entry); + this._pendingUnlinks.delete(path); + }); + }, typeof opts.atomic === 'number' ? opts.atomic : 100); + return this; + } + if (event === EV_ADD && this._pendingUnlinks.has(path)) { + event = args[0] = EV_CHANGE; + this._pendingUnlinks.delete(path); + } + } + + if (awf && (event === EV_ADD || event === EV_CHANGE) && this._readyEmitted) { + const awfEmit = (err, stats) => { + if (err) { + event = args[0] = EV_ERROR; + args[1] = err; + this.emitWithAll(event, args); + } else if (stats) { + // if stats doesn't exist the file must have been deleted + if (args.length > 2) { + args[2] = stats; + } else { + args.push(stats); + } + this.emitWithAll(event, args); + } + }; + + this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit); + return this; + } + + if (event === EV_CHANGE) { + const isThrottled = !this._throttle(EV_CHANGE, path, 50); + if (isThrottled) return this; + } + + if (opts.alwaysStat && val1 === undefined && + (event === EV_ADD || event === EV_ADD_DIR || event === EV_CHANGE) + ) { + const fullPath = opts.cwd ? sysPath.join(opts.cwd, path) : path; + let stats; + try { + stats = await stat(fullPath); + } catch (err) {} + // Suppress event when fs_stat fails, to avoid sending undefined 'stat' + if (!stats || this.closed) return; + args.push(stats); + } + this.emitWithAll(event, args); + + return this; +} + +/** + * Common handler for errors + * @param {Error} error + * @returns {Error|Boolean} The error if defined, otherwise the value of the FSWatcher instance's `closed` flag + */ +_handleError(error) { + const code = error && error.code; + if (error && code !== 'ENOENT' && code !== 'ENOTDIR' && + (!this.options.ignorePermissionErrors || (code !== 'EPERM' && code !== 'EACCES')) + ) { + this.emit(EV_ERROR, error); + } + return error || this.closed; +} + +/** + * Helper utility for throttling + * @param {ThrottleType} actionType type being throttled + * @param {Path} path being acted upon + * @param {Number} timeout duration of time to suppress duplicate actions + * @returns {Object|false} tracking object or false if action should be suppressed + */ +_throttle(actionType, path, timeout) { + if (!this._throttled.has(actionType)) { + this._throttled.set(actionType, new Map()); + } + + /** @type {Map} */ + const action = this._throttled.get(actionType); + /** @type {Object} */ + const actionPath = action.get(path); + + if (actionPath) { + actionPath.count++; + return false; + } + + let timeoutObject; + const clear = () => { + const item = action.get(path); + const count = item ? item.count : 0; + action.delete(path); + clearTimeout(timeoutObject); + if (item) clearTimeout(item.timeoutObject); + return count; + }; + timeoutObject = setTimeout(clear, timeout); + const thr = {timeoutObject, clear, count: 0}; + action.set(path, thr); + return thr; +} + +_incrReadyCount() { + return this._readyCount++; +} + +/** + * Awaits write operation to finish. + * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback. + * @param {Path} path being acted upon + * @param {Number} threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished + * @param {EventName} event + * @param {Function} awfEmit Callback to be called when ready for event to be emitted. + */ +_awaitWriteFinish(path, threshold, event, awfEmit) { + let timeoutHandler; + + let fullPath = path; + if (this.options.cwd && !sysPath.isAbsolute(path)) { + fullPath = sysPath.join(this.options.cwd, path); + } + + const now = new Date(); + + const awaitWriteFinish = (prevStat) => { + fs.stat(fullPath, (err, curStat) => { + if (err || !this._pendingWrites.has(path)) { + if (err && err.code !== 'ENOENT') awfEmit(err); + return; + } + + const now = Number(new Date()); + + if (prevStat && curStat.size !== prevStat.size) { + this._pendingWrites.get(path).lastChange = now; + } + const pw = this._pendingWrites.get(path); + const df = now - pw.lastChange; + + if (df >= threshold) { + this._pendingWrites.delete(path); + awfEmit(undefined, curStat); + } else { + timeoutHandler = setTimeout( + awaitWriteFinish, + this.options.awaitWriteFinish.pollInterval, + curStat + ); + } + }); + }; + + if (!this._pendingWrites.has(path)) { + this._pendingWrites.set(path, { + lastChange: now, + cancelWait: () => { + this._pendingWrites.delete(path); + clearTimeout(timeoutHandler); + return event; + } + }); + timeoutHandler = setTimeout( + awaitWriteFinish, + this.options.awaitWriteFinish.pollInterval + ); + } +} + +_getGlobIgnored() { + return [...this._ignoredPaths.values()]; +} + +/** + * Determines whether user has asked to ignore this path. + * @param {Path} path filepath or dir + * @param {fs.Stats=} stats result of fs.stat + * @returns {Boolean} + */ +_isIgnored(path, stats) { + if (this.options.atomic && DOT_RE.test(path)) return true; + if (!this._userIgnored) { + const {cwd} = this.options; + const ign = this.options.ignored; + + const ignored = ign && ign.map(normalizeIgnored(cwd)); + const paths = arrify(ignored) + .filter((path) => typeof path === STRING_TYPE && !isGlob(path)) + .map((path) => path + SLASH_GLOBSTAR); + const list = this._getGlobIgnored().map(normalizeIgnored(cwd)).concat(ignored, paths); + this._userIgnored = anymatch(list, undefined, ANYMATCH_OPTS); + } + + return this._userIgnored([path, stats]); +} + +_isntIgnored(path, stat) { + return !this._isIgnored(path, stat); +} + +/** + * Provides a set of common helpers and properties relating to symlink and glob handling. + * @param {Path} path file, directory, or glob pattern being watched + * @param {Number=} depth at any depth > 0, this isn't a glob + * @returns {WatchHelper} object containing helpers for this path + */ +_getWatchHelpers(path, depth) { + const watchPath = depth || this.options.disableGlobbing || !isGlob(path) ? path : globParent(path); + const follow = this.options.followSymlinks; + + return new WatchHelper(path, watchPath, follow, this); +} + +// Directory helpers +// ----------------- + +/** + * Provides directory tracking objects + * @param {String} directory path of the directory + * @returns {DirEntry} the directory's tracking object + */ +_getWatchedDir(directory) { + if (!this._boundRemove) this._boundRemove = this._remove.bind(this); + const dir = sysPath.resolve(directory); + if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove)); + return this._watched.get(dir); +} + +// File helpers +// ------------ + +/** + * Check for read permissions. + * Based on this answer on SO: https://stackoverflow.com/a/11781404/1358405 + * @param {fs.Stats} stats - object, result of fs_stat + * @returns {Boolean} indicates whether the file can be read +*/ +_hasReadPermissions(stats) { + if (this.options.ignorePermissionErrors) return true; + + // stats.mode may be bigint + const md = stats && Number.parseInt(stats.mode, 10); + const st = md & 0o777; + const it = Number.parseInt(st.toString(8)[0], 10); + return Boolean(4 & it); +} + +/** + * Handles emitting unlink events for + * files and directories, and via recursion, for + * files and directories within directories that are unlinked + * @param {String} directory within which the following item is located + * @param {String} item base path of item/directory + * @returns {void} +*/ +_remove(directory, item, isDirectory) { + // if what is being deleted is a directory, get that directory's paths + // for recursive deleting and cleaning of watched object + // if it is not a directory, nestedDirectoryChildren will be empty array + const path = sysPath.join(directory, item); + const fullPath = sysPath.resolve(path); + isDirectory = isDirectory != null + ? isDirectory + : this._watched.has(path) || this._watched.has(fullPath); + + // prevent duplicate handling in case of arriving here nearly simultaneously + // via multiple paths (such as _handleFile and _handleDir) + if (!this._throttle('remove', path, 100)) return; + + // if the only watched file is removed, watch for its return + if (!isDirectory && !this.options.useFsEvents && this._watched.size === 1) { + this.add(directory, item, true); + } + + // This will create a new entry in the watched object in either case + // so we got to do the directory check beforehand + const wp = this._getWatchedDir(path); + const nestedDirectoryChildren = wp.getChildren(); + + // Recursively remove children directories / files. + nestedDirectoryChildren.forEach(nested => this._remove(path, nested)); + + // Check if item was on the watched list and remove it + const parent = this._getWatchedDir(directory); + const wasTracked = parent.has(item); + parent.remove(item); + + // Fixes issue #1042 -> Relative paths were detected and added as symlinks + // (https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L612), + // but never removed from the map in case the path was deleted. + // This leads to an incorrect state if the path was recreated: + // https://github.com/paulmillr/chokidar/blob/e1753ddbc9571bdc33b4a4af172d52cb6e611c10/lib/nodefs-handler.js#L553 + if (this._symlinkPaths.has(fullPath)) { + this._symlinkPaths.delete(fullPath); + } + + // If we wait for this file to be fully written, cancel the wait. + let relPath = path; + if (this.options.cwd) relPath = sysPath.relative(this.options.cwd, path); + if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) { + const event = this._pendingWrites.get(relPath).cancelWait(); + if (event === EV_ADD) return; + } + + // The Entry will either be a directory that just got removed + // or a bogus entry to a file, in either case we have to remove it + this._watched.delete(path); + this._watched.delete(fullPath); + const eventName = isDirectory ? EV_UNLINK_DIR : EV_UNLINK; + if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path); + + // Avoid conflicts if we later create another file with the same name + if (!this.options.useFsEvents) { + this._closePath(path); + } +} + +/** + * Closes all watchers for a path + * @param {Path} path + */ +_closePath(path) { + this._closeFile(path) + const dir = sysPath.dirname(path); + this._getWatchedDir(dir).remove(sysPath.basename(path)); +} + +/** + * Closes only file-specific watchers + * @param {Path} path + */ +_closeFile(path) { + const closers = this._closers.get(path); + if (!closers) return; + closers.forEach(closer => closer()); + this._closers.delete(path); +} + +/** + * + * @param {Path} path + * @param {Function} closer + */ +_addPathCloser(path, closer) { + if (!closer) return; + let list = this._closers.get(path); + if (!list) { + list = []; + this._closers.set(path, list); + } + list.push(closer); +} + +_readdirp(root, opts) { + if (this.closed) return; + const options = {type: EV_ALL, alwaysStat: true, lstat: true, ...opts}; + let stream = readdirp(root, options); + this._streams.add(stream); + stream.once(STR_CLOSE, () => { + stream = undefined; + }); + stream.once(STR_END, () => { + if (stream) { + this._streams.delete(stream); + stream = undefined; + } + }); + return stream; +} + +} + +// Export FSWatcher class +exports.FSWatcher = FSWatcher; + +/** + * Instantiates watcher with paths to be tracked. + * @param {String|Array} paths file/directory paths and/or globs + * @param {Object=} options chokidar opts + * @returns an instance of FSWatcher for chaining. + */ +const watch = (paths, options) => { + const watcher = new FSWatcher(options); + watcher.add(paths); + return watcher; +}; + +exports.watch = watch; diff --git a/node_modules/chokidar/lib/constants.js b/node_modules/chokidar/lib/constants.js new file mode 100644 index 0000000000000000000000000000000000000000..1454f85b544c33b22b2d16963c323df55927c671 --- /dev/null +++ b/node_modules/chokidar/lib/constants.js @@ -0,0 +1,65 @@ +'use strict'; + +const {sep} = require('path'); +const {platform} = process; +const os = require('os'); + +exports.EV_ALL = 'all'; +exports.EV_READY = 'ready'; +exports.EV_ADD = 'add'; +exports.EV_CHANGE = 'change'; +exports.EV_ADD_DIR = 'addDir'; +exports.EV_UNLINK = 'unlink'; +exports.EV_UNLINK_DIR = 'unlinkDir'; +exports.EV_RAW = 'raw'; +exports.EV_ERROR = 'error'; + +exports.STR_DATA = 'data'; +exports.STR_END = 'end'; +exports.STR_CLOSE = 'close'; + +exports.FSEVENT_CREATED = 'created'; +exports.FSEVENT_MODIFIED = 'modified'; +exports.FSEVENT_DELETED = 'deleted'; +exports.FSEVENT_MOVED = 'moved'; +exports.FSEVENT_CLONED = 'cloned'; +exports.FSEVENT_UNKNOWN = 'unknown'; +exports.FSEVENT_TYPE_FILE = 'file'; +exports.FSEVENT_TYPE_DIRECTORY = 'directory'; +exports.FSEVENT_TYPE_SYMLINK = 'symlink'; + +exports.KEY_LISTENERS = 'listeners'; +exports.KEY_ERR = 'errHandlers'; +exports.KEY_RAW = 'rawEmitters'; +exports.HANDLER_KEYS = [exports.KEY_LISTENERS, exports.KEY_ERR, exports.KEY_RAW]; + +exports.DOT_SLASH = `.${sep}`; + +exports.BACK_SLASH_RE = /\\/g; +exports.DOUBLE_SLASH_RE = /\/\//; +exports.SLASH_OR_BACK_SLASH_RE = /[/\\]/; +exports.DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/; +exports.REPLACER_RE = /^\.[/\\]/; + +exports.SLASH = '/'; +exports.SLASH_SLASH = '//'; +exports.BRACE_START = '{'; +exports.BANG = '!'; +exports.ONE_DOT = '.'; +exports.TWO_DOTS = '..'; +exports.STAR = '*'; +exports.GLOBSTAR = '**'; +exports.ROOT_GLOBSTAR = '/**/*'; +exports.SLASH_GLOBSTAR = '/**'; +exports.DIR_SUFFIX = 'Dir'; +exports.ANYMATCH_OPTS = {dot: true}; +exports.STRING_TYPE = 'string'; +exports.FUNCTION_TYPE = 'function'; +exports.EMPTY_STR = ''; +exports.EMPTY_FN = () => {}; +exports.IDENTITY_FN = val => val; + +exports.isWindows = platform === 'win32'; +exports.isMacos = platform === 'darwin'; +exports.isLinux = platform === 'linux'; +exports.isIBMi = os.type() === 'OS400'; diff --git a/node_modules/chokidar/lib/fsevents-handler.js b/node_modules/chokidar/lib/fsevents-handler.js new file mode 100644 index 0000000000000000000000000000000000000000..0f7f2cba857e0dbe001a5597061b11a9268d1e0e --- /dev/null +++ b/node_modules/chokidar/lib/fsevents-handler.js @@ -0,0 +1,524 @@ +'use strict'; + +const fs = require('fs'); +const sysPath = require('path'); +const { promisify } = require('util'); + +let fsevents; +try { + fsevents = require('fsevents'); +} catch (error) { + if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error); +} + +if (fsevents) { + // TODO: real check + const mtch = process.version.match(/v(\d+)\.(\d+)/); + if (mtch && mtch[1] && mtch[2]) { + const maj = Number.parseInt(mtch[1], 10); + const min = Number.parseInt(mtch[2], 10); + if (maj === 8 && min < 16) { + fsevents = undefined; + } + } +} + +const { + EV_ADD, + EV_CHANGE, + EV_ADD_DIR, + EV_UNLINK, + EV_ERROR, + STR_DATA, + STR_END, + FSEVENT_CREATED, + FSEVENT_MODIFIED, + FSEVENT_DELETED, + FSEVENT_MOVED, + // FSEVENT_CLONED, + FSEVENT_UNKNOWN, + FSEVENT_TYPE_FILE, + FSEVENT_TYPE_DIRECTORY, + FSEVENT_TYPE_SYMLINK, + + ROOT_GLOBSTAR, + DIR_SUFFIX, + DOT_SLASH, + FUNCTION_TYPE, + EMPTY_FN, + IDENTITY_FN +} = require('./constants'); + +const Depth = (value) => isNaN(value) ? {} : {depth: value}; + +const stat = promisify(fs.stat); +const lstat = promisify(fs.lstat); +const realpath = promisify(fs.realpath); + +const statMethods = { stat, lstat }; + +/** + * @typedef {String} Path + */ + +/** + * @typedef {Object} FsEventsWatchContainer + * @property {Set} listeners + * @property {Function} rawEmitter + * @property {{stop: Function}} watcher + */ + +// fsevents instance helper functions +/** + * Object to hold per-process fsevents instances (may be shared across chokidar FSWatcher instances) + * @type {Map} + */ +const FSEventsWatchers = new Map(); + +// Threshold of duplicate path prefixes at which to start +// consolidating going forward +const consolidateThreshhold = 10; + +const wrongEventFlags = new Set([ + 69888, 70400, 71424, 72704, 73472, 131328, 131840, 262912 +]); + +/** + * Instantiates the fsevents interface + * @param {Path} path path to be watched + * @param {Function} callback called when fsevents is bound and ready + * @returns {{stop: Function}} new fsevents instance + */ +const createFSEventsInstance = (path, callback) => { + const stop = fsevents.watch(path, callback); + return {stop}; +}; + +/** + * Instantiates the fsevents interface or binds listeners to an existing one covering + * the same file tree. + * @param {Path} path - to be watched + * @param {Path} realPath - real path for symlinks + * @param {Function} listener - called when fsevents emits events + * @param {Function} rawEmitter - passes data to listeners of the 'raw' event + * @returns {Function} closer + */ +function setFSEventsListener(path, realPath, listener, rawEmitter) { + let watchPath = sysPath.extname(realPath) ? sysPath.dirname(realPath) : realPath; + + const parentPath = sysPath.dirname(watchPath); + let cont = FSEventsWatchers.get(watchPath); + + // If we've accumulated a substantial number of paths that + // could have been consolidated by watching one directory + // above the current one, create a watcher on the parent + // path instead, so that we do consolidate going forward. + if (couldConsolidate(parentPath)) { + watchPath = parentPath; + } + + const resolvedPath = sysPath.resolve(path); + const hasSymlink = resolvedPath !== realPath; + + const filteredListener = (fullPath, flags, info) => { + if (hasSymlink) fullPath = fullPath.replace(realPath, resolvedPath); + if ( + fullPath === resolvedPath || + !fullPath.indexOf(resolvedPath + sysPath.sep) + ) listener(fullPath, flags, info); + }; + + // check if there is already a watcher on a parent path + // modifies `watchPath` to the parent path when it finds a match + let watchedParent = false; + for (const watchedPath of FSEventsWatchers.keys()) { + if (realPath.indexOf(sysPath.resolve(watchedPath) + sysPath.sep) === 0) { + watchPath = watchedPath; + cont = FSEventsWatchers.get(watchPath); + watchedParent = true; + break; + } + } + + if (cont || watchedParent) { + cont.listeners.add(filteredListener); + } else { + cont = { + listeners: new Set([filteredListener]), + rawEmitter, + watcher: createFSEventsInstance(watchPath, (fullPath, flags) => { + if (!cont.listeners.size) return; + const info = fsevents.getInfo(fullPath, flags); + cont.listeners.forEach(list => { + list(fullPath, flags, info); + }); + + cont.rawEmitter(info.event, fullPath, info); + }) + }; + FSEventsWatchers.set(watchPath, cont); + } + + // removes this instance's listeners and closes the underlying fsevents + // instance if there are no more listeners left + return () => { + const lst = cont.listeners; + + lst.delete(filteredListener); + if (!lst.size) { + FSEventsWatchers.delete(watchPath); + if (cont.watcher) return cont.watcher.stop().then(() => { + cont.rawEmitter = cont.watcher = undefined; + Object.freeze(cont); + }); + } + }; +} + +// Decide whether or not we should start a new higher-level +// parent watcher +const couldConsolidate = (path) => { + let count = 0; + for (const watchPath of FSEventsWatchers.keys()) { + if (watchPath.indexOf(path) === 0) { + count++; + if (count >= consolidateThreshhold) { + return true; + } + } + } + + return false; +}; + +// returns boolean indicating whether fsevents can be used +const canUse = () => fsevents && FSEventsWatchers.size < 128; + +// determines subdirectory traversal levels from root to path +const calcDepth = (path, root) => { + let i = 0; + while (!path.indexOf(root) && (path = sysPath.dirname(path)) !== root) i++; + return i; +}; + +// returns boolean indicating whether the fsevents' event info has the same type +// as the one returned by fs.stat +const sameTypes = (info, stats) => ( + info.type === FSEVENT_TYPE_DIRECTORY && stats.isDirectory() || + info.type === FSEVENT_TYPE_SYMLINK && stats.isSymbolicLink() || + info.type === FSEVENT_TYPE_FILE && stats.isFile() +) + +/** + * @mixin + */ +class FsEventsHandler { + +/** + * @param {import('../index').FSWatcher} fsw + */ +constructor(fsw) { + this.fsw = fsw; +} +checkIgnored(path, stats) { + const ipaths = this.fsw._ignoredPaths; + if (this.fsw._isIgnored(path, stats)) { + ipaths.add(path); + if (stats && stats.isDirectory()) { + ipaths.add(path + ROOT_GLOBSTAR); + } + return true; + } + + ipaths.delete(path); + ipaths.delete(path + ROOT_GLOBSTAR); +} + +addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) { + const event = watchedDir.has(item) ? EV_CHANGE : EV_ADD; + this.handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts); +} + +async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts) { + try { + const stats = await stat(path) + if (this.fsw.closed) return; + if (sameTypes(info, stats)) { + this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } else { + this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } catch (error) { + if (error.code === 'EACCES') { + this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } else { + this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } +} + +handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts) { + if (this.fsw.closed || this.checkIgnored(path)) return; + + if (event === EV_UNLINK) { + const isDirectory = info.type === FSEVENT_TYPE_DIRECTORY + // suppress unlink events on never before seen files + if (isDirectory || watchedDir.has(item)) { + this.fsw._remove(parent, item, isDirectory); + } + } else { + if (event === EV_ADD) { + // track new directories + if (info.type === FSEVENT_TYPE_DIRECTORY) this.fsw._getWatchedDir(path); + + if (info.type === FSEVENT_TYPE_SYMLINK && opts.followSymlinks) { + // push symlinks back to the top of the stack to get handled + const curDepth = opts.depth === undefined ? + undefined : calcDepth(fullPath, realPath) + 1; + return this._addToFsEvents(path, false, true, curDepth); + } + + // track new paths + // (other than symlinks being followed, which will be tracked soon) + this.fsw._getWatchedDir(parent).add(item); + } + /** + * @type {'add'|'addDir'|'unlink'|'unlinkDir'} + */ + const eventName = info.type === FSEVENT_TYPE_DIRECTORY ? event + DIR_SUFFIX : event; + this.fsw._emit(eventName, path); + if (eventName === EV_ADD_DIR) this._addToFsEvents(path, false, true); + } +} + +/** + * Handle symlinks encountered during directory scan + * @param {String} watchPath - file/dir path to be watched with fsevents + * @param {String} realPath - real path (in case of symlinks) + * @param {Function} transform - path transformer + * @param {Function} globFilter - path filter in case a glob pattern was provided + * @returns {Function} closer for the watcher instance +*/ +_watchWithFsEvents(watchPath, realPath, transform, globFilter) { + if (this.fsw.closed || this.fsw._isIgnored(watchPath)) return; + const opts = this.fsw.options; + const watchCallback = async (fullPath, flags, info) => { + if (this.fsw.closed) return; + if ( + opts.depth !== undefined && + calcDepth(fullPath, realPath) > opts.depth + ) return; + const path = transform(sysPath.join( + watchPath, sysPath.relative(watchPath, fullPath) + )); + if (globFilter && !globFilter(path)) return; + // ensure directories are tracked + const parent = sysPath.dirname(path); + const item = sysPath.basename(path); + const watchedDir = this.fsw._getWatchedDir( + info.type === FSEVENT_TYPE_DIRECTORY ? path : parent + ); + + // correct for wrong events emitted + if (wrongEventFlags.has(flags) || info.event === FSEVENT_UNKNOWN) { + if (typeof opts.ignored === FUNCTION_TYPE) { + let stats; + try { + stats = await stat(path); + } catch (error) {} + if (this.fsw.closed) return; + if (this.checkIgnored(path, stats)) return; + if (sameTypes(info, stats)) { + this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } else { + this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } else { + this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } else { + switch (info.event) { + case FSEVENT_CREATED: + case FSEVENT_MODIFIED: + return this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); + case FSEVENT_DELETED: + case FSEVENT_MOVED: + return this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts); + } + } + }; + + const closer = setFSEventsListener( + watchPath, + realPath, + watchCallback, + this.fsw._emitRaw + ); + + this.fsw._emitReady(); + return closer; +} + +/** + * Handle symlinks encountered during directory scan + * @param {String} linkPath path to symlink + * @param {String} fullPath absolute path to the symlink + * @param {Function} transform pre-existing path transformer + * @param {Number} curDepth level of subdirectories traversed to where symlink is + * @returns {Promise} + */ +async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) { + // don't follow the same symlink more than once + if (this.fsw.closed || this.fsw._symlinkPaths.has(fullPath)) return; + + this.fsw._symlinkPaths.set(fullPath, true); + this.fsw._incrReadyCount(); + + try { + const linkTarget = await realpath(linkPath); + if (this.fsw.closed) return; + if (this.fsw._isIgnored(linkTarget)) { + return this.fsw._emitReady(); + } + + this.fsw._incrReadyCount(); + + // add the linkTarget for watching with a wrapper for transform + // that causes emitted paths to incorporate the link's path + this._addToFsEvents(linkTarget || linkPath, (path) => { + let aliasedPath = linkPath; + if (linkTarget && linkTarget !== DOT_SLASH) { + aliasedPath = path.replace(linkTarget, linkPath); + } else if (path !== DOT_SLASH) { + aliasedPath = sysPath.join(linkPath, path); + } + return transform(aliasedPath); + }, false, curDepth); + } catch(error) { + if (this.fsw._handleError(error)) { + return this.fsw._emitReady(); + } + } +} + +/** + * + * @param {Path} newPath + * @param {fs.Stats} stats + */ +emitAdd(newPath, stats, processPath, opts, forceAdd) { + const pp = processPath(newPath); + const isDir = stats.isDirectory(); + const dirObj = this.fsw._getWatchedDir(sysPath.dirname(pp)); + const base = sysPath.basename(pp); + + // ensure empty dirs get tracked + if (isDir) this.fsw._getWatchedDir(pp); + if (dirObj.has(base)) return; + dirObj.add(base); + + if (!opts.ignoreInitial || forceAdd === true) { + this.fsw._emit(isDir ? EV_ADD_DIR : EV_ADD, pp, stats); + } +} + +initWatch(realPath, path, wh, processPath) { + if (this.fsw.closed) return; + const closer = this._watchWithFsEvents( + wh.watchPath, + sysPath.resolve(realPath || wh.watchPath), + processPath, + wh.globFilter + ); + this.fsw._addPathCloser(path, closer); +} + +/** + * Handle added path with fsevents + * @param {String} path file/dir path or glob pattern + * @param {Function|Boolean=} transform converts working path to what the user expects + * @param {Boolean=} forceAdd ensure add is emitted + * @param {Number=} priorDepth Level of subdirectories already traversed. + * @returns {Promise} + */ +async _addToFsEvents(path, transform, forceAdd, priorDepth) { + if (this.fsw.closed) { + return; + } + const opts = this.fsw.options; + const processPath = typeof transform === FUNCTION_TYPE ? transform : IDENTITY_FN; + + const wh = this.fsw._getWatchHelpers(path); + + // evaluate what is at the path we're being asked to watch + try { + const stats = await statMethods[wh.statMethod](wh.watchPath); + if (this.fsw.closed) return; + if (this.fsw._isIgnored(wh.watchPath, stats)) { + throw null; + } + if (stats.isDirectory()) { + // emit addDir unless this is a glob parent + if (!wh.globFilter) this.emitAdd(processPath(path), stats, processPath, opts, forceAdd); + + // don't recurse further if it would exceed depth setting + if (priorDepth && priorDepth > opts.depth) return; + + // scan the contents of the dir + this.fsw._readdirp(wh.watchPath, { + fileFilter: entry => wh.filterPath(entry), + directoryFilter: entry => wh.filterDir(entry), + ...Depth(opts.depth - (priorDepth || 0)) + }).on(STR_DATA, (entry) => { + // need to check filterPath on dirs b/c filterDir is less restrictive + if (this.fsw.closed) { + return; + } + if (entry.stats.isDirectory() && !wh.filterPath(entry)) return; + + const joinedPath = sysPath.join(wh.watchPath, entry.path); + const {fullPath} = entry; + + if (wh.followSymlinks && entry.stats.isSymbolicLink()) { + // preserve the current depth here since it can't be derived from + // real paths past the symlink + const curDepth = opts.depth === undefined ? + undefined : calcDepth(joinedPath, sysPath.resolve(wh.watchPath)) + 1; + + this._handleFsEventsSymlink(joinedPath, fullPath, processPath, curDepth); + } else { + this.emitAdd(joinedPath, entry.stats, processPath, opts, forceAdd); + } + }).on(EV_ERROR, EMPTY_FN).on(STR_END, () => { + this.fsw._emitReady(); + }); + } else { + this.emitAdd(wh.watchPath, stats, processPath, opts, forceAdd); + this.fsw._emitReady(); + } + } catch (error) { + if (!error || this.fsw._handleError(error)) { + // TODO: Strange thing: "should not choke on an ignored watch path" will be failed without 2 ready calls -__- + this.fsw._emitReady(); + this.fsw._emitReady(); + } + } + + if (opts.persistent && forceAdd !== true) { + if (typeof transform === FUNCTION_TYPE) { + // realpath has already been resolved + this.initWatch(undefined, path, wh, processPath); + } else { + let realPath; + try { + realPath = await realpath(wh.watchPath); + } catch (e) {} + this.initWatch(realPath, path, wh, processPath); + } + } +} + +} + +module.exports = FsEventsHandler; +module.exports.canUse = canUse; diff --git a/node_modules/chokidar/lib/nodefs-handler.js b/node_modules/chokidar/lib/nodefs-handler.js new file mode 100644 index 0000000000000000000000000000000000000000..199cfe9f9fff5a2f5267c67a004b1fa92ec56649 --- /dev/null +++ b/node_modules/chokidar/lib/nodefs-handler.js @@ -0,0 +1,654 @@ +'use strict'; + +const fs = require('fs'); +const sysPath = require('path'); +const { promisify } = require('util'); +const isBinaryPath = require('is-binary-path'); +const { + isWindows, + isLinux, + EMPTY_FN, + EMPTY_STR, + KEY_LISTENERS, + KEY_ERR, + KEY_RAW, + HANDLER_KEYS, + EV_CHANGE, + EV_ADD, + EV_ADD_DIR, + EV_ERROR, + STR_DATA, + STR_END, + BRACE_START, + STAR +} = require('./constants'); + +const THROTTLE_MODE_WATCH = 'watch'; + +const open = promisify(fs.open); +const stat = promisify(fs.stat); +const lstat = promisify(fs.lstat); +const close = promisify(fs.close); +const fsrealpath = promisify(fs.realpath); + +const statMethods = { lstat, stat }; + +// TODO: emit errors properly. Example: EMFILE on Macos. +const foreach = (val, fn) => { + if (val instanceof Set) { + val.forEach(fn); + } else { + fn(val); + } +}; + +const addAndConvert = (main, prop, item) => { + let container = main[prop]; + if (!(container instanceof Set)) { + main[prop] = container = new Set([container]); + } + container.add(item); +}; + +const clearItem = cont => key => { + const set = cont[key]; + if (set instanceof Set) { + set.clear(); + } else { + delete cont[key]; + } +}; + +const delFromSet = (main, prop, item) => { + const container = main[prop]; + if (container instanceof Set) { + container.delete(item); + } else if (container === item) { + delete main[prop]; + } +}; + +const isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val; + +/** + * @typedef {String} Path + */ + +// fs_watch helpers + +// object to hold per-process fs_watch instances +// (may be shared across chokidar FSWatcher instances) + +/** + * @typedef {Object} FsWatchContainer + * @property {Set} listeners + * @property {Set} errHandlers + * @property {Set} rawEmitters + * @property {fs.FSWatcher=} watcher + * @property {Boolean=} watcherUnusable + */ + +/** + * @type {Map} + */ +const FsWatchInstances = new Map(); + +/** + * Instantiates the fs_watch interface + * @param {String} path to be watched + * @param {Object} options to be passed to fs_watch + * @param {Function} listener main event handler + * @param {Function} errHandler emits info about errors + * @param {Function} emitRaw emits raw event data + * @returns {fs.FSWatcher} new fsevents instance + */ +function createFsWatchInstance(path, options, listener, errHandler, emitRaw) { + const handleEvent = (rawEvent, evPath) => { + listener(path); + emitRaw(rawEvent, evPath, {watchedPath: path}); + + // emit based on events occurring for files from a directory's watcher in + // case the file's watcher misses it (and rely on throttling to de-dupe) + if (evPath && path !== evPath) { + fsWatchBroadcast( + sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath) + ); + } + }; + try { + return fs.watch(path, options, handleEvent); + } catch (error) { + errHandler(error); + } +} + +/** + * Helper for passing fs_watch event data to a collection of listeners + * @param {Path} fullPath absolute path bound to fs_watch instance + * @param {String} type listener type + * @param {*=} val1 arguments to be passed to listeners + * @param {*=} val2 + * @param {*=} val3 + */ +const fsWatchBroadcast = (fullPath, type, val1, val2, val3) => { + const cont = FsWatchInstances.get(fullPath); + if (!cont) return; + foreach(cont[type], (listener) => { + listener(val1, val2, val3); + }); +}; + +/** + * Instantiates the fs_watch interface or binds listeners + * to an existing one covering the same file system entry + * @param {String} path + * @param {String} fullPath absolute path + * @param {Object} options to be passed to fs_watch + * @param {Object} handlers container for event listener functions + */ +const setFsWatchListener = (path, fullPath, options, handlers) => { + const {listener, errHandler, rawEmitter} = handlers; + let cont = FsWatchInstances.get(fullPath); + + /** @type {fs.FSWatcher=} */ + let watcher; + if (!options.persistent) { + watcher = createFsWatchInstance( + path, options, listener, errHandler, rawEmitter + ); + return watcher.close.bind(watcher); + } + if (cont) { + addAndConvert(cont, KEY_LISTENERS, listener); + addAndConvert(cont, KEY_ERR, errHandler); + addAndConvert(cont, KEY_RAW, rawEmitter); + } else { + watcher = createFsWatchInstance( + path, + options, + fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), + errHandler, // no need to use broadcast here + fsWatchBroadcast.bind(null, fullPath, KEY_RAW) + ); + if (!watcher) return; + watcher.on(EV_ERROR, async (error) => { + const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR); + cont.watcherUnusable = true; // documented since Node 10.4.1 + // Workaround for https://github.com/joyent/node/issues/4337 + if (isWindows && error.code === 'EPERM') { + try { + const fd = await open(path, 'r'); + await close(fd); + broadcastErr(error); + } catch (err) {} + } else { + broadcastErr(error); + } + }); + cont = { + listeners: listener, + errHandlers: errHandler, + rawEmitters: rawEmitter, + watcher + }; + FsWatchInstances.set(fullPath, cont); + } + // const index = cont.listeners.indexOf(listener); + + // removes this instance's listeners and closes the underlying fs_watch + // instance if there are no more listeners left + return () => { + delFromSet(cont, KEY_LISTENERS, listener); + delFromSet(cont, KEY_ERR, errHandler); + delFromSet(cont, KEY_RAW, rawEmitter); + if (isEmptySet(cont.listeners)) { + // Check to protect against issue gh-730. + // if (cont.watcherUnusable) { + cont.watcher.close(); + // } + FsWatchInstances.delete(fullPath); + HANDLER_KEYS.forEach(clearItem(cont)); + cont.watcher = undefined; + Object.freeze(cont); + } + }; +}; + +// fs_watchFile helpers + +// object to hold per-process fs_watchFile instances +// (may be shared across chokidar FSWatcher instances) +const FsWatchFileInstances = new Map(); + +/** + * Instantiates the fs_watchFile interface or binds listeners + * to an existing one covering the same file system entry + * @param {String} path to be watched + * @param {String} fullPath absolute path + * @param {Object} options options to be passed to fs_watchFile + * @param {Object} handlers container for event listener functions + * @returns {Function} closer + */ +const setFsWatchFileListener = (path, fullPath, options, handlers) => { + const {listener, rawEmitter} = handlers; + let cont = FsWatchFileInstances.get(fullPath); + + /* eslint-disable no-unused-vars, prefer-destructuring */ + let listeners = new Set(); + let rawEmitters = new Set(); + + const copts = cont && cont.options; + if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) { + // "Upgrade" the watcher to persistence or a quicker interval. + // This creates some unlikely edge case issues if the user mixes + // settings in a very weird way, but solving for those cases + // doesn't seem worthwhile for the added complexity. + listeners = cont.listeners; + rawEmitters = cont.rawEmitters; + fs.unwatchFile(fullPath); + cont = undefined; + } + + /* eslint-enable no-unused-vars, prefer-destructuring */ + + if (cont) { + addAndConvert(cont, KEY_LISTENERS, listener); + addAndConvert(cont, KEY_RAW, rawEmitter); + } else { + // TODO + // listeners.add(listener); + // rawEmitters.add(rawEmitter); + cont = { + listeners: listener, + rawEmitters: rawEmitter, + options, + watcher: fs.watchFile(fullPath, options, (curr, prev) => { + foreach(cont.rawEmitters, (rawEmitter) => { + rawEmitter(EV_CHANGE, fullPath, {curr, prev}); + }); + const currmtime = curr.mtimeMs; + if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) { + foreach(cont.listeners, (listener) => listener(path, curr)); + } + }) + }; + FsWatchFileInstances.set(fullPath, cont); + } + // const index = cont.listeners.indexOf(listener); + + // Removes this instance's listeners and closes the underlying fs_watchFile + // instance if there are no more listeners left. + return () => { + delFromSet(cont, KEY_LISTENERS, listener); + delFromSet(cont, KEY_RAW, rawEmitter); + if (isEmptySet(cont.listeners)) { + FsWatchFileInstances.delete(fullPath); + fs.unwatchFile(fullPath); + cont.options = cont.watcher = undefined; + Object.freeze(cont); + } + }; +}; + +/** + * @mixin + */ +class NodeFsHandler { + +/** + * @param {import("../index").FSWatcher} fsW + */ +constructor(fsW) { + this.fsw = fsW; + this._boundHandleError = (error) => fsW._handleError(error); +} + +/** + * Watch file for changes with fs_watchFile or fs_watch. + * @param {String} path to file or dir + * @param {Function} listener on fs change + * @returns {Function} closer for the watcher instance + */ +_watchWithNodeFs(path, listener) { + const opts = this.fsw.options; + const directory = sysPath.dirname(path); + const basename = sysPath.basename(path); + const parent = this.fsw._getWatchedDir(directory); + parent.add(basename); + const absolutePath = sysPath.resolve(path); + const options = {persistent: opts.persistent}; + if (!listener) listener = EMPTY_FN; + + let closer; + if (opts.usePolling) { + options.interval = opts.enableBinaryInterval && isBinaryPath(basename) ? + opts.binaryInterval : opts.interval; + closer = setFsWatchFileListener(path, absolutePath, options, { + listener, + rawEmitter: this.fsw._emitRaw + }); + } else { + closer = setFsWatchListener(path, absolutePath, options, { + listener, + errHandler: this._boundHandleError, + rawEmitter: this.fsw._emitRaw + }); + } + return closer; +} + +/** + * Watch a file and emit add event if warranted. + * @param {Path} file Path + * @param {fs.Stats} stats result of fs_stat + * @param {Boolean} initialAdd was the file added at watch instantiation? + * @returns {Function} closer for the watcher instance + */ +_handleFile(file, stats, initialAdd) { + if (this.fsw.closed) { + return; + } + const dirname = sysPath.dirname(file); + const basename = sysPath.basename(file); + const parent = this.fsw._getWatchedDir(dirname); + // stats is always present + let prevStats = stats; + + // if the file is already being watched, do nothing + if (parent.has(basename)) return; + + const listener = async (path, newStats) => { + if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return; + if (!newStats || newStats.mtimeMs === 0) { + try { + const newStats = await stat(file); + if (this.fsw.closed) return; + // Check that change event was not fired because of changed only accessTime. + const at = newStats.atimeMs; + const mt = newStats.mtimeMs; + if (!at || at <= mt || mt !== prevStats.mtimeMs) { + this.fsw._emit(EV_CHANGE, file, newStats); + } + if (isLinux && prevStats.ino !== newStats.ino) { + this.fsw._closeFile(path) + prevStats = newStats; + this.fsw._addPathCloser(path, this._watchWithNodeFs(file, listener)); + } else { + prevStats = newStats; + } + } catch (error) { + // Fix issues where mtime is null but file is still present + this.fsw._remove(dirname, basename); + } + // add is about to be emitted if file not already tracked in parent + } else if (parent.has(basename)) { + // Check that change event was not fired because of changed only accessTime. + const at = newStats.atimeMs; + const mt = newStats.mtimeMs; + if (!at || at <= mt || mt !== prevStats.mtimeMs) { + this.fsw._emit(EV_CHANGE, file, newStats); + } + prevStats = newStats; + } + } + // kick off the watcher + const closer = this._watchWithNodeFs(file, listener); + + // emit an add event if we're supposed to + if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) { + if (!this.fsw._throttle(EV_ADD, file, 0)) return; + this.fsw._emit(EV_ADD, file, stats); + } + + return closer; +} + +/** + * Handle symlinks encountered while reading a dir. + * @param {Object} entry returned by readdirp + * @param {String} directory path of dir being read + * @param {String} path of this item + * @param {String} item basename of this item + * @returns {Promise} true if no more processing is needed for this entry. + */ +async _handleSymlink(entry, directory, path, item) { + if (this.fsw.closed) { + return; + } + const full = entry.fullPath; + const dir = this.fsw._getWatchedDir(directory); + + if (!this.fsw.options.followSymlinks) { + // watch symlink directly (don't follow) and detect changes + this.fsw._incrReadyCount(); + + let linkPath; + try { + linkPath = await fsrealpath(path); + } catch (e) { + this.fsw._emitReady(); + return true; + } + + if (this.fsw.closed) return; + if (dir.has(item)) { + if (this.fsw._symlinkPaths.get(full) !== linkPath) { + this.fsw._symlinkPaths.set(full, linkPath); + this.fsw._emit(EV_CHANGE, path, entry.stats); + } + } else { + dir.add(item); + this.fsw._symlinkPaths.set(full, linkPath); + this.fsw._emit(EV_ADD, path, entry.stats); + } + this.fsw._emitReady(); + return true; + } + + // don't follow the same symlink more than once + if (this.fsw._symlinkPaths.has(full)) { + return true; + } + + this.fsw._symlinkPaths.set(full, true); +} + +_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) { + // Normalize the directory name on Windows + directory = sysPath.join(directory, EMPTY_STR); + + if (!wh.hasGlob) { + throttler = this.fsw._throttle('readdir', directory, 1000); + if (!throttler) return; + } + + const previous = this.fsw._getWatchedDir(wh.path); + const current = new Set(); + + let stream = this.fsw._readdirp(directory, { + fileFilter: entry => wh.filterPath(entry), + directoryFilter: entry => wh.filterDir(entry), + depth: 0 + }).on(STR_DATA, async (entry) => { + if (this.fsw.closed) { + stream = undefined; + return; + } + const item = entry.path; + let path = sysPath.join(directory, item); + current.add(item); + + if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) { + return; + } + + if (this.fsw.closed) { + stream = undefined; + return; + } + // Files that present in current directory snapshot + // but absent in previous are added to watch list and + // emit `add` event. + if (item === target || !target && !previous.has(item)) { + this.fsw._incrReadyCount(); + + // ensure relativeness of path is preserved in case of watcher reuse + path = sysPath.join(dir, sysPath.relative(dir, path)); + + this._addToNodeFs(path, initialAdd, wh, depth + 1); + } + }).on(EV_ERROR, this._boundHandleError); + + return new Promise(resolve => + stream.once(STR_END, () => { + if (this.fsw.closed) { + stream = undefined; + return; + } + const wasThrottled = throttler ? throttler.clear() : false; + + resolve(); + + // Files that absent in current directory snapshot + // but present in previous emit `remove` event + // and are removed from @watched[directory]. + previous.getChildren().filter((item) => { + return item !== directory && + !current.has(item) && + // in case of intersecting globs; + // a path may have been filtered out of this readdir, but + // shouldn't be removed because it matches a different glob + (!wh.hasGlob || wh.filterPath({ + fullPath: sysPath.resolve(directory, item) + })); + }).forEach((item) => { + this.fsw._remove(directory, item); + }); + + stream = undefined; + + // one more time for any missed in case changes came in extremely quickly + if (wasThrottled) this._handleRead(directory, false, wh, target, dir, depth, throttler); + }) + ); +} + +/** + * Read directory to add / remove files from `@watched` list and re-read it on change. + * @param {String} dir fs path + * @param {fs.Stats} stats + * @param {Boolean} initialAdd + * @param {Number} depth relative to user-supplied path + * @param {String} target child path targeted for watch + * @param {Object} wh Common watch helpers for this path + * @param {String} realpath + * @returns {Promise} closer for the watcher instance. + */ +async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) { + const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir)); + const tracked = parentDir.has(sysPath.basename(dir)); + if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) { + if (!wh.hasGlob || wh.globFilter(dir)) this.fsw._emit(EV_ADD_DIR, dir, stats); + } + + // ensure dir is tracked (harmless if redundant) + parentDir.add(sysPath.basename(dir)); + this.fsw._getWatchedDir(dir); + let throttler; + let closer; + + const oDepth = this.fsw.options.depth; + if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) { + if (!target) { + await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler); + if (this.fsw.closed) return; + } + + closer = this._watchWithNodeFs(dir, (dirPath, stats) => { + // if current directory is removed, do nothing + if (stats && stats.mtimeMs === 0) return; + + this._handleRead(dirPath, false, wh, target, dir, depth, throttler); + }); + } + return closer; +} + +/** + * Handle added file, directory, or glob pattern. + * Delegates call to _handleFile / _handleDir after checks. + * @param {String} path to file or ir + * @param {Boolean} initialAdd was the file added at watch instantiation? + * @param {Object} priorWh depth relative to user-supplied path + * @param {Number} depth Child path actually targeted for watch + * @param {String=} target Child path actually targeted for watch + * @returns {Promise} + */ +async _addToNodeFs(path, initialAdd, priorWh, depth, target) { + const ready = this.fsw._emitReady; + if (this.fsw._isIgnored(path) || this.fsw.closed) { + ready(); + return false; + } + + const wh = this.fsw._getWatchHelpers(path, depth); + if (!wh.hasGlob && priorWh) { + wh.hasGlob = priorWh.hasGlob; + wh.globFilter = priorWh.globFilter; + wh.filterPath = entry => priorWh.filterPath(entry); + wh.filterDir = entry => priorWh.filterDir(entry); + } + + // evaluate what is at the path we're being asked to watch + try { + const stats = await statMethods[wh.statMethod](wh.watchPath); + if (this.fsw.closed) return; + if (this.fsw._isIgnored(wh.watchPath, stats)) { + ready(); + return false; + } + + const follow = this.fsw.options.followSymlinks && !path.includes(STAR) && !path.includes(BRACE_START); + let closer; + if (stats.isDirectory()) { + const absPath = sysPath.resolve(path); + const targetPath = follow ? await fsrealpath(path) : path; + if (this.fsw.closed) return; + closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath); + if (this.fsw.closed) return; + // preserve this symlink's target path + if (absPath !== targetPath && targetPath !== undefined) { + this.fsw._symlinkPaths.set(absPath, targetPath); + } + } else if (stats.isSymbolicLink()) { + const targetPath = follow ? await fsrealpath(path) : path; + if (this.fsw.closed) return; + const parent = sysPath.dirname(wh.watchPath); + this.fsw._getWatchedDir(parent).add(wh.watchPath); + this.fsw._emit(EV_ADD, wh.watchPath, stats); + closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath); + if (this.fsw.closed) return; + + // preserve this symlink's target path + if (targetPath !== undefined) { + this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath); + } + } else { + closer = this._handleFile(wh.watchPath, stats, initialAdd); + } + ready(); + + this.fsw._addPathCloser(path, closer); + return false; + + } catch (error) { + if (this.fsw._handleError(error)) { + ready(); + return path; + } + } +} + +} + +module.exports = NodeFsHandler; diff --git a/node_modules/chokidar/package.json b/node_modules/chokidar/package.json new file mode 100644 index 0000000000000000000000000000000000000000..6c3cd27c7bccf1a1b7e349e5de20330006f5ea9a --- /dev/null +++ b/node_modules/chokidar/package.json @@ -0,0 +1,85 @@ +{ + "name": "chokidar", + "description": "Minimal and efficient cross-platform file watching library", + "version": "3.5.3", + "homepage": "https://github.com/paulmillr/chokidar", + "author": "Paul Miller (https://paulmillr.com)", + "contributors": [ + "Paul Miller (https://paulmillr.com)", + "Elan Shanker" + ], + "engines": { + "node": ">= 8.10.0" + }, + "main": "index.js", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "devDependencies": { + "@types/node": "^14", + "chai": "^4.3", + "dtslint": "^3.3.0", + "eslint": "^7.0.0", + "mocha": "^7.0.0", + "nyc": "^15.0.0", + "rimraf": "^3.0.0", + "sinon": "^9.0.1", + "sinon-chai": "^3.3.0", + "typescript": "~4.4.3", + "upath": "^1.2.0" + }, + "files": [ + "index.js", + "lib/*.js", + "types/index.d.ts" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/paulmillr/chokidar.git" + }, + "bugs": { + "url": "https://github.com/paulmillr/chokidar/issues" + }, + "license": "MIT", + "scripts": { + "dtslint": "dtslint types", + "lint": "eslint --report-unused-disable-directives --ignore-path .gitignore .", + "mocha": "mocha --exit --timeout 90000", + "test": "npm run lint && npm run mocha" + }, + "keywords": [ + "fs", + "watch", + "watchFile", + "watcher", + "watching", + "file", + "fsevents" + ], + "types": "./types/index.d.ts", + "nyc": { + "include": [ + "index.js", + "lib/*.js" + ], + "reporter": [ + "html", + "text" + ] + }, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] +} diff --git a/node_modules/chokidar/types/index.d.ts b/node_modules/chokidar/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aab8e337accaf54e81b171ca3b7674e337d4794b --- /dev/null +++ b/node_modules/chokidar/types/index.d.ts @@ -0,0 +1,188 @@ +// TypeScript Version: 3.0 + +/// + +import * as fs from "fs"; +import { EventEmitter } from "events"; +import { Matcher } from 'anymatch'; + +export class FSWatcher extends EventEmitter implements fs.FSWatcher { + options: WatchOptions; + + /** + * Constructs a new FSWatcher instance with optional WatchOptions parameter. + */ + constructor(options?: WatchOptions); + + /** + * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one + * string. + */ + add(paths: string | ReadonlyArray): this; + + /** + * Stop watching files, directories, or glob patterns. Takes an array of strings or just one + * string. + */ + unwatch(paths: string | ReadonlyArray): this; + + /** + * Returns an object representing all the paths on the file system being watched by this + * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless + * the `cwd` option was used), and the values are arrays of the names of the items contained in + * each directory. + */ + getWatched(): { + [directory: string]: string[]; + }; + + /** + * Removes all listeners from watched files. + */ + close(): Promise; + + on(event: 'add'|'addDir'|'change', listener: (path: string, stats?: fs.Stats) => void): this; + + on(event: 'all', listener: (eventName: 'add'|'addDir'|'change'|'unlink'|'unlinkDir', path: string, stats?: fs.Stats) => void): this; + + /** + * Error occurred + */ + on(event: 'error', listener: (error: Error) => void): this; + + /** + * Exposes the native Node `fs.FSWatcher events` + */ + on(event: 'raw', listener: (eventName: string, path: string, details: any) => void): this; + + /** + * Fires when the initial scan is complete + */ + on(event: 'ready', listener: () => void): this; + + on(event: 'unlink'|'unlinkDir', listener: (path: string) => void): this; + + on(event: string, listener: (...args: any[]) => void): this; +} + +export interface WatchOptions { + /** + * Indicates whether the process should continue to run as long as files are being watched. If + * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`, + * even if the process continues to run. + */ + persistent?: boolean; + + /** + * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to + * be ignored. The whole relative or absolute path is tested, not just filename. If a function + * with two arguments is provided, it gets called twice per path - once with a single argument + * (the path), second time with two arguments (the path and the + * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path). + */ + ignored?: Matcher; + + /** + * If set to `false` then `add`/`addDir` events are also emitted for matching paths while + * instantiating the watching as chokidar discovers these file paths (before the `ready` event). + */ + ignoreInitial?: boolean; + + /** + * When `false`, only the symlinks themselves will be watched for changes instead of following + * the link references and bubbling events through the link's path. + */ + followSymlinks?: boolean; + + /** + * The base directory from which watch `paths` are to be derived. Paths emitted with events will + * be relative to this. + */ + cwd?: string; + + /** + * If set to true then the strings passed to .watch() and .add() are treated as literal path + * names, even if they look like globs. Default: false. + */ + disableGlobbing?: boolean; + + /** + * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU + * utilization, consider setting this to `false`. It is typically necessary to **set this to + * `true` to successfully watch files over a network**, and it may be necessary to successfully + * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides + * the `useFsEvents` default. + */ + usePolling?: boolean; + + /** + * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly + * and `fsevents` is available this supercedes the `usePolling` setting. When set to `false` on + * OS X, `usePolling: true` becomes the default. + */ + useFsEvents?: boolean; + + /** + * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that + * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is + * provided even in cases where it wasn't already available from the underlying watch events. + */ + alwaysStat?: boolean; + + /** + * If set, limits how many levels of subdirectories will be traversed. + */ + depth?: number; + + /** + * Interval of file system polling. + */ + interval?: number; + + /** + * Interval of file system polling for binary files. ([see list of binary extensions](https://gi + * thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json)) + */ + binaryInterval?: number; + + /** + * Indicates whether to watch files that don't have read permissions if possible. If watching + * fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed + * silently. + */ + ignorePermissionErrors?: boolean; + + /** + * `true` if `useFsEvents` and `usePolling` are `false`). Automatically filters out artifacts + * that occur when using editors that use "atomic writes" instead of writing directly to the + * source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change` + * event rather than `unlink` then `add`. If the default of 100 ms does not work well for you, + * you can override it by setting `atomic` to a custom value, in milliseconds. + */ + atomic?: boolean | number; + + /** + * can be set to an object in order to adjust timing params: + */ + awaitWriteFinish?: AwaitWriteFinishOptions | boolean; +} + +export interface AwaitWriteFinishOptions { + /** + * Amount of time in milliseconds for a file size to remain constant before emitting its event. + */ + stabilityThreshold?: number; + + /** + * File size polling interval. + */ + pollInterval?: number; +} + +/** + * produces an instance of `FSWatcher`. + */ +export function watch( + paths: string | ReadonlyArray, + options?: WatchOptions +): FSWatcher; diff --git a/node_modules/combined-stream/License b/node_modules/combined-stream/License new file mode 100644 index 0000000000000000000000000000000000000000..4804b7ab411f5f72ff74343a88bc503ecc309033 --- /dev/null +++ b/node_modules/combined-stream/License @@ -0,0 +1,19 @@ +Copyright (c) 2011 Debuggable Limited + +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. diff --git a/node_modules/combined-stream/Readme.md b/node_modules/combined-stream/Readme.md new file mode 100644 index 0000000000000000000000000000000000000000..9e367b5bc5b59c98923b75d327799e5759f15e23 --- /dev/null +++ b/node_modules/combined-stream/Readme.md @@ -0,0 +1,138 @@ +# combined-stream + +A stream that emits multiple other streams one after another. + +**NB** Currently `combined-stream` works with streams version 1 only. There is ongoing effort to switch this library to streams version 2. Any help is welcome. :) Meanwhile you can explore other libraries that provide streams2 support with more or less compatibility with `combined-stream`. + +- [combined-stream2](https://www.npmjs.com/package/combined-stream2): A drop-in streams2-compatible replacement for the combined-stream module. + +- [multistream](https://www.npmjs.com/package/multistream): A stream that emits multiple other streams one after another. + +## Installation + +``` bash +npm install combined-stream +``` + +## Usage + +Here is a simple example that shows how you can use combined-stream to combine +two files into one: + +``` javascript +var CombinedStream = require('combined-stream'); +var fs = require('fs'); + +var combinedStream = CombinedStream.create(); +combinedStream.append(fs.createReadStream('file1.txt')); +combinedStream.append(fs.createReadStream('file2.txt')); + +combinedStream.pipe(fs.createWriteStream('combined.txt')); +``` + +While the example above works great, it will pause all source streams until +they are needed. If you don't want that to happen, you can set `pauseStreams` +to `false`: + +``` javascript +var CombinedStream = require('combined-stream'); +var fs = require('fs'); + +var combinedStream = CombinedStream.create({pauseStreams: false}); +combinedStream.append(fs.createReadStream('file1.txt')); +combinedStream.append(fs.createReadStream('file2.txt')); + +combinedStream.pipe(fs.createWriteStream('combined.txt')); +``` + +However, what if you don't have all the source streams yet, or you don't want +to allocate the resources (file descriptors, memory, etc.) for them right away? +Well, in that case you can simply provide a callback that supplies the stream +by calling a `next()` function: + +``` javascript +var CombinedStream = require('combined-stream'); +var fs = require('fs'); + +var combinedStream = CombinedStream.create(); +combinedStream.append(function(next) { + next(fs.createReadStream('file1.txt')); +}); +combinedStream.append(function(next) { + next(fs.createReadStream('file2.txt')); +}); + +combinedStream.pipe(fs.createWriteStream('combined.txt')); +``` + +## API + +### CombinedStream.create([options]) + +Returns a new combined stream object. Available options are: + +* `maxDataSize` +* `pauseStreams` + +The effect of those options is described below. + +### combinedStream.pauseStreams = `true` + +Whether to apply back pressure to the underlaying streams. If set to `false`, +the underlaying streams will never be paused. If set to `true`, the +underlaying streams will be paused right after being appended, as well as when +`delayedStream.pipe()` wants to throttle. + +### combinedStream.maxDataSize = `2 * 1024 * 1024` + +The maximum amount of bytes (or characters) to buffer for all source streams. +If this value is exceeded, `combinedStream` emits an `'error'` event. + +### combinedStream.dataSize = `0` + +The amount of bytes (or characters) currently buffered by `combinedStream`. + +### combinedStream.append(stream) + +Appends the given `stream` to the combinedStream object. If `pauseStreams` is +set to `true, this stream will also be paused right away. + +`streams` can also be a function that takes one parameter called `next`. `next` +is a function that must be invoked in order to provide the `next` stream, see +example above. + +Regardless of how the `stream` is appended, combined-stream always attaches an +`'error'` listener to it, so you don't have to do that manually. + +Special case: `stream` can also be a String or Buffer. + +### combinedStream.write(data) + +You should not call this, `combinedStream` takes care of piping the appended +streams into itself for you. + +### combinedStream.resume() + +Causes `combinedStream` to start drain the streams it manages. The function is +idempotent, and also emits a `'resume'` event each time which usually goes to +the stream that is currently being drained. + +### combinedStream.pause(); + +If `combinedStream.pauseStreams` is set to `false`, this does nothing. +Otherwise a `'pause'` event is emitted, this goes to the stream that is +currently being drained, so you can use it to apply back pressure. + +### combinedStream.end(); + +Sets `combinedStream.writable` to false, emits an `'end'` event, and removes +all streams from the queue. + +### combinedStream.destroy(); + +Same as `combinedStream.end()`, except it emits a `'close'` event instead of +`'end'`. + +## License + +combined-stream is licensed under the MIT license. diff --git a/node_modules/combined-stream/lib/combined_stream.js b/node_modules/combined-stream/lib/combined_stream.js new file mode 100644 index 0000000000000000000000000000000000000000..125f097f35818ba9bb6ca9f13f693909e6034097 --- /dev/null +++ b/node_modules/combined-stream/lib/combined_stream.js @@ -0,0 +1,208 @@ +var util = require('util'); +var Stream = require('stream').Stream; +var DelayedStream = require('delayed-stream'); + +module.exports = CombinedStream; +function CombinedStream() { + this.writable = false; + this.readable = true; + this.dataSize = 0; + this.maxDataSize = 2 * 1024 * 1024; + this.pauseStreams = true; + + this._released = false; + this._streams = []; + this._currentStream = null; + this._insideLoop = false; + this._pendingNext = false; +} +util.inherits(CombinedStream, Stream); + +CombinedStream.create = function(options) { + var combinedStream = new this(); + + options = options || {}; + for (var option in options) { + combinedStream[option] = options[option]; + } + + return combinedStream; +}; + +CombinedStream.isStreamLike = function(stream) { + return (typeof stream !== 'function') + && (typeof stream !== 'string') + && (typeof stream !== 'boolean') + && (typeof stream !== 'number') + && (!Buffer.isBuffer(stream)); +}; + +CombinedStream.prototype.append = function(stream) { + var isStreamLike = CombinedStream.isStreamLike(stream); + + if (isStreamLike) { + if (!(stream instanceof DelayedStream)) { + var newStream = DelayedStream.create(stream, { + maxDataSize: Infinity, + pauseStream: this.pauseStreams, + }); + stream.on('data', this._checkDataSize.bind(this)); + stream = newStream; + } + + this._handleErrors(stream); + + if (this.pauseStreams) { + stream.pause(); + } + } + + this._streams.push(stream); + return this; +}; + +CombinedStream.prototype.pipe = function(dest, options) { + Stream.prototype.pipe.call(this, dest, options); + this.resume(); + return dest; +}; + +CombinedStream.prototype._getNext = function() { + this._currentStream = null; + + if (this._insideLoop) { + this._pendingNext = true; + return; // defer call + } + + this._insideLoop = true; + try { + do { + this._pendingNext = false; + this._realGetNext(); + } while (this._pendingNext); + } finally { + this._insideLoop = false; + } +}; + +CombinedStream.prototype._realGetNext = function() { + var stream = this._streams.shift(); + + + if (typeof stream == 'undefined') { + this.end(); + return; + } + + if (typeof stream !== 'function') { + this._pipeNext(stream); + return; + } + + var getStream = stream; + getStream(function(stream) { + var isStreamLike = CombinedStream.isStreamLike(stream); + if (isStreamLike) { + stream.on('data', this._checkDataSize.bind(this)); + this._handleErrors(stream); + } + + this._pipeNext(stream); + }.bind(this)); +}; + +CombinedStream.prototype._pipeNext = function(stream) { + this._currentStream = stream; + + var isStreamLike = CombinedStream.isStreamLike(stream); + if (isStreamLike) { + stream.on('end', this._getNext.bind(this)); + stream.pipe(this, {end: false}); + return; + } + + var value = stream; + this.write(value); + this._getNext(); +}; + +CombinedStream.prototype._handleErrors = function(stream) { + var self = this; + stream.on('error', function(err) { + self._emitError(err); + }); +}; + +CombinedStream.prototype.write = function(data) { + this.emit('data', data); +}; + +CombinedStream.prototype.pause = function() { + if (!this.pauseStreams) { + return; + } + + if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause(); + this.emit('pause'); +}; + +CombinedStream.prototype.resume = function() { + if (!this._released) { + this._released = true; + this.writable = true; + this._getNext(); + } + + if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume(); + this.emit('resume'); +}; + +CombinedStream.prototype.end = function() { + this._reset(); + this.emit('end'); +}; + +CombinedStream.prototype.destroy = function() { + this._reset(); + this.emit('close'); +}; + +CombinedStream.prototype._reset = function() { + this.writable = false; + this._streams = []; + this._currentStream = null; +}; + +CombinedStream.prototype._checkDataSize = function() { + this._updateDataSize(); + if (this.dataSize <= this.maxDataSize) { + return; + } + + var message = + 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'; + this._emitError(new Error(message)); +}; + +CombinedStream.prototype._updateDataSize = function() { + this.dataSize = 0; + + var self = this; + this._streams.forEach(function(stream) { + if (!stream.dataSize) { + return; + } + + self.dataSize += stream.dataSize; + }); + + if (this._currentStream && this._currentStream.dataSize) { + this.dataSize += this._currentStream.dataSize; + } +}; + +CombinedStream.prototype._emitError = function(err) { + this._reset(); + this.emit('error', err); +}; diff --git a/node_modules/combined-stream/package.json b/node_modules/combined-stream/package.json new file mode 100644 index 0000000000000000000000000000000000000000..6982b6da17561e86b110f0c8eb7add66b9180e7b --- /dev/null +++ b/node_modules/combined-stream/package.json @@ -0,0 +1,25 @@ +{ + "author": "Felix Geisendörfer (http://debuggable.com/)", + "name": "combined-stream", + "description": "A stream that emits multiple other streams one after another.", + "version": "1.0.8", + "homepage": "https://github.com/felixge/node-combined-stream", + "repository": { + "type": "git", + "url": "git://github.com/felixge/node-combined-stream.git" + }, + "main": "./lib/combined_stream", + "scripts": { + "test": "node test/run.js" + }, + "engines": { + "node": ">= 0.8" + }, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "devDependencies": { + "far": "~0.0.7" + }, + "license": "MIT" +} diff --git a/node_modules/combined-stream/yarn.lock b/node_modules/combined-stream/yarn.lock new file mode 100644 index 0000000000000000000000000000000000000000..7edf41840c9812acddef7ae6d9b513f98d3509cb --- /dev/null +++ b/node_modules/combined-stream/yarn.lock @@ -0,0 +1,17 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +far@~0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/far/-/far-0.0.7.tgz#01c1fd362bcd26ce9cf161af3938aa34619f79a7" + dependencies: + oop "0.0.3" + +oop@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/oop/-/oop-0.0.3.tgz#70fa405a5650891a194fdc82ca68dad6dabf4401" diff --git a/node_modules/core-util-is/LICENSE b/node_modules/core-util-is/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d8d7f9437dbf5ad54701a187f05988bcf0006fd8 --- /dev/null +++ b/node_modules/core-util-is/LICENSE @@ -0,0 +1,19 @@ +Copyright Node.js contributors. All rights reserved. + +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. diff --git a/node_modules/core-util-is/README.md b/node_modules/core-util-is/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5a76b4149c5eb5077c09578e349820bccbbd266e --- /dev/null +++ b/node_modules/core-util-is/README.md @@ -0,0 +1,3 @@ +# core-util-is + +The `util.is*` functions introduced in Node v0.12. diff --git a/node_modules/core-util-is/lib/util.js b/node_modules/core-util-is/lib/util.js new file mode 100644 index 0000000000000000000000000000000000000000..6e5a20d7dc09e280bf06302f4f872b8eb168aac0 --- /dev/null +++ b/node_modules/core-util-is/lib/util.js @@ -0,0 +1,107 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = require('buffer').Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} diff --git a/node_modules/core-util-is/package.json b/node_modules/core-util-is/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b0c51f580be4cff40105d5b52a8a513bc0330e94 --- /dev/null +++ b/node_modules/core-util-is/package.json @@ -0,0 +1,38 @@ +{ + "name": "core-util-is", + "version": "1.0.3", + "description": "The `util.is*` functions introduced in Node v0.12.", + "main": "lib/util.js", + "files": [ + "lib" + ], + "repository": { + "type": "git", + "url": "git://github.com/isaacs/core-util-is" + }, + "keywords": [ + "util", + "isBuffer", + "isArray", + "isNumber", + "isString", + "isRegExp", + "isThis", + "isThat", + "polyfill" + ], + "author": "Isaac Z. Schlueter (http://blog.izs.me/)", + "license": "MIT", + "bugs": { + "url": "https://github.com/isaacs/core-util-is/issues" + }, + "scripts": { + "test": "tap test.js", + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags" + }, + "devDependencies": { + "tap": "^15.0.9" + } +} diff --git a/node_modules/define-data-property/.eslintrc b/node_modules/define-data-property/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..75443e81ee0f6180b9ceee33bc69fa8696162783 --- /dev/null +++ b/node_modules/define-data-property/.eslintrc @@ -0,0 +1,24 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "complexity": 0, + "id-length": 0, + "new-cap": ["error", { + "capIsNewExceptions": [ + "GetIntrinsic", + ], + }], + }, + + "overrides": [ + { + "files": "test/**", + "rules": { + "max-lines-per-function": "off", + }, + }, + ], +} diff --git a/node_modules/define-data-property/.github/FUNDING.yml b/node_modules/define-data-property/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..3e17725ddfc684e0a254b7eed5adb8d05bfdeaa5 --- /dev/null +++ b/node_modules/define-data-property/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/define-data-property +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/define-data-property/.nycrc b/node_modules/define-data-property/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..1826526e091b89c896e7099ccd891db79165e329 --- /dev/null +++ b/node_modules/define-data-property/.nycrc @@ -0,0 +1,13 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "lines": 86, + "statements": 85.93, + "functions": 82.43, + "branches": 76.06, + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/define-data-property/CHANGELOG.md b/node_modules/define-data-property/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..94bad092de7aa70a8b9d1264ea46c8a23eb54438 --- /dev/null +++ b/node_modules/define-data-property/CHANGELOG.md @@ -0,0 +1,41 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.1.1](https://github.com/ljharb/define-data-property/compare/v1.1.0...v1.1.1) - 2023-10-12 + +### Commits + +- [Tests] fix tests in ES3 engines [`5c6920e`](https://github.com/ljharb/define-data-property/commit/5c6920edd1f52f675b02f417e539c28135b43f94) +- [Dev Deps] update `@types/es-value-fixtures`, `@types/for-each`, `@types/gopd`, `@types/has-property-descriptors`, `tape`, `typescript` [`7d82dfc`](https://github.com/ljharb/define-data-property/commit/7d82dfc20f778b4465bba06335dd53f6f431aea3) +- [Fix] IE 8 has a broken `Object.defineProperty` [`0672e1a`](https://github.com/ljharb/define-data-property/commit/0672e1af2a9fcc787e7c23b96dea60d290df5548) +- [meta] emit types on prepack [`73acb1f`](https://github.com/ljharb/define-data-property/commit/73acb1f903c21b314ec7156bf10f73c7910530c0) +- [Dev Deps] update `tape`, `typescript` [`9489a77`](https://github.com/ljharb/define-data-property/commit/9489a7738bf2ecf0ac71d5b78ec4ca6ad7ba0142) + +## [v1.1.0](https://github.com/ljharb/define-data-property/compare/v1.0.1...v1.1.0) - 2023-09-13 + +### Commits + +- [New] add `loose` arg [`155235a`](https://github.com/ljharb/define-data-property/commit/155235a4c4d7741f6de01cd87c99599a56654b72) +- [New] allow `null` to be passed for the non* args [`7d2fa5f`](https://github.com/ljharb/define-data-property/commit/7d2fa5f06be0392736c13b126f7cd38979f34792) + +## [v1.0.1](https://github.com/ljharb/define-data-property/compare/v1.0.0...v1.0.1) - 2023-09-12 + +### Commits + +- [meta] add TS types [`43d763c`](https://github.com/ljharb/define-data-property/commit/43d763c6c883f652de1c9c02ef6216ee507ffa69) +- [Dev Deps] update `@types/tape`, `typescript` [`f444985`](https://github.com/ljharb/define-data-property/commit/f444985811c36f3e6448a03ad2f9b7898917f4c7) +- [meta] add `safe-publish-latest`, [`172bb10`](https://github.com/ljharb/define-data-property/commit/172bb10890896ebb160e64398f6ee55760107bee) + +## v1.0.0 - 2023-09-12 + +### Commits + +- Initial implementation, tests, readme [`5b43d6b`](https://github.com/ljharb/define-data-property/commit/5b43d6b44e675a904810467a7d4e0adb7efc3196) +- Initial commit [`35e577a`](https://github.com/ljharb/define-data-property/commit/35e577a6ba59a98befa97776d70d90f3bea9009d) +- npm init [`82a0a04`](https://github.com/ljharb/define-data-property/commit/82a0a04a321ca7de220af02d41e2745e8a9962ed) +- Only apps should have lockfiles [`96df244`](https://github.com/ljharb/define-data-property/commit/96df244a3c6f426f9a2437be825d1c6f5dd7158e) +- [meta] use `npmignore` to autogenerate an npmignore file [`a87ff18`](https://github.com/ljharb/define-data-property/commit/a87ff18cb79e14c2eb5720486c4759fd9a189375) diff --git a/node_modules/define-data-property/LICENSE b/node_modules/define-data-property/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b4213ac640ad53446325d2dab2c2bc8620406b72 --- /dev/null +++ b/node_modules/define-data-property/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Jordan Harband + +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. diff --git a/node_modules/define-data-property/README.md b/node_modules/define-data-property/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f2304daef9b105844c4495414f1b8164d86befa2 --- /dev/null +++ b/node_modules/define-data-property/README.md @@ -0,0 +1,67 @@ +# define-data-property [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Define a data property on an object. Will fall back to assignment in an engine without descriptors. + +The three `non*` argument can also be passed `null`, which will use the existing state if available. + +The `loose` argument will mean that if you attempt to set a non-normal data property, in an environment without descriptor support, it will fall back to normal assignment. + +## Usage + +```javascript +var defineDataProperty = require('define-data-property'); +var assert = require('assert'); + +var obj = {}; +defineDataProperty(obj, 'key', 'value'); +defineDataProperty( + obj, + 'key2', + 'value', + true, // nonEnumerable, optional + false, // nonWritable, optional + true, // nonConfigurable, optional + false // loose, optional +); + +assert.deepEqual( + Object.getOwnPropertyDescriptors(obj), + { + key: { + configurable: true, + enumerable: true, + value: 'value', + writable: true, + }, + key2: { + configurable: false, + enumerable: false, + value: 'value', + writable: true, + }, + } +); +``` + +[package-url]: https://npmjs.org/package/define-data-property +[npm-version-svg]: https://versionbadg.es/ljharb/define-data-property.svg +[deps-svg]: https://david-dm.org/ljharb/define-data-property.svg +[deps-url]: https://david-dm.org/ljharb/define-data-property +[dev-deps-svg]: https://david-dm.org/ljharb/define-data-property/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/define-data-property#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/define-data-property.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/define-data-property.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/define-data-property.svg +[downloads-url]: https://npm-stat.com/charts.html?package=define-data-property +[codecov-image]: https://codecov.io/gh/ljharb/define-data-property/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/ljharb/define-data-property/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/define-data-property +[actions-url]: https://github.com/ljharb/define-data-property/actions diff --git a/node_modules/define-data-property/index.d.ts b/node_modules/define-data-property/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2e353d109fb96a3fd34f0d6e89d0575d2780bbb --- /dev/null +++ b/node_modules/define-data-property/index.d.ts @@ -0,0 +1,3 @@ +declare const _exports: (obj: Record, property: PropertyKey, value: unknown, nonEnumerable?: boolean | null, nonWritable?: boolean | null, nonConfigurable?: boolean | null, loose?: boolean) => void; +export = _exports; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/define-data-property/index.d.ts.map b/node_modules/define-data-property/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..39aca4b8d3877964238f4d63698b670fb564646d --- /dev/null +++ b/node_modules/define-data-property/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"8BAqBiB,OAAO,WAAW,EAAE,OAAO,CAAC,YAAY,WAAW,SAAS,OAAO,kBAAkB,OAAO,GAAG,IAAI,gBAAgB,OAAO,GAAG,IAAI,oBAAoB,OAAO,GAAG,IAAI,UAAU,OAAO,KAAK,IAAI"} \ No newline at end of file diff --git a/node_modules/define-data-property/index.js b/node_modules/define-data-property/index.js new file mode 100644 index 0000000000000000000000000000000000000000..95340651982e2b15dfd714e04052a7fc5ddeb407 --- /dev/null +++ b/node_modules/define-data-property/index.js @@ -0,0 +1,68 @@ +'use strict'; + +var hasPropertyDescriptors = require('has-property-descriptors')(); + +var GetIntrinsic = require('get-intrinsic'); + +var $defineProperty = hasPropertyDescriptors && GetIntrinsic('%Object.defineProperty%', true); +if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + } catch (e) { + // IE 8 has a broken defineProperty + $defineProperty = false; + } +} + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var gopd = require('gopd'); + +/** @type {(obj: Record, property: PropertyKey, value: unknown, nonEnumerable?: boolean | null, nonWritable?: boolean | null, nonConfigurable?: boolean | null, loose?: boolean) => void} */ +module.exports = function defineDataProperty( + obj, + property, + value +) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new $TypeError('`obj` must be an object or a function`'); + } + if (typeof property !== 'string' && typeof property !== 'symbol') { + throw new $TypeError('`property` must be a string or a symbol`'); + } + if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { + throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); + } + if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { + throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); + } + if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { + throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); + } + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('`loose`, if provided, must be a boolean'); + } + + var nonEnumerable = arguments.length > 3 ? arguments[3] : null; + var nonWritable = arguments.length > 4 ? arguments[4] : null; + var nonConfigurable = arguments.length > 5 ? arguments[5] : null; + var loose = arguments.length > 6 ? arguments[6] : false; + + /* @type {false | TypedPropertyDescriptor} */ + var desc = !!gopd && gopd(obj, property); + + if ($defineProperty) { + $defineProperty(obj, property, { + configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, + enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, + value: value, + writable: nonWritable === null && desc ? desc.writable : !nonWritable + }); + } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { + // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable + obj[property] = value; // eslint-disable-line no-param-reassign + } else { + throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); + } +}; diff --git a/node_modules/define-data-property/package.json b/node_modules/define-data-property/package.json new file mode 100644 index 0000000000000000000000000000000000000000..1bb5815ba3335e4780a4771dd9b5aaa02f965e5f --- /dev/null +++ b/node_modules/define-data-property/package.json @@ -0,0 +1,113 @@ +{ + "name": "define-data-property", + "version": "1.1.1", + "description": "Define a data property on an object. Will fall back to assignment in an engine without descriptors.", + "main": "index.js", + "exports": { + ".": [ + { + "types": "./index.d.ts", + "default": "./index.js" + }, + "./index.js" + ], + "./package.json": "./package.json" + }, + "sideEffects": false, + "types": "./index.d.ts", + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated && npm run emit-types", + "prepublish": "not-in-publish || npm run prepublishOnly", + "prepublishOnly": "safe-publish-latest", + "tsc": "tsc -p .", + "preemit-types": "rm -f *.ts *.ts.map test/*.ts test/*.ts.map", + "emit-types": "npm run tsc -- --noEmit false --emitDeclarationOnly", + "postemit-types": "rm test/*.ts test/*.ts.map", + "prelint": "evalmd README.md", + "lint": "eslint --ext=js,mjs .", + "postlint": "npm run tsc", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ljharb/define-data-property.git" + }, + "keywords": [ + "define", + "data", + "property", + "object", + "accessor", + "javascript", + "ecmascript", + "enumerable", + "configurable", + "writable" + ], + "author": "Jordan Harband ", + "license": "MIT", + "bugs": { + "url": "https://github.com/ljharb/define-data-property/issues" + }, + "homepage": "https://github.com/ljharb/define-data-property#readme", + "dependencies": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "devDependencies": { + "@ljharb/eslint-config": "^21.1.0", + "@types/es-value-fixtures": "^1.4.1", + "@types/for-each": "^0.3.1", + "@types/get-intrinsic": "^1.2.0", + "@types/gopd": "^1.0.1", + "@types/has": "^1.0.0", + "@types/has-property-descriptors": "^1.0.1", + "@types/object-inspect": "^1.8.2", + "@types/object.getownpropertydescriptors": "^2.1.2", + "@types/tape": "^5.6.1", + "aud": "^2.0.3", + "auto-changelog": "^2.4.0", + "es-value-fixtures": "^1.4.2", + "eslint": "=8.8.0", + "evalmd": "^0.0.19", + "for-each": "^0.3.3", + "has": "^1.0.3", + "in-publish": "^2.0.1", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "object-inspect": "^1.12.3", + "object.getownpropertydescriptors": "^2.1.7", + "reflect.ownkeys": "^1.1.4", + "safe-publish-latest": "^2.0.0", + "tape": "^5.7.1", + "typescript": "^5.3.0-dev.20231012" + }, + "engines": { + "node": ">= 0.4" + }, + "testling": { + "files": "test/index.js" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + }, + "publishConfig": { + "ignore": [ + ".github/workflows", + "!*.ts", + "!*.ts.map", + "types/reflect.ownkeys" + ] + } +} diff --git a/node_modules/define-data-property/test/index.js b/node_modules/define-data-property/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..405508ec510a788304b81931ac7c7cdcbe489eed --- /dev/null +++ b/node_modules/define-data-property/test/index.js @@ -0,0 +1,392 @@ +'use strict'; + +var test = require('tape'); +var v = require('es-value-fixtures'); +var forEach = require('for-each'); +var inspect = require('object-inspect'); +var has = require('has'); +var hasPropertyDescriptors = require('has-property-descriptors')(); +var getOwnPropertyDescriptors = require('object.getownpropertydescriptors'); +var ownKeys = require('reflect.ownkeys'); + +var defineDataProperty = require('../'); + +test('defineDataProperty', function (t) { + t.test('argument validation', function (st) { + forEach(v.primitives, function (nonObject) { + st['throws']( + // @ts-expect-error + function () { defineDataProperty(nonObject, 'key', 'value'); }, + TypeError, + 'throws on non-object input: ' + inspect(nonObject) + ); + }); + + forEach(v.nonPropertyKeys, function (nonPropertyKey) { + st['throws']( + // @ts-expect-error + function () { defineDataProperty({}, nonPropertyKey, 'value'); }, + TypeError, + 'throws on non-PropertyKey input: ' + inspect(nonPropertyKey) + ); + }); + + forEach(v.nonBooleans, function (nonBoolean) { + if (nonBoolean !== null) { + st['throws']( + // @ts-expect-error + function () { defineDataProperty({}, 'key', 'value', nonBoolean); }, + TypeError, + 'throws on non-boolean nonEnumerable: ' + inspect(nonBoolean) + ); + + st['throws']( + // @ts-expect-error + function () { defineDataProperty({}, 'key', 'value', false, nonBoolean); }, + TypeError, + 'throws on non-boolean nonWritable: ' + inspect(nonBoolean) + ); + + st['throws']( + // @ts-expect-error + function () { defineDataProperty({}, 'key', 'value', false, false, nonBoolean); }, + TypeError, + 'throws on non-boolean nonConfigurable: ' + inspect(nonBoolean) + ); + } + }); + + st.end(); + }); + + t.test('normal data property', function (st) { + /** @type {Record} */ + var obj = { existing: 'existing property' }; + st.ok(has(obj, 'existing'), 'has initial own property'); + st.equal(obj.existing, 'existing property', 'has expected initial value'); + + var res = defineDataProperty(obj, 'added', 'added property'); + st.equal(res, void undefined, 'returns `undefined`'); + st.ok(has(obj, 'added'), 'has expected own property'); + st.equal(obj.added, 'added property', 'has expected value'); + + defineDataProperty(obj, 'existing', 'new value'); + st.ok(has(obj, 'existing'), 'still has expected own property'); + st.equal(obj.existing, 'new value', 'has new expected value'); + + defineDataProperty(obj, 'explicit1', 'new value', false); + st.ok(has(obj, 'explicit1'), 'has expected own property (explicit enumerable)'); + st.equal(obj.explicit1, 'new value', 'has new expected value (explicit enumerable)'); + + defineDataProperty(obj, 'explicit2', 'new value', false, false); + st.ok(has(obj, 'explicit2'), 'has expected own property (explicit writable)'); + st.equal(obj.explicit2, 'new value', 'has new expected value (explicit writable)'); + + defineDataProperty(obj, 'explicit3', 'new value', false, false, false); + st.ok(has(obj, 'explicit3'), 'has expected own property (explicit configurable)'); + st.equal(obj.explicit3, 'new value', 'has new expected value (explicit configurable)'); + + st.end(); + }); + + t.test('loose mode', { skip: !hasPropertyDescriptors }, function (st) { + var obj = { existing: 'existing property' }; + + defineDataProperty(obj, 'added', 'added value 1', true, null, null, true); + st.deepEqual( + getOwnPropertyDescriptors(obj), + { + existing: { + configurable: true, + enumerable: true, + value: 'existing property', + writable: true + }, + added: { + configurable: true, + enumerable: !hasPropertyDescriptors, + value: 'added value 1', + writable: true + } + }, + 'in loose mode, obj still adds property 1' + ); + + defineDataProperty(obj, 'added', 'added value 2', false, true, null, true); + st.deepEqual( + getOwnPropertyDescriptors(obj), + { + existing: { + configurable: true, + enumerable: true, + value: 'existing property', + writable: true + }, + added: { + configurable: true, + enumerable: true, + value: 'added value 2', + writable: !hasPropertyDescriptors + } + }, + 'in loose mode, obj still adds property 2' + ); + + defineDataProperty(obj, 'added', 'added value 3', false, false, true, true); + st.deepEqual( + getOwnPropertyDescriptors(obj), + { + existing: { + configurable: true, + enumerable: true, + value: 'existing property', + writable: true + }, + added: { + configurable: !hasPropertyDescriptors, + enumerable: true, + value: 'added value 3', + writable: true + } + }, + 'in loose mode, obj still adds property 3' + ); + + st.end(); + }); + + t.test('non-normal data property, ES3', { skip: hasPropertyDescriptors }, function (st) { + /** @type {Record} */ + var obj = { existing: 'existing property' }; + + st['throws']( + function () { defineDataProperty(obj, 'added', 'added value', true); }, + SyntaxError, + 'nonEnumerable throws a Syntax Error' + ); + + st['throws']( + function () { defineDataProperty(obj, 'added', 'added value', false, true); }, + SyntaxError, + 'nonWritable throws a Syntax Error' + ); + + st['throws']( + function () { defineDataProperty(obj, 'added', 'added value', false, false, true); }, + SyntaxError, + 'nonWritable throws a Syntax Error' + ); + + st.deepEqual( + ownKeys(obj), + ['existing'], + 'obj still has expected keys' + ); + st.equal(obj.existing, 'existing property', 'obj still has expected values'); + + st.end(); + }); + + t.test('new non-normal data property, ES5+', { skip: !hasPropertyDescriptors }, function (st) { + /** @type {Record} */ + var obj = { existing: 'existing property' }; + + defineDataProperty(obj, 'nonEnum', null, true); + defineDataProperty(obj, 'nonWrit', null, false, true); + defineDataProperty(obj, 'nonConf', null, false, false, true); + + st.deepEqual( + getOwnPropertyDescriptors(obj), + { + existing: { + configurable: true, + enumerable: true, + value: 'existing property', + writable: true + }, + nonEnum: { + configurable: true, + enumerable: false, + value: null, + writable: true + }, + nonWrit: { + configurable: true, + enumerable: true, + value: null, + writable: false + }, + nonConf: { + configurable: false, + enumerable: true, + value: null, + writable: true + } + }, + 'obj has expected property descriptors' + ); + + st.end(); + }); + + t.test('existing non-normal data property, ES5+', { skip: !hasPropertyDescriptors }, function (st) { + // test case changing an existing non-normal property + + /** @type {Record} */ + var obj = {}; + Object.defineProperty(obj, 'nonEnum', { configurable: true, enumerable: false, value: null, writable: true }); + Object.defineProperty(obj, 'nonWrit', { configurable: true, enumerable: true, value: null, writable: false }); + Object.defineProperty(obj, 'nonConf', { configurable: false, enumerable: true, value: null, writable: true }); + + st.deepEqual( + getOwnPropertyDescriptors(obj), + { + nonEnum: { + configurable: true, + enumerable: false, + value: null, + writable: true + }, + nonWrit: { + configurable: true, + enumerable: true, + value: null, + writable: false + }, + nonConf: { + configurable: false, + enumerable: true, + value: null, + writable: true + } + }, + 'obj initially has expected property descriptors' + ); + + defineDataProperty(obj, 'nonEnum', 'new value', false); + defineDataProperty(obj, 'nonWrit', 'new value', false, false); + st['throws']( + function () { defineDataProperty(obj, 'nonConf', 'new value', false, false, false); }, + TypeError, + 'can not alter a nonconfigurable property' + ); + + st.deepEqual( + getOwnPropertyDescriptors(obj), + { + nonEnum: { + configurable: true, + enumerable: true, + value: 'new value', + writable: true + }, + nonWrit: { + configurable: true, + enumerable: true, + value: 'new value', + writable: true + }, + nonConf: { + configurable: false, + enumerable: true, + value: null, + writable: true + } + }, + 'obj ends up with expected property descriptors' + ); + + st.end(); + }); + + t.test('frozen object, ES5+', { skip: !hasPropertyDescriptors }, function (st) { + var frozen = Object.freeze({ existing: true }); + + st['throws']( + function () { defineDataProperty(frozen, 'existing', 'new value'); }, + TypeError, + 'frozen object can not modify an existing property' + ); + + st['throws']( + function () { defineDataProperty(frozen, 'new', 'new property'); }, + TypeError, + 'frozen object can not add a new property' + ); + + st.end(); + }); + + t.test('sealed object, ES5+', { skip: !hasPropertyDescriptors }, function (st) { + var sealed = Object.seal({ existing: true }); + st.deepEqual( + Object.getOwnPropertyDescriptor(sealed, 'existing'), + { + configurable: false, + enumerable: true, + value: true, + writable: true + }, + 'existing value on sealed object has expected descriptor' + ); + + defineDataProperty(sealed, 'existing', 'new value'); + + st.deepEqual( + Object.getOwnPropertyDescriptor(sealed, 'existing'), + { + configurable: false, + enumerable: true, + value: 'new value', + writable: true + }, + 'existing value on sealed object has changed descriptor' + ); + + st['throws']( + function () { defineDataProperty(sealed, 'new', 'new property'); }, + TypeError, + 'sealed object can not add a new property' + ); + + st.end(); + }); + + t.test('nonextensible object, ES5+', { skip: !hasPropertyDescriptors }, function (st) { + var nonExt = Object.preventExtensions({ existing: true }); + + st.deepEqual( + Object.getOwnPropertyDescriptor(nonExt, 'existing'), + { + configurable: true, + enumerable: true, + value: true, + writable: true + }, + 'existing value on non-extensible object has expected descriptor' + ); + + defineDataProperty(nonExt, 'existing', 'new value', true); + + st.deepEqual( + Object.getOwnPropertyDescriptor(nonExt, 'existing'), + { + configurable: true, + enumerable: false, + value: 'new value', + writable: true + }, + 'existing value on non-extensible object has changed descriptor' + ); + + st['throws']( + function () { defineDataProperty(nonExt, 'new', 'new property'); }, + TypeError, + 'non-extensible object can not add a new property' + ); + + st.end(); + }); + + t.end(); +}); diff --git a/node_modules/define-data-property/tsconfig.json b/node_modules/define-data-property/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..69f060dccdff2bc2089bd1056026de02fe6c760a --- /dev/null +++ b/node_modules/define-data-property/tsconfig.json @@ -0,0 +1,59 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + + /* Language and Environment */ + "target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + "typeRoots": ["types"], /* Specify multiple folders that act like './node_modules/@types'. */ + "resolveJsonModule": true, /* Enable importing .json files. */ + + /* JavaScript Support */ + "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + "noEmit": true, /* Disable emitting files from a compilation. */ + + /* Interop Constraints */ + "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + + /* Completeness */ + // "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "exclude": [ + "coverage" + ] +} diff --git a/node_modules/end-of-stream/LICENSE b/node_modules/end-of-stream/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..757562ec59276bff35792501d88fe83b34acca9a --- /dev/null +++ b/node_modules/end-of-stream/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Mathias Buus + +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. \ No newline at end of file diff --git a/node_modules/end-of-stream/README.md b/node_modules/end-of-stream/README.md new file mode 100644 index 0000000000000000000000000000000000000000..857b14bd7e4ffecbf82d04d2d9f7f54d5b0a9d97 --- /dev/null +++ b/node_modules/end-of-stream/README.md @@ -0,0 +1,54 @@ +# end-of-stream + +A node module that calls a callback when a readable/writable/duplex stream has completed or failed. + + npm install end-of-stream + +[![Build status](https://travis-ci.org/mafintosh/end-of-stream.svg?branch=master)](https://travis-ci.org/mafintosh/end-of-stream) + +## Usage + +Simply pass a stream and a callback to the `eos`. +Both legacy streams, streams2 and stream3 are supported. + +``` js +var eos = require('end-of-stream'); + +eos(readableStream, function(err) { + // this will be set to the stream instance + if (err) return console.log('stream had an error or closed early'); + console.log('stream has ended', this === readableStream); +}); + +eos(writableStream, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has finished', this === writableStream); +}); + +eos(duplexStream, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has ended and finished', this === duplexStream); +}); + +eos(duplexStream, {readable:false}, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has finished but might still be readable'); +}); + +eos(duplexStream, {writable:false}, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has ended but might still be writable'); +}); + +eos(readableStream, {error:false}, function(err) { + // do not treat emit('error', err) as a end-of-stream +}); +``` + +## License + +MIT + +## Related + +`end-of-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. diff --git a/node_modules/end-of-stream/index.js b/node_modules/end-of-stream/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c77f0d5d704e3d4ef95f115d4defc267ee9d528e --- /dev/null +++ b/node_modules/end-of-stream/index.js @@ -0,0 +1,94 @@ +var once = require('once'); + +var noop = function() {}; + +var isRequest = function(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +}; + +var isChildProcess = function(stream) { + return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3 +}; + +var eos = function(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + + callback = once(callback || noop); + + var ws = stream._writableState; + var rs = stream._readableState; + var readable = opts.readable || (opts.readable !== false && stream.readable); + var writable = opts.writable || (opts.writable !== false && stream.writable); + var cancelled = false; + + var onlegacyfinish = function() { + if (!stream.writable) onfinish(); + }; + + var onfinish = function() { + writable = false; + if (!readable) callback.call(stream); + }; + + var onend = function() { + readable = false; + if (!writable) callback.call(stream); + }; + + var onexit = function(exitCode) { + callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null); + }; + + var onerror = function(err) { + callback.call(stream, err); + }; + + var onclose = function() { + process.nextTick(onclosenexttick); + }; + + var onclosenexttick = function() { + if (cancelled) return; + if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close')); + if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close')); + }; + + var onrequest = function() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest(); + else stream.on('request', onrequest); + } else if (writable && !ws) { // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + if (isChildProcess(stream)) stream.on('exit', onexit); + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + + return function() { + cancelled = true; + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('exit', onexit); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +}; + +module.exports = eos; diff --git a/node_modules/end-of-stream/package.json b/node_modules/end-of-stream/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b75bbf0fd3e3c0f2d87be02143e811862ad8b766 --- /dev/null +++ b/node_modules/end-of-stream/package.json @@ -0,0 +1,37 @@ +{ + "name": "end-of-stream", + "version": "1.4.4", + "description": "Call a callback when a readable/writable/duplex stream has completed or failed.", + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/end-of-stream.git" + }, + "dependencies": { + "once": "^1.4.0" + }, + "scripts": { + "test": "node test.js" + }, + "files": [ + "index.js" + ], + "keywords": [ + "stream", + "streams", + "callback", + "finish", + "close", + "end", + "wait" + ], + "bugs": { + "url": "https://github.com/mafintosh/end-of-stream/issues" + }, + "homepage": "https://github.com/mafintosh/end-of-stream", + "main": "index.js", + "author": "Mathias Buus ", + "license": "MIT", + "devDependencies": { + "tape": "^4.11.0" + } +} diff --git a/node_modules/es-abstract/.editorconfig b/node_modules/es-abstract/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..4598a381a859cf6d57a9cb45127a2aa3771feec2 --- /dev/null +++ b/node_modules/es-abstract/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +indent_style = tab; +insert_final_newline = true; +quote_type = auto; +space_after_anonymous_functions = true; +space_after_control_statements = true; +spaces_around_operators = true; +trim_trailing_whitespace = true; +spaces_in_brackets = false; +end_of_line = lf; + +[CHANGELOG.md] +indent_style = space diff --git a/node_modules/es-abstract/.eslintrc b/node_modules/es-abstract/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..d1c20db51d485461de944f3a04601a444e48d6da --- /dev/null +++ b/node_modules/es-abstract/.eslintrc @@ -0,0 +1,88 @@ +{ + "root": true, + + "extends": "@ljharb", + + "env": { + "es6": true, + }, + + "rules": { + "array-bracket-newline": 0, + "complexity": 0, + "eqeqeq": [2, "allow-null"], + "func-name-matching": 0, + "id-length": [2, { "min": 1, "max": 40 }], + "max-params": [2, 5], + "max-lines-per-function": 1, + "max-statements": 1, + "max-statements-per-line": [2, { "max": 2 }], + "multiline-comment-style": 0, + "no-magic-numbers": 0, + "new-cap": 0, + "no-extra-parens": 1, + "sort-keys": 0, + }, + + "overrides": [ + { + "files": "GetIntrinsic.js", + "rules": { + "max-statements": 0, + } + }, + { + "files": "operations/*", + "rules": { + "max-lines": 0, + }, + }, + { + "files": [ + "operations/deltas.js", + "operations/getOps.js", + "operations/spackle.js", + "operations/years.js", + ], + "extends": "@ljharb/eslint-config/node/latest", + "rules": { + "complexity": 0, + "func-style": 0, + "max-lines-per-function": 0, + "max-nested-callbacks": 0, + "max-statements": 0, + "no-magic-numbers": 0, + "no-throw-literal": 0, + }, + }, + { + "files": "test/**", + "extends": "@ljharb/eslint-config/tests", + "rules": { + "max-len": 0, + "max-lines-per-function": 0, + "no-implicit-coercion": 0, + "no-invalid-this": 1, + "prefer-promise-reject-errors": 0, + }, + }, + { + "files": [ + "*/Num*ToRawBytes.js", + "*/RawBytesToNum*.js", + "helpers/bytesAs*.js", + "helpers/valueToFloat*.js", + ], + "rules": { + "max-lines-per-function": "off", + "max-statements": "off", + "no-redeclare": "warn", + "operator-linebreak": [2, "before", { + "overrides": { + "=": "none" + } + }], + }, + }, + ], +} diff --git a/node_modules/es-abstract/.nycrc b/node_modules/es-abstract/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..9e5435f9d6400382ab820a769ab355142eeafb33 --- /dev/null +++ b/node_modules/es-abstract/.nycrc @@ -0,0 +1,15 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "operations", + "test", + "helpers/callBind.js", + "helpers/callBound.js", + "helpers/getOwnPropertyDescriptor.js", + "helpers/getSymbolDescription.js", + "helpers/regexTester.js" + ] +} diff --git a/node_modules/es-abstract/2015/AbstractEqualityComparison.js b/node_modules/es-abstract/2015/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..b56a5066224470eec1a41d7d3b2d6591f7a5f1b8 --- /dev/null +++ b/node_modules/es-abstract/2015/AbstractEqualityComparison.js @@ -0,0 +1,37 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return x === y; // ES6+ specified this shortcut anyways. + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (xType === 'Boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (yType === 'Boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'Symbol') && yType === 'Object') { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + return false; +}; diff --git a/node_modules/es-abstract/2015/AdvanceStringIndex.js b/node_modules/es-abstract/2015/AdvanceStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..831ea96ef913582f778f0aa5479ecbaa529d700d --- /dev/null +++ b/node_modules/es-abstract/2015/AdvanceStringIndex.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $charCodeAt = require('call-bind/callBound')('String.prototype.charCodeAt'); + +// https://262.ecma-international.org/6.0/#sec-advancestringindex + +module.exports = function AdvanceStringIndex(S, index, unicode) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); + } + if (Type(unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `unicode` must be a Boolean'); + } + if (!unicode) { + return index + 1; + } + var length = S.length; + if ((index + 1) >= length) { + return index + 1; + } + + var first = $charCodeAt(S, index); + if (!isLeadingSurrogate(first)) { + return index + 1; + } + + var second = $charCodeAt(S, index + 1); + if (!isTrailingSurrogate(second)) { + return index + 1; + } + + return index + 2; +}; diff --git a/node_modules/es-abstract/2015/ArrayCreate.js b/node_modules/es-abstract/2015/ArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..0d34db9beca45cd443d12448cf33057a3eac49b7 --- /dev/null +++ b/node_modules/es-abstract/2015/ArrayCreate.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ArrayPrototype = GetIntrinsic('%Array.prototype%'); +var $RangeError = GetIntrinsic('%RangeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isInteger = require('../helpers/isInteger'); + +var hasProto = require('has-proto')(); + +var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1; + +var $setProto = GetIntrinsic('%Object.setPrototypeOf%', true) || ( + hasProto + ? function (O, proto) { + O.__proto__ = proto; // eslint-disable-line no-proto, no-param-reassign + return O; + } + : null +); + +// https://262.ecma-international.org/6.0/#sec-arraycreate + +module.exports = function ArrayCreate(length) { + if (!isInteger(length) || length < 0) { + throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); + } + if (length > MAX_ARRAY_LENGTH) { + throw new $RangeError('length is greater than (2**32 - 1)'); + } + var proto = arguments.length > 1 ? arguments[1] : $ArrayPrototype; + var A = []; // steps 5 - 7, and 9 + if (proto !== $ArrayPrototype) { // step 8 + if (!$setProto) { + throw new $SyntaxError('ArrayCreate: a `proto` argument that is not `Array.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + $setProto(A, proto); + } + if (length !== 0) { // bypasses the need for step 2 + A.length = length; + } + /* step 10, the above as a shortcut for the below + OrdinaryDefineOwnProperty(A, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': true + }); + */ + return A; +}; diff --git a/node_modules/es-abstract/2015/ArraySetLength.js b/node_modules/es-abstract/2015/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2015/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2015/ArraySpeciesCreate.js b/node_modules/es-abstract/2015/ArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..1944dfe7b8974e00989d21840cb935a5770ed977 --- /dev/null +++ b/node_modules/es-abstract/2015/ArraySpeciesCreate.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Array = GetIntrinsic('%Array%'); +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate + +module.exports = function ArraySpeciesCreate(originalArray, length) { + if (!isInteger(length) || length < 0) { + throw new $TypeError('Assertion failed: length must be an integer >= 0'); + } + var len = length === 0 ? 0 : length; + var C; + var isArray = IsArray(originalArray); + if (isArray) { + C = Get(originalArray, 'constructor'); + // TODO: figure out how to make a cross-realm normal Array, a same-realm Array + // if (IsConstructor(C)) { + // if C is another realm's Array, C = undefined + // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ? + // } + if ($species && Type(C) === 'Object') { + C = Get(C, $species); + if (C === null) { + C = void 0; + } + } + } + if (typeof C === 'undefined') { + return $Array(len); + } + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); + } + return new C(len); // Construct(C, len); +}; + diff --git a/node_modules/es-abstract/2015/Call.js b/node_modules/es-abstract/2015/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..be76246db04f06d84ed52f6f052d6bc98b131b51 --- /dev/null +++ b/node_modules/es-abstract/2015/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2015/CompletePropertyDescriptor.js b/node_modules/es-abstract/2015/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..1530241dc526d85b8e2e27d226aa2015befc762c --- /dev/null +++ b/node_modules/es-abstract/2015/CompletePropertyDescriptor.js @@ -0,0 +1,39 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var assertRecord = require('../helpers/assertRecord'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + /* eslint no-param-reassign: 0 */ + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2015/CreateDataProperty.js b/node_modules/es-abstract/2015/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2015/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2015/CreateHTML.js b/node_modules/es-abstract/2015/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2015/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2015/CreateListFromArrayLike.js b/node_modules/es-abstract/2015/CreateListFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..4c34219206e1fc0a5990f7bdbee2592b77a68160 --- /dev/null +++ b/node_modules/es-abstract/2015/CreateListFromArrayLike.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf'); +var $push = callBound('Array.prototype.push'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'Object']; + +// https://262.ecma-international.org/6.0/#sec-createlistfromarraylike +module.exports = function CreateListFromArrayLike(obj) { + var elementTypes = arguments.length > 1 + ? arguments[1] + : defaultElementTypes; + + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + if (!IsArray(elementTypes)) { + throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array'); + } + var len = ToLength(Get(obj, 'length')); + var list = []; + var index = 0; + while (index < len) { + var indexName = ToString(index); + var next = Get(obj, indexName); + var nextType = Type(next); + if ($indexOf(elementTypes, nextType) < 0) { + throw new $TypeError('item type ' + nextType + ' is not a valid elementType'); + } + $push(list, next); + index += 1; + } + return list; +}; diff --git a/node_modules/es-abstract/2015/CreateMethodProperty.js b/node_modules/es-abstract/2015/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2015/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2015/DateFromTime.js b/node_modules/es-abstract/2015/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2015/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2015/DayFromYear.js b/node_modules/es-abstract/2015/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2015/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2015/DayWithinYear.js b/node_modules/es-abstract/2015/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2015/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2015/DefinePropertyOrThrow.js b/node_modules/es-abstract/2015/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2015/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2015/DeletePropertyOrThrow.js b/node_modules/es-abstract/2015/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2015/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2015/DetachArrayBuffer.js b/node_modules/es-abstract/2015/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..a7b89b36bbcad1f5cc6f1dfbf5f9ae878f34617a --- /dev/null +++ b/node_modules/es-abstract/2015/DetachArrayBuffer.js @@ -0,0 +1,34 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; // node 11.7+ +} catch (e) { /**/ } + +// https://262.ecma-international.org/6.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot'); + } + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2015/EnumerableOwnNames.js b/node_modules/es-abstract/2015/EnumerableOwnNames.js new file mode 100644 index 0000000000000000000000000000000000000000..b8235966aca93bf9f759e9f20c49aa837c7c3a1f --- /dev/null +++ b/node_modules/es-abstract/2015/EnumerableOwnNames.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var keys = require('object-keys'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-enumerableownnames + +module.exports = function EnumerableOwnNames(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return keys(O); +}; diff --git a/node_modules/es-abstract/2015/FromPropertyDescriptor.js b/node_modules/es-abstract/2015/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..c70f0c60e1ff8b16858f71af25b644f8d9a3d589 --- /dev/null +++ b/node_modules/es-abstract/2015/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var assertRecord = require('../helpers/assertRecord'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined') { + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2015/Get.js b/node_modules/es-abstract/2015/Get.js new file mode 100644 index 0000000000000000000000000000000000000000..09731522229d6e3427d4b72b4648bf3bd0b1e8cf --- /dev/null +++ b/node_modules/es-abstract/2015/Get.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-get-o-p + +module.exports = function Get(O, P) { + // 7.3.1.1 + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + // 7.3.1.2 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + // 7.3.1.3 + return O[P]; +}; diff --git a/node_modules/es-abstract/2015/GetGlobalObject.js b/node_modules/es-abstract/2015/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2015/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2015/GetIterator.js b/node_modules/es-abstract/2015/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..145557da422e4910c3371cff4d498ed244213d1e --- /dev/null +++ b/node_modules/es-abstract/2015/GetIterator.js @@ -0,0 +1,34 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getiterator + +module.exports = function GetIterator(obj, method) { + var actualMethod = method; + if (arguments.length < 2) { + actualMethod = getIteratorMethod( + { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod, + IsArray: IsArray + }, + obj + ); + } + var iterator = Call(actualMethod, obj); + if (Type(iterator) !== 'Object') { + throw new $TypeError('iterator must return an object'); + } + + return iterator; +}; diff --git a/node_modules/es-abstract/2015/GetMethod.js b/node_modules/es-abstract/2015/GetMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..e9f2854ff3842ecf3c3c2b23f425628ba00dd285 --- /dev/null +++ b/node_modules/es-abstract/2015/GetMethod.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var IsPropertyKey = require('./IsPropertyKey'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/6.0/#sec-getmethod + +module.exports = function GetMethod(O, P) { + // 7.3.9.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // 7.3.9.2 + var func = GetV(O, P); + + // 7.3.9.4 + if (func == null) { + return void 0; + } + + // 7.3.9.5 + if (!IsCallable(func)) { + throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); + } + + // 7.3.9.6 + return func; +}; diff --git a/node_modules/es-abstract/2015/GetOwnPropertyKeys.js b/node_modules/es-abstract/2015/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..043fd733bd8a4e8724c38dc30444a0fd8a726f5e --- /dev/null +++ b/node_modules/es-abstract/2015/GetOwnPropertyKeys.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +var esType = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (esType(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $gOPS ? $gOPS(O) : []; + } + if (Type === 'String') { + if (!$gOPN) { + return keys(O); + } + return $gOPN(O); + } + throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`'); +}; diff --git a/node_modules/es-abstract/2015/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2015/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2015/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2015/GetV.js b/node_modules/es-abstract/2015/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2015/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2015/GetValueFromBuffer.js b/node_modules/es-abstract/2015/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..0295846c7cc4d2bfe61f42e0a33f0183bb9d8295 --- /dev/null +++ b/node_modules/es-abstract/2015/GetValueFromBuffer.js @@ -0,0 +1,97 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $charAt = callBound('String.prototype.charAt'); +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var defaultEndianness = require('../helpers/defaultEndianness'); +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isArrayBuffer = require('is-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table49 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $Float32: 4, + $Float64: 8 +}; + +var isUnsignedElementType = function isUnsignedElementType(type) { return $charAt(type, 0) === 'U'; }; + +// https://262.ecma-international.org/6.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string') { + throw new $TypeError('Assertion failed: `type` must be a string'); + } + + if (arguments.length > 3 && typeof arguments[3] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + var elementSize = table49['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + // 6. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + var rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 3 ? arguments[3] : defaultEndianness === 'little'; // step 7 + + if (!isLittleEndian) { + $reverse(rawValue); // step 8 + } + + var bytes = $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize); + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(bytes, true); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(bytes, true); + } + + return bytesAsInteger(bytes, elementSize, isUnsignedElementType(type), false); +}; diff --git a/node_modules/es-abstract/2015/HasOwnProperty.js b/node_modules/es-abstract/2015/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2015/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2015/HasProperty.js b/node_modules/es-abstract/2015/HasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..91476d208b05fd6e7e30ca9751381c45114d6306 --- /dev/null +++ b/node_modules/es-abstract/2015/HasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasproperty + +module.exports = function HasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2015/HourFromTime.js b/node_modules/es-abstract/2015/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2015/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2015/InstanceofOperator.js b/node_modules/es-abstract/2015/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..4a34d0c20cdb0d93d5de2316c73ba8faff2aabeb --- /dev/null +++ b/node_modules/es-abstract/2015/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2015/Invoke.js b/node_modules/es-abstract/2015/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..084e5e28253d5ac2d98d1e0b735512b7e9db6e17 --- /dev/null +++ b/node_modules/es-abstract/2015/Invoke.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var IsPropertyKey = require('./IsPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2015/IsAccessorDescriptor.js b/node_modules/es-abstract/2015/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2015/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2015/IsCallable.js b/node_modules/es-abstract/2015/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2015/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2015/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2015/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2015/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2015/IsConcatSpreadable.js b/node_modules/es-abstract/2015/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2015/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2015/IsConstructor.js b/node_modules/es-abstract/2015/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2015/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2015/IsDataDescriptor.js b/node_modules/es-abstract/2015/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2015/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2015/IsGenericDescriptor.js b/node_modules/es-abstract/2015/IsGenericDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..d43bec2b35e5c65a5bb7bb8c023b03eb87df8613 --- /dev/null +++ b/node_modules/es-abstract/2015/IsGenericDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var assertRecord = require('../helpers/assertRecord'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isgenericdescriptor + +module.exports = function IsGenericDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) { + return true; + } + + return false; +}; diff --git a/node_modules/es-abstract/2015/IsInteger.js b/node_modules/es-abstract/2015/IsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..e3d25f38e30093f0a0444e98ef3ddc4e0b35d2ed --- /dev/null +++ b/node_modules/es-abstract/2015/IsInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-isinteger + +module.exports = function IsInteger(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2015/IsPromise.js b/node_modules/es-abstract/2015/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..411539b0818c20d3f4d41852082b3f1a263dbcd8 --- /dev/null +++ b/node_modules/es-abstract/2015/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (Type(x) !== 'Object') { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2015/IsPropertyDescriptor.js b/node_modules/es-abstract/2015/IsPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..4cfe79bbe5dbcc5df02e1dae9d1859cb8d9e8cb3 --- /dev/null +++ b/node_modules/es-abstract/2015/IsPropertyDescriptor.js @@ -0,0 +1,19 @@ +'use strict'; + +// TODO, semver-major: delete this + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var Type = require('./Type'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type + +module.exports = function IsPropertyDescriptor(Desc) { + return isPropertyDescriptor({ + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor, + Type: Type + }, Desc); +}; diff --git a/node_modules/es-abstract/2015/IsPropertyKey.js b/node_modules/es-abstract/2015/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..aaeb6f9b6f83b5a39f1f53cec0edbf19cbc61170 --- /dev/null +++ b/node_modules/es-abstract/2015/IsPropertyKey.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; +}; diff --git a/node_modules/es-abstract/2015/IsRegExp.js b/node_modules/es-abstract/2015/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2015/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2015/IsWordChar.js b/node_modules/es-abstract/2015/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..49f42eccac00ebf7f6c2e3c755a2ba24d35c7ac8 --- /dev/null +++ b/node_modules/es-abstract/2015/IsWordChar.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); + +var every = require('../helpers/every'); +var regexTester = require('safe-regex-test'); + +var isChar = function isChar(c) { + return typeof c === 'string' && c.length === 1; +}; + +var isWordCharacter = regexTester(/^[a-zA-Z0-9_]$/); + +// https://262.ecma-international.org/6.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input) { + if (!IsInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + return isWordCharacter(c); // steps 3-4 +}; diff --git a/node_modules/es-abstract/2015/IteratorClose.js b/node_modules/es-abstract/2015/IteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..7c1076082e1e22b9b4a834af869afae7237414a7 --- /dev/null +++ b/node_modules/es-abstract/2015/IteratorClose.js @@ -0,0 +1,51 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorclose + +module.exports = function IteratorClose(iterator, completion) { + if (Type(iterator) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterator) is not Object'); + } + if (!IsCallable(completion) && !(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a thunk representing a Completion Record, nor a Completion Record instance'); + } + var completionThunk = completion instanceof CompletionRecord ? function () { return completion['?'](); } : completion; + + var iteratorReturn = GetMethod(iterator, 'return'); + + if (typeof iteratorReturn === 'undefined') { + return completionThunk(); + } + + var completionRecord; + try { + var innerResult = Call(iteratorReturn, iterator, []); + } catch (e) { + // if we hit here, then "e" is the innerResult completion that needs re-throwing + + // if the completion is of type "throw", this will throw. + completionThunk(); + completionThunk = null; // ensure it's not called twice. + + // if not, then return the innerResult completion + throw e; + } + completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does + completionThunk = null; // ensure it's not called twice. + + if (Type(innerResult) !== 'Object') { + throw new $TypeError('iterator .return must return an object'); + } + + return completionRecord; +}; diff --git a/node_modules/es-abstract/2015/IteratorComplete.js b/node_modules/es-abstract/2015/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2015/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2015/IteratorNext.js b/node_modules/es-abstract/2015/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..d84d66edb5fc2bd565f3053f15208c37a33024d6 --- /dev/null +++ b/node_modules/es-abstract/2015/IteratorNext.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Invoke = require('./Invoke'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (Type(result) !== 'Object') { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2015/IteratorStep.js b/node_modules/es-abstract/2015/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2015/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2015/IteratorValue.js b/node_modules/es-abstract/2015/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2015/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2015/MakeDate.js b/node_modules/es-abstract/2015/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..efeb6452e78c9f30c8aefc53fede97b874ac2e63 --- /dev/null +++ b/node_modules/es-abstract/2015/MakeDate.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2015/MakeTime.js b/node_modules/es-abstract/2015/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..34cb4dcca3f84920250ddb1dce54cecba114a3ad --- /dev/null +++ b/node_modules/es-abstract/2015/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2015/MonthFromTime.js b/node_modules/es-abstract/2015/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2015/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2015/NewPromiseCapability.js b/node_modules/es-abstract/2015/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2015/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2015/NormalCompletion.js b/node_modules/es-abstract/2015/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2015/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2015/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2015/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ede44ed6b75eed8e851821ffee51b52994bb86a7 --- /dev/null +++ b/node_modules/es-abstract/2015/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var ObjectCreate = require('./ObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return ObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2015/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2015/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2015/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2015/OrdinaryGetOwnProperty.js b/node_modules/es-abstract/2015/OrdinaryGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..52c657eec324c29e3121b1e19130a2dcf2f70a18 --- /dev/null +++ b/node_modules/es-abstract/2015/OrdinaryGetOwnProperty.js @@ -0,0 +1,44 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var hasOwn = require('hasown'); + +var IsArray = require('./IsArray'); +var IsPropertyKey = require('./IsPropertyKey'); +var IsRegExp = require('./IsRegExp'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty + +module.exports = function OrdinaryGetOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!hasOwn(O, P)) { + return void 0; + } + if (!$gOPD) { + // ES3 / IE 8 fallback + var arrayLength = IsArray(O) && P === 'length'; + var regexLastIndex = IsRegExp(O) && P === 'lastIndex'; + return { + '[[Configurable]]': !(arrayLength || regexLastIndex), + '[[Enumerable]]': $isEnumerable(O, P), + '[[Value]]': O[P], + '[[Writable]]': true + }; + } + return ToPropertyDescriptor($gOPD(O, P)); +}; diff --git a/node_modules/es-abstract/2015/OrdinaryHasInstance.js b/node_modules/es-abstract/2015/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2015/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2015/OrdinaryHasProperty.js b/node_modules/es-abstract/2015/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2015/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2015/QuoteJSONString.js b/node_modules/es-abstract/2015/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..7dabf54bf2f02e4172c9c05373c1335c450bf941 --- /dev/null +++ b/node_modules/es-abstract/2015/QuoteJSONString.js @@ -0,0 +1,52 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); +var $strSlice = callBound('String.prototype.slice'); +var $strSplit = callBound('String.prototype.split'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-quotejsonstring + +var escapes = { + '\u0008': 'b', + '\u000C': 'f', + '\u000A': 'n', + '\u000D': 'r', + '\u0009': 't' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(value), function (C) { + if (C === '"' || C === '\\') { + product += '\u005C' + C; + } else if (C === '\u0008' || C === '\u000C' || C === '\u000A' || C === '\u000D' || C === '\u0009') { + var abbrev = escapes[C]; + product += '\u005C' + abbrev; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20) { + product += '\u005Cu' + $toLowerCase($strSlice('0000' + $numberToString(cCharCode, 16), -4)); + } else { + product += C; + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2015/RegExpExec.js b/node_modules/es-abstract/2015/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2015/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2015/RequireObjectCoercible.js b/node_modules/es-abstract/2015/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9008359db8f9ac7107563f46c1aebc2258b8cb2b --- /dev/null +++ b/node_modules/es-abstract/2015/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../5/CheckObjectCoercible'); diff --git a/node_modules/es-abstract/2015/SameValue.js b/node_modules/es-abstract/2015/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2015/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2015/SameValueZero.js b/node_modules/es-abstract/2015/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2015/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2015/Set.js b/node_modules/es-abstract/2015/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..969703136399bce4cdbafbd357690f4f53301c0d --- /dev/null +++ b/node_modules/es-abstract/2015/Set.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (Type(Throw) !== 'Boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2015/SetFunctionName.js b/node_modules/es-abstract/2015/SetFunctionName.js new file mode 100644 index 0000000000000000000000000000000000000000..21c3ea95a3b8230ad8f4856944c508bd7635b932 --- /dev/null +++ b/node_modules/es-abstract/2015/SetFunctionName.js @@ -0,0 +1,44 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasOwn = require('hasown'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var getSymbolDescription = require('get-symbol-description'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsExtensible = require('./IsExtensible'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setfunctionname + +module.exports = function SetFunctionName(F, name) { + if (typeof F !== 'function') { + throw new $TypeError('Assertion failed: `F` must be a function'); + } + if (!IsExtensible(F) || hasOwn(F, 'name')) { + throw new $TypeError('Assertion failed: `F` must be extensible, and must not have a `name` own property'); + } + var nameType = Type(name); + if (nameType !== 'Symbol' && nameType !== 'String') { + throw new $TypeError('Assertion failed: `name` must be a Symbol or a String'); + } + if (nameType === 'Symbol') { + var description = getSymbolDescription(name); + // eslint-disable-next-line no-param-reassign + name = typeof description === 'undefined' ? '' : '[' + description + ']'; + } + if (arguments.length > 2) { + var prefix = arguments[2]; + // eslint-disable-next-line no-param-reassign + name = prefix + ' ' + name; + } + return DefinePropertyOrThrow(F, 'name', { + '[[Value]]': name, + '[[Writable]]': false, + '[[Enumerable]]': false, + '[[Configurable]]': true + }); +}; diff --git a/node_modules/es-abstract/2015/SetIntegrityLevel.js b/node_modules/es-abstract/2015/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2015/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2015/SetValueInBuffer.js b/node_modules/es-abstract/2015/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..d5c2fa479b95179deeba9ccec4d2e1513cb21585 --- /dev/null +++ b/node_modules/es-abstract/2015/SetValueInBuffer.js @@ -0,0 +1,120 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var isArrayBuffer = require('is-array-buffer'); +var hasOwn = require('hasown'); + +var table49 = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +var TypeToAO = { + __proto__: null, + Int8: ToInt8, + Uint8: ToUint8, + Uint8C: ToUint8Clamp, + Int16: ToInt16, + Uint16: ToUint16, + Int32: ToInt32, + Uint32: ToUint32 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); +var integerToNBytes = require('../helpers/integerToNBytes'); +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); + +// https://262.ecma-international.org/6.0/#sec-setvalueinbuffer + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || !hasOwn(table49, type)) { + throw new $TypeError('Assertion failed: `type` must be a Typed Array Element Type'); + } + + if (typeof value !== 'number') { + throw new $TypeError('Assertion failed: `value` must be a number'); + } + + if (arguments.length > 4 && typeof arguments[4] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Assert: Type(value) is Number. + + // 5. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + // 6. Assert: block is not undefined. + + var elementSize = table49[type]; // step 7 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the GetValueFromBuffer abstract operation. + var isLittleEndian = arguments.length > 4 ? arguments[4] : defaultEndianness === 'little'; // step 8 + + var rawBytes; + if (type === 'Float32') { // step 1 + rawBytes = valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + rawBytes = valueToFloat64Bytes(value, isLittleEndian); + } else { + var n = table49[type]; // step 3.a + + var convOp = TypeToAO[type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + rawBytes = integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 + } + + // 12. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + + // 13. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2015/SpeciesConstructor.js b/node_modules/es-abstract/2015/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2015/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2015/SplitMatch.js b/node_modules/es-abstract/2015/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..d57fb691e5e91dfb4d30a974e9ebbff47a22e24e --- /dev/null +++ b/node_modules/es-abstract/2015/SplitMatch.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/6.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (Type(R) !== 'String') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return false; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return false; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2015/StrictEqualityComparison.js b/node_modules/es-abstract/2015/StrictEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..f3435ba9d181eb49f51d00bf6d12e960477c1991 --- /dev/null +++ b/node_modules/es-abstract/2015/StrictEqualityComparison.js @@ -0,0 +1,17 @@ +'use strict'; + +var Type = require('./Type'); + +// https://262.ecma-international.org/5.1/#sec-11.9.6 + +module.exports = function StrictEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType !== yType) { + return false; + } + if (xType === 'Undefined' || xType === 'Null') { + return true; + } + return x === y; // shortcut for steps 4-7 +}; diff --git a/node_modules/es-abstract/2015/StringCreate.js b/node_modules/es-abstract/2015/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2015/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2015/SymbolDescriptiveString.js b/node_modules/es-abstract/2015/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2015/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2015/TimeFromYear.js b/node_modules/es-abstract/2015/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2015/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2015/TimeWithinDay.js b/node_modules/es-abstract/2015/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2015/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2015/ToBoolean.js b/node_modules/es-abstract/2015/ToBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..466404bf9992f0ba636249264c620d6c56215d6a --- /dev/null +++ b/node_modules/es-abstract/2015/ToBoolean.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.2 + +module.exports = function ToBoolean(value) { return !!value; }; diff --git a/node_modules/es-abstract/2015/ToDateString.js b/node_modules/es-abstract/2015/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2015/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2015/ToInt16.js b/node_modules/es-abstract/2015/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2015/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2015/ToInt32.js b/node_modules/es-abstract/2015/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2015/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2015/ToInt8.js b/node_modules/es-abstract/2015/ToInt8.js new file mode 100644 index 0000000000000000000000000000000000000000..e223b6c1d352a3432da2d272d0f7e66bbfa818b4 --- /dev/null +++ b/node_modules/es-abstract/2015/ToInt8.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint8 = require('./ToUint8'); + +// https://262.ecma-international.org/6.0/#sec-toint8 + +module.exports = function ToInt8(argument) { + var int8bit = ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; +}; diff --git a/node_modules/es-abstract/2015/ToInteger.js b/node_modules/es-abstract/2015/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..f6625796ebd22a688826a1bd5d36e20dfe6ebcc7 --- /dev/null +++ b/node_modules/es-abstract/2015/ToInteger.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5ToInteger = require('../5/ToInteger'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/6.0/#sec-tointeger + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + return ES5ToInteger(number); +}; diff --git a/node_modules/es-abstract/2015/ToLength.js b/node_modules/es-abstract/2015/ToLength.js new file mode 100644 index 0000000000000000000000000000000000000000..1bef9bed7b2f0cbbd9477769cb4bcdeb3b8814bc --- /dev/null +++ b/node_modules/es-abstract/2015/ToLength.js @@ -0,0 +1,12 @@ +'use strict'; + +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var ToInteger = require('./ToInteger'); + +module.exports = function ToLength(argument) { + var len = ToInteger(argument); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; } + return len; +}; diff --git a/node_modules/es-abstract/2015/ToNumber.js b/node_modules/es-abstract/2015/ToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..3abb6a68d228b8c1cf79db2181d2d4872573eb99 --- /dev/null +++ b/node_modules/es-abstract/2015/ToNumber.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Number = GetIntrinsic('%Number%'); +var $RegExp = GetIntrinsic('%RegExp%'); +var $parseInteger = GetIntrinsic('%parseInt%'); + +var callBound = require('call-bind/callBound'); +var regexTester = require('safe-regex-test'); +var isPrimitive = require('../helpers/isPrimitive'); + +var $strSlice = callBound('String.prototype.slice'); +var isBinary = regexTester(/^0b[01]+$/i); +var isOctal = regexTester(/^0o[0-7]+$/i); +var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i); +var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); +var nonWSregex = new $RegExp('[' + nonWS + ']', 'g'); +var hasNonWS = regexTester(nonWSregex); + +var $trim = require('string.prototype.trim'); + +var ToPrimitive = require('./ToPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-tonumber + +module.exports = function ToNumber(argument) { + var value = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (typeof value === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a number'); + } + if (typeof value === 'string') { + if (isBinary(value)) { + return ToNumber($parseInteger($strSlice(value, 2), 2)); + } else if (isOctal(value)) { + return ToNumber($parseInteger($strSlice(value, 2), 8)); + } else if (hasNonWS(value) || isInvalidHexLiteral(value)) { + return NaN; + } + var trimmed = $trim(value); + if (trimmed !== value) { + return ToNumber(trimmed); + } + + } + return $Number(value); +}; diff --git a/node_modules/es-abstract/2015/ToPropertyDescriptor.js b/node_modules/es-abstract/2015/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..0af998a5d7f922a5494751846932c0987aa95ff9 --- /dev/null +++ b/node_modules/es-abstract/2015/ToPropertyDescriptor.js @@ -0,0 +1,52 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); +var ToBoolean = require('./ToBoolean'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (Type(Obj) !== 'Object') { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2015/ToString.js b/node_modules/es-abstract/2015/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2015/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2015/ToUint16.js b/node_modules/es-abstract/2015/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..633ca8464dd23b8c48cb91bf70f026c5e2fa91fd --- /dev/null +++ b/node_modules/es-abstract/2015/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2015/ToUint32.js b/node_modules/es-abstract/2015/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2015/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2015/ToUint8.js b/node_modules/es-abstract/2015/ToUint8.js new file mode 100644 index 0000000000000000000000000000000000000000..6e4e4b5add2ab6ee6c7cf55371c4140e80d1caf5 --- /dev/null +++ b/node_modules/es-abstract/2015/ToUint8.js @@ -0,0 +1,20 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +var abs = require('./abs'); +var floor = require('./floor'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/6.0/#sec-touint8 + +module.exports = function ToUint8(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x100); +}; diff --git a/node_modules/es-abstract/2015/ToUint8Clamp.js b/node_modules/es-abstract/2015/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2015/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2015/Type.js b/node_modules/es-abstract/2015/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..da5cb762508f187a91583bfc2d509036d492aa66 --- /dev/null +++ b/node_modules/es-abstract/2015/Type.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/6.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2015/ValidateTypedArray.js b/node_modules/es-abstract/2015/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2015/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2015/WeekDay.js b/node_modules/es-abstract/2015/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2015/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2015/YearFromTime.js b/node_modules/es-abstract/2015/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..be06ecbc36310e9f8ff1e6939dab408141051c0a --- /dev/null +++ b/node_modules/es-abstract/2015/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bind/callBound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2015/abs.js b/node_modules/es-abstract/2015/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2015/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2015/floor.js b/node_modules/es-abstract/2015/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..8439df0649365bf9309bbea76dcfae10e64a599c --- /dev/null +++ b/node_modules/es-abstract/2015/floor.js @@ -0,0 +1,11 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function floor(x) { + // return x - modulo(x, 1); + return $floor(x); +}; diff --git a/node_modules/es-abstract/2015/max.js b/node_modules/es-abstract/2015/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2015/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2015/msFromTime.js b/node_modules/es-abstract/2015/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2015/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2015/thisBooleanValue.js b/node_modules/es-abstract/2015/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2015/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2015/thisNumberValue.js b/node_modules/es-abstract/2015/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2015/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2016/AbstractEqualityComparison.js b/node_modules/es-abstract/2016/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..b56a5066224470eec1a41d7d3b2d6591f7a5f1b8 --- /dev/null +++ b/node_modules/es-abstract/2016/AbstractEqualityComparison.js @@ -0,0 +1,37 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return x === y; // ES6+ specified this shortcut anyways. + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (xType === 'Boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (yType === 'Boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'Symbol') && yType === 'Object') { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + return false; +}; diff --git a/node_modules/es-abstract/2016/AdvanceStringIndex.js b/node_modules/es-abstract/2016/AdvanceStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..831ea96ef913582f778f0aa5479ecbaa529d700d --- /dev/null +++ b/node_modules/es-abstract/2016/AdvanceStringIndex.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $charCodeAt = require('call-bind/callBound')('String.prototype.charCodeAt'); + +// https://262.ecma-international.org/6.0/#sec-advancestringindex + +module.exports = function AdvanceStringIndex(S, index, unicode) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); + } + if (Type(unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `unicode` must be a Boolean'); + } + if (!unicode) { + return index + 1; + } + var length = S.length; + if ((index + 1) >= length) { + return index + 1; + } + + var first = $charCodeAt(S, index); + if (!isLeadingSurrogate(first)) { + return index + 1; + } + + var second = $charCodeAt(S, index + 1); + if (!isTrailingSurrogate(second)) { + return index + 1; + } + + return index + 2; +}; diff --git a/node_modules/es-abstract/2016/ArrayCreate.js b/node_modules/es-abstract/2016/ArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..0d34db9beca45cd443d12448cf33057a3eac49b7 --- /dev/null +++ b/node_modules/es-abstract/2016/ArrayCreate.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ArrayPrototype = GetIntrinsic('%Array.prototype%'); +var $RangeError = GetIntrinsic('%RangeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isInteger = require('../helpers/isInteger'); + +var hasProto = require('has-proto')(); + +var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1; + +var $setProto = GetIntrinsic('%Object.setPrototypeOf%', true) || ( + hasProto + ? function (O, proto) { + O.__proto__ = proto; // eslint-disable-line no-proto, no-param-reassign + return O; + } + : null +); + +// https://262.ecma-international.org/6.0/#sec-arraycreate + +module.exports = function ArrayCreate(length) { + if (!isInteger(length) || length < 0) { + throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); + } + if (length > MAX_ARRAY_LENGTH) { + throw new $RangeError('length is greater than (2**32 - 1)'); + } + var proto = arguments.length > 1 ? arguments[1] : $ArrayPrototype; + var A = []; // steps 5 - 7, and 9 + if (proto !== $ArrayPrototype) { // step 8 + if (!$setProto) { + throw new $SyntaxError('ArrayCreate: a `proto` argument that is not `Array.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + $setProto(A, proto); + } + if (length !== 0) { // bypasses the need for step 2 + A.length = length; + } + /* step 10, the above as a shortcut for the below + OrdinaryDefineOwnProperty(A, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': true + }); + */ + return A; +}; diff --git a/node_modules/es-abstract/2016/ArraySetLength.js b/node_modules/es-abstract/2016/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2016/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2016/ArraySpeciesCreate.js b/node_modules/es-abstract/2016/ArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..1944dfe7b8974e00989d21840cb935a5770ed977 --- /dev/null +++ b/node_modules/es-abstract/2016/ArraySpeciesCreate.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Array = GetIntrinsic('%Array%'); +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate + +module.exports = function ArraySpeciesCreate(originalArray, length) { + if (!isInteger(length) || length < 0) { + throw new $TypeError('Assertion failed: length must be an integer >= 0'); + } + var len = length === 0 ? 0 : length; + var C; + var isArray = IsArray(originalArray); + if (isArray) { + C = Get(originalArray, 'constructor'); + // TODO: figure out how to make a cross-realm normal Array, a same-realm Array + // if (IsConstructor(C)) { + // if C is another realm's Array, C = undefined + // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ? + // } + if ($species && Type(C) === 'Object') { + C = Get(C, $species); + if (C === null) { + C = void 0; + } + } + } + if (typeof C === 'undefined') { + return $Array(len); + } + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); + } + return new C(len); // Construct(C, len); +}; + diff --git a/node_modules/es-abstract/2016/Call.js b/node_modules/es-abstract/2016/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..be76246db04f06d84ed52f6f052d6bc98b131b51 --- /dev/null +++ b/node_modules/es-abstract/2016/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2016/CompletePropertyDescriptor.js b/node_modules/es-abstract/2016/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..1530241dc526d85b8e2e27d226aa2015befc762c --- /dev/null +++ b/node_modules/es-abstract/2016/CompletePropertyDescriptor.js @@ -0,0 +1,39 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var assertRecord = require('../helpers/assertRecord'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + /* eslint no-param-reassign: 0 */ + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2016/CreateDataProperty.js b/node_modules/es-abstract/2016/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2016/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2016/CreateHTML.js b/node_modules/es-abstract/2016/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2016/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2016/CreateListFromArrayLike.js b/node_modules/es-abstract/2016/CreateListFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..4c34219206e1fc0a5990f7bdbee2592b77a68160 --- /dev/null +++ b/node_modules/es-abstract/2016/CreateListFromArrayLike.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf'); +var $push = callBound('Array.prototype.push'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'Object']; + +// https://262.ecma-international.org/6.0/#sec-createlistfromarraylike +module.exports = function CreateListFromArrayLike(obj) { + var elementTypes = arguments.length > 1 + ? arguments[1] + : defaultElementTypes; + + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + if (!IsArray(elementTypes)) { + throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array'); + } + var len = ToLength(Get(obj, 'length')); + var list = []; + var index = 0; + while (index < len) { + var indexName = ToString(index); + var next = Get(obj, indexName); + var nextType = Type(next); + if ($indexOf(elementTypes, nextType) < 0) { + throw new $TypeError('item type ' + nextType + ' is not a valid elementType'); + } + $push(list, next); + index += 1; + } + return list; +}; diff --git a/node_modules/es-abstract/2016/CreateMethodProperty.js b/node_modules/es-abstract/2016/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2016/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2016/DateFromTime.js b/node_modules/es-abstract/2016/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2016/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2016/DayFromYear.js b/node_modules/es-abstract/2016/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2016/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2016/DayWithinYear.js b/node_modules/es-abstract/2016/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2016/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2016/DefinePropertyOrThrow.js b/node_modules/es-abstract/2016/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2016/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2016/DeletePropertyOrThrow.js b/node_modules/es-abstract/2016/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2016/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2016/DetachArrayBuffer.js b/node_modules/es-abstract/2016/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..a7b89b36bbcad1f5cc6f1dfbf5f9ae878f34617a --- /dev/null +++ b/node_modules/es-abstract/2016/DetachArrayBuffer.js @@ -0,0 +1,34 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; // node 11.7+ +} catch (e) { /**/ } + +// https://262.ecma-international.org/6.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot'); + } + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2016/EnumerableOwnNames.js b/node_modules/es-abstract/2016/EnumerableOwnNames.js new file mode 100644 index 0000000000000000000000000000000000000000..b8235966aca93bf9f759e9f20c49aa837c7c3a1f --- /dev/null +++ b/node_modules/es-abstract/2016/EnumerableOwnNames.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var keys = require('object-keys'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-enumerableownnames + +module.exports = function EnumerableOwnNames(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return keys(O); +}; diff --git a/node_modules/es-abstract/2016/FromPropertyDescriptor.js b/node_modules/es-abstract/2016/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..c70f0c60e1ff8b16858f71af25b644f8d9a3d589 --- /dev/null +++ b/node_modules/es-abstract/2016/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var assertRecord = require('../helpers/assertRecord'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined') { + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2016/GetGlobalObject.js b/node_modules/es-abstract/2016/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2016/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2016/GetIterator.js b/node_modules/es-abstract/2016/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..145557da422e4910c3371cff4d498ed244213d1e --- /dev/null +++ b/node_modules/es-abstract/2016/GetIterator.js @@ -0,0 +1,34 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getiterator + +module.exports = function GetIterator(obj, method) { + var actualMethod = method; + if (arguments.length < 2) { + actualMethod = getIteratorMethod( + { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod, + IsArray: IsArray + }, + obj + ); + } + var iterator = Call(actualMethod, obj); + if (Type(iterator) !== 'Object') { + throw new $TypeError('iterator must return an object'); + } + + return iterator; +}; diff --git a/node_modules/es-abstract/2016/GetMethod.js b/node_modules/es-abstract/2016/GetMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..e9f2854ff3842ecf3c3c2b23f425628ba00dd285 --- /dev/null +++ b/node_modules/es-abstract/2016/GetMethod.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var IsPropertyKey = require('./IsPropertyKey'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/6.0/#sec-getmethod + +module.exports = function GetMethod(O, P) { + // 7.3.9.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // 7.3.9.2 + var func = GetV(O, P); + + // 7.3.9.4 + if (func == null) { + return void 0; + } + + // 7.3.9.5 + if (!IsCallable(func)) { + throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); + } + + // 7.3.9.6 + return func; +}; diff --git a/node_modules/es-abstract/2016/GetOwnPropertyKeys.js b/node_modules/es-abstract/2016/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..043fd733bd8a4e8724c38dc30444a0fd8a726f5e --- /dev/null +++ b/node_modules/es-abstract/2016/GetOwnPropertyKeys.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +var esType = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (esType(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $gOPS ? $gOPS(O) : []; + } + if (Type === 'String') { + if (!$gOPN) { + return keys(O); + } + return $gOPN(O); + } + throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`'); +}; diff --git a/node_modules/es-abstract/2016/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2016/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2016/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2016/GetV.js b/node_modules/es-abstract/2016/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2016/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2016/GetValueFromBuffer.js b/node_modules/es-abstract/2016/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..0295846c7cc4d2bfe61f42e0a33f0183bb9d8295 --- /dev/null +++ b/node_modules/es-abstract/2016/GetValueFromBuffer.js @@ -0,0 +1,97 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $charAt = callBound('String.prototype.charAt'); +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var defaultEndianness = require('../helpers/defaultEndianness'); +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isArrayBuffer = require('is-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table49 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $Float32: 4, + $Float64: 8 +}; + +var isUnsignedElementType = function isUnsignedElementType(type) { return $charAt(type, 0) === 'U'; }; + +// https://262.ecma-international.org/6.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string') { + throw new $TypeError('Assertion failed: `type` must be a string'); + } + + if (arguments.length > 3 && typeof arguments[3] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + var elementSize = table49['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + // 6. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + var rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 3 ? arguments[3] : defaultEndianness === 'little'; // step 7 + + if (!isLittleEndian) { + $reverse(rawValue); // step 8 + } + + var bytes = $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize); + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(bytes, true); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(bytes, true); + } + + return bytesAsInteger(bytes, elementSize, isUnsignedElementType(type), false); +}; diff --git a/node_modules/es-abstract/2016/HasOwnProperty.js b/node_modules/es-abstract/2016/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2016/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2016/HourFromTime.js b/node_modules/es-abstract/2016/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2016/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2016/InstanceofOperator.js b/node_modules/es-abstract/2016/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..4a34d0c20cdb0d93d5de2316c73ba8faff2aabeb --- /dev/null +++ b/node_modules/es-abstract/2016/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2016/Invoke.js b/node_modules/es-abstract/2016/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..084e5e28253d5ac2d98d1e0b735512b7e9db6e17 --- /dev/null +++ b/node_modules/es-abstract/2016/Invoke.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var IsPropertyKey = require('./IsPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2016/IsAccessorDescriptor.js b/node_modules/es-abstract/2016/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2016/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2016/IsCallable.js b/node_modules/es-abstract/2016/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2016/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2016/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2016/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2016/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2016/IsConcatSpreadable.js b/node_modules/es-abstract/2016/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2016/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2016/IsConstructor.js b/node_modules/es-abstract/2016/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2016/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2016/IsDataDescriptor.js b/node_modules/es-abstract/2016/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2016/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2016/IsInteger.js b/node_modules/es-abstract/2016/IsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..e3d25f38e30093f0a0444e98ef3ddc4e0b35d2ed --- /dev/null +++ b/node_modules/es-abstract/2016/IsInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-isinteger + +module.exports = function IsInteger(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2016/IsPromise.js b/node_modules/es-abstract/2016/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..411539b0818c20d3f4d41852082b3f1a263dbcd8 --- /dev/null +++ b/node_modules/es-abstract/2016/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (Type(x) !== 'Object') { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2016/IsPropertyDescriptor.js b/node_modules/es-abstract/2016/IsPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..4cfe79bbe5dbcc5df02e1dae9d1859cb8d9e8cb3 --- /dev/null +++ b/node_modules/es-abstract/2016/IsPropertyDescriptor.js @@ -0,0 +1,19 @@ +'use strict'; + +// TODO, semver-major: delete this + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var Type = require('./Type'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type + +module.exports = function IsPropertyDescriptor(Desc) { + return isPropertyDescriptor({ + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor, + Type: Type + }, Desc); +}; diff --git a/node_modules/es-abstract/2016/IsPropertyKey.js b/node_modules/es-abstract/2016/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..aaeb6f9b6f83b5a39f1f53cec0edbf19cbc61170 --- /dev/null +++ b/node_modules/es-abstract/2016/IsPropertyKey.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; +}; diff --git a/node_modules/es-abstract/2016/IsRegExp.js b/node_modules/es-abstract/2016/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2016/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2016/IsWordChar.js b/node_modules/es-abstract/2016/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..49f42eccac00ebf7f6c2e3c755a2ba24d35c7ac8 --- /dev/null +++ b/node_modules/es-abstract/2016/IsWordChar.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); + +var every = require('../helpers/every'); +var regexTester = require('safe-regex-test'); + +var isChar = function isChar(c) { + return typeof c === 'string' && c.length === 1; +}; + +var isWordCharacter = regexTester(/^[a-zA-Z0-9_]$/); + +// https://262.ecma-international.org/6.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input) { + if (!IsInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + return isWordCharacter(c); // steps 3-4 +}; diff --git a/node_modules/es-abstract/2016/IterableToArrayLike.js b/node_modules/es-abstract/2016/IterableToArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..82c6c33d50bfc145cf97057b76e834211bd76b2a --- /dev/null +++ b/node_modules/es-abstract/2016/IterableToArrayLike.js @@ -0,0 +1,39 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); +var $arrayPush = callBound('Array.prototype.push'); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var GetIterator = require('./GetIterator'); +var GetMethod = require('./GetMethod'); +var IsArray = require('./IsArray'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ToObject = require('./ToObject'); +var ES = { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod, + IsArray: IsArray +}; + +// https://262.ecma-international.org/7.0/#sec-iterabletoarraylike + +module.exports = function IterableToArrayLike(items) { + var usingIterator = getIteratorMethod(ES, items); + if (typeof usingIterator !== 'undefined') { + var iterator = GetIterator(items, usingIterator); + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + $arrayPush(values, nextValue); + } + } + return values; + } + + return ToObject(items); +}; diff --git a/node_modules/es-abstract/2016/IteratorClose.js b/node_modules/es-abstract/2016/IteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..7c1076082e1e22b9b4a834af869afae7237414a7 --- /dev/null +++ b/node_modules/es-abstract/2016/IteratorClose.js @@ -0,0 +1,51 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorclose + +module.exports = function IteratorClose(iterator, completion) { + if (Type(iterator) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterator) is not Object'); + } + if (!IsCallable(completion) && !(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a thunk representing a Completion Record, nor a Completion Record instance'); + } + var completionThunk = completion instanceof CompletionRecord ? function () { return completion['?'](); } : completion; + + var iteratorReturn = GetMethod(iterator, 'return'); + + if (typeof iteratorReturn === 'undefined') { + return completionThunk(); + } + + var completionRecord; + try { + var innerResult = Call(iteratorReturn, iterator, []); + } catch (e) { + // if we hit here, then "e" is the innerResult completion that needs re-throwing + + // if the completion is of type "throw", this will throw. + completionThunk(); + completionThunk = null; // ensure it's not called twice. + + // if not, then return the innerResult completion + throw e; + } + completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does + completionThunk = null; // ensure it's not called twice. + + if (Type(innerResult) !== 'Object') { + throw new $TypeError('iterator .return must return an object'); + } + + return completionRecord; +}; diff --git a/node_modules/es-abstract/2016/IteratorComplete.js b/node_modules/es-abstract/2016/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2016/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2016/IteratorNext.js b/node_modules/es-abstract/2016/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..d84d66edb5fc2bd565f3053f15208c37a33024d6 --- /dev/null +++ b/node_modules/es-abstract/2016/IteratorNext.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Invoke = require('./Invoke'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (Type(result) !== 'Object') { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2016/IteratorStep.js b/node_modules/es-abstract/2016/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2016/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2016/IteratorValue.js b/node_modules/es-abstract/2016/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2016/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2016/MakeDate.js b/node_modules/es-abstract/2016/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..efeb6452e78c9f30c8aefc53fede97b874ac2e63 --- /dev/null +++ b/node_modules/es-abstract/2016/MakeDate.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2016/MakeTime.js b/node_modules/es-abstract/2016/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..34cb4dcca3f84920250ddb1dce54cecba114a3ad --- /dev/null +++ b/node_modules/es-abstract/2016/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2016/MonthFromTime.js b/node_modules/es-abstract/2016/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2016/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2016/NewPromiseCapability.js b/node_modules/es-abstract/2016/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2016/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2016/NormalCompletion.js b/node_modules/es-abstract/2016/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2016/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2016/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2016/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ede44ed6b75eed8e851821ffee51b52994bb86a7 --- /dev/null +++ b/node_modules/es-abstract/2016/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var ObjectCreate = require('./ObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return ObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2016/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2016/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2016/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2016/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2016/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..ba17b98872933ef285da579420e75fa18b072ce9 --- /dev/null +++ b/node_modules/es-abstract/2016/OrdinaryGetPrototypeOf.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $getProto = require('../helpers/getProto'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2016/OrdinaryHasInstance.js b/node_modules/es-abstract/2016/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2016/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2016/OrdinaryHasProperty.js b/node_modules/es-abstract/2016/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2016/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2016/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2016/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b72306c187b6e9f4355b399831a46e10fa7f61 --- /dev/null +++ b/node_modules/es-abstract/2016/OrdinarySetPrototypeOf.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $setProto = require('../helpers/setProto'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (Type(V) !== 'Object' && Type(V) !== 'Null') { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2016/QuoteJSONString.js b/node_modules/es-abstract/2016/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..7dabf54bf2f02e4172c9c05373c1335c450bf941 --- /dev/null +++ b/node_modules/es-abstract/2016/QuoteJSONString.js @@ -0,0 +1,52 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); +var $strSlice = callBound('String.prototype.slice'); +var $strSplit = callBound('String.prototype.split'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-quotejsonstring + +var escapes = { + '\u0008': 'b', + '\u000C': 'f', + '\u000A': 'n', + '\u000D': 'r', + '\u0009': 't' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(value), function (C) { + if (C === '"' || C === '\\') { + product += '\u005C' + C; + } else if (C === '\u0008' || C === '\u000C' || C === '\u000A' || C === '\u000D' || C === '\u0009') { + var abbrev = escapes[C]; + product += '\u005C' + abbrev; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20) { + product += '\u005Cu' + $toLowerCase($strSlice('0000' + $numberToString(cCharCode, 16), -4)); + } else { + product += C; + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2016/RegExpExec.js b/node_modules/es-abstract/2016/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2016/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2016/RequireObjectCoercible.js b/node_modules/es-abstract/2016/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9008359db8f9ac7107563f46c1aebc2258b8cb2b --- /dev/null +++ b/node_modules/es-abstract/2016/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../5/CheckObjectCoercible'); diff --git a/node_modules/es-abstract/2016/SameValue.js b/node_modules/es-abstract/2016/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2016/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2016/SameValueZero.js b/node_modules/es-abstract/2016/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2016/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2016/Set.js b/node_modules/es-abstract/2016/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..969703136399bce4cdbafbd357690f4f53301c0d --- /dev/null +++ b/node_modules/es-abstract/2016/Set.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (Type(Throw) !== 'Boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2016/SetIntegrityLevel.js b/node_modules/es-abstract/2016/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2016/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2016/SetValueInBuffer.js b/node_modules/es-abstract/2016/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..d5c2fa479b95179deeba9ccec4d2e1513cb21585 --- /dev/null +++ b/node_modules/es-abstract/2016/SetValueInBuffer.js @@ -0,0 +1,120 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var isArrayBuffer = require('is-array-buffer'); +var hasOwn = require('hasown'); + +var table49 = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +var TypeToAO = { + __proto__: null, + Int8: ToInt8, + Uint8: ToUint8, + Uint8C: ToUint8Clamp, + Int16: ToInt16, + Uint16: ToUint16, + Int32: ToInt32, + Uint32: ToUint32 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); +var integerToNBytes = require('../helpers/integerToNBytes'); +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); + +// https://262.ecma-international.org/6.0/#sec-setvalueinbuffer + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || !hasOwn(table49, type)) { + throw new $TypeError('Assertion failed: `type` must be a Typed Array Element Type'); + } + + if (typeof value !== 'number') { + throw new $TypeError('Assertion failed: `value` must be a number'); + } + + if (arguments.length > 4 && typeof arguments[4] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Assert: Type(value) is Number. + + // 5. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + // 6. Assert: block is not undefined. + + var elementSize = table49[type]; // step 7 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the GetValueFromBuffer abstract operation. + var isLittleEndian = arguments.length > 4 ? arguments[4] : defaultEndianness === 'little'; // step 8 + + var rawBytes; + if (type === 'Float32') { // step 1 + rawBytes = valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + rawBytes = valueToFloat64Bytes(value, isLittleEndian); + } else { + var n = table49[type]; // step 3.a + + var convOp = TypeToAO[type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + rawBytes = integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 + } + + // 12. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + + // 13. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2016/SpeciesConstructor.js b/node_modules/es-abstract/2016/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2016/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2016/SplitMatch.js b/node_modules/es-abstract/2016/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..d57fb691e5e91dfb4d30a974e9ebbff47a22e24e --- /dev/null +++ b/node_modules/es-abstract/2016/SplitMatch.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/6.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (Type(R) !== 'String') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return false; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return false; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2016/StringCreate.js b/node_modules/es-abstract/2016/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2016/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2016/SymbolDescriptiveString.js b/node_modules/es-abstract/2016/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2016/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2016/TimeFromYear.js b/node_modules/es-abstract/2016/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2016/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2016/TimeWithinDay.js b/node_modules/es-abstract/2016/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2016/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2016/ToBoolean.js b/node_modules/es-abstract/2016/ToBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..466404bf9992f0ba636249264c620d6c56215d6a --- /dev/null +++ b/node_modules/es-abstract/2016/ToBoolean.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.2 + +module.exports = function ToBoolean(value) { return !!value; }; diff --git a/node_modules/es-abstract/2016/ToDateString.js b/node_modules/es-abstract/2016/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2016/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2016/ToInt16.js b/node_modules/es-abstract/2016/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2016/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2016/ToInt32.js b/node_modules/es-abstract/2016/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2016/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2016/ToInt8.js b/node_modules/es-abstract/2016/ToInt8.js new file mode 100644 index 0000000000000000000000000000000000000000..e223b6c1d352a3432da2d272d0f7e66bbfa818b4 --- /dev/null +++ b/node_modules/es-abstract/2016/ToInt8.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint8 = require('./ToUint8'); + +// https://262.ecma-international.org/6.0/#sec-toint8 + +module.exports = function ToInt8(argument) { + var int8bit = ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; +}; diff --git a/node_modules/es-abstract/2016/ToInteger.js b/node_modules/es-abstract/2016/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..f6625796ebd22a688826a1bd5d36e20dfe6ebcc7 --- /dev/null +++ b/node_modules/es-abstract/2016/ToInteger.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5ToInteger = require('../5/ToInteger'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/6.0/#sec-tointeger + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + return ES5ToInteger(number); +}; diff --git a/node_modules/es-abstract/2016/ToLength.js b/node_modules/es-abstract/2016/ToLength.js new file mode 100644 index 0000000000000000000000000000000000000000..1bef9bed7b2f0cbbd9477769cb4bcdeb3b8814bc --- /dev/null +++ b/node_modules/es-abstract/2016/ToLength.js @@ -0,0 +1,12 @@ +'use strict'; + +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var ToInteger = require('./ToInteger'); + +module.exports = function ToLength(argument) { + var len = ToInteger(argument); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; } + return len; +}; diff --git a/node_modules/es-abstract/2016/ToPropertyDescriptor.js b/node_modules/es-abstract/2016/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..0af998a5d7f922a5494751846932c0987aa95ff9 --- /dev/null +++ b/node_modules/es-abstract/2016/ToPropertyDescriptor.js @@ -0,0 +1,52 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); +var ToBoolean = require('./ToBoolean'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (Type(Obj) !== 'Object') { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2016/ToString.js b/node_modules/es-abstract/2016/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2016/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2016/ToUint16.js b/node_modules/es-abstract/2016/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..633ca8464dd23b8c48cb91bf70f026c5e2fa91fd --- /dev/null +++ b/node_modules/es-abstract/2016/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2016/ToUint32.js b/node_modules/es-abstract/2016/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2016/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2016/ToUint8.js b/node_modules/es-abstract/2016/ToUint8.js new file mode 100644 index 0000000000000000000000000000000000000000..6e4e4b5add2ab6ee6c7cf55371c4140e80d1caf5 --- /dev/null +++ b/node_modules/es-abstract/2016/ToUint8.js @@ -0,0 +1,20 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +var abs = require('./abs'); +var floor = require('./floor'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/6.0/#sec-touint8 + +module.exports = function ToUint8(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x100); +}; diff --git a/node_modules/es-abstract/2016/ToUint8Clamp.js b/node_modules/es-abstract/2016/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2016/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2016/Type.js b/node_modules/es-abstract/2016/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..da5cb762508f187a91583bfc2d509036d492aa66 --- /dev/null +++ b/node_modules/es-abstract/2016/Type.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/6.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2016/TypedArrayCreate.js b/node_modules/es-abstract/2016/TypedArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..ef9fbe2599495aabd3fdb47a40dffd7d178ad2cb --- /dev/null +++ b/node_modules/es-abstract/2016/TypedArrayCreate.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var availableTypedArrays = require('available-typed-arrays')(); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/7.0/#typedarray-create + +module.exports = function TypedArrayCreate(constructor, argumentList) { + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); + } + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + // var newTypedArray = Construct(constructor, argumentList); // step 1 + var newTypedArray; + if (argumentList.length === 0) { + newTypedArray = new constructor(); + } else if (argumentList.length === 1) { + newTypedArray = new constructor(argumentList[0]); + } else if (argumentList.length === 2) { + newTypedArray = new constructor(argumentList[0], argumentList[1]); + } else { + newTypedArray = new constructor(argumentList[0], argumentList[1], argumentList[2]); + } + + ValidateTypedArray(newTypedArray); // step 2 + + if (argumentList.length === 1 && Type(argumentList[0]) === 'Number') { // step 3 + if (typedArrayLength(newTypedArray) < argumentList[0]) { + throw new $TypeError('Assertion failed: `argumentList[0]` must be <= `newTypedArray.length`'); // step 3.a + } + } + + return newTypedArray; // step 4 +}; diff --git a/node_modules/es-abstract/2016/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2016/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2bfdff5eb705c2c866ad0623064a35be67b92b73 --- /dev/null +++ b/node_modules/es-abstract/2016/TypedArraySpeciesCreate.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2016/UTF16Decode.js b/node_modules/es-abstract/2016/UTF16Decode.js new file mode 100644 index 0000000000000000000000000000000000000000..86927b478ccdb26659380330009b5d3eaae0e8a3 --- /dev/null +++ b/node_modules/es-abstract/2016/UTF16Decode.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +// https://262.ecma-international.org/7.0/#sec-utf16decode + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16Decode(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2016/UTF16Encoding.js b/node_modules/es-abstract/2016/UTF16Encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..f381595fd70d6396dd841c7e71552247f2d80f0e --- /dev/null +++ b/node_modules/es-abstract/2016/UTF16Encoding.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/7.0/#sec-utf16encoding + +module.exports = function UTF16Encoding(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = floor((cp - 65536) / 1024) + 0xD800; + var cu2 = modulo(cp - 65536, 1024) + 0xDC00; + return $fromCharCode(cu1) + $fromCharCode(cu2); +}; diff --git a/node_modules/es-abstract/2016/ValidateTypedArray.js b/node_modules/es-abstract/2016/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2016/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2016/WeekDay.js b/node_modules/es-abstract/2016/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2016/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2016/YearFromTime.js b/node_modules/es-abstract/2016/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..be06ecbc36310e9f8ff1e6939dab408141051c0a --- /dev/null +++ b/node_modules/es-abstract/2016/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bind/callBound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2016/abs.js b/node_modules/es-abstract/2016/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2016/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2016/floor.js b/node_modules/es-abstract/2016/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..8439df0649365bf9309bbea76dcfae10e64a599c --- /dev/null +++ b/node_modules/es-abstract/2016/floor.js @@ -0,0 +1,11 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function floor(x) { + // return x - modulo(x, 1); + return $floor(x); +}; diff --git a/node_modules/es-abstract/2016/max.js b/node_modules/es-abstract/2016/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2016/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2016/msFromTime.js b/node_modules/es-abstract/2016/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2016/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2016/thisBooleanValue.js b/node_modules/es-abstract/2016/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2016/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2016/thisNumberValue.js b/node_modules/es-abstract/2016/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2016/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2017/AbstractEqualityComparison.js b/node_modules/es-abstract/2017/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..b56a5066224470eec1a41d7d3b2d6591f7a5f1b8 --- /dev/null +++ b/node_modules/es-abstract/2017/AbstractEqualityComparison.js @@ -0,0 +1,37 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return x === y; // ES6+ specified this shortcut anyways. + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (xType === 'Boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (yType === 'Boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'Symbol') && yType === 'Object') { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + return false; +}; diff --git a/node_modules/es-abstract/2017/AdvanceStringIndex.js b/node_modules/es-abstract/2017/AdvanceStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..831ea96ef913582f778f0aa5479ecbaa529d700d --- /dev/null +++ b/node_modules/es-abstract/2017/AdvanceStringIndex.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $charCodeAt = require('call-bind/callBound')('String.prototype.charCodeAt'); + +// https://262.ecma-international.org/6.0/#sec-advancestringindex + +module.exports = function AdvanceStringIndex(S, index, unicode) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); + } + if (Type(unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `unicode` must be a Boolean'); + } + if (!unicode) { + return index + 1; + } + var length = S.length; + if ((index + 1) >= length) { + return index + 1; + } + + var first = $charCodeAt(S, index); + if (!isLeadingSurrogate(first)) { + return index + 1; + } + + var second = $charCodeAt(S, index + 1); + if (!isTrailingSurrogate(second)) { + return index + 1; + } + + return index + 2; +}; diff --git a/node_modules/es-abstract/2017/ArraySetLength.js b/node_modules/es-abstract/2017/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2017/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2017/Call.js b/node_modules/es-abstract/2017/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..be76246db04f06d84ed52f6f052d6bc98b131b51 --- /dev/null +++ b/node_modules/es-abstract/2017/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2017/CompletePropertyDescriptor.js b/node_modules/es-abstract/2017/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..1530241dc526d85b8e2e27d226aa2015befc762c --- /dev/null +++ b/node_modules/es-abstract/2017/CompletePropertyDescriptor.js @@ -0,0 +1,39 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var assertRecord = require('../helpers/assertRecord'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + /* eslint no-param-reassign: 0 */ + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2017/CreateDataProperty.js b/node_modules/es-abstract/2017/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2017/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2017/CreateHTML.js b/node_modules/es-abstract/2017/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2017/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2017/CreateListFromArrayLike.js b/node_modules/es-abstract/2017/CreateListFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..4c34219206e1fc0a5990f7bdbee2592b77a68160 --- /dev/null +++ b/node_modules/es-abstract/2017/CreateListFromArrayLike.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf'); +var $push = callBound('Array.prototype.push'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'Object']; + +// https://262.ecma-international.org/6.0/#sec-createlistfromarraylike +module.exports = function CreateListFromArrayLike(obj) { + var elementTypes = arguments.length > 1 + ? arguments[1] + : defaultElementTypes; + + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + if (!IsArray(elementTypes)) { + throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array'); + } + var len = ToLength(Get(obj, 'length')); + var list = []; + var index = 0; + while (index < len) { + var indexName = ToString(index); + var next = Get(obj, indexName); + var nextType = Type(next); + if ($indexOf(elementTypes, nextType) < 0) { + throw new $TypeError('item type ' + nextType + ' is not a valid elementType'); + } + $push(list, next); + index += 1; + } + return list; +}; diff --git a/node_modules/es-abstract/2017/CreateMethodProperty.js b/node_modules/es-abstract/2017/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2017/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2017/DateFromTime.js b/node_modules/es-abstract/2017/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2017/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2017/DayFromYear.js b/node_modules/es-abstract/2017/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2017/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2017/DayWithinYear.js b/node_modules/es-abstract/2017/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2017/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2017/DefinePropertyOrThrow.js b/node_modules/es-abstract/2017/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2017/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2017/DeletePropertyOrThrow.js b/node_modules/es-abstract/2017/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2017/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2017/DetachArrayBuffer.js b/node_modules/es-abstract/2017/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..db77a07ecacc819f1084d81e8d7594140e51929a --- /dev/null +++ b/node_modules/es-abstract/2017/DetachArrayBuffer.js @@ -0,0 +1,35 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; // node 11.7+ +} catch (e) { /**/ } + +// https://262.ecma-international.org/8.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2017/FromPropertyDescriptor.js b/node_modules/es-abstract/2017/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..c70f0c60e1ff8b16858f71af25b644f8d9a3d589 --- /dev/null +++ b/node_modules/es-abstract/2017/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var assertRecord = require('../helpers/assertRecord'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined') { + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2017/GetGlobalObject.js b/node_modules/es-abstract/2017/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2017/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2017/GetIterator.js b/node_modules/es-abstract/2017/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..145557da422e4910c3371cff4d498ed244213d1e --- /dev/null +++ b/node_modules/es-abstract/2017/GetIterator.js @@ -0,0 +1,34 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getiterator + +module.exports = function GetIterator(obj, method) { + var actualMethod = method; + if (arguments.length < 2) { + actualMethod = getIteratorMethod( + { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod, + IsArray: IsArray + }, + obj + ); + } + var iterator = Call(actualMethod, obj); + if (Type(iterator) !== 'Object') { + throw new $TypeError('iterator must return an object'); + } + + return iterator; +}; diff --git a/node_modules/es-abstract/2017/GetMethod.js b/node_modules/es-abstract/2017/GetMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..e9f2854ff3842ecf3c3c2b23f425628ba00dd285 --- /dev/null +++ b/node_modules/es-abstract/2017/GetMethod.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var IsPropertyKey = require('./IsPropertyKey'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/6.0/#sec-getmethod + +module.exports = function GetMethod(O, P) { + // 7.3.9.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // 7.3.9.2 + var func = GetV(O, P); + + // 7.3.9.4 + if (func == null) { + return void 0; + } + + // 7.3.9.5 + if (!IsCallable(func)) { + throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); + } + + // 7.3.9.6 + return func; +}; diff --git a/node_modules/es-abstract/2017/GetOwnPropertyKeys.js b/node_modules/es-abstract/2017/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..043fd733bd8a4e8724c38dc30444a0fd8a726f5e --- /dev/null +++ b/node_modules/es-abstract/2017/GetOwnPropertyKeys.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +var esType = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (esType(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $gOPS ? $gOPS(O) : []; + } + if (Type === 'String') { + if (!$gOPN) { + return keys(O); + } + return $gOPN(O); + } + throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`'); +}; diff --git a/node_modules/es-abstract/2017/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2017/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2017/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2017/GetV.js b/node_modules/es-abstract/2017/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2017/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2017/GetValueFromBuffer.js b/node_modules/es-abstract/2017/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..0a0d14dba7b57bd67b9b6b9408315f91dcd1ef87 --- /dev/null +++ b/node_modules/es-abstract/2017/GetValueFromBuffer.js @@ -0,0 +1,108 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $slice = callBound('Array.prototype.slice'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumber = require('./RawBytesToNumber'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table50 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $Float32: 4, + $Float64: 8 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/8.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string') { + throw new $TypeError('Assertion failed: `type` must be a string'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (typeof order !== 'string') { + throw new $TypeError('Assertion failed: `order` must be a string'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = table50['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('TODO: support SharedArrayBuffers'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumber(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2017/HasOwnProperty.js b/node_modules/es-abstract/2017/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2017/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2017/HourFromTime.js b/node_modules/es-abstract/2017/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2017/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2017/InstanceofOperator.js b/node_modules/es-abstract/2017/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..4a34d0c20cdb0d93d5de2316c73ba8faff2aabeb --- /dev/null +++ b/node_modules/es-abstract/2017/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2017/Invoke.js b/node_modules/es-abstract/2017/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..084e5e28253d5ac2d98d1e0b735512b7e9db6e17 --- /dev/null +++ b/node_modules/es-abstract/2017/Invoke.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var IsPropertyKey = require('./IsPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2017/IsAccessorDescriptor.js b/node_modules/es-abstract/2017/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2017/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2017/IsCallable.js b/node_modules/es-abstract/2017/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2017/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2017/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2017/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2017/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2017/IsConcatSpreadable.js b/node_modules/es-abstract/2017/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2017/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2017/IsConstructor.js b/node_modules/es-abstract/2017/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2017/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2017/IsDataDescriptor.js b/node_modules/es-abstract/2017/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2017/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2017/IsInteger.js b/node_modules/es-abstract/2017/IsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..e3d25f38e30093f0a0444e98ef3ddc4e0b35d2ed --- /dev/null +++ b/node_modules/es-abstract/2017/IsInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-isinteger + +module.exports = function IsInteger(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2017/IsPromise.js b/node_modules/es-abstract/2017/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..411539b0818c20d3f4d41852082b3f1a263dbcd8 --- /dev/null +++ b/node_modules/es-abstract/2017/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (Type(x) !== 'Object') { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2017/IsPropertyDescriptor.js b/node_modules/es-abstract/2017/IsPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..4cfe79bbe5dbcc5df02e1dae9d1859cb8d9e8cb3 --- /dev/null +++ b/node_modules/es-abstract/2017/IsPropertyDescriptor.js @@ -0,0 +1,19 @@ +'use strict'; + +// TODO, semver-major: delete this + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var Type = require('./Type'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type + +module.exports = function IsPropertyDescriptor(Desc) { + return isPropertyDescriptor({ + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor, + Type: Type + }, Desc); +}; diff --git a/node_modules/es-abstract/2017/IsPropertyKey.js b/node_modules/es-abstract/2017/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..aaeb6f9b6f83b5a39f1f53cec0edbf19cbc61170 --- /dev/null +++ b/node_modules/es-abstract/2017/IsPropertyKey.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; +}; diff --git a/node_modules/es-abstract/2017/IsRegExp.js b/node_modules/es-abstract/2017/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2017/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2017/IsSharedArrayBuffer.js b/node_modules/es-abstract/2017/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8e96e33f3c2dca5c15127f2ae83fc45861d548b9 --- /dev/null +++ b/node_modules/es-abstract/2017/IsSharedArrayBuffer.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2017/IsWordChar.js b/node_modules/es-abstract/2017/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..5d61804925b6cb8f2570823c90ce44c1c96ece02 --- /dev/null +++ b/node_modules/es-abstract/2017/IsWordChar.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); +var Type = require('./Type'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!IsInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2017/IterableToList.js b/node_modules/es-abstract/2017/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..6a1a6be39f021a3129ea8d815e3f035a1361c644 --- /dev/null +++ b/node_modules/es-abstract/2017/IterableToList.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); +var $arrayPush = callBound('Array.prototype.push'); + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/8.0/#sec-iterabletolist + +module.exports = function IterableToList(items, method) { + var iterator = GetIterator(items, method); + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + $arrayPush(values, nextValue); + } + } + return values; +}; diff --git a/node_modules/es-abstract/2017/IteratorClose.js b/node_modules/es-abstract/2017/IteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..7c1076082e1e22b9b4a834af869afae7237414a7 --- /dev/null +++ b/node_modules/es-abstract/2017/IteratorClose.js @@ -0,0 +1,51 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorclose + +module.exports = function IteratorClose(iterator, completion) { + if (Type(iterator) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterator) is not Object'); + } + if (!IsCallable(completion) && !(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a thunk representing a Completion Record, nor a Completion Record instance'); + } + var completionThunk = completion instanceof CompletionRecord ? function () { return completion['?'](); } : completion; + + var iteratorReturn = GetMethod(iterator, 'return'); + + if (typeof iteratorReturn === 'undefined') { + return completionThunk(); + } + + var completionRecord; + try { + var innerResult = Call(iteratorReturn, iterator, []); + } catch (e) { + // if we hit here, then "e" is the innerResult completion that needs re-throwing + + // if the completion is of type "throw", this will throw. + completionThunk(); + completionThunk = null; // ensure it's not called twice. + + // if not, then return the innerResult completion + throw e; + } + completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does + completionThunk = null; // ensure it's not called twice. + + if (Type(innerResult) !== 'Object') { + throw new $TypeError('iterator .return must return an object'); + } + + return completionRecord; +}; diff --git a/node_modules/es-abstract/2017/IteratorComplete.js b/node_modules/es-abstract/2017/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2017/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2017/IteratorNext.js b/node_modules/es-abstract/2017/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..d84d66edb5fc2bd565f3053f15208c37a33024d6 --- /dev/null +++ b/node_modules/es-abstract/2017/IteratorNext.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Invoke = require('./Invoke'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (Type(result) !== 'Object') { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2017/IteratorStep.js b/node_modules/es-abstract/2017/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2017/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2017/IteratorValue.js b/node_modules/es-abstract/2017/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2017/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2017/MakeDate.js b/node_modules/es-abstract/2017/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..efeb6452e78c9f30c8aefc53fede97b874ac2e63 --- /dev/null +++ b/node_modules/es-abstract/2017/MakeDate.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2017/MakeTime.js b/node_modules/es-abstract/2017/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..34cb4dcca3f84920250ddb1dce54cecba114a3ad --- /dev/null +++ b/node_modules/es-abstract/2017/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2017/MonthFromTime.js b/node_modules/es-abstract/2017/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2017/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2017/NewPromiseCapability.js b/node_modules/es-abstract/2017/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2017/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2017/NormalCompletion.js b/node_modules/es-abstract/2017/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2017/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2017/NumberToRawBytes.js b/node_modules/es-abstract/2017/NumberToRawBytes.js new file mode 100644 index 0000000000000000000000000000000000000000..c85e97196201ecdca0098ea997421a5bb1b25a9b --- /dev/null +++ b/node_modules/es-abstract/2017/NumberToRawBytes.js @@ -0,0 +1,74 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwnProperty = require('./HasOwnProperty'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); +var Type = require('./Type'); + +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); +var integerToNBytes = require('../helpers/integerToNBytes'); + +var keys = require('object-keys'); + +// https://262.ecma-international.org/8.0/#table-50 +var TypeToSizes = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +var TypeToAO = { + __proto__: null, + Int8: ToInt8, + Uint8: ToUint8, + Uint8C: ToUint8Clamp, + Int16: ToInt16, + Uint16: ToUint16, + Int32: ToInt32, + Uint32: ToUint32 +}; + +// https://262.ecma-international.org/8.0/#sec-numbertorawbytes + +module.exports = function NumberToRawBytes(type, value, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(TypeToSizes, type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type: ' + keys(TypeToSizes)); + } + if (Type(value) !== 'Number') { + throw new $TypeError('Assertion failed: `value` must be a Number'); + } + if (Type(isLittleEndian) !== 'Boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + if (type === 'Float32') { // step 1 + return valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + return valueToFloat64Bytes(value, isLittleEndian); + } // step 3 + + var n = TypeToSizes[type]; // step 3.a + + var convOp = TypeToAO[type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 +}; diff --git a/node_modules/es-abstract/2017/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2017/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ede44ed6b75eed8e851821ffee51b52994bb86a7 --- /dev/null +++ b/node_modules/es-abstract/2017/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var ObjectCreate = require('./ObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return ObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2017/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2017/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2017/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2017/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2017/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..ba17b98872933ef285da579420e75fa18b072ce9 --- /dev/null +++ b/node_modules/es-abstract/2017/OrdinaryGetPrototypeOf.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $getProto = require('../helpers/getProto'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2017/OrdinaryHasInstance.js b/node_modules/es-abstract/2017/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2017/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2017/OrdinaryHasProperty.js b/node_modules/es-abstract/2017/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2017/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2017/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2017/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b72306c187b6e9f4355b399831a46e10fa7f61 --- /dev/null +++ b/node_modules/es-abstract/2017/OrdinarySetPrototypeOf.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $setProto = require('../helpers/setProto'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (Type(V) !== 'Object' && Type(V) !== 'Null') { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2017/OrdinaryToPrimitive.js b/node_modules/es-abstract/2017/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..e1dbe1427f8d87cba5e2c711fcb73144fa55ec33 --- /dev/null +++ b/node_modules/es-abstract/2017/OrdinaryToPrimitive.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* Type(hint) !== 'String' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (Type(result) !== 'Object') { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2017/QuoteJSONString.js b/node_modules/es-abstract/2017/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..7dabf54bf2f02e4172c9c05373c1335c450bf941 --- /dev/null +++ b/node_modules/es-abstract/2017/QuoteJSONString.js @@ -0,0 +1,52 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); +var $strSlice = callBound('String.prototype.slice'); +var $strSplit = callBound('String.prototype.split'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-quotejsonstring + +var escapes = { + '\u0008': 'b', + '\u000C': 'f', + '\u000A': 'n', + '\u000D': 'r', + '\u0009': 't' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(value), function (C) { + if (C === '"' || C === '\\') { + product += '\u005C' + C; + } else if (C === '\u0008' || C === '\u000C' || C === '\u000A' || C === '\u000D' || C === '\u0009') { + var abbrev = escapes[C]; + product += '\u005C' + abbrev; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20) { + product += '\u005Cu' + $toLowerCase($strSlice('0000' + $numberToString(cCharCode, 16), -4)); + } else { + product += C; + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2017/RawBytesToNumber.js b/node_modules/es-abstract/2017/RawBytesToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..652471623dee44dc6186a4f8f1815bf5cbc2352b --- /dev/null +++ b/node_modules/es-abstract/2017/RawBytesToNumber.js @@ -0,0 +1,74 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var $charAt = callBound('String.prototype.charAt'); +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var hasOwnProperty = require('./HasOwnProperty'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var every = require('../helpers/every'); +var isByteValue = require('../helpers/isByteValue'); + +var keys = require('object-keys'); + +// https://262.ecma-international.org/8.0/#table-50 +var TypeToSizes = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +// https://262.ecma-international.org/8.0/#sec-rawbytestonumber + +module.exports = function RawBytesToNumber(type, rawBytes, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(TypeToSizes, type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type: ' + keys(TypeToSizes)); + } + if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) { + throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes'); + } + if (Type(isLittleEndian) !== 'Boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + var elementSize = TypeToSizes[type]; // step 1 + + if (rawBytes.length !== elementSize) { + // this assertion is not in the spec, but it'd be an editorial error if it were ever violated + throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type); + } + + // eslint-disable-next-line no-param-reassign + rawBytes = $slice(rawBytes, 0, elementSize); + if (!isLittleEndian) { + $reverse(rawBytes); // step 2 + } + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(rawBytes); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(rawBytes); + } + + return bytesAsInteger(rawBytes, elementSize, $charAt(type, 0) === 'U', false); +}; diff --git a/node_modules/es-abstract/2017/RegExpExec.js b/node_modules/es-abstract/2017/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2017/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2017/RequireObjectCoercible.js b/node_modules/es-abstract/2017/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9008359db8f9ac7107563f46c1aebc2258b8cb2b --- /dev/null +++ b/node_modules/es-abstract/2017/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../5/CheckObjectCoercible'); diff --git a/node_modules/es-abstract/2017/SameValue.js b/node_modules/es-abstract/2017/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2017/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2017/SameValueZero.js b/node_modules/es-abstract/2017/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2017/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2017/Set.js b/node_modules/es-abstract/2017/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..969703136399bce4cdbafbd357690f4f53301c0d --- /dev/null +++ b/node_modules/es-abstract/2017/Set.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (Type(Throw) !== 'Boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2017/SetIntegrityLevel.js b/node_modules/es-abstract/2017/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2017/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2017/SetValueInBuffer.js b/node_modules/es-abstract/2017/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..d5c2fa479b95179deeba9ccec4d2e1513cb21585 --- /dev/null +++ b/node_modules/es-abstract/2017/SetValueInBuffer.js @@ -0,0 +1,120 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var isArrayBuffer = require('is-array-buffer'); +var hasOwn = require('hasown'); + +var table49 = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +var TypeToAO = { + __proto__: null, + Int8: ToInt8, + Uint8: ToUint8, + Uint8C: ToUint8Clamp, + Int16: ToInt16, + Uint16: ToUint16, + Int32: ToInt32, + Uint32: ToUint32 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); +var integerToNBytes = require('../helpers/integerToNBytes'); +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); + +// https://262.ecma-international.org/6.0/#sec-setvalueinbuffer + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || !hasOwn(table49, type)) { + throw new $TypeError('Assertion failed: `type` must be a Typed Array Element Type'); + } + + if (typeof value !== 'number') { + throw new $TypeError('Assertion failed: `value` must be a number'); + } + + if (arguments.length > 4 && typeof arguments[4] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Assert: Type(value) is Number. + + // 5. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + // 6. Assert: block is not undefined. + + var elementSize = table49[type]; // step 7 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the GetValueFromBuffer abstract operation. + var isLittleEndian = arguments.length > 4 ? arguments[4] : defaultEndianness === 'little'; // step 8 + + var rawBytes; + if (type === 'Float32') { // step 1 + rawBytes = valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + rawBytes = valueToFloat64Bytes(value, isLittleEndian); + } else { + var n = table49[type]; // step 3.a + + var convOp = TypeToAO[type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + rawBytes = integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 + } + + // 12. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + + // 13. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2017/SpeciesConstructor.js b/node_modules/es-abstract/2017/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2017/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2017/SplitMatch.js b/node_modules/es-abstract/2017/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..d57fb691e5e91dfb4d30a974e9ebbff47a22e24e --- /dev/null +++ b/node_modules/es-abstract/2017/SplitMatch.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/6.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (Type(R) !== 'String') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return false; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return false; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2017/StringCreate.js b/node_modules/es-abstract/2017/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2017/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2017/SymbolDescriptiveString.js b/node_modules/es-abstract/2017/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2017/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2017/TimeFromYear.js b/node_modules/es-abstract/2017/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2017/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2017/TimeWithinDay.js b/node_modules/es-abstract/2017/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2017/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2017/ToDateString.js b/node_modules/es-abstract/2017/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2017/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2017/ToIndex.js b/node_modules/es-abstract/2017/ToIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..7c9d746d5395402d3e5617ef790b468155b503e4 --- /dev/null +++ b/node_modules/es-abstract/2017/ToIndex.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); + +var ToInteger = require('./ToInteger'); +var ToLength = require('./ToLength'); +var SameValueZero = require('./SameValueZero'); + +// https://262.ecma-international.org/8.0/#sec-toindex + +module.exports = function ToIndex(value) { + if (typeof value === 'undefined') { + return 0; + } + var integerIndex = ToInteger(value); + if (integerIndex < 0) { + throw new $RangeError('index must be >= 0'); + } + var index = ToLength(integerIndex); + if (!SameValueZero(integerIndex, index)) { + throw new $RangeError('index must be >= 0 and < 2 ** 53 - 1'); + } + return index; +}; diff --git a/node_modules/es-abstract/2017/ToInt16.js b/node_modules/es-abstract/2017/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2017/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2017/ToInt32.js b/node_modules/es-abstract/2017/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2017/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2017/ToInt8.js b/node_modules/es-abstract/2017/ToInt8.js new file mode 100644 index 0000000000000000000000000000000000000000..e223b6c1d352a3432da2d272d0f7e66bbfa818b4 --- /dev/null +++ b/node_modules/es-abstract/2017/ToInt8.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint8 = require('./ToUint8'); + +// https://262.ecma-international.org/6.0/#sec-toint8 + +module.exports = function ToInt8(argument) { + var int8bit = ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; +}; diff --git a/node_modules/es-abstract/2017/ToInteger.js b/node_modules/es-abstract/2017/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..f6625796ebd22a688826a1bd5d36e20dfe6ebcc7 --- /dev/null +++ b/node_modules/es-abstract/2017/ToInteger.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5ToInteger = require('../5/ToInteger'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/6.0/#sec-tointeger + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + return ES5ToInteger(number); +}; diff --git a/node_modules/es-abstract/2017/ToLength.js b/node_modules/es-abstract/2017/ToLength.js new file mode 100644 index 0000000000000000000000000000000000000000..1bef9bed7b2f0cbbd9477769cb4bcdeb3b8814bc --- /dev/null +++ b/node_modules/es-abstract/2017/ToLength.js @@ -0,0 +1,12 @@ +'use strict'; + +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var ToInteger = require('./ToInteger'); + +module.exports = function ToLength(argument) { + var len = ToInteger(argument); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; } + return len; +}; diff --git a/node_modules/es-abstract/2017/ToPropertyDescriptor.js b/node_modules/es-abstract/2017/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..0af998a5d7f922a5494751846932c0987aa95ff9 --- /dev/null +++ b/node_modules/es-abstract/2017/ToPropertyDescriptor.js @@ -0,0 +1,52 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); +var ToBoolean = require('./ToBoolean'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (Type(Obj) !== 'Object') { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2017/ToString.js b/node_modules/es-abstract/2017/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2017/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2017/ToUint16.js b/node_modules/es-abstract/2017/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..633ca8464dd23b8c48cb91bf70f026c5e2fa91fd --- /dev/null +++ b/node_modules/es-abstract/2017/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2017/ToUint32.js b/node_modules/es-abstract/2017/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2017/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2017/ToUint8Clamp.js b/node_modules/es-abstract/2017/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2017/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2017/Type.js b/node_modules/es-abstract/2017/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..da5cb762508f187a91583bfc2d509036d492aa66 --- /dev/null +++ b/node_modules/es-abstract/2017/Type.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/6.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2017/TypedArrayCreate.js b/node_modules/es-abstract/2017/TypedArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..ef9fbe2599495aabd3fdb47a40dffd7d178ad2cb --- /dev/null +++ b/node_modules/es-abstract/2017/TypedArrayCreate.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var availableTypedArrays = require('available-typed-arrays')(); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/7.0/#typedarray-create + +module.exports = function TypedArrayCreate(constructor, argumentList) { + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); + } + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + // var newTypedArray = Construct(constructor, argumentList); // step 1 + var newTypedArray; + if (argumentList.length === 0) { + newTypedArray = new constructor(); + } else if (argumentList.length === 1) { + newTypedArray = new constructor(argumentList[0]); + } else if (argumentList.length === 2) { + newTypedArray = new constructor(argumentList[0], argumentList[1]); + } else { + newTypedArray = new constructor(argumentList[0], argumentList[1], argumentList[2]); + } + + ValidateTypedArray(newTypedArray); // step 2 + + if (argumentList.length === 1 && Type(argumentList[0]) === 'Number') { // step 3 + if (typedArrayLength(newTypedArray) < argumentList[0]) { + throw new $TypeError('Assertion failed: `argumentList[0]` must be <= `newTypedArray.length`'); // step 3.a + } + } + + return newTypedArray; // step 4 +}; diff --git a/node_modules/es-abstract/2017/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2017/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2bfdff5eb705c2c866ad0623064a35be67b92b73 --- /dev/null +++ b/node_modules/es-abstract/2017/TypedArraySpeciesCreate.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2017/UTF16Decode.js b/node_modules/es-abstract/2017/UTF16Decode.js new file mode 100644 index 0000000000000000000000000000000000000000..86927b478ccdb26659380330009b5d3eaae0e8a3 --- /dev/null +++ b/node_modules/es-abstract/2017/UTF16Decode.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +// https://262.ecma-international.org/7.0/#sec-utf16decode + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16Decode(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2017/UTF16Encoding.js b/node_modules/es-abstract/2017/UTF16Encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..f381595fd70d6396dd841c7e71552247f2d80f0e --- /dev/null +++ b/node_modules/es-abstract/2017/UTF16Encoding.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/7.0/#sec-utf16encoding + +module.exports = function UTF16Encoding(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = floor((cp - 65536) / 1024) + 0xD800; + var cu2 = modulo(cp - 65536, 1024) + 0xDC00; + return $fromCharCode(cu1) + $fromCharCode(cu2); +}; diff --git a/node_modules/es-abstract/2017/ValidateTypedArray.js b/node_modules/es-abstract/2017/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2017/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2017/WeekDay.js b/node_modules/es-abstract/2017/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2017/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2017/YearFromTime.js b/node_modules/es-abstract/2017/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..be06ecbc36310e9f8ff1e6939dab408141051c0a --- /dev/null +++ b/node_modules/es-abstract/2017/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bind/callBound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2017/abs.js b/node_modules/es-abstract/2017/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2017/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2017/floor.js b/node_modules/es-abstract/2017/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..8439df0649365bf9309bbea76dcfae10e64a599c --- /dev/null +++ b/node_modules/es-abstract/2017/floor.js @@ -0,0 +1,11 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function floor(x) { + // return x - modulo(x, 1); + return $floor(x); +}; diff --git a/node_modules/es-abstract/2017/max.js b/node_modules/es-abstract/2017/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2017/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2017/msFromTime.js b/node_modules/es-abstract/2017/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2017/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2017/thisBooleanValue.js b/node_modules/es-abstract/2017/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2017/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2017/thisNumberValue.js b/node_modules/es-abstract/2017/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2017/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2018/AbstractEqualityComparison.js b/node_modules/es-abstract/2018/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..b56a5066224470eec1a41d7d3b2d6591f7a5f1b8 --- /dev/null +++ b/node_modules/es-abstract/2018/AbstractEqualityComparison.js @@ -0,0 +1,37 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return x === y; // ES6+ specified this shortcut anyways. + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (xType === 'Boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (yType === 'Boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'Symbol') && yType === 'Object') { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + return false; +}; diff --git a/node_modules/es-abstract/2018/ArraySetLength.js b/node_modules/es-abstract/2018/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2018/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2018/Call.js b/node_modules/es-abstract/2018/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..be76246db04f06d84ed52f6f052d6bc98b131b51 --- /dev/null +++ b/node_modules/es-abstract/2018/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2018/CompletePropertyDescriptor.js b/node_modules/es-abstract/2018/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..1530241dc526d85b8e2e27d226aa2015befc762c --- /dev/null +++ b/node_modules/es-abstract/2018/CompletePropertyDescriptor.js @@ -0,0 +1,39 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var assertRecord = require('../helpers/assertRecord'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + /* eslint no-param-reassign: 0 */ + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2018/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2018/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..8f41b8d406382452e441089809bd6747ce4e20a5 --- /dev/null +++ b/node_modules/es-abstract/2018/CreateAsyncFromSyncIterator.js @@ -0,0 +1,155 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Promise = GetIntrinsic('%Promise%', true); + +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); +var IteratorValue = require('./IteratorValue'); +var ObjectCreate = require('./ObjectCreate'); +var PromiseResolve = require('./PromiseResolve'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); + +var callBound = require('call-bind/callBound'); + +var $then = callBound('Promise.prototype.then', true); + +var assertRecord = require('../helpers/assertRecord'); + +var AsyncFromSyncIteratorContinuation = function AsyncFromSyncIteratorContinuation(result) { + if (Type(result) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $TypeError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord['[[Iterator]]'], value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord['[[Iterator]]']);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/9.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + assertRecord(Type, 'Iterator Record', 'syncIteratorRecord', syncIteratorRecord); + + // var asyncIterator = ObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = ObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2018/CreateDataProperty.js b/node_modules/es-abstract/2018/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2018/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2018/CreateHTML.js b/node_modules/es-abstract/2018/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2018/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2018/CreateListFromArrayLike.js b/node_modules/es-abstract/2018/CreateListFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..4c34219206e1fc0a5990f7bdbee2592b77a68160 --- /dev/null +++ b/node_modules/es-abstract/2018/CreateListFromArrayLike.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf'); +var $push = callBound('Array.prototype.push'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'Object']; + +// https://262.ecma-international.org/6.0/#sec-createlistfromarraylike +module.exports = function CreateListFromArrayLike(obj) { + var elementTypes = arguments.length > 1 + ? arguments[1] + : defaultElementTypes; + + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + if (!IsArray(elementTypes)) { + throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array'); + } + var len = ToLength(Get(obj, 'length')); + var list = []; + var index = 0; + while (index < len) { + var indexName = ToString(index); + var next = Get(obj, indexName); + var nextType = Type(next); + if ($indexOf(elementTypes, nextType) < 0) { + throw new $TypeError('item type ' + nextType + ' is not a valid elementType'); + } + $push(list, next); + index += 1; + } + return list; +}; diff --git a/node_modules/es-abstract/2018/CreateMethodProperty.js b/node_modules/es-abstract/2018/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2018/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2018/DateFromTime.js b/node_modules/es-abstract/2018/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2018/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2018/DateString.js b/node_modules/es-abstract/2018/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..939c14c0c87ef6b1d8ebc09e936e6c4e86e793c5 --- /dev/null +++ b/node_modules/es-abstract/2018/DateString.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var Type = require('./Type'); +var WeekDay = require('./WeekDay'); +var MonthFromTime = require('./MonthFromTime'); +var YearFromTime = require('./YearFromTime'); +var DateFromTime = require('./DateFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2018/DayFromYear.js b/node_modules/es-abstract/2018/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2018/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2018/DayWithinYear.js b/node_modules/es-abstract/2018/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2018/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2018/DefinePropertyOrThrow.js b/node_modules/es-abstract/2018/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2018/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2018/DeletePropertyOrThrow.js b/node_modules/es-abstract/2018/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2018/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2018/DetachArrayBuffer.js b/node_modules/es-abstract/2018/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..03284729b3d4e77587ae9204577ebf42e5b1b884 --- /dev/null +++ b/node_modules/es-abstract/2018/DetachArrayBuffer.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2018/FromPropertyDescriptor.js b/node_modules/es-abstract/2018/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..c70f0c60e1ff8b16858f71af25b644f8d9a3d589 --- /dev/null +++ b/node_modules/es-abstract/2018/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var assertRecord = require('../helpers/assertRecord'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined') { + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2018/GetGlobalObject.js b/node_modules/es-abstract/2018/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2018/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2018/GetIterator.js b/node_modules/es-abstract/2018/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..145557da422e4910c3371cff4d498ed244213d1e --- /dev/null +++ b/node_modules/es-abstract/2018/GetIterator.js @@ -0,0 +1,34 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getiterator + +module.exports = function GetIterator(obj, method) { + var actualMethod = method; + if (arguments.length < 2) { + actualMethod = getIteratorMethod( + { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod, + IsArray: IsArray + }, + obj + ); + } + var iterator = Call(actualMethod, obj); + if (Type(iterator) !== 'Object') { + throw new $TypeError('iterator must return an object'); + } + + return iterator; +}; diff --git a/node_modules/es-abstract/2018/GetOwnPropertyKeys.js b/node_modules/es-abstract/2018/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..043fd733bd8a4e8724c38dc30444a0fd8a726f5e --- /dev/null +++ b/node_modules/es-abstract/2018/GetOwnPropertyKeys.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +var esType = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (esType(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $gOPS ? $gOPS(O) : []; + } + if (Type === 'String') { + if (!$gOPN) { + return keys(O); + } + return $gOPN(O); + } + throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`'); +}; diff --git a/node_modules/es-abstract/2018/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2018/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2018/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2018/GetV.js b/node_modules/es-abstract/2018/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2018/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2018/GetValueFromBuffer.js b/node_modules/es-abstract/2018/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..0a0d14dba7b57bd67b9b6b9408315f91dcd1ef87 --- /dev/null +++ b/node_modules/es-abstract/2018/GetValueFromBuffer.js @@ -0,0 +1,108 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $slice = callBound('Array.prototype.slice'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumber = require('./RawBytesToNumber'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table50 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $Float32: 4, + $Float64: 8 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/8.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string') { + throw new $TypeError('Assertion failed: `type` must be a string'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (typeof order !== 'string') { + throw new $TypeError('Assertion failed: `order` must be a string'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = table50['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('TODO: support SharedArrayBuffers'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumber(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2018/HasOwnProperty.js b/node_modules/es-abstract/2018/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2018/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2018/HourFromTime.js b/node_modules/es-abstract/2018/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2018/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2018/InstanceofOperator.js b/node_modules/es-abstract/2018/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..4a34d0c20cdb0d93d5de2316c73ba8faff2aabeb --- /dev/null +++ b/node_modules/es-abstract/2018/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2018/Invoke.js b/node_modules/es-abstract/2018/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..084e5e28253d5ac2d98d1e0b735512b7e9db6e17 --- /dev/null +++ b/node_modules/es-abstract/2018/Invoke.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var IsPropertyKey = require('./IsPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2018/IsAccessorDescriptor.js b/node_modules/es-abstract/2018/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2018/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2018/IsCallable.js b/node_modules/es-abstract/2018/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2018/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2018/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2018/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2018/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2018/IsConcatSpreadable.js b/node_modules/es-abstract/2018/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2018/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2018/IsConstructor.js b/node_modules/es-abstract/2018/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2018/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2018/IsDataDescriptor.js b/node_modules/es-abstract/2018/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2018/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2018/IsInteger.js b/node_modules/es-abstract/2018/IsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..e3d25f38e30093f0a0444e98ef3ddc4e0b35d2ed --- /dev/null +++ b/node_modules/es-abstract/2018/IsInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-isinteger + +module.exports = function IsInteger(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2018/IsPromise.js b/node_modules/es-abstract/2018/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..411539b0818c20d3f4d41852082b3f1a263dbcd8 --- /dev/null +++ b/node_modules/es-abstract/2018/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (Type(x) !== 'Object') { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2018/IsPropertyKey.js b/node_modules/es-abstract/2018/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..aaeb6f9b6f83b5a39f1f53cec0edbf19cbc61170 --- /dev/null +++ b/node_modules/es-abstract/2018/IsPropertyKey.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; +}; diff --git a/node_modules/es-abstract/2018/IsRegExp.js b/node_modules/es-abstract/2018/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2018/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2018/IsSharedArrayBuffer.js b/node_modules/es-abstract/2018/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8e96e33f3c2dca5c15127f2ae83fc45861d548b9 --- /dev/null +++ b/node_modules/es-abstract/2018/IsSharedArrayBuffer.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2018/IsWordChar.js b/node_modules/es-abstract/2018/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..5d61804925b6cb8f2570823c90ce44c1c96ece02 --- /dev/null +++ b/node_modules/es-abstract/2018/IsWordChar.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); +var Type = require('./Type'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!IsInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2018/IterableToList.js b/node_modules/es-abstract/2018/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..6a1a6be39f021a3129ea8d815e3f035a1361c644 --- /dev/null +++ b/node_modules/es-abstract/2018/IterableToList.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); +var $arrayPush = callBound('Array.prototype.push'); + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/8.0/#sec-iterabletolist + +module.exports = function IterableToList(items, method) { + var iterator = GetIterator(items, method); + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + $arrayPush(values, nextValue); + } + } + return values; +}; diff --git a/node_modules/es-abstract/2018/IteratorComplete.js b/node_modules/es-abstract/2018/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2018/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2018/IteratorNext.js b/node_modules/es-abstract/2018/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..d84d66edb5fc2bd565f3053f15208c37a33024d6 --- /dev/null +++ b/node_modules/es-abstract/2018/IteratorNext.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Invoke = require('./Invoke'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (Type(result) !== 'Object') { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2018/IteratorStep.js b/node_modules/es-abstract/2018/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2018/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2018/IteratorValue.js b/node_modules/es-abstract/2018/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2018/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2018/MakeDate.js b/node_modules/es-abstract/2018/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..efeb6452e78c9f30c8aefc53fede97b874ac2e63 --- /dev/null +++ b/node_modules/es-abstract/2018/MakeDate.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2018/MakeTime.js b/node_modules/es-abstract/2018/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..34cb4dcca3f84920250ddb1dce54cecba114a3ad --- /dev/null +++ b/node_modules/es-abstract/2018/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2018/MonthFromTime.js b/node_modules/es-abstract/2018/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2018/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2018/NewPromiseCapability.js b/node_modules/es-abstract/2018/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2018/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2018/NormalCompletion.js b/node_modules/es-abstract/2018/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2018/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2018/NumberToRawBytes.js b/node_modules/es-abstract/2018/NumberToRawBytes.js new file mode 100644 index 0000000000000000000000000000000000000000..c85e97196201ecdca0098ea997421a5bb1b25a9b --- /dev/null +++ b/node_modules/es-abstract/2018/NumberToRawBytes.js @@ -0,0 +1,74 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwnProperty = require('./HasOwnProperty'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); +var Type = require('./Type'); + +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); +var integerToNBytes = require('../helpers/integerToNBytes'); + +var keys = require('object-keys'); + +// https://262.ecma-international.org/8.0/#table-50 +var TypeToSizes = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +var TypeToAO = { + __proto__: null, + Int8: ToInt8, + Uint8: ToUint8, + Uint8C: ToUint8Clamp, + Int16: ToInt16, + Uint16: ToUint16, + Int32: ToInt32, + Uint32: ToUint32 +}; + +// https://262.ecma-international.org/8.0/#sec-numbertorawbytes + +module.exports = function NumberToRawBytes(type, value, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(TypeToSizes, type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type: ' + keys(TypeToSizes)); + } + if (Type(value) !== 'Number') { + throw new $TypeError('Assertion failed: `value` must be a Number'); + } + if (Type(isLittleEndian) !== 'Boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + if (type === 'Float32') { // step 1 + return valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + return valueToFloat64Bytes(value, isLittleEndian); + } // step 3 + + var n = TypeToSizes[type]; // step 3.a + + var convOp = TypeToAO[type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 +}; diff --git a/node_modules/es-abstract/2018/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2018/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ede44ed6b75eed8e851821ffee51b52994bb86a7 --- /dev/null +++ b/node_modules/es-abstract/2018/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var ObjectCreate = require('./ObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return ObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2018/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2018/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2018/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2018/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2018/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..ba17b98872933ef285da579420e75fa18b072ce9 --- /dev/null +++ b/node_modules/es-abstract/2018/OrdinaryGetPrototypeOf.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $getProto = require('../helpers/getProto'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2018/OrdinaryHasInstance.js b/node_modules/es-abstract/2018/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2018/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2018/OrdinaryHasProperty.js b/node_modules/es-abstract/2018/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2018/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2018/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2018/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b72306c187b6e9f4355b399831a46e10fa7f61 --- /dev/null +++ b/node_modules/es-abstract/2018/OrdinarySetPrototypeOf.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $setProto = require('../helpers/setProto'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (Type(V) !== 'Object' && Type(V) !== 'Null') { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2018/OrdinaryToPrimitive.js b/node_modules/es-abstract/2018/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..e1dbe1427f8d87cba5e2c711fcb73144fa55ec33 --- /dev/null +++ b/node_modules/es-abstract/2018/OrdinaryToPrimitive.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* Type(hint) !== 'String' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (Type(result) !== 'Object') { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2018/QuoteJSONString.js b/node_modules/es-abstract/2018/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..2a570dc362f94035d8b3a5d3f8456e09d2ee6639 --- /dev/null +++ b/node_modules/es-abstract/2018/QuoteJSONString.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $strSplit = callBound('String.prototype.split'); + +var Type = require('./Type'); +var UnicodeEscape = require('./UnicodeEscape'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/9.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(value), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else if ($charCodeAt(C, 0) < 0x20) { + product += UnicodeEscape(C); + } else { + product += C; + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2018/RawBytesToNumber.js b/node_modules/es-abstract/2018/RawBytesToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..652471623dee44dc6186a4f8f1815bf5cbc2352b --- /dev/null +++ b/node_modules/es-abstract/2018/RawBytesToNumber.js @@ -0,0 +1,74 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var $charAt = callBound('String.prototype.charAt'); +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var hasOwnProperty = require('./HasOwnProperty'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var every = require('../helpers/every'); +var isByteValue = require('../helpers/isByteValue'); + +var keys = require('object-keys'); + +// https://262.ecma-international.org/8.0/#table-50 +var TypeToSizes = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +// https://262.ecma-international.org/8.0/#sec-rawbytestonumber + +module.exports = function RawBytesToNumber(type, rawBytes, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(TypeToSizes, type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type: ' + keys(TypeToSizes)); + } + if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) { + throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes'); + } + if (Type(isLittleEndian) !== 'Boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + var elementSize = TypeToSizes[type]; // step 1 + + if (rawBytes.length !== elementSize) { + // this assertion is not in the spec, but it'd be an editorial error if it were ever violated + throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type); + } + + // eslint-disable-next-line no-param-reassign + rawBytes = $slice(rawBytes, 0, elementSize); + if (!isLittleEndian) { + $reverse(rawBytes); // step 2 + } + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(rawBytes); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(rawBytes); + } + + return bytesAsInteger(rawBytes, elementSize, $charAt(type, 0) === 'U', false); +}; diff --git a/node_modules/es-abstract/2018/RegExpExec.js b/node_modules/es-abstract/2018/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2018/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2018/RequireObjectCoercible.js b/node_modules/es-abstract/2018/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9008359db8f9ac7107563f46c1aebc2258b8cb2b --- /dev/null +++ b/node_modules/es-abstract/2018/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../5/CheckObjectCoercible'); diff --git a/node_modules/es-abstract/2018/SameValue.js b/node_modules/es-abstract/2018/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2018/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2018/SameValueZero.js b/node_modules/es-abstract/2018/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2018/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2018/Set.js b/node_modules/es-abstract/2018/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..969703136399bce4cdbafbd357690f4f53301c0d --- /dev/null +++ b/node_modules/es-abstract/2018/Set.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (Type(Throw) !== 'Boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2018/SetFunctionLength.js b/node_modules/es-abstract/2018/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..14228bf184d47240007244933a9b015770a5ce7d --- /dev/null +++ b/node_modules/es-abstract/2018/SetFunctionLength.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/9.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (Type(length) !== 'Number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (length < 0 || !isInteger(length)) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2018/SetIntegrityLevel.js b/node_modules/es-abstract/2018/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2018/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2018/SetValueInBuffer.js b/node_modules/es-abstract/2018/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..d5c2fa479b95179deeba9ccec4d2e1513cb21585 --- /dev/null +++ b/node_modules/es-abstract/2018/SetValueInBuffer.js @@ -0,0 +1,120 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var isArrayBuffer = require('is-array-buffer'); +var hasOwn = require('hasown'); + +var table49 = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +var TypeToAO = { + __proto__: null, + Int8: ToInt8, + Uint8: ToUint8, + Uint8C: ToUint8Clamp, + Int16: ToInt16, + Uint16: ToUint16, + Int32: ToInt32, + Uint32: ToUint32 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); +var integerToNBytes = require('../helpers/integerToNBytes'); +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); + +// https://262.ecma-international.org/6.0/#sec-setvalueinbuffer + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || !hasOwn(table49, type)) { + throw new $TypeError('Assertion failed: `type` must be a Typed Array Element Type'); + } + + if (typeof value !== 'number') { + throw new $TypeError('Assertion failed: `value` must be a number'); + } + + if (arguments.length > 4 && typeof arguments[4] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Assert: Type(value) is Number. + + // 5. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + // 6. Assert: block is not undefined. + + var elementSize = table49[type]; // step 7 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the GetValueFromBuffer abstract operation. + var isLittleEndian = arguments.length > 4 ? arguments[4] : defaultEndianness === 'little'; // step 8 + + var rawBytes; + if (type === 'Float32') { // step 1 + rawBytes = valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + rawBytes = valueToFloat64Bytes(value, isLittleEndian); + } else { + var n = table49[type]; // step 3.a + + var convOp = TypeToAO[type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + rawBytes = integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 + } + + // 12. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + + // 13. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2018/SpeciesConstructor.js b/node_modules/es-abstract/2018/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2018/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2018/SplitMatch.js b/node_modules/es-abstract/2018/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..d57fb691e5e91dfb4d30a974e9ebbff47a22e24e --- /dev/null +++ b/node_modules/es-abstract/2018/SplitMatch.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/6.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (Type(R) !== 'String') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return false; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return false; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2018/StringCreate.js b/node_modules/es-abstract/2018/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2018/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2018/SymbolDescriptiveString.js b/node_modules/es-abstract/2018/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2018/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2018/ThrowCompletion.js b/node_modules/es-abstract/2018/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2018/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2018/TimeFromYear.js b/node_modules/es-abstract/2018/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2018/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2018/TimeString.js b/node_modules/es-abstract/2018/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..051c4728e2e495a323f9ed64acd3be8d25603b00 --- /dev/null +++ b/node_modules/es-abstract/2018/TimeString.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); +var Type = require('./Type'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2018/TimeWithinDay.js b/node_modules/es-abstract/2018/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2018/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2018/ToDateString.js b/node_modules/es-abstract/2018/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2018/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2018/ToInt16.js b/node_modules/es-abstract/2018/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2018/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2018/ToInt32.js b/node_modules/es-abstract/2018/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2018/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2018/ToInt8.js b/node_modules/es-abstract/2018/ToInt8.js new file mode 100644 index 0000000000000000000000000000000000000000..e223b6c1d352a3432da2d272d0f7e66bbfa818b4 --- /dev/null +++ b/node_modules/es-abstract/2018/ToInt8.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint8 = require('./ToUint8'); + +// https://262.ecma-international.org/6.0/#sec-toint8 + +module.exports = function ToInt8(argument) { + var int8bit = ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; +}; diff --git a/node_modules/es-abstract/2018/ToInteger.js b/node_modules/es-abstract/2018/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..f6625796ebd22a688826a1bd5d36e20dfe6ebcc7 --- /dev/null +++ b/node_modules/es-abstract/2018/ToInteger.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5ToInteger = require('../5/ToInteger'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/6.0/#sec-tointeger + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + return ES5ToInteger(number); +}; diff --git a/node_modules/es-abstract/2018/ToPropertyDescriptor.js b/node_modules/es-abstract/2018/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..0af998a5d7f922a5494751846932c0987aa95ff9 --- /dev/null +++ b/node_modules/es-abstract/2018/ToPropertyDescriptor.js @@ -0,0 +1,52 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); +var ToBoolean = require('./ToBoolean'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (Type(Obj) !== 'Object') { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2018/ToString.js b/node_modules/es-abstract/2018/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2018/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2018/ToUint16.js b/node_modules/es-abstract/2018/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..633ca8464dd23b8c48cb91bf70f026c5e2fa91fd --- /dev/null +++ b/node_modules/es-abstract/2018/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2018/ToUint32.js b/node_modules/es-abstract/2018/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2018/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2018/ToUint8Clamp.js b/node_modules/es-abstract/2018/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2018/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2018/Type.js b/node_modules/es-abstract/2018/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..da5cb762508f187a91583bfc2d509036d492aa66 --- /dev/null +++ b/node_modules/es-abstract/2018/Type.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/6.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2018/TypedArrayCreate.js b/node_modules/es-abstract/2018/TypedArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..ef9fbe2599495aabd3fdb47a40dffd7d178ad2cb --- /dev/null +++ b/node_modules/es-abstract/2018/TypedArrayCreate.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var availableTypedArrays = require('available-typed-arrays')(); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/7.0/#typedarray-create + +module.exports = function TypedArrayCreate(constructor, argumentList) { + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); + } + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + // var newTypedArray = Construct(constructor, argumentList); // step 1 + var newTypedArray; + if (argumentList.length === 0) { + newTypedArray = new constructor(); + } else if (argumentList.length === 1) { + newTypedArray = new constructor(argumentList[0]); + } else if (argumentList.length === 2) { + newTypedArray = new constructor(argumentList[0], argumentList[1]); + } else { + newTypedArray = new constructor(argumentList[0], argumentList[1], argumentList[2]); + } + + ValidateTypedArray(newTypedArray); // step 2 + + if (argumentList.length === 1 && Type(argumentList[0]) === 'Number') { // step 3 + if (typedArrayLength(newTypedArray) < argumentList[0]) { + throw new $TypeError('Assertion failed: `argumentList[0]` must be <= `newTypedArray.length`'); // step 3.a + } + } + + return newTypedArray; // step 4 +}; diff --git a/node_modules/es-abstract/2018/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2018/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2bfdff5eb705c2c866ad0623064a35be67b92b73 --- /dev/null +++ b/node_modules/es-abstract/2018/TypedArraySpeciesCreate.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2018/UTF16Decode.js b/node_modules/es-abstract/2018/UTF16Decode.js new file mode 100644 index 0000000000000000000000000000000000000000..86927b478ccdb26659380330009b5d3eaae0e8a3 --- /dev/null +++ b/node_modules/es-abstract/2018/UTF16Decode.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +// https://262.ecma-international.org/7.0/#sec-utf16decode + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16Decode(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2018/UTF16Encoding.js b/node_modules/es-abstract/2018/UTF16Encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..f381595fd70d6396dd841c7e71552247f2d80f0e --- /dev/null +++ b/node_modules/es-abstract/2018/UTF16Encoding.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/7.0/#sec-utf16encoding + +module.exports = function UTF16Encoding(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = floor((cp - 65536) / 1024) + 0xD800; + var cu2 = modulo(cp - 65536, 1024) + 0xDC00; + return $fromCharCode(cu1) + $fromCharCode(cu2); +}; diff --git a/node_modules/es-abstract/2018/UnicodeEscape.js b/node_modules/es-abstract/2018/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..db7163f77ee22a384534802b61c8f54879507124 --- /dev/null +++ b/node_modules/es-abstract/2018/UnicodeEscape.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/9.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + $strSlice('0000' + $toLowerCase($numberToString(n, 16)), -4); +}; diff --git a/node_modules/es-abstract/2018/ValidateTypedArray.js b/node_modules/es-abstract/2018/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2018/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2018/WeekDay.js b/node_modules/es-abstract/2018/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2018/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2018/YearFromTime.js b/node_modules/es-abstract/2018/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..be06ecbc36310e9f8ff1e6939dab408141051c0a --- /dev/null +++ b/node_modules/es-abstract/2018/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bind/callBound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2018/abs.js b/node_modules/es-abstract/2018/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2018/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2018/floor.js b/node_modules/es-abstract/2018/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..8439df0649365bf9309bbea76dcfae10e64a599c --- /dev/null +++ b/node_modules/es-abstract/2018/floor.js @@ -0,0 +1,11 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function floor(x) { + // return x - modulo(x, 1); + return $floor(x); +}; diff --git a/node_modules/es-abstract/2018/max.js b/node_modules/es-abstract/2018/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2018/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2018/msFromTime.js b/node_modules/es-abstract/2018/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2018/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2018/thisBooleanValue.js b/node_modules/es-abstract/2018/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2018/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2018/thisNumberValue.js b/node_modules/es-abstract/2018/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2018/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2019/AbstractEqualityComparison.js b/node_modules/es-abstract/2019/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..b56a5066224470eec1a41d7d3b2d6591f7a5f1b8 --- /dev/null +++ b/node_modules/es-abstract/2019/AbstractEqualityComparison.js @@ -0,0 +1,37 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return x === y; // ES6+ specified this shortcut anyways. + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (xType === 'Boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (yType === 'Boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'Symbol') && yType === 'Object') { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + return false; +}; diff --git a/node_modules/es-abstract/2019/AddEntriesFromIterable.js b/node_modules/es-abstract/2019/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..5bea627fb5160cdb554ce44056112c90b47722f9 --- /dev/null +++ b/node_modules/es-abstract/2019/AddEntriesFromIterable.js @@ -0,0 +1,47 @@ +'use strict'; + +var inspect = require('object-inspect'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); +var Type = require('./Type'); + +// https://262.ecma-international.org/10.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable); + while (true) { // eslint-disable-line no-constant-condition + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (Type(nextItem) !== 'Object') { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2019/ArraySetLength.js b/node_modules/es-abstract/2019/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2019/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2019/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2019/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..5618539dd6fb0d80d53105fcae16dfc946cf187b --- /dev/null +++ b/node_modules/es-abstract/2019/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bind/callBound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); +var Type = require('./Type'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (Type(result) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2019/Call.js b/node_modules/es-abstract/2019/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..be76246db04f06d84ed52f6f052d6bc98b131b51 --- /dev/null +++ b/node_modules/es-abstract/2019/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2019/CompletePropertyDescriptor.js b/node_modules/es-abstract/2019/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..1530241dc526d85b8e2e27d226aa2015befc762c --- /dev/null +++ b/node_modules/es-abstract/2019/CompletePropertyDescriptor.js @@ -0,0 +1,39 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var assertRecord = require('../helpers/assertRecord'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + /* eslint no-param-reassign: 0 */ + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2019/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2019/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..d6ec19bd1a482eb5cb9d3bfdc6f28b7b05eb56a4 --- /dev/null +++ b/node_modules/es-abstract/2019/CreateAsyncFromSyncIterator.js @@ -0,0 +1,121 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var ObjectCreate = require('./ObjectCreate'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); + +var assertRecord = require('../helpers/assertRecord'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord['[[Iterator]]'], value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord['[[Iterator]]']);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/10.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + assertRecord(Type, 'Iterator Record', 'syncIteratorRecord', syncIteratorRecord); + + // var asyncIterator = ObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = ObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2019/CreateDataProperty.js b/node_modules/es-abstract/2019/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2019/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2019/CreateHTML.js b/node_modules/es-abstract/2019/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2019/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2019/CreateMethodProperty.js b/node_modules/es-abstract/2019/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2019/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2019/DateFromTime.js b/node_modules/es-abstract/2019/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2019/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2019/DateString.js b/node_modules/es-abstract/2019/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..939c14c0c87ef6b1d8ebc09e936e6c4e86e793c5 --- /dev/null +++ b/node_modules/es-abstract/2019/DateString.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var Type = require('./Type'); +var WeekDay = require('./WeekDay'); +var MonthFromTime = require('./MonthFromTime'); +var YearFromTime = require('./YearFromTime'); +var DateFromTime = require('./DateFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2019/DayFromYear.js b/node_modules/es-abstract/2019/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2019/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2019/DayWithinYear.js b/node_modules/es-abstract/2019/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2019/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2019/DefinePropertyOrThrow.js b/node_modules/es-abstract/2019/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2019/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2019/DeletePropertyOrThrow.js b/node_modules/es-abstract/2019/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2019/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2019/DetachArrayBuffer.js b/node_modules/es-abstract/2019/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..03284729b3d4e77587ae9204577ebf42e5b1b884 --- /dev/null +++ b/node_modules/es-abstract/2019/DetachArrayBuffer.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2019/FlattenIntoArray.js b/node_modules/es-abstract/2019/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..f2a0837c601c08e42d52dbb21df11c0eec8da6f2 --- /dev/null +++ b/node_modules/es-abstract/2019/FlattenIntoArray.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = ToLength(Get(element, 'length')); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2019/FromPropertyDescriptor.js b/node_modules/es-abstract/2019/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..c70f0c60e1ff8b16858f71af25b644f8d9a3d589 --- /dev/null +++ b/node_modules/es-abstract/2019/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var assertRecord = require('../helpers/assertRecord'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined') { + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2019/GetGlobalObject.js b/node_modules/es-abstract/2019/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2019/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2019/GetIterator.js b/node_modules/es-abstract/2019/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..145557da422e4910c3371cff4d498ed244213d1e --- /dev/null +++ b/node_modules/es-abstract/2019/GetIterator.js @@ -0,0 +1,34 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getiterator + +module.exports = function GetIterator(obj, method) { + var actualMethod = method; + if (arguments.length < 2) { + actualMethod = getIteratorMethod( + { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod, + IsArray: IsArray + }, + obj + ); + } + var iterator = Call(actualMethod, obj); + if (Type(iterator) !== 'Object') { + throw new $TypeError('iterator must return an object'); + } + + return iterator; +}; diff --git a/node_modules/es-abstract/2019/GetOwnPropertyKeys.js b/node_modules/es-abstract/2019/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..043fd733bd8a4e8724c38dc30444a0fd8a726f5e --- /dev/null +++ b/node_modules/es-abstract/2019/GetOwnPropertyKeys.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +var esType = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (esType(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $gOPS ? $gOPS(O) : []; + } + if (Type === 'String') { + if (!$gOPN) { + return keys(O); + } + return $gOPN(O); + } + throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`'); +}; diff --git a/node_modules/es-abstract/2019/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2019/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2019/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2019/GetV.js b/node_modules/es-abstract/2019/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2019/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2019/GetValueFromBuffer.js b/node_modules/es-abstract/2019/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..e6c7385c177dafe1767d8c3608e7a125ba584501 --- /dev/null +++ b/node_modules/es-abstract/2019/GetValueFromBuffer.js @@ -0,0 +1,106 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $slice = callBound('Array.prototype.slice'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumber = require('./RawBytesToNumber'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table59 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $Float32: 4, + $Float64: 8 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/10.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string') { + throw new $TypeError('Assertion failed: `type` must be a string'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (typeof order !== 'string') { + throw new $TypeError('Assertion failed: `order` must be a string'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = table59['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumber(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2019/HasOwnProperty.js b/node_modules/es-abstract/2019/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2019/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2019/HourFromTime.js b/node_modules/es-abstract/2019/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2019/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2019/InstanceofOperator.js b/node_modules/es-abstract/2019/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..4a34d0c20cdb0d93d5de2316c73ba8faff2aabeb --- /dev/null +++ b/node_modules/es-abstract/2019/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2019/IsAccessorDescriptor.js b/node_modules/es-abstract/2019/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2019/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2019/IsCallable.js b/node_modules/es-abstract/2019/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2019/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2019/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2019/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2019/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2019/IsConcatSpreadable.js b/node_modules/es-abstract/2019/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2019/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2019/IsConstructor.js b/node_modules/es-abstract/2019/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2019/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2019/IsDataDescriptor.js b/node_modules/es-abstract/2019/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2019/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2019/IsInteger.js b/node_modules/es-abstract/2019/IsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..e3d25f38e30093f0a0444e98ef3ddc4e0b35d2ed --- /dev/null +++ b/node_modules/es-abstract/2019/IsInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-isinteger + +module.exports = function IsInteger(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2019/IsPropertyKey.js b/node_modules/es-abstract/2019/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..aaeb6f9b6f83b5a39f1f53cec0edbf19cbc61170 --- /dev/null +++ b/node_modules/es-abstract/2019/IsPropertyKey.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; +}; diff --git a/node_modules/es-abstract/2019/IsRegExp.js b/node_modules/es-abstract/2019/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2019/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2019/IsSharedArrayBuffer.js b/node_modules/es-abstract/2019/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8e96e33f3c2dca5c15127f2ae83fc45861d548b9 --- /dev/null +++ b/node_modules/es-abstract/2019/IsSharedArrayBuffer.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2019/IsWordChar.js b/node_modules/es-abstract/2019/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..5d61804925b6cb8f2570823c90ce44c1c96ece02 --- /dev/null +++ b/node_modules/es-abstract/2019/IsWordChar.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); +var Type = require('./Type'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!IsInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2019/IterableToList.js b/node_modules/es-abstract/2019/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..6a1a6be39f021a3129ea8d815e3f035a1361c644 --- /dev/null +++ b/node_modules/es-abstract/2019/IterableToList.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); +var $arrayPush = callBound('Array.prototype.push'); + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/8.0/#sec-iterabletolist + +module.exports = function IterableToList(items, method) { + var iterator = GetIterator(items, method); + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + $arrayPush(values, nextValue); + } + } + return values; +}; diff --git a/node_modules/es-abstract/2019/IteratorComplete.js b/node_modules/es-abstract/2019/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2019/IteratorNext.js b/node_modules/es-abstract/2019/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..d84d66edb5fc2bd565f3053f15208c37a33024d6 --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorNext.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Invoke = require('./Invoke'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (Type(result) !== 'Object') { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2019/IteratorStep.js b/node_modules/es-abstract/2019/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2019/IteratorValue.js b/node_modules/es-abstract/2019/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2019/MakeDate.js b/node_modules/es-abstract/2019/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..efeb6452e78c9f30c8aefc53fede97b874ac2e63 --- /dev/null +++ b/node_modules/es-abstract/2019/MakeDate.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2019/MakeTime.js b/node_modules/es-abstract/2019/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..34cb4dcca3f84920250ddb1dce54cecba114a3ad --- /dev/null +++ b/node_modules/es-abstract/2019/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2019/MonthFromTime.js b/node_modules/es-abstract/2019/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2019/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2019/NewPromiseCapability.js b/node_modules/es-abstract/2019/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2019/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2019/NormalCompletion.js b/node_modules/es-abstract/2019/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2019/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2019/NumberToRawBytes.js b/node_modules/es-abstract/2019/NumberToRawBytes.js new file mode 100644 index 0000000000000000000000000000000000000000..c85e97196201ecdca0098ea997421a5bb1b25a9b --- /dev/null +++ b/node_modules/es-abstract/2019/NumberToRawBytes.js @@ -0,0 +1,74 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwnProperty = require('./HasOwnProperty'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); +var Type = require('./Type'); + +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); +var integerToNBytes = require('../helpers/integerToNBytes'); + +var keys = require('object-keys'); + +// https://262.ecma-international.org/8.0/#table-50 +var TypeToSizes = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +var TypeToAO = { + __proto__: null, + Int8: ToInt8, + Uint8: ToUint8, + Uint8C: ToUint8Clamp, + Int16: ToInt16, + Uint16: ToUint16, + Int32: ToInt32, + Uint32: ToUint32 +}; + +// https://262.ecma-international.org/8.0/#sec-numbertorawbytes + +module.exports = function NumberToRawBytes(type, value, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(TypeToSizes, type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type: ' + keys(TypeToSizes)); + } + if (Type(value) !== 'Number') { + throw new $TypeError('Assertion failed: `value` must be a Number'); + } + if (Type(isLittleEndian) !== 'Boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + if (type === 'Float32') { // step 1 + return valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + return valueToFloat64Bytes(value, isLittleEndian); + } // step 3 + + var n = TypeToSizes[type]; // step 3.a + + var convOp = TypeToAO[type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 +}; diff --git a/node_modules/es-abstract/2019/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2019/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ede44ed6b75eed8e851821ffee51b52994bb86a7 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var ObjectCreate = require('./ObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return ObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2019/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2019/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2019/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2019/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..ba17b98872933ef285da579420e75fa18b072ce9 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryGetPrototypeOf.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $getProto = require('../helpers/getProto'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2019/OrdinaryHasInstance.js b/node_modules/es-abstract/2019/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2019/OrdinaryHasProperty.js b/node_modules/es-abstract/2019/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2019/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2019/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b72306c187b6e9f4355b399831a46e10fa7f61 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinarySetPrototypeOf.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $setProto = require('../helpers/setProto'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (Type(V) !== 'Object' && Type(V) !== 'Null') { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2019/OrdinaryToPrimitive.js b/node_modules/es-abstract/2019/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..e1dbe1427f8d87cba5e2c711fcb73144fa55ec33 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryToPrimitive.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* Type(hint) !== 'String' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (Type(result) !== 'Object') { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2019/QuoteJSONString.js b/node_modules/es-abstract/2019/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..5c2b6c9dcffecddaa658cd4ae7c68404abf19b30 --- /dev/null +++ b/node_modules/es-abstract/2019/QuoteJSONString.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $strSplit = callBound('String.prototype.split'); + +var Type = require('./Type'); +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16Encoding = require('./UTF16Encoding'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/10.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(value), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(C) || isTrailingSurrogate(C)) { + product += UnicodeEscape(C); + } else { + product += UTF16Encoding(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2019/RawBytesToNumber.js b/node_modules/es-abstract/2019/RawBytesToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..652471623dee44dc6186a4f8f1815bf5cbc2352b --- /dev/null +++ b/node_modules/es-abstract/2019/RawBytesToNumber.js @@ -0,0 +1,74 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var $charAt = callBound('String.prototype.charAt'); +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var hasOwnProperty = require('./HasOwnProperty'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var every = require('../helpers/every'); +var isByteValue = require('../helpers/isByteValue'); + +var keys = require('object-keys'); + +// https://262.ecma-international.org/8.0/#table-50 +var TypeToSizes = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +// https://262.ecma-international.org/8.0/#sec-rawbytestonumber + +module.exports = function RawBytesToNumber(type, rawBytes, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(TypeToSizes, type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type: ' + keys(TypeToSizes)); + } + if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) { + throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes'); + } + if (Type(isLittleEndian) !== 'Boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + var elementSize = TypeToSizes[type]; // step 1 + + if (rawBytes.length !== elementSize) { + // this assertion is not in the spec, but it'd be an editorial error if it were ever violated + throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type); + } + + // eslint-disable-next-line no-param-reassign + rawBytes = $slice(rawBytes, 0, elementSize); + if (!isLittleEndian) { + $reverse(rawBytes); // step 2 + } + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(rawBytes); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(rawBytes); + } + + return bytesAsInteger(rawBytes, elementSize, $charAt(type, 0) === 'U', false); +}; diff --git a/node_modules/es-abstract/2019/RegExpExec.js b/node_modules/es-abstract/2019/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2019/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2019/RequireObjectCoercible.js b/node_modules/es-abstract/2019/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9008359db8f9ac7107563f46c1aebc2258b8cb2b --- /dev/null +++ b/node_modules/es-abstract/2019/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../5/CheckObjectCoercible'); diff --git a/node_modules/es-abstract/2019/SameValue.js b/node_modules/es-abstract/2019/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2019/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2019/SameValueZero.js b/node_modules/es-abstract/2019/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2019/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2019/Set.js b/node_modules/es-abstract/2019/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..969703136399bce4cdbafbd357690f4f53301c0d --- /dev/null +++ b/node_modules/es-abstract/2019/Set.js @@ -0,0 +1,47 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (Type(Throw) !== 'Boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2019/SetFunctionLength.js b/node_modules/es-abstract/2019/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..14228bf184d47240007244933a9b015770a5ce7d --- /dev/null +++ b/node_modules/es-abstract/2019/SetFunctionLength.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/9.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (Type(length) !== 'Number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (length < 0 || !isInteger(length)) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2019/SetIntegrityLevel.js b/node_modules/es-abstract/2019/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2019/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2019/SetValueInBuffer.js b/node_modules/es-abstract/2019/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..d5c2fa479b95179deeba9ccec4d2e1513cb21585 --- /dev/null +++ b/node_modules/es-abstract/2019/SetValueInBuffer.js @@ -0,0 +1,120 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var isArrayBuffer = require('is-array-buffer'); +var hasOwn = require('hasown'); + +var table49 = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + Float32: 4, + Float64: 8 +}; + +var TypeToAO = { + __proto__: null, + Int8: ToInt8, + Uint8: ToUint8, + Uint8C: ToUint8Clamp, + Int16: ToInt16, + Uint16: ToUint16, + Int32: ToInt32, + Uint32: ToUint32 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); +var integerToNBytes = require('../helpers/integerToNBytes'); +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); + +// https://262.ecma-international.org/6.0/#sec-setvalueinbuffer + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value) { + if (!isArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || !hasOwn(table49, type)) { + throw new $TypeError('Assertion failed: `type` must be a Typed Array Element Type'); + } + + if (typeof value !== 'number') { + throw new $TypeError('Assertion failed: `value` must be a number'); + } + + if (arguments.length > 4 && typeof arguments[4] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Assert: Type(value) is Number. + + // 5. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + // 6. Assert: block is not undefined. + + var elementSize = table49[type]; // step 7 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"'); + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the GetValueFromBuffer abstract operation. + var isLittleEndian = arguments.length > 4 ? arguments[4] : defaultEndianness === 'little'; // step 8 + + var rawBytes; + if (type === 'Float32') { // step 1 + rawBytes = valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + rawBytes = valueToFloat64Bytes(value, isLittleEndian); + } else { + var n = table49[type]; // step 3.a + + var convOp = TypeToAO[type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + rawBytes = integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 + } + + // 12. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + + // 13. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2019/SpeciesConstructor.js b/node_modules/es-abstract/2019/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2019/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2019/SplitMatch.js b/node_modules/es-abstract/2019/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..d57fb691e5e91dfb4d30a974e9ebbff47a22e24e --- /dev/null +++ b/node_modules/es-abstract/2019/SplitMatch.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/6.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (Type(R) !== 'String') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return false; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return false; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2019/StringCreate.js b/node_modules/es-abstract/2019/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2019/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2019/SymbolDescriptiveString.js b/node_modules/es-abstract/2019/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2019/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2019/ThrowCompletion.js b/node_modules/es-abstract/2019/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2019/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2019/TimeFromYear.js b/node_modules/es-abstract/2019/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2019/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2019/TimeString.js b/node_modules/es-abstract/2019/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..051c4728e2e495a323f9ed64acd3be8d25603b00 --- /dev/null +++ b/node_modules/es-abstract/2019/TimeString.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); +var Type = require('./Type'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2019/TimeWithinDay.js b/node_modules/es-abstract/2019/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2019/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2019/ToDateString.js b/node_modules/es-abstract/2019/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2019/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2019/ToInt16.js b/node_modules/es-abstract/2019/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2019/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2019/ToInt32.js b/node_modules/es-abstract/2019/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2019/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2019/ToInteger.js b/node_modules/es-abstract/2019/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..f6625796ebd22a688826a1bd5d36e20dfe6ebcc7 --- /dev/null +++ b/node_modules/es-abstract/2019/ToInteger.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5ToInteger = require('../5/ToInteger'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/6.0/#sec-tointeger + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + return ES5ToInteger(number); +}; diff --git a/node_modules/es-abstract/2019/ToPropertyDescriptor.js b/node_modules/es-abstract/2019/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..0af998a5d7f922a5494751846932c0987aa95ff9 --- /dev/null +++ b/node_modules/es-abstract/2019/ToPropertyDescriptor.js @@ -0,0 +1,52 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); +var ToBoolean = require('./ToBoolean'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (Type(Obj) !== 'Object') { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2019/ToString.js b/node_modules/es-abstract/2019/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2019/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2019/ToUint16.js b/node_modules/es-abstract/2019/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..633ca8464dd23b8c48cb91bf70f026c5e2fa91fd --- /dev/null +++ b/node_modules/es-abstract/2019/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2019/ToUint32.js b/node_modules/es-abstract/2019/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2019/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2019/ToUint8Clamp.js b/node_modules/es-abstract/2019/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2019/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2019/TrimString.js b/node_modules/es-abstract/2019/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..113dcf82b82d823bee32c607bcd897bc6e36548a --- /dev/null +++ b/node_modules/es-abstract/2019/TrimString.js @@ -0,0 +1,29 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2019/Type.js b/node_modules/es-abstract/2019/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..da5cb762508f187a91583bfc2d509036d492aa66 --- /dev/null +++ b/node_modules/es-abstract/2019/Type.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/6.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2019/TypedArrayCreate.js b/node_modules/es-abstract/2019/TypedArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..ef9fbe2599495aabd3fdb47a40dffd7d178ad2cb --- /dev/null +++ b/node_modules/es-abstract/2019/TypedArrayCreate.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var availableTypedArrays = require('available-typed-arrays')(); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/7.0/#typedarray-create + +module.exports = function TypedArrayCreate(constructor, argumentList) { + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); + } + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + // var newTypedArray = Construct(constructor, argumentList); // step 1 + var newTypedArray; + if (argumentList.length === 0) { + newTypedArray = new constructor(); + } else if (argumentList.length === 1) { + newTypedArray = new constructor(argumentList[0]); + } else if (argumentList.length === 2) { + newTypedArray = new constructor(argumentList[0], argumentList[1]); + } else { + newTypedArray = new constructor(argumentList[0], argumentList[1], argumentList[2]); + } + + ValidateTypedArray(newTypedArray); // step 2 + + if (argumentList.length === 1 && Type(argumentList[0]) === 'Number') { // step 3 + if (typedArrayLength(newTypedArray) < argumentList[0]) { + throw new $TypeError('Assertion failed: `argumentList[0]` must be <= `newTypedArray.length`'); // step 3.a + } + } + + return newTypedArray; // step 4 +}; diff --git a/node_modules/es-abstract/2019/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2019/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2bfdff5eb705c2c866ad0623064a35be67b92b73 --- /dev/null +++ b/node_modules/es-abstract/2019/TypedArraySpeciesCreate.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2019/UTF16Decode.js b/node_modules/es-abstract/2019/UTF16Decode.js new file mode 100644 index 0000000000000000000000000000000000000000..86927b478ccdb26659380330009b5d3eaae0e8a3 --- /dev/null +++ b/node_modules/es-abstract/2019/UTF16Decode.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +// https://262.ecma-international.org/7.0/#sec-utf16decode + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16Decode(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2019/UTF16Encoding.js b/node_modules/es-abstract/2019/UTF16Encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..f381595fd70d6396dd841c7e71552247f2d80f0e --- /dev/null +++ b/node_modules/es-abstract/2019/UTF16Encoding.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/7.0/#sec-utf16encoding + +module.exports = function UTF16Encoding(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = floor((cp - 65536) / 1024) + 0xD800; + var cu2 = modulo(cp - 65536, 1024) + 0xDC00; + return $fromCharCode(cu1) + $fromCharCode(cu2); +}; diff --git a/node_modules/es-abstract/2019/UnicodeEscape.js b/node_modules/es-abstract/2019/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..db7163f77ee22a384534802b61c8f54879507124 --- /dev/null +++ b/node_modules/es-abstract/2019/UnicodeEscape.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/9.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + $strSlice('0000' + $toLowerCase($numberToString(n, 16)), -4); +}; diff --git a/node_modules/es-abstract/2019/ValidateTypedArray.js b/node_modules/es-abstract/2019/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2019/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2019/WeekDay.js b/node_modules/es-abstract/2019/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2019/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2019/YearFromTime.js b/node_modules/es-abstract/2019/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..be06ecbc36310e9f8ff1e6939dab408141051c0a --- /dev/null +++ b/node_modules/es-abstract/2019/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bind/callBound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2019/abs.js b/node_modules/es-abstract/2019/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2019/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2019/floor.js b/node_modules/es-abstract/2019/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..8439df0649365bf9309bbea76dcfae10e64a599c --- /dev/null +++ b/node_modules/es-abstract/2019/floor.js @@ -0,0 +1,11 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function floor(x) { + // return x - modulo(x, 1); + return $floor(x); +}; diff --git a/node_modules/es-abstract/2019/max.js b/node_modules/es-abstract/2019/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2019/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2019/msFromTime.js b/node_modules/es-abstract/2019/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2019/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2019/thisBooleanValue.js b/node_modules/es-abstract/2019/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2019/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2019/thisNumberValue.js b/node_modules/es-abstract/2019/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2019/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2020/AbstractEqualityComparison.js b/node_modules/es-abstract/2020/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..871a84fa82232b983822ccd743483a3926649a41 --- /dev/null +++ b/node_modules/es-abstract/2020/AbstractEqualityComparison.js @@ -0,0 +1,57 @@ +'use strict'; + +var StrictEqualityComparison = require('./StrictEqualityComparison'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +var isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return StrictEqualityComparison(x, y); + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (xType === 'BigInt' && yType === 'String') { + var n = StringToBigInt(y); + if (isNaN(n)) { + return false; + } + return AbstractEqualityComparison(x, n); + } + if (xType === 'String' && yType === 'BigInt') { + return AbstractEqualityComparison(y, x); + } + if (xType === 'Boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (yType === 'Boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'BigInt' || xType === 'Symbol') && yType === 'Object') { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'BigInt' || yType === 'Symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + if ((xType === 'BigInt' && yType === 'Number') || (xType === 'Number' && yType === 'BigInt')) { + if (isNaN(x) || isNaN(y) || x === Infinity || y === Infinity || x === -Infinity || y === -Infinity) { + return false; + } + return x == y; // eslint-disable-line eqeqeq + } + return false; +}; diff --git a/node_modules/es-abstract/2020/AddEntriesFromIterable.js b/node_modules/es-abstract/2020/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..5bea627fb5160cdb554ce44056112c90b47722f9 --- /dev/null +++ b/node_modules/es-abstract/2020/AddEntriesFromIterable.js @@ -0,0 +1,47 @@ +'use strict'; + +var inspect = require('object-inspect'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); +var Type = require('./Type'); + +// https://262.ecma-international.org/10.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable); + while (true) { // eslint-disable-line no-constant-condition + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (Type(nextItem) !== 'Object') { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2020/ArraySetLength.js b/node_modules/es-abstract/2020/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2020/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2020/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2020/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..5618539dd6fb0d80d53105fcae16dfc946cf187b --- /dev/null +++ b/node_modules/es-abstract/2020/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bind/callBound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); +var Type = require('./Type'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (Type(result) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2020/BigInt/add.js b/node_modules/es-abstract/2020/BigInt/add.js new file mode 100644 index 0000000000000000000000000000000000000000..22b5db4b32d2c9dc6ee3562cb998d4376cada88b --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/add.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add + +module.exports = function BigIntAdd(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/bitwiseAND.js b/node_modules/es-abstract/2020/BigInt/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..83cd2c3ca9edc6de1fa2d30055f4c2daf15aa71e --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/bitwiseAND.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND + +module.exports = function BigIntBitwiseAND(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/bitwiseNOT.js b/node_modules/es-abstract/2020/BigInt/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..9a444dfeab8d635d8355db0e0644a74250776136 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/bitwiseNOT.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT + +module.exports = function BigIntBitwiseNOT(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + return -x - $BigInt(1); +}; diff --git a/node_modules/es-abstract/2020/BigInt/bitwiseOR.js b/node_modules/es-abstract/2020/BigInt/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..3c1b57193ef48115b08bc6bf1d5eb55c69dbb965 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/bitwiseOR.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR + +module.exports = function BigIntBitwiseOR(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/bitwiseXOR.js b/node_modules/es-abstract/2020/BigInt/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..45f8217efb83cd6ad102a8cbcb01cb534bdab133 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/bitwiseXOR.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR + +module.exports = function BigIntBitwiseXOR(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/divide.js b/node_modules/es-abstract/2020/BigInt/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..5706e7d72e4243301af168763d9c035de9cc0e98 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/divide.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide + +module.exports = function BigIntDivide(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + if (y === $BigInt(0)) { + throw new $RangeError('Division by zero'); + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/equal.js b/node_modules/es-abstract/2020/BigInt/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..a28826d67ff75d4158a5d4fbb9e3a8e38b7d5160 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/equal.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal + +module.exports = function BigIntEqual(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/exponentiate.js b/node_modules/es-abstract/2020/BigInt/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..2365838c269b68e03f489f9e26b5a9828bd5edf2 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/exponentiate.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate + +module.exports = function BigIntExponentiate(base, exponent) { + if (Type(base) !== 'BigInt' || Type(exponent) !== 'BigInt') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts'); + } + if (exponent < $BigInt(0)) { + throw new $RangeError('Exponent must be positive'); + } + if (/* base === $BigInt(0) && */ exponent === $BigInt(0)) { + return $BigInt(1); + } + + var square = base; + var remaining = exponent; + while (remaining > $BigInt(0)) { + square += exponent; + --remaining; // eslint-disable-line no-plusplus + } + return square; +}; diff --git a/node_modules/es-abstract/2020/BigInt/index.js b/node_modules/es-abstract/2020/BigInt/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2020/BigInt/leftShift.js b/node_modules/es-abstract/2020/BigInt/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..d2a570223e22c29d6196a51153109aad2f420b3e --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/leftShift.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift + +module.exports = function BigIntLeftShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x << y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/lessThan.js b/node_modules/es-abstract/2020/BigInt/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..0b3cd6ba029e8ee1d8e22e0230d06b68255c4b87 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/lessThan.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan + +module.exports = function BigIntLessThan(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/multiply.js b/node_modules/es-abstract/2020/BigInt/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..6e5d56c83ea0b9bfbe2801895c732e0aff77f922 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/multiply.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply + +module.exports = function BigIntMultiply(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/remainder.js b/node_modules/es-abstract/2020/BigInt/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..d2dc678caf6bdeff4a0dfbc7819129231c0b040c --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/remainder.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder + +module.exports = function BigIntRemainder(n, d) { + if (Type(n) !== 'BigInt' || Type(d) !== 'BigInt') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts'); + } + + if (d === zero) { + throw new $RangeError('Division by zero'); + } + + if (n === zero) { + return zero; + } + + // shortcut for the actual spec mechanics + return n % d; +}; diff --git a/node_modules/es-abstract/2020/BigInt/sameValue.js b/node_modules/es-abstract/2020/BigInt/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..63ff06393bba6fe77255bb577ba40c84a789aed4 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/sameValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValue + +module.exports = function BigIntSameValue(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/sameValueZero.js b/node_modules/es-abstract/2020/BigInt/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..39f262c6da2f26b7f576d28ce75e4ddffa05498b --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/sameValueZero.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValueZero + +module.exports = function BigIntSameValueZero(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/signedRightShift.js b/node_modules/es-abstract/2020/BigInt/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..f63c642f0cda7f1c8079b674dd8a700a018e13cb --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/signedRightShift.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntLeftShift = require('./leftShift'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift + +module.exports = function BigIntSignedRightShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntLeftShift(x, -y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/subtract.js b/node_modules/es-abstract/2020/BigInt/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..0490784f679cd079bdacb6019c20b72d1c82195c --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/subtract.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract + +module.exports = function BigIntSubtract(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x - y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/toString.js b/node_modules/es-abstract/2020/BigInt/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..858d95545475ea5c86c2c62b0d2a1c0476fb1d53 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/toString.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring + +module.exports = function BigIntToString(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` must be a BigInt'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2020/BigInt/unaryMinus.js b/node_modules/es-abstract/2020/BigInt/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..ee0f7ef1962c387400f371c970cef8fba071b616 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/unaryMinus.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus + +module.exports = function BigIntUnaryMinus(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + + if (x === zero) { + return zero; + } + + return -x; +}; diff --git a/node_modules/es-abstract/2020/BigInt/unsignedRightShift.js b/node_modules/es-abstract/2020/BigInt/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..7ad94f7a88d5f49e9125028d497112317d25783e --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/unsignedRightShift.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift + +module.exports = function BigIntUnsignedRightShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + throw new $TypeError('BigInts have no unsigned right shift, use >> instead'); +}; diff --git a/node_modules/es-abstract/2020/BigIntBitwiseOp.js b/node_modules/es-abstract/2020/BigIntBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..0b1c03a911b68cf88fab0a9156e7ac56b2ef3567 --- /dev/null +++ b/node_modules/es-abstract/2020/BigIntBitwiseOp.js @@ -0,0 +1,66 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +// var $BigInt = GetIntrinsic('%BigInt%', true); +// var $pow = GetIntrinsic('%Math.pow%'); + +// var BinaryAnd = require('./BinaryAnd'); +// var BinaryOr = require('./BinaryOr'); +// var BinaryXor = require('./BinaryXor'); +var Type = require('./Type'); +// var modulo = require('./modulo'); + +// var zero = $BigInt && $BigInt(0); +// var negOne = $BigInt && $BigInt(-1); +// var two = $BigInt && $BigInt(2); + +// https://262.ecma-international.org/11.0/#sec-bigintbitwiseop + +module.exports = function BigIntBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('`x` and `y` must be BigInts'); + } + + if (op === '&') { + return x & y; + } + if (op === '|') { + return x | y; + } + return x ^ y; + /* + var result = zero; + var shift = 0; + while (x !== zero && x !== negOne && y !== zero && y !== negOne) { + var xDigit = modulo(x, two); + var yDigit = modulo(y, two); + if (op === '&') { + result += $pow(2, shift) * BinaryAnd(xDigit, yDigit); + } else if (op === '|') { + result += $pow(2, shift) * BinaryOr(xDigit, yDigit); + } else if (op === '^') { + result += $pow(2, shift) * BinaryXor(xDigit, yDigit); + } + shift += 1; + x = (x - xDigit) / two; + y = (y - yDigit) / two; + } + var tmp; + if (op === '&') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else if (op === '|') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else { + tmp = BinaryXor(modulo(x, two), modulo(y, two)); + } + if (tmp !== 0) { + result -= $pow(2, shift); + } + return result; + */ +}; diff --git a/node_modules/es-abstract/2020/BinaryAnd.js b/node_modules/es-abstract/2020/BinaryAnd.js new file mode 100644 index 0000000000000000000000000000000000000000..c617f388dea72e00af72319427af0554e296aad9 --- /dev/null +++ b/node_modules/es-abstract/2020/BinaryAnd.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; diff --git a/node_modules/es-abstract/2020/BinaryOr.js b/node_modules/es-abstract/2020/BinaryOr.js new file mode 100644 index 0000000000000000000000000000000000000000..6de0955f1a6d349fc321e9ea9d1020c939abd28c --- /dev/null +++ b/node_modules/es-abstract/2020/BinaryOr.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryor + +module.exports = function BinaryOr(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x | y; +}; diff --git a/node_modules/es-abstract/2020/BinaryXor.js b/node_modules/es-abstract/2020/BinaryXor.js new file mode 100644 index 0000000000000000000000000000000000000000..189d7d8469ce1f6f509b21bfb5e6a06ae849cd70 --- /dev/null +++ b/node_modules/es-abstract/2020/BinaryXor.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryxor + +module.exports = function BinaryXor(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x ^ y; +}; diff --git a/node_modules/es-abstract/2020/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2020/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..64540dd6e3d71bf6d195589ff569874ff126fc12 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateAsyncFromSyncIterator.js @@ -0,0 +1,121 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); + +var assertRecord = require('../helpers/assertRecord'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord['[[Iterator]]'], value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord['[[Iterator]]']);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/11.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + assertRecord(Type, 'Iterator Record', 'syncIteratorRecord', syncIteratorRecord); + + // var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2020/CreateDataProperty.js b/node_modules/es-abstract/2020/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2020/CreateHTML.js b/node_modules/es-abstract/2020/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2020/CreateMethodProperty.js b/node_modules/es-abstract/2020/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2020/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2020/CreateRegExpStringIterator.js b/node_modules/es-abstract/2020/CreateRegExpStringIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..cdfae56216ba75dee3fb62db722c22e9b293a99f --- /dev/null +++ b/node_modules/es-abstract/2020/CreateRegExpStringIterator.js @@ -0,0 +1,100 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); +var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var CreateMethodProperty = require('./CreateMethodProperty'); +var Get = require('./Get'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var RegExpExec = require('./RegExpExec'); +var Set = require('./Set'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); +var setToStringTag = require('es-set-tostringtag'); + +var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) { + if (Type(S) !== 'String') { + throw new $TypeError('`S` must be a string'); + } + if (Type(global) !== 'Boolean') { + throw new $TypeError('`global` must be a boolean'); + } + if (Type(fullUnicode) !== 'Boolean') { + throw new $TypeError('`fullUnicode` must be a boolean'); + } + SLOT.set(this, '[[IteratingRegExp]]', R); + SLOT.set(this, '[[IteratedString]]', S); + SLOT.set(this, '[[Global]]', global); + SLOT.set(this, '[[Unicode]]', fullUnicode); + SLOT.set(this, '[[Done]]', false); +}; + +if (IteratorPrototype) { + RegExpStringIterator.prototype = OrdinaryObjectCreate(IteratorPrototype); +} + +var RegExpStringIteratorNext = function next() { + var O = this; // eslint-disable-line no-invalid-this + if (Type(O) !== 'Object') { + throw new $TypeError('receiver must be an object'); + } + if ( + !(O instanceof RegExpStringIterator) + || !SLOT.has(O, '[[IteratingRegExp]]') + || !SLOT.has(O, '[[IteratedString]]') + || !SLOT.has(O, '[[Global]]') + || !SLOT.has(O, '[[Unicode]]') + || !SLOT.has(O, '[[Done]]') + ) { + throw new $TypeError('"this" value must be a RegExpStringIterator instance'); + } + if (SLOT.get(O, '[[Done]]')) { + return CreateIterResultObject(undefined, true); + } + var R = SLOT.get(O, '[[IteratingRegExp]]'); + var S = SLOT.get(O, '[[IteratedString]]'); + var global = SLOT.get(O, '[[Global]]'); + var fullUnicode = SLOT.get(O, '[[Unicode]]'); + var match = RegExpExec(R, S); + if (match === null) { + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(undefined, true); + } + if (global) { + var matchStr = ToString(Get(match, '0')); + if (matchStr === '') { + var thisIndex = ToLength(Get(R, 'lastIndex')); + var nextIndex = AdvanceStringIndex(S, thisIndex, fullUnicode); + Set(R, 'lastIndex', nextIndex, true); + } + return CreateIterResultObject(match, false); + } + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(match, false); +}; +CreateMethodProperty(RegExpStringIterator.prototype, 'next', RegExpStringIteratorNext); + +if (hasSymbols) { + setToStringTag(RegExpStringIterator.prototype, 'RegExp String Iterator'); + + if (Symbol.iterator && typeof RegExpStringIterator.prototype[Symbol.iterator] !== 'function') { + var iteratorFn = function SymbolIterator() { + return this; + }; + CreateMethodProperty(RegExpStringIterator.prototype, Symbol.iterator, iteratorFn); + } +} + +// https://262.ecma-international.org/11.0/#sec-createregexpstringiterator +module.exports = function CreateRegExpStringIterator(R, S, global, fullUnicode) { + // assert R.global === global && R.unicode === fullUnicode? + return new RegExpStringIterator(R, S, global, fullUnicode); +}; diff --git a/node_modules/es-abstract/2020/DateFromTime.js b/node_modules/es-abstract/2020/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2020/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2020/DateString.js b/node_modules/es-abstract/2020/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..939c14c0c87ef6b1d8ebc09e936e6c4e86e793c5 --- /dev/null +++ b/node_modules/es-abstract/2020/DateString.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var Type = require('./Type'); +var WeekDay = require('./WeekDay'); +var MonthFromTime = require('./MonthFromTime'); +var YearFromTime = require('./YearFromTime'); +var DateFromTime = require('./DateFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2020/DayFromYear.js b/node_modules/es-abstract/2020/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2020/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2020/DefinePropertyOrThrow.js b/node_modules/es-abstract/2020/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2020/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2020/DeletePropertyOrThrow.js b/node_modules/es-abstract/2020/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2020/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2020/DetachArrayBuffer.js b/node_modules/es-abstract/2020/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..03284729b3d4e77587ae9204577ebf42e5b1b884 --- /dev/null +++ b/node_modules/es-abstract/2020/DetachArrayBuffer.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2020/FlattenIntoArray.js b/node_modules/es-abstract/2020/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..0fb87bc6a39b028f45d6ca131333e9e398443935 --- /dev/null +++ b/node_modules/es-abstract/2020/FlattenIntoArray.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/11.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = LengthOfArrayLike(element); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2020/FromPropertyDescriptor.js b/node_modules/es-abstract/2020/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..c70f0c60e1ff8b16858f71af25b644f8d9a3d589 --- /dev/null +++ b/node_modules/es-abstract/2020/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var assertRecord = require('../helpers/assertRecord'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined') { + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2020/GetGlobalObject.js b/node_modules/es-abstract/2020/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2020/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2020/GetIterator.js b/node_modules/es-abstract/2020/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..672454abdbff3f738bfea8ca06a39ce88e849942 --- /dev/null +++ b/node_modules/es-abstract/2020/GetIterator.js @@ -0,0 +1,66 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $asyncIterator = GetIntrinsic('%Symbol.asyncIterator%', true); + +var inspect = require('object-inspect'); +var hasSymbols = require('has-symbols')(); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-getiterator + +module.exports = function GetIterator(obj, hint, method) { + var actualHint = hint; + if (arguments.length < 2) { + actualHint = 'sync'; + } + if (actualHint !== 'sync' && actualHint !== 'async') { + throw new $TypeError("Assertion failed: `hint` must be one of 'sync' or 'async', got " + inspect(hint)); + } + + var actualMethod = method; + if (arguments.length < 3) { + if (actualHint === 'async') { + if (hasSymbols && $asyncIterator) { + actualMethod = GetMethod(obj, $asyncIterator); + } + if (actualMethod === undefined) { + throw new $SyntaxError("async from sync iterators aren't currently supported"); + } + } else { + actualMethod = getIteratorMethod( + { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod, + IsArray: IsArray + }, + obj + ); + } + } + var iterator = Call(actualMethod, obj); + if (Type(iterator) !== 'Object') { + throw new $TypeError('iterator must return an object'); + } + + return iterator; + + // TODO: This should return an IteratorRecord + /* + var nextMethod = GetV(iterator, 'next'); + return { + '[[Iterator]]': iterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; + */ +}; diff --git a/node_modules/es-abstract/2020/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2020/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2020/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2020/GetV.js b/node_modules/es-abstract/2020/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2020/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2020/GetValueFromBuffer.js b/node_modules/es-abstract/2020/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8d3a2f4fc54239ca212915a513d02fc150c59cf1 --- /dev/null +++ b/node_modules/es-abstract/2020/GetValueFromBuffer.js @@ -0,0 +1,110 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $slice = callBound('Array.prototype.slice'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumeric = require('./RawBytesToNumeric'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table61 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $BigInt64: 8, + $BigUint64: 8, + $Float32: 4, + $Float64: 8 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || typeof table61['$' + type] !== 'number') { + throw new $TypeError('Assertion failed: `type` must be a Typed Array element type'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (order !== 'SeqCst' && order !== 'Unordered') { + throw new $TypeError('Assertion failed: `order` must be either `SeqCst` or `Unordered`'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = table61['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "BigInt64", "BigUint64", "Float32", or "Float64"'); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumeric(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2020/HasOwnProperty.js b/node_modules/es-abstract/2020/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2020/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2020/HourFromTime.js b/node_modules/es-abstract/2020/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2020/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2020/IsAccessorDescriptor.js b/node_modules/es-abstract/2020/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2020/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2020/IsCallable.js b/node_modules/es-abstract/2020/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2020/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2020/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2020/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2020/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2020/IsConcatSpreadable.js b/node_modules/es-abstract/2020/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2020/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2020/IsConstructor.js b/node_modules/es-abstract/2020/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2020/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2020/IsDataDescriptor.js b/node_modules/es-abstract/2020/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2020/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2020/IsInteger.js b/node_modules/es-abstract/2020/IsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..e3d25f38e30093f0a0444e98ef3ddc4e0b35d2ed --- /dev/null +++ b/node_modules/es-abstract/2020/IsInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-isinteger + +module.exports = function IsInteger(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2020/IsPropertyKey.js b/node_modules/es-abstract/2020/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..aaeb6f9b6f83b5a39f1f53cec0edbf19cbc61170 --- /dev/null +++ b/node_modules/es-abstract/2020/IsPropertyKey.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; +}; diff --git a/node_modules/es-abstract/2020/IsRegExp.js b/node_modules/es-abstract/2020/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2020/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2020/IsSharedArrayBuffer.js b/node_modules/es-abstract/2020/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8e96e33f3c2dca5c15127f2ae83fc45861d548b9 --- /dev/null +++ b/node_modules/es-abstract/2020/IsSharedArrayBuffer.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2020/IsUnsignedElementType.js b/node_modules/es-abstract/2020/IsUnsignedElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ff194d73916d487ce951d1c7553b7aa5ab34cf --- /dev/null +++ b/node_modules/es-abstract/2020/IsUnsignedElementType.js @@ -0,0 +1,11 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype + +module.exports = function IsUnsignedElementType(type) { + return type === 'Uint8' + || type === 'Uint8C' + || type === 'Uint16' + || type === 'Uint32' + || type === 'BigUint64'; +}; diff --git a/node_modules/es-abstract/2020/IsValidIntegerIndex.js b/node_modules/es-abstract/2020/IsValidIntegerIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..e2e9af5d83e453f0d4f62b7290f58c248fdc8843 --- /dev/null +++ b/node_modules/es-abstract/2020/IsValidIntegerIndex.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsInteger = require('./IsInteger'); + +var isNegativeZero = require('../helpers/isNegativeZero'); + +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/11.0/#sec-isvalidintegerindex + +module.exports = function IsValidIntegerIndex(O, index) { + // Assert: O is an Integer-Indexed exotic object. + typedArrayBuffer(O); // step 1 + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: Type(index) is not Number'); // step 2 + } + + if (!IsInteger(index)) { return false; } // step 3 + + if (isNegativeZero(index)) { return false; } // step 4 + + if (index < 0 || index >= O.length) { return false; } // step 5 + + return true; // step 6 +}; diff --git a/node_modules/es-abstract/2020/IsWordChar.js b/node_modules/es-abstract/2020/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..5d61804925b6cb8f2570823c90ce44c1c96ece02 --- /dev/null +++ b/node_modules/es-abstract/2020/IsWordChar.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); +var Type = require('./Type'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!IsInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2020/IterableToList.js b/node_modules/es-abstract/2020/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..d994d741aec8650f608ae575d97b66cbf6a2171d --- /dev/null +++ b/node_modules/es-abstract/2020/IterableToList.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); +var $arrayPush = callBound('Array.prototype.push'); + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/9.0/#sec-iterabletolist + +module.exports = function IterableToList(items, method) { + var iterator = GetIterator(items, 'sync', method); + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + $arrayPush(values, nextValue); + } + } + return values; +}; diff --git a/node_modules/es-abstract/2020/IteratorComplete.js b/node_modules/es-abstract/2020/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2020/IteratorNext.js b/node_modules/es-abstract/2020/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..d84d66edb5fc2bd565f3053f15208c37a33024d6 --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorNext.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Invoke = require('./Invoke'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (Type(result) !== 'Object') { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2020/IteratorStep.js b/node_modules/es-abstract/2020/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2020/IteratorValue.js b/node_modules/es-abstract/2020/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2020/LengthOfArrayLike.js b/node_modules/es-abstract/2020/LengthOfArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..132c4d58480f74f2cb987dd997783c035d313a43 --- /dev/null +++ b/node_modules/es-abstract/2020/LengthOfArrayLike.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToLength = require('./ToLength'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-lengthofarraylike + +module.exports = function LengthOfArrayLike(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + return ToLength(Get(obj, 'length')); +}; + +// TODO: use this all over diff --git a/node_modules/es-abstract/2020/MakeTime.js b/node_modules/es-abstract/2020/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..34cb4dcca3f84920250ddb1dce54cecba114a3ad --- /dev/null +++ b/node_modules/es-abstract/2020/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2020/MonthFromTime.js b/node_modules/es-abstract/2020/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2020/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2020/NewPromiseCapability.js b/node_modules/es-abstract/2020/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2020/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2020/NormalCompletion.js b/node_modules/es-abstract/2020/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2020/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2020/NumberBitwiseOp.js b/node_modules/es-abstract/2020/NumberBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..11425ffded076a0f37bd06b3a4b2cc0964eede2b --- /dev/null +++ b/node_modules/es-abstract/2020/NumberBitwiseOp.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var ToInt32 = require('./ToInt32'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-numberbitwiseop + +module.exports = function NumberBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (Type(x) !== 'Number' || Type(y) !== 'Number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + var lnum = ToInt32(x); + var rnum = ToUint32(y); + if (op === '&') { + return lnum & rnum; + } + if (op === '|') { + return lnum | rnum; + } + return lnum ^ rnum; +}; diff --git a/node_modules/es-abstract/2020/NumberToBigInt.js b/node_modules/es-abstract/2020/NumberToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..7d13b69db21495c7950491d08dcbba3b55a396ae --- /dev/null +++ b/node_modules/es-abstract/2020/NumberToBigInt.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/11.0/#sec-numbertobigint + +module.exports = function NumberToBigInt(number) { + if (Type(number) !== 'Number') { + throw new $TypeError('Assertion failed: `number` must be a String'); + } + if (!isInteger(number)) { + throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + return $BigInt(number); +}; diff --git a/node_modules/es-abstract/2020/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2020/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2020/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2020/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..ba17b98872933ef285da579420e75fa18b072ce9 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryGetPrototypeOf.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $getProto = require('../helpers/getProto'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2020/OrdinaryHasInstance.js b/node_modules/es-abstract/2020/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2020/OrdinaryHasProperty.js b/node_modules/es-abstract/2020/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2020/OrdinaryObjectCreate.js b/node_modules/es-abstract/2020/OrdinaryObjectCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..140534083c5c78b6cba43ce916ce30e39efd5c9b --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryObjectCreate.js @@ -0,0 +1,56 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ObjectCreate = GetIntrinsic('%Object.create%', true); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +var forEach = require('../helpers/forEach'); + +var SLOT = require('internal-slot'); + +var hasProto = require('has-proto')(); + +// https://262.ecma-international.org/11.0/#sec-objectcreate + +module.exports = function OrdinaryObjectCreate(proto) { + if (proto !== null && Type(proto) !== 'Object') { + throw new $TypeError('Assertion failed: `proto` must be null or an object'); + } + var additionalInternalSlotsList = arguments.length < 2 ? [] : arguments[1]; + if (!IsArray(additionalInternalSlotsList)) { + throw new $TypeError('Assertion failed: `additionalInternalSlotsList` must be an Array'); + } + + // var internalSlotsList = ['[[Prototype]]', '[[Extensible]]']; // step 1 + // internalSlotsList.push(...additionalInternalSlotsList); // step 2 + // var O = MakeBasicObject(internalSlotsList); // step 3 + // setProto(O, proto); // step 4 + // return O; // step 5 + + var O; + if ($ObjectCreate) { + O = $ObjectCreate(proto); + } else if (hasProto) { + O = { __proto__: proto }; + } else { + if (proto === null) { + throw new $SyntaxError('native Object.create support is required to create null objects'); + } + var T = function T() {}; + T.prototype = proto; + O = new T(); + } + + if (additionalInternalSlotsList.length > 0) { + forEach(additionalInternalSlotsList, function (slot) { + SLOT.set(O, slot, void undefined); + }); + } + + return O; +}; diff --git a/node_modules/es-abstract/2020/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2020/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b72306c187b6e9f4355b399831a46e10fa7f61 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinarySetPrototypeOf.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $setProto = require('../helpers/setProto'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (Type(V) !== 'Object' && Type(V) !== 'Null') { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2020/OrdinaryToPrimitive.js b/node_modules/es-abstract/2020/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..e1dbe1427f8d87cba5e2c711fcb73144fa55ec33 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryToPrimitive.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* Type(hint) !== 'String' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (Type(result) !== 'Object') { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2020/QuoteJSONString.js b/node_modules/es-abstract/2020/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..3b6ec40a41dad04677e6450cc11fa0e37a61aa6b --- /dev/null +++ b/node_modules/es-abstract/2020/QuoteJSONString.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +var Type = require('./Type'); +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16Encoding = require('./UTF16Encoding'); +var UTF16DecodeString = require('./UTF16DecodeString'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/11.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach(UTF16DecodeString(value), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(C) || isTrailingSurrogate(C)) { + product += UnicodeEscape(C); + } else { + product += UTF16Encoding(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2020/RegExpExec.js b/node_modules/es-abstract/2020/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2020/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2020/RequireObjectCoercible.js b/node_modules/es-abstract/2020/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9008359db8f9ac7107563f46c1aebc2258b8cb2b --- /dev/null +++ b/node_modules/es-abstract/2020/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../5/CheckObjectCoercible'); diff --git a/node_modules/es-abstract/2020/SameValue.js b/node_modules/es-abstract/2020/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2020/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2020/SameValueZero.js b/node_modules/es-abstract/2020/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2020/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2020/SetFunctionLength.js b/node_modules/es-abstract/2020/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..a471b0c479c759f3c0bdd8e573362f82af11dfc3 --- /dev/null +++ b/node_modules/es-abstract/2020/SetFunctionLength.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); +var IsNonNegativeInteger = require('./IsNonNegativeInteger'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (Type(length) !== 'Number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (!IsNonNegativeInteger(length)) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2020/SetIntegrityLevel.js b/node_modules/es-abstract/2020/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2020/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2020/SetValueInBuffer.js b/node_modules/es-abstract/2020/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..4039c142f479ab9091399d4950e59c265d4df774 --- /dev/null +++ b/node_modules/es-abstract/2020/SetValueInBuffer.js @@ -0,0 +1,109 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isInteger = require('../helpers/isInteger'); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var NumericToRawBytes = require('./NumericToRawBytes'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var hasOwn = require('hasown'); + +var table61 = { + __proto__: null, + Int8: 1, + Uint8: 1, + Uint8C: 1, + Int16: 2, + Uint16: 2, + Int32: 4, + Uint32: 4, + BigInt64: 8, + BigUint64: 8, + Float32: 4, + Float64: 8 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/11.0/#sec-setvalueinbuffer + +/* eslint max-params: 0 */ + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || !hasOwn(table61, type)) { + throw new $TypeError('Assertion failed: `type` must be a Typed Array Element Type'); + } + + if (typeof value !== 'number' && typeof value !== 'bigint') { + throw new $TypeError('Assertion failed: `value` must be a Number or a BigInt'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + if (order !== 'SeqCst' && order !== 'Unordered' && order !== 'Init') { + throw new $TypeError('Assertion failed: `order` must be `"SeqCst"`, `"Unordered"`, or `"Init"`'); + } + + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + if (IsBigIntElementType(type) ? typeof value !== 'bigint' : typeof value !== 'number') { // step 4 + throw new $TypeError('Assertion failed: `value` must be a BigInt if type is BigInt64 or BigUint64, otherwise a Number'); + } + + // 5. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + var elementSize = table61[type]; // step 6 + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the GetValueFromBuffer abstract operation. + var isLittleEndian = arguments.length > 6 ? arguments[6] : defaultEndianness === 'little'; // step 8 + + var rawBytes = NumericToRawBytes(type, value, isLittleEndian); // step 8 + + if (isSAB) { // step 9 + /* + Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + Let eventList be the [[EventList]] field of the element in execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier(). + If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false. + Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventList. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 10. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + } + + // 11. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2020/SpeciesConstructor.js b/node_modules/es-abstract/2020/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2020/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2020/SplitMatch.js b/node_modules/es-abstract/2020/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..d57fb691e5e91dfb4d30a974e9ebbff47a22e24e --- /dev/null +++ b/node_modules/es-abstract/2020/SplitMatch.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/6.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (Type(R) !== 'String') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return false; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return false; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2020/StringCreate.js b/node_modules/es-abstract/2020/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2020/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2020/StringPad.js b/node_modules/es-abstract/2020/StringPad.js new file mode 100644 index 0000000000000000000000000000000000000000..cdf69001bb5bdc84a82d4b30da527138e1c9dc31 --- /dev/null +++ b/node_modules/es-abstract/2020/StringPad.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/11.0/#sec-stringpad + +module.exports = function StringPad(O, maxLength, fillString, placement) { + if (placement !== 'start' && placement !== 'end') { + throw new $TypeError('Assertion failed: `placement` must be "start" or "end"'); + } + var S = ToString(O); + var intMaxLength = ToLength(maxLength); + var stringLength = S.length; + if (intMaxLength <= stringLength) { + return S; + } + var filler = typeof fillString === 'undefined' ? ' ' : ToString(fillString); + if (filler === '') { + return S; + } + var fillLen = intMaxLength - stringLength; + + // the String value consisting of repeated concatenations of filler truncated to length fillLen. + var truncatedStringFiller = ''; + while (truncatedStringFiller.length < fillLen) { + truncatedStringFiller += filler; + } + truncatedStringFiller = $strSlice(truncatedStringFiller, 0, fillLen); + + if (placement === 'start') { + return truncatedStringFiller + S; + } + return S + truncatedStringFiller; +}; diff --git a/node_modules/es-abstract/2020/SymbolDescriptiveString.js b/node_modules/es-abstract/2020/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2020/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2020/ThrowCompletion.js b/node_modules/es-abstract/2020/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2020/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2020/TimeFromYear.js b/node_modules/es-abstract/2020/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2020/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2020/TimeString.js b/node_modules/es-abstract/2020/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..051c4728e2e495a323f9ed64acd3be8d25603b00 --- /dev/null +++ b/node_modules/es-abstract/2020/TimeString.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); +var Type = require('./Type'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2020/TimeWithinDay.js b/node_modules/es-abstract/2020/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2020/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2020/ToDateString.js b/node_modules/es-abstract/2020/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2020/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2020/ToInt16.js b/node_modules/es-abstract/2020/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2020/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2020/ToInt32.js b/node_modules/es-abstract/2020/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2020/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2020/ToInteger.js b/node_modules/es-abstract/2020/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..9210af89e918a892c86877ff82d4bff068c6606f --- /dev/null +++ b/node_modules/es-abstract/2020/ToInteger.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5ToInteger = require('../5/ToInteger'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/11.0/#sec-tointeger + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + if (number !== 0) { + number = ES5ToInteger(number); + } + return number === 0 ? 0 : number; +}; diff --git a/node_modules/es-abstract/2020/ToNumeric.js b/node_modules/es-abstract/2020/ToNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..140adb3975b21c3ed32a21751188c2c728a2365e --- /dev/null +++ b/node_modules/es-abstract/2020/ToNumeric.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); + +var isPrimitive = require('../helpers/isPrimitive'); + +var ToPrimitive = require('./ToPrimitive'); +var ToNumber = require('./ToNumber'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-tonumeric + +module.exports = function ToNumeric(argument) { + var primValue = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (Type(primValue) === 'BigInt') { + return primValue; + } + return ToNumber(primValue); +}; diff --git a/node_modules/es-abstract/2020/ToString.js b/node_modules/es-abstract/2020/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2020/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2020/ToUint8Clamp.js b/node_modules/es-abstract/2020/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2020/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2020/TrimString.js b/node_modules/es-abstract/2020/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..113dcf82b82d823bee32c607bcd897bc6e36548a --- /dev/null +++ b/node_modules/es-abstract/2020/TrimString.js @@ -0,0 +1,29 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2020/Type.js b/node_modules/es-abstract/2020/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..555ca74ea51969958716accd635da40009319542 --- /dev/null +++ b/node_modules/es-abstract/2020/Type.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + if (typeof x === 'bigint') { + return 'BigInt'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2020/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2020/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2bfdff5eb705c2c866ad0623064a35be67b92b73 --- /dev/null +++ b/node_modules/es-abstract/2020/TypedArraySpeciesCreate.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2020/UTF16DecodeString.js b/node_modules/es-abstract/2020/UTF16DecodeString.js new file mode 100644 index 0000000000000000000000000000000000000000..8e27a21e8105854b372157b89b45264c2ccc7d7f --- /dev/null +++ b/node_modules/es-abstract/2020/UTF16DecodeString.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $push = callBound('Array.prototype.push'); + +var CodePointAt = require('./CodePointAt'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodestring + +module.exports = function UTF16DecodeString(string) { + if (Type(string) !== 'String') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var codePoints = []; + var size = string.length; + var position = 0; + while (position < size) { + var cp = CodePointAt(string, position); + $push(codePoints, cp['[[CodePoint]]']); + position += cp['[[CodeUnitCount]]']; + } + return codePoints; +}; diff --git a/node_modules/es-abstract/2020/UTF16DecodeSurrogatePair.js b/node_modules/es-abstract/2020/UTF16DecodeSurrogatePair.js new file mode 100644 index 0000000000000000000000000000000000000000..2632e654cb8a655c39ee07fe0d1fd8cffd4ebf74 --- /dev/null +++ b/node_modules/es-abstract/2020/UTF16DecodeSurrogatePair.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16DecodeSurrogatePair(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2020/UTF16Encoding.js b/node_modules/es-abstract/2020/UTF16Encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..f381595fd70d6396dd841c7e71552247f2d80f0e --- /dev/null +++ b/node_modules/es-abstract/2020/UTF16Encoding.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/7.0/#sec-utf16encoding + +module.exports = function UTF16Encoding(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = floor((cp - 65536) / 1024) + 0xD800; + var cu2 = modulo(cp - 65536, 1024) + 0xDC00; + return $fromCharCode(cu1) + $fromCharCode(cu2); +}; diff --git a/node_modules/es-abstract/2020/UnicodeEscape.js b/node_modules/es-abstract/2020/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..b708c90df0a05e9250f3dbbb9ac1044bb88b5d42 --- /dev/null +++ b/node_modules/es-abstract/2020/UnicodeEscape.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); + +var StringPad = require('./StringPad'); + +// https://262.ecma-international.org/11.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + StringPad($toLowerCase($numberToString(n, 16)), 4, '0', 'start'); +}; diff --git a/node_modules/es-abstract/2020/ValidateTypedArray.js b/node_modules/es-abstract/2020/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2020/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2020/WeekDay.js b/node_modules/es-abstract/2020/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2020/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2020/abs.js b/node_modules/es-abstract/2020/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2020/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2020/floor.js b/node_modules/es-abstract/2020/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..625548e936b95ca0735790d52c46f9bee5730558 --- /dev/null +++ b/node_modules/es-abstract/2020/floor.js @@ -0,0 +1,16 @@ +'use strict'; + +var Type = require('./Type'); + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/11.0/#eqn-floor + +module.exports = function floor(x) { + // return x - modulo(x, 1); + if (Type(x) === 'BigInt') { + return x; + } + return $floor(x); +}; diff --git a/node_modules/es-abstract/2020/max.js b/node_modules/es-abstract/2020/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2020/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2020/msFromTime.js b/node_modules/es-abstract/2020/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2020/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2020/thisBooleanValue.js b/node_modules/es-abstract/2020/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2020/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2020/thisNumberValue.js b/node_modules/es-abstract/2020/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2020/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2021/AbstractEqualityComparison.js b/node_modules/es-abstract/2021/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..871a84fa82232b983822ccd743483a3926649a41 --- /dev/null +++ b/node_modules/es-abstract/2021/AbstractEqualityComparison.js @@ -0,0 +1,57 @@ +'use strict'; + +var StrictEqualityComparison = require('./StrictEqualityComparison'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +var isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return StrictEqualityComparison(x, y); + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (xType === 'BigInt' && yType === 'String') { + var n = StringToBigInt(y); + if (isNaN(n)) { + return false; + } + return AbstractEqualityComparison(x, n); + } + if (xType === 'String' && yType === 'BigInt') { + return AbstractEqualityComparison(y, x); + } + if (xType === 'Boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (yType === 'Boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'BigInt' || xType === 'Symbol') && yType === 'Object') { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'BigInt' || yType === 'Symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + if ((xType === 'BigInt' && yType === 'Number') || (xType === 'Number' && yType === 'BigInt')) { + if (isNaN(x) || isNaN(y) || x === Infinity || y === Infinity || x === -Infinity || y === -Infinity) { + return false; + } + return x == y; // eslint-disable-line eqeqeq + } + return false; +}; diff --git a/node_modules/es-abstract/2021/AddEntriesFromIterable.js b/node_modules/es-abstract/2021/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..5bea627fb5160cdb554ce44056112c90b47722f9 --- /dev/null +++ b/node_modules/es-abstract/2021/AddEntriesFromIterable.js @@ -0,0 +1,47 @@ +'use strict'; + +var inspect = require('object-inspect'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); +var Type = require('./Type'); + +// https://262.ecma-international.org/10.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable); + while (true) { // eslint-disable-line no-constant-condition + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (Type(nextItem) !== 'Object') { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2021/ApplyStringOrNumericBinaryOperator.js b/node_modules/es-abstract/2021/ApplyStringOrNumericBinaryOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..e5f997a39d09af338a6a314e28774f8b132d7438 --- /dev/null +++ b/node_modules/es-abstract/2021/ApplyStringOrNumericBinaryOperator.js @@ -0,0 +1,80 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var HasOwnProperty = require('./HasOwnProperty'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var NumberAdd = require('./Number/add'); +var NumberBitwiseAND = require('./Number/bitwiseAND'); +var NumberBitwiseOR = require('./Number/bitwiseOR'); +var NumberBitwiseXOR = require('./Number/bitwiseXOR'); +var NumberDivide = require('./Number/divide'); +var NumberExponentiate = require('./Number/exponentiate'); +var NumberLeftShift = require('./Number/leftShift'); +var NumberMultiply = require('./Number/multiply'); +var NumberRemainder = require('./Number/remainder'); +var NumberSignedRightShift = require('./Number/signedRightShift'); +var NumberSubtract = require('./Number/subtract'); +var NumberUnsignedRightShift = require('./Number/unsignedRightShift'); +var BigIntAdd = require('./BigInt/add'); +var BigIntBitwiseAND = require('./BigInt/bitwiseAND'); +var BigIntBitwiseOR = require('./BigInt/bitwiseOR'); +var BigIntBitwiseXOR = require('./BigInt/bitwiseXOR'); +var BigIntDivide = require('./BigInt/divide'); +var BigIntExponentiate = require('./BigInt/exponentiate'); +var BigIntLeftShift = require('./BigInt/leftShift'); +var BigIntMultiply = require('./BigInt/multiply'); +var BigIntRemainder = require('./BigInt/remainder'); +var BigIntSignedRightShift = require('./BigInt/signedRightShift'); +var BigIntSubtract = require('./BigInt/subtract'); +var BigIntUnsignedRightShift = require('./BigInt/unsignedRightShift'); + +// https://262.ecma-international.org/12.0/#sec-applystringornumericbinaryoperator + +// https://262.ecma-international.org/12.0/#step-applystringornumericbinaryoperator-operations-table +var table = { + '**': [NumberExponentiate, BigIntExponentiate], + '*': [NumberMultiply, BigIntMultiply], + '/': [NumberDivide, BigIntDivide], + '%': [NumberRemainder, BigIntRemainder], + '+': [NumberAdd, BigIntAdd], + '-': [NumberSubtract, BigIntSubtract], + '<<': [NumberLeftShift, BigIntLeftShift], + '>>': [NumberSignedRightShift, BigIntSignedRightShift], + '>>>': [NumberUnsignedRightShift, BigIntUnsignedRightShift], + '&': [NumberBitwiseAND, BigIntBitwiseAND], + '^': [NumberBitwiseXOR, BigIntBitwiseXOR], + '|': [NumberBitwiseOR, BigIntBitwiseOR] +}; + +module.exports = function ApplyStringOrNumericBinaryOperator(lval, opText, rval) { + if (Type(opText) !== 'String' || !HasOwnProperty(table, opText)) { + throw new $TypeError('Assertion failed: `opText` must be a valid operation string'); + } + if (opText === '+') { + var lprim = ToPrimitive(lval); + var rprim = ToPrimitive(rval); + if (Type(lprim) === 'String' || Type(rprim) === 'String') { + var lstr = ToString(lprim); + var rstr = ToString(rprim); + return lstr + rstr; + } + /* eslint no-param-reassign: 1 */ + lval = lprim; + rval = rprim; + } + var lnum = ToNumeric(lval); + var rnum = ToNumeric(rval); + var T = Type(lnum); + if (T !== Type(rnum)) { + throw new $TypeError('types of ' + lnum + ' and ' + rnum + ' differ'); + } + var Operation = table[opText][T === 'BigInt' ? 1 : 0]; + return Operation(lnum, rnum); +}; diff --git a/node_modules/es-abstract/2021/ArraySetLength.js b/node_modules/es-abstract/2021/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2021/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2021/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2021/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..5618539dd6fb0d80d53105fcae16dfc946cf187b --- /dev/null +++ b/node_modules/es-abstract/2021/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bind/callBound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); +var Type = require('./Type'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (Type(result) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2021/BigInt/add.js b/node_modules/es-abstract/2021/BigInt/add.js new file mode 100644 index 0000000000000000000000000000000000000000..22b5db4b32d2c9dc6ee3562cb998d4376cada88b --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/add.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add + +module.exports = function BigIntAdd(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/bitwiseAND.js b/node_modules/es-abstract/2021/BigInt/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..83cd2c3ca9edc6de1fa2d30055f4c2daf15aa71e --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/bitwiseAND.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND + +module.exports = function BigIntBitwiseAND(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/bitwiseNOT.js b/node_modules/es-abstract/2021/BigInt/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..9a444dfeab8d635d8355db0e0644a74250776136 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/bitwiseNOT.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT + +module.exports = function BigIntBitwiseNOT(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + return -x - $BigInt(1); +}; diff --git a/node_modules/es-abstract/2021/BigInt/bitwiseOR.js b/node_modules/es-abstract/2021/BigInt/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..3c1b57193ef48115b08bc6bf1d5eb55c69dbb965 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/bitwiseOR.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR + +module.exports = function BigIntBitwiseOR(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/bitwiseXOR.js b/node_modules/es-abstract/2021/BigInt/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..45f8217efb83cd6ad102a8cbcb01cb534bdab133 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/bitwiseXOR.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR + +module.exports = function BigIntBitwiseXOR(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/divide.js b/node_modules/es-abstract/2021/BigInt/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..5706e7d72e4243301af168763d9c035de9cc0e98 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/divide.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide + +module.exports = function BigIntDivide(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + if (y === $BigInt(0)) { + throw new $RangeError('Division by zero'); + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/equal.js b/node_modules/es-abstract/2021/BigInt/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..a28826d67ff75d4158a5d4fbb9e3a8e38b7d5160 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/equal.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal + +module.exports = function BigIntEqual(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/exponentiate.js b/node_modules/es-abstract/2021/BigInt/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..2365838c269b68e03f489f9e26b5a9828bd5edf2 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/exponentiate.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate + +module.exports = function BigIntExponentiate(base, exponent) { + if (Type(base) !== 'BigInt' || Type(exponent) !== 'BigInt') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts'); + } + if (exponent < $BigInt(0)) { + throw new $RangeError('Exponent must be positive'); + } + if (/* base === $BigInt(0) && */ exponent === $BigInt(0)) { + return $BigInt(1); + } + + var square = base; + var remaining = exponent; + while (remaining > $BigInt(0)) { + square += exponent; + --remaining; // eslint-disable-line no-plusplus + } + return square; +}; diff --git a/node_modules/es-abstract/2021/BigInt/index.js b/node_modules/es-abstract/2021/BigInt/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2021/BigInt/leftShift.js b/node_modules/es-abstract/2021/BigInt/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..d2a570223e22c29d6196a51153109aad2f420b3e --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/leftShift.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift + +module.exports = function BigIntLeftShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x << y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/lessThan.js b/node_modules/es-abstract/2021/BigInt/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..0b3cd6ba029e8ee1d8e22e0230d06b68255c4b87 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/lessThan.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan + +module.exports = function BigIntLessThan(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/multiply.js b/node_modules/es-abstract/2021/BigInt/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..6e5d56c83ea0b9bfbe2801895c732e0aff77f922 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/multiply.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply + +module.exports = function BigIntMultiply(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/remainder.js b/node_modules/es-abstract/2021/BigInt/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..d2dc678caf6bdeff4a0dfbc7819129231c0b040c --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/remainder.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder + +module.exports = function BigIntRemainder(n, d) { + if (Type(n) !== 'BigInt' || Type(d) !== 'BigInt') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts'); + } + + if (d === zero) { + throw new $RangeError('Division by zero'); + } + + if (n === zero) { + return zero; + } + + // shortcut for the actual spec mechanics + return n % d; +}; diff --git a/node_modules/es-abstract/2021/BigInt/sameValue.js b/node_modules/es-abstract/2021/BigInt/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..63ff06393bba6fe77255bb577ba40c84a789aed4 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/sameValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValue + +module.exports = function BigIntSameValue(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/sameValueZero.js b/node_modules/es-abstract/2021/BigInt/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..39f262c6da2f26b7f576d28ce75e4ddffa05498b --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/sameValueZero.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValueZero + +module.exports = function BigIntSameValueZero(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/signedRightShift.js b/node_modules/es-abstract/2021/BigInt/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..f63c642f0cda7f1c8079b674dd8a700a018e13cb --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/signedRightShift.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntLeftShift = require('./leftShift'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift + +module.exports = function BigIntSignedRightShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntLeftShift(x, -y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/subtract.js b/node_modules/es-abstract/2021/BigInt/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..0490784f679cd079bdacb6019c20b72d1c82195c --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/subtract.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract + +module.exports = function BigIntSubtract(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x - y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/toString.js b/node_modules/es-abstract/2021/BigInt/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..858d95545475ea5c86c2c62b0d2a1c0476fb1d53 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/toString.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring + +module.exports = function BigIntToString(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` must be a BigInt'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2021/BigInt/unaryMinus.js b/node_modules/es-abstract/2021/BigInt/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..ee0f7ef1962c387400f371c970cef8fba071b616 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/unaryMinus.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus + +module.exports = function BigIntUnaryMinus(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + + if (x === zero) { + return zero; + } + + return -x; +}; diff --git a/node_modules/es-abstract/2021/BigInt/unsignedRightShift.js b/node_modules/es-abstract/2021/BigInt/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..7ad94f7a88d5f49e9125028d497112317d25783e --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/unsignedRightShift.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift + +module.exports = function BigIntUnsignedRightShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + throw new $TypeError('BigInts have no unsigned right shift, use >> instead'); +}; diff --git a/node_modules/es-abstract/2021/BigIntBitwiseOp.js b/node_modules/es-abstract/2021/BigIntBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..0b1c03a911b68cf88fab0a9156e7ac56b2ef3567 --- /dev/null +++ b/node_modules/es-abstract/2021/BigIntBitwiseOp.js @@ -0,0 +1,66 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +// var $BigInt = GetIntrinsic('%BigInt%', true); +// var $pow = GetIntrinsic('%Math.pow%'); + +// var BinaryAnd = require('./BinaryAnd'); +// var BinaryOr = require('./BinaryOr'); +// var BinaryXor = require('./BinaryXor'); +var Type = require('./Type'); +// var modulo = require('./modulo'); + +// var zero = $BigInt && $BigInt(0); +// var negOne = $BigInt && $BigInt(-1); +// var two = $BigInt && $BigInt(2); + +// https://262.ecma-international.org/11.0/#sec-bigintbitwiseop + +module.exports = function BigIntBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('`x` and `y` must be BigInts'); + } + + if (op === '&') { + return x & y; + } + if (op === '|') { + return x | y; + } + return x ^ y; + /* + var result = zero; + var shift = 0; + while (x !== zero && x !== negOne && y !== zero && y !== negOne) { + var xDigit = modulo(x, two); + var yDigit = modulo(y, two); + if (op === '&') { + result += $pow(2, shift) * BinaryAnd(xDigit, yDigit); + } else if (op === '|') { + result += $pow(2, shift) * BinaryOr(xDigit, yDigit); + } else if (op === '^') { + result += $pow(2, shift) * BinaryXor(xDigit, yDigit); + } + shift += 1; + x = (x - xDigit) / two; + y = (y - yDigit) / two; + } + var tmp; + if (op === '&') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else if (op === '|') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else { + tmp = BinaryXor(modulo(x, two), modulo(y, two)); + } + if (tmp !== 0) { + result -= $pow(2, shift); + } + return result; + */ +}; diff --git a/node_modules/es-abstract/2021/BinaryAnd.js b/node_modules/es-abstract/2021/BinaryAnd.js new file mode 100644 index 0000000000000000000000000000000000000000..c617f388dea72e00af72319427af0554e296aad9 --- /dev/null +++ b/node_modules/es-abstract/2021/BinaryAnd.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; diff --git a/node_modules/es-abstract/2021/BinaryOr.js b/node_modules/es-abstract/2021/BinaryOr.js new file mode 100644 index 0000000000000000000000000000000000000000..6de0955f1a6d349fc321e9ea9d1020c939abd28c --- /dev/null +++ b/node_modules/es-abstract/2021/BinaryOr.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryor + +module.exports = function BinaryOr(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x | y; +}; diff --git a/node_modules/es-abstract/2021/BinaryXor.js b/node_modules/es-abstract/2021/BinaryXor.js new file mode 100644 index 0000000000000000000000000000000000000000..189d7d8469ce1f6f509b21bfb5e6a06ae849cd70 --- /dev/null +++ b/node_modules/es-abstract/2021/BinaryXor.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryxor + +module.exports = function BinaryXor(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x ^ y; +}; diff --git a/node_modules/es-abstract/2021/ByteListBitwiseOp.js b/node_modules/es-abstract/2021/ByteListBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..67f4cecb59bac39e28f28b8f305b8f2d2ec18f0d --- /dev/null +++ b/node_modules/es-abstract/2021/ByteListBitwiseOp.js @@ -0,0 +1,44 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $push = callBound('Array.prototype.push'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistbitwiseop + +module.exports = function ByteListBitwiseOp(op, xBytes, yBytes) { + if (op !== '&' && op !== '^' && op !== '|') { + throw new $TypeError('Assertion failed: `op` must be `&`, `^`, or `|`'); + } + if (!IsArray(xBytes) || !IsArray(yBytes) || xBytes.length !== yBytes.length) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + + var result = []; + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + var resultByte; + if (op === '&') { + resultByte = xByte & yByte; + } else if (op === '^') { + resultByte = xByte ^ yByte; + } else { + resultByte = xByte | yByte; + } + $push(result, resultByte); + } + + return result; +}; diff --git a/node_modules/es-abstract/2021/ByteListEqual.js b/node_modules/es-abstract/2021/ByteListEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..489ddc224e6678e32474b3900c55bbb0c6202ff0 --- /dev/null +++ b/node_modules/es-abstract/2021/ByteListEqual.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistequal + +module.exports = function ByteListEqual(xBytes, yBytes) { + if (!IsArray(xBytes) || !IsArray(yBytes)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + + if (xBytes.length !== yBytes.length) { + return false; + } + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + if (xByte !== yByte) { + return false; + } + } + return true; +}; diff --git a/node_modules/es-abstract/2021/CodePointsToString.js b/node_modules/es-abstract/2021/CodePointsToString.js new file mode 100644 index 0000000000000000000000000000000000000000..6d7cd854b9d8536a9d6c0f09d484dad84b5c2f2e --- /dev/null +++ b/node_modules/es-abstract/2021/CodePointsToString.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/12.0/#sec-codepointstostring + +module.exports = function CodePointsToString(text) { + if (!IsArray(text)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + var result = ''; + forEach(text, function (cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + result += UTF16EncodeCodePoint(cp); + }); + return result; +}; diff --git a/node_modules/es-abstract/2021/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2021/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..64540dd6e3d71bf6d195589ff569874ff126fc12 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateAsyncFromSyncIterator.js @@ -0,0 +1,121 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); + +var assertRecord = require('../helpers/assertRecord'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord['[[Iterator]]'], value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord['[[Iterator]]']);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/11.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + assertRecord(Type, 'Iterator Record', 'syncIteratorRecord', syncIteratorRecord); + + // var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2021/CreateDataProperty.js b/node_modules/es-abstract/2021/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2021/CreateHTML.js b/node_modules/es-abstract/2021/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2021/CreateMethodProperty.js b/node_modules/es-abstract/2021/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2021/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2021/CreateRegExpStringIterator.js b/node_modules/es-abstract/2021/CreateRegExpStringIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..cdfae56216ba75dee3fb62db722c22e9b293a99f --- /dev/null +++ b/node_modules/es-abstract/2021/CreateRegExpStringIterator.js @@ -0,0 +1,100 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); +var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var CreateMethodProperty = require('./CreateMethodProperty'); +var Get = require('./Get'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var RegExpExec = require('./RegExpExec'); +var Set = require('./Set'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); +var setToStringTag = require('es-set-tostringtag'); + +var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) { + if (Type(S) !== 'String') { + throw new $TypeError('`S` must be a string'); + } + if (Type(global) !== 'Boolean') { + throw new $TypeError('`global` must be a boolean'); + } + if (Type(fullUnicode) !== 'Boolean') { + throw new $TypeError('`fullUnicode` must be a boolean'); + } + SLOT.set(this, '[[IteratingRegExp]]', R); + SLOT.set(this, '[[IteratedString]]', S); + SLOT.set(this, '[[Global]]', global); + SLOT.set(this, '[[Unicode]]', fullUnicode); + SLOT.set(this, '[[Done]]', false); +}; + +if (IteratorPrototype) { + RegExpStringIterator.prototype = OrdinaryObjectCreate(IteratorPrototype); +} + +var RegExpStringIteratorNext = function next() { + var O = this; // eslint-disable-line no-invalid-this + if (Type(O) !== 'Object') { + throw new $TypeError('receiver must be an object'); + } + if ( + !(O instanceof RegExpStringIterator) + || !SLOT.has(O, '[[IteratingRegExp]]') + || !SLOT.has(O, '[[IteratedString]]') + || !SLOT.has(O, '[[Global]]') + || !SLOT.has(O, '[[Unicode]]') + || !SLOT.has(O, '[[Done]]') + ) { + throw new $TypeError('"this" value must be a RegExpStringIterator instance'); + } + if (SLOT.get(O, '[[Done]]')) { + return CreateIterResultObject(undefined, true); + } + var R = SLOT.get(O, '[[IteratingRegExp]]'); + var S = SLOT.get(O, '[[IteratedString]]'); + var global = SLOT.get(O, '[[Global]]'); + var fullUnicode = SLOT.get(O, '[[Unicode]]'); + var match = RegExpExec(R, S); + if (match === null) { + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(undefined, true); + } + if (global) { + var matchStr = ToString(Get(match, '0')); + if (matchStr === '') { + var thisIndex = ToLength(Get(R, 'lastIndex')); + var nextIndex = AdvanceStringIndex(S, thisIndex, fullUnicode); + Set(R, 'lastIndex', nextIndex, true); + } + return CreateIterResultObject(match, false); + } + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(match, false); +}; +CreateMethodProperty(RegExpStringIterator.prototype, 'next', RegExpStringIteratorNext); + +if (hasSymbols) { + setToStringTag(RegExpStringIterator.prototype, 'RegExp String Iterator'); + + if (Symbol.iterator && typeof RegExpStringIterator.prototype[Symbol.iterator] !== 'function') { + var iteratorFn = function SymbolIterator() { + return this; + }; + CreateMethodProperty(RegExpStringIterator.prototype, Symbol.iterator, iteratorFn); + } +} + +// https://262.ecma-international.org/11.0/#sec-createregexpstringiterator +module.exports = function CreateRegExpStringIterator(R, S, global, fullUnicode) { + // assert R.global === global && R.unicode === fullUnicode? + return new RegExpStringIterator(R, S, global, fullUnicode); +}; diff --git a/node_modules/es-abstract/2021/DateFromTime.js b/node_modules/es-abstract/2021/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2021/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2021/DateString.js b/node_modules/es-abstract/2021/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..939c14c0c87ef6b1d8ebc09e936e6c4e86e793c5 --- /dev/null +++ b/node_modules/es-abstract/2021/DateString.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var Type = require('./Type'); +var WeekDay = require('./WeekDay'); +var MonthFromTime = require('./MonthFromTime'); +var YearFromTime = require('./YearFromTime'); +var DateFromTime = require('./DateFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2021/DayFromYear.js b/node_modules/es-abstract/2021/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2021/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2021/DefinePropertyOrThrow.js b/node_modules/es-abstract/2021/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2021/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2021/DeletePropertyOrThrow.js b/node_modules/es-abstract/2021/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2021/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2021/DetachArrayBuffer.js b/node_modules/es-abstract/2021/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..03284729b3d4e77587ae9204577ebf42e5b1b884 --- /dev/null +++ b/node_modules/es-abstract/2021/DetachArrayBuffer.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2021/FlattenIntoArray.js b/node_modules/es-abstract/2021/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..0fb87bc6a39b028f45d6ca131333e9e398443935 --- /dev/null +++ b/node_modules/es-abstract/2021/FlattenIntoArray.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/11.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = LengthOfArrayLike(element); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2021/FromPropertyDescriptor.js b/node_modules/es-abstract/2021/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..c70f0c60e1ff8b16858f71af25b644f8d9a3d589 --- /dev/null +++ b/node_modules/es-abstract/2021/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var assertRecord = require('../helpers/assertRecord'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined') { + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2021/GetGlobalObject.js b/node_modules/es-abstract/2021/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2021/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2021/GetIterator.js b/node_modules/es-abstract/2021/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..672454abdbff3f738bfea8ca06a39ce88e849942 --- /dev/null +++ b/node_modules/es-abstract/2021/GetIterator.js @@ -0,0 +1,66 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $asyncIterator = GetIntrinsic('%Symbol.asyncIterator%', true); + +var inspect = require('object-inspect'); +var hasSymbols = require('has-symbols')(); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-getiterator + +module.exports = function GetIterator(obj, hint, method) { + var actualHint = hint; + if (arguments.length < 2) { + actualHint = 'sync'; + } + if (actualHint !== 'sync' && actualHint !== 'async') { + throw new $TypeError("Assertion failed: `hint` must be one of 'sync' or 'async', got " + inspect(hint)); + } + + var actualMethod = method; + if (arguments.length < 3) { + if (actualHint === 'async') { + if (hasSymbols && $asyncIterator) { + actualMethod = GetMethod(obj, $asyncIterator); + } + if (actualMethod === undefined) { + throw new $SyntaxError("async from sync iterators aren't currently supported"); + } + } else { + actualMethod = getIteratorMethod( + { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod, + IsArray: IsArray + }, + obj + ); + } + } + var iterator = Call(actualMethod, obj); + if (Type(iterator) !== 'Object') { + throw new $TypeError('iterator must return an object'); + } + + return iterator; + + // TODO: This should return an IteratorRecord + /* + var nextMethod = GetV(iterator, 'next'); + return { + '[[Iterator]]': iterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; + */ +}; diff --git a/node_modules/es-abstract/2021/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2021/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2021/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2021/GetV.js b/node_modules/es-abstract/2021/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2021/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2021/GetValueFromBuffer.js b/node_modules/es-abstract/2021/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8d3a2f4fc54239ca212915a513d02fc150c59cf1 --- /dev/null +++ b/node_modules/es-abstract/2021/GetValueFromBuffer.js @@ -0,0 +1,110 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $slice = callBound('Array.prototype.slice'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumeric = require('./RawBytesToNumeric'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table61 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $BigInt64: 8, + $BigUint64: 8, + $Float32: 4, + $Float64: 8 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || typeof table61['$' + type] !== 'number') { + throw new $TypeError('Assertion failed: `type` must be a Typed Array element type'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (order !== 'SeqCst' && order !== 'Unordered') { + throw new $TypeError('Assertion failed: `order` must be either `SeqCst` or `Unordered`'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = table61['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "BigInt64", "BigUint64", "Float32", or "Float64"'); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumeric(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2021/HasOwnProperty.js b/node_modules/es-abstract/2021/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2021/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2021/HourFromTime.js b/node_modules/es-abstract/2021/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2021/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2021/IsAccessorDescriptor.js b/node_modules/es-abstract/2021/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2021/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2021/IsCallable.js b/node_modules/es-abstract/2021/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2021/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2021/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2021/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2021/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2021/IsConcatSpreadable.js b/node_modules/es-abstract/2021/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2021/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2021/IsConstructor.js b/node_modules/es-abstract/2021/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2021/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2021/IsDataDescriptor.js b/node_modules/es-abstract/2021/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2021/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2021/IsIntegralNumber.js b/node_modules/es-abstract/2021/IsIntegralNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..644b936d910756ded2fb0bcc172048685c76b9dc --- /dev/null +++ b/node_modules/es-abstract/2021/IsIntegralNumber.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-isinteger + +module.exports = function IsIntegralNumber(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2021/IsPropertyKey.js b/node_modules/es-abstract/2021/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..aaeb6f9b6f83b5a39f1f53cec0edbf19cbc61170 --- /dev/null +++ b/node_modules/es-abstract/2021/IsPropertyKey.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; +}; diff --git a/node_modules/es-abstract/2021/IsRegExp.js b/node_modules/es-abstract/2021/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2021/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2021/IsSharedArrayBuffer.js b/node_modules/es-abstract/2021/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8e96e33f3c2dca5c15127f2ae83fc45861d548b9 --- /dev/null +++ b/node_modules/es-abstract/2021/IsSharedArrayBuffer.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2021/IsUnsignedElementType.js b/node_modules/es-abstract/2021/IsUnsignedElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ff194d73916d487ce951d1c7553b7aa5ab34cf --- /dev/null +++ b/node_modules/es-abstract/2021/IsUnsignedElementType.js @@ -0,0 +1,11 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype + +module.exports = function IsUnsignedElementType(type) { + return type === 'Uint8' + || type === 'Uint8C' + || type === 'Uint16' + || type === 'Uint32' + || type === 'BigUint64'; +}; diff --git a/node_modules/es-abstract/2021/IsValidIntegerIndex.js b/node_modules/es-abstract/2021/IsValidIntegerIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..830416312dad6bf3e99ec0e00aab0ad8fa23b90e --- /dev/null +++ b/node_modules/es-abstract/2021/IsValidIntegerIndex.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsIntegralNumber = require('./IsIntegralNumber'); + +var isNegativeZero = require('../helpers/isNegativeZero'); + +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/12.0/#sec-isvalidintegerindex + +module.exports = function IsValidIntegerIndex(O, index) { + // Assert: O is an Integer-Indexed exotic object. + var buffer = typedArrayBuffer(O); // step 1 + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: Type(index) is not Number'); + } + + if (IsDetachedBuffer(buffer)) { return false; } // step 2 + + if (!IsIntegralNumber(index)) { return false; } // step 3 + + if (isNegativeZero(index)) { return false; } // step 4 + + if (index < 0 || index >= O.length) { return false; } // step 5 + + return true; // step 6 +}; diff --git a/node_modules/es-abstract/2021/IsWordChar.js b/node_modules/es-abstract/2021/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..0df6b20249c345d6f85a5a9d255db20d2809d55f --- /dev/null +++ b/node_modules/es-abstract/2021/IsWordChar.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var IsIntegralNumber = require('./IsIntegralNumber'); +var Type = require('./Type'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/12.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!IsIntegralNumber(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsIntegralNumber(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2021/IterableToList.js b/node_modules/es-abstract/2021/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..320ab47128e2ee4c2de4ba67d68c16b7f272f868 --- /dev/null +++ b/node_modules/es-abstract/2021/IterableToList.js @@ -0,0 +1,29 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); +var $arrayPush = callBound('Array.prototype.push'); + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/12.0/#sec-iterabletolist + +module.exports = function IterableToList(items) { + var iterator; + if (arguments.length > 1) { + iterator = GetIterator(items, 'sync', arguments[1]); + } else { + iterator = GetIterator(items, 'sync'); + } + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + $arrayPush(values, nextValue); + } + } + return values; +}; diff --git a/node_modules/es-abstract/2021/IteratorComplete.js b/node_modules/es-abstract/2021/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2021/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2021/IteratorStep.js b/node_modules/es-abstract/2021/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2021/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2021/IteratorValue.js b/node_modules/es-abstract/2021/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2021/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2021/LengthOfArrayLike.js b/node_modules/es-abstract/2021/LengthOfArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..132c4d58480f74f2cb987dd997783c035d313a43 --- /dev/null +++ b/node_modules/es-abstract/2021/LengthOfArrayLike.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToLength = require('./ToLength'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-lengthofarraylike + +module.exports = function LengthOfArrayLike(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + return ToLength(Get(obj, 'length')); +}; + +// TODO: use this all over diff --git a/node_modules/es-abstract/2021/MakeTime.js b/node_modules/es-abstract/2021/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a11d07ef831315771e0e62afde939f2463b18d5a --- /dev/null +++ b/node_modules/es-abstract/2021/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); + +// https://262.ecma-international.org/12.0/#sec-maketime + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToIntegerOrInfinity(hour); + var m = ToIntegerOrInfinity(min); + var s = ToIntegerOrInfinity(sec); + var milli = ToIntegerOrInfinity(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2021/MonthFromTime.js b/node_modules/es-abstract/2021/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2021/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2021/NewPromiseCapability.js b/node_modules/es-abstract/2021/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2021/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2021/NormalCompletion.js b/node_modules/es-abstract/2021/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2021/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2021/NumberBitwiseOp.js b/node_modules/es-abstract/2021/NumberBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..11425ffded076a0f37bd06b3a4b2cc0964eede2b --- /dev/null +++ b/node_modules/es-abstract/2021/NumberBitwiseOp.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var ToInt32 = require('./ToInt32'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-numberbitwiseop + +module.exports = function NumberBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (Type(x) !== 'Number' || Type(y) !== 'Number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + var lnum = ToInt32(x); + var rnum = ToUint32(y); + if (op === '&') { + return lnum & rnum; + } + if (op === '|') { + return lnum | rnum; + } + return lnum ^ rnum; +}; diff --git a/node_modules/es-abstract/2021/NumberToBigInt.js b/node_modules/es-abstract/2021/NumberToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..9ed8ed9a9be5df66578faa95cc5896874969c6ee --- /dev/null +++ b/node_modules/es-abstract/2021/NumberToBigInt.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsIntegralNumber = require('./IsIntegralNumber'); +var Type = require('./Type'); + +// https://262.ecma-international.org/12.0/#sec-numbertobigint + +module.exports = function NumberToBigInt(number) { + if (Type(number) !== 'Number') { + throw new $TypeError('Assertion failed: `number` must be a String'); + } + if (!IsIntegralNumber(number)) { + throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + return $BigInt(number); +}; diff --git a/node_modules/es-abstract/2021/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2021/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2021/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2021/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..ba17b98872933ef285da579420e75fa18b072ce9 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryGetPrototypeOf.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $getProto = require('../helpers/getProto'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2021/OrdinaryHasInstance.js b/node_modules/es-abstract/2021/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2021/OrdinaryHasProperty.js b/node_modules/es-abstract/2021/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2021/OrdinaryObjectCreate.js b/node_modules/es-abstract/2021/OrdinaryObjectCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..140534083c5c78b6cba43ce916ce30e39efd5c9b --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryObjectCreate.js @@ -0,0 +1,56 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ObjectCreate = GetIntrinsic('%Object.create%', true); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +var forEach = require('../helpers/forEach'); + +var SLOT = require('internal-slot'); + +var hasProto = require('has-proto')(); + +// https://262.ecma-international.org/11.0/#sec-objectcreate + +module.exports = function OrdinaryObjectCreate(proto) { + if (proto !== null && Type(proto) !== 'Object') { + throw new $TypeError('Assertion failed: `proto` must be null or an object'); + } + var additionalInternalSlotsList = arguments.length < 2 ? [] : arguments[1]; + if (!IsArray(additionalInternalSlotsList)) { + throw new $TypeError('Assertion failed: `additionalInternalSlotsList` must be an Array'); + } + + // var internalSlotsList = ['[[Prototype]]', '[[Extensible]]']; // step 1 + // internalSlotsList.push(...additionalInternalSlotsList); // step 2 + // var O = MakeBasicObject(internalSlotsList); // step 3 + // setProto(O, proto); // step 4 + // return O; // step 5 + + var O; + if ($ObjectCreate) { + O = $ObjectCreate(proto); + } else if (hasProto) { + O = { __proto__: proto }; + } else { + if (proto === null) { + throw new $SyntaxError('native Object.create support is required to create null objects'); + } + var T = function T() {}; + T.prototype = proto; + O = new T(); + } + + if (additionalInternalSlotsList.length > 0) { + forEach(additionalInternalSlotsList, function (slot) { + SLOT.set(O, slot, void undefined); + }); + } + + return O; +}; diff --git a/node_modules/es-abstract/2021/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2021/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b72306c187b6e9f4355b399831a46e10fa7f61 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinarySetPrototypeOf.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $setProto = require('../helpers/setProto'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (Type(V) !== 'Object' && Type(V) !== 'Null') { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2021/OrdinaryToPrimitive.js b/node_modules/es-abstract/2021/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..e1dbe1427f8d87cba5e2c711fcb73144fa55ec33 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryToPrimitive.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* Type(hint) !== 'String' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (Type(result) !== 'Object') { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2021/QuoteJSONString.js b/node_modules/es-abstract/2021/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..1a7fae182435751a6938740e4149c6e30095a175 --- /dev/null +++ b/node_modules/es-abstract/2021/QuoteJSONString.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +var StringToCodePoints = require('./StringToCodePoints'); +var Type = require('./Type'); +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/12.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach(StringToCodePoints(value), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(C) || isTrailingSurrogate(C)) { + product += UnicodeEscape(C); + } else { + product += UTF16EncodeCodePoint(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2021/RegExpExec.js b/node_modules/es-abstract/2021/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2021/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2021/RequireObjectCoercible.js b/node_modules/es-abstract/2021/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9008359db8f9ac7107563f46c1aebc2258b8cb2b --- /dev/null +++ b/node_modules/es-abstract/2021/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../5/CheckObjectCoercible'); diff --git a/node_modules/es-abstract/2021/SameValue.js b/node_modules/es-abstract/2021/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2021/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2021/SameValueZero.js b/node_modules/es-abstract/2021/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2021/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2021/SetFunctionLength.js b/node_modules/es-abstract/2021/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..fbf9f2352ab66d475e974df9d59ef67eb8437290 --- /dev/null +++ b/node_modules/es-abstract/2021/SetFunctionLength.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (Type(length) !== 'Number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (length !== Infinity && (!isInteger(length) || length < 0)) { + throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2021/SetIntegrityLevel.js b/node_modules/es-abstract/2021/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2021/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2021/SetTypedArrayFromArrayLike.js b/node_modules/es-abstract/2021/SetTypedArrayFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..2d3f1e89c5b583c59dc15543587e42aee36c8729 --- /dev/null +++ b/node_modules/es-abstract/2021/SetTypedArrayFromArrayLike.js @@ -0,0 +1,127 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); + +var isInteger = require('../helpers/isInteger'); + +var Get = require('./Get'); +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); +var ToString = require('./ToString'); + +var table60Sizes = { + __proto__: null, + $Int8Array: 1, + $Uint8Array: 1, + $Uint8ClampedArray: 1, + $Int16Array: 2, + $Uint16Array: 2, + $Int32Array: 4, + $Uint32Array: 4, + $BigInt64Array: 8, + $BigUint64Array: 8, + $Float32Array: 4, + $Float64Array: 8 +}; + +var table60Types = { + __proto__: null, + $Int8Array: 'Int8', + $Uint8Array: 'Uint8', + $Uint8ClampedArray: 'Uint8C', + $Int16Array: 'Int16', + $Uint16Array: 'Uint16', + $Int32Array: 'Int32', + $Uint32Array: 'Uint32', + $BigInt64Array: 'BigInt64', + $BigUint64Array: 'BigUint64', + $Float32Array: 'Float32', + $Float64Array: 'Float64' +}; + +// https://262.ecma-international.org/12.0/#sec-settypedarrayfromarraylike + +module.exports = function SetTypedArrayFromArrayLike(target, targetOffset, source) { + var whichTarget = whichTypedArray(target); + if (!whichTarget) { + throw new $TypeError('Assertion failed: target must be a TypedArray instance'); + } + + if (targetOffset !== Infinity && (!isInteger(targetOffset) || targetOffset < 0)) { + throw new $TypeError('Assertion failed: targetOffset must be a non-negative integer or +Infinity'); + } + + if (isTypedArray(source)) { + throw new $TypeError('Assertion failed: source must not be a TypedArray instance'); // step 1 + } + + var targetBuffer = typedArrayBuffer(target); // step 2 + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 3 + } + + var targetLength = typedArrayLength(target); // step 4 + + var targetName = whichTarget; // step 5 + + var targetElementSize = table60Sizes['$' + targetName]; // step 6 + + var targetType = table60Types['$' + targetName]; // step 7 + + var targetByteOffset = typedArrayByteOffset(target); // step 8 + + var src = ToObject(source); // step 9 + + var srcLength = LengthOfArrayLike(src); // step 10 + + if (targetOffset === Infinity) { + throw new $RangeError('targetOffset must be a finite integer'); // step 11 + } + + if (srcLength + targetOffset > targetLength) { + throw new $RangeError('targetOffset + srcLength must be <= target.length'); // step 12 + } + + var targetByteIndex = (targetOffset * targetElementSize) + targetByteOffset; // step 13 + + var k = 0; // step 14 + + var limit = targetByteIndex + (targetElementSize * srcLength); // step 15 + + while (targetByteIndex < limit) { // step 16 + var Pk = ToString(k); // step 16.a + + var value = Get(src, Pk); // step 16.b + + if (IsBigIntElementType(targetType)) { + value = ToBigInt(value); // step 16.c + } else { + value = ToNumber(value); // step 16.d + } + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 16.e + } + + SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, 'Unordered'); // step 16.f + + k += 1; // step 16.g + + targetByteIndex += targetElementSize; // step 16.h + } +}; diff --git a/node_modules/es-abstract/2021/SpeciesConstructor.js b/node_modules/es-abstract/2021/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2021/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2021/SplitMatch.js b/node_modules/es-abstract/2021/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..a21cde6450617819e2bd861aa0fbb7dfd3ba60b9 --- /dev/null +++ b/node_modules/es-abstract/2021/SplitMatch.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/12.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (Type(R) !== 'String') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return 'not-matched'; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return 'not-matched'; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2021/StringCreate.js b/node_modules/es-abstract/2021/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2021/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2021/StringPad.js b/node_modules/es-abstract/2021/StringPad.js new file mode 100644 index 0000000000000000000000000000000000000000..cdf69001bb5bdc84a82d4b30da527138e1c9dc31 --- /dev/null +++ b/node_modules/es-abstract/2021/StringPad.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/11.0/#sec-stringpad + +module.exports = function StringPad(O, maxLength, fillString, placement) { + if (placement !== 'start' && placement !== 'end') { + throw new $TypeError('Assertion failed: `placement` must be "start" or "end"'); + } + var S = ToString(O); + var intMaxLength = ToLength(maxLength); + var stringLength = S.length; + if (intMaxLength <= stringLength) { + return S; + } + var filler = typeof fillString === 'undefined' ? ' ' : ToString(fillString); + if (filler === '') { + return S; + } + var fillLen = intMaxLength - stringLength; + + // the String value consisting of repeated concatenations of filler truncated to length fillLen. + var truncatedStringFiller = ''; + while (truncatedStringFiller.length < fillLen) { + truncatedStringFiller += filler; + } + truncatedStringFiller = $strSlice(truncatedStringFiller, 0, fillLen); + + if (placement === 'start') { + return truncatedStringFiller + S; + } + return S + truncatedStringFiller; +}; diff --git a/node_modules/es-abstract/2021/StringToCodePoints.js b/node_modules/es-abstract/2021/StringToCodePoints.js new file mode 100644 index 0000000000000000000000000000000000000000..f503ce1b47933696d1cd0bdebbd790e90025921a --- /dev/null +++ b/node_modules/es-abstract/2021/StringToCodePoints.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $push = callBound('Array.prototype.push'); + +var CodePointAt = require('./CodePointAt'); +var Type = require('./Type'); + +// https://262.ecma-international.org/12.0/#sec-stringtocodepoints + +module.exports = function StringToCodePoints(string) { + if (Type(string) !== 'String') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var codePoints = []; + var size = string.length; + var position = 0; + while (position < size) { + var cp = CodePointAt(string, position); + $push(codePoints, cp['[[CodePoint]]']); + position += cp['[[CodeUnitCount]]']; + } + return codePoints; +}; diff --git a/node_modules/es-abstract/2021/SymbolDescriptiveString.js b/node_modules/es-abstract/2021/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2021/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2021/ThrowCompletion.js b/node_modules/es-abstract/2021/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2021/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2021/TimeFromYear.js b/node_modules/es-abstract/2021/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2021/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2021/TimeString.js b/node_modules/es-abstract/2021/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..051c4728e2e495a323f9ed64acd3be8d25603b00 --- /dev/null +++ b/node_modules/es-abstract/2021/TimeString.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); +var Type = require('./Type'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2021/TimeWithinDay.js b/node_modules/es-abstract/2021/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2021/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2021/ToDateString.js b/node_modules/es-abstract/2021/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2021/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2021/ToInt16.js b/node_modules/es-abstract/2021/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2021/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2021/ToInt32.js b/node_modules/es-abstract/2021/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2021/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2021/ToString.js b/node_modules/es-abstract/2021/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2021/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2021/ToUint8Clamp.js b/node_modules/es-abstract/2021/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2021/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2021/TrimString.js b/node_modules/es-abstract/2021/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..113dcf82b82d823bee32c607bcd897bc6e36548a --- /dev/null +++ b/node_modules/es-abstract/2021/TrimString.js @@ -0,0 +1,29 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2021/Type.js b/node_modules/es-abstract/2021/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..555ca74ea51969958716accd635da40009319542 --- /dev/null +++ b/node_modules/es-abstract/2021/Type.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + if (typeof x === 'bigint') { + return 'BigInt'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2021/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2021/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2bfdff5eb705c2c866ad0623064a35be67b92b73 --- /dev/null +++ b/node_modules/es-abstract/2021/TypedArraySpeciesCreate.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2021/UnicodeEscape.js b/node_modules/es-abstract/2021/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..b708c90df0a05e9250f3dbbb9ac1044bb88b5d42 --- /dev/null +++ b/node_modules/es-abstract/2021/UnicodeEscape.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); + +var StringPad = require('./StringPad'); + +// https://262.ecma-international.org/11.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + StringPad($toLowerCase($numberToString(n, 16)), 4, '0', 'start'); +}; diff --git a/node_modules/es-abstract/2021/ValidateIntegerTypedArray.js b/node_modules/es-abstract/2021/ValidateIntegerTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..0bcc0aff4aa886d14995915869f65f073d3080f7 --- /dev/null +++ b/node_modules/es-abstract/2021/ValidateIntegerTypedArray.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var Type = require('./Type'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var whichTypedArray = require('which-typed-array'); + +// https://262.ecma-international.org/12.0/#sec-validateintegertypedarray + +var table60 = { + __proto__: null, + $Int8Array: 'Int8', + $Uint8Array: 'Uint8', + $Uint8ClampedArray: 'Uint8C', + $Int16Array: 'Int16', + $Uint16Array: 'Uint16', + $Int32Array: 'Int32', + $Uint32Array: 'Uint32', + $BigInt64Array: 'BigInt64', + $BigUint64Array: 'BigUint64', + $Float32Array: 'Float32', + $Float64Array: 'Float64' +}; + +module.exports = function ValidateIntegerTypedArray(typedArray) { + var waitable = arguments.length > 1 ? arguments[1] : false; // step 1 + + if (Type(waitable) !== 'Boolean') { + throw new $TypeError('Assertion failed: `waitable` must be a Boolean'); + } + + var buffer = ValidateTypedArray(typedArray); // step 2 + + var typeName = whichTypedArray(typedArray); // step 3 + + var type = table60['$' + typeName]; // step 4 + + if (waitable) { // step 5 + if (typeName !== 'Int32Array' && typeName !== 'BigInt64Array') { + throw new $TypeError('Assertion failed: `typedArray` must be an Int32Array or BigInt64Array when `waitable` is true'); // step 5.a + } + } else if (!IsUnclampedIntegerElementType(type) && !IsBigIntElementType(type)) { + throw new $TypeError('Assertion failed: `typedArray` must be an integer TypedArray'); // step 6.a + } + + return buffer; // step 7 +}; diff --git a/node_modules/es-abstract/2021/ValidateTypedArray.js b/node_modules/es-abstract/2021/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2021/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2021/WeekDay.js b/node_modules/es-abstract/2021/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2021/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2021/abs.js b/node_modules/es-abstract/2021/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2021/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2021/floor.js b/node_modules/es-abstract/2021/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..625548e936b95ca0735790d52c46f9bee5730558 --- /dev/null +++ b/node_modules/es-abstract/2021/floor.js @@ -0,0 +1,16 @@ +'use strict'; + +var Type = require('./Type'); + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/11.0/#eqn-floor + +module.exports = function floor(x) { + // return x - modulo(x, 1); + if (Type(x) === 'BigInt') { + return x; + } + return $floor(x); +}; diff --git a/node_modules/es-abstract/2021/max.js b/node_modules/es-abstract/2021/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2021/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2021/msFromTime.js b/node_modules/es-abstract/2021/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2021/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2021/thisBooleanValue.js b/node_modules/es-abstract/2021/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2021/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2021/thisNumberValue.js b/node_modules/es-abstract/2021/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2021/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2022/AddEntriesFromIterable.js b/node_modules/es-abstract/2022/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..5bea627fb5160cdb554ce44056112c90b47722f9 --- /dev/null +++ b/node_modules/es-abstract/2022/AddEntriesFromIterable.js @@ -0,0 +1,47 @@ +'use strict'; + +var inspect = require('object-inspect'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); +var Type = require('./Type'); + +// https://262.ecma-international.org/10.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable); + while (true) { // eslint-disable-line no-constant-condition + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (Type(nextItem) !== 'Object') { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2022/ApplyStringOrNumericBinaryOperator.js b/node_modules/es-abstract/2022/ApplyStringOrNumericBinaryOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..e5f997a39d09af338a6a314e28774f8b132d7438 --- /dev/null +++ b/node_modules/es-abstract/2022/ApplyStringOrNumericBinaryOperator.js @@ -0,0 +1,80 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var HasOwnProperty = require('./HasOwnProperty'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var NumberAdd = require('./Number/add'); +var NumberBitwiseAND = require('./Number/bitwiseAND'); +var NumberBitwiseOR = require('./Number/bitwiseOR'); +var NumberBitwiseXOR = require('./Number/bitwiseXOR'); +var NumberDivide = require('./Number/divide'); +var NumberExponentiate = require('./Number/exponentiate'); +var NumberLeftShift = require('./Number/leftShift'); +var NumberMultiply = require('./Number/multiply'); +var NumberRemainder = require('./Number/remainder'); +var NumberSignedRightShift = require('./Number/signedRightShift'); +var NumberSubtract = require('./Number/subtract'); +var NumberUnsignedRightShift = require('./Number/unsignedRightShift'); +var BigIntAdd = require('./BigInt/add'); +var BigIntBitwiseAND = require('./BigInt/bitwiseAND'); +var BigIntBitwiseOR = require('./BigInt/bitwiseOR'); +var BigIntBitwiseXOR = require('./BigInt/bitwiseXOR'); +var BigIntDivide = require('./BigInt/divide'); +var BigIntExponentiate = require('./BigInt/exponentiate'); +var BigIntLeftShift = require('./BigInt/leftShift'); +var BigIntMultiply = require('./BigInt/multiply'); +var BigIntRemainder = require('./BigInt/remainder'); +var BigIntSignedRightShift = require('./BigInt/signedRightShift'); +var BigIntSubtract = require('./BigInt/subtract'); +var BigIntUnsignedRightShift = require('./BigInt/unsignedRightShift'); + +// https://262.ecma-international.org/12.0/#sec-applystringornumericbinaryoperator + +// https://262.ecma-international.org/12.0/#step-applystringornumericbinaryoperator-operations-table +var table = { + '**': [NumberExponentiate, BigIntExponentiate], + '*': [NumberMultiply, BigIntMultiply], + '/': [NumberDivide, BigIntDivide], + '%': [NumberRemainder, BigIntRemainder], + '+': [NumberAdd, BigIntAdd], + '-': [NumberSubtract, BigIntSubtract], + '<<': [NumberLeftShift, BigIntLeftShift], + '>>': [NumberSignedRightShift, BigIntSignedRightShift], + '>>>': [NumberUnsignedRightShift, BigIntUnsignedRightShift], + '&': [NumberBitwiseAND, BigIntBitwiseAND], + '^': [NumberBitwiseXOR, BigIntBitwiseXOR], + '|': [NumberBitwiseOR, BigIntBitwiseOR] +}; + +module.exports = function ApplyStringOrNumericBinaryOperator(lval, opText, rval) { + if (Type(opText) !== 'String' || !HasOwnProperty(table, opText)) { + throw new $TypeError('Assertion failed: `opText` must be a valid operation string'); + } + if (opText === '+') { + var lprim = ToPrimitive(lval); + var rprim = ToPrimitive(rval); + if (Type(lprim) === 'String' || Type(rprim) === 'String') { + var lstr = ToString(lprim); + var rstr = ToString(rprim); + return lstr + rstr; + } + /* eslint no-param-reassign: 1 */ + lval = lprim; + rval = rprim; + } + var lnum = ToNumeric(lval); + var rnum = ToNumeric(rval); + var T = Type(lnum); + if (T !== Type(rnum)) { + throw new $TypeError('types of ' + lnum + ' and ' + rnum + ' differ'); + } + var Operation = table[opText][T === 'BigInt' ? 1 : 0]; + return Operation(lnum, rnum); +}; diff --git a/node_modules/es-abstract/2022/ArraySetLength.js b/node_modules/es-abstract/2022/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2022/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2022/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2022/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..5618539dd6fb0d80d53105fcae16dfc946cf187b --- /dev/null +++ b/node_modules/es-abstract/2022/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bind/callBound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); +var Type = require('./Type'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (Type(result) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2022/BigInt/add.js b/node_modules/es-abstract/2022/BigInt/add.js new file mode 100644 index 0000000000000000000000000000000000000000..22b5db4b32d2c9dc6ee3562cb998d4376cada88b --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/add.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add + +module.exports = function BigIntAdd(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/bitwiseAND.js b/node_modules/es-abstract/2022/BigInt/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..83cd2c3ca9edc6de1fa2d30055f4c2daf15aa71e --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/bitwiseAND.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND + +module.exports = function BigIntBitwiseAND(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/bitwiseNOT.js b/node_modules/es-abstract/2022/BigInt/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..9a444dfeab8d635d8355db0e0644a74250776136 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/bitwiseNOT.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT + +module.exports = function BigIntBitwiseNOT(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + return -x - $BigInt(1); +}; diff --git a/node_modules/es-abstract/2022/BigInt/bitwiseOR.js b/node_modules/es-abstract/2022/BigInt/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..3c1b57193ef48115b08bc6bf1d5eb55c69dbb965 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/bitwiseOR.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR + +module.exports = function BigIntBitwiseOR(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/bitwiseXOR.js b/node_modules/es-abstract/2022/BigInt/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..45f8217efb83cd6ad102a8cbcb01cb534bdab133 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/bitwiseXOR.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR + +module.exports = function BigIntBitwiseXOR(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/divide.js b/node_modules/es-abstract/2022/BigInt/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..5706e7d72e4243301af168763d9c035de9cc0e98 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/divide.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide + +module.exports = function BigIntDivide(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + if (y === $BigInt(0)) { + throw new $RangeError('Division by zero'); + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/equal.js b/node_modules/es-abstract/2022/BigInt/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..a28826d67ff75d4158a5d4fbb9e3a8e38b7d5160 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/equal.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal + +module.exports = function BigIntEqual(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/exponentiate.js b/node_modules/es-abstract/2022/BigInt/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..2365838c269b68e03f489f9e26b5a9828bd5edf2 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/exponentiate.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate + +module.exports = function BigIntExponentiate(base, exponent) { + if (Type(base) !== 'BigInt' || Type(exponent) !== 'BigInt') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts'); + } + if (exponent < $BigInt(0)) { + throw new $RangeError('Exponent must be positive'); + } + if (/* base === $BigInt(0) && */ exponent === $BigInt(0)) { + return $BigInt(1); + } + + var square = base; + var remaining = exponent; + while (remaining > $BigInt(0)) { + square += exponent; + --remaining; // eslint-disable-line no-plusplus + } + return square; +}; diff --git a/node_modules/es-abstract/2022/BigInt/index.js b/node_modules/es-abstract/2022/BigInt/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2022/BigInt/leftShift.js b/node_modules/es-abstract/2022/BigInt/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..d2a570223e22c29d6196a51153109aad2f420b3e --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/leftShift.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift + +module.exports = function BigIntLeftShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x << y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/lessThan.js b/node_modules/es-abstract/2022/BigInt/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..0b3cd6ba029e8ee1d8e22e0230d06b68255c4b87 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/lessThan.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan + +module.exports = function BigIntLessThan(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/multiply.js b/node_modules/es-abstract/2022/BigInt/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..6e5d56c83ea0b9bfbe2801895c732e0aff77f922 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/multiply.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply + +module.exports = function BigIntMultiply(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/remainder.js b/node_modules/es-abstract/2022/BigInt/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..d2dc678caf6bdeff4a0dfbc7819129231c0b040c --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/remainder.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder + +module.exports = function BigIntRemainder(n, d) { + if (Type(n) !== 'BigInt' || Type(d) !== 'BigInt') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts'); + } + + if (d === zero) { + throw new $RangeError('Division by zero'); + } + + if (n === zero) { + return zero; + } + + // shortcut for the actual spec mechanics + return n % d; +}; diff --git a/node_modules/es-abstract/2022/BigInt/sameValue.js b/node_modules/es-abstract/2022/BigInt/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..63ff06393bba6fe77255bb577ba40c84a789aed4 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/sameValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValue + +module.exports = function BigIntSameValue(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/sameValueZero.js b/node_modules/es-abstract/2022/BigInt/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..39f262c6da2f26b7f576d28ce75e4ddffa05498b --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/sameValueZero.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValueZero + +module.exports = function BigIntSameValueZero(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/signedRightShift.js b/node_modules/es-abstract/2022/BigInt/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..f63c642f0cda7f1c8079b674dd8a700a018e13cb --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/signedRightShift.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntLeftShift = require('./leftShift'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift + +module.exports = function BigIntSignedRightShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntLeftShift(x, -y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/subtract.js b/node_modules/es-abstract/2022/BigInt/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..0490784f679cd079bdacb6019c20b72d1c82195c --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/subtract.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract + +module.exports = function BigIntSubtract(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x - y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/toString.js b/node_modules/es-abstract/2022/BigInt/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..858d95545475ea5c86c2c62b0d2a1c0476fb1d53 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/toString.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring + +module.exports = function BigIntToString(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` must be a BigInt'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2022/BigInt/unaryMinus.js b/node_modules/es-abstract/2022/BigInt/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..ee0f7ef1962c387400f371c970cef8fba071b616 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/unaryMinus.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus + +module.exports = function BigIntUnaryMinus(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + + if (x === zero) { + return zero; + } + + return -x; +}; diff --git a/node_modules/es-abstract/2022/BigInt/unsignedRightShift.js b/node_modules/es-abstract/2022/BigInt/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..7ad94f7a88d5f49e9125028d497112317d25783e --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/unsignedRightShift.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift + +module.exports = function BigIntUnsignedRightShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + throw new $TypeError('BigInts have no unsigned right shift, use >> instead'); +}; diff --git a/node_modules/es-abstract/2022/BigIntBitwiseOp.js b/node_modules/es-abstract/2022/BigIntBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..0b1c03a911b68cf88fab0a9156e7ac56b2ef3567 --- /dev/null +++ b/node_modules/es-abstract/2022/BigIntBitwiseOp.js @@ -0,0 +1,66 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +// var $BigInt = GetIntrinsic('%BigInt%', true); +// var $pow = GetIntrinsic('%Math.pow%'); + +// var BinaryAnd = require('./BinaryAnd'); +// var BinaryOr = require('./BinaryOr'); +// var BinaryXor = require('./BinaryXor'); +var Type = require('./Type'); +// var modulo = require('./modulo'); + +// var zero = $BigInt && $BigInt(0); +// var negOne = $BigInt && $BigInt(-1); +// var two = $BigInt && $BigInt(2); + +// https://262.ecma-international.org/11.0/#sec-bigintbitwiseop + +module.exports = function BigIntBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('`x` and `y` must be BigInts'); + } + + if (op === '&') { + return x & y; + } + if (op === '|') { + return x | y; + } + return x ^ y; + /* + var result = zero; + var shift = 0; + while (x !== zero && x !== negOne && y !== zero && y !== negOne) { + var xDigit = modulo(x, two); + var yDigit = modulo(y, two); + if (op === '&') { + result += $pow(2, shift) * BinaryAnd(xDigit, yDigit); + } else if (op === '|') { + result += $pow(2, shift) * BinaryOr(xDigit, yDigit); + } else if (op === '^') { + result += $pow(2, shift) * BinaryXor(xDigit, yDigit); + } + shift += 1; + x = (x - xDigit) / two; + y = (y - yDigit) / two; + } + var tmp; + if (op === '&') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else if (op === '|') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else { + tmp = BinaryXor(modulo(x, two), modulo(y, two)); + } + if (tmp !== 0) { + result -= $pow(2, shift); + } + return result; + */ +}; diff --git a/node_modules/es-abstract/2022/BinaryAnd.js b/node_modules/es-abstract/2022/BinaryAnd.js new file mode 100644 index 0000000000000000000000000000000000000000..c617f388dea72e00af72319427af0554e296aad9 --- /dev/null +++ b/node_modules/es-abstract/2022/BinaryAnd.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; diff --git a/node_modules/es-abstract/2022/BinaryOr.js b/node_modules/es-abstract/2022/BinaryOr.js new file mode 100644 index 0000000000000000000000000000000000000000..6de0955f1a6d349fc321e9ea9d1020c939abd28c --- /dev/null +++ b/node_modules/es-abstract/2022/BinaryOr.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryor + +module.exports = function BinaryOr(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x | y; +}; diff --git a/node_modules/es-abstract/2022/BinaryXor.js b/node_modules/es-abstract/2022/BinaryXor.js new file mode 100644 index 0000000000000000000000000000000000000000..189d7d8469ce1f6f509b21bfb5e6a06ae849cd70 --- /dev/null +++ b/node_modules/es-abstract/2022/BinaryXor.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryxor + +module.exports = function BinaryXor(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x ^ y; +}; diff --git a/node_modules/es-abstract/2022/ByteListBitwiseOp.js b/node_modules/es-abstract/2022/ByteListBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..67f4cecb59bac39e28f28b8f305b8f2d2ec18f0d --- /dev/null +++ b/node_modules/es-abstract/2022/ByteListBitwiseOp.js @@ -0,0 +1,44 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $push = callBound('Array.prototype.push'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistbitwiseop + +module.exports = function ByteListBitwiseOp(op, xBytes, yBytes) { + if (op !== '&' && op !== '^' && op !== '|') { + throw new $TypeError('Assertion failed: `op` must be `&`, `^`, or `|`'); + } + if (!IsArray(xBytes) || !IsArray(yBytes) || xBytes.length !== yBytes.length) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + + var result = []; + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + var resultByte; + if (op === '&') { + resultByte = xByte & yByte; + } else if (op === '^') { + resultByte = xByte ^ yByte; + } else { + resultByte = xByte | yByte; + } + $push(result, resultByte); + } + + return result; +}; diff --git a/node_modules/es-abstract/2022/ByteListEqual.js b/node_modules/es-abstract/2022/ByteListEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..489ddc224e6678e32474b3900c55bbb0c6202ff0 --- /dev/null +++ b/node_modules/es-abstract/2022/ByteListEqual.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistequal + +module.exports = function ByteListEqual(xBytes, yBytes) { + if (!IsArray(xBytes) || !IsArray(yBytes)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + + if (xBytes.length !== yBytes.length) { + return false; + } + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + if (xByte !== yByte) { + return false; + } + } + return true; +}; diff --git a/node_modules/es-abstract/2022/CodePointsToString.js b/node_modules/es-abstract/2022/CodePointsToString.js new file mode 100644 index 0000000000000000000000000000000000000000..6d7cd854b9d8536a9d6c0f09d484dad84b5c2f2e --- /dev/null +++ b/node_modules/es-abstract/2022/CodePointsToString.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/12.0/#sec-codepointstostring + +module.exports = function CodePointsToString(text) { + if (!IsArray(text)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + var result = ''; + forEach(text, function (cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + result += UTF16EncodeCodePoint(cp); + }); + return result; +}; diff --git a/node_modules/es-abstract/2022/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2022/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..64540dd6e3d71bf6d195589ff569874ff126fc12 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateAsyncFromSyncIterator.js @@ -0,0 +1,121 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); + +var assertRecord = require('../helpers/assertRecord'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord['[[Iterator]]'], value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord['[[Iterator]]']);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/11.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + assertRecord(Type, 'Iterator Record', 'syncIteratorRecord', syncIteratorRecord); + + // var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2022/CreateDataProperty.js b/node_modules/es-abstract/2022/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2022/CreateHTML.js b/node_modules/es-abstract/2022/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2022/CreateMethodProperty.js b/node_modules/es-abstract/2022/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2022/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2022/CreateNonEnumerableDataPropertyOrThrow.js b/node_modules/es-abstract/2022/CreateNonEnumerableDataPropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..59a16ef00455b61e93ba72ebcb734906fc29bfcd --- /dev/null +++ b/node_modules/es-abstract/2022/CreateNonEnumerableDataPropertyOrThrow.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/13.0/#sec-createnonenumerabledatapropertyorthrow + +module.exports = function CreateNonEnumerableDataPropertyOrThrow(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefinePropertyOrThrow(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2022/CreateRegExpStringIterator.js b/node_modules/es-abstract/2022/CreateRegExpStringIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..cdfae56216ba75dee3fb62db722c22e9b293a99f --- /dev/null +++ b/node_modules/es-abstract/2022/CreateRegExpStringIterator.js @@ -0,0 +1,100 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); +var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var CreateMethodProperty = require('./CreateMethodProperty'); +var Get = require('./Get'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var RegExpExec = require('./RegExpExec'); +var Set = require('./Set'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); +var setToStringTag = require('es-set-tostringtag'); + +var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) { + if (Type(S) !== 'String') { + throw new $TypeError('`S` must be a string'); + } + if (Type(global) !== 'Boolean') { + throw new $TypeError('`global` must be a boolean'); + } + if (Type(fullUnicode) !== 'Boolean') { + throw new $TypeError('`fullUnicode` must be a boolean'); + } + SLOT.set(this, '[[IteratingRegExp]]', R); + SLOT.set(this, '[[IteratedString]]', S); + SLOT.set(this, '[[Global]]', global); + SLOT.set(this, '[[Unicode]]', fullUnicode); + SLOT.set(this, '[[Done]]', false); +}; + +if (IteratorPrototype) { + RegExpStringIterator.prototype = OrdinaryObjectCreate(IteratorPrototype); +} + +var RegExpStringIteratorNext = function next() { + var O = this; // eslint-disable-line no-invalid-this + if (Type(O) !== 'Object') { + throw new $TypeError('receiver must be an object'); + } + if ( + !(O instanceof RegExpStringIterator) + || !SLOT.has(O, '[[IteratingRegExp]]') + || !SLOT.has(O, '[[IteratedString]]') + || !SLOT.has(O, '[[Global]]') + || !SLOT.has(O, '[[Unicode]]') + || !SLOT.has(O, '[[Done]]') + ) { + throw new $TypeError('"this" value must be a RegExpStringIterator instance'); + } + if (SLOT.get(O, '[[Done]]')) { + return CreateIterResultObject(undefined, true); + } + var R = SLOT.get(O, '[[IteratingRegExp]]'); + var S = SLOT.get(O, '[[IteratedString]]'); + var global = SLOT.get(O, '[[Global]]'); + var fullUnicode = SLOT.get(O, '[[Unicode]]'); + var match = RegExpExec(R, S); + if (match === null) { + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(undefined, true); + } + if (global) { + var matchStr = ToString(Get(match, '0')); + if (matchStr === '') { + var thisIndex = ToLength(Get(R, 'lastIndex')); + var nextIndex = AdvanceStringIndex(S, thisIndex, fullUnicode); + Set(R, 'lastIndex', nextIndex, true); + } + return CreateIterResultObject(match, false); + } + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(match, false); +}; +CreateMethodProperty(RegExpStringIterator.prototype, 'next', RegExpStringIteratorNext); + +if (hasSymbols) { + setToStringTag(RegExpStringIterator.prototype, 'RegExp String Iterator'); + + if (Symbol.iterator && typeof RegExpStringIterator.prototype[Symbol.iterator] !== 'function') { + var iteratorFn = function SymbolIterator() { + return this; + }; + CreateMethodProperty(RegExpStringIterator.prototype, Symbol.iterator, iteratorFn); + } +} + +// https://262.ecma-international.org/11.0/#sec-createregexpstringiterator +module.exports = function CreateRegExpStringIterator(R, S, global, fullUnicode) { + // assert R.global === global && R.unicode === fullUnicode? + return new RegExpStringIterator(R, S, global, fullUnicode); +}; diff --git a/node_modules/es-abstract/2022/DateFromTime.js b/node_modules/es-abstract/2022/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2022/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2022/DateString.js b/node_modules/es-abstract/2022/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..939c14c0c87ef6b1d8ebc09e936e6c4e86e793c5 --- /dev/null +++ b/node_modules/es-abstract/2022/DateString.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var Type = require('./Type'); +var WeekDay = require('./WeekDay'); +var MonthFromTime = require('./MonthFromTime'); +var YearFromTime = require('./YearFromTime'); +var DateFromTime = require('./DateFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2022/DayFromYear.js b/node_modules/es-abstract/2022/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2022/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2022/DefinePropertyOrThrow.js b/node_modules/es-abstract/2022/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2022/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2022/DeletePropertyOrThrow.js b/node_modules/es-abstract/2022/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2022/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2022/DetachArrayBuffer.js b/node_modules/es-abstract/2022/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..03284729b3d4e77587ae9204577ebf42e5b1b884 --- /dev/null +++ b/node_modules/es-abstract/2022/DetachArrayBuffer.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2022/FlattenIntoArray.js b/node_modules/es-abstract/2022/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..0fb87bc6a39b028f45d6ca131333e9e398443935 --- /dev/null +++ b/node_modules/es-abstract/2022/FlattenIntoArray.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/11.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = LengthOfArrayLike(element); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2022/GetGlobalObject.js b/node_modules/es-abstract/2022/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2022/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2022/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2022/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2022/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2022/GetV.js b/node_modules/es-abstract/2022/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2022/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2022/GetValueFromBuffer.js b/node_modules/es-abstract/2022/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8d3a2f4fc54239ca212915a513d02fc150c59cf1 --- /dev/null +++ b/node_modules/es-abstract/2022/GetValueFromBuffer.js @@ -0,0 +1,110 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $slice = callBound('Array.prototype.slice'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumeric = require('./RawBytesToNumeric'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table61 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $BigInt64: 8, + $BigUint64: 8, + $Float32: 4, + $Float64: 8 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || typeof table61['$' + type] !== 'number') { + throw new $TypeError('Assertion failed: `type` must be a Typed Array element type'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (order !== 'SeqCst' && order !== 'Unordered') { + throw new $TypeError('Assertion failed: `order` must be either `SeqCst` or `Unordered`'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = table61['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "BigInt64", "BigUint64", "Float32", or "Float64"'); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumeric(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2022/HasOwnProperty.js b/node_modules/es-abstract/2022/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2022/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2022/HourFromTime.js b/node_modules/es-abstract/2022/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2022/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2022/IsAccessorDescriptor.js b/node_modules/es-abstract/2022/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2022/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2022/IsCallable.js b/node_modules/es-abstract/2022/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2022/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2022/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2022/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..48e719f3c1e515175311d0f2fe599b4743f43062 --- /dev/null +++ b/node_modules/es-abstract/2022/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/13.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, '', Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2022/IsConcatSpreadable.js b/node_modules/es-abstract/2022/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2022/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2022/IsConstructor.js b/node_modules/es-abstract/2022/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2022/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2022/IsDataDescriptor.js b/node_modules/es-abstract/2022/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2022/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2022/IsIntegralNumber.js b/node_modules/es-abstract/2022/IsIntegralNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..644b936d910756ded2fb0bcc172048685c76b9dc --- /dev/null +++ b/node_modules/es-abstract/2022/IsIntegralNumber.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-isinteger + +module.exports = function IsIntegralNumber(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2022/IsLooselyEqual.js b/node_modules/es-abstract/2022/IsLooselyEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..9d254ba68cfaafd1c39cf785e1f77439747e6dd2 --- /dev/null +++ b/node_modules/es-abstract/2022/IsLooselyEqual.js @@ -0,0 +1,58 @@ +'use strict'; + +var isFinite = require('../helpers/isFinite'); + +var IsStrictlyEqual = require('./IsStrictlyEqual'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/13.0/#sec-islooselyequal + +module.exports = function IsLooselyEqual(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return IsStrictlyEqual(x, y); + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return IsLooselyEqual(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return IsLooselyEqual(ToNumber(x), y); + } + if (xType === 'BigInt' && yType === 'String') { + var n = StringToBigInt(y); + if (typeof n === 'undefined') { + return false; + } + return IsLooselyEqual(x, n); + } + if (xType === 'String' && yType === 'BigInt') { + return IsLooselyEqual(y, x); + } + if (xType === 'Boolean') { + return IsLooselyEqual(ToNumber(x), y); + } + if (yType === 'Boolean') { + return IsLooselyEqual(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'Symbol' || xType === 'BigInt') && yType === 'Object') { + return IsLooselyEqual(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol' || yType === 'BigInt')) { + return IsLooselyEqual(ToPrimitive(x), y); + } + if ((xType === 'BigInt' && yType === 'Number') || (xType === 'Number' && yType === 'BigInt')) { + if (!isFinite(x) || !isFinite(y)) { + return false; + } + // eslint-disable-next-line eqeqeq + return x == y; // shortcut for step 13.b. + } + return false; +}; diff --git a/node_modules/es-abstract/2022/IsPropertyKey.js b/node_modules/es-abstract/2022/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..aaeb6f9b6f83b5a39f1f53cec0edbf19cbc61170 --- /dev/null +++ b/node_modules/es-abstract/2022/IsPropertyKey.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; +}; diff --git a/node_modules/es-abstract/2022/IsRegExp.js b/node_modules/es-abstract/2022/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2022/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2022/IsSharedArrayBuffer.js b/node_modules/es-abstract/2022/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8e96e33f3c2dca5c15127f2ae83fc45861d548b9 --- /dev/null +++ b/node_modules/es-abstract/2022/IsSharedArrayBuffer.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2022/IsStringWellFormedUnicode.js b/node_modules/es-abstract/2022/IsStringWellFormedUnicode.js new file mode 100644 index 0000000000000000000000000000000000000000..72213f659f67abc3d65ab7bab1f13e7ff2cd3a33 --- /dev/null +++ b/node_modules/es-abstract/2022/IsStringWellFormedUnicode.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var CodePointAt = require('./CodePointAt'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/13.0/#sec-isstringwellformedunicode + +module.exports = function IsStringWellFormedUnicode(string) { + if (Type(string) !== 'String') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var strLen = string.length; // step 1 + var k = 0; // step 2 + while (k !== strLen) { // step 3 + var cp = CodePointAt(string, k); // step 3.a + if (cp['[[IsUnpairedSurrogate]]']) { + return false; // step 3.b + } + k += cp['[[CodeUnitCount]]']; // step 3.c + } + return true; // step 4 +}; diff --git a/node_modules/es-abstract/2022/IsUnsignedElementType.js b/node_modules/es-abstract/2022/IsUnsignedElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ff194d73916d487ce951d1c7553b7aa5ab34cf --- /dev/null +++ b/node_modules/es-abstract/2022/IsUnsignedElementType.js @@ -0,0 +1,11 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype + +module.exports = function IsUnsignedElementType(type) { + return type === 'Uint8' + || type === 'Uint8C' + || type === 'Uint16' + || type === 'Uint32' + || type === 'BigUint64'; +}; diff --git a/node_modules/es-abstract/2022/IsValidIntegerIndex.js b/node_modules/es-abstract/2022/IsValidIntegerIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..830416312dad6bf3e99ec0e00aab0ad8fa23b90e --- /dev/null +++ b/node_modules/es-abstract/2022/IsValidIntegerIndex.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsIntegralNumber = require('./IsIntegralNumber'); + +var isNegativeZero = require('../helpers/isNegativeZero'); + +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/12.0/#sec-isvalidintegerindex + +module.exports = function IsValidIntegerIndex(O, index) { + // Assert: O is an Integer-Indexed exotic object. + var buffer = typedArrayBuffer(O); // step 1 + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: Type(index) is not Number'); + } + + if (IsDetachedBuffer(buffer)) { return false; } // step 2 + + if (!IsIntegralNumber(index)) { return false; } // step 3 + + if (isNegativeZero(index)) { return false; } // step 4 + + if (index < 0 || index >= O.length) { return false; } // step 5 + + return true; // step 6 +}; diff --git a/node_modules/es-abstract/2022/IsWordChar.js b/node_modules/es-abstract/2022/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..0df6b20249c345d6f85a5a9d255db20d2809d55f --- /dev/null +++ b/node_modules/es-abstract/2022/IsWordChar.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var IsIntegralNumber = require('./IsIntegralNumber'); +var Type = require('./Type'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/12.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!IsIntegralNumber(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsIntegralNumber(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2022/IterableToList.js b/node_modules/es-abstract/2022/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..320ab47128e2ee4c2de4ba67d68c16b7f272f868 --- /dev/null +++ b/node_modules/es-abstract/2022/IterableToList.js @@ -0,0 +1,29 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); +var $arrayPush = callBound('Array.prototype.push'); + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/12.0/#sec-iterabletolist + +module.exports = function IterableToList(items) { + var iterator; + if (arguments.length > 1) { + iterator = GetIterator(items, 'sync', arguments[1]); + } else { + iterator = GetIterator(items, 'sync'); + } + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + $arrayPush(values, nextValue); + } + } + return values; +}; diff --git a/node_modules/es-abstract/2022/IteratorComplete.js b/node_modules/es-abstract/2022/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2022/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2022/IteratorStep.js b/node_modules/es-abstract/2022/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2022/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2022/IteratorValue.js b/node_modules/es-abstract/2022/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2022/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2022/LengthOfArrayLike.js b/node_modules/es-abstract/2022/LengthOfArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..132c4d58480f74f2cb987dd997783c035d313a43 --- /dev/null +++ b/node_modules/es-abstract/2022/LengthOfArrayLike.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToLength = require('./ToLength'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-lengthofarraylike + +module.exports = function LengthOfArrayLike(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + return ToLength(Get(obj, 'length')); +}; + +// TODO: use this all over diff --git a/node_modules/es-abstract/2022/MakeMatchIndicesIndexPairArray.js b/node_modules/es-abstract/2022/MakeMatchIndicesIndexPairArray.js new file mode 100644 index 0000000000000000000000000000000000000000..962f5d8be8411a244e180f0c8f5ae2dd516ace2d --- /dev/null +++ b/node_modules/es-abstract/2022/MakeMatchIndicesIndexPairArray.js @@ -0,0 +1,69 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var ArrayCreate = require('./ArrayCreate'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var GetMatchIndexPair = require('./GetMatchIndexPair'); +var IsArray = require('./IsArray'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var every = require('../helpers/every'); +var isMatchRecord = require('../helpers/isMatchRecord'); + +var isStringOrUndefined = function isStringOrUndefined(s) { + return typeof s === 'undefined' || typeof s === 'string'; +}; + +var isMatchRecordOrUndefined = function isMatchRecordOrUndefined(m) { + return typeof m === 'undefined' || isMatchRecord(m); +}; + +var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1; + +// https://262.ecma-international.org/13.0/#sec-getmatchindexpair + +module.exports = function MakeMatchIndicesIndexPairArray(S, indices, groupNames, hasGroups) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!IsArray(indices) || !every(indices, isMatchRecordOrUndefined)) { + throw new $TypeError('Assertion failed: `indices` must be a List of either Match Records or `undefined`'); + } + if (!IsArray(groupNames) || !every(groupNames, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `groupNames` must be a List of either Strings or `undefined`'); + } + if (Type(hasGroups) !== 'Boolean') { + throw new $TypeError('Assertion failed: `hasGroups` must be a Boolean'); + } + + var n = indices.length; // step 1 + if (!(n < MAX_ARRAY_LENGTH)) { + throw new $TypeError('Assertion failed: `indices` length must be less than the max array size, 2**32 - 1'); + } + if (groupNames.length !== n - 1) { + throw new $TypeError('Assertion failed: `groupNames` must have exactly one fewer item than `indices`'); + } + + var A = ArrayCreate(n); // step 5 + var groups = hasGroups ? OrdinaryObjectCreate(null) : void undefined; // step 6-7 + CreateDataPropertyOrThrow(A, 'groups', groups); // step 8 + + for (var i = 0; i < n; i += 1) { // step 9 + var matchIndices = indices[i]; // step 9.a + // eslint-disable-next-line no-negated-condition + var matchIndexPair = typeof matchIndices !== 'undefined' ? GetMatchIndexPair(S, matchIndices) : void undefined; // step 9.b-9.c + CreateDataPropertyOrThrow(A, ToString(i), matchIndexPair); // step 9.d + if (i > 0 && typeof groupNames[i - 1] !== 'undefined') { // step 9.e + if (!groups) { + throw new $TypeError('if `hasGroups` is `false`, `groupNames` can only contain `undefined` values'); + } + CreateDataPropertyOrThrow(groups, groupNames[i - 1], matchIndexPair); // step 9.e.i + } + } + return A; // step 10 +}; diff --git a/node_modules/es-abstract/2022/MonthFromTime.js b/node_modules/es-abstract/2022/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2022/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2022/NewPromiseCapability.js b/node_modules/es-abstract/2022/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2022/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2022/NormalCompletion.js b/node_modules/es-abstract/2022/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2022/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2022/NumberBitwiseOp.js b/node_modules/es-abstract/2022/NumberBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..11425ffded076a0f37bd06b3a4b2cc0964eede2b --- /dev/null +++ b/node_modules/es-abstract/2022/NumberBitwiseOp.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var ToInt32 = require('./ToInt32'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-numberbitwiseop + +module.exports = function NumberBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (Type(x) !== 'Number' || Type(y) !== 'Number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + var lnum = ToInt32(x); + var rnum = ToUint32(y); + if (op === '&') { + return lnum & rnum; + } + if (op === '|') { + return lnum | rnum; + } + return lnum ^ rnum; +}; diff --git a/node_modules/es-abstract/2022/NumberToBigInt.js b/node_modules/es-abstract/2022/NumberToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..9ed8ed9a9be5df66578faa95cc5896874969c6ee --- /dev/null +++ b/node_modules/es-abstract/2022/NumberToBigInt.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsIntegralNumber = require('./IsIntegralNumber'); +var Type = require('./Type'); + +// https://262.ecma-international.org/12.0/#sec-numbertobigint + +module.exports = function NumberToBigInt(number) { + if (Type(number) !== 'Number') { + throw new $TypeError('Assertion failed: `number` must be a String'); + } + if (!IsIntegralNumber(number)) { + throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + return $BigInt(number); +}; diff --git a/node_modules/es-abstract/2022/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2022/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2022/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2022/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..ba17b98872933ef285da579420e75fa18b072ce9 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryGetPrototypeOf.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $getProto = require('../helpers/getProto'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2022/OrdinaryHasInstance.js b/node_modules/es-abstract/2022/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2022/OrdinaryHasProperty.js b/node_modules/es-abstract/2022/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2022/OrdinaryObjectCreate.js b/node_modules/es-abstract/2022/OrdinaryObjectCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..140534083c5c78b6cba43ce916ce30e39efd5c9b --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryObjectCreate.js @@ -0,0 +1,56 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ObjectCreate = GetIntrinsic('%Object.create%', true); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +var forEach = require('../helpers/forEach'); + +var SLOT = require('internal-slot'); + +var hasProto = require('has-proto')(); + +// https://262.ecma-international.org/11.0/#sec-objectcreate + +module.exports = function OrdinaryObjectCreate(proto) { + if (proto !== null && Type(proto) !== 'Object') { + throw new $TypeError('Assertion failed: `proto` must be null or an object'); + } + var additionalInternalSlotsList = arguments.length < 2 ? [] : arguments[1]; + if (!IsArray(additionalInternalSlotsList)) { + throw new $TypeError('Assertion failed: `additionalInternalSlotsList` must be an Array'); + } + + // var internalSlotsList = ['[[Prototype]]', '[[Extensible]]']; // step 1 + // internalSlotsList.push(...additionalInternalSlotsList); // step 2 + // var O = MakeBasicObject(internalSlotsList); // step 3 + // setProto(O, proto); // step 4 + // return O; // step 5 + + var O; + if ($ObjectCreate) { + O = $ObjectCreate(proto); + } else if (hasProto) { + O = { __proto__: proto }; + } else { + if (proto === null) { + throw new $SyntaxError('native Object.create support is required to create null objects'); + } + var T = function T() {}; + T.prototype = proto; + O = new T(); + } + + if (additionalInternalSlotsList.length > 0) { + forEach(additionalInternalSlotsList, function (slot) { + SLOT.set(O, slot, void undefined); + }); + } + + return O; +}; diff --git a/node_modules/es-abstract/2022/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2022/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b72306c187b6e9f4355b399831a46e10fa7f61 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinarySetPrototypeOf.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $setProto = require('../helpers/setProto'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (Type(V) !== 'Object' && Type(V) !== 'Null') { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2022/OrdinaryToPrimitive.js b/node_modules/es-abstract/2022/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..e1dbe1427f8d87cba5e2c711fcb73144fa55ec33 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryToPrimitive.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* Type(hint) !== 'String' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (Type(result) !== 'Object') { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2022/QuoteJSONString.js b/node_modules/es-abstract/2022/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..1a7fae182435751a6938740e4149c6e30095a175 --- /dev/null +++ b/node_modules/es-abstract/2022/QuoteJSONString.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +var StringToCodePoints = require('./StringToCodePoints'); +var Type = require('./Type'); +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/12.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach(StringToCodePoints(value), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(C) || isTrailingSurrogate(C)) { + product += UnicodeEscape(C); + } else { + product += UTF16EncodeCodePoint(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2022/RegExpExec.js b/node_modules/es-abstract/2022/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2022/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2022/RequireObjectCoercible.js b/node_modules/es-abstract/2022/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9008359db8f9ac7107563f46c1aebc2258b8cb2b --- /dev/null +++ b/node_modules/es-abstract/2022/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../5/CheckObjectCoercible'); diff --git a/node_modules/es-abstract/2022/SameValue.js b/node_modules/es-abstract/2022/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2022/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2022/SameValueZero.js b/node_modules/es-abstract/2022/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2022/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2022/SetFunctionLength.js b/node_modules/es-abstract/2022/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..fbf9f2352ab66d475e974df9d59ef67eb8437290 --- /dev/null +++ b/node_modules/es-abstract/2022/SetFunctionLength.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (Type(length) !== 'Number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (length !== Infinity && (!isInteger(length) || length < 0)) { + throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2022/SetIntegrityLevel.js b/node_modules/es-abstract/2022/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2022/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2022/SetTypedArrayFromArrayLike.js b/node_modules/es-abstract/2022/SetTypedArrayFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..aa5581d99ce325eb1d93e751210528159d3bee49 --- /dev/null +++ b/node_modules/es-abstract/2022/SetTypedArrayFromArrayLike.js @@ -0,0 +1,97 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); + +var isInteger = require('../helpers/isInteger'); + +var Get = require('./Get'); +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); +var ToString = require('./ToString'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); +var TypedArrayElementType = require('./TypedArrayElementType'); + +// https://262.ecma-international.org/13.0/#sec-settypedarrayfromarraylike + +module.exports = function SetTypedArrayFromArrayLike(target, targetOffset, source) { + var whichTarget = whichTypedArray(target); + if (!whichTarget) { + throw new $TypeError('Assertion failed: target must be a TypedArray instance'); + } + + if (targetOffset !== Infinity && (!isInteger(targetOffset) || targetOffset < 0)) { + throw new $TypeError('Assertion failed: targetOffset must be a non-negative integer or +Infinity'); + } + + if (isTypedArray(source)) { + throw new $TypeError('Assertion failed: source must not be a TypedArray instance'); + } + + var targetBuffer = typedArrayBuffer(target); // step 1 + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 2 + } + + var targetLength = typedArrayLength(target); // step 3 + + var targetElementSize = TypedArrayElementSize(target); // step 4 + + var targetType = TypedArrayElementType(target); // step 5 + + var targetByteOffset = typedArrayByteOffset(target); // step 6 + + var src = ToObject(source); // step 7 + + var srcLength = LengthOfArrayLike(src); // step 8 + + if (targetOffset === Infinity) { + throw new $RangeError('targetOffset must be a finite integer'); // step 9 + } + + if (srcLength + targetOffset > targetLength) { + throw new $RangeError('targetOffset + srcLength must be <= target.length'); // step 10 + } + + var targetByteIndex = (targetOffset * targetElementSize) + targetByteOffset; // step 11 + + var k = 0; // step 12 + + var limit = targetByteIndex + (targetElementSize * srcLength); // step 13 + + while (targetByteIndex < limit) { // step 14 + var Pk = ToString(k); // step 14.a + + var value = Get(src, Pk); // step 14.b + + if (IsBigIntElementType(targetType)) { + value = ToBigInt(value); // step 14.c + } else { + value = ToNumber(value); // step 14.d + } + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 14.e + } + + SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, 'Unordered'); // step 14.f + + k += 1; // step 14.g + + targetByteIndex += targetElementSize; // step 14.h + } +}; diff --git a/node_modules/es-abstract/2022/SortIndexedProperties.js b/node_modules/es-abstract/2022/SortIndexedProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..97eb76afa9a2b87fa793fa2fb46e0b4611925066 --- /dev/null +++ b/node_modules/es-abstract/2022/SortIndexedProperties.js @@ -0,0 +1,64 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DeletePropertyOrThrow = require('./DeletePropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var Set = require('./Set'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var isAbstractClosure = require('../helpers/isAbstractClosure'); +var isInteger = require('../helpers/isInteger'); + +var $push = callBound('Array.prototype.push'); +var $sort = callBound('Array.prototype.sort'); + +// https://262.ecma-international.org/13.0/#sec-sortindexedproperties + +module.exports = function SortIndexedProperties(obj, len, SortCompare) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(obj) is not Object'); + } + if (!isInteger(len) || len < 0) { + throw new $TypeError('Assertion failed: `len` must be an integer >= 0'); + } + if (!isAbstractClosure(SortCompare) || SortCompare.length !== 2) { + throw new $TypeError('Assertion failed: `SortCompare` must be an abstract closure taking 2 arguments'); + } + + var items = []; // step 1 + + var k = 0; // step 2 + + while (k < len) { // step 3 + var Pk = ToString(k); + var kPresent = HasProperty(obj, Pk); + if (kPresent) { + var kValue = Get(obj, Pk); + $push(items, kValue); + } + k += 1; + } + + var itemCount = items.length; // step 4 + + $sort(items, SortCompare); // step 5 + + var j = 0; // step 6 + + while (j < itemCount) { // step 7 + Set(obj, ToString(j), items[j], true); + j += 1; + } + + while (j < len) { // step 8 + DeletePropertyOrThrow(obj, ToString(j)); + j += 1; + } + return obj; // step 9 +}; diff --git a/node_modules/es-abstract/2022/SpeciesConstructor.js b/node_modules/es-abstract/2022/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2022/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2022/StringCreate.js b/node_modules/es-abstract/2022/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2022/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2022/StringPad.js b/node_modules/es-abstract/2022/StringPad.js new file mode 100644 index 0000000000000000000000000000000000000000..cdf69001bb5bdc84a82d4b30da527138e1c9dc31 --- /dev/null +++ b/node_modules/es-abstract/2022/StringPad.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/11.0/#sec-stringpad + +module.exports = function StringPad(O, maxLength, fillString, placement) { + if (placement !== 'start' && placement !== 'end') { + throw new $TypeError('Assertion failed: `placement` must be "start" or "end"'); + } + var S = ToString(O); + var intMaxLength = ToLength(maxLength); + var stringLength = S.length; + if (intMaxLength <= stringLength) { + return S; + } + var filler = typeof fillString === 'undefined' ? ' ' : ToString(fillString); + if (filler === '') { + return S; + } + var fillLen = intMaxLength - stringLength; + + // the String value consisting of repeated concatenations of filler truncated to length fillLen. + var truncatedStringFiller = ''; + while (truncatedStringFiller.length < fillLen) { + truncatedStringFiller += filler; + } + truncatedStringFiller = $strSlice(truncatedStringFiller, 0, fillLen); + + if (placement === 'start') { + return truncatedStringFiller + S; + } + return S + truncatedStringFiller; +}; diff --git a/node_modules/es-abstract/2022/StringToCodePoints.js b/node_modules/es-abstract/2022/StringToCodePoints.js new file mode 100644 index 0000000000000000000000000000000000000000..f503ce1b47933696d1cd0bdebbd790e90025921a --- /dev/null +++ b/node_modules/es-abstract/2022/StringToCodePoints.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $push = callBound('Array.prototype.push'); + +var CodePointAt = require('./CodePointAt'); +var Type = require('./Type'); + +// https://262.ecma-international.org/12.0/#sec-stringtocodepoints + +module.exports = function StringToCodePoints(string) { + if (Type(string) !== 'String') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var codePoints = []; + var size = string.length; + var position = 0; + while (position < size) { + var cp = CodePointAt(string, position); + $push(codePoints, cp['[[CodePoint]]']); + position += cp['[[CodeUnitCount]]']; + } + return codePoints; +}; diff --git a/node_modules/es-abstract/2022/StringToNumber.js b/node_modules/es-abstract/2022/StringToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..5775b56c69f4e09f332eb4f091ae99568500c058 --- /dev/null +++ b/node_modules/es-abstract/2022/StringToNumber.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); +var $RegExp = GetIntrinsic('%RegExp%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $parseInteger = GetIntrinsic('%parseInt%'); + +var callBound = require('call-bind/callBound'); +var regexTester = require('safe-regex-test'); + +var $strSlice = callBound('String.prototype.slice'); +var isBinary = regexTester(/^0b[01]+$/i); +var isOctal = regexTester(/^0o[0-7]+$/i); +var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i); +var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); +var nonWSregex = new $RegExp('[' + nonWS + ']', 'g'); +var hasNonWS = regexTester(nonWSregex); + +var $trim = require('string.prototype.trim'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/13.0/#sec-stringtonumber + +module.exports = function StringToNumber(argument) { + if (Type(argument) !== 'String') { + throw new $TypeError('Assertion failed: `argument` is not a String'); + } + if (isBinary(argument)) { + return $Number($parseInteger($strSlice(argument, 2), 2)); + } + if (isOctal(argument)) { + return $Number($parseInteger($strSlice(argument, 2), 8)); + } + if (hasNonWS(argument) || isInvalidHexLiteral(argument)) { + return NaN; + } + var trimmed = $trim(argument); + if (trimmed !== argument) { + return StringToNumber(trimmed); + } + return $Number(argument); +}; diff --git a/node_modules/es-abstract/2022/SymbolDescriptiveString.js b/node_modules/es-abstract/2022/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2022/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2022/ThrowCompletion.js b/node_modules/es-abstract/2022/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2022/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2022/TimeFromYear.js b/node_modules/es-abstract/2022/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2022/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2022/TimeString.js b/node_modules/es-abstract/2022/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..051c4728e2e495a323f9ed64acd3be8d25603b00 --- /dev/null +++ b/node_modules/es-abstract/2022/TimeString.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); +var Type = require('./Type'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2022/ToDateString.js b/node_modules/es-abstract/2022/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2022/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2022/ToInt16.js b/node_modules/es-abstract/2022/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2022/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2022/ToInt32.js b/node_modules/es-abstract/2022/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2022/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2022/ToString.js b/node_modules/es-abstract/2022/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2022/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2022/ToUint8Clamp.js b/node_modules/es-abstract/2022/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2022/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2022/TrimString.js b/node_modules/es-abstract/2022/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..113dcf82b82d823bee32c607bcd897bc6e36548a --- /dev/null +++ b/node_modules/es-abstract/2022/TrimString.js @@ -0,0 +1,29 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2022/Type.js b/node_modules/es-abstract/2022/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..555ca74ea51969958716accd635da40009319542 --- /dev/null +++ b/node_modules/es-abstract/2022/Type.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + if (typeof x === 'bigint') { + return 'BigInt'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2022/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2022/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2bfdff5eb705c2c866ad0623064a35be67b92b73 --- /dev/null +++ b/node_modules/es-abstract/2022/TypedArraySpeciesCreate.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2022/UnicodeEscape.js b/node_modules/es-abstract/2022/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..b708c90df0a05e9250f3dbbb9ac1044bb88b5d42 --- /dev/null +++ b/node_modules/es-abstract/2022/UnicodeEscape.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); + +var StringPad = require('./StringPad'); + +// https://262.ecma-international.org/11.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + StringPad($toLowerCase($numberToString(n, 16)), 4, '0', 'start'); +}; diff --git a/node_modules/es-abstract/2022/ValidateIntegerTypedArray.js b/node_modules/es-abstract/2022/ValidateIntegerTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c9c8249c6aaa9e11c158e4c22d14dbdbf2cc0fab --- /dev/null +++ b/node_modules/es-abstract/2022/ValidateIntegerTypedArray.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var Type = require('./Type'); +var TypedArrayElementType = require('./TypedArrayElementType'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var whichTypedArray = require('which-typed-array'); + +// https://262.ecma-international.org/13.0/#sec-validateintegertypedarray + +module.exports = function ValidateIntegerTypedArray(typedArray) { + var waitable = arguments.length > 1 ? arguments[1] : false; // step 1 + + if (Type(waitable) !== 'Boolean') { + throw new $TypeError('Assertion failed: `waitable` must be a Boolean'); + } + + var buffer = ValidateTypedArray(typedArray); // step 2 + + if (waitable) { // step 5 + var typeName = whichTypedArray(typedArray); + if (typeName !== 'Int32Array' && typeName !== 'BigInt64Array') { + throw new $TypeError('Assertion failed: `typedArray` must be an Int32Array or BigInt64Array when `waitable` is true'); // step 5.a + } + } else { + var type = TypedArrayElementType(typedArray); // step 5.a + if (!IsUnclampedIntegerElementType(type) && !IsBigIntElementType(type)) { + throw new $TypeError('Assertion failed: `typedArray` must be an integer TypedArray'); // step 5.b + } + } + + return buffer; // step 6 +}; diff --git a/node_modules/es-abstract/2022/ValidateTypedArray.js b/node_modules/es-abstract/2022/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2022/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2022/WeekDay.js b/node_modules/es-abstract/2022/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2022/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2022/abs.js b/node_modules/es-abstract/2022/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2022/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2022/floor.js b/node_modules/es-abstract/2022/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..625548e936b95ca0735790d52c46f9bee5730558 --- /dev/null +++ b/node_modules/es-abstract/2022/floor.js @@ -0,0 +1,16 @@ +'use strict'; + +var Type = require('./Type'); + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/11.0/#eqn-floor + +module.exports = function floor(x) { + // return x - modulo(x, 1); + if (Type(x) === 'BigInt') { + return x; + } + return $floor(x); +}; diff --git a/node_modules/es-abstract/2022/max.js b/node_modules/es-abstract/2022/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2022/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2022/msFromTime.js b/node_modules/es-abstract/2022/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2022/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2022/thisBooleanValue.js b/node_modules/es-abstract/2022/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2022/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2022/thisNumberValue.js b/node_modules/es-abstract/2022/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2022/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2023/AddEntriesFromIterable.js b/node_modules/es-abstract/2023/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..907229909ef20dbcf86c24eb724590e8e5342d1e --- /dev/null +++ b/node_modules/es-abstract/2023/AddEntriesFromIterable.js @@ -0,0 +1,47 @@ +'use strict'; + +var inspect = require('object-inspect'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); +var Type = require('./Type'); + +// https://262.ecma-international.org/14.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable, 'sync'); + while (true) { // eslint-disable-line no-constant-condition + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (Type(nextItem) !== 'Object') { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2023/ApplyStringOrNumericBinaryOperator.js b/node_modules/es-abstract/2023/ApplyStringOrNumericBinaryOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..e5f997a39d09af338a6a314e28774f8b132d7438 --- /dev/null +++ b/node_modules/es-abstract/2023/ApplyStringOrNumericBinaryOperator.js @@ -0,0 +1,80 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var HasOwnProperty = require('./HasOwnProperty'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var NumberAdd = require('./Number/add'); +var NumberBitwiseAND = require('./Number/bitwiseAND'); +var NumberBitwiseOR = require('./Number/bitwiseOR'); +var NumberBitwiseXOR = require('./Number/bitwiseXOR'); +var NumberDivide = require('./Number/divide'); +var NumberExponentiate = require('./Number/exponentiate'); +var NumberLeftShift = require('./Number/leftShift'); +var NumberMultiply = require('./Number/multiply'); +var NumberRemainder = require('./Number/remainder'); +var NumberSignedRightShift = require('./Number/signedRightShift'); +var NumberSubtract = require('./Number/subtract'); +var NumberUnsignedRightShift = require('./Number/unsignedRightShift'); +var BigIntAdd = require('./BigInt/add'); +var BigIntBitwiseAND = require('./BigInt/bitwiseAND'); +var BigIntBitwiseOR = require('./BigInt/bitwiseOR'); +var BigIntBitwiseXOR = require('./BigInt/bitwiseXOR'); +var BigIntDivide = require('./BigInt/divide'); +var BigIntExponentiate = require('./BigInt/exponentiate'); +var BigIntLeftShift = require('./BigInt/leftShift'); +var BigIntMultiply = require('./BigInt/multiply'); +var BigIntRemainder = require('./BigInt/remainder'); +var BigIntSignedRightShift = require('./BigInt/signedRightShift'); +var BigIntSubtract = require('./BigInt/subtract'); +var BigIntUnsignedRightShift = require('./BigInt/unsignedRightShift'); + +// https://262.ecma-international.org/12.0/#sec-applystringornumericbinaryoperator + +// https://262.ecma-international.org/12.0/#step-applystringornumericbinaryoperator-operations-table +var table = { + '**': [NumberExponentiate, BigIntExponentiate], + '*': [NumberMultiply, BigIntMultiply], + '/': [NumberDivide, BigIntDivide], + '%': [NumberRemainder, BigIntRemainder], + '+': [NumberAdd, BigIntAdd], + '-': [NumberSubtract, BigIntSubtract], + '<<': [NumberLeftShift, BigIntLeftShift], + '>>': [NumberSignedRightShift, BigIntSignedRightShift], + '>>>': [NumberUnsignedRightShift, BigIntUnsignedRightShift], + '&': [NumberBitwiseAND, BigIntBitwiseAND], + '^': [NumberBitwiseXOR, BigIntBitwiseXOR], + '|': [NumberBitwiseOR, BigIntBitwiseOR] +}; + +module.exports = function ApplyStringOrNumericBinaryOperator(lval, opText, rval) { + if (Type(opText) !== 'String' || !HasOwnProperty(table, opText)) { + throw new $TypeError('Assertion failed: `opText` must be a valid operation string'); + } + if (opText === '+') { + var lprim = ToPrimitive(lval); + var rprim = ToPrimitive(rval); + if (Type(lprim) === 'String' || Type(rprim) === 'String') { + var lstr = ToString(lprim); + var rstr = ToString(rprim); + return lstr + rstr; + } + /* eslint no-param-reassign: 1 */ + lval = lprim; + rval = rprim; + } + var lnum = ToNumeric(lval); + var rnum = ToNumeric(rval); + var T = Type(lnum); + if (T !== Type(rnum)) { + throw new $TypeError('types of ' + lnum + ' and ' + rnum + ' differ'); + } + var Operation = table[opText][T === 'BigInt' ? 1 : 0]; + return Operation(lnum, rnum); +}; diff --git a/node_modules/es-abstract/2023/ArraySetLength.js b/node_modules/es-abstract/2023/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..45d7569e7d18caa18779ec051123fac050fd356f --- /dev/null +++ b/node_modules/es-abstract/2023/ArraySetLength.js @@ -0,0 +1,85 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsArray = require('./IsArray'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + } + if (!oldLenDesc['[[Writable]]']) { + return false; + } + var newWritable; + if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) { + newWritable = true; + } else { + newWritable = false; + newLenDesc['[[Writable]]'] = true; + } + var succeeded = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2023/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2023/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..5618539dd6fb0d80d53105fcae16dfc946cf187b --- /dev/null +++ b/node_modules/es-abstract/2023/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bind/callBound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); +var Type = require('./Type'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (Type(result) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2023/BigInt/add.js b/node_modules/es-abstract/2023/BigInt/add.js new file mode 100644 index 0000000000000000000000000000000000000000..22b5db4b32d2c9dc6ee3562cb998d4376cada88b --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/add.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add + +module.exports = function BigIntAdd(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/bitwiseAND.js b/node_modules/es-abstract/2023/BigInt/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..83cd2c3ca9edc6de1fa2d30055f4c2daf15aa71e --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/bitwiseAND.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND + +module.exports = function BigIntBitwiseAND(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2023/BigInt/bitwiseNOT.js b/node_modules/es-abstract/2023/BigInt/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..9a444dfeab8d635d8355db0e0644a74250776136 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/bitwiseNOT.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT + +module.exports = function BigIntBitwiseNOT(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + return -x - $BigInt(1); +}; diff --git a/node_modules/es-abstract/2023/BigInt/bitwiseOR.js b/node_modules/es-abstract/2023/BigInt/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..3c1b57193ef48115b08bc6bf1d5eb55c69dbb965 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/bitwiseOR.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR + +module.exports = function BigIntBitwiseOR(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2023/BigInt/bitwiseXOR.js b/node_modules/es-abstract/2023/BigInt/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..45f8217efb83cd6ad102a8cbcb01cb534bdab133 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/bitwiseXOR.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR + +module.exports = function BigIntBitwiseXOR(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2023/BigInt/divide.js b/node_modules/es-abstract/2023/BigInt/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..5706e7d72e4243301af168763d9c035de9cc0e98 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/divide.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide + +module.exports = function BigIntDivide(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + if (y === $BigInt(0)) { + throw new $RangeError('Division by zero'); + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/equal.js b/node_modules/es-abstract/2023/BigInt/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..a28826d67ff75d4158a5d4fbb9e3a8e38b7d5160 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/equal.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal + +module.exports = function BigIntEqual(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/exponentiate.js b/node_modules/es-abstract/2023/BigInt/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..2365838c269b68e03f489f9e26b5a9828bd5edf2 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/exponentiate.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate + +module.exports = function BigIntExponentiate(base, exponent) { + if (Type(base) !== 'BigInt' || Type(exponent) !== 'BigInt') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts'); + } + if (exponent < $BigInt(0)) { + throw new $RangeError('Exponent must be positive'); + } + if (/* base === $BigInt(0) && */ exponent === $BigInt(0)) { + return $BigInt(1); + } + + var square = base; + var remaining = exponent; + while (remaining > $BigInt(0)) { + square += exponent; + --remaining; // eslint-disable-line no-plusplus + } + return square; +}; diff --git a/node_modules/es-abstract/2023/BigInt/index.js b/node_modules/es-abstract/2023/BigInt/index.js new file mode 100644 index 0000000000000000000000000000000000000000..6ba755ff52a6f144423c3662e0d496c0a09dad31 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/index.js @@ -0,0 +1,39 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2023/BigInt/leftShift.js b/node_modules/es-abstract/2023/BigInt/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..d2a570223e22c29d6196a51153109aad2f420b3e --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/leftShift.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift + +module.exports = function BigIntLeftShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x << y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/lessThan.js b/node_modules/es-abstract/2023/BigInt/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..0b3cd6ba029e8ee1d8e22e0230d06b68255c4b87 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/lessThan.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan + +module.exports = function BigIntLessThan(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/multiply.js b/node_modules/es-abstract/2023/BigInt/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..6e5d56c83ea0b9bfbe2801895c732e0aff77f922 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/multiply.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply + +module.exports = function BigIntMultiply(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/remainder.js b/node_modules/es-abstract/2023/BigInt/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..d2dc678caf6bdeff4a0dfbc7819129231c0b040c --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/remainder.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder + +module.exports = function BigIntRemainder(n, d) { + if (Type(n) !== 'BigInt' || Type(d) !== 'BigInt') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts'); + } + + if (d === zero) { + throw new $RangeError('Division by zero'); + } + + if (n === zero) { + return zero; + } + + // shortcut for the actual spec mechanics + return n % d; +}; diff --git a/node_modules/es-abstract/2023/BigInt/signedRightShift.js b/node_modules/es-abstract/2023/BigInt/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..f63c642f0cda7f1c8079b674dd8a700a018e13cb --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/signedRightShift.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); +var BigIntLeftShift = require('./leftShift'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift + +module.exports = function BigIntSignedRightShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntLeftShift(x, -y); +}; diff --git a/node_modules/es-abstract/2023/BigInt/subtract.js b/node_modules/es-abstract/2023/BigInt/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..0490784f679cd079bdacb6019c20b72d1c82195c --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/subtract.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract + +module.exports = function BigIntSubtract(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x - y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/toString.js b/node_modules/es-abstract/2023/BigInt/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..43ad9ec88fef7d8f27eb639b18b01d43b4bf26be --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/toString.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError; +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $BigIntToString = callBound('BigInt.prototype.toString', true); + +var Type = require('../Type'); + +var isInteger = require('../../helpers/isInteger'); + +// https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-tostring + +module.exports = function BigIntToString(x, radix) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` must be a BigInt'); + } + + if (!isInteger(radix) || radix < 2 || radix > 36) { + throw new $TypeError('Assertion failed: `radix` must be an integer >= 2 and <= 36'); + } + + if (!$BigIntToString) { + throw new $SyntaxError('BigInt is not supported'); + } + + return $BigIntToString(x, radix); // steps 1 - 12 +}; diff --git a/node_modules/es-abstract/2023/BigInt/unaryMinus.js b/node_modules/es-abstract/2023/BigInt/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..ee0f7ef1962c387400f371c970cef8fba071b616 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/unaryMinus.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus + +module.exports = function BigIntUnaryMinus(x) { + if (Type(x) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + + if (x === zero) { + return zero; + } + + return -x; +}; diff --git a/node_modules/es-abstract/2023/BigInt/unsignedRightShift.js b/node_modules/es-abstract/2023/BigInt/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..7ad94f7a88d5f49e9125028d497112317d25783e --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/unsignedRightShift.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('../Type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift + +module.exports = function BigIntUnsignedRightShift(x, y) { + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + throw new $TypeError('BigInts have no unsigned right shift, use >> instead'); +}; diff --git a/node_modules/es-abstract/2023/BigIntBitwiseOp.js b/node_modules/es-abstract/2023/BigIntBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..0b1c03a911b68cf88fab0a9156e7ac56b2ef3567 --- /dev/null +++ b/node_modules/es-abstract/2023/BigIntBitwiseOp.js @@ -0,0 +1,66 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +// var $BigInt = GetIntrinsic('%BigInt%', true); +// var $pow = GetIntrinsic('%Math.pow%'); + +// var BinaryAnd = require('./BinaryAnd'); +// var BinaryOr = require('./BinaryOr'); +// var BinaryXor = require('./BinaryXor'); +var Type = require('./Type'); +// var modulo = require('./modulo'); + +// var zero = $BigInt && $BigInt(0); +// var negOne = $BigInt && $BigInt(-1); +// var two = $BigInt && $BigInt(2); + +// https://262.ecma-international.org/11.0/#sec-bigintbitwiseop + +module.exports = function BigIntBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') { + throw new $TypeError('`x` and `y` must be BigInts'); + } + + if (op === '&') { + return x & y; + } + if (op === '|') { + return x | y; + } + return x ^ y; + /* + var result = zero; + var shift = 0; + while (x !== zero && x !== negOne && y !== zero && y !== negOne) { + var xDigit = modulo(x, two); + var yDigit = modulo(y, two); + if (op === '&') { + result += $pow(2, shift) * BinaryAnd(xDigit, yDigit); + } else if (op === '|') { + result += $pow(2, shift) * BinaryOr(xDigit, yDigit); + } else if (op === '^') { + result += $pow(2, shift) * BinaryXor(xDigit, yDigit); + } + shift += 1; + x = (x - xDigit) / two; + y = (y - yDigit) / two; + } + var tmp; + if (op === '&') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else if (op === '|') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else { + tmp = BinaryXor(modulo(x, two), modulo(y, two)); + } + if (tmp !== 0) { + result -= $pow(2, shift); + } + return result; + */ +}; diff --git a/node_modules/es-abstract/2023/BinaryAnd.js b/node_modules/es-abstract/2023/BinaryAnd.js new file mode 100644 index 0000000000000000000000000000000000000000..c617f388dea72e00af72319427af0554e296aad9 --- /dev/null +++ b/node_modules/es-abstract/2023/BinaryAnd.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; diff --git a/node_modules/es-abstract/2023/BinaryOr.js b/node_modules/es-abstract/2023/BinaryOr.js new file mode 100644 index 0000000000000000000000000000000000000000..6de0955f1a6d349fc321e9ea9d1020c939abd28c --- /dev/null +++ b/node_modules/es-abstract/2023/BinaryOr.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryor + +module.exports = function BinaryOr(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x | y; +}; diff --git a/node_modules/es-abstract/2023/BinaryXor.js b/node_modules/es-abstract/2023/BinaryXor.js new file mode 100644 index 0000000000000000000000000000000000000000..189d7d8469ce1f6f509b21bfb5e6a06ae849cd70 --- /dev/null +++ b/node_modules/es-abstract/2023/BinaryXor.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/11.0/#sec-binaryxor + +module.exports = function BinaryXor(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x ^ y; +}; diff --git a/node_modules/es-abstract/2023/ByteListBitwiseOp.js b/node_modules/es-abstract/2023/ByteListBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..67f4cecb59bac39e28f28b8f305b8f2d2ec18f0d --- /dev/null +++ b/node_modules/es-abstract/2023/ByteListBitwiseOp.js @@ -0,0 +1,44 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $push = callBound('Array.prototype.push'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistbitwiseop + +module.exports = function ByteListBitwiseOp(op, xBytes, yBytes) { + if (op !== '&' && op !== '^' && op !== '|') { + throw new $TypeError('Assertion failed: `op` must be `&`, `^`, or `|`'); + } + if (!IsArray(xBytes) || !IsArray(yBytes) || xBytes.length !== yBytes.length) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + + var result = []; + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + var resultByte; + if (op === '&') { + resultByte = xByte & yByte; + } else if (op === '^') { + resultByte = xByte ^ yByte; + } else { + resultByte = xByte | yByte; + } + $push(result, resultByte); + } + + return result; +}; diff --git a/node_modules/es-abstract/2023/ByteListEqual.js b/node_modules/es-abstract/2023/ByteListEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..489ddc224e6678e32474b3900c55bbb0c6202ff0 --- /dev/null +++ b/node_modules/es-abstract/2023/ByteListEqual.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistequal + +module.exports = function ByteListEqual(xBytes, yBytes) { + if (!IsArray(xBytes) || !IsArray(yBytes)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + + if (xBytes.length !== yBytes.length) { + return false; + } + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + if (xByte !== yByte) { + return false; + } + } + return true; +}; diff --git a/node_modules/es-abstract/2023/CanBeHeldWeakly.js b/node_modules/es-abstract/2023/CanBeHeldWeakly.js new file mode 100644 index 0000000000000000000000000000000000000000..717effc67e0d000ac4f88bf2b2a6e59872e43e49 --- /dev/null +++ b/node_modules/es-abstract/2023/CanBeHeldWeakly.js @@ -0,0 +1,16 @@ +'use strict'; + +var KeyForSymbol = require('./KeyForSymbol'); +var Type = require('./Type'); + +// https://262.ecma-international.org/14.0/#sec-canbeheldweakly + +module.exports = function CanBeHeldWeakly(v) { + if (Type(v) === 'Object') { + return true; // step 1 + } + if (Type(v) === 'Symbol' && typeof KeyForSymbol(v) === 'undefined') { + return true; // step 2 + } + return false; // step 3 +}; diff --git a/node_modules/es-abstract/2023/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2023/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..15e893dabec5fe250cc15fe619e59b88b83ade41 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateAsyncFromSyncIterator.js @@ -0,0 +1,121 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); + +var assertRecord = require('../helpers/assertRecord'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord, value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (Type(result) !== 'Object') { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/14.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + assertRecord(Type, 'Iterator Record', 'syncIteratorRecord', syncIteratorRecord); + + // var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2023/CreateDataProperty.js b/node_modules/es-abstract/2023/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..5bd5fc4787a84e58be01e58cb29dce24be36fa67 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateDataProperty.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2023/CreateHTML.js b/node_modules/es-abstract/2023/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7633da6800327bf86f70c81e07c731efdfe974 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateHTML.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (Type(tag) !== 'String' || Type(attribute) !== 'String') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2023/CreateMethodProperty.js b/node_modules/es-abstract/2023/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..058c0f17608547e778850740ffe3537813ccf7fa --- /dev/null +++ b/node_modules/es-abstract/2023/CreateMethodProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2023/CreateNonEnumerableDataPropertyOrThrow.js b/node_modules/es-abstract/2023/CreateNonEnumerableDataPropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..59a16ef00455b61e93ba72ebcb734906fc29bfcd --- /dev/null +++ b/node_modules/es-abstract/2023/CreateNonEnumerableDataPropertyOrThrow.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/13.0/#sec-createnonenumerabledatapropertyorthrow + +module.exports = function CreateNonEnumerableDataPropertyOrThrow(O, P, V) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefinePropertyOrThrow(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2023/CreateRegExpStringIterator.js b/node_modules/es-abstract/2023/CreateRegExpStringIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..cdfae56216ba75dee3fb62db722c22e9b293a99f --- /dev/null +++ b/node_modules/es-abstract/2023/CreateRegExpStringIterator.js @@ -0,0 +1,100 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var hasSymbols = require('has-symbols')(); + +var $TypeError = GetIntrinsic('%TypeError%'); +var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var CreateMethodProperty = require('./CreateMethodProperty'); +var Get = require('./Get'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var RegExpExec = require('./RegExpExec'); +var Set = require('./Set'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var SLOT = require('internal-slot'); +var setToStringTag = require('es-set-tostringtag'); + +var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) { + if (Type(S) !== 'String') { + throw new $TypeError('`S` must be a string'); + } + if (Type(global) !== 'Boolean') { + throw new $TypeError('`global` must be a boolean'); + } + if (Type(fullUnicode) !== 'Boolean') { + throw new $TypeError('`fullUnicode` must be a boolean'); + } + SLOT.set(this, '[[IteratingRegExp]]', R); + SLOT.set(this, '[[IteratedString]]', S); + SLOT.set(this, '[[Global]]', global); + SLOT.set(this, '[[Unicode]]', fullUnicode); + SLOT.set(this, '[[Done]]', false); +}; + +if (IteratorPrototype) { + RegExpStringIterator.prototype = OrdinaryObjectCreate(IteratorPrototype); +} + +var RegExpStringIteratorNext = function next() { + var O = this; // eslint-disable-line no-invalid-this + if (Type(O) !== 'Object') { + throw new $TypeError('receiver must be an object'); + } + if ( + !(O instanceof RegExpStringIterator) + || !SLOT.has(O, '[[IteratingRegExp]]') + || !SLOT.has(O, '[[IteratedString]]') + || !SLOT.has(O, '[[Global]]') + || !SLOT.has(O, '[[Unicode]]') + || !SLOT.has(O, '[[Done]]') + ) { + throw new $TypeError('"this" value must be a RegExpStringIterator instance'); + } + if (SLOT.get(O, '[[Done]]')) { + return CreateIterResultObject(undefined, true); + } + var R = SLOT.get(O, '[[IteratingRegExp]]'); + var S = SLOT.get(O, '[[IteratedString]]'); + var global = SLOT.get(O, '[[Global]]'); + var fullUnicode = SLOT.get(O, '[[Unicode]]'); + var match = RegExpExec(R, S); + if (match === null) { + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(undefined, true); + } + if (global) { + var matchStr = ToString(Get(match, '0')); + if (matchStr === '') { + var thisIndex = ToLength(Get(R, 'lastIndex')); + var nextIndex = AdvanceStringIndex(S, thisIndex, fullUnicode); + Set(R, 'lastIndex', nextIndex, true); + } + return CreateIterResultObject(match, false); + } + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(match, false); +}; +CreateMethodProperty(RegExpStringIterator.prototype, 'next', RegExpStringIteratorNext); + +if (hasSymbols) { + setToStringTag(RegExpStringIterator.prototype, 'RegExp String Iterator'); + + if (Symbol.iterator && typeof RegExpStringIterator.prototype[Symbol.iterator] !== 'function') { + var iteratorFn = function SymbolIterator() { + return this; + }; + CreateMethodProperty(RegExpStringIterator.prototype, Symbol.iterator, iteratorFn); + } +} + +// https://262.ecma-international.org/11.0/#sec-createregexpstringiterator +module.exports = function CreateRegExpStringIterator(R, S, global, fullUnicode) { + // assert R.global === global && R.unicode === fullUnicode? + return new RegExpStringIterator(R, S, global, fullUnicode); +}; diff --git a/node_modules/es-abstract/2023/DateFromTime.js b/node_modules/es-abstract/2023/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/2023/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2023/DateString.js b/node_modules/es-abstract/2023/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..939c14c0c87ef6b1d8ebc09e936e6c4e86e793c5 --- /dev/null +++ b/node_modules/es-abstract/2023/DateString.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var Type = require('./Type'); +var WeekDay = require('./WeekDay'); +var MonthFromTime = require('./MonthFromTime'); +var YearFromTime = require('./YearFromTime'); +var DateFromTime = require('./DateFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2023/DayFromYear.js b/node_modules/es-abstract/2023/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2023/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2023/DefinePropertyOrThrow.js b/node_modules/es-abstract/2023/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe097068db3146588a0a63740c2c8c5c5f6d1e7 --- /dev/null +++ b/node_modules/es-abstract/2023/DefinePropertyOrThrow.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsPropertyKey = require('./IsPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + var Desc = isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2023/DeletePropertyOrThrow.js b/node_modules/es-abstract/2023/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..581bf06ea2444eb4a4b5324c6dae2d3224585e0a --- /dev/null +++ b/node_modules/es-abstract/2023/DeletePropertyOrThrow.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2023/DetachArrayBuffer.js b/node_modules/es-abstract/2023/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..03284729b3d4e77587ae9204577ebf42e5b1b884 --- /dev/null +++ b/node_modules/es-abstract/2023/DetachArrayBuffer.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + return null; +}; diff --git a/node_modules/es-abstract/2023/FlattenIntoArray.js b/node_modules/es-abstract/2023/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..0fb87bc6a39b028f45d6ca131333e9e398443935 --- /dev/null +++ b/node_modules/es-abstract/2023/FlattenIntoArray.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/11.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = LengthOfArrayLike(element); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2023/GetGlobalObject.js b/node_modules/es-abstract/2023/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2023/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2023/GetIteratorFromMethod.js b/node_modules/es-abstract/2023/GetIteratorFromMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..aac91ca2cf7088f43b668852bb30054408bcdce3 --- /dev/null +++ b/node_modules/es-abstract/2023/GetIteratorFromMethod.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/14.0/#sec-getiteratorfrommethod + +module.exports = function GetIteratorFromMethod(obj, method) { + if (!IsCallable(method)) { + throw new $TypeError('method must be a function'); + } + + var iterator = Call(method, obj); // step 1 + if (Type(iterator) !== 'Object') { + throw new $TypeError('iterator must return an object'); // step 2 + } + + var nextMethod = GetV(iterator, 'next'); // step 3 + return { // steps 4-5 + '[[Iterator]]': iterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2023/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2023/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b281ef4fe740b938b6809edc1c188dac3cb934b --- /dev/null +++ b/node_modules/es-abstract/2023/GetPrototypeFromConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (Type(intrinsic) !== 'Object') { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (Type(proto) !== 'Object') { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2023/GetV.js b/node_modules/es-abstract/2023/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..706a9211ab847290089554a2571b684b3fac840b --- /dev/null +++ b/node_modules/es-abstract/2023/GetV.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var inspect = require('object-inspect'); + +var IsPropertyKey = require('./IsPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2023/GetValueFromBuffer.js b/node_modules/es-abstract/2023/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8d3a2f4fc54239ca212915a513d02fc150c59cf1 --- /dev/null +++ b/node_modules/es-abstract/2023/GetValueFromBuffer.js @@ -0,0 +1,110 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var callBound = require('call-bind/callBound'); + +var $slice = callBound('Array.prototype.slice'); + +var isInteger = require('../helpers/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumeric = require('./RawBytesToNumeric'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var table61 = { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $BigInt64: 8, + $BigUint64: 8, + $Float32: 4, + $Float64: 8 +}; + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || typeof table61['$' + type] !== 'number') { + throw new $TypeError('Assertion failed: `type` must be a Typed Array element type'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (order !== 'SeqCst' && order !== 'Unordered') { + throw new $TypeError('Assertion failed: `order` must be either `SeqCst` or `Unordered`'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = table61['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "BigInt64", "BigUint64", "Float32", or "Float64"'); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumeric(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2023/HasOwnProperty.js b/node_modules/es-abstract/2023/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f24115370be26bde68a2ae54343cfc73c36962 --- /dev/null +++ b/node_modules/es-abstract/2023/HasOwnProperty.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var hasOwn = require('hasown'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2023/HourFromTime.js b/node_modules/es-abstract/2023/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2023/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2023/IsAccessorDescriptor.js b/node_modules/es-abstract/2023/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/2023/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2023/IsCallable.js b/node_modules/es-abstract/2023/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2023/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2023/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2023/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..48e719f3c1e515175311d0f2fe599b4743f43062 --- /dev/null +++ b/node_modules/es-abstract/2023/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/13.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, '', Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2023/IsConcatSpreadable.js b/node_modules/es-abstract/2023/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..10e1eab2168c8c1779141bf027e5f03860b14ddf --- /dev/null +++ b/node_modules/es-abstract/2023/IsConcatSpreadable.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (Type(O) !== 'Object') { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2023/IsConstructor.js b/node_modules/es-abstract/2023/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2023/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2023/IsDataDescriptor.js b/node_modules/es-abstract/2023/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/2023/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2023/IsIntegralNumber.js b/node_modules/es-abstract/2023/IsIntegralNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..f00051a449e06eda8741cb511486e727c9228e15 --- /dev/null +++ b/node_modules/es-abstract/2023/IsIntegralNumber.js @@ -0,0 +1,15 @@ +'use strict'; + +var truncate = require('./truncate'); +var Type = require('./Type'); + +var $isFinite = require('../helpers/isFinite'); + +// https://262.ecma-international.org/14.0/#sec-isintegralnumber + +module.exports = function IsIntegralNumber(argument) { + if (Type(argument) !== 'Number' || !$isFinite(argument)) { + return false; + } + return truncate(argument) === argument; +}; diff --git a/node_modules/es-abstract/2023/IsLooselyEqual.js b/node_modules/es-abstract/2023/IsLooselyEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..9d254ba68cfaafd1c39cf785e1f77439747e6dd2 --- /dev/null +++ b/node_modules/es-abstract/2023/IsLooselyEqual.js @@ -0,0 +1,58 @@ +'use strict'; + +var isFinite = require('../helpers/isFinite'); + +var IsStrictlyEqual = require('./IsStrictlyEqual'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/13.0/#sec-islooselyequal + +module.exports = function IsLooselyEqual(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return IsStrictlyEqual(x, y); + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return IsLooselyEqual(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return IsLooselyEqual(ToNumber(x), y); + } + if (xType === 'BigInt' && yType === 'String') { + var n = StringToBigInt(y); + if (typeof n === 'undefined') { + return false; + } + return IsLooselyEqual(x, n); + } + if (xType === 'String' && yType === 'BigInt') { + return IsLooselyEqual(y, x); + } + if (xType === 'Boolean') { + return IsLooselyEqual(ToNumber(x), y); + } + if (yType === 'Boolean') { + return IsLooselyEqual(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number' || xType === 'Symbol' || xType === 'BigInt') && yType === 'Object') { + return IsLooselyEqual(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol' || yType === 'BigInt')) { + return IsLooselyEqual(ToPrimitive(x), y); + } + if ((xType === 'BigInt' && yType === 'Number') || (xType === 'Number' && yType === 'BigInt')) { + if (!isFinite(x) || !isFinite(y)) { + return false; + } + // eslint-disable-next-line eqeqeq + return x == y; // shortcut for step 13.b. + } + return false; +}; diff --git a/node_modules/es-abstract/2023/IsRegExp.js b/node_modules/es-abstract/2023/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..33d983dc8d3bac1be5bed0e6fa685cdad31a3041 --- /dev/null +++ b/node_modules/es-abstract/2023/IsRegExp.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!argument || typeof argument !== 'object') { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2023/IsSharedArrayBuffer.js b/node_modules/es-abstract/2023/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8e96e33f3c2dca5c15127f2ae83fc45861d548b9 --- /dev/null +++ b/node_modules/es-abstract/2023/IsSharedArrayBuffer.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2023/IsStringWellFormedUnicode.js b/node_modules/es-abstract/2023/IsStringWellFormedUnicode.js new file mode 100644 index 0000000000000000000000000000000000000000..4a4ad6682ba28c250f978acc488f2111682982e5 --- /dev/null +++ b/node_modules/es-abstract/2023/IsStringWellFormedUnicode.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var CodePointAt = require('./CodePointAt'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/14.0/#sec-isstringwellformedunicode + +module.exports = function IsStringWellFormedUnicode(string) { + if (Type(string) !== 'String') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var len = string.length; // step 1 + var k = 0; // step 2 + while (k < len) { // step 3 + var cp = CodePointAt(string, k); // step 3.a + if (cp['[[IsUnpairedSurrogate]]']) { + return false; // step 3.b + } + k += cp['[[CodeUnitCount]]']; // step 3.c + } + return true; // step 4 +}; diff --git a/node_modules/es-abstract/2023/IsUnsignedElementType.js b/node_modules/es-abstract/2023/IsUnsignedElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ff194d73916d487ce951d1c7553b7aa5ab34cf --- /dev/null +++ b/node_modules/es-abstract/2023/IsUnsignedElementType.js @@ -0,0 +1,11 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype + +module.exports = function IsUnsignedElementType(type) { + return type === 'Uint8' + || type === 'Uint8C' + || type === 'Uint16' + || type === 'Uint32' + || type === 'BigUint64'; +}; diff --git a/node_modules/es-abstract/2023/IsValidIntegerIndex.js b/node_modules/es-abstract/2023/IsValidIntegerIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..830416312dad6bf3e99ec0e00aab0ad8fa23b90e --- /dev/null +++ b/node_modules/es-abstract/2023/IsValidIntegerIndex.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsIntegralNumber = require('./IsIntegralNumber'); + +var isNegativeZero = require('../helpers/isNegativeZero'); + +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/12.0/#sec-isvalidintegerindex + +module.exports = function IsValidIntegerIndex(O, index) { + // Assert: O is an Integer-Indexed exotic object. + var buffer = typedArrayBuffer(O); // step 1 + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: Type(index) is not Number'); + } + + if (IsDetachedBuffer(buffer)) { return false; } // step 2 + + if (!IsIntegralNumber(index)) { return false; } // step 3 + + if (isNegativeZero(index)) { return false; } // step 4 + + if (index < 0 || index >= O.length) { return false; } // step 5 + + return true; // step 6 +}; diff --git a/node_modules/es-abstract/2023/IsWordChar.js b/node_modules/es-abstract/2023/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..3d8459ab6df142796ade58f5030425038c22d50f --- /dev/null +++ b/node_modules/es-abstract/2023/IsWordChar.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var Type = require('./Type'); +var WordCharacters = require('./WordCharacters'); + +var assertRecord = require('../helpers/assertRecord'); +var every = require('../helpers/every'); +var isInteger = require('../helpers/isInteger'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/14.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(rer, Input, e) { + assertRecord(Type, 'RegExp Record', 'rer', rer); + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + + if (!isInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + + var InputLength = Input.length; // step 1 + + if (e === -1 || e === InputLength) { + return false; // step 2 + } + + var c = Input[e]; // step 3 + + return $indexOf(WordCharacters(rer), c) > -1; // steps 4-5 +}; diff --git a/node_modules/es-abstract/2023/IteratorComplete.js b/node_modules/es-abstract/2023/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..29f5f75fea94580190a055fb81854e035ef39fc0 --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorComplete.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2023/IteratorStep.js b/node_modules/es-abstract/2023/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..c4f15362a02b51b948c46d78890f2dcfcd5524a2 --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorStep.js @@ -0,0 +1,18 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/14.0/#sec-iteratorstep + +module.exports = function IteratorStep(iteratorRecord) { + assertRecord(Type, 'Iterator Record', 'iteratorRecord', iteratorRecord); + + var result = IteratorNext(iteratorRecord); // step 1 + var done = IteratorComplete(result); // step 2 + return done === true ? false : result; // steps 3-4 +}; + diff --git a/node_modules/es-abstract/2023/IteratorToList.js b/node_modules/es-abstract/2023/IteratorToList.js new file mode 100644 index 0000000000000000000000000000000000000000..5b5ecea3433b8f8edf5f4fbc4f8bb5e46a8cbdfa --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorToList.js @@ -0,0 +1,28 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var $arrayPush = callBound('Array.prototype.push'); + +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/14.0/#sec-iteratortolist + +module.exports = function IteratorToList(iteratorRecord) { + assertRecord(Type, 'Iterator Record', 'iteratorRecord', iteratorRecord); + + var values = []; // step 1 + var next = true; // step 2 + while (next) { // step 3 + next = IteratorStep(iteratorRecord); // step 3.a + if (next) { + var nextValue = IteratorValue(next); // step 3.b.i + $arrayPush(values, nextValue); // step 3.b.ii + } + } + return values; // step 4 +}; diff --git a/node_modules/es-abstract/2023/IteratorValue.js b/node_modules/es-abstract/2023/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b16daed51c68f02189e62a3fac276e928d011c --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (Type(iterResult) !== 'Object') { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2023/KeyForSymbol.js b/node_modules/es-abstract/2023/KeyForSymbol.js new file mode 100644 index 0000000000000000000000000000000000000000..5fec3cc74c39eb6424b1a047964e380d125bd60e --- /dev/null +++ b/node_modules/es-abstract/2023/KeyForSymbol.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $keyFor = callBound('Symbol.keyFor', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/14.0/#sec-keyforsymbol + +module.exports = function KeyForSymbol(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $keyFor(sym); +}; diff --git a/node_modules/es-abstract/2023/LengthOfArrayLike.js b/node_modules/es-abstract/2023/LengthOfArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..132c4d58480f74f2cb987dd997783c035d313a43 --- /dev/null +++ b/node_modules/es-abstract/2023/LengthOfArrayLike.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var ToLength = require('./ToLength'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-lengthofarraylike + +module.exports = function LengthOfArrayLike(obj) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + return ToLength(Get(obj, 'length')); +}; + +// TODO: use this all over diff --git a/node_modules/es-abstract/2023/MakeMatchIndicesIndexPairArray.js b/node_modules/es-abstract/2023/MakeMatchIndicesIndexPairArray.js new file mode 100644 index 0000000000000000000000000000000000000000..962f5d8be8411a244e180f0c8f5ae2dd516ace2d --- /dev/null +++ b/node_modules/es-abstract/2023/MakeMatchIndicesIndexPairArray.js @@ -0,0 +1,69 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var ArrayCreate = require('./ArrayCreate'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var GetMatchIndexPair = require('./GetMatchIndexPair'); +var IsArray = require('./IsArray'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var every = require('../helpers/every'); +var isMatchRecord = require('../helpers/isMatchRecord'); + +var isStringOrUndefined = function isStringOrUndefined(s) { + return typeof s === 'undefined' || typeof s === 'string'; +}; + +var isMatchRecordOrUndefined = function isMatchRecordOrUndefined(m) { + return typeof m === 'undefined' || isMatchRecord(m); +}; + +var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1; + +// https://262.ecma-international.org/13.0/#sec-getmatchindexpair + +module.exports = function MakeMatchIndicesIndexPairArray(S, indices, groupNames, hasGroups) { + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!IsArray(indices) || !every(indices, isMatchRecordOrUndefined)) { + throw new $TypeError('Assertion failed: `indices` must be a List of either Match Records or `undefined`'); + } + if (!IsArray(groupNames) || !every(groupNames, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `groupNames` must be a List of either Strings or `undefined`'); + } + if (Type(hasGroups) !== 'Boolean') { + throw new $TypeError('Assertion failed: `hasGroups` must be a Boolean'); + } + + var n = indices.length; // step 1 + if (!(n < MAX_ARRAY_LENGTH)) { + throw new $TypeError('Assertion failed: `indices` length must be less than the max array size, 2**32 - 1'); + } + if (groupNames.length !== n - 1) { + throw new $TypeError('Assertion failed: `groupNames` must have exactly one fewer item than `indices`'); + } + + var A = ArrayCreate(n); // step 5 + var groups = hasGroups ? OrdinaryObjectCreate(null) : void undefined; // step 6-7 + CreateDataPropertyOrThrow(A, 'groups', groups); // step 8 + + for (var i = 0; i < n; i += 1) { // step 9 + var matchIndices = indices[i]; // step 9.a + // eslint-disable-next-line no-negated-condition + var matchIndexPair = typeof matchIndices !== 'undefined' ? GetMatchIndexPair(S, matchIndices) : void undefined; // step 9.b-9.c + CreateDataPropertyOrThrow(A, ToString(i), matchIndexPair); // step 9.d + if (i > 0 && typeof groupNames[i - 1] !== 'undefined') { // step 9.e + if (!groups) { + throw new $TypeError('if `hasGroups` is `false`, `groupNames` can only contain `undefined` values'); + } + CreateDataPropertyOrThrow(groups, groupNames[i - 1], matchIndexPair); // step 9.e.i + } + } + return A; // step 10 +}; diff --git a/node_modules/es-abstract/2023/MonthFromTime.js b/node_modules/es-abstract/2023/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/2023/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/2023/NewPromiseCapability.js b/node_modules/es-abstract/2023/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..640c380dbb5e2624b6c02b9ab278245e43e1fd29 --- /dev/null +++ b/node_modules/es-abstract/2023/NewPromiseCapability.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2023/NormalCompletion.js b/node_modules/es-abstract/2023/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2023/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2023/NumberToBigInt.js b/node_modules/es-abstract/2023/NumberToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..9ed8ed9a9be5df66578faa95cc5896874969c6ee --- /dev/null +++ b/node_modules/es-abstract/2023/NumberToBigInt.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = GetIntrinsic('%RangeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsIntegralNumber = require('./IsIntegralNumber'); +var Type = require('./Type'); + +// https://262.ecma-international.org/12.0/#sec-numbertobigint + +module.exports = function NumberToBigInt(number) { + if (Type(number) !== 'Number') { + throw new $TypeError('Assertion failed: `number` must be a String'); + } + if (!IsIntegralNumber(number)) { + throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + return $BigInt(number); +}; diff --git a/node_modules/es-abstract/2023/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2023/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd4fe58ddf1f03472822574a9b0567716cd2f3 --- /dev/null +++ b/node_modules/es-abstract/2023/OrdinaryDefineOwnProperty.js @@ -0,0 +1,61 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = require('gopd'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var IsPropertyKey = require('./IsPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var Type = require('./Type'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor({ + Type: Type, + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor + }, Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2023/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2023/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..ba17b98872933ef285da579420e75fa18b072ce9 --- /dev/null +++ b/node_modules/es-abstract/2023/OrdinaryGetPrototypeOf.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $getProto = require('../helpers/getProto'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2023/OrdinaryHasInstance.js b/node_modules/es-abstract/2023/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..996a50e0709931c22809a8c81214d4d6387a4e83 --- /dev/null +++ b/node_modules/es-abstract/2023/OrdinaryHasInstance.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (Type(O) !== 'Object') { + return false; + } + var P = Get(C, 'prototype'); + if (Type(P) !== 'Object') { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2023/OrdinaryHasProperty.js b/node_modules/es-abstract/2023/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..27e7da33ad0c951797cfc98682e8b07872a269c5 --- /dev/null +++ b/node_modules/es-abstract/2023/OrdinaryHasProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsPropertyKey = require('./IsPropertyKey'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!IsPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2023/OrdinaryObjectCreate.js b/node_modules/es-abstract/2023/OrdinaryObjectCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..140534083c5c78b6cba43ce916ce30e39efd5c9b --- /dev/null +++ b/node_modules/es-abstract/2023/OrdinaryObjectCreate.js @@ -0,0 +1,56 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ObjectCreate = GetIntrinsic('%Object.create%', true); +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var IsArray = require('./IsArray'); +var Type = require('./Type'); + +var forEach = require('../helpers/forEach'); + +var SLOT = require('internal-slot'); + +var hasProto = require('has-proto')(); + +// https://262.ecma-international.org/11.0/#sec-objectcreate + +module.exports = function OrdinaryObjectCreate(proto) { + if (proto !== null && Type(proto) !== 'Object') { + throw new $TypeError('Assertion failed: `proto` must be null or an object'); + } + var additionalInternalSlotsList = arguments.length < 2 ? [] : arguments[1]; + if (!IsArray(additionalInternalSlotsList)) { + throw new $TypeError('Assertion failed: `additionalInternalSlotsList` must be an Array'); + } + + // var internalSlotsList = ['[[Prototype]]', '[[Extensible]]']; // step 1 + // internalSlotsList.push(...additionalInternalSlotsList); // step 2 + // var O = MakeBasicObject(internalSlotsList); // step 3 + // setProto(O, proto); // step 4 + // return O; // step 5 + + var O; + if ($ObjectCreate) { + O = $ObjectCreate(proto); + } else if (hasProto) { + O = { __proto__: proto }; + } else { + if (proto === null) { + throw new $SyntaxError('native Object.create support is required to create null objects'); + } + var T = function T() {}; + T.prototype = proto; + O = new T(); + } + + if (additionalInternalSlotsList.length > 0) { + forEach(additionalInternalSlotsList, function (slot) { + SLOT.set(O, slot, void undefined); + }); + } + + return O; +}; diff --git a/node_modules/es-abstract/2023/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2023/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b72306c187b6e9f4355b399831a46e10fa7f61 --- /dev/null +++ b/node_modules/es-abstract/2023/OrdinarySetPrototypeOf.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $setProto = require('../helpers/setProto'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); +var Type = require('./Type'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (Type(V) !== 'Object' && Type(V) !== 'Null') { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2023/OrdinaryToPrimitive.js b/node_modules/es-abstract/2023/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..e1dbe1427f8d87cba5e2c711fcb73144fa55ec33 --- /dev/null +++ b/node_modules/es-abstract/2023/OrdinaryToPrimitive.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* Type(hint) !== 'String' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (Type(result) !== 'Object') { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2023/QuoteJSONString.js b/node_modules/es-abstract/2023/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..1a7fae182435751a6938740e4149c6e30095a175 --- /dev/null +++ b/node_modules/es-abstract/2023/QuoteJSONString.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +var StringToCodePoints = require('./StringToCodePoints'); +var Type = require('./Type'); +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/12.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach(StringToCodePoints(value), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(C) || isTrailingSurrogate(C)) { + product += UnicodeEscape(C); + } else { + product += UTF16EncodeCodePoint(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2023/RegExpExec.js b/node_modules/es-abstract/2023/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..cf15207415f5a240b61698dd943c81485ac589fa --- /dev/null +++ b/node_modules/es-abstract/2023/RegExpExec.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var regexExec = require('call-bind/callBound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (Type(R) !== 'Object') { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (Type(S) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || Type(result) === 'Object') { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2023/SameValue.js b/node_modules/es-abstract/2023/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/2023/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2023/SameValueZero.js b/node_modules/es-abstract/2023/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2851b5ee656e7e2432c12f777ced1e516f720d --- /dev/null +++ b/node_modules/es-abstract/2023/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2023/SetFunctionLength.js b/node_modules/es-abstract/2023/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..fbf9f2352ab66d475e974df9d59ef67eb8437290 --- /dev/null +++ b/node_modules/es-abstract/2023/SetFunctionLength.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); +var Type = require('./Type'); + +var isInteger = require('../helpers/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (Type(length) !== 'Number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (length !== Infinity && (!isInteger(length) || length < 0)) { + throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2023/SetIntegrityLevel.js b/node_modules/es-abstract/2023/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..aaef85a0a258a2856587bdb3f4285cfda3d7d266 --- /dev/null +++ b/node_modules/es-abstract/2023/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPD = require('gopd'); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (level !== 'sealed' && level !== 'frozen') { + throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`'); + } + if (!$preventExtensions) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support'); + } + var status = $preventExtensions(O); + if (!status) { + return false; + } + if (!$gOPN) { + throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support'); + } + var theKeys = $gOPN(O); + if (level === 'sealed') { + forEach(theKeys, function (k) { + DefinePropertyOrThrow(O, k, { configurable: false }); + }); + } else if (level === 'frozen') { + forEach(theKeys, function (k) { + var currentDesc = $gOPD(O, k); + if (typeof currentDesc !== 'undefined') { + var desc; + if (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2023/SetTypedArrayFromArrayLike.js b/node_modules/es-abstract/2023/SetTypedArrayFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..aa5581d99ce325eb1d93e751210528159d3bee49 --- /dev/null +++ b/node_modules/es-abstract/2023/SetTypedArrayFromArrayLike.js @@ -0,0 +1,97 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = GetIntrinsic('%RangeError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); + +var isInteger = require('../helpers/isInteger'); + +var Get = require('./Get'); +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); +var ToString = require('./ToString'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); +var TypedArrayElementType = require('./TypedArrayElementType'); + +// https://262.ecma-international.org/13.0/#sec-settypedarrayfromarraylike + +module.exports = function SetTypedArrayFromArrayLike(target, targetOffset, source) { + var whichTarget = whichTypedArray(target); + if (!whichTarget) { + throw new $TypeError('Assertion failed: target must be a TypedArray instance'); + } + + if (targetOffset !== Infinity && (!isInteger(targetOffset) || targetOffset < 0)) { + throw new $TypeError('Assertion failed: targetOffset must be a non-negative integer or +Infinity'); + } + + if (isTypedArray(source)) { + throw new $TypeError('Assertion failed: source must not be a TypedArray instance'); + } + + var targetBuffer = typedArrayBuffer(target); // step 1 + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 2 + } + + var targetLength = typedArrayLength(target); // step 3 + + var targetElementSize = TypedArrayElementSize(target); // step 4 + + var targetType = TypedArrayElementType(target); // step 5 + + var targetByteOffset = typedArrayByteOffset(target); // step 6 + + var src = ToObject(source); // step 7 + + var srcLength = LengthOfArrayLike(src); // step 8 + + if (targetOffset === Infinity) { + throw new $RangeError('targetOffset must be a finite integer'); // step 9 + } + + if (srcLength + targetOffset > targetLength) { + throw new $RangeError('targetOffset + srcLength must be <= target.length'); // step 10 + } + + var targetByteIndex = (targetOffset * targetElementSize) + targetByteOffset; // step 11 + + var k = 0; // step 12 + + var limit = targetByteIndex + (targetElementSize * srcLength); // step 13 + + while (targetByteIndex < limit) { // step 14 + var Pk = ToString(k); // step 14.a + + var value = Get(src, Pk); // step 14.b + + if (IsBigIntElementType(targetType)) { + value = ToBigInt(value); // step 14.c + } else { + value = ToNumber(value); // step 14.d + } + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 14.e + } + + SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, 'Unordered'); // step 14.f + + k += 1; // step 14.g + + targetByteIndex += targetElementSize; // step 14.h + } +}; diff --git a/node_modules/es-abstract/2023/SortIndexedProperties.js b/node_modules/es-abstract/2023/SortIndexedProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..1f7ac9052bb2dac5128107d7ecee488750ef6e32 --- /dev/null +++ b/node_modules/es-abstract/2023/SortIndexedProperties.js @@ -0,0 +1,52 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var isAbstractClosure = require('../helpers/isAbstractClosure'); +var isInteger = require('../helpers/isInteger'); + +var $push = callBound('Array.prototype.push'); +var $sort = callBound('Array.prototype.sort'); + +// https://262.ecma-international.org/14.0/#sec-sortindexedproperties + +module.exports = function SortIndexedProperties(obj, len, SortCompare, holes) { + if (Type(obj) !== 'Object') { + throw new $TypeError('Assertion failed: Type(obj) is not Object'); + } + if (!isInteger(len) || len < 0) { + throw new $TypeError('Assertion failed: `len` must be an integer >= 0'); + } + if (!isAbstractClosure(SortCompare) || SortCompare.length !== 2) { + throw new $TypeError('Assertion failed: `SortCompare` must be an abstract closure taking 2 arguments'); + } + if (holes !== 'skip-holes' && holes !== 'read-through-holes') { + throw new $TypeError('Assertion failed: `holes` must be either `skip-holes` or `read-through-holes`'); + } + + var items = []; // step 1 + + var k = 0; // step 2 + + while (k < len) { // step 3 + var Pk = ToString(k); + var kRead = holes === 'skip-holes' ? HasProperty(obj, Pk) : true; // step 3.b - 3.c + if (kRead) { // step 3.d + var kValue = Get(obj, Pk); + $push(items, kValue); + } + k += 1; // step 3.e + } + + $sort(items, SortCompare); // step 4 + + return items; // step 5 +}; diff --git a/node_modules/es-abstract/2023/SpeciesConstructor.js b/node_modules/es-abstract/2023/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..1937b9c9cdebecfe2ef4d8078b1b75419b746e96 --- /dev/null +++ b/node_modules/es-abstract/2023/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsConstructor = require('./IsConstructor'); +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (Type(C) !== 'Object') { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2023/StringCreate.js b/node_modules/es-abstract/2023/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd02820f79e32ecde7325655d829f3f7602121bc --- /dev/null +++ b/node_modules/es-abstract/2023/StringCreate.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Type = require('./Type'); + +var setProto = require('../helpers/setProto'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (Type(value) !== 'String') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2023/StringPad.js b/node_modules/es-abstract/2023/StringPad.js new file mode 100644 index 0000000000000000000000000000000000000000..cdf69001bb5bdc84a82d4b30da527138e1c9dc31 --- /dev/null +++ b/node_modules/es-abstract/2023/StringPad.js @@ -0,0 +1,43 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/11.0/#sec-stringpad + +module.exports = function StringPad(O, maxLength, fillString, placement) { + if (placement !== 'start' && placement !== 'end') { + throw new $TypeError('Assertion failed: `placement` must be "start" or "end"'); + } + var S = ToString(O); + var intMaxLength = ToLength(maxLength); + var stringLength = S.length; + if (intMaxLength <= stringLength) { + return S; + } + var filler = typeof fillString === 'undefined' ? ' ' : ToString(fillString); + if (filler === '') { + return S; + } + var fillLen = intMaxLength - stringLength; + + // the String value consisting of repeated concatenations of filler truncated to length fillLen. + var truncatedStringFiller = ''; + while (truncatedStringFiller.length < fillLen) { + truncatedStringFiller += filler; + } + truncatedStringFiller = $strSlice(truncatedStringFiller, 0, fillLen); + + if (placement === 'start') { + return truncatedStringFiller + S; + } + return S + truncatedStringFiller; +}; diff --git a/node_modules/es-abstract/2023/StringToCodePoints.js b/node_modules/es-abstract/2023/StringToCodePoints.js new file mode 100644 index 0000000000000000000000000000000000000000..f503ce1b47933696d1cd0bdebbd790e90025921a --- /dev/null +++ b/node_modules/es-abstract/2023/StringToCodePoints.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $push = callBound('Array.prototype.push'); + +var CodePointAt = require('./CodePointAt'); +var Type = require('./Type'); + +// https://262.ecma-international.org/12.0/#sec-stringtocodepoints + +module.exports = function StringToCodePoints(string) { + if (Type(string) !== 'String') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var codePoints = []; + var size = string.length; + var position = 0; + while (position < size) { + var cp = CodePointAt(string, position); + $push(codePoints, cp['[[CodePoint]]']); + position += cp['[[CodeUnitCount]]']; + } + return codePoints; +}; diff --git a/node_modules/es-abstract/2023/StringToNumber.js b/node_modules/es-abstract/2023/StringToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..5775b56c69f4e09f332eb4f091ae99568500c058 --- /dev/null +++ b/node_modules/es-abstract/2023/StringToNumber.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); +var $RegExp = GetIntrinsic('%RegExp%'); +var $TypeError = GetIntrinsic('%TypeError%'); +var $parseInteger = GetIntrinsic('%parseInt%'); + +var callBound = require('call-bind/callBound'); +var regexTester = require('safe-regex-test'); + +var $strSlice = callBound('String.prototype.slice'); +var isBinary = regexTester(/^0b[01]+$/i); +var isOctal = regexTester(/^0o[0-7]+$/i); +var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i); +var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); +var nonWSregex = new $RegExp('[' + nonWS + ']', 'g'); +var hasNonWS = regexTester(nonWSregex); + +var $trim = require('string.prototype.trim'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/13.0/#sec-stringtonumber + +module.exports = function StringToNumber(argument) { + if (Type(argument) !== 'String') { + throw new $TypeError('Assertion failed: `argument` is not a String'); + } + if (isBinary(argument)) { + return $Number($parseInteger($strSlice(argument, 2), 2)); + } + if (isOctal(argument)) { + return $Number($parseInteger($strSlice(argument, 2), 8)); + } + if (hasNonWS(argument) || isInvalidHexLiteral(argument)) { + return NaN; + } + var trimmed = $trim(argument); + if (trimmed !== argument) { + return StringToNumber(trimmed); + } + return $Number(argument); +}; diff --git a/node_modules/es-abstract/2023/SymbolDescriptiveString.js b/node_modules/es-abstract/2023/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..89c253ffaed3e70e166e290dcb3602116888e3e8 --- /dev/null +++ b/node_modules/es-abstract/2023/SymbolDescriptiveString.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (Type(sym) !== 'Symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2023/ThrowCompletion.js b/node_modules/es-abstract/2023/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2023/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2023/TimeFromYear.js b/node_modules/es-abstract/2023/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2023/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2023/TimeString.js b/node_modules/es-abstract/2023/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..051c4728e2e495a323f9ed64acd3be8d25603b00 --- /dev/null +++ b/node_modules/es-abstract/2023/TimeString.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var $isNaN = require('../helpers/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); +var Type = require('./Type'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (Type(tv) !== 'Number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2023/ToDateString.js b/node_modules/es-abstract/2023/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..dabb2bb38a515be5dc890665494539e5feb3a843 --- /dev/null +++ b/node_modules/es-abstract/2023/ToDateString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('../helpers/isNaN'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (Type(tv) !== 'Number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2023/ToInt16.js b/node_modules/es-abstract/2023/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..49d02c4c5c2306c117fc42ab7de988155b0c458a --- /dev/null +++ b/node_modules/es-abstract/2023/ToInt16.js @@ -0,0 +1,21 @@ +'use strict'; + +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); +var truncate = require('./truncate'); + +var isFinite = require('../helpers/isFinite'); + +// https://262.ecma-international.org/14.0/#sec-toint16 + +var two16 = 0x10000; // Math.pow(2, 16); + +module.exports = function ToInt16(argument) { + var number = ToNumber(argument); + if (!isFinite(number) || number === 0) { + return 0; + } + var int = truncate(number); + var int16bit = modulo(int, two16); + return int16bit >= 0x8000 ? int16bit - two16 : int16bit; +}; diff --git a/node_modules/es-abstract/2023/ToInt32.js b/node_modules/es-abstract/2023/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..c4d6bbc61bffc82e26837c7d00aff3c713aee094 --- /dev/null +++ b/node_modules/es-abstract/2023/ToInt32.js @@ -0,0 +1,23 @@ +'use strict'; + +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); +var truncate = require('./truncate'); + +var isFinite = require('../helpers/isFinite'); + +// https://262.ecma-international.org/14.0/#sec-toint32 + +var two31 = 0x80000000; // Math.pow(2, 31); +var two32 = 0x100000000; // Math.pow(2, 32); + +module.exports = function ToInt32(argument) { + var number = ToNumber(argument); + if (!isFinite(number) || number === 0) { + return 0; + } + var int = truncate(number); + var int32bit = modulo(int, two32); + var result = int32bit >= two31 ? int32bit - two32 : int32bit; + return result === 0 ? 0 : result; // in the spec, these are math values, so we filter out -0 here +}; diff --git a/node_modules/es-abstract/2023/ToString.js b/node_modules/es-abstract/2023/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..d86aed4ce88de023db08cf5689c93220b3f6f7cb --- /dev/null +++ b/node_modules/es-abstract/2023/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2023/ToUint8Clamp.js b/node_modules/es-abstract/2023/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba2fd71192ebf5a8ae55389a57ceb45deea9155 --- /dev/null +++ b/node_modules/es-abstract/2023/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('../helpers/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2023/TrimString.js b/node_modules/es-abstract/2023/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..113dcf82b82d823bee32c607bcd897bc6e36548a --- /dev/null +++ b/node_modules/es-abstract/2023/TrimString.js @@ -0,0 +1,29 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2023/Type.js b/node_modules/es-abstract/2023/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..555ca74ea51969958716accd635da40009319542 --- /dev/null +++ b/node_modules/es-abstract/2023/Type.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + if (typeof x === 'bigint') { + return 'BigInt'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2023/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2023/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2bfdff5eb705c2c866ad0623064a35be67b92b73 --- /dev/null +++ b/node_modules/es-abstract/2023/TypedArraySpeciesCreate.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2023/UnicodeEscape.js b/node_modules/es-abstract/2023/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..b708c90df0a05e9250f3dbbb9ac1044bb88b5d42 --- /dev/null +++ b/node_modules/es-abstract/2023/UnicodeEscape.js @@ -0,0 +1,27 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); + +var StringPad = require('./StringPad'); + +// https://262.ecma-international.org/11.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + StringPad($toLowerCase($numberToString(n, 16)), 4, '0', 'start'); +}; diff --git a/node_modules/es-abstract/2023/ValidateIntegerTypedArray.js b/node_modules/es-abstract/2023/ValidateIntegerTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c9c8249c6aaa9e11c158e4c22d14dbdbf2cc0fab --- /dev/null +++ b/node_modules/es-abstract/2023/ValidateIntegerTypedArray.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var Type = require('./Type'); +var TypedArrayElementType = require('./TypedArrayElementType'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var whichTypedArray = require('which-typed-array'); + +// https://262.ecma-international.org/13.0/#sec-validateintegertypedarray + +module.exports = function ValidateIntegerTypedArray(typedArray) { + var waitable = arguments.length > 1 ? arguments[1] : false; // step 1 + + if (Type(waitable) !== 'Boolean') { + throw new $TypeError('Assertion failed: `waitable` must be a Boolean'); + } + + var buffer = ValidateTypedArray(typedArray); // step 2 + + if (waitable) { // step 5 + var typeName = whichTypedArray(typedArray); + if (typeName !== 'Int32Array' && typeName !== 'BigInt64Array') { + throw new $TypeError('Assertion failed: `typedArray` must be an Int32Array or BigInt64Array when `waitable` is true'); // step 5.a + } + } else { + var type = TypedArrayElementType(typedArray); // step 5.a + if (!IsUnclampedIntegerElementType(type) && !IsBigIntElementType(type)) { + throw new $TypeError('Assertion failed: `typedArray` must be an integer TypedArray'); // step 5.b + } + } + + return buffer; // step 6 +}; diff --git a/node_modules/es-abstract/2023/ValidateTypedArray.js b/node_modules/es-abstract/2023/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aa3139381627e12d09620dbc78f46478530142 --- /dev/null +++ b/node_modules/es-abstract/2023/ValidateTypedArray.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); +var $taSome = callBound('TypedArray.prototype.some', true); + +var Type = require('./Type'); + +var isTypedArray = require('is-typed-array'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (Type(O) !== 'Object') { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: O must be a TypedArray'); + } + + // without `.some` (like in node 0.10), there's no way to check buffer detachment, but also no way to be detached + if ($taSome) { + $taSome(O, function () { return true; }); + } + + return O.buffer; +}; diff --git a/node_modules/es-abstract/2023/WeekDay.js b/node_modules/es-abstract/2023/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2023/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2023/abs.js b/node_modules/es-abstract/2023/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/2023/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2023/floor.js b/node_modules/es-abstract/2023/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..625548e936b95ca0735790d52c46f9bee5730558 --- /dev/null +++ b/node_modules/es-abstract/2023/floor.js @@ -0,0 +1,16 @@ +'use strict'; + +var Type = require('./Type'); + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/11.0/#eqn-floor + +module.exports = function floor(x) { + // return x - modulo(x, 1); + if (Type(x) === 'BigInt') { + return x; + } + return $floor(x); +}; diff --git a/node_modules/es-abstract/2023/max.js b/node_modules/es-abstract/2023/max.js new file mode 100644 index 0000000000000000000000000000000000000000..b919d4e836fe5b10b34f8290ba3449addc614050 --- /dev/null +++ b/node_modules/es-abstract/2023/max.js @@ -0,0 +1,7 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = GetIntrinsic('%Math.max%'); diff --git a/node_modules/es-abstract/2023/msFromTime.js b/node_modules/es-abstract/2023/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2023/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2023/thisBooleanValue.js b/node_modules/es-abstract/2023/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e93a28ce47cce3d864ef90f5ea4cfa6cf2c8044b --- /dev/null +++ b/node_modules/es-abstract/2023/thisBooleanValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $BooleanValueOf = require('call-bind/callBound')('Boolean.prototype.valueOf'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (Type(value) === 'Boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2023/thisNumberValue.js b/node_modules/es-abstract/2023/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..03580df26f9d84b5bf8f16d7377826977066ecdc --- /dev/null +++ b/node_modules/es-abstract/2023/thisNumberValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var Type = require('./Type'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (Type(value) === 'Number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2023/truncate.js b/node_modules/es-abstract/2023/truncate.js new file mode 100644 index 0000000000000000000000000000000000000000..3a58d73bec7be145d20836121ab3960719c254d1 --- /dev/null +++ b/node_modules/es-abstract/2023/truncate.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var floor = require('./floor'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://262.ecma-international.org/14.0/#eqn-truncate + +module.exports = function truncate(x) { + if (typeof x !== 'number' && typeof x !== 'bigint') { + throw new $TypeError('argument must be a Number or a BigInt'); + } + var result = x < 0 ? -floor(-x) : floor(x); + return result === 0 ? 0 : result; // in the spec, these are math values, so we filter out -0 here +}; diff --git a/node_modules/es-abstract/5/AbstractEqualityComparison.js b/node_modules/es-abstract/5/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..568bb409588cb78da834cc26117f132df8562703 --- /dev/null +++ b/node_modules/es-abstract/5/AbstractEqualityComparison.js @@ -0,0 +1,37 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/5.1/#sec-11.9.3 + +module.exports = function AbstractEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType === yType) { + return x === y; // ES6+ specified this shortcut anyways. + } + if (x == null && y == null) { + return true; + } + if (xType === 'Number' && yType === 'String') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (xType === 'String' && yType === 'Number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (xType === 'Boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (yType === 'Boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((xType === 'String' || xType === 'Number') && yType === 'Object') { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (xType === 'Object' && (yType === 'String' || yType === 'Number')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + return false; +}; diff --git a/node_modules/es-abstract/5/AbstractRelationalComparison.js b/node_modules/es-abstract/5/AbstractRelationalComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..0dfed5ffe1c63530db2b93ae8dd4e43acabcecd2 --- /dev/null +++ b/node_modules/es-abstract/5/AbstractRelationalComparison.js @@ -0,0 +1,63 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var isPrefixOf = require('../helpers/isPrefixOf'); + +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); +var Type = require('./Type'); + +// https://262.ecma-international.org/5.1/#sec-11.8.5 + +// eslint-disable-next-line max-statements +module.exports = function AbstractRelationalComparison(x, y, LeftFirst) { + if (Type(LeftFirst) !== 'Boolean') { + throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean'); + } + var px; + var py; + if (LeftFirst) { + px = ToPrimitive(x, $Number); + py = ToPrimitive(y, $Number); + } else { + py = ToPrimitive(y, $Number); + px = ToPrimitive(x, $Number); + } + var bothStrings = Type(px) === 'String' && Type(py) === 'String'; + if (!bothStrings) { + var nx = ToNumber(px); + var ny = ToNumber(py); + if ($isNaN(nx) || $isNaN(ny)) { + return undefined; + } + if ($isFinite(nx) && $isFinite(ny) && nx === ny) { + return false; + } + if (nx === Infinity) { + return false; + } + if (ny === Infinity) { + return true; + } + if (ny === -Infinity) { + return false; + } + if (nx === -Infinity) { + return true; + } + return nx < ny; // by now, these are both nonzero, finite, and not equal + } + if (isPrefixOf(py, px)) { + return false; + } + if (isPrefixOf(px, py)) { + return true; + } + return px < py; // both strings, neither a prefix of the other. shortcut for steps c-f +}; diff --git a/node_modules/es-abstract/5/Canonicalize.js b/node_modules/es-abstract/5/Canonicalize.js new file mode 100644 index 0000000000000000000000000000000000000000..5b8c3592c2427433e3d26b8e12e2f214b79720ab --- /dev/null +++ b/node_modules/es-abstract/5/Canonicalize.js @@ -0,0 +1,42 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var callBound = require('call-bind/callBound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $toUpperCase = callBound('String.prototype.toUpperCase'); + +var Type = require('./Type'); + +// https://262.ecma-international.org/5.1/#sec-15.10.2.8 + +module.exports = function Canonicalize(ch, IgnoreCase) { + if (Type(ch) !== 'String' || ch.length !== 1) { + throw new $TypeError('Assertion failed: `ch` must be a character'); + } + + if (Type(IgnoreCase) !== 'Boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` must be a Boolean'); + } + + if (!IgnoreCase) { + return ch; // step 1 + } + + var u = $toUpperCase(ch); // step 2 + + if (u.length !== 1) { + return ch; // step 3 + } + + var cu = u; // step 4 + + if ($charCodeAt(ch, 0) >= 128 && $charCodeAt(cu, 0) < 128) { + return ch; // step 5 + } + + return cu; +}; diff --git a/node_modules/es-abstract/5/CheckObjectCoercible.js b/node_modules/es-abstract/5/CheckObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..9083c717a357c5d21478bcced466c041141be5a2 --- /dev/null +++ b/node_modules/es-abstract/5/CheckObjectCoercible.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +// http://262.ecma-international.org/5.1/#sec-9.10 + +module.exports = function CheckObjectCoercible(value, optMessage) { + if (value == null) { + throw new $TypeError(optMessage || ('Cannot call method on ' + value)); + } + return value; +}; diff --git a/node_modules/es-abstract/5/DateFromTime.js b/node_modules/es-abstract/5/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..20e4f2e4de7f72c0ce7fabfddabf984dbc783733 --- /dev/null +++ b/node_modules/es-abstract/5/DateFromTime.js @@ -0,0 +1,54 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/5/Day.js b/node_modules/es-abstract/5/Day.js new file mode 100644 index 0000000000000000000000000000000000000000..51d01033c81cbd356ff4da8010c166137364237d --- /dev/null +++ b/node_modules/es-abstract/5/Day.js @@ -0,0 +1,11 @@ +'use strict'; + +var floor = require('./floor'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function Day(t) { + return floor(t / msPerDay); +}; diff --git a/node_modules/es-abstract/5/DayFromYear.js b/node_modules/es-abstract/5/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/5/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/5/DayWithinYear.js b/node_modules/es-abstract/5/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/5/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/5/DaysInYear.js b/node_modules/es-abstract/5/DaysInYear.js new file mode 100644 index 0000000000000000000000000000000000000000..7116c69027022323e41130f384db7cc3d35709f9 --- /dev/null +++ b/node_modules/es-abstract/5/DaysInYear.js @@ -0,0 +1,18 @@ +'use strict'; + +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DaysInYear(y) { + if (modulo(y, 4) !== 0) { + return 365; + } + if (modulo(y, 100) !== 0) { + return 366; + } + if (modulo(y, 400) !== 0) { + return 365; + } + return 366; +}; diff --git a/node_modules/es-abstract/5/FromPropertyDescriptor.js b/node_modules/es-abstract/5/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..ebf5c89154cc9df7b49bf9dc170dd89ed28061c6 --- /dev/null +++ b/node_modules/es-abstract/5/FromPropertyDescriptor.js @@ -0,0 +1,39 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.4 + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return Desc; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (IsDataDescriptor(Desc)) { + return { + value: Desc['[[Value]]'], + writable: !!Desc['[[Writable]]'], + enumerable: !!Desc['[[Enumerable]]'], + configurable: !!Desc['[[Configurable]]'] + }; + } else if (IsAccessorDescriptor(Desc)) { + return { + get: Desc['[[Get]]'], + set: Desc['[[Set]]'], + enumerable: !!Desc['[[Enumerable]]'], + configurable: !!Desc['[[Configurable]]'] + }; + } + throw new $TypeError('FromPropertyDescriptor must be called with a fully populated Property Descriptor'); + +}; diff --git a/node_modules/es-abstract/5/HourFromTime.js b/node_modules/es-abstract/5/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/5/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/5/InLeapYear.js b/node_modules/es-abstract/5/InLeapYear.js new file mode 100644 index 0000000000000000000000000000000000000000..bfe0c451f4e79b74150e5bf26fae8b507eaff216 --- /dev/null +++ b/node_modules/es-abstract/5/InLeapYear.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $EvalError = GetIntrinsic('%EvalError%'); + +var DaysInYear = require('./DaysInYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function InLeapYear(t) { + var days = DaysInYear(YearFromTime(t)); + if (days === 365) { + return 0; + } + if (days === 366) { + return 1; + } + throw new $EvalError('Assertion failed: there are not 365 or 366 days in a year, got: ' + days); +}; diff --git a/node_modules/es-abstract/5/IsAccessorDescriptor.js b/node_modules/es-abstract/5/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..102ec33e5b04307c06f52e32e08845ed7684c0de --- /dev/null +++ b/node_modules/es-abstract/5/IsAccessorDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/5/IsCallable.js b/node_modules/es-abstract/5/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/5/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/5/IsDataDescriptor.js b/node_modules/es-abstract/5/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e87078fb0509224c0e352f07380304f5694dc884 --- /dev/null +++ b/node_modules/es-abstract/5/IsDataDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/5/IsGenericDescriptor.js b/node_modules/es-abstract/5/IsGenericDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..b47bfc335dbd59c820e6b1a8ba431e33eb61f19a --- /dev/null +++ b/node_modules/es-abstract/5/IsGenericDescriptor.js @@ -0,0 +1,23 @@ +'use strict'; + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var Type = require('./Type'); + +var assertRecord = require('../helpers/assertRecord'); + +// https://262.ecma-international.org/5.1/#sec-8.10.3 + +module.exports = function IsGenericDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + assertRecord(Type, 'Property Descriptor', 'Desc', Desc); + + if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) { + return true; + } + + return false; +}; diff --git a/node_modules/es-abstract/5/IsPropertyDescriptor.js b/node_modules/es-abstract/5/IsPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..4cfe79bbe5dbcc5df02e1dae9d1859cb8d9e8cb3 --- /dev/null +++ b/node_modules/es-abstract/5/IsPropertyDescriptor.js @@ -0,0 +1,19 @@ +'use strict'; + +// TODO, semver-major: delete this + +var isPropertyDescriptor = require('../helpers/isPropertyDescriptor'); + +var Type = require('./Type'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type + +module.exports = function IsPropertyDescriptor(Desc) { + return isPropertyDescriptor({ + IsDataDescriptor: IsDataDescriptor, + IsAccessorDescriptor: IsAccessorDescriptor, + Type: Type + }, Desc); +}; diff --git a/node_modules/es-abstract/5/MakeDate.js b/node_modules/es-abstract/5/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..efeb6452e78c9f30c8aefc53fede97b874ac2e63 --- /dev/null +++ b/node_modules/es-abstract/5/MakeDate.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/5/MakeDay.js b/node_modules/es-abstract/5/MakeDay.js new file mode 100644 index 0000000000000000000000000000000000000000..13f568633a34a03b7b746ae36ac48f8916eb9838 --- /dev/null +++ b/node_modules/es-abstract/5/MakeDay.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $DateUTC = GetIntrinsic('%Date.UTC%'); + +var $isFinite = require('../helpers/isFinite'); + +var DateFromTime = require('./DateFromTime'); +var Day = require('./Day'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var MonthFromTime = require('./MonthFromTime'); +var ToInteger = require('./ToInteger'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.12 + +module.exports = function MakeDay(year, month, date) { + if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) { + return NaN; + } + var y = ToInteger(year); + var m = ToInteger(month); + var dt = ToInteger(date); + var ym = y + floor(m / 12); + var mn = modulo(m, 12); + var t = $DateUTC(ym, mn, 1); + if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) { + return NaN; + } + return Day(t) + dt - 1; +}; diff --git a/node_modules/es-abstract/5/MakeTime.js b/node_modules/es-abstract/5/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..34cb4dcca3f84920250ddb1dce54cecba114a3ad --- /dev/null +++ b/node_modules/es-abstract/5/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('../helpers/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/5/MinFromTime.js b/node_modules/es-abstract/5/MinFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a0c631d4cc56cb21e15712def6008d5623edd0f9 --- /dev/null +++ b/node_modules/es-abstract/5/MinFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerMinute = timeConstants.msPerMinute; +var MinutesPerHour = timeConstants.MinutesPerHour; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function MinFromTime(t) { + return modulo(floor(t / msPerMinute), MinutesPerHour); +}; diff --git a/node_modules/es-abstract/5/MonthFromTime.js b/node_modules/es-abstract/5/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a482a7df95f61c5c723bd70ceb220c4b5e06a2d3 --- /dev/null +++ b/node_modules/es-abstract/5/MonthFromTime.js @@ -0,0 +1,47 @@ +'use strict'; + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } +}; diff --git a/node_modules/es-abstract/5/SameValue.js b/node_modules/es-abstract/5/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..b73939b2042635df5d2b0402fdb984c95f87ce8a --- /dev/null +++ b/node_modules/es-abstract/5/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('../helpers/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/5/SecFromTime.js b/node_modules/es-abstract/5/SecFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..fc2e44560240f134cf345e63ab69d5f8a2d8cec1 --- /dev/null +++ b/node_modules/es-abstract/5/SecFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var SecondsPerMinute = timeConstants.SecondsPerMinute; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function SecFromTime(t) { + return modulo(floor(t / msPerSecond), SecondsPerMinute); +}; diff --git a/node_modules/es-abstract/5/StrictEqualityComparison.js b/node_modules/es-abstract/5/StrictEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..f3435ba9d181eb49f51d00bf6d12e960477c1991 --- /dev/null +++ b/node_modules/es-abstract/5/StrictEqualityComparison.js @@ -0,0 +1,17 @@ +'use strict'; + +var Type = require('./Type'); + +// https://262.ecma-international.org/5.1/#sec-11.9.6 + +module.exports = function StrictEqualityComparison(x, y) { + var xType = Type(x); + var yType = Type(y); + if (xType !== yType) { + return false; + } + if (xType === 'Undefined' || xType === 'Null') { + return true; + } + return x === y; // shortcut for steps 4-7 +}; diff --git a/node_modules/es-abstract/5/TimeClip.js b/node_modules/es-abstract/5/TimeClip.js new file mode 100644 index 0000000000000000000000000000000000000000..e416cab4bf318b82cfe651e1ed9b3abfeb0dbcc9 --- /dev/null +++ b/node_modules/es-abstract/5/TimeClip.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); +var $Number = GetIntrinsic('%Number%'); + +var $isFinite = require('../helpers/isFinite'); + +var abs = require('./abs'); +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.14 + +module.exports = function TimeClip(time) { + if (!$isFinite(time) || abs(time) > 8.64e15) { + return NaN; + } + return $Number(new $Date(ToNumber(time))); +}; + diff --git a/node_modules/es-abstract/5/TimeFromYear.js b/node_modules/es-abstract/5/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/5/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/5/TimeWithinDay.js b/node_modules/es-abstract/5/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/5/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/5/ToBoolean.js b/node_modules/es-abstract/5/ToBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..466404bf9992f0ba636249264c620d6c56215d6a --- /dev/null +++ b/node_modules/es-abstract/5/ToBoolean.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.2 + +module.exports = function ToBoolean(value) { return !!value; }; diff --git a/node_modules/es-abstract/5/ToInt32.js b/node_modules/es-abstract/5/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/5/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/5/ToInteger.js b/node_modules/es-abstract/5/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..d1c9b61629b3fd4b89d25aec01204225652bcbc3 --- /dev/null +++ b/node_modules/es-abstract/5/ToInteger.js @@ -0,0 +1,18 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.4 + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + if ($isNaN(number)) { return 0; } + if (number === 0 || !$isFinite(number)) { return number; } + return $sign(number) * floor(abs(number)); +}; diff --git a/node_modules/es-abstract/5/ToNumber.js b/node_modules/es-abstract/5/ToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..1e7507adb0074ea54e24a1e276eb527b89fb8185 --- /dev/null +++ b/node_modules/es-abstract/5/ToNumber.js @@ -0,0 +1,32 @@ +'use strict'; + +var ToPrimitive = require('./ToPrimitive'); + +var callBound = require('call-bind/callBound'); + +var $replace = callBound('String.prototype.replace'); + +var safeRegexTester = require('safe-regex-test'); + +var isNonDecimal = safeRegexTester(/^0[ob]|^[+-]0x/); + +// http://262.ecma-international.org/5.1/#sec-9.3 + +module.exports = function ToNumber(value) { + var prim = ToPrimitive(value, Number); + if (typeof prim !== 'string') { + return +prim; // eslint-disable-line no-implicit-coercion + } + + var trimmed = $replace( + prim, + // eslint-disable-next-line no-control-regex + /^[ \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u0085]+|[ \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u0085]+$/g, + '' + ); + if (isNonDecimal(trimmed)) { + return NaN; + } + + return +trimmed; // eslint-disable-line no-implicit-coercion +}; diff --git a/node_modules/es-abstract/5/ToObject.js b/node_modules/es-abstract/5/ToObject.js new file mode 100644 index 0000000000000000000000000000000000000000..816e537562ca1ae0097b2f5729afbb6bfa18c458 --- /dev/null +++ b/node_modules/es-abstract/5/ToObject.js @@ -0,0 +1,14 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = GetIntrinsic('%Object%'); + +var CheckObjectCoercible = require('./CheckObjectCoercible'); + +// http://262.ecma-international.org/5.1/#sec-9.9 + +module.exports = function ToObject(value) { + CheckObjectCoercible(value); + return $Object(value); +}; diff --git a/node_modules/es-abstract/5/ToPrimitive.js b/node_modules/es-abstract/5/ToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..56dfdb0cbfabdd4d38f111f9234ac01046ad4f89 --- /dev/null +++ b/node_modules/es-abstract/5/ToPrimitive.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.1 + +module.exports = require('es-to-primitive/es5'); diff --git a/node_modules/es-abstract/5/ToPropertyDescriptor.js b/node_modules/es-abstract/5/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..0af998a5d7f922a5494751846932c0987aa95ff9 --- /dev/null +++ b/node_modules/es-abstract/5/ToPropertyDescriptor.js @@ -0,0 +1,52 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); + +var Type = require('./Type'); +var ToBoolean = require('./ToBoolean'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (Type(Obj) !== 'Object') { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/5/ToString.js b/node_modules/es-abstract/5/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..c39faeb0dbe3662c0ab48aec5cb9cfcb2f8112c9 --- /dev/null +++ b/node_modules/es-abstract/5/ToString.js @@ -0,0 +1,12 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); + +// http://262.ecma-international.org/5.1/#sec-9.8 + +module.exports = function ToString(value) { + return $String(value); +}; + diff --git a/node_modules/es-abstract/5/ToUint16.js b/node_modules/es-abstract/5/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..633ca8464dd23b8c48cb91bf70f026c5e2fa91fd --- /dev/null +++ b/node_modules/es-abstract/5/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('../helpers/isNaN'); +var $isFinite = require('../helpers/isFinite'); +var $sign = require('../helpers/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/5/ToUint32.js b/node_modules/es-abstract/5/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/5/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/5/Type.js b/node_modules/es-abstract/5/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..f02303074e5c9ed5ba06b0e49344b67298f51260 --- /dev/null +++ b/node_modules/es-abstract/5/Type.js @@ -0,0 +1,24 @@ +'use strict'; + +// https://262.ecma-international.org/5.1/#sec-8 + +module.exports = function Type(x) { + if (x === null) { + return 'Null'; + } + if (typeof x === 'undefined') { + return 'Undefined'; + } + if (typeof x === 'function' || typeof x === 'object') { + return 'Object'; + } + if (typeof x === 'number') { + return 'Number'; + } + if (typeof x === 'boolean') { + return 'Boolean'; + } + if (typeof x === 'string') { + return 'String'; + } +}; diff --git a/node_modules/es-abstract/5/WeekDay.js b/node_modules/es-abstract/5/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/5/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/5/YearFromTime.js b/node_modules/es-abstract/5/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..be06ecbc36310e9f8ff1e6939dab408141051c0a --- /dev/null +++ b/node_modules/es-abstract/5/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bind/callBound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/5/abs.js b/node_modules/es-abstract/5/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc45434da5484de0bfd2685ba0fa34728274fa6 --- /dev/null +++ b/node_modules/es-abstract/5/abs.js @@ -0,0 +1,11 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/5/floor.js b/node_modules/es-abstract/5/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..8439df0649365bf9309bbea76dcfae10e64a599c --- /dev/null +++ b/node_modules/es-abstract/5/floor.js @@ -0,0 +1,11 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = Math.floor; + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function floor(x) { + // return x - modulo(x, 1); + return $floor(x); +}; diff --git a/node_modules/es-abstract/5/modulo.js b/node_modules/es-abstract/5/modulo.js new file mode 100644 index 0000000000000000000000000000000000000000..b94bb52bb3c62e45629a4b1e8f0ebba219d5e41e --- /dev/null +++ b/node_modules/es-abstract/5/modulo.js @@ -0,0 +1,9 @@ +'use strict'; + +var mod = require('../helpers/mod'); + +// https://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function modulo(x, y) { + return mod(x, y); +}; diff --git a/node_modules/es-abstract/5/msFromTime.js b/node_modules/es-abstract/5/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/5/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/CHANGELOG.md b/node_modules/es-abstract/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..2b321ebb612a9fbf06b98d6168c7145617981822 --- /dev/null +++ b/node_modules/es-abstract/CHANGELOG.md @@ -0,0 +1,768 @@ +1.22.3 / 2023-10-20 +================= + * [Fix] `ES2015`+: `GetSubstitution`: accept `undefined` instead of a hole + * [Refactor] use `hasown` instead of `has` + * [Deps] update `call-bind`, `get-intrinsic`, `object-inspect`, `which-typed-array` + * [Dev Deps] update `function-bind`, `is-core-module`, `mock-property`, `tape` + +1.22.2 / 2023-09-14 +================= + * [Fix] `ES2015`+: `NewPromiseCapability`: use AOs from the current year, not 2022 + * [Refactor] `ES2021`+: `SetTypedArrayFromArrayLike`: use `IsBigIntElementType` + * [Refactor] properly name `helpers/typedArrayConstructors` + * [Refactor] simplify helpers + * [Deps] update `arraybuffer.prototype.slice`, `function.prototype.name`, `is-typed-array`, `regexp.prototype.flags`, `safe-array-concat`, `string.prototype.trim`, `string.prototype.trimend`, `string.prototype.trimstart`, `which-typed-array` + * [actions] update actions + * [Tests] run SES tests on more node versions + * [Dev Deps] update `@unicode/unicode-15.0.0`, `array.from`, `array.prototype.filter`, `array.prototype.flatmap`, `array.prototype.indexof`, `is-core-module`, `object.fromentries`, `ses`, `tape` + +1.22.1 / 2023-07-15 +================= + * [Deps] add missing `safe-array-concat` dep + +1.22.0 / 2023-07-15 +================= + * [New] add `ES2023` + * [New] `ES2021+`: add `SetTypedArrayFromArrayLike`, `SetTypedArrayFromTypedArray` + * [New] `ES2021`+: add `CloneArrayBuffer` + * [New] `ES2020`+: add `IsValidIntegerIndex` + * [New] `ES2015`+: add `GetValueFromBuffer`, `SetValueInBuffer` + * [New] `ES2016`+: add `TypedArrayCreate`, `TypedArraySpeciesCreate` + * [New] `ES2015`+: add `IsWordChar` + * [New] `ES2017`+ add `WordCharacters` + * [New] `ES2015`+: add `Canonicalize` + * [New] `ES2015`+: add `NewPromiseCapability` + * [Fix] `ES2017+`: `NumberToRawBytes`, `NumericToRawBytes`: reimplement Float64, fix integer scenarios + * [Refactor] add `helpers/isLineTerminator` + * [Refactor] add `isInteger` helper, and use it + * [Refactor] extract `isStringOrHole` to a helper + * [Refactor] `ES2017`+: `RawBytesToNumber`, `RawBytesToNumeric`: extract common code to helpers + * [Refactor] make a `MAX_VALUE` helper + * [Tests] fix RawBytesToNumeric tests in node v10.4-10.8 + * [Tests] fix buffer test cases in node v10.4-v10.8 + +1.21.3 / 2023-07-12 +================= + * [Fix] `ES2017+`: `RawBytesToNumber`, `RawBytesToNumeric`: properly handle some scenarios + * [Fix] `ES2015`+: `GetV`: the receiver is `V`, not `O` + * [Fix] `ES2017`+: `RawBytesToNumber`, `RawBytesToNumeric`: fix exponent calculation for Float64, improve tests + * [Fix] `ES2017`+: `RawBytesToNumber`, `RawBytesToNumeric`: fix logic, improve tests + * [Fix] `ES2019`+: `thisTimeValue`: fix spackling + * [Robustness] `ES2017`+: `NumberToRawBytes`, `NumericToRawBytes`: use `SameValue` instead of `Object.is` + * [Refactor] `ES2021`+: `ValidateAtomicAccess`: use `typed-array-byte-offset` + * [Refactor] `ES2019`+: `AddEntriesFromIterable`: use `ThrowCompletion` + * [patch] `ES2015`+: `ObjectDefineProperties`: satisfy TODO + * [patch] `ES2015`+: `GetV`: improve error message + * [patch] fix spec URLs + * [Deps] update `get-intrinsic`, `regexp.prototype.flags`, `which-typed-array` + * [actions] fix permissions + * [Tests] add buffer test case fixtures + tests + * [Tests] skip test that modifies the env in SES + * [Tests] fix regex flags tests for node 20 + * [Dev Deps] update `@ljharb/eslint-config`, `aud`, `available-regexp-flags`, `is-core-module`, `tape` + +1.21.2 / 2023-03-12 +================= + * [Fix] `ES2015`+: `CreateDataProperty`: use `OrdinaryDefineOwnProperty` + * [Fix] `ES2015`+: `CreateDataProperty`: use `OrdinaryDefineOwnProperty` + * [Fix] `ES2015`+: `GetPrototypeFromConstructor`: add missing assertion that `intrinsicDefaultProto` is an object + * [Fix] `ES2015`+: `IsDetachedBuffer`: ensure a nullish error does not crash + * [Fix] `ES2015`+: `ToDateString`: properly handle time values that aren’t "now" + * [Fix] `ES2015`+: `ToUint8Clamp`: avoid an extra observable ToNumber + * [Fix] `ES2015`+`: `GetMethod`: when `func` is not callable and `P` is a symbol, avoid the wrong TypeError + * [Fix] `ES2020`+: `ToBigInt`: properly throw on anything besides string, bigint, boolean + * [Fix] `ES2021`+: `SplitMatch`: instead of `false`, return `'not-matched'` + * [Fix] `helpers/assertRecord`: handle nullish input + * [Fix] `helpers/isFullyPopulatedPropertyDescriptor`: handle primitive inputs + * [Robustness] `ES5`: `ToNumber`: avoid relying on runtime `.test` and `.replace` + * [Refactor] `ES2015`: mark `IsDataDescriptor` and `IsAccessorDescriptor` as spackled + * [Refactor] `ES2015`+: `IsDetachedBuffer`: use `array-buffer-byte-length` package + * [Refactor] `ES2015`+: `OrdinaryHasInstance`: rely on falsiness + * [Refactor] `ES2016`+: `CreateListFromArrayLike`: hoist default element types to module level + * [Refactor] `ES2022`+: `StringToNumber`, `ToNumber`: use `string.prototype.trim` + * [patch] `ES2022`+: `IsLessThan`: fix a comment + * [patch] `ES2022`+: `TypedArrayElementSize`, `TypedArrayElementType`: throw a SyntaxError with an unknown TA type + * [patch] `ES2022`+: `IsLessThan`: fix a comment + * [patch] `ES2020`+: `thisBigIntValue`: throw a SyntaxError, not TypeError, for unsupported features + * [patch] `helpers/getIteratorMethod`: `String` is always available + * [patch] fix commented spec URLs + * [patch] omit `%` for `callBound` + * [meta] fix spec URLs + * [meta] fix spackle metadata, comments + * [Deps] update `get-intrinsic`, `internal-slot`, `is-array-buffer`, `object-inspect` + * [Deps] move `function-bind` to dev deps + * [Tests] String.fromCharCode takes numbers, not strings + * [Tests] use `makeIteratorRecord` helper + * [Tests] increase coverage + * [Tests] fix tests that throw a sentinel + * [Dev Deps] update `array.from`, `available-regexp-flags`, `tape` + +1.21.1 / 2023-01-10 +================= + * [Fix] move `available-typed-arrays` to runtime deps + * [Fix] `ES2021`+: `NumberToBigInt`: throw the proper error on an env without BigInts + * [Fix] `ES2018`+: `CreateAsyncFromSyncIterator`: properly check `next` method args length + * [Fix] `ES2020`-`ES2021`: Abstract Relational Comparison: handle BigInts properly + * [Fix] `ES2022`+: `StringToBigInt`: invalid BigInts should be `undefined`, not `NaN` as in previous years + * [Fix] `helpers/isFinite`: properly handle BigInt values + * [Fix] `ES2020`+: `CreateListFromArrayLike`: accept BigInts + * [Fix] `ES2019`+: `AsyncFromSyncIteratorContinuation`: throw a SyntaxError when > 1 arg is passed + * [patch] `ES2020`+: `GetIterator`: use SyntaxError for intentionally unsupported + * [patch] `ES2015`+: `GetPrototypeFromContructor`: use SyntaxError for intentionally unsupported + * [patch] `ES2022`+: `StringToNumber`: fix non-string assertion failure message + * [Deps] update `es-set-tostringtag`, `is-array-buffer` + * [Tests] increase coverage + * [Tests] exclude coverage from files that have been replaced by an extracted package + +1.21.0 / 2023-01-04 +================= + * [New] `ES2015`+: add `IsDetachedBuffer` + * [New] `ES2015+`: add `DetachArrayBuffer` + * [New] `ES2020`+: add `NumericToRawBytes` + * [New] `ES2017` - `ES2019`: add `NumberToRawBytes` + * [New] `ES2020+`: add `RawBytesToNumeric` + * [New] `ES2017-ES2019`: add `RawBytesToNumber` + * [New] `ES2017`+: add `ValidateAtomicAccess` + * [New] `ES2021`+: add `ValidateIntegerTypedArray` + * [New] `ES2015`+: add `ValidateTypedArray` + * [New] `ES2015`+: add `GetGlobalObject` + * [New] `ES2022`+: add `TypedArrayElementSize`, `TypedArrayElementType` + * [New] `ES2015`+: add `max`, `min` + * [New] `helpers/assertRecord`: add predicates for PromiseCapability and AsyncGeneratorRequest Records + * [New] `ES2018`+: add `AsyncIteratorClose` + * [New] `ES2015`+: `IteratorClose`: also accept a Completion Record instance instead of a completion thunk + * [New] `ES2015`+ (CompletionRecord, NormalCompletion), `ES2018`+ (ThrowCompletion): add new AOs + * [New] `ES2015`+ (`ObjectCreate`) and `ES2020`+ (`OrdinaryObjectCreate`): use `internal-slot` to support additional slots + * [New] `ES2018`+: add `CreateAsyncFromSyncIterator` + * [patch] `ES2015`+: `GetMethod`: better failure message + * [Refactor] use `es-set-tostringtag` package + * [Refactor] use `has-proto` package + * [Deps] update `has-proto`, `es-set-tostringtag`, `internal-slot` + * [meta] fix spackle script to `git add` after all writing is done + * [meta] autogenerate esX entry points + * [meta] use a leading slash in gitattributes for proper spackle matching + * [Tests] fix comments on missing AOs + * [Tests] filter out host-defined AOs + * [Dev Deps] update `@ljharb/eslint-config`, `aud` + +1.20.5 / 2022-12-07 +================= + * [Fix] `ES2020+`: `floor`: make it work with BigInts as well + * [Refactor] use `gopd` + * [Tests] add `mod` helper tests (#147) + * [Deps] update `string.prototype.trimend`, `string.prototype.trimstart` + * [Dev Deps] update `array.prototype.filter`, `array.prototype.flatmap`, `array.prototype.indexof`, `object.fromentries` + +1.20.4 / 2022-10-06 +================= + * [Fix] `ES2021+`: values that truncate to -0 in `ToIntegerOrInfinity` (#146) + * [Deps] update `is-callable` + +1.20.3 / 2022-09-22 +================= + * [Refactor] extract regex tester to `safe-regex-test` package + * [Deps] update `get-intrinsic`, `is-callable` + * [Dev Deps] update `aud`, `tape` + +1.20.2 / 2022-09-01 +================= + * [Fix] `ES2020+`: `SameValueNonNumeric`: properly throw on BigInt values + * [Deps] update `object.assign`, `get-intrinsic`, `object-inspect` + * [Dev Deps] update `array.prototype.indexof`, `diff`, `es-value-fixtures`, `tape` + * [meta] `spackle`: always mkdirp new files to be written + * [Tests] fix vscode auto-const from 8fc256d + +1.20.1 / 2022-05-16 +================= + * [Fix] `thisTimeValue`: use `getTime`, not `valueOf`, to get the time value + * [Refactor] create `IsArray` helper + * [Deps] update `regexp.prototype.flags` + * [Dev Deps] use `for-each` instead of `foreach` + +1.20.0 / 2022-05-05 +================= + * [New] add ES2022 + * [New] `ES2015+`: add `ObjectDefineProperties` + * [Refactor] create `fromPropertyDescriptor` helper + * [Refactor] use `has-property-descriptors` + * [Deps] update `string.prototype.trimend`, `string.prototype.trimstart`, `unbox-primitive` + * [meta] use `npmignore` to autogenerate an npmignore file + * [Dev Deps] update `es-value-fixtures`, `has-bigints`, `functions-have-names` + * [Tests] copy GetIntrinsic tests over from `get-intrinsic` + +1.19.5 / 2022-04-13 +================= + * [Fix] `DefineOwnProperty`: FF 4-22 throws an exception when defining length of an array + * [Dev Deps] update `@ljharb/eslint-config` + +1.19.4 / 2022-04-12 +================= + * [Fix] `ES2015+`: `CreateDataProperty`: a nonwritable but configurable property is still converted to a data property + +1.19.3 / 2022-04-11 +================= + * [Fix] `ES2015+`: `GetIterator`, `IterableToArrayLike`: in Symbol-less envs, handle boxed string objects + * [Robustness] use `exec` instead of `test`, since the latter observably looks up `exec` + * [Deps] update `is-shared-array-buffer` + * [actions] restrict permissions + * [Dev Deps] update `tape` + * [Tests] add test coverage + * [Tests] avoid a bug in node v4.0 with bound function names + +1.19.2 / 2022-03-28 +================= + * [Fix] `ES2018+`: `EnumerableOwnPropertyNames`, `ToIntegerOrInfinity`, `UTF16SurrogatePairToCodePoint`: proper function names + * [Fix] `ES2015+`: `GetOwnPropertyKeys`/`IsExtensible`/`{Set,Test}IntegrityLevel`: avoid a crash in IE 8 on missing ES5 intrinsics + * [Fix] `helpers/DefineOwnProperty`: avoid a crash in IE 8 + * [Fix] `ES2015+`: `StringCreate`: properly check for `prototype` being `String.prototype` + * [Docs] `ES2015+`: `GetV`: Fix spec URL + * [meta] operations: use a URL object instead of a URL string + * [meta] remove defunct greenkeeper config + * [meta] better `eccheck` command; fix indentation + * [Tests] node v0.6 lacks `RegExp.prototype.source` + * [Tests] remove a stray `console.log` + * [Tests] properly set the lastIndex in IE 8 + * [Tests] skip test due to IE 6-8 sparse/undefined bug + * [Tests] in IE 8, an empty regex is `` and not `(?:)` + * [Tests] ES3 engines don’t have `.bind` + * [Tests] avoid needless failures in ES3 engines that don't support descriptors + * [Tests] add test to cover https://github.com/tc39/ecma262/issues/2611 + * [Deps] update `has-symbols`, `is-negative-zero`, `is-weakref`, `object-inspect` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object.fromentries`, `safe-publish-latest`, `tape` + * [actions] reuse common workflows + * [actions] update codecov uploader + +1.19.1 / 2021-10-02 +================= + * [Fix] `ES2020+`: `CreateRegExpStringIterator`: should not have enumerable methods + * [Dev Deps] update `array.prototype.filter`, `array.prototype.indexof` + +1.19.0 / 2021-09-30 +================= + * [New] `ES2021+`: `IterableToList`: make `method` parameter optional (#61) + * [New] add ES2021 + * [New] `ES2020+`: add `StringToBigInt`, `ToBigInt`, `ToBigInt64`, `ToBigUint64` + * [New] `ES2017`+: add `IsSharedArrayBuffer`, `OrdinaryToPrimitive` + * [New] `ES2015+`: add `CharacterRange`, `IsCompatiblePropertyDescriptor` + * [New] `ES2020+`: add `CreateRegExpStringIterator` + * [Fix] `ES2020+`: `ToBigInt64`/`ToBigUint64`: avoid node v10.4-v10.8 bug with limited BigInt range + * [Fix] `ES2020+`: `AbstractRelationalComparison`, `AbstractEqualityComparison`: support BigInt + * [Fix] `ES2020+`: `ToBigInt64`/`ToBigUint64`: Improve the definitions of twoSixtyThree and twoSixtyFour (#140) + * [meta] do not publish .gitattributes + * [Tests] Correct the behavior of `safeBigInt` + * [Tests] Exclude dotfiles from the testing sweep (#141) + +1.18.7 / 2021-09-28 +================= + * [Fix] `getOwnPropertyDescriptor` helper: avoid crashing in IE < 9 + * [Fix] `ArraySetLength`: `node` `v0.6` has a bug where array lengths can be Set but not Defined + * [eslint] remove unused directive + * [Tests] fix spelling + +1.18.6 / 2021-09-07 +================= + * [Fix] `ES2020+`: `NumberToBigInt`: throw a SyntaxError when BigInts are not supported + * [Refactor] extract getSymbolDescription logic to `get-symbol-description` + * [Refactor] `ES2018+`: `AbstractRelationalComparison`: use `IsStringPrefix` + * [Deps] update `is-callable`, `is-regex`, `is-string` + * [Dev Deps] update `@ljharb/eslint-config`, `tape` + * [Tests] `GetSubstitution`: add cases + +1.18.5 / 2021-08-01 +================= + * [meta] remove "exports" (#133) + * [Dev Deps] update `eslint` + +1.18.4 / 2021-07-29 +================= + * [meta] partial revert of b54cfe8525faff482450e843a49d43be3a086225 + * [Deps] update `internal-slot`, `object-inspect` + * [Dev Deps] update `eslint`, `tape` + * [Tests] `ArraySetLength`: increase coverage + +1.18.3 / 2021-05-27 +================= + * [Fix] `ES2020+`: `ToNumber`: ensure it throws on a BigInt (#130) + +1.18.2 / 2021-05-25 +================= + * [meta] add `helpers` to "exports" field, for back compat + +1.18.1 / 2021-05-25 +================= + * [readme] update and clarify entry points + * [meta] add "exports" field, with escape hatch + * [meta] add `sideEffects` field + * [meta] use `prepublishOnly`, for npm 7+ + * [eslint] clean up eslint rules + * [Deps] update `is-regex`, `is-string`, `object-inspect`, `unbox-primitive` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` + * [actions] disable fail-fast on matrix jobs + * [actions] use `node/install` action instead of `node/run` + * [actions] update codeql-analysis to new best practices + +1.18.0 / 2021-03-03 +================= + * [New] add `ES2020`, and a number of additional AOs: See the changelog entries for the prereleases for more information: + - [next.3](./CHANGELOG.md#1180-next3--2021-03-01) + - [next.2](./CHANGELOG.md#1180-next2--2021-01-17) + - [next.1](./CHANGELOG.md#1180-next1--2020-09-30) + - [next.0](./CHANGELOG.md#1180-next0--2020-08-14) + * [Refactor] `ES5+`: `Abstract Relational Comparison`: increase coverage + * [Tests] increase coverage + * [Tests] do not run coverage on node 0.6 + +1.18.0-next.3 / 2021-03-01 +================= + * [New] `ES2015`: add `StringGetIndexProperty` + * [New] `ES2015+`: add `RegExpCreate`, `SplitMatch`, `StringCreate` + * [New] `ES2016-ES2019`: add `UTF16Decode` + * [New] `ES2020+`: add `NumberToBigInt` + * [New] `ES2020+: add `BigInt::`/`Number::` methods: + * [Fix] `ES5`: `ToNumber`: properly refuse to parse ES6+ forms + * [Fix] `ES2015+`: `Invoke`: optional argumentsList must be a List of arguments, not a list of arguments + * [Fix] `ES2016+`: `UTF16Encoding`: properly return a string code point instead of a numeric code point + * [Fix] `ES2020`: `NumberBitwiseOp`: assert that x and y are Numbers + * [readme] remove travis/testling badge, fix repo URLs + * [meta] `ES2015`: add missing `CreateArrayIterator` AO + * [meta] `ES2015-ES2017`: add missing `DaylightSavingTA` AO + * [meta] rerun `npm run spackle` to update URLs left after 11d8c8df11c0d15d094a6035afed662e22b440ef + * [meta] update ecma URLs + * [meta] unignore 2020 operations list + * [meta] update operations scripts linting + * [meta] refactor getOps script to fetch all years at once + * [meta] refactor operations script to keep years in one place + * [meta] fix ES2015 spec URL + * [Deps] update `has-symbols`, `string.prototype.trimend`, `string.prototype.trimstart`, `get-intrinsic`, `is-callable`, `is-regex` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `array.prototype.indexof`, `aud`, `es-value-fixtures`, `object.fromentries`, `tape`, `diff` + * [operations] detect ES2020+ style `T::` numeric operations + * [Tests] increase coverage + * [Tests] `BigInt(1e17)` throws on node v10.4-v10.6 + * [Tests] improve coverage on `Number::` methods + * [Tests] `tape` v5 `.equal` now uses strict equality, so no more need for `is()` + * [Tests] improve BigInt:: and Number:: coverage + * [Tests] actually run all the helpers tests + * [Tests] ensure "expected missing" ops list is accurate + * [Tests] abstract away per-operation skips + * [Tests] skip BigInt:: tests on envs without BigInts + * [Tests] use `es-value-fixtures` + * [actions] update workflows + +1.18.0-next.2 / 2021-01-17 +================= + * [New] `helpers`: add `isByteValue`, `isCodePoint`, `some` + * [Fix] `ES2018+`: fix `GetSubstitution` with named captures + * [Fix] `ES2020`: `GetIterator`: add omitted `hint` parameter + * [Fix] `ES2018`/`ES2019`: `SetFunctionLength`: Infinities should throw + * [Fix] `ES2020`: `ToIndex` uses `SameValue` instead of `SameValueZero` + * [Fix] `ES2020`: `CopyDataProperties` uses `CreateDataPropertyOrThrow` instead of `CreateDataProperty` + * [Refactor] use extracted `call-bind` instead of local helpers + * [Refactor] use extracted `get-intrinsic` package + * [Deps] update `call-bind`, `get-intrinsic`, `is-callable`, `is-negative-zero`, `is-regex`, `object-inspect`, `object.assign`, `string.prototype.trimend`, `string.prototype.trimstart` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `array.prototype.indexof`, `aud`, `diff`, `functions-have-names`, `has-bigints`, `has-strict-mode`, `object-is`, `object.fromentries`, `tape` + * [actions] switch Automatic Rebase workflow to `pull_request_target` event + * [actions] add "Allow Edits" workflow + * [meta] pin cheerio to v1.0.0-rc.3, to fix getOps + * [meta] make all URLs consistent, and point to spec artifacts + * [meta] refactor `deltas` script; update eslint on operations scripts + * [meta] do not publish .github dir (#123) + * [Tests] add `v.notNonNegativeIntegers`, `v.nonConstructorFunctions` + * [Tests] migrate tests to Github Actions + * [Tests] run coverage on all tests + * [Tests] add `npm run test:ses` + +1.18.0-next.1 / 2020-09-30 +================= + * [Fix] `ES2020`: `ToInteger`: `-0` should always be normalized to `+0` (#116) + * [patch] `GetIntrinsic`: Adapt to override-mistake-fix pattern (#115) + * [Fix] `callBind`: ensure compatibility with SES + * [Deps] update `is-callable`, `object.assign` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config` + * [eslint] fix warning + * [Tests] temporarily allow SES tests to fail (#115) + * [Tests] ses-compat - initialize module after ses lockdown (#113) + * [Tests] [Refactor] use defineProperty helper rather than assignment + * [Tests] [Refactor] clean up defineProperty test helper + +1.18.0-next.0 / 2020-08-14 +================= + * [New] add `ES2020` + * [New] `GetIntrinsic`: add `%AggregateError%`, `%FinalizationRegistry%`, and `%WeakRef%` + * [New] `ES5`+: add `abs`, `floor`; use `modulo` consistently + * [New] `GetIntrinsic`: Cache accessed intrinsics (#98) + * [New] `GetIntrinsic`: Add ES201x function intrinsics (#97) + * [New] `ES2015`+: add `QuoteJSONString`, `OrdinaryCreateFromConstructor` + * [New] `ES2017`+: add `StringGetOwnProperty` + * [New] `ES2016`+: add `UTF16Encoding` + * [New] `ES2018`+: add `SetFunctionLength`, `UnicodeEscape` + * [New] add `isLeadingSurrogate`/`isTrailingSurrogate` helpers + * [Fix] `ES5`+: `ToPropertyDescriptor`: use intrinsic TypeError + * [Fix] `ES2018+`: `CopyDataProperties`/`NumberToString`: use intrinsic TypeError + * [Deps] update `is-regex`, `object-inspect` + * [Dev Deps] update `eslint` + +1.17.7 / 2020-09-30 +================= + * [Fix] `ES2020`: `ToInteger`: `-0` should always be normalized to `+0` (#116) + * [patch] `GetIntrinsic`: Adapt to override-mistake-fix pattern (#115) + * [Fix] `callBind`: ensure compatibility with SES + * [Deps] update `is-callable`, `is-regex`, `object-inspect`, `object.assign` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config` + +1.17.6 / 2020-06-13 +================= + * [Fix] `helpers/getSymbolDescription`: use the global Symbol registry when available (#92) + * [Fix] `ES2015+`: `IsConstructor`: when `Reflect.construct` is available, be spec-accurate (#93) + * [Fix] `ES2015+`: `Set`: Always return boolean value (#101) + * [Fix] `ES2015+`: `Set`: ensure exceptions are thrown in IE 9 when requested + * [Fix] Use `Reflect.apply(…)` if available (#99) + * [Fix] `helpers/floor`: module-cache `Math.floor` + * [Fix] `helpers/getSymbolDescription`: Prefer bound `description` getter when present + * [Fix] `2016`: Use `getIteratorMethod` in `IterableToArrayLike` (#94) + * [Fix] `helpers/OwnPropertyKeys`: Use `Reflect.ownKeys(…)` if available (#91) + * [Fix] `2018+`: Fix `CopyDataProperties` depending on `this` (#95) + * [meta] mark spackled files as autogenerated + * [meta] `Type`: fix spec URL + * [meta] `ES2015`: complete ops list + * [Deps] update `is‑callable`, `is‑regex` + * [Deps] switch from `string.prototype.trimleft`/`string.prototype.trimright` to `string.prototype.trimstart`/`string.prototype.trimend` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `in-publish`, `object-is`, `tape`; add `aud` + * [eslint] `helpers/isPropertyDescriptor`: fix indentation + * [Tests] `helpers/getSymbolDescription`: add test cases; some envs have `Symbol.for` but can not infer a name (#92) + * [Tests] try out CodeQL analysis + * [Tests] reformat expected missing ops + * [Tests] Run tests with `undefined` this (#96) + +1.17.5 / 2020-03-22 +================= + * [Fix] `CreateDataProperty`: update an existing property + * [Fix] run missing spackle from cd7504701879ddea0f5981e99cbcf93bfea9171d + * [Dev Deps] update `make-arrow-function`, `tape`, `@ljharb/eslint-config` + +1.17.4 / 2020-01-21 +================= + * [Fix] `2015+`: add code to handle IE 8’s problems + * [Tests] fix tests for IE 8 + +1.17.3 / 2020-01-19 +================= + * [Fix] `ObjectCreate` `2015+`: Fall back to `__proto__` and normal `new` in older browsers + * [Fix] `GetIntrinsic`: ensure the `allowMissing` property actually works on dotted intrinsics + +1.17.2 / 2020-01-14 +================= + * [Fix] `helpers/OwnPropertyKeys`: include non-enumerables too + +1.17.1 / 2020-01-14 +================= + * [Refactor] add `OwnPropertyKeys` helper, use it in `CopyDataProperties` + * [Refactor] `IteratorClose`: remove useless assignment + * [Dev Deps] update `eslint`, `tape`, `diff` + +1.17.0 / 2019-12-20 +================= + * [New] Split up each operation into its own file (prereleased) + * [Fix] `GetIntrinsic`: IE 8 has a broken `Object.getOwnPropertyDescriptor` + * [Fix] `object.assign` is a runtime dep (prereleased) + * [Refactor] `GetIntrinsic`: remove the internal property salts, since % already handles that + * [Refactor] `GetIntrinsic`: further simplification + * [Deps] update `is-callable`, `string.prototype.trimleft`, `string.prototype.trimright`, `is-regex` + * [Dev Deps] update `@ljharb/eslint-config`, `object-is`, `object.fromentries`, `tape` + * [Tests] add `.eslintignore` + * [meta] remove unused Makefile and associated utils + * [meta] only run spackle script in publish (#78) (prereleased) + +1.17.0-next.1 / 2019-12-11 +================= + * [Fix] `object.assign` is a runtime dep + * [meta] only run spackle script in publish (#78) + +1.17.0-next.0 / 2019-12-11 +================= + * [New] Split up each operation into its own file + +1.16.3 / 2019-12-04 +================= + * [Fix] `GetIntrinsic`: when given a path to a getter, return the actual getter + * [Dev Deps] update `eslint` + +1.16.2 / 2019-11-24 +================= + * [Fix] IE 6-7 lack JSON + * [Fix] IE 6-8 strings can’t use array slice, they need string slice + * [Dev Deps] update `eslint` + +1.16.1 / 2019-11-24 +================= + * [Fix] `GetIntrinsics`: turns out IE 8 throws when `Object.getOwnPropertyDescriptor(arguments);`, and does not throw on `callee` anyways + * [Deps] update `es-to-primitive`, `has-symbols`, `object-inspect` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest` + * [meta] re-include year files inside `operations` + * [meta] add `funding` field + * [actions] add Automatic Rebase github action + * [Tests] use shared travis-ci config + * [Tests] disable `check-coverage`, and let codecov do it + +1.16.0 / 2019-10-18 +================= + * [New] `ES2015+`: add `SetFunctionName` + * [New] `ES2015+`: add `GetPrototypeFromConstructor`, with caveats + * [New] `ES2015+`: add `CreateListFromArrayLike` + * [New] `ES2016+`: add `OrdinarySetPrototypeOf` + * [New] `ES2016+`: add `OrdinaryGetPrototypeOf` + * [New] add `getSymbolDescription` and `getInferredName` helpers + * [Fix] `GetIterator`: add fallback for pre-Symbol environments, tests + * [Dev Deps] update `object.fromentries` + * [Tests] add `node` `v12.2` + +1.15.0 / 2019-10-02 +================= + * [New] `ES2018`+: add `DateString`, `TimeString` + * [New] `ES2015`+: add `ToDateString` + * [New] `ES5`+: add `msFromTime`, `SecFromTime`, `MinFromTime`, `HourFromTime`, `TimeWithinDay`, `Day`, `DayFromYear`, `TimeFromYear`, `YearFromTime`, `WeekDay`, `DaysInYear`, `InLeapYear`, `DayWithinYear`, `MonthFromTime`, `DateFromTime`, `MakeDay`, `MakeDate`, `MakeTime`, `TimeClip`, `modulo` + * [New] add `regexTester` helper + * [New] add `callBound` helper + * [New] add ES2020’s intrinsic dot notation + * [New] add `isPrefixOf` helper + * [New] add `maxSafeInteger` helper + * [Deps] update `string.prototype.trimleft`, `string.prototype.trimright` + * [Dev Deps] update `eslint` + * [Tests] on `node` `v12.11` + * [meta] npmignore operations scripts; add "deltas" + +1.14.2 / 2019-09-08 +================= + * [Fix] `ES2016`: `IterableToArrayLike`: add proper fallback for strings, pre-Symbols + * [Tests] on `node` `v12.10` + +1.14.1 / 2019-09-03 +================= + * [meta] republish with some extra files removed + +1.14.0 / 2019-09-02 +================= + * [New] add ES2019 + * [New] `ES2017+`: add `IterableToList` + * [New] `ES2016`: add `IterableToArrayLike` + * [New] `ES2015+`: add `ArrayCreate`, `ArraySetLength`, `OrdinaryDefineOwnProperty`, `OrdinaryGetOwnProperty`, `OrdinaryHasProperty`, `CreateHTML`, `GetOwnPropertyKeys`, `InstanceofOperator`, `SymbolDescriptiveString`, `GetSubstitution`, `ValidateAndApplyPropertyDescriptor`, `IsPromise`, `OrdinaryHasInstance`, `TestIntegrityLevel`, `SetIntegrityLevel` + * [New] add `callBind` helper, and use it + * [New] add helpers: `isPropertyDescriptor`, `every` + * [New] ES5+: add `Abstract Relational Comparison` + * [New] ES5+: add `Abstract Equality Comparison`, `Strict Equality Comparison` + * [Fix] `ES2015+`: `GetIterator`: only require native Symbols when `method` is omitted + * [Fix] `ES2015`: `Call`: error message now properly displays Symbols using `object-inspect` + * [Fix] `ES2015+`: `ValidateAndApplyPropertyDescriptor`: use ES2017 logic to bypass spec bugs + * [Fix] `ES2015+`: `CreateDataProperty`, `DefinePropertyOrThrow`, `ValidateAndApplyPropertyDescriptor`: add fallbacks for ES3 + * [Fix] `ES2015+`: `FromPropertyDescriptor`: no longer requires a fully complete Property Descriptor + * [Fix] `ES5`: `IsPropertyDescriptor`: call into `IsDataDescriptor` and `IsAccessorDescriptor` + * [Refactor] use `has-symbols` for Symbol detection + * [Fix] `helpers/assertRecord`: remove `console.log` + * [Deps] update `object-keys` + * [readme] add security note + * [meta] change http URLs to https + * [meta] linter cleanup + * [meta] fix getOps script + * [meta] add FUNDING.yml + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `semver`, `replace`, `cheerio`, `tape` + * [Tests] up to `node` `v12.9`, `v11.15`, `v10.16`, `v8.16`, `v6.17` + * [Tests] temporarily allow node 0.6 to fail; segfaulting in travis + * [Tests] use the values helper more in es5 tests + * [Tests] fix linting to apply to all files + * [Tests] run `npx aud` only on prod deps + * [Tests] add v.descriptors helpers + * [Tests] use `npx aud` instead of `npm audit` with hoops + * [Tests] use `eclint` instead of `editorconfig-tools` + * [Tests] some intrinsic cleanup + * [Tests] migrate es5 tests to use values helper + * [Tests] add some missing ES2015 ops + +1.13.0 / 2019-01-02 +================= + * [New] add ES2018 + * [New] add ES2015/ES2016: EnumerableOwnNames; ES2017: EnumerableOwnProperties + * [New] `ES2015+`: add `thisBooleanValue`, `thisNumberValue`, `thisStringValue`, `thisTimeValue` + * [New] `ES2015+`: add `DefinePropertyOrThrow`, `DeletePropertyOrThrow`, `CreateMethodProperty` + * [New] add `assertRecord` helper + * [Deps] update `is-callable`, `has`, `object-keys`, `es-to-primitive` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`, `semver`, `safe-publish-latest`, `replace` + * [Tests] use `npm audit` instead of `nsp` + * [Tests] remove `jscs` + * [Tests] up to `node` `v11.6`, `v10.15`, `v8.15`, `v6.16` + * [Tests] move descriptor factories to `values` helper + * [Tests] add `getOps` to programmatically fetch abstract operation names + +1.12.0 / 2018-05-31 +================= + * [New] add `GetIntrinsic` entry point + * [New] `ES2015`+: add `ObjectCreate` + * [Robustness]: `ES2015+`: ensure `Math.{abs,floor}` and `Function.call` are cached + +1.11.0 / 2018-03-21 +================= + * [New] `ES2015+`: add iterator abstract ops + * [Dev Deps] update `eslint`, `nsp`, `object.assign`, `semver`, `tape` + * [Tests] up to `node` `v9.8`, `v8.10`, `v6.13` + +1.10.0 / 2017-11-24 +================= + * [New] ES2015+: `AdvanceStringIndex` + * [Dev Deps] update `eslint`, `nsp` + * [Tests] require node 0.6 to pass again + * [Tests] up to `node` `v9.2`, `v8.9`, `v6.12`; use `nvm install-latest-npm`; pin included builds to LTS + +1.9.0 / 2017-09-30 +================= + * [New] `es2015+`: add `ArraySpeciesCreate` + * [New] ES2015+: add `CreateDataProperty` and `CreateDataPropertyOrThrow` + * [Tests] consolidate duplicated tests + * [Tests] increase coverage + * [Dev Deps] update `nsp`, `eslint` + +1.8.2 / 2017-09-03 +================= + * [Fix] `es2015`+: `ToNumber`: provide the proper hint for Date objects (#27) + * [Dev Deps] update `eslint` + +1.8.1 / 2017-08-30 +================= + * [Fix] ES2015+: `ToPropertyKey`: should return a symbol for Symbols (#26) + * [Deps] update `function-bind` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config` + * [Docs] github broke markdown parsing + +1.8.0 / 2017-08-04 +================= + * [New] add ES2017 + * [New] move es6+ to es2015+; leave es6/es7 as aliases + * [New] ES5+: add `IsPropertyDescriptor`, `IsAccessorDescriptor`, `IsDataDescriptor`, `IsGenericDescriptor`, `FromPropertyDescriptor`, `ToPropertyDescriptor` + * [New] ES2015+: add `CompletePropertyDescriptor`, `Set`, `HasOwnProperty`, `HasProperty`, `IsConcatSpreadable`, `Invoke`, `CreateIterResultObject`, `RegExpExec` + * [Fix] es7/es2016: do not mutate ES6 + * [Fix] assign helper only supports one source + * [Deps] update `is-regex` + * [Dev Deps] update `nsp`, `eslint`, `@ljharb/eslint-config` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `nsp`, `semver`, `tape` + * [Tests] add tests for missing and excess operations + * [Tests] add codecov for coverage + * [Tests] up to `node` `v8.2`, `v7.10`, `v6.11`, `v4.8`; newer npm breaks on older node + * [Tests] use same lists of value types across tests; ensure tests are the same when ops are the same + * [Tests] ES2015: add ToNumber symbol tests + * [Tests] switch to `nyc` for code coverage + * [Tests] make IsRegExp tests consistent across editions + +1.7.0 / 2017-01-22 +================= + * [New] ES6: Add `GetMethod` (#16) + * [New] ES6: Add `GetV` (#16) + * [New] ES6: Add `Get` (#17) + * [Tests] up to `node` `v7.4`, `v6.9`, `v4.6`; improve test matrix + * [Dev Deps] update `tape`, `nsp`, `eslint`, `@ljharb/eslint-config`, `safe-publish-latest` + +1.6.1 / 2016-08-21 +================= + * [Fix] ES6: IsConstructor should return true for `class` constructors. + +1.6.0 / 2016-08-20 +================= + * [New] ES5 / ES6: add `Type` + * [New] ES6: `SpeciesConstructor` + * [Dev Deps] update `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver`; add `safe-publish-latest` + * [Tests] up to `node` `v6.4`, `v5.12`, `v4.5` + +1.5.1 / 2016-05-30 +================= + * [Fix] `ES.IsRegExp`: actually look up `Symbol.match` on the argument + * [Refactor] create `isNaN` helper + * [Deps] update `is-callable`, `function-bind` + * [Deps] update `es-to-primitive`, fix ES5 tests + * [Dev Deps] update `jscs`, `eslint`, `@ljharb/eslint-config`, `tape`, `nsp` + * [Tests] up to `node` `v6.2`, `v5.11`, `v4.4` + * [Tests] use pretest/posttest for linting/security + +1.5.0 / 2015-12-27 +================= + * [New] adds `Symbol.toPrimitive` support via `es-to-primitive` + * [Deps] update `is-callable`, `es-to-primitive` + * [Dev Deps] update `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver`, `tape` + * [Tests] up to `node` `v5.3` + +1.4.3 / 2015-11-04 +================= + * [Fix] `ES6.ToNumber`: should give `NaN` for explicitly signed hex strings (#4) + * [Refactor] `ES6.ToNumber`: No need to double-trim + * [Refactor] group tests better + * [Tests] should still pass on `node` `v0.8` + +1.4.2 / 2015-11-02 +================= + * [Fix] ensure `ES.ToNumber` trims whitespace, and does not trim non-whitespace (#3) + +1.4.1 / 2015-10-31 +================= + * [Fix] ensure only 0-1 are valid binary and 0-7 are valid octal digits (#2) + * [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config` + * [Tests] on `node` `v5.0` + * [Tests] fix npm upgrades for older node versions + * package.json: use object form of "authors", add "contributors" + +1.4.0 / 2015-09-26 +================= + * [Deps] update `is-callable` + * [Dev Deps] update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` + * [Tests] on `node` `v4.2` + * [New] Add `SameValueNonNumber` to ES7 + +1.3.2 / 2015-09-26 +================= + * [Fix] Fix `ES6.IsRegExp` to properly handle `Symbol.match`, per spec. + * [Tests] up to `io.js` `v3.3`, `node` `v4.1` + * [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver` + +1.3.1 / 2015-08-15 +================= + * [Fix] Ensure that objects that `toString` to a binary or octal literal also convert properly + +1.3.0 / 2015-08-15 +================= + * [New] ES6’s ToNumber now supports binary and octal literals. + * [Dev Deps] update `jscs`, `eslint`, `@ljharb/eslint-config`, `tape` + * [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG + * [Tests] up to `io.js` `v3.0` + +1.2.2 / 2015-07-28 +================= + * [Fix] Both `ES5.CheckObjectCoercible` and `ES6.RequireObjectCoercible` return the value if they don't throw. + * [Tests] Test on latest `io.js` versions. + * [Dev Deps] Update `eslint`, `jscs`, `tape`, `semver`, `covert`, `nsp` + +1.2.1 / 2015-03-20 +================= + * Fix `isFinite` helper. + +1.2.0 / 2015-03-19 +================= + * Use `es-to-primitive` for ToPrimitive methods. + * Test on latest `io.js` versions; allow failures on all but 2 latest `node`/`io.js` versions. + +1.1.2 / 2015-03-20 +================= + * Fix isFinite helper. + +1.1.1 / 2015-03-19 +================= + * Fix isPrimitive check for functions + * Update `eslint`, `editorconfig-tools`, `semver`, `nsp` + +1.1.0 / 2015-02-17 +================= + * Add ES7 export (non-default). + * All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. + * Test on `iojs-v1.2`. + +1.0.1 / 2015-01-30 +================= + * Use `is-callable` instead of an internal function. + * Update `tape`, `jscs`, `nsp`, `eslint` + +1.0.0 / 2015-01-10 +================= + * v1.0.0 diff --git a/node_modules/es-abstract/GetIntrinsic.js b/node_modules/es-abstract/GetIntrinsic.js new file mode 100644 index 0000000000000000000000000000000000000000..d7e67b47dc441e8d398ed25d8ab28eccedbabd5a --- /dev/null +++ b/node_modules/es-abstract/GetIntrinsic.js @@ -0,0 +1,5 @@ +'use strict'; + +// TODO: remove, semver-major + +module.exports = require('get-intrinsic'); diff --git a/node_modules/es-abstract/LICENSE b/node_modules/es-abstract/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..3f137ce0c3fc306a4d1dace0721253cf38b51535 --- /dev/null +++ b/node_modules/es-abstract/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (C) 2015 Jordan Harband + +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. diff --git a/node_modules/es-abstract/README.md b/node_modules/es-abstract/README.md new file mode 100644 index 0000000000000000000000000000000000000000..08f7b1c2a03fbd3911915c0e772858aa6bf21128 --- /dev/null +++ b/node_modules/es-abstract/README.md @@ -0,0 +1,43 @@ +# es-abstract [![Version Badge][npm-version-svg]][package-url] + +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +ECMAScript spec abstract operations. + +Every operation is available by edition/year and by name - for example, `es-abstract/2020/Call` gives you the `Call` operation from ES2020, `es-abstract/5/Type` gives you the `Type` operation from ES5. + +All abstract operations are also available under an `es5`/`es2015`/`es2016`/`es2017`/`es2018`/`es2019`/`es2020`/`es2021` entry point, and as a property on the `main` export, but using deep imports is highly encouraged for bundle size and performance reasons. Non-deep entry points will be removed in the next semver-major release. + +## Example + +```js +var ES = require('es-abstract'); +var assert = require('assert'); + +assert(ES.isCallable(function () {})); +assert(!ES.isCallable(/a/g)); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +## Security + +Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report. + +[package-url]: https://npmjs.org/package/es-abstract +[npm-version-svg]: https://versionbadg.es/ljharb/es-abstract.svg +[deps-svg]: https://david-dm.org/ljharb/es-abstract.svg +[deps-url]: https://david-dm.org/ljharb/es-abstract +[dev-deps-svg]: https://david-dm.org/ljharb/es-abstract/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/es-abstract#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/es-abstract.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/es-abstract.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/es-abstract.svg +[downloads-url]: https://npm-stat.com/charts.html?package=es-abstract diff --git a/node_modules/es-abstract/es2015.js b/node_modules/es-abstract/es2015.js new file mode 100644 index 0000000000000000000000000000000000000000..1033716cefb335ada6e0b01f6b5290ed69ae6c02 --- /dev/null +++ b/node_modules/es-abstract/es2015.js @@ -0,0 +1,139 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/6.0/#sec-abstract-operations +var ES2015 = { + 'Abstract Equality Comparison': require('./2015/AbstractEqualityComparison'), + 'Abstract Relational Comparison': require('./2015/AbstractRelationalComparison'), + 'Strict Equality Comparison': require('./2015/StrictEqualityComparison'), + abs: require('./2015/abs'), + AdvanceStringIndex: require('./2015/AdvanceStringIndex'), + ArrayCreate: require('./2015/ArrayCreate'), + ArraySetLength: require('./2015/ArraySetLength'), + ArraySpeciesCreate: require('./2015/ArraySpeciesCreate'), + Call: require('./2015/Call'), + Canonicalize: require('./2015/Canonicalize'), + CanonicalNumericIndexString: require('./2015/CanonicalNumericIndexString'), + CharacterRange: require('./2015/CharacterRange'), + CompletePropertyDescriptor: require('./2015/CompletePropertyDescriptor'), + CompletionRecord: require('./2015/CompletionRecord'), + CreateDataProperty: require('./2015/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2015/CreateDataPropertyOrThrow'), + CreateHTML: require('./2015/CreateHTML'), + CreateIterResultObject: require('./2015/CreateIterResultObject'), + CreateListFromArrayLike: require('./2015/CreateListFromArrayLike'), + CreateMethodProperty: require('./2015/CreateMethodProperty'), + DateFromTime: require('./2015/DateFromTime'), + Day: require('./2015/Day'), + DayFromYear: require('./2015/DayFromYear'), + DaysInYear: require('./2015/DaysInYear'), + DayWithinYear: require('./2015/DayWithinYear'), + DefinePropertyOrThrow: require('./2015/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2015/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2015/DetachArrayBuffer'), + EnumerableOwnNames: require('./2015/EnumerableOwnNames'), + floor: require('./2015/floor'), + FromPropertyDescriptor: require('./2015/FromPropertyDescriptor'), + Get: require('./2015/Get'), + GetGlobalObject: require('./2015/GetGlobalObject'), + GetIterator: require('./2015/GetIterator'), + GetMethod: require('./2015/GetMethod'), + GetOwnPropertyKeys: require('./2015/GetOwnPropertyKeys'), + GetPrototypeFromConstructor: require('./2015/GetPrototypeFromConstructor'), + GetSubstitution: require('./2015/GetSubstitution'), + GetV: require('./2015/GetV'), + GetValueFromBuffer: require('./2015/GetValueFromBuffer'), + HasOwnProperty: require('./2015/HasOwnProperty'), + HasProperty: require('./2015/HasProperty'), + HourFromTime: require('./2015/HourFromTime'), + InLeapYear: require('./2015/InLeapYear'), + InstanceofOperator: require('./2015/InstanceofOperator'), + Invoke: require('./2015/Invoke'), + IsAccessorDescriptor: require('./2015/IsAccessorDescriptor'), + IsArray: require('./2015/IsArray'), + IsCallable: require('./2015/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2015/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2015/IsConcatSpreadable'), + IsConstructor: require('./2015/IsConstructor'), + IsDataDescriptor: require('./2015/IsDataDescriptor'), + IsDetachedBuffer: require('./2015/IsDetachedBuffer'), + IsExtensible: require('./2015/IsExtensible'), + IsGenericDescriptor: require('./2015/IsGenericDescriptor'), + IsInteger: require('./2015/IsInteger'), + IsPromise: require('./2015/IsPromise'), + IsPropertyDescriptor: require('./2015/IsPropertyDescriptor'), + IsPropertyKey: require('./2015/IsPropertyKey'), + IsRegExp: require('./2015/IsRegExp'), + IsWordChar: require('./2015/IsWordChar'), + IteratorClose: require('./2015/IteratorClose'), + IteratorComplete: require('./2015/IteratorComplete'), + IteratorNext: require('./2015/IteratorNext'), + IteratorStep: require('./2015/IteratorStep'), + IteratorValue: require('./2015/IteratorValue'), + MakeDate: require('./2015/MakeDate'), + MakeDay: require('./2015/MakeDay'), + MakeTime: require('./2015/MakeTime'), + max: require('./2015/max'), + min: require('./2015/min'), + MinFromTime: require('./2015/MinFromTime'), + modulo: require('./2015/modulo'), + MonthFromTime: require('./2015/MonthFromTime'), + msFromTime: require('./2015/msFromTime'), + NewPromiseCapability: require('./2015/NewPromiseCapability'), + NormalCompletion: require('./2015/NormalCompletion'), + ObjectCreate: require('./2015/ObjectCreate'), + ObjectDefineProperties: require('./2015/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2015/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2015/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2015/OrdinaryGetOwnProperty'), + OrdinaryHasInstance: require('./2015/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2015/OrdinaryHasProperty'), + QuoteJSONString: require('./2015/QuoteJSONString'), + RegExpCreate: require('./2015/RegExpCreate'), + RegExpExec: require('./2015/RegExpExec'), + RequireObjectCoercible: require('./2015/RequireObjectCoercible'), + SameValue: require('./2015/SameValue'), + SameValueZero: require('./2015/SameValueZero'), + SecFromTime: require('./2015/SecFromTime'), + Set: require('./2015/Set'), + SetFunctionName: require('./2015/SetFunctionName'), + SetIntegrityLevel: require('./2015/SetIntegrityLevel'), + SetValueInBuffer: require('./2015/SetValueInBuffer'), + SpeciesConstructor: require('./2015/SpeciesConstructor'), + SplitMatch: require('./2015/SplitMatch'), + StringCreate: require('./2015/StringCreate'), + StringGetIndexProperty: require('./2015/StringGetIndexProperty'), + SymbolDescriptiveString: require('./2015/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2015/TestIntegrityLevel'), + thisBooleanValue: require('./2015/thisBooleanValue'), + thisNumberValue: require('./2015/thisNumberValue'), + thisStringValue: require('./2015/thisStringValue'), + thisTimeValue: require('./2015/thisTimeValue'), + TimeClip: require('./2015/TimeClip'), + TimeFromYear: require('./2015/TimeFromYear'), + TimeWithinDay: require('./2015/TimeWithinDay'), + ToBoolean: require('./2015/ToBoolean'), + ToDateString: require('./2015/ToDateString'), + ToInt16: require('./2015/ToInt16'), + ToInt32: require('./2015/ToInt32'), + ToInt8: require('./2015/ToInt8'), + ToInteger: require('./2015/ToInteger'), + ToLength: require('./2015/ToLength'), + ToNumber: require('./2015/ToNumber'), + ToObject: require('./2015/ToObject'), + ToPrimitive: require('./2015/ToPrimitive'), + ToPropertyDescriptor: require('./2015/ToPropertyDescriptor'), + ToPropertyKey: require('./2015/ToPropertyKey'), + ToString: require('./2015/ToString'), + ToUint16: require('./2015/ToUint16'), + ToUint32: require('./2015/ToUint32'), + ToUint8: require('./2015/ToUint8'), + ToUint8Clamp: require('./2015/ToUint8Clamp'), + Type: require('./2015/Type'), + ValidateAndApplyPropertyDescriptor: require('./2015/ValidateAndApplyPropertyDescriptor'), + ValidateTypedArray: require('./2015/ValidateTypedArray'), + WeekDay: require('./2015/WeekDay'), + YearFromTime: require('./2015/YearFromTime') +}; + +module.exports = ES2015; diff --git a/node_modules/es-abstract/es2016.js b/node_modules/es-abstract/es2016.js new file mode 100644 index 0000000000000000000000000000000000000000..61e5f15e6a95c7f6c5092fcc508b08456ed2295b --- /dev/null +++ b/node_modules/es-abstract/es2016.js @@ -0,0 +1,146 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/7.0/#sec-abstract-operations +var ES2016 = { + 'Abstract Equality Comparison': require('./2016/AbstractEqualityComparison'), + 'Abstract Relational Comparison': require('./2016/AbstractRelationalComparison'), + 'Strict Equality Comparison': require('./2016/StrictEqualityComparison'), + abs: require('./2016/abs'), + AdvanceStringIndex: require('./2016/AdvanceStringIndex'), + ArrayCreate: require('./2016/ArrayCreate'), + ArraySetLength: require('./2016/ArraySetLength'), + ArraySpeciesCreate: require('./2016/ArraySpeciesCreate'), + Call: require('./2016/Call'), + Canonicalize: require('./2016/Canonicalize'), + CanonicalNumericIndexString: require('./2016/CanonicalNumericIndexString'), + CharacterRange: require('./2016/CharacterRange'), + CompletePropertyDescriptor: require('./2016/CompletePropertyDescriptor'), + CompletionRecord: require('./2016/CompletionRecord'), + CreateDataProperty: require('./2016/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2016/CreateDataPropertyOrThrow'), + CreateHTML: require('./2016/CreateHTML'), + CreateIterResultObject: require('./2016/CreateIterResultObject'), + CreateListFromArrayLike: require('./2016/CreateListFromArrayLike'), + CreateMethodProperty: require('./2016/CreateMethodProperty'), + DateFromTime: require('./2016/DateFromTime'), + Day: require('./2016/Day'), + DayFromYear: require('./2016/DayFromYear'), + DaysInYear: require('./2016/DaysInYear'), + DayWithinYear: require('./2016/DayWithinYear'), + DefinePropertyOrThrow: require('./2016/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2016/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2016/DetachArrayBuffer'), + EnumerableOwnNames: require('./2016/EnumerableOwnNames'), + floor: require('./2016/floor'), + FromPropertyDescriptor: require('./2016/FromPropertyDescriptor'), + Get: require('./2016/Get'), + GetGlobalObject: require('./2016/GetGlobalObject'), + GetIterator: require('./2016/GetIterator'), + GetMethod: require('./2016/GetMethod'), + GetOwnPropertyKeys: require('./2016/GetOwnPropertyKeys'), + GetPrototypeFromConstructor: require('./2016/GetPrototypeFromConstructor'), + GetSubstitution: require('./2016/GetSubstitution'), + GetV: require('./2016/GetV'), + GetValueFromBuffer: require('./2016/GetValueFromBuffer'), + HasOwnProperty: require('./2016/HasOwnProperty'), + HasProperty: require('./2016/HasProperty'), + HourFromTime: require('./2016/HourFromTime'), + InLeapYear: require('./2016/InLeapYear'), + InstanceofOperator: require('./2016/InstanceofOperator'), + Invoke: require('./2016/Invoke'), + IsAccessorDescriptor: require('./2016/IsAccessorDescriptor'), + IsArray: require('./2016/IsArray'), + IsCallable: require('./2016/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2016/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2016/IsConcatSpreadable'), + IsConstructor: require('./2016/IsConstructor'), + IsDataDescriptor: require('./2016/IsDataDescriptor'), + IsDetachedBuffer: require('./2016/IsDetachedBuffer'), + IsExtensible: require('./2016/IsExtensible'), + IsGenericDescriptor: require('./2016/IsGenericDescriptor'), + IsInteger: require('./2016/IsInteger'), + IsPromise: require('./2016/IsPromise'), + IsPropertyDescriptor: require('./2016/IsPropertyDescriptor'), + IsPropertyKey: require('./2016/IsPropertyKey'), + IsRegExp: require('./2016/IsRegExp'), + IsWordChar: require('./2016/IsWordChar'), + IterableToArrayLike: require('./2016/IterableToArrayLike'), + IteratorClose: require('./2016/IteratorClose'), + IteratorComplete: require('./2016/IteratorComplete'), + IteratorNext: require('./2016/IteratorNext'), + IteratorStep: require('./2016/IteratorStep'), + IteratorValue: require('./2016/IteratorValue'), + MakeDate: require('./2016/MakeDate'), + MakeDay: require('./2016/MakeDay'), + MakeTime: require('./2016/MakeTime'), + max: require('./2016/max'), + min: require('./2016/min'), + MinFromTime: require('./2016/MinFromTime'), + modulo: require('./2016/modulo'), + MonthFromTime: require('./2016/MonthFromTime'), + msFromTime: require('./2016/msFromTime'), + NewPromiseCapability: require('./2016/NewPromiseCapability'), + NormalCompletion: require('./2016/NormalCompletion'), + ObjectCreate: require('./2016/ObjectCreate'), + ObjectDefineProperties: require('./2016/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2016/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2016/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2016/OrdinaryGetOwnProperty'), + OrdinaryGetPrototypeOf: require('./2016/OrdinaryGetPrototypeOf'), + OrdinaryHasInstance: require('./2016/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2016/OrdinaryHasProperty'), + OrdinarySetPrototypeOf: require('./2016/OrdinarySetPrototypeOf'), + QuoteJSONString: require('./2016/QuoteJSONString'), + RegExpCreate: require('./2016/RegExpCreate'), + RegExpExec: require('./2016/RegExpExec'), + RequireObjectCoercible: require('./2016/RequireObjectCoercible'), + SameValue: require('./2016/SameValue'), + SameValueNonNumber: require('./2016/SameValueNonNumber'), + SameValueZero: require('./2016/SameValueZero'), + SecFromTime: require('./2016/SecFromTime'), + Set: require('./2016/Set'), + SetFunctionName: require('./2016/SetFunctionName'), + SetIntegrityLevel: require('./2016/SetIntegrityLevel'), + SetValueInBuffer: require('./2016/SetValueInBuffer'), + SpeciesConstructor: require('./2016/SpeciesConstructor'), + SplitMatch: require('./2016/SplitMatch'), + StringCreate: require('./2016/StringCreate'), + SymbolDescriptiveString: require('./2016/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2016/TestIntegrityLevel'), + thisBooleanValue: require('./2016/thisBooleanValue'), + thisNumberValue: require('./2016/thisNumberValue'), + thisStringValue: require('./2016/thisStringValue'), + thisTimeValue: require('./2016/thisTimeValue'), + TimeClip: require('./2016/TimeClip'), + TimeFromYear: require('./2016/TimeFromYear'), + TimeWithinDay: require('./2016/TimeWithinDay'), + ToBoolean: require('./2016/ToBoolean'), + ToDateString: require('./2016/ToDateString'), + ToInt16: require('./2016/ToInt16'), + ToInt32: require('./2016/ToInt32'), + ToInt8: require('./2016/ToInt8'), + ToInteger: require('./2016/ToInteger'), + ToLength: require('./2016/ToLength'), + ToNumber: require('./2016/ToNumber'), + ToObject: require('./2016/ToObject'), + ToPrimitive: require('./2016/ToPrimitive'), + ToPropertyDescriptor: require('./2016/ToPropertyDescriptor'), + ToPropertyKey: require('./2016/ToPropertyKey'), + ToString: require('./2016/ToString'), + ToUint16: require('./2016/ToUint16'), + ToUint32: require('./2016/ToUint32'), + ToUint8: require('./2016/ToUint8'), + ToUint8Clamp: require('./2016/ToUint8Clamp'), + Type: require('./2016/Type'), + TypedArrayCreate: require('./2016/TypedArrayCreate'), + TypedArraySpeciesCreate: require('./2016/TypedArraySpeciesCreate'), + UTF16Decode: require('./2016/UTF16Decode'), + UTF16Encoding: require('./2016/UTF16Encoding'), + ValidateAndApplyPropertyDescriptor: require('./2016/ValidateAndApplyPropertyDescriptor'), + ValidateTypedArray: require('./2016/ValidateTypedArray'), + WeekDay: require('./2016/WeekDay'), + YearFromTime: require('./2016/YearFromTime') +}; + +module.exports = ES2016; diff --git a/node_modules/es-abstract/es2017.js b/node_modules/es-abstract/es2017.js new file mode 100644 index 0000000000000000000000000000000000000000..37fe762242e3d120be75d5e720e14cda1cf733d0 --- /dev/null +++ b/node_modules/es-abstract/es2017.js @@ -0,0 +1,154 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/8.0/#sec-abstract-operations +var ES2017 = { + 'Abstract Equality Comparison': require('./2017/AbstractEqualityComparison'), + 'Abstract Relational Comparison': require('./2017/AbstractRelationalComparison'), + 'Strict Equality Comparison': require('./2017/StrictEqualityComparison'), + abs: require('./2017/abs'), + AdvanceStringIndex: require('./2017/AdvanceStringIndex'), + ArrayCreate: require('./2017/ArrayCreate'), + ArraySetLength: require('./2017/ArraySetLength'), + ArraySpeciesCreate: require('./2017/ArraySpeciesCreate'), + Call: require('./2017/Call'), + Canonicalize: require('./2017/Canonicalize'), + CanonicalNumericIndexString: require('./2017/CanonicalNumericIndexString'), + CharacterRange: require('./2017/CharacterRange'), + CompletePropertyDescriptor: require('./2017/CompletePropertyDescriptor'), + CompletionRecord: require('./2017/CompletionRecord'), + CreateDataProperty: require('./2017/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2017/CreateDataPropertyOrThrow'), + CreateHTML: require('./2017/CreateHTML'), + CreateIterResultObject: require('./2017/CreateIterResultObject'), + CreateListFromArrayLike: require('./2017/CreateListFromArrayLike'), + CreateMethodProperty: require('./2017/CreateMethodProperty'), + DateFromTime: require('./2017/DateFromTime'), + Day: require('./2017/Day'), + DayFromYear: require('./2017/DayFromYear'), + DaysInYear: require('./2017/DaysInYear'), + DayWithinYear: require('./2017/DayWithinYear'), + DefinePropertyOrThrow: require('./2017/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2017/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2017/DetachArrayBuffer'), + EnumerableOwnProperties: require('./2017/EnumerableOwnProperties'), + floor: require('./2017/floor'), + FromPropertyDescriptor: require('./2017/FromPropertyDescriptor'), + Get: require('./2017/Get'), + GetGlobalObject: require('./2017/GetGlobalObject'), + GetIterator: require('./2017/GetIterator'), + GetMethod: require('./2017/GetMethod'), + GetOwnPropertyKeys: require('./2017/GetOwnPropertyKeys'), + GetPrototypeFromConstructor: require('./2017/GetPrototypeFromConstructor'), + GetSubstitution: require('./2017/GetSubstitution'), + GetV: require('./2017/GetV'), + GetValueFromBuffer: require('./2017/GetValueFromBuffer'), + HasOwnProperty: require('./2017/HasOwnProperty'), + HasProperty: require('./2017/HasProperty'), + HourFromTime: require('./2017/HourFromTime'), + InLeapYear: require('./2017/InLeapYear'), + InstanceofOperator: require('./2017/InstanceofOperator'), + Invoke: require('./2017/Invoke'), + IsAccessorDescriptor: require('./2017/IsAccessorDescriptor'), + IsArray: require('./2017/IsArray'), + IsCallable: require('./2017/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2017/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2017/IsConcatSpreadable'), + IsConstructor: require('./2017/IsConstructor'), + IsDataDescriptor: require('./2017/IsDataDescriptor'), + IsDetachedBuffer: require('./2017/IsDetachedBuffer'), + IsExtensible: require('./2017/IsExtensible'), + IsGenericDescriptor: require('./2017/IsGenericDescriptor'), + IsInteger: require('./2017/IsInteger'), + IsPromise: require('./2017/IsPromise'), + IsPropertyDescriptor: require('./2017/IsPropertyDescriptor'), + IsPropertyKey: require('./2017/IsPropertyKey'), + IsRegExp: require('./2017/IsRegExp'), + IsSharedArrayBuffer: require('./2017/IsSharedArrayBuffer'), + IsWordChar: require('./2017/IsWordChar'), + IterableToList: require('./2017/IterableToList'), + IteratorClose: require('./2017/IteratorClose'), + IteratorComplete: require('./2017/IteratorComplete'), + IteratorNext: require('./2017/IteratorNext'), + IteratorStep: require('./2017/IteratorStep'), + IteratorValue: require('./2017/IteratorValue'), + MakeDate: require('./2017/MakeDate'), + MakeDay: require('./2017/MakeDay'), + MakeTime: require('./2017/MakeTime'), + max: require('./2017/max'), + min: require('./2017/min'), + MinFromTime: require('./2017/MinFromTime'), + modulo: require('./2017/modulo'), + MonthFromTime: require('./2017/MonthFromTime'), + msFromTime: require('./2017/msFromTime'), + NewPromiseCapability: require('./2017/NewPromiseCapability'), + NormalCompletion: require('./2017/NormalCompletion'), + NumberToRawBytes: require('./2017/NumberToRawBytes'), + ObjectCreate: require('./2017/ObjectCreate'), + ObjectDefineProperties: require('./2017/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2017/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2017/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2017/OrdinaryGetOwnProperty'), + OrdinaryGetPrototypeOf: require('./2017/OrdinaryGetPrototypeOf'), + OrdinaryHasInstance: require('./2017/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2017/OrdinaryHasProperty'), + OrdinarySetPrototypeOf: require('./2017/OrdinarySetPrototypeOf'), + OrdinaryToPrimitive: require('./2017/OrdinaryToPrimitive'), + QuoteJSONString: require('./2017/QuoteJSONString'), + RawBytesToNumber: require('./2017/RawBytesToNumber'), + RegExpCreate: require('./2017/RegExpCreate'), + RegExpExec: require('./2017/RegExpExec'), + RequireObjectCoercible: require('./2017/RequireObjectCoercible'), + SameValue: require('./2017/SameValue'), + SameValueNonNumber: require('./2017/SameValueNonNumber'), + SameValueZero: require('./2017/SameValueZero'), + SecFromTime: require('./2017/SecFromTime'), + Set: require('./2017/Set'), + SetFunctionName: require('./2017/SetFunctionName'), + SetIntegrityLevel: require('./2017/SetIntegrityLevel'), + SetValueInBuffer: require('./2017/SetValueInBuffer'), + SpeciesConstructor: require('./2017/SpeciesConstructor'), + SplitMatch: require('./2017/SplitMatch'), + StringCreate: require('./2017/StringCreate'), + StringGetOwnProperty: require('./2017/StringGetOwnProperty'), + SymbolDescriptiveString: require('./2017/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2017/TestIntegrityLevel'), + thisBooleanValue: require('./2017/thisBooleanValue'), + thisNumberValue: require('./2017/thisNumberValue'), + thisStringValue: require('./2017/thisStringValue'), + thisTimeValue: require('./2017/thisTimeValue'), + TimeClip: require('./2017/TimeClip'), + TimeFromYear: require('./2017/TimeFromYear'), + TimeWithinDay: require('./2017/TimeWithinDay'), + ToBoolean: require('./2017/ToBoolean'), + ToDateString: require('./2017/ToDateString'), + ToIndex: require('./2017/ToIndex'), + ToInt16: require('./2017/ToInt16'), + ToInt32: require('./2017/ToInt32'), + ToInt8: require('./2017/ToInt8'), + ToInteger: require('./2017/ToInteger'), + ToLength: require('./2017/ToLength'), + ToNumber: require('./2017/ToNumber'), + ToObject: require('./2017/ToObject'), + ToPrimitive: require('./2017/ToPrimitive'), + ToPropertyDescriptor: require('./2017/ToPropertyDescriptor'), + ToPropertyKey: require('./2017/ToPropertyKey'), + ToString: require('./2017/ToString'), + ToUint16: require('./2017/ToUint16'), + ToUint32: require('./2017/ToUint32'), + ToUint8: require('./2017/ToUint8'), + ToUint8Clamp: require('./2017/ToUint8Clamp'), + Type: require('./2017/Type'), + TypedArrayCreate: require('./2017/TypedArrayCreate'), + TypedArraySpeciesCreate: require('./2017/TypedArraySpeciesCreate'), + UTF16Decode: require('./2017/UTF16Decode'), + UTF16Encoding: require('./2017/UTF16Encoding'), + ValidateAndApplyPropertyDescriptor: require('./2017/ValidateAndApplyPropertyDescriptor'), + ValidateAtomicAccess: require('./2017/ValidateAtomicAccess'), + ValidateTypedArray: require('./2017/ValidateTypedArray'), + WeekDay: require('./2017/WeekDay'), + WordCharacters: require('./2017/WordCharacters'), + YearFromTime: require('./2017/YearFromTime') +}; + +module.exports = ES2017; diff --git a/node_modules/es-abstract/es2018.js b/node_modules/es-abstract/es2018.js new file mode 100644 index 0000000000000000000000000000000000000000..d55fa0de4e2b0880e30d05bf34f9c1be2bf2da2f --- /dev/null +++ b/node_modules/es-abstract/es2018.js @@ -0,0 +1,165 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/9.0/#sec-abstract-operations +var ES2018 = { + 'Abstract Equality Comparison': require('./2018/AbstractEqualityComparison'), + 'Abstract Relational Comparison': require('./2018/AbstractRelationalComparison'), + 'Strict Equality Comparison': require('./2018/StrictEqualityComparison'), + abs: require('./2018/abs'), + AdvanceStringIndex: require('./2018/AdvanceStringIndex'), + ArrayCreate: require('./2018/ArrayCreate'), + ArraySetLength: require('./2018/ArraySetLength'), + ArraySpeciesCreate: require('./2018/ArraySpeciesCreate'), + AsyncIteratorClose: require('./2018/AsyncIteratorClose'), + Call: require('./2018/Call'), + Canonicalize: require('./2018/Canonicalize'), + CanonicalNumericIndexString: require('./2018/CanonicalNumericIndexString'), + CharacterRange: require('./2018/CharacterRange'), + CompletePropertyDescriptor: require('./2018/CompletePropertyDescriptor'), + CompletionRecord: require('./2018/CompletionRecord'), + CopyDataProperties: require('./2018/CopyDataProperties'), + CreateAsyncFromSyncIterator: require('./2018/CreateAsyncFromSyncIterator'), + CreateDataProperty: require('./2018/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2018/CreateDataPropertyOrThrow'), + CreateHTML: require('./2018/CreateHTML'), + CreateIterResultObject: require('./2018/CreateIterResultObject'), + CreateListFromArrayLike: require('./2018/CreateListFromArrayLike'), + CreateMethodProperty: require('./2018/CreateMethodProperty'), + DateFromTime: require('./2018/DateFromTime'), + DateString: require('./2018/DateString'), + Day: require('./2018/Day'), + DayFromYear: require('./2018/DayFromYear'), + DaysInYear: require('./2018/DaysInYear'), + DayWithinYear: require('./2018/DayWithinYear'), + DefinePropertyOrThrow: require('./2018/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2018/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2018/DetachArrayBuffer'), + EnumerableOwnPropertyNames: require('./2018/EnumerableOwnPropertyNames'), + floor: require('./2018/floor'), + FromPropertyDescriptor: require('./2018/FromPropertyDescriptor'), + Get: require('./2018/Get'), + GetGlobalObject: require('./2018/GetGlobalObject'), + GetIterator: require('./2018/GetIterator'), + GetMethod: require('./2018/GetMethod'), + GetOwnPropertyKeys: require('./2018/GetOwnPropertyKeys'), + GetPrototypeFromConstructor: require('./2018/GetPrototypeFromConstructor'), + GetSubstitution: require('./2018/GetSubstitution'), + GetV: require('./2018/GetV'), + GetValueFromBuffer: require('./2018/GetValueFromBuffer'), + HasOwnProperty: require('./2018/HasOwnProperty'), + HasProperty: require('./2018/HasProperty'), + HourFromTime: require('./2018/HourFromTime'), + InLeapYear: require('./2018/InLeapYear'), + InstanceofOperator: require('./2018/InstanceofOperator'), + Invoke: require('./2018/Invoke'), + IsAccessorDescriptor: require('./2018/IsAccessorDescriptor'), + IsArray: require('./2018/IsArray'), + IsCallable: require('./2018/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2018/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2018/IsConcatSpreadable'), + IsConstructor: require('./2018/IsConstructor'), + IsDataDescriptor: require('./2018/IsDataDescriptor'), + IsDetachedBuffer: require('./2018/IsDetachedBuffer'), + IsExtensible: require('./2018/IsExtensible'), + IsGenericDescriptor: require('./2018/IsGenericDescriptor'), + IsInteger: require('./2018/IsInteger'), + IsPromise: require('./2018/IsPromise'), + IsPropertyKey: require('./2018/IsPropertyKey'), + IsRegExp: require('./2018/IsRegExp'), + IsSharedArrayBuffer: require('./2018/IsSharedArrayBuffer'), + IsStringPrefix: require('./2018/IsStringPrefix'), + IsWordChar: require('./2018/IsWordChar'), + IterableToList: require('./2018/IterableToList'), + IteratorClose: require('./2018/IteratorClose'), + IteratorComplete: require('./2018/IteratorComplete'), + IteratorNext: require('./2018/IteratorNext'), + IteratorStep: require('./2018/IteratorStep'), + IteratorValue: require('./2018/IteratorValue'), + MakeDate: require('./2018/MakeDate'), + MakeDay: require('./2018/MakeDay'), + MakeTime: require('./2018/MakeTime'), + max: require('./2018/max'), + min: require('./2018/min'), + MinFromTime: require('./2018/MinFromTime'), + modulo: require('./2018/modulo'), + MonthFromTime: require('./2018/MonthFromTime'), + msFromTime: require('./2018/msFromTime'), + NewPromiseCapability: require('./2018/NewPromiseCapability'), + NormalCompletion: require('./2018/NormalCompletion'), + NumberToRawBytes: require('./2018/NumberToRawBytes'), + NumberToString: require('./2018/NumberToString'), + ObjectCreate: require('./2018/ObjectCreate'), + ObjectDefineProperties: require('./2018/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2018/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2018/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2018/OrdinaryGetOwnProperty'), + OrdinaryGetPrototypeOf: require('./2018/OrdinaryGetPrototypeOf'), + OrdinaryHasInstance: require('./2018/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2018/OrdinaryHasProperty'), + OrdinarySetPrototypeOf: require('./2018/OrdinarySetPrototypeOf'), + OrdinaryToPrimitive: require('./2018/OrdinaryToPrimitive'), + PromiseResolve: require('./2018/PromiseResolve'), + QuoteJSONString: require('./2018/QuoteJSONString'), + RawBytesToNumber: require('./2018/RawBytesToNumber'), + RegExpCreate: require('./2018/RegExpCreate'), + RegExpExec: require('./2018/RegExpExec'), + RequireObjectCoercible: require('./2018/RequireObjectCoercible'), + SameValue: require('./2018/SameValue'), + SameValueNonNumber: require('./2018/SameValueNonNumber'), + SameValueZero: require('./2018/SameValueZero'), + SecFromTime: require('./2018/SecFromTime'), + Set: require('./2018/Set'), + SetFunctionLength: require('./2018/SetFunctionLength'), + SetFunctionName: require('./2018/SetFunctionName'), + SetIntegrityLevel: require('./2018/SetIntegrityLevel'), + SetValueInBuffer: require('./2018/SetValueInBuffer'), + SpeciesConstructor: require('./2018/SpeciesConstructor'), + SplitMatch: require('./2018/SplitMatch'), + StringCreate: require('./2018/StringCreate'), + StringGetOwnProperty: require('./2018/StringGetOwnProperty'), + SymbolDescriptiveString: require('./2018/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2018/TestIntegrityLevel'), + thisBooleanValue: require('./2018/thisBooleanValue'), + thisNumberValue: require('./2018/thisNumberValue'), + thisStringValue: require('./2018/thisStringValue'), + thisSymbolValue: require('./2018/thisSymbolValue'), + thisTimeValue: require('./2018/thisTimeValue'), + ThrowCompletion: require('./2018/ThrowCompletion'), + TimeClip: require('./2018/TimeClip'), + TimeFromYear: require('./2018/TimeFromYear'), + TimeString: require('./2018/TimeString'), + TimeWithinDay: require('./2018/TimeWithinDay'), + ToBoolean: require('./2018/ToBoolean'), + ToDateString: require('./2018/ToDateString'), + ToIndex: require('./2018/ToIndex'), + ToInt16: require('./2018/ToInt16'), + ToInt32: require('./2018/ToInt32'), + ToInt8: require('./2018/ToInt8'), + ToInteger: require('./2018/ToInteger'), + ToLength: require('./2018/ToLength'), + ToNumber: require('./2018/ToNumber'), + ToObject: require('./2018/ToObject'), + ToPrimitive: require('./2018/ToPrimitive'), + ToPropertyDescriptor: require('./2018/ToPropertyDescriptor'), + ToPropertyKey: require('./2018/ToPropertyKey'), + ToString: require('./2018/ToString'), + ToUint16: require('./2018/ToUint16'), + ToUint32: require('./2018/ToUint32'), + ToUint8: require('./2018/ToUint8'), + ToUint8Clamp: require('./2018/ToUint8Clamp'), + Type: require('./2018/Type'), + TypedArrayCreate: require('./2018/TypedArrayCreate'), + TypedArraySpeciesCreate: require('./2018/TypedArraySpeciesCreate'), + UnicodeEscape: require('./2018/UnicodeEscape'), + UTF16Decode: require('./2018/UTF16Decode'), + UTF16Encoding: require('./2018/UTF16Encoding'), + ValidateAndApplyPropertyDescriptor: require('./2018/ValidateAndApplyPropertyDescriptor'), + ValidateAtomicAccess: require('./2018/ValidateAtomicAccess'), + ValidateTypedArray: require('./2018/ValidateTypedArray'), + WeekDay: require('./2018/WeekDay'), + WordCharacters: require('./2018/WordCharacters'), + YearFromTime: require('./2018/YearFromTime') +}; + +module.exports = ES2018; diff --git a/node_modules/es-abstract/es2019.js b/node_modules/es-abstract/es2019.js new file mode 100644 index 0000000000000000000000000000000000000000..42d96e4800e8e9cd54942955e5c46c0bb832c35a --- /dev/null +++ b/node_modules/es-abstract/es2019.js @@ -0,0 +1,169 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/10.0/#sec-abstract-operations +var ES2019 = { + 'Abstract Equality Comparison': require('./2019/AbstractEqualityComparison'), + 'Abstract Relational Comparison': require('./2019/AbstractRelationalComparison'), + 'Strict Equality Comparison': require('./2019/StrictEqualityComparison'), + abs: require('./2019/abs'), + AddEntriesFromIterable: require('./2019/AddEntriesFromIterable'), + AdvanceStringIndex: require('./2019/AdvanceStringIndex'), + ArrayCreate: require('./2019/ArrayCreate'), + ArraySetLength: require('./2019/ArraySetLength'), + ArraySpeciesCreate: require('./2019/ArraySpeciesCreate'), + AsyncFromSyncIteratorContinuation: require('./2019/AsyncFromSyncIteratorContinuation'), + AsyncIteratorClose: require('./2019/AsyncIteratorClose'), + Call: require('./2019/Call'), + Canonicalize: require('./2019/Canonicalize'), + CanonicalNumericIndexString: require('./2019/CanonicalNumericIndexString'), + CharacterRange: require('./2019/CharacterRange'), + CompletePropertyDescriptor: require('./2019/CompletePropertyDescriptor'), + CompletionRecord: require('./2019/CompletionRecord'), + CopyDataProperties: require('./2019/CopyDataProperties'), + CreateAsyncFromSyncIterator: require('./2019/CreateAsyncFromSyncIterator'), + CreateDataProperty: require('./2019/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2019/CreateDataPropertyOrThrow'), + CreateHTML: require('./2019/CreateHTML'), + CreateIterResultObject: require('./2019/CreateIterResultObject'), + CreateListFromArrayLike: require('./2019/CreateListFromArrayLike'), + CreateMethodProperty: require('./2019/CreateMethodProperty'), + DateFromTime: require('./2019/DateFromTime'), + DateString: require('./2019/DateString'), + Day: require('./2019/Day'), + DayFromYear: require('./2019/DayFromYear'), + DaysInYear: require('./2019/DaysInYear'), + DayWithinYear: require('./2019/DayWithinYear'), + DefinePropertyOrThrow: require('./2019/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2019/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2019/DetachArrayBuffer'), + EnumerableOwnPropertyNames: require('./2019/EnumerableOwnPropertyNames'), + FlattenIntoArray: require('./2019/FlattenIntoArray'), + floor: require('./2019/floor'), + FromPropertyDescriptor: require('./2019/FromPropertyDescriptor'), + Get: require('./2019/Get'), + GetGlobalObject: require('./2019/GetGlobalObject'), + GetIterator: require('./2019/GetIterator'), + GetMethod: require('./2019/GetMethod'), + GetOwnPropertyKeys: require('./2019/GetOwnPropertyKeys'), + GetPrototypeFromConstructor: require('./2019/GetPrototypeFromConstructor'), + GetSubstitution: require('./2019/GetSubstitution'), + GetV: require('./2019/GetV'), + GetValueFromBuffer: require('./2019/GetValueFromBuffer'), + HasOwnProperty: require('./2019/HasOwnProperty'), + HasProperty: require('./2019/HasProperty'), + HourFromTime: require('./2019/HourFromTime'), + InLeapYear: require('./2019/InLeapYear'), + InstanceofOperator: require('./2019/InstanceofOperator'), + Invoke: require('./2019/Invoke'), + IsAccessorDescriptor: require('./2019/IsAccessorDescriptor'), + IsArray: require('./2019/IsArray'), + IsCallable: require('./2019/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2019/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2019/IsConcatSpreadable'), + IsConstructor: require('./2019/IsConstructor'), + IsDataDescriptor: require('./2019/IsDataDescriptor'), + IsDetachedBuffer: require('./2019/IsDetachedBuffer'), + IsExtensible: require('./2019/IsExtensible'), + IsGenericDescriptor: require('./2019/IsGenericDescriptor'), + IsInteger: require('./2019/IsInteger'), + IsPromise: require('./2019/IsPromise'), + IsPropertyKey: require('./2019/IsPropertyKey'), + IsRegExp: require('./2019/IsRegExp'), + IsSharedArrayBuffer: require('./2019/IsSharedArrayBuffer'), + IsStringPrefix: require('./2019/IsStringPrefix'), + IsWordChar: require('./2019/IsWordChar'), + IterableToList: require('./2019/IterableToList'), + IteratorClose: require('./2019/IteratorClose'), + IteratorComplete: require('./2019/IteratorComplete'), + IteratorNext: require('./2019/IteratorNext'), + IteratorStep: require('./2019/IteratorStep'), + IteratorValue: require('./2019/IteratorValue'), + MakeDate: require('./2019/MakeDate'), + MakeDay: require('./2019/MakeDay'), + MakeTime: require('./2019/MakeTime'), + max: require('./2019/max'), + min: require('./2019/min'), + MinFromTime: require('./2019/MinFromTime'), + modulo: require('./2019/modulo'), + MonthFromTime: require('./2019/MonthFromTime'), + msFromTime: require('./2019/msFromTime'), + NewPromiseCapability: require('./2019/NewPromiseCapability'), + NormalCompletion: require('./2019/NormalCompletion'), + NumberToRawBytes: require('./2019/NumberToRawBytes'), + NumberToString: require('./2019/NumberToString'), + ObjectCreate: require('./2019/ObjectCreate'), + ObjectDefineProperties: require('./2019/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2019/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2019/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2019/OrdinaryGetOwnProperty'), + OrdinaryGetPrototypeOf: require('./2019/OrdinaryGetPrototypeOf'), + OrdinaryHasInstance: require('./2019/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2019/OrdinaryHasProperty'), + OrdinarySetPrototypeOf: require('./2019/OrdinarySetPrototypeOf'), + OrdinaryToPrimitive: require('./2019/OrdinaryToPrimitive'), + PromiseResolve: require('./2019/PromiseResolve'), + QuoteJSONString: require('./2019/QuoteJSONString'), + RawBytesToNumber: require('./2019/RawBytesToNumber'), + RegExpCreate: require('./2019/RegExpCreate'), + RegExpExec: require('./2019/RegExpExec'), + RequireObjectCoercible: require('./2019/RequireObjectCoercible'), + SameValue: require('./2019/SameValue'), + SameValueNonNumber: require('./2019/SameValueNonNumber'), + SameValueZero: require('./2019/SameValueZero'), + SecFromTime: require('./2019/SecFromTime'), + Set: require('./2019/Set'), + SetFunctionLength: require('./2019/SetFunctionLength'), + SetFunctionName: require('./2019/SetFunctionName'), + SetIntegrityLevel: require('./2019/SetIntegrityLevel'), + SetValueInBuffer: require('./2019/SetValueInBuffer'), + SpeciesConstructor: require('./2019/SpeciesConstructor'), + SplitMatch: require('./2019/SplitMatch'), + StringCreate: require('./2019/StringCreate'), + StringGetOwnProperty: require('./2019/StringGetOwnProperty'), + SymbolDescriptiveString: require('./2019/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2019/TestIntegrityLevel'), + thisBooleanValue: require('./2019/thisBooleanValue'), + thisNumberValue: require('./2019/thisNumberValue'), + thisStringValue: require('./2019/thisStringValue'), + thisSymbolValue: require('./2019/thisSymbolValue'), + thisTimeValue: require('./2019/thisTimeValue'), + ThrowCompletion: require('./2019/ThrowCompletion'), + TimeClip: require('./2019/TimeClip'), + TimeFromYear: require('./2019/TimeFromYear'), + TimeString: require('./2019/TimeString'), + TimeWithinDay: require('./2019/TimeWithinDay'), + ToBoolean: require('./2019/ToBoolean'), + ToDateString: require('./2019/ToDateString'), + ToIndex: require('./2019/ToIndex'), + ToInt16: require('./2019/ToInt16'), + ToInt32: require('./2019/ToInt32'), + ToInt8: require('./2019/ToInt8'), + ToInteger: require('./2019/ToInteger'), + ToLength: require('./2019/ToLength'), + ToNumber: require('./2019/ToNumber'), + ToObject: require('./2019/ToObject'), + ToPrimitive: require('./2019/ToPrimitive'), + ToPropertyDescriptor: require('./2019/ToPropertyDescriptor'), + ToPropertyKey: require('./2019/ToPropertyKey'), + ToString: require('./2019/ToString'), + ToUint16: require('./2019/ToUint16'), + ToUint32: require('./2019/ToUint32'), + ToUint8: require('./2019/ToUint8'), + ToUint8Clamp: require('./2019/ToUint8Clamp'), + TrimString: require('./2019/TrimString'), + Type: require('./2019/Type'), + TypedArrayCreate: require('./2019/TypedArrayCreate'), + TypedArraySpeciesCreate: require('./2019/TypedArraySpeciesCreate'), + UnicodeEscape: require('./2019/UnicodeEscape'), + UTF16Decode: require('./2019/UTF16Decode'), + UTF16Encoding: require('./2019/UTF16Encoding'), + ValidateAndApplyPropertyDescriptor: require('./2019/ValidateAndApplyPropertyDescriptor'), + ValidateAtomicAccess: require('./2019/ValidateAtomicAccess'), + ValidateTypedArray: require('./2019/ValidateTypedArray'), + WeekDay: require('./2019/WeekDay'), + WordCharacters: require('./2019/WordCharacters'), + YearFromTime: require('./2019/YearFromTime') +}; + +module.exports = ES2019; diff --git a/node_modules/es-abstract/es2020.js b/node_modules/es-abstract/es2020.js new file mode 100644 index 0000000000000000000000000000000000000000..39f6b7931bac02da9560827d940fac1fe53be1c1 --- /dev/null +++ b/node_modules/es-abstract/es2020.js @@ -0,0 +1,193 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/11.0/#sec-abstract-operations +var ES2020 = { + 'Abstract Equality Comparison': require('./2020/AbstractEqualityComparison'), + 'Abstract Relational Comparison': require('./2020/AbstractRelationalComparison'), + 'Strict Equality Comparison': require('./2020/StrictEqualityComparison'), + abs: require('./2020/abs'), + AddEntriesFromIterable: require('./2020/AddEntriesFromIterable'), + AdvanceStringIndex: require('./2020/AdvanceStringIndex'), + ArrayCreate: require('./2020/ArrayCreate'), + ArraySetLength: require('./2020/ArraySetLength'), + ArraySpeciesCreate: require('./2020/ArraySpeciesCreate'), + AsyncFromSyncIteratorContinuation: require('./2020/AsyncFromSyncIteratorContinuation'), + AsyncIteratorClose: require('./2020/AsyncIteratorClose'), + BigInt: require('./2020/BigInt'), + BigIntBitwiseOp: require('./2020/BigIntBitwiseOp'), + BinaryAnd: require('./2020/BinaryAnd'), + BinaryOr: require('./2020/BinaryOr'), + BinaryXor: require('./2020/BinaryXor'), + Call: require('./2020/Call'), + Canonicalize: require('./2020/Canonicalize'), + CanonicalNumericIndexString: require('./2020/CanonicalNumericIndexString'), + CharacterRange: require('./2020/CharacterRange'), + CodePointAt: require('./2020/CodePointAt'), + CompletePropertyDescriptor: require('./2020/CompletePropertyDescriptor'), + CompletionRecord: require('./2020/CompletionRecord'), + CopyDataProperties: require('./2020/CopyDataProperties'), + CreateAsyncFromSyncIterator: require('./2020/CreateAsyncFromSyncIterator'), + CreateDataProperty: require('./2020/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2020/CreateDataPropertyOrThrow'), + CreateHTML: require('./2020/CreateHTML'), + CreateIterResultObject: require('./2020/CreateIterResultObject'), + CreateListFromArrayLike: require('./2020/CreateListFromArrayLike'), + CreateMethodProperty: require('./2020/CreateMethodProperty'), + CreateRegExpStringIterator: require('./2020/CreateRegExpStringIterator'), + DateFromTime: require('./2020/DateFromTime'), + DateString: require('./2020/DateString'), + Day: require('./2020/Day'), + DayFromYear: require('./2020/DayFromYear'), + DaysInYear: require('./2020/DaysInYear'), + DayWithinYear: require('./2020/DayWithinYear'), + DefinePropertyOrThrow: require('./2020/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2020/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2020/DetachArrayBuffer'), + EnumerableOwnPropertyNames: require('./2020/EnumerableOwnPropertyNames'), + FlattenIntoArray: require('./2020/FlattenIntoArray'), + floor: require('./2020/floor'), + FromPropertyDescriptor: require('./2020/FromPropertyDescriptor'), + Get: require('./2020/Get'), + GetGlobalObject: require('./2020/GetGlobalObject'), + GetIterator: require('./2020/GetIterator'), + GetMethod: require('./2020/GetMethod'), + GetOwnPropertyKeys: require('./2020/GetOwnPropertyKeys'), + GetPrototypeFromConstructor: require('./2020/GetPrototypeFromConstructor'), + GetSubstitution: require('./2020/GetSubstitution'), + GetV: require('./2020/GetV'), + GetValueFromBuffer: require('./2020/GetValueFromBuffer'), + HasOwnProperty: require('./2020/HasOwnProperty'), + HasProperty: require('./2020/HasProperty'), + HourFromTime: require('./2020/HourFromTime'), + InLeapYear: require('./2020/InLeapYear'), + InstanceofOperator: require('./2020/InstanceofOperator'), + Invoke: require('./2020/Invoke'), + IsAccessorDescriptor: require('./2020/IsAccessorDescriptor'), + IsArray: require('./2020/IsArray'), + IsBigIntElementType: require('./2020/IsBigIntElementType'), + IsCallable: require('./2020/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2020/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2020/IsConcatSpreadable'), + IsConstructor: require('./2020/IsConstructor'), + IsDataDescriptor: require('./2020/IsDataDescriptor'), + IsDetachedBuffer: require('./2020/IsDetachedBuffer'), + IsExtensible: require('./2020/IsExtensible'), + IsGenericDescriptor: require('./2020/IsGenericDescriptor'), + IsInteger: require('./2020/IsInteger'), + IsNonNegativeInteger: require('./2020/IsNonNegativeInteger'), + IsNoTearConfiguration: require('./2020/IsNoTearConfiguration'), + IsPromise: require('./2020/IsPromise'), + IsPropertyKey: require('./2020/IsPropertyKey'), + IsRegExp: require('./2020/IsRegExp'), + IsSharedArrayBuffer: require('./2020/IsSharedArrayBuffer'), + IsStringPrefix: require('./2020/IsStringPrefix'), + IsUnclampedIntegerElementType: require('./2020/IsUnclampedIntegerElementType'), + IsUnsignedElementType: require('./2020/IsUnsignedElementType'), + IsValidIntegerIndex: require('./2020/IsValidIntegerIndex'), + IsWordChar: require('./2020/IsWordChar'), + IterableToList: require('./2020/IterableToList'), + IteratorClose: require('./2020/IteratorClose'), + IteratorComplete: require('./2020/IteratorComplete'), + IteratorNext: require('./2020/IteratorNext'), + IteratorStep: require('./2020/IteratorStep'), + IteratorValue: require('./2020/IteratorValue'), + LengthOfArrayLike: require('./2020/LengthOfArrayLike'), + MakeDate: require('./2020/MakeDate'), + MakeDay: require('./2020/MakeDay'), + MakeTime: require('./2020/MakeTime'), + max: require('./2020/max'), + min: require('./2020/min'), + MinFromTime: require('./2020/MinFromTime'), + modulo: require('./2020/modulo'), + MonthFromTime: require('./2020/MonthFromTime'), + msFromTime: require('./2020/msFromTime'), + NewPromiseCapability: require('./2020/NewPromiseCapability'), + NormalCompletion: require('./2020/NormalCompletion'), + Number: require('./2020/Number'), + NumberBitwiseOp: require('./2020/NumberBitwiseOp'), + NumberToBigInt: require('./2020/NumberToBigInt'), + NumericToRawBytes: require('./2020/NumericToRawBytes'), + ObjectDefineProperties: require('./2020/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2020/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2020/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2020/OrdinaryGetOwnProperty'), + OrdinaryGetPrototypeOf: require('./2020/OrdinaryGetPrototypeOf'), + OrdinaryHasInstance: require('./2020/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2020/OrdinaryHasProperty'), + OrdinaryObjectCreate: require('./2020/OrdinaryObjectCreate'), + OrdinarySetPrototypeOf: require('./2020/OrdinarySetPrototypeOf'), + OrdinaryToPrimitive: require('./2020/OrdinaryToPrimitive'), + PromiseResolve: require('./2020/PromiseResolve'), + QuoteJSONString: require('./2020/QuoteJSONString'), + RawBytesToNumeric: require('./2020/RawBytesToNumeric'), + RegExpCreate: require('./2020/RegExpCreate'), + RegExpExec: require('./2020/RegExpExec'), + RequireObjectCoercible: require('./2020/RequireObjectCoercible'), + SameValue: require('./2020/SameValue'), + SameValueNonNumeric: require('./2020/SameValueNonNumeric'), + SameValueZero: require('./2020/SameValueZero'), + SecFromTime: require('./2020/SecFromTime'), + Set: require('./2020/Set'), + SetFunctionLength: require('./2020/SetFunctionLength'), + SetFunctionName: require('./2020/SetFunctionName'), + SetIntegrityLevel: require('./2020/SetIntegrityLevel'), + SetValueInBuffer: require('./2020/SetValueInBuffer'), + SpeciesConstructor: require('./2020/SpeciesConstructor'), + SplitMatch: require('./2020/SplitMatch'), + StringCreate: require('./2020/StringCreate'), + StringGetOwnProperty: require('./2020/StringGetOwnProperty'), + StringPad: require('./2020/StringPad'), + StringToBigInt: require('./2020/StringToBigInt'), + SymbolDescriptiveString: require('./2020/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2020/TestIntegrityLevel'), + thisBigIntValue: require('./2020/thisBigIntValue'), + thisBooleanValue: require('./2020/thisBooleanValue'), + thisNumberValue: require('./2020/thisNumberValue'), + thisStringValue: require('./2020/thisStringValue'), + thisSymbolValue: require('./2020/thisSymbolValue'), + thisTimeValue: require('./2020/thisTimeValue'), + ThrowCompletion: require('./2020/ThrowCompletion'), + TimeClip: require('./2020/TimeClip'), + TimeFromYear: require('./2020/TimeFromYear'), + TimeString: require('./2020/TimeString'), + TimeWithinDay: require('./2020/TimeWithinDay'), + ToBigInt: require('./2020/ToBigInt'), + ToBigInt64: require('./2020/ToBigInt64'), + ToBigUint64: require('./2020/ToBigUint64'), + ToBoolean: require('./2020/ToBoolean'), + ToDateString: require('./2020/ToDateString'), + ToIndex: require('./2020/ToIndex'), + ToInt16: require('./2020/ToInt16'), + ToInt32: require('./2020/ToInt32'), + ToInt8: require('./2020/ToInt8'), + ToInteger: require('./2020/ToInteger'), + ToLength: require('./2020/ToLength'), + ToNumber: require('./2020/ToNumber'), + ToNumeric: require('./2020/ToNumeric'), + ToObject: require('./2020/ToObject'), + ToPrimitive: require('./2020/ToPrimitive'), + ToPropertyDescriptor: require('./2020/ToPropertyDescriptor'), + ToPropertyKey: require('./2020/ToPropertyKey'), + ToString: require('./2020/ToString'), + ToUint16: require('./2020/ToUint16'), + ToUint32: require('./2020/ToUint32'), + ToUint8: require('./2020/ToUint8'), + ToUint8Clamp: require('./2020/ToUint8Clamp'), + TrimString: require('./2020/TrimString'), + Type: require('./2020/Type'), + TypedArrayCreate: require('./2020/TypedArrayCreate'), + TypedArraySpeciesCreate: require('./2020/TypedArraySpeciesCreate'), + UnicodeEscape: require('./2020/UnicodeEscape'), + UTF16DecodeString: require('./2020/UTF16DecodeString'), + UTF16DecodeSurrogatePair: require('./2020/UTF16DecodeSurrogatePair'), + UTF16Encoding: require('./2020/UTF16Encoding'), + ValidateAndApplyPropertyDescriptor: require('./2020/ValidateAndApplyPropertyDescriptor'), + ValidateAtomicAccess: require('./2020/ValidateAtomicAccess'), + ValidateTypedArray: require('./2020/ValidateTypedArray'), + WeekDay: require('./2020/WeekDay'), + WordCharacters: require('./2020/WordCharacters'), + YearFromTime: require('./2020/YearFromTime') +}; + +module.exports = ES2020; diff --git a/node_modules/es-abstract/es2021.js b/node_modules/es-abstract/es2021.js new file mode 100644 index 0000000000000000000000000000000000000000..410d283f2d4358ea6abd29dd2647e2973095814d --- /dev/null +++ b/node_modules/es-abstract/es2021.js @@ -0,0 +1,207 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/12.0/#sec-abstract-operations +var ES2021 = { + 'Abstract Equality Comparison': require('./2021/AbstractEqualityComparison'), + 'Abstract Relational Comparison': require('./2021/AbstractRelationalComparison'), + 'Strict Equality Comparison': require('./2021/StrictEqualityComparison'), + abs: require('./2021/abs'), + AddEntriesFromIterable: require('./2021/AddEntriesFromIterable'), + AddToKeptObjects: require('./2021/AddToKeptObjects'), + AdvanceStringIndex: require('./2021/AdvanceStringIndex'), + ApplyStringOrNumericBinaryOperator: require('./2021/ApplyStringOrNumericBinaryOperator'), + ArrayCreate: require('./2021/ArrayCreate'), + ArraySetLength: require('./2021/ArraySetLength'), + ArraySpeciesCreate: require('./2021/ArraySpeciesCreate'), + AsyncFromSyncIteratorContinuation: require('./2021/AsyncFromSyncIteratorContinuation'), + AsyncIteratorClose: require('./2021/AsyncIteratorClose'), + BigInt: require('./2021/BigInt'), + BigIntBitwiseOp: require('./2021/BigIntBitwiseOp'), + BinaryAnd: require('./2021/BinaryAnd'), + BinaryOr: require('./2021/BinaryOr'), + BinaryXor: require('./2021/BinaryXor'), + ByteListBitwiseOp: require('./2021/ByteListBitwiseOp'), + ByteListEqual: require('./2021/ByteListEqual'), + Call: require('./2021/Call'), + Canonicalize: require('./2021/Canonicalize'), + CanonicalNumericIndexString: require('./2021/CanonicalNumericIndexString'), + CharacterRange: require('./2021/CharacterRange'), + clamp: require('./2021/clamp'), + ClearKeptObjects: require('./2021/ClearKeptObjects'), + CloneArrayBuffer: require('./2021/CloneArrayBuffer'), + CodePointAt: require('./2021/CodePointAt'), + CodePointsToString: require('./2021/CodePointsToString'), + CompletePropertyDescriptor: require('./2021/CompletePropertyDescriptor'), + CompletionRecord: require('./2021/CompletionRecord'), + CopyDataProperties: require('./2021/CopyDataProperties'), + CreateAsyncFromSyncIterator: require('./2021/CreateAsyncFromSyncIterator'), + CreateDataProperty: require('./2021/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2021/CreateDataPropertyOrThrow'), + CreateHTML: require('./2021/CreateHTML'), + CreateIterResultObject: require('./2021/CreateIterResultObject'), + CreateListFromArrayLike: require('./2021/CreateListFromArrayLike'), + CreateMethodProperty: require('./2021/CreateMethodProperty'), + CreateRegExpStringIterator: require('./2021/CreateRegExpStringIterator'), + DateFromTime: require('./2021/DateFromTime'), + DateString: require('./2021/DateString'), + Day: require('./2021/Day'), + DayFromYear: require('./2021/DayFromYear'), + DaysInYear: require('./2021/DaysInYear'), + DayWithinYear: require('./2021/DayWithinYear'), + DefinePropertyOrThrow: require('./2021/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2021/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2021/DetachArrayBuffer'), + EnumerableOwnPropertyNames: require('./2021/EnumerableOwnPropertyNames'), + FlattenIntoArray: require('./2021/FlattenIntoArray'), + floor: require('./2021/floor'), + FromPropertyDescriptor: require('./2021/FromPropertyDescriptor'), + Get: require('./2021/Get'), + GetGlobalObject: require('./2021/GetGlobalObject'), + GetIterator: require('./2021/GetIterator'), + GetMethod: require('./2021/GetMethod'), + GetOwnPropertyKeys: require('./2021/GetOwnPropertyKeys'), + GetPromiseResolve: require('./2021/GetPromiseResolve'), + GetPrototypeFromConstructor: require('./2021/GetPrototypeFromConstructor'), + GetSubstitution: require('./2021/GetSubstitution'), + GetV: require('./2021/GetV'), + GetValueFromBuffer: require('./2021/GetValueFromBuffer'), + HasOwnProperty: require('./2021/HasOwnProperty'), + HasProperty: require('./2021/HasProperty'), + HourFromTime: require('./2021/HourFromTime'), + InLeapYear: require('./2021/InLeapYear'), + InstanceofOperator: require('./2021/InstanceofOperator'), + Invoke: require('./2021/Invoke'), + IsAccessorDescriptor: require('./2021/IsAccessorDescriptor'), + IsArray: require('./2021/IsArray'), + IsBigIntElementType: require('./2021/IsBigIntElementType'), + IsCallable: require('./2021/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2021/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2021/IsConcatSpreadable'), + IsConstructor: require('./2021/IsConstructor'), + IsDataDescriptor: require('./2021/IsDataDescriptor'), + IsDetachedBuffer: require('./2021/IsDetachedBuffer'), + IsExtensible: require('./2021/IsExtensible'), + IsGenericDescriptor: require('./2021/IsGenericDescriptor'), + IsIntegralNumber: require('./2021/IsIntegralNumber'), + IsNoTearConfiguration: require('./2021/IsNoTearConfiguration'), + IsPromise: require('./2021/IsPromise'), + IsPropertyKey: require('./2021/IsPropertyKey'), + IsRegExp: require('./2021/IsRegExp'), + IsSharedArrayBuffer: require('./2021/IsSharedArrayBuffer'), + IsStringPrefix: require('./2021/IsStringPrefix'), + IsUnclampedIntegerElementType: require('./2021/IsUnclampedIntegerElementType'), + IsUnsignedElementType: require('./2021/IsUnsignedElementType'), + IsValidIntegerIndex: require('./2021/IsValidIntegerIndex'), + IsWordChar: require('./2021/IsWordChar'), + IterableToList: require('./2021/IterableToList'), + IteratorClose: require('./2021/IteratorClose'), + IteratorComplete: require('./2021/IteratorComplete'), + IteratorNext: require('./2021/IteratorNext'), + IteratorStep: require('./2021/IteratorStep'), + IteratorValue: require('./2021/IteratorValue'), + LengthOfArrayLike: require('./2021/LengthOfArrayLike'), + MakeDate: require('./2021/MakeDate'), + MakeDay: require('./2021/MakeDay'), + MakeTime: require('./2021/MakeTime'), + max: require('./2021/max'), + min: require('./2021/min'), + MinFromTime: require('./2021/MinFromTime'), + modulo: require('./2021/modulo'), + MonthFromTime: require('./2021/MonthFromTime'), + msFromTime: require('./2021/msFromTime'), + NewPromiseCapability: require('./2021/NewPromiseCapability'), + NormalCompletion: require('./2021/NormalCompletion'), + Number: require('./2021/Number'), + NumberBitwiseOp: require('./2021/NumberBitwiseOp'), + NumberToBigInt: require('./2021/NumberToBigInt'), + NumericToRawBytes: require('./2021/NumericToRawBytes'), + ObjectDefineProperties: require('./2021/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2021/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2021/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2021/OrdinaryGetOwnProperty'), + OrdinaryGetPrototypeOf: require('./2021/OrdinaryGetPrototypeOf'), + OrdinaryHasInstance: require('./2021/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2021/OrdinaryHasProperty'), + OrdinaryObjectCreate: require('./2021/OrdinaryObjectCreate'), + OrdinarySetPrototypeOf: require('./2021/OrdinarySetPrototypeOf'), + OrdinaryToPrimitive: require('./2021/OrdinaryToPrimitive'), + PromiseResolve: require('./2021/PromiseResolve'), + QuoteJSONString: require('./2021/QuoteJSONString'), + RawBytesToNumeric: require('./2021/RawBytesToNumeric'), + RegExpCreate: require('./2021/RegExpCreate'), + RegExpExec: require('./2021/RegExpExec'), + RequireObjectCoercible: require('./2021/RequireObjectCoercible'), + SameValue: require('./2021/SameValue'), + SameValueNonNumeric: require('./2021/SameValueNonNumeric'), + SameValueZero: require('./2021/SameValueZero'), + SecFromTime: require('./2021/SecFromTime'), + Set: require('./2021/Set'), + SetFunctionLength: require('./2021/SetFunctionLength'), + SetFunctionName: require('./2021/SetFunctionName'), + SetIntegrityLevel: require('./2021/SetIntegrityLevel'), + SetTypedArrayFromArrayLike: require('./2021/SetTypedArrayFromArrayLike'), + SetTypedArrayFromTypedArray: require('./2021/SetTypedArrayFromTypedArray'), + SetValueInBuffer: require('./2021/SetValueInBuffer'), + SpeciesConstructor: require('./2021/SpeciesConstructor'), + SplitMatch: require('./2021/SplitMatch'), + StringCreate: require('./2021/StringCreate'), + StringGetOwnProperty: require('./2021/StringGetOwnProperty'), + StringIndexOf: require('./2021/StringIndexOf'), + StringPad: require('./2021/StringPad'), + StringToBigInt: require('./2021/StringToBigInt'), + StringToCodePoints: require('./2021/StringToCodePoints'), + substring: require('./2021/substring'), + SymbolDescriptiveString: require('./2021/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2021/TestIntegrityLevel'), + thisBigIntValue: require('./2021/thisBigIntValue'), + thisBooleanValue: require('./2021/thisBooleanValue'), + thisNumberValue: require('./2021/thisNumberValue'), + thisStringValue: require('./2021/thisStringValue'), + thisSymbolValue: require('./2021/thisSymbolValue'), + thisTimeValue: require('./2021/thisTimeValue'), + ThrowCompletion: require('./2021/ThrowCompletion'), + TimeClip: require('./2021/TimeClip'), + TimeFromYear: require('./2021/TimeFromYear'), + TimeString: require('./2021/TimeString'), + TimeWithinDay: require('./2021/TimeWithinDay'), + ToBigInt: require('./2021/ToBigInt'), + ToBigInt64: require('./2021/ToBigInt64'), + ToBigUint64: require('./2021/ToBigUint64'), + ToBoolean: require('./2021/ToBoolean'), + ToDateString: require('./2021/ToDateString'), + ToIndex: require('./2021/ToIndex'), + ToInt16: require('./2021/ToInt16'), + ToInt32: require('./2021/ToInt32'), + ToInt8: require('./2021/ToInt8'), + ToIntegerOrInfinity: require('./2021/ToIntegerOrInfinity'), + ToLength: require('./2021/ToLength'), + ToNumber: require('./2021/ToNumber'), + ToNumeric: require('./2021/ToNumeric'), + ToObject: require('./2021/ToObject'), + ToPrimitive: require('./2021/ToPrimitive'), + ToPropertyDescriptor: require('./2021/ToPropertyDescriptor'), + ToPropertyKey: require('./2021/ToPropertyKey'), + ToString: require('./2021/ToString'), + ToUint16: require('./2021/ToUint16'), + ToUint32: require('./2021/ToUint32'), + ToUint8: require('./2021/ToUint8'), + ToUint8Clamp: require('./2021/ToUint8Clamp'), + TrimString: require('./2021/TrimString'), + Type: require('./2021/Type'), + TypedArrayCreate: require('./2021/TypedArrayCreate'), + TypedArraySpeciesCreate: require('./2021/TypedArraySpeciesCreate'), + UnicodeEscape: require('./2021/UnicodeEscape'), + UTF16EncodeCodePoint: require('./2021/UTF16EncodeCodePoint'), + UTF16SurrogatePairToCodePoint: require('./2021/UTF16SurrogatePairToCodePoint'), + ValidateAndApplyPropertyDescriptor: require('./2021/ValidateAndApplyPropertyDescriptor'), + ValidateAtomicAccess: require('./2021/ValidateAtomicAccess'), + ValidateIntegerTypedArray: require('./2021/ValidateIntegerTypedArray'), + ValidateTypedArray: require('./2021/ValidateTypedArray'), + WeakRefDeref: require('./2021/WeakRefDeref'), + WeekDay: require('./2021/WeekDay'), + WordCharacters: require('./2021/WordCharacters'), + YearFromTime: require('./2021/YearFromTime') +}; + +module.exports = ES2021; diff --git a/node_modules/es-abstract/es2022.js b/node_modules/es-abstract/es2022.js new file mode 100644 index 0000000000000000000000000000000000000000..dfd808ae359c3172dda511ee4b6ef092336bbe29 --- /dev/null +++ b/node_modules/es-abstract/es2022.js @@ -0,0 +1,219 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/13.0/#sec-abstract-operations +var ES2022 = { + abs: require('./2022/abs'), + AddEntriesFromIterable: require('./2022/AddEntriesFromIterable'), + AddToKeptObjects: require('./2022/AddToKeptObjects'), + AdvanceStringIndex: require('./2022/AdvanceStringIndex'), + ApplyStringOrNumericBinaryOperator: require('./2022/ApplyStringOrNumericBinaryOperator'), + ArrayCreate: require('./2022/ArrayCreate'), + ArraySetLength: require('./2022/ArraySetLength'), + ArraySpeciesCreate: require('./2022/ArraySpeciesCreate'), + AsyncFromSyncIteratorContinuation: require('./2022/AsyncFromSyncIteratorContinuation'), + AsyncIteratorClose: require('./2022/AsyncIteratorClose'), + BigInt: require('./2022/BigInt'), + BigIntBitwiseOp: require('./2022/BigIntBitwiseOp'), + BinaryAnd: require('./2022/BinaryAnd'), + BinaryOr: require('./2022/BinaryOr'), + BinaryXor: require('./2022/BinaryXor'), + ByteListBitwiseOp: require('./2022/ByteListBitwiseOp'), + ByteListEqual: require('./2022/ByteListEqual'), + Call: require('./2022/Call'), + Canonicalize: require('./2022/Canonicalize'), + CanonicalNumericIndexString: require('./2022/CanonicalNumericIndexString'), + CharacterRange: require('./2022/CharacterRange'), + clamp: require('./2022/clamp'), + ClearKeptObjects: require('./2022/ClearKeptObjects'), + CloneArrayBuffer: require('./2022/CloneArrayBuffer'), + CodePointAt: require('./2022/CodePointAt'), + CodePointsToString: require('./2022/CodePointsToString'), + CompletePropertyDescriptor: require('./2022/CompletePropertyDescriptor'), + CompletionRecord: require('./2022/CompletionRecord'), + CopyDataProperties: require('./2022/CopyDataProperties'), + CreateAsyncFromSyncIterator: require('./2022/CreateAsyncFromSyncIterator'), + CreateDataProperty: require('./2022/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2022/CreateDataPropertyOrThrow'), + CreateHTML: require('./2022/CreateHTML'), + CreateIterResultObject: require('./2022/CreateIterResultObject'), + CreateListFromArrayLike: require('./2022/CreateListFromArrayLike'), + CreateMethodProperty: require('./2022/CreateMethodProperty'), + CreateNonEnumerableDataPropertyOrThrow: require('./2022/CreateNonEnumerableDataPropertyOrThrow'), + CreateRegExpStringIterator: require('./2022/CreateRegExpStringIterator'), + DateFromTime: require('./2022/DateFromTime'), + DateString: require('./2022/DateString'), + Day: require('./2022/Day'), + DayFromYear: require('./2022/DayFromYear'), + DaysInYear: require('./2022/DaysInYear'), + DayWithinYear: require('./2022/DayWithinYear'), + DefinePropertyOrThrow: require('./2022/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2022/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2022/DetachArrayBuffer'), + EnumerableOwnPropertyNames: require('./2022/EnumerableOwnPropertyNames'), + FlattenIntoArray: require('./2022/FlattenIntoArray'), + floor: require('./2022/floor'), + FromPropertyDescriptor: require('./2022/FromPropertyDescriptor'), + Get: require('./2022/Get'), + GetGlobalObject: require('./2022/GetGlobalObject'), + GetIterator: require('./2022/GetIterator'), + GetMatchIndexPair: require('./2022/GetMatchIndexPair'), + GetMatchString: require('./2022/GetMatchString'), + GetMethod: require('./2022/GetMethod'), + GetOwnPropertyKeys: require('./2022/GetOwnPropertyKeys'), + GetPromiseResolve: require('./2022/GetPromiseResolve'), + GetPrototypeFromConstructor: require('./2022/GetPrototypeFromConstructor'), + GetStringIndex: require('./2022/GetStringIndex'), + GetSubstitution: require('./2022/GetSubstitution'), + GetV: require('./2022/GetV'), + GetValueFromBuffer: require('./2022/GetValueFromBuffer'), + HasOwnProperty: require('./2022/HasOwnProperty'), + HasProperty: require('./2022/HasProperty'), + HourFromTime: require('./2022/HourFromTime'), + InLeapYear: require('./2022/InLeapYear'), + InstallErrorCause: require('./2022/InstallErrorCause'), + InstanceofOperator: require('./2022/InstanceofOperator'), + Invoke: require('./2022/Invoke'), + IsAccessorDescriptor: require('./2022/IsAccessorDescriptor'), + IsArray: require('./2022/IsArray'), + IsBigIntElementType: require('./2022/IsBigIntElementType'), + IsCallable: require('./2022/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2022/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2022/IsConcatSpreadable'), + IsConstructor: require('./2022/IsConstructor'), + IsDataDescriptor: require('./2022/IsDataDescriptor'), + IsDetachedBuffer: require('./2022/IsDetachedBuffer'), + IsExtensible: require('./2022/IsExtensible'), + IsGenericDescriptor: require('./2022/IsGenericDescriptor'), + IsIntegralNumber: require('./2022/IsIntegralNumber'), + IsLessThan: require('./2022/IsLessThan'), + IsLooselyEqual: require('./2022/IsLooselyEqual'), + IsNoTearConfiguration: require('./2022/IsNoTearConfiguration'), + IsPromise: require('./2022/IsPromise'), + IsPropertyKey: require('./2022/IsPropertyKey'), + IsRegExp: require('./2022/IsRegExp'), + IsSharedArrayBuffer: require('./2022/IsSharedArrayBuffer'), + IsStrictlyEqual: require('./2022/IsStrictlyEqual'), + IsStringPrefix: require('./2022/IsStringPrefix'), + IsStringWellFormedUnicode: require('./2022/IsStringWellFormedUnicode'), + IsUnclampedIntegerElementType: require('./2022/IsUnclampedIntegerElementType'), + IsUnsignedElementType: require('./2022/IsUnsignedElementType'), + IsValidIntegerIndex: require('./2022/IsValidIntegerIndex'), + IsWordChar: require('./2022/IsWordChar'), + IterableToList: require('./2022/IterableToList'), + IteratorClose: require('./2022/IteratorClose'), + IteratorComplete: require('./2022/IteratorComplete'), + IteratorNext: require('./2022/IteratorNext'), + IteratorStep: require('./2022/IteratorStep'), + IteratorValue: require('./2022/IteratorValue'), + LengthOfArrayLike: require('./2022/LengthOfArrayLike'), + MakeDate: require('./2022/MakeDate'), + MakeDay: require('./2022/MakeDay'), + MakeMatchIndicesIndexPairArray: require('./2022/MakeMatchIndicesIndexPairArray'), + MakeTime: require('./2022/MakeTime'), + max: require('./2022/max'), + min: require('./2022/min'), + MinFromTime: require('./2022/MinFromTime'), + modulo: require('./2022/modulo'), + MonthFromTime: require('./2022/MonthFromTime'), + msFromTime: require('./2022/msFromTime'), + NewPromiseCapability: require('./2022/NewPromiseCapability'), + NormalCompletion: require('./2022/NormalCompletion'), + Number: require('./2022/Number'), + NumberBitwiseOp: require('./2022/NumberBitwiseOp'), + NumberToBigInt: require('./2022/NumberToBigInt'), + NumericToRawBytes: require('./2022/NumericToRawBytes'), + ObjectDefineProperties: require('./2022/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2022/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2022/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2022/OrdinaryGetOwnProperty'), + OrdinaryGetPrototypeOf: require('./2022/OrdinaryGetPrototypeOf'), + OrdinaryHasInstance: require('./2022/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2022/OrdinaryHasProperty'), + OrdinaryObjectCreate: require('./2022/OrdinaryObjectCreate'), + OrdinarySetPrototypeOf: require('./2022/OrdinarySetPrototypeOf'), + OrdinaryToPrimitive: require('./2022/OrdinaryToPrimitive'), + PromiseResolve: require('./2022/PromiseResolve'), + QuoteJSONString: require('./2022/QuoteJSONString'), + RawBytesToNumeric: require('./2022/RawBytesToNumeric'), + RegExpCreate: require('./2022/RegExpCreate'), + RegExpExec: require('./2022/RegExpExec'), + RegExpHasFlag: require('./2022/RegExpHasFlag'), + RequireObjectCoercible: require('./2022/RequireObjectCoercible'), + SameValue: require('./2022/SameValue'), + SameValueNonNumeric: require('./2022/SameValueNonNumeric'), + SameValueZero: require('./2022/SameValueZero'), + SecFromTime: require('./2022/SecFromTime'), + Set: require('./2022/Set'), + SetFunctionLength: require('./2022/SetFunctionLength'), + SetFunctionName: require('./2022/SetFunctionName'), + SetIntegrityLevel: require('./2022/SetIntegrityLevel'), + SetTypedArrayFromArrayLike: require('./2022/SetTypedArrayFromArrayLike'), + SetTypedArrayFromTypedArray: require('./2022/SetTypedArrayFromTypedArray'), + SetValueInBuffer: require('./2022/SetValueInBuffer'), + SortIndexedProperties: require('./2022/SortIndexedProperties'), + SpeciesConstructor: require('./2022/SpeciesConstructor'), + StringCreate: require('./2022/StringCreate'), + StringGetOwnProperty: require('./2022/StringGetOwnProperty'), + StringIndexOf: require('./2022/StringIndexOf'), + StringPad: require('./2022/StringPad'), + StringToBigInt: require('./2022/StringToBigInt'), + StringToCodePoints: require('./2022/StringToCodePoints'), + StringToNumber: require('./2022/StringToNumber'), + substring: require('./2022/substring'), + SymbolDescriptiveString: require('./2022/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2022/TestIntegrityLevel'), + thisBigIntValue: require('./2022/thisBigIntValue'), + thisBooleanValue: require('./2022/thisBooleanValue'), + thisNumberValue: require('./2022/thisNumberValue'), + thisStringValue: require('./2022/thisStringValue'), + thisSymbolValue: require('./2022/thisSymbolValue'), + thisTimeValue: require('./2022/thisTimeValue'), + ThrowCompletion: require('./2022/ThrowCompletion'), + TimeClip: require('./2022/TimeClip'), + TimeFromYear: require('./2022/TimeFromYear'), + TimeString: require('./2022/TimeString'), + TimeWithinDay: require('./2022/TimeWithinDay'), + ToBigInt: require('./2022/ToBigInt'), + ToBigInt64: require('./2022/ToBigInt64'), + ToBigUint64: require('./2022/ToBigUint64'), + ToBoolean: require('./2022/ToBoolean'), + ToDateString: require('./2022/ToDateString'), + ToIndex: require('./2022/ToIndex'), + ToInt16: require('./2022/ToInt16'), + ToInt32: require('./2022/ToInt32'), + ToInt8: require('./2022/ToInt8'), + ToIntegerOrInfinity: require('./2022/ToIntegerOrInfinity'), + ToLength: require('./2022/ToLength'), + ToNumber: require('./2022/ToNumber'), + ToNumeric: require('./2022/ToNumeric'), + ToObject: require('./2022/ToObject'), + ToPrimitive: require('./2022/ToPrimitive'), + ToPropertyDescriptor: require('./2022/ToPropertyDescriptor'), + ToPropertyKey: require('./2022/ToPropertyKey'), + ToString: require('./2022/ToString'), + ToUint16: require('./2022/ToUint16'), + ToUint32: require('./2022/ToUint32'), + ToUint8: require('./2022/ToUint8'), + ToUint8Clamp: require('./2022/ToUint8Clamp'), + ToZeroPaddedDecimalString: require('./2022/ToZeroPaddedDecimalString'), + TrimString: require('./2022/TrimString'), + Type: require('./2022/Type'), + TypedArrayCreate: require('./2022/TypedArrayCreate'), + TypedArrayElementSize: require('./2022/TypedArrayElementSize'), + TypedArrayElementType: require('./2022/TypedArrayElementType'), + TypedArraySpeciesCreate: require('./2022/TypedArraySpeciesCreate'), + UnicodeEscape: require('./2022/UnicodeEscape'), + UTF16EncodeCodePoint: require('./2022/UTF16EncodeCodePoint'), + UTF16SurrogatePairToCodePoint: require('./2022/UTF16SurrogatePairToCodePoint'), + ValidateAndApplyPropertyDescriptor: require('./2022/ValidateAndApplyPropertyDescriptor'), + ValidateAtomicAccess: require('./2022/ValidateAtomicAccess'), + ValidateIntegerTypedArray: require('./2022/ValidateIntegerTypedArray'), + ValidateTypedArray: require('./2022/ValidateTypedArray'), + WeakRefDeref: require('./2022/WeakRefDeref'), + WeekDay: require('./2022/WeekDay'), + WordCharacters: require('./2022/WordCharacters'), + YearFromTime: require('./2022/YearFromTime') +}; + +module.exports = ES2022; diff --git a/node_modules/es-abstract/es2023.js b/node_modules/es-abstract/es2023.js new file mode 100644 index 0000000000000000000000000000000000000000..75fddd5bb721ba15265edaaa506fd0336d8dd95e --- /dev/null +++ b/node_modules/es-abstract/es2023.js @@ -0,0 +1,227 @@ +'use strict'; + +/* eslint global-require: 0 */ +// https://262.ecma-international.org/14.0/#sec-abstract-operations +var ES2023 = { + abs: require('./2023/abs'), + AddEntriesFromIterable: require('./2023/AddEntriesFromIterable'), + AddToKeptObjects: require('./2023/AddToKeptObjects'), + AdvanceStringIndex: require('./2023/AdvanceStringIndex'), + ApplyStringOrNumericBinaryOperator: require('./2023/ApplyStringOrNumericBinaryOperator'), + ArrayCreate: require('./2023/ArrayCreate'), + ArraySetLength: require('./2023/ArraySetLength'), + ArraySpeciesCreate: require('./2023/ArraySpeciesCreate'), + AsyncFromSyncIteratorContinuation: require('./2023/AsyncFromSyncIteratorContinuation'), + AsyncIteratorClose: require('./2023/AsyncIteratorClose'), + BigInt: require('./2023/BigInt'), + BigIntBitwiseOp: require('./2023/BigIntBitwiseOp'), + BinaryAnd: require('./2023/BinaryAnd'), + BinaryOr: require('./2023/BinaryOr'), + BinaryXor: require('./2023/BinaryXor'), + ByteListBitwiseOp: require('./2023/ByteListBitwiseOp'), + ByteListEqual: require('./2023/ByteListEqual'), + Call: require('./2023/Call'), + CanBeHeldWeakly: require('./2023/CanBeHeldWeakly'), + Canonicalize: require('./2023/Canonicalize'), + CanonicalNumericIndexString: require('./2023/CanonicalNumericIndexString'), + CharacterRange: require('./2023/CharacterRange'), + clamp: require('./2023/clamp'), + ClearKeptObjects: require('./2023/ClearKeptObjects'), + CloneArrayBuffer: require('./2023/CloneArrayBuffer'), + CodePointAt: require('./2023/CodePointAt'), + CodePointsToString: require('./2023/CodePointsToString'), + CompareArrayElements: require('./2023/CompareArrayElements'), + CompareTypedArrayElements: require('./2023/CompareTypedArrayElements'), + CompletePropertyDescriptor: require('./2023/CompletePropertyDescriptor'), + CompletionRecord: require('./2023/CompletionRecord'), + CopyDataProperties: require('./2023/CopyDataProperties'), + CreateAsyncFromSyncIterator: require('./2023/CreateAsyncFromSyncIterator'), + CreateDataProperty: require('./2023/CreateDataProperty'), + CreateDataPropertyOrThrow: require('./2023/CreateDataPropertyOrThrow'), + CreateHTML: require('./2023/CreateHTML'), + CreateIterResultObject: require('./2023/CreateIterResultObject'), + CreateListFromArrayLike: require('./2023/CreateListFromArrayLike'), + CreateMethodProperty: require('./2023/CreateMethodProperty'), + CreateNonEnumerableDataPropertyOrThrow: require('./2023/CreateNonEnumerableDataPropertyOrThrow'), + CreateRegExpStringIterator: require('./2023/CreateRegExpStringIterator'), + DateFromTime: require('./2023/DateFromTime'), + DateString: require('./2023/DateString'), + Day: require('./2023/Day'), + DayFromYear: require('./2023/DayFromYear'), + DaysInYear: require('./2023/DaysInYear'), + DayWithinYear: require('./2023/DayWithinYear'), + DefinePropertyOrThrow: require('./2023/DefinePropertyOrThrow'), + DeletePropertyOrThrow: require('./2023/DeletePropertyOrThrow'), + DetachArrayBuffer: require('./2023/DetachArrayBuffer'), + EnumerableOwnProperties: require('./2023/EnumerableOwnProperties'), + FindViaPredicate: require('./2023/FindViaPredicate'), + FlattenIntoArray: require('./2023/FlattenIntoArray'), + floor: require('./2023/floor'), + FromPropertyDescriptor: require('./2023/FromPropertyDescriptor'), + Get: require('./2023/Get'), + GetGlobalObject: require('./2023/GetGlobalObject'), + GetIterator: require('./2023/GetIterator'), + GetIteratorFromMethod: require('./2023/GetIteratorFromMethod'), + GetMatchIndexPair: require('./2023/GetMatchIndexPair'), + GetMatchString: require('./2023/GetMatchString'), + GetMethod: require('./2023/GetMethod'), + GetOwnPropertyKeys: require('./2023/GetOwnPropertyKeys'), + GetPromiseResolve: require('./2023/GetPromiseResolve'), + GetPrototypeFromConstructor: require('./2023/GetPrototypeFromConstructor'), + GetStringIndex: require('./2023/GetStringIndex'), + GetSubstitution: require('./2023/GetSubstitution'), + GetV: require('./2023/GetV'), + GetValueFromBuffer: require('./2023/GetValueFromBuffer'), + HasOwnProperty: require('./2023/HasOwnProperty'), + HasProperty: require('./2023/HasProperty'), + HourFromTime: require('./2023/HourFromTime'), + InLeapYear: require('./2023/InLeapYear'), + InstallErrorCause: require('./2023/InstallErrorCause'), + InstanceofOperator: require('./2023/InstanceofOperator'), + Invoke: require('./2023/Invoke'), + IsAccessorDescriptor: require('./2023/IsAccessorDescriptor'), + IsArray: require('./2023/IsArray'), + IsBigIntElementType: require('./2023/IsBigIntElementType'), + IsCallable: require('./2023/IsCallable'), + IsCompatiblePropertyDescriptor: require('./2023/IsCompatiblePropertyDescriptor'), + IsConcatSpreadable: require('./2023/IsConcatSpreadable'), + IsConstructor: require('./2023/IsConstructor'), + IsDataDescriptor: require('./2023/IsDataDescriptor'), + IsDetachedBuffer: require('./2023/IsDetachedBuffer'), + IsExtensible: require('./2023/IsExtensible'), + IsGenericDescriptor: require('./2023/IsGenericDescriptor'), + IsIntegralNumber: require('./2023/IsIntegralNumber'), + IsLessThan: require('./2023/IsLessThan'), + IsLooselyEqual: require('./2023/IsLooselyEqual'), + IsNoTearConfiguration: require('./2023/IsNoTearConfiguration'), + IsPromise: require('./2023/IsPromise'), + IsPropertyKey: require('./2023/IsPropertyKey'), + IsRegExp: require('./2023/IsRegExp'), + IsSharedArrayBuffer: require('./2023/IsSharedArrayBuffer'), + IsStrictlyEqual: require('./2023/IsStrictlyEqual'), + IsStringWellFormedUnicode: require('./2023/IsStringWellFormedUnicode'), + IsUnclampedIntegerElementType: require('./2023/IsUnclampedIntegerElementType'), + IsUnsignedElementType: require('./2023/IsUnsignedElementType'), + IsValidIntegerIndex: require('./2023/IsValidIntegerIndex'), + IsWordChar: require('./2023/IsWordChar'), + IteratorClose: require('./2023/IteratorClose'), + IteratorComplete: require('./2023/IteratorComplete'), + IteratorNext: require('./2023/IteratorNext'), + IteratorStep: require('./2023/IteratorStep'), + IteratorToList: require('./2023/IteratorToList'), + IteratorValue: require('./2023/IteratorValue'), + KeyForSymbol: require('./2023/KeyForSymbol'), + LengthOfArrayLike: require('./2023/LengthOfArrayLike'), + MakeDate: require('./2023/MakeDate'), + MakeDay: require('./2023/MakeDay'), + MakeMatchIndicesIndexPairArray: require('./2023/MakeMatchIndicesIndexPairArray'), + MakeTime: require('./2023/MakeTime'), + max: require('./2023/max'), + min: require('./2023/min'), + MinFromTime: require('./2023/MinFromTime'), + modulo: require('./2023/modulo'), + MonthFromTime: require('./2023/MonthFromTime'), + msFromTime: require('./2023/msFromTime'), + NewPromiseCapability: require('./2023/NewPromiseCapability'), + NormalCompletion: require('./2023/NormalCompletion'), + Number: require('./2023/Number'), + NumberBitwiseOp: require('./2023/NumberBitwiseOp'), + NumberToBigInt: require('./2023/NumberToBigInt'), + NumericToRawBytes: require('./2023/NumericToRawBytes'), + ObjectDefineProperties: require('./2023/ObjectDefineProperties'), + OrdinaryCreateFromConstructor: require('./2023/OrdinaryCreateFromConstructor'), + OrdinaryDefineOwnProperty: require('./2023/OrdinaryDefineOwnProperty'), + OrdinaryGetOwnProperty: require('./2023/OrdinaryGetOwnProperty'), + OrdinaryGetPrototypeOf: require('./2023/OrdinaryGetPrototypeOf'), + OrdinaryHasInstance: require('./2023/OrdinaryHasInstance'), + OrdinaryHasProperty: require('./2023/OrdinaryHasProperty'), + OrdinaryObjectCreate: require('./2023/OrdinaryObjectCreate'), + OrdinarySetPrototypeOf: require('./2023/OrdinarySetPrototypeOf'), + OrdinaryToPrimitive: require('./2023/OrdinaryToPrimitive'), + ParseHexOctet: require('./2023/ParseHexOctet'), + PromiseResolve: require('./2023/PromiseResolve'), + QuoteJSONString: require('./2023/QuoteJSONString'), + RawBytesToNumeric: require('./2023/RawBytesToNumeric'), + RegExpCreate: require('./2023/RegExpCreate'), + RegExpExec: require('./2023/RegExpExec'), + RegExpHasFlag: require('./2023/RegExpHasFlag'), + RequireObjectCoercible: require('./2023/RequireObjectCoercible'), + SameValue: require('./2023/SameValue'), + SameValueNonNumber: require('./2023/SameValueNonNumber'), + SameValueZero: require('./2023/SameValueZero'), + SecFromTime: require('./2023/SecFromTime'), + Set: require('./2023/Set'), + SetFunctionLength: require('./2023/SetFunctionLength'), + SetFunctionName: require('./2023/SetFunctionName'), + SetIntegrityLevel: require('./2023/SetIntegrityLevel'), + SetTypedArrayFromArrayLike: require('./2023/SetTypedArrayFromArrayLike'), + SetTypedArrayFromTypedArray: require('./2023/SetTypedArrayFromTypedArray'), + SetValueInBuffer: require('./2023/SetValueInBuffer'), + SortIndexedProperties: require('./2023/SortIndexedProperties'), + SpeciesConstructor: require('./2023/SpeciesConstructor'), + StringCreate: require('./2023/StringCreate'), + StringGetOwnProperty: require('./2023/StringGetOwnProperty'), + StringIndexOf: require('./2023/StringIndexOf'), + StringPad: require('./2023/StringPad'), + StringToBigInt: require('./2023/StringToBigInt'), + StringToCodePoints: require('./2023/StringToCodePoints'), + StringToNumber: require('./2023/StringToNumber'), + substring: require('./2023/substring'), + SymbolDescriptiveString: require('./2023/SymbolDescriptiveString'), + TestIntegrityLevel: require('./2023/TestIntegrityLevel'), + thisBigIntValue: require('./2023/thisBigIntValue'), + thisBooleanValue: require('./2023/thisBooleanValue'), + thisNumberValue: require('./2023/thisNumberValue'), + thisStringValue: require('./2023/thisStringValue'), + thisSymbolValue: require('./2023/thisSymbolValue'), + thisTimeValue: require('./2023/thisTimeValue'), + ThrowCompletion: require('./2023/ThrowCompletion'), + TimeClip: require('./2023/TimeClip'), + TimeFromYear: require('./2023/TimeFromYear'), + TimeString: require('./2023/TimeString'), + TimeWithinDay: require('./2023/TimeWithinDay'), + ToBigInt: require('./2023/ToBigInt'), + ToBigInt64: require('./2023/ToBigInt64'), + ToBigUint64: require('./2023/ToBigUint64'), + ToBoolean: require('./2023/ToBoolean'), + ToDateString: require('./2023/ToDateString'), + ToIndex: require('./2023/ToIndex'), + ToInt16: require('./2023/ToInt16'), + ToInt32: require('./2023/ToInt32'), + ToInt8: require('./2023/ToInt8'), + ToIntegerOrInfinity: require('./2023/ToIntegerOrInfinity'), + ToLength: require('./2023/ToLength'), + ToNumber: require('./2023/ToNumber'), + ToNumeric: require('./2023/ToNumeric'), + ToObject: require('./2023/ToObject'), + ToPrimitive: require('./2023/ToPrimitive'), + ToPropertyDescriptor: require('./2023/ToPropertyDescriptor'), + ToPropertyKey: require('./2023/ToPropertyKey'), + ToString: require('./2023/ToString'), + ToUint16: require('./2023/ToUint16'), + ToUint32: require('./2023/ToUint32'), + ToUint8: require('./2023/ToUint8'), + ToUint8Clamp: require('./2023/ToUint8Clamp'), + ToZeroPaddedDecimalString: require('./2023/ToZeroPaddedDecimalString'), + TrimString: require('./2023/TrimString'), + truncate: require('./2023/truncate'), + Type: require('./2023/Type'), + TypedArrayCreate: require('./2023/TypedArrayCreate'), + TypedArrayCreateSameType: require('./2023/TypedArrayCreateSameType'), + TypedArrayElementSize: require('./2023/TypedArrayElementSize'), + TypedArrayElementType: require('./2023/TypedArrayElementType'), + TypedArraySpeciesCreate: require('./2023/TypedArraySpeciesCreate'), + UnicodeEscape: require('./2023/UnicodeEscape'), + UTF16EncodeCodePoint: require('./2023/UTF16EncodeCodePoint'), + UTF16SurrogatePairToCodePoint: require('./2023/UTF16SurrogatePairToCodePoint'), + ValidateAndApplyPropertyDescriptor: require('./2023/ValidateAndApplyPropertyDescriptor'), + ValidateAtomicAccess: require('./2023/ValidateAtomicAccess'), + ValidateIntegerTypedArray: require('./2023/ValidateIntegerTypedArray'), + ValidateTypedArray: require('./2023/ValidateTypedArray'), + WeakRefDeref: require('./2023/WeakRefDeref'), + WeekDay: require('./2023/WeekDay'), + WordCharacters: require('./2023/WordCharacters'), + YearFromTime: require('./2023/YearFromTime') +}; + +module.exports = ES2023; diff --git a/node_modules/es-abstract/es5.js b/node_modules/es-abstract/es5.js new file mode 100644 index 0000000000000000000000000000000000000000..3cb42988c99d76000cd5c1f64f659c4c3583b64a --- /dev/null +++ b/node_modules/es-abstract/es5.js @@ -0,0 +1,52 @@ +'use strict'; + +/* eslint global-require: 0 */ + +// https://es5.github.io/#x9 +module.exports = { + 'Abstract Equality Comparison': require('./5/AbstractEqualityComparison'), + 'Abstract Relational Comparison': require('./5/AbstractRelationalComparison'), + 'Strict Equality Comparison': require('./5/StrictEqualityComparison'), + abs: require('./5/abs'), + Canonicalize: require('./5/Canonicalize'), + CheckObjectCoercible: require('./5/CheckObjectCoercible'), + DateFromTime: require('./5/DateFromTime'), + Day: require('./5/Day'), + DayFromYear: require('./5/DayFromYear'), + DaysInYear: require('./5/DaysInYear'), + DayWithinYear: require('./5/DayWithinYear'), + floor: require('./5/floor'), + FromPropertyDescriptor: require('./5/FromPropertyDescriptor'), + HourFromTime: require('./5/HourFromTime'), + InLeapYear: require('./5/InLeapYear'), + IsAccessorDescriptor: require('./5/IsAccessorDescriptor'), + IsCallable: require('./5/IsCallable'), + IsDataDescriptor: require('./5/IsDataDescriptor'), + IsGenericDescriptor: require('./5/IsGenericDescriptor'), + IsPropertyDescriptor: require('./5/IsPropertyDescriptor'), + MakeDate: require('./5/MakeDate'), + MakeDay: require('./5/MakeDay'), + MakeTime: require('./5/MakeTime'), + MinFromTime: require('./5/MinFromTime'), + modulo: require('./5/modulo'), + MonthFromTime: require('./5/MonthFromTime'), + msFromTime: require('./5/msFromTime'), + SameValue: require('./5/SameValue'), + SecFromTime: require('./5/SecFromTime'), + TimeClip: require('./5/TimeClip'), + TimeFromYear: require('./5/TimeFromYear'), + TimeWithinDay: require('./5/TimeWithinDay'), + ToBoolean: require('./5/ToBoolean'), + ToInt32: require('./5/ToInt32'), + ToInteger: require('./5/ToInteger'), + ToNumber: require('./5/ToNumber'), + ToObject: require('./5/ToObject'), + ToPrimitive: require('./5/ToPrimitive'), + ToPropertyDescriptor: require('./5/ToPropertyDescriptor'), + ToString: require('./5/ToString'), + ToUint16: require('./5/ToUint16'), + ToUint32: require('./5/ToUint32'), + Type: require('./5/Type'), + WeekDay: require('./5/WeekDay'), + YearFromTime: require('./5/YearFromTime') +}; diff --git a/node_modules/es-abstract/es6.js b/node_modules/es-abstract/es6.js new file mode 100644 index 0000000000000000000000000000000000000000..2d1f4dc927a904056054c0030c14db3703e9d1d7 --- /dev/null +++ b/node_modules/es-abstract/es6.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./es2015'); diff --git a/node_modules/es-abstract/es7.js b/node_modules/es-abstract/es7.js new file mode 100644 index 0000000000000000000000000000000000000000..f2f15c0a88712c90794becea456ba86d4c35b11e --- /dev/null +++ b/node_modules/es-abstract/es7.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./es2016'); diff --git a/node_modules/es-abstract/helpers/DefineOwnProperty.js b/node_modules/es-abstract/helpers/DefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..61e83716e67018a6bca69022d4d733acc2c3724c --- /dev/null +++ b/node_modules/es-abstract/helpers/DefineOwnProperty.js @@ -0,0 +1,55 @@ +'use strict'; + +var hasPropertyDescriptors = require('has-property-descriptors'); + +var GetIntrinsic = require('get-intrinsic'); + +var $defineProperty = hasPropertyDescriptors() && GetIntrinsic('%Object.defineProperty%', true); + +var hasArrayLengthDefineBug = hasPropertyDescriptors.hasArrayLengthDefineBug(); + +// eslint-disable-next-line global-require +var isArray = hasArrayLengthDefineBug && require('../helpers/IsArray'); + +var callBound = require('call-bind/callBound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +// eslint-disable-next-line max-params +module.exports = function DefineOwnProperty(IsDataDescriptor, SameValue, FromPropertyDescriptor, O, P, desc) { + if (!$defineProperty) { + if (!IsDataDescriptor(desc)) { + // ES3 does not support getters/setters + return false; + } + if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) { + return false; + } + + // fallback for ES3 + if (P in O && $isEnumerable(O, P) !== !!desc['[[Enumerable]]']) { + // a non-enumerable existing property + return false; + } + + // property does not exist at all, or exists but is enumerable + var V = desc['[[Value]]']; + // eslint-disable-next-line no-param-reassign + O[P] = V; // will use [[Define]] + return SameValue(O[P], V); + } + if ( + hasArrayLengthDefineBug + && P === 'length' + && '[[Value]]' in desc + && isArray(O) + && O.length !== desc['[[Value]]'] + ) { + // eslint-disable-next-line no-param-reassign + O.length = desc['[[Value]]']; + return O.length === desc['[[Value]]']; + } + + $defineProperty(O, P, FromPropertyDescriptor(desc)); + return true; +}; diff --git a/node_modules/es-abstract/helpers/IsArray.js b/node_modules/es-abstract/helpers/IsArray.js new file mode 100644 index 0000000000000000000000000000000000000000..26b52fb4bfc5e6f8ba11e7cbd7e73a9191705e99 --- /dev/null +++ b/node_modules/es-abstract/helpers/IsArray.js @@ -0,0 +1,12 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Array = GetIntrinsic('%Array%'); + +// eslint-disable-next-line global-require +var toStr = !$Array.isArray && require('call-bind/callBound')('Object.prototype.toString'); + +module.exports = $Array.isArray || function IsArray(argument) { + return toStr(argument) === '[object Array]'; +}; diff --git a/node_modules/es-abstract/helpers/OwnPropertyKeys.js b/node_modules/es-abstract/helpers/OwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..6baa986fb4b90a0e355c72acf2290f0ef80c320c --- /dev/null +++ b/node_modules/es-abstract/helpers/OwnPropertyKeys.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var callBind = require('call-bind'); +var callBound = require('call-bind/callBound'); + +var $ownKeys = GetIntrinsic('%Reflect.ownKeys%', true); +var $pushApply = callBind.apply(GetIntrinsic('%Array.prototype.push%')); +var $SymbolValueOf = callBound('Symbol.prototype.valueOf', true); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = $SymbolValueOf ? GetIntrinsic('%Object.getOwnPropertySymbols%') : null; + +var keys = require('object-keys'); + +module.exports = $ownKeys || function OwnPropertyKeys(source) { + var ownKeys = ($gOPN || keys)(source); + if ($gOPS) { + $pushApply(ownKeys, $gOPS(source)); + } + return ownKeys; +}; diff --git a/node_modules/es-abstract/helpers/assertRecord.js b/node_modules/es-abstract/helpers/assertRecord.js new file mode 100644 index 0000000000000000000000000000000000000000..d715c9c7f295bbeadd9a8d702605eab46afa5e50 --- /dev/null +++ b/node_modules/es-abstract/helpers/assertRecord.js @@ -0,0 +1,87 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); + +var hasOwn = require('hasown'); +var isInteger = require('./isInteger'); + +var isMatchRecord = require('./isMatchRecord'); + +var predicates = { + // https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type + 'Property Descriptor': function isPropertyDescriptor(Desc) { + var allowed = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Get]]': true, + '[[Set]]': true, + '[[Value]]': true, + '[[Writable]]': true + }; + + if (!Desc) { + return false; + } + for (var key in Desc) { // eslint-disable-line + if (hasOwn(Desc, key) && !allowed[key]) { + return false; + } + } + + var isData = hasOwn(Desc, '[[Value]]'); + var IsAccessor = hasOwn(Desc, '[[Get]]') || hasOwn(Desc, '[[Set]]'); + if (isData && IsAccessor) { + throw new $TypeError('Property Descriptors may not be both accessor and data descriptors'); + } + return true; + }, + // https://262.ecma-international.org/13.0/#sec-match-records + 'Match Record': isMatchRecord, + 'Iterator Record': function isIteratorRecord(value) { + return hasOwn(value, '[[Iterator]]') && hasOwn(value, '[[NextMethod]]') && hasOwn(value, '[[Done]]'); + }, + 'PromiseCapability Record': function isPromiseCapabilityRecord(value) { + return !!value + && hasOwn(value, '[[Resolve]]') + && typeof value['[[Resolve]]'] === 'function' + && hasOwn(value, '[[Reject]]') + && typeof value['[[Reject]]'] === 'function' + && hasOwn(value, '[[Promise]]') + && value['[[Promise]]'] + && typeof value['[[Promise]]'].then === 'function'; + }, + 'AsyncGeneratorRequest Record': function isAsyncGeneratorRequestRecord(value) { + return !!value + && hasOwn(value, '[[Completion]]') // TODO: confirm is a completion record + && hasOwn(value, '[[Capability]]') + && predicates['PromiseCapability Record'](value['[[Capability]]']); + }, + 'RegExp Record': function isRegExpRecord(value) { + return value + && hasOwn(value, '[[IgnoreCase]]') + && typeof value['[[IgnoreCase]]'] === 'boolean' + && hasOwn(value, '[[Multiline]]') + && typeof value['[[Multiline]]'] === 'boolean' + && hasOwn(value, '[[DotAll]]') + && typeof value['[[DotAll]]'] === 'boolean' + && hasOwn(value, '[[Unicode]]') + && typeof value['[[Unicode]]'] === 'boolean' + && hasOwn(value, '[[CapturingGroupsCount]]') + && typeof value['[[CapturingGroupsCount]]'] === 'number' + && isInteger(value['[[CapturingGroupsCount]]']) + && value['[[CapturingGroupsCount]]'] >= 0; + } +}; + +module.exports = function assertRecord(Type, recordType, argumentName, value) { + var predicate = predicates[recordType]; + if (typeof predicate !== 'function') { + throw new $SyntaxError('unknown record type: ' + recordType); + } + if (Type(value) !== 'Object' || !predicate(value)) { + throw new $TypeError(argumentName + ' must be a ' + recordType); + } +}; diff --git a/node_modules/es-abstract/helpers/assign.js b/node_modules/es-abstract/helpers/assign.js new file mode 100644 index 0000000000000000000000000000000000000000..1e63a30de0c6d3b30a9cd4565cb6cb1676445e6a --- /dev/null +++ b/node_modules/es-abstract/helpers/assign.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasOwn = require('hasown'); + +var $assign = GetIntrinsic('%Object.assign%', true); + +module.exports = function assign(target, source) { + if ($assign) { + return $assign(target, source); + } + + // eslint-disable-next-line no-restricted-syntax + for (var key in source) { + if (hasOwn(source, key)) { + // eslint-disable-next-line no-param-reassign + target[key] = source[key]; + } + } + return target; +}; diff --git a/node_modules/es-abstract/helpers/bytesAsFloat32.js b/node_modules/es-abstract/helpers/bytesAsFloat32.js new file mode 100644 index 0000000000000000000000000000000000000000..2e2cdcb1aba9d24e7436e6975ef034d5d1ca5c3c --- /dev/null +++ b/node_modules/es-abstract/helpers/bytesAsFloat32.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $pow = GetIntrinsic('%Math.pow%'); + +module.exports = function bytesAsFloat32(rawBytes) { + // return new Float32Array(new Uint8Array(rawBytes).buffer)[0]; + + /* + Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary32 value. +If value is an IEEE 754-2008 binary32 NaN value, return the NaN Number value. +Return the Number value that corresponds to value. + */ + var sign = rawBytes[3] & 0x80 ? -1 : 1; // Check the sign bit + var exponent = ((rawBytes[3] & 0x7F) << 1) + | (rawBytes[2] >> 7); // Combine bits for exponent + var mantissa = ((rawBytes[2] & 0x7F) << 16) + | (rawBytes[1] << 8) + | rawBytes[0]; // Combine bits for mantissa + + if (exponent === 0 && mantissa === 0) { + return sign === 1 ? 0 : -0; + } + if (exponent === 0xFF && mantissa === 0) { + return sign === 1 ? Infinity : -Infinity; + } + if (exponent === 0xFF && mantissa !== 0) { + return NaN; + } + + exponent -= 127; // subtract the bias + + if (exponent === -127) { + return sign * mantissa * $pow(2, -126 - 23); + } + return sign * (1 + (mantissa * $pow(2, -23))) * $pow(2, exponent); +}; diff --git a/node_modules/es-abstract/helpers/bytesAsFloat64.js b/node_modules/es-abstract/helpers/bytesAsFloat64.js new file mode 100644 index 0000000000000000000000000000000000000000..675c5b6d81ccf18296d422645b727b33bc054e69 --- /dev/null +++ b/node_modules/es-abstract/helpers/bytesAsFloat64.js @@ -0,0 +1,44 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $pow = GetIntrinsic('%Math.pow%'); + +module.exports = function bytesAsFloat64(rawBytes) { + // return new Float64Array(new Uint8Array(rawBytes).buffer)[0]; + + /* + Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary64 value. +If value is an IEEE 754-2008 binary64 NaN value, return the NaN Number value. +Return the Number value that corresponds to value. + */ + var sign = rawBytes[7] & 0x80 ? -1 : 1; // first bit + var exponent = ((rawBytes[7] & 0x7F) << 4) // 7 bits from index 7 + | ((rawBytes[6] & 0xF0) >> 4); // 4 bits from index 6 + var mantissa = ((rawBytes[6] & 0x0F) * 0x1000000000000) // 4 bits from index 6 + + (rawBytes[5] * 0x10000000000) // 8 bits from index 5 + + (rawBytes[4] * 0x100000000) // 8 bits from index 4 + + (rawBytes[3] * 0x1000000) // 8 bits from index 3 + + (rawBytes[2] * 0x10000) // 8 bits from index 2 + + (rawBytes[1] * 0x100) // 8 bits from index 1 + + rawBytes[0]; // 8 bits from index 0 + + if (exponent === 0 && mantissa === 0) { + return sign * 0; + } + if (exponent === 0x7FF && mantissa !== 0) { + return NaN; + } + if (exponent === 0x7FF && mantissa === 0) { + return sign * Infinity; + } + + exponent -= 1023; // subtract the bias + + // Handle subnormal numbers + if (exponent === -1023) { + return sign * mantissa * 5e-324; // $pow(2, -1022 - 52) + } + + return sign * (1 + (mantissa / 0x10000000000000)) * $pow(2, exponent); +}; diff --git a/node_modules/es-abstract/helpers/bytesAsInteger.js b/node_modules/es-abstract/helpers/bytesAsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..bae4bef2d44b84dac105b34698004c59dd90901b --- /dev/null +++ b/node_modules/es-abstract/helpers/bytesAsInteger.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $pow = GetIntrinsic('%Math.pow%'); +var $Number = GetIntrinsic('%Number%'); +var $BigInt = GetIntrinsic('%BigInt%', true); + +module.exports = function bytesAsInteger(rawBytes, elementSize, isUnsigned, isBigInt) { + var Z = isBigInt ? $BigInt : $Number; + + // this is common to both branches + var intValue = Z(0); + for (var i = 0; i < rawBytes.length; i++) { + intValue += Z(rawBytes[i]) * Z($pow(2, 8 * i)); + } + /* + Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number. + */ + + if (!isUnsigned) { // steps 5-6 + // Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian 2's complement number of bit length elementSize × 8. + var bitLength = elementSize * 8; + + if (rawBytes[elementSize - 1] & 0x80) { + intValue -= Z($pow(2, bitLength)); + } + } + + return intValue; // step 7 +}; diff --git a/node_modules/es-abstract/helpers/callBind.js b/node_modules/es-abstract/helpers/callBind.js new file mode 100644 index 0000000000000000000000000000000000000000..699dba7062bd96f5cf7e799b4dfc6d57f5835be0 --- /dev/null +++ b/node_modules/es-abstract/helpers/callBind.js @@ -0,0 +1,5 @@ +'use strict'; + +// TODO; semver-major: remove + +module.exports = require('call-bind'); diff --git a/node_modules/es-abstract/helpers/callBound.js b/node_modules/es-abstract/helpers/callBound.js new file mode 100644 index 0000000000000000000000000000000000000000..349030cbc960356069067a54978b7e61f15ef423 --- /dev/null +++ b/node_modules/es-abstract/helpers/callBound.js @@ -0,0 +1,5 @@ +'use strict'; + +// TODO; semver-major: remove + +module.exports = require('call-bind/callBound'); diff --git a/node_modules/es-abstract/helpers/caseFolding.json b/node_modules/es-abstract/helpers/caseFolding.json new file mode 100644 index 0000000000000000000000000000000000000000..1f8383511e4b914c3422897ca57368594b0a02d8 --- /dev/null +++ b/node_modules/es-abstract/helpers/caseFolding.json @@ -0,0 +1,1430 @@ +{ + "C": { + "a": "A", + "b": "B", + "c": "C", + "d": "D", + "e": "E", + "f": "F", + "g": "G", + "h": "H", + "i": "I", + "j": "J", + "k": "K", + "l": "L", + "m": "M", + "n": "N", + "o": "O", + "p": "P", + "q": "Q", + "r": "R", + "s": "ſ", + "t": "T", + "u": "U", + "v": "V", + "w": "W", + "x": "X", + "y": "Y", + "z": "Z", + "μ": "Μ", + "à": "À", + "á": "Á", + "â": "Â", + "ã": "Ã", + "ä": "Ä", + "å": "Å", + "æ": "Æ", + "ç": "Ç", + "è": "È", + "é": "É", + "ê": "Ê", + "ë": "Ë", + "ì": "Ì", + "í": "Í", + "î": "Î", + "ï": "Ï", + "ð": "Ð", + "ñ": "Ñ", + "ò": "Ò", + "ó": "Ó", + "ô": "Ô", + "õ": "Õ", + "ö": "Ö", + "ø": "Ø", + "ù": "Ù", + "ú": "Ú", + "û": "Û", + "ü": "Ü", + "ý": "Ý", + "þ": "Þ", + "ā": "Ā", + "ă": "Ă", + "ą": "Ą", + "ć": "Ć", + "ĉ": "Ĉ", + "ċ": "Ċ", + "č": "Č", + "ď": "Ď", + "đ": "Đ", + "ē": "Ē", + "ĕ": "Ĕ", + "ė": "Ė", + "ę": "Ę", + "ě": "Ě", + "ĝ": "Ĝ", + "ğ": "Ğ", + "ġ": "Ġ", + "ģ": "Ģ", + "ĥ": "Ĥ", + "ħ": "Ħ", + "ĩ": "Ĩ", + "ī": "Ī", + "ĭ": "Ĭ", + "į": "Į", + "ij": "IJ", + "ĵ": "Ĵ", + "ķ": "Ķ", + "ĺ": "Ĺ", + "ļ": "Ļ", + "ľ": "Ľ", + "ŀ": "Ŀ", + "ł": "Ł", + "ń": "Ń", + "ņ": "Ņ", + "ň": "Ň", + "ŋ": "Ŋ", + "ō": "Ō", + "ŏ": "Ŏ", + "ő": "Ő", + "œ": "Œ", + "ŕ": "Ŕ", + "ŗ": "Ŗ", + "ř": "Ř", + "ś": "Ś", + "ŝ": "Ŝ", + "ş": "Ş", + "š": "Š", + "ţ": "Ţ", + "ť": "Ť", + "ŧ": "Ŧ", + "ũ": "Ũ", + "ū": "Ū", + "ŭ": "Ŭ", + "ů": "Ů", + "ű": "Ű", + "ų": "Ų", + "ŵ": "Ŵ", + "ŷ": "Ŷ", + "ÿ": "Ÿ", + "ź": "Ź", + "ż": "Ż", + "ž": "Ž", + "ɓ": "Ɓ", + "ƃ": "Ƃ", + "ƅ": "Ƅ", + "ɔ": "Ɔ", + "ƈ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+ "ƞ": "Ƞ", + "ȣ": "Ȣ", + "ȥ": "Ȥ", + "ȧ": "Ȧ", + "ȩ": "Ȩ", + "ȫ": "Ȫ", + "ȭ": "Ȭ", + "ȯ": "Ȯ", + "ȱ": "Ȱ", + "ȳ": "Ȳ", + "ⱥ": "Ⱥ", + "ȼ": "Ȼ", + "ƚ": "Ƚ", + "ⱦ": "Ⱦ", + "ɂ": "Ɂ", + "ƀ": "Ƀ", + "ʉ": "Ʉ", + "ʌ": "Ʌ", + "ɇ": "Ɇ", + "ɉ": "Ɉ", + "ɋ": "Ɋ", + "ɍ": "Ɍ", + "ɏ": "Ɏ", + "ι": "ι", + "ͱ": "Ͱ", + "ͳ": "Ͳ", + "ͷ": "Ͷ", + "ϳ": "Ϳ", + "ά": "Ά", + "έ": "Έ", + "ή": "Ή", + "ί": "Ί", + "ό": "Ό", + "ύ": "Ύ", + "ώ": "Ώ", + "α": "Α", + "β": "ϐ", + "γ": "Γ", + "δ": "Δ", + "ε": "ϵ", + "ζ": "Ζ", + "η": "Η", + "θ": "ϴ", + "κ": "ϰ", + "λ": "Λ", + "ν": "Ν", + "ξ": "Ξ", + "ο": "Ο", + "π": "ϖ", + "ρ": "ϱ", + "σ": "ς", + "τ": "Τ", + "υ": "Υ", + "φ": "ϕ", + "χ": "Χ", + "ψ": "Ψ", + "ω": "Ω", + "ϊ": "Ϊ", + "ϋ": "Ϋ", + "ϗ": "Ϗ", + "ϙ": "Ϙ", + "ϛ": "Ϛ", + "ϝ": "Ϝ", + "ϟ": "Ϟ", + "ϡ": "Ϡ", + "ϣ": "Ϣ", + "ϥ": "Ϥ", + "ϧ": "Ϧ", + "ϩ": "Ϩ", + "ϫ": "Ϫ", + "ϭ": "Ϭ", + "ϯ": "Ϯ", + "ϸ": "Ϸ", + "ϲ": "Ϲ", + "ϻ": "Ϻ", + "ͻ": "Ͻ", + "ͼ": "Ͼ", + "ͽ": "Ͽ", + "ѐ": "Ѐ", + "ё": "Ё", + "ђ": "Ђ", + "ѓ": "Ѓ", + "є": "Є", + "ѕ": "Ѕ", + "і": "І", + "ї": "Ї", + "ј": "Ј", + "љ": "Љ", + "њ": "Њ", + "ћ": "Ћ", + "ќ": "Ќ", + "ѝ": "Ѝ", + "ў": "Ў", + "џ": "Џ", + "а": "А", + "б": "Б", + "в": "ᲀ", + "г": "Г", + "д": "ᲁ", + "е": "Е", + "ж": "Ж", + "з": "З", + "и": "И", + "й": "Й", + "к": "К", + "л": "Л", + "м": "М", + "н": "Н", + "о": "ᲂ", + "п": "П", + "р": "Р", + "с": "ᲃ", + "т": "ᲅ", + "у": "У", + "ф": "Ф", + "х": "Х", + "ц": "Ц", + "ч": "Ч", + "ш": "Ш", + "щ": "Щ", + "ъ": "ᲆ", + "ы": "Ы", + "ь": "Ь", + "э": "Э", + "ю": "Ю", + "я": "Я", + "ѡ": "Ѡ", + "ѣ": "ᲇ", + "ѥ": "Ѥ", + "ѧ": "Ѧ", + "ѩ": "Ѩ", + "ѫ": "Ѫ", + "ѭ": "Ѭ", + "ѯ": "Ѯ", + "ѱ": "Ѱ", + "ѳ": "Ѳ", + "ѵ": "Ѵ", + "ѷ": "Ѷ", + "ѹ": "Ѹ", + "ѻ": "Ѻ", + "ѽ": "Ѽ", + "ѿ": "Ѿ", + "ҁ": "Ҁ", + "ҋ": "Ҋ", + "ҍ": "Ҍ", + "ҏ": "Ҏ", + "ґ": "Ґ", + "ғ": "Ғ", + "ҕ": "Ҕ", + "җ": "Җ", + "ҙ": "Ҙ", + "қ": "Қ", + "ҝ": "Ҝ", + "ҟ": "Ҟ", + "ҡ": "Ҡ", + "ң": "Ң", + "ҥ": "Ҥ", + "ҧ": "Ҧ", + "ҩ": "Ҩ", + "ҫ": "Ҫ", + "ҭ": "Ҭ", + "ү": "Ү", + "ұ": "Ұ", + "ҳ": "Ҳ", + "ҵ": "Ҵ", + "ҷ": "Ҷ", + "ҹ": "Ҹ", + "һ": "Һ", + "ҽ": "Ҽ", + "ҿ": "Ҿ", + "ӏ": "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", + "պ": "Պ", + "ջ": "Ջ", + "ռ": "Ռ", + "ս": "Ս", + "վ": "Վ", + "տ": "Տ", + "ր": "Ր", + "ց": "Ց", + "ւ": "Ւ", + "փ": "Փ", + "ք": "Ք", + "օ": "Օ", + "ֆ": "Ֆ", + "ⴀ": "Ⴀ", + "ⴁ": "Ⴁ", + "ⴂ": "Ⴂ", + "ⴃ": "Ⴃ", + "ⴄ": "Ⴄ", + "ⴅ": "Ⴅ", + "ⴆ": "Ⴆ", + "ⴇ": "Ⴇ", + "ⴈ": "Ⴈ", + "ⴉ": "Ⴉ", + "ⴊ": "Ⴊ", + "ⴋ": "Ⴋ", + "ⴌ": "Ⴌ", + "ⴍ": "Ⴍ", + "ⴎ": "Ⴎ", + "ⴏ": "Ⴏ", + "ⴐ": "Ⴐ", + "ⴑ": "Ⴑ", + "ⴒ": "Ⴒ", + "ⴓ": "Ⴓ", + "ⴔ": "Ⴔ", + "ⴕ": "Ⴕ", + "ⴖ": "Ⴖ", + "ⴗ": "Ⴗ", + "ⴘ": "Ⴘ", + "ⴙ": "Ⴙ", + "ⴚ": "Ⴚ", + "ⴛ": "Ⴛ", + "ⴜ": "Ⴜ", + "ⴝ": "Ⴝ", + "ⴞ": "Ⴞ", + "ⴟ": "Ⴟ", + "ⴠ": "Ⴠ", + "ⴡ": "Ⴡ", + "ⴢ": "Ⴢ", + "ⴣ": "Ⴣ", + "ⴤ": "Ⴤ", + "ⴥ": "Ⴥ", + "ⴧ": "Ⴧ", + "ⴭ": "Ⴭ", + "Ᏸ": "ᏸ", + "Ᏹ": "ᏹ", + "Ᏺ": "ᏺ", + "Ᏻ": "ᏻ", + "Ᏼ": "ᏼ", + "Ᏽ": "ᏽ", + "ꙋ": "Ꙋ", + "ა": "Ა", + "ბ": "Ბ", + "გ": "Გ", + "დ": "Დ", + "ე": "Ე", + "ვ": "Ვ", + "ზ": "Ზ", + "თ": "Თ", + "ი": "Ი", + "კ": "Კ", + "ლ": "Ლ", + "მ": "Მ", + "ნ": "Ნ", + "ო": "Ო", + "პ": "Პ", + "ჟ": "Ჟ", + "რ": "Რ", + "ს": "Ს", + "ტ": "Ტ", + "უ": "Უ", + "ფ": "Ფ", + "ქ": "Ქ", + "ღ": "Ღ", + "ყ": "Ყ", + "შ": "Შ", + "ჩ": "Ჩ", + "ც": "Ც", + "ძ": "Ძ", + "წ": "Წ", + "ჭ": "Ჭ", + "ხ": "Ხ", + "ჯ": "Ჯ", + "ჰ": "Ჰ", + "ჱ": "Ჱ", + "ჲ": "Ჲ", + "ჳ": "Ჳ", + "ჴ": "Ჴ", + "ჵ": "Ჵ", + "ჶ": "Ჶ", + "ჷ": "Ჷ", + "ჸ": "Ჸ", + "ჹ": "Ჹ", + "ჺ": "Ჺ", + "ჽ": "Ჽ", + "ჾ": "Ჾ", + "ჿ": "Ჿ", + "ḁ": "Ḁ", + "ḃ": "Ḃ", + "ḅ": "Ḅ", + "ḇ": "Ḇ", + "ḉ": "Ḉ", + "ḋ": "Ḋ", + "ḍ": "Ḍ", + "ḏ": "Ḏ", + "ḑ": "Ḑ", + "ḓ": "Ḓ", + "ḕ": "Ḕ", + "ḗ": "Ḗ", + "ḙ": "Ḙ", + "ḛ": "Ḛ", + "ḝ": "Ḝ", + "ḟ": "Ḟ", + "ḡ": "Ḡ", + "ḣ": "Ḣ", + "ḥ": "Ḥ", + "ḧ": "Ḧ", + "ḩ": "Ḩ", + "ḫ": "Ḫ", + "ḭ": "Ḭ", + "ḯ": "Ḯ", + "ḱ": "Ḱ", + "ḳ": "Ḳ", + "ḵ": "Ḵ", + "ḷ": "Ḷ", + "ḹ": "Ḹ", + "ḻ": "Ḻ", + "ḽ": "Ḽ", + "ḿ": "Ḿ", + "ṁ": "Ṁ", + "ṃ": "Ṃ", + "ṅ": "Ṅ", + "ṇ": "Ṇ", + "ṉ": "Ṉ", + "ṋ": "Ṋ", + "ṍ": "Ṍ", + "ṏ": "Ṏ", + "ṑ": "Ṑ", + "ṓ": "Ṓ", + "ṕ": "Ṕ", + "ṗ": "Ṗ", + "ṙ": "Ṙ", + "ṛ": "Ṛ", + "ṝ": "Ṝ", + "ṟ": "Ṟ", + "ṡ": "ẛ", + "ṣ": "Ṣ", + "ṥ": "Ṥ", + "ṧ": "Ṧ", + "ṩ": "Ṩ", + "ṫ": "Ṫ", + "ṭ": "Ṭ", + "ṯ": "Ṯ", + "ṱ": "Ṱ", + "ṳ": "Ṳ", + "ṵ": "Ṵ", + "ṷ": "Ṷ", + "ṹ": "Ṹ", + "ṻ": "Ṻ", + "ṽ": "Ṽ", + "ṿ": "Ṿ", + "ẁ": "Ẁ", + "ẃ": "Ẃ", + "ẅ": "Ẅ", + "ẇ": "Ẇ", + "ẉ": "Ẉ", + "ẋ": "Ẋ", + "ẍ": "Ẍ", + "ẏ": "Ẏ", + "ẑ": "Ẑ", + "ẓ": "Ẓ", + "ẕ": "Ẕ", + "ạ": "Ạ", + "ả": "Ả", + "ấ": "Ấ", + "ầ": "Ầ", + "ẩ": "Ẩ", + "ẫ": "Ẫ", + "ậ": "Ậ", + "ắ": "Ắ", + "ằ": "Ằ", + "ẳ": "Ẳ", + "ẵ": "Ẵ", + "ặ": "Ặ", + "ẹ": "Ẹ", + "ẻ": "Ẻ", + "ẽ": "Ẽ", + "ế": "Ế", + "ề": "Ề", + "ể": "Ể", + "ễ": "Ễ", + "ệ": "Ệ", + "ỉ": "Ỉ", + "ị": "Ị", + "ọ": "Ọ", + "ỏ": "Ỏ", + "ố": "Ố", + "ồ": "Ồ", + "ổ": "Ổ", + "ỗ": "Ỗ", + "ộ": "Ộ", + "ớ": "Ớ", + "ờ": "Ờ", + "ở": "Ở", + "ỡ": "Ỡ", + "ợ": "Ợ", + "ụ": "Ụ", + "ủ": "Ủ", + "ứ": "Ứ", + "ừ": "Ừ", + "ử": "Ử", + "ữ": "Ữ", + "ự": "Ự", + "ỳ": "Ỳ", + "ỵ": "Ỵ", + "ỷ": "Ỷ", + "ỹ": "Ỹ", + "ỻ": "Ỻ", + "ỽ": "Ỽ", + "ỿ": "Ỿ", + "ἀ": "Ἀ", + "ἁ": "Ἁ", + "ἂ": "Ἂ", + "ἃ": "Ἃ", + "ἄ": "Ἄ", + "ἅ": "Ἅ", + "ἆ": "Ἆ", + "ἇ": "Ἇ", + "ἐ": "Ἐ", + "ἑ": "Ἑ", + "ἒ": "Ἒ", + "ἓ": "Ἓ", + "ἔ": "Ἔ", + "ἕ": "Ἕ", + "ἠ": "Ἠ", + "ἡ": "Ἡ", + "ἢ": "Ἢ", + "ἣ": "Ἣ", + "ἤ": "Ἤ", + "ἥ": "Ἥ", + "ἦ": "Ἦ", + "ἧ": "Ἧ", + "ἰ": "Ἰ", + "ἱ": "Ἱ", + "ἲ": "Ἲ", + "ἳ": "Ἳ", + "ἴ": "Ἴ", + "ἵ": "Ἵ", + "ἶ": "Ἶ", + "ἷ": "Ἷ", + "ὀ": "Ὀ", + "ὁ": "Ὁ", + "ὂ": "Ὂ", + "ὃ": "Ὃ", + "ὄ": "Ὄ", + "ὅ": "Ὅ", + "ὑ": "Ὑ", + "ὓ": "Ὓ", + "ὕ": "Ὕ", + "ὗ": "Ὗ", + "ὠ": "Ὠ", + "ὡ": "Ὡ", + "ὢ": "Ὢ", + "ὣ": "Ὣ", + "ὤ": "Ὤ", + "ὥ": "Ὥ", + "ὦ": "Ὦ", + "ὧ": "Ὧ", + "ᾰ": "Ᾰ", + "ᾱ": "Ᾱ", + "ὰ": "Ὰ", + "ά": "Ά", + "ὲ": "Ὲ", + "έ": "Έ", + "ὴ": "Ὴ", + "ή": "Ή", + "ῐ": "Ῐ", + "ῑ": "Ῑ", + "ὶ": "Ὶ", + "ί": "Ί", + "ῠ": "Ῠ", + "ῡ": "Ῡ", + "ὺ": "Ὺ", + "ύ": "Ύ", + "ῥ": "Ῥ", + "ὸ": "Ὸ", + "ό": "Ό", + "ὼ": "Ὼ", + "ώ": "Ώ", + "ⅎ": "Ⅎ", + "ⅰ": "Ⅰ", + "ⅱ": "Ⅱ", + "ⅲ": "Ⅲ", + "ⅳ": "Ⅳ", + "ⅴ": "Ⅴ", + "ⅵ": "Ⅵ", + "ⅶ": "Ⅶ", + "ⅷ": "Ⅷ", + "ⅸ": "Ⅸ", + "ⅹ": "Ⅹ", + "ⅺ": "Ⅺ", + "ⅻ": "Ⅻ", + "ⅼ": "Ⅼ", + "ⅽ": "Ⅽ", + "ⅾ": "Ⅾ", + "ⅿ": "Ⅿ", + "ↄ": "Ↄ", + "ⓐ": "Ⓐ", + "ⓑ": "Ⓑ", + "ⓒ": "Ⓒ", + "ⓓ": "Ⓓ", + "ⓔ": "Ⓔ", + "ⓕ": "Ⓕ", + "ⓖ": "Ⓖ", + "ⓗ": "Ⓗ", + "ⓘ": "Ⓘ", + "ⓙ": "Ⓙ", + "ⓚ": "Ⓚ", + "ⓛ": "Ⓛ", + "ⓜ": "Ⓜ", + "ⓝ": "Ⓝ", + "ⓞ": "Ⓞ", + "ⓟ": "Ⓟ", + "ⓠ": "Ⓠ", + "ⓡ": "Ⓡ", + "ⓢ": "Ⓢ", + "ⓣ": "Ⓣ", + "ⓤ": "Ⓤ", + "ⓥ": "Ⓥ", + "ⓦ": "Ⓦ", + "ⓧ": "Ⓧ", + "ⓨ": "Ⓨ", + "ⓩ": "Ⓩ", + "ⰰ": "Ⰰ", + "ⰱ": "Ⰱ", + "ⰲ": "Ⰲ", + "ⰳ": "Ⰳ", + "ⰴ": "Ⰴ", + "ⰵ": "Ⰵ", + "ⰶ": "Ⰶ", + "ⰷ": "Ⰷ", + "ⰸ": "Ⰸ", + "ⰹ": "Ⰹ", + "ⰺ": "Ⰺ", + "ⰻ": "Ⰻ", + "ⰼ": "Ⰼ", + "ⰽ": "Ⰽ", + "ⰾ": "Ⰾ", + "ⰿ": "Ⰿ", + "ⱀ": "Ⱀ", + "ⱁ": "Ⱁ", + "ⱂ": "Ⱂ", + "ⱃ": "Ⱃ", + "ⱄ": "Ⱄ", + "ⱅ": "Ⱅ", + "ⱆ": "Ⱆ", + "ⱇ": "Ⱇ", + "ⱈ": "Ⱈ", + "ⱉ": "Ⱉ", + "ⱊ": "Ⱊ", + "ⱋ": "Ⱋ", + "ⱌ": "Ⱌ", + "ⱍ": "Ⱍ", + "ⱎ": "Ⱎ", + "ⱏ": "Ⱏ", + "ⱐ": "Ⱐ", + "ⱑ": "Ⱑ", + "ⱒ": "Ⱒ", + "ⱓ": "Ⱓ", + "ⱔ": "Ⱔ", + "ⱕ": "Ⱕ", + "ⱖ": "Ⱖ", + "ⱗ": "Ⱗ", + "ⱘ": "Ⱘ", + "ⱙ": "Ⱙ", + "ⱚ": "Ⱚ", + "ⱛ": "Ⱛ", + "ⱜ": "Ⱜ", + "ⱝ": "Ⱝ", + "ⱞ": "Ⱞ", + "ⱟ": "Ⱟ", + "ⱡ": "Ⱡ", + "ɫ": "Ɫ", + "ᵽ": "Ᵽ", + "ɽ": "Ɽ", + "ⱨ": "Ⱨ", + "ⱪ": "Ⱪ", + "ⱬ": "Ⱬ", + "ɑ": "Ɑ", + "ɱ": "Ɱ", + "ɐ": "Ɐ", + "ɒ": "Ɒ", + "ⱳ": "Ⱳ", + "ⱶ": "Ⱶ", + "ȿ": "Ȿ", + "ɀ": "Ɀ", + "ⲁ": "Ⲁ", + "ⲃ": "Ⲃ", + "ⲅ": "Ⲅ", + "ⲇ": "Ⲇ", + "ⲉ": "Ⲉ", + "ⲋ": "Ⲋ", + "ⲍ": "Ⲍ", + "ⲏ": "Ⲏ", + "ⲑ": "Ⲑ", + "ⲓ": "Ⲓ", + "ⲕ": "Ⲕ", + "ⲗ": "Ⲗ", + "ⲙ": "Ⲙ", + "ⲛ": "Ⲛ", + "ⲝ": "Ⲝ", + "ⲟ": "Ⲟ", + "ⲡ": "Ⲡ", + "ⲣ": "Ⲣ", + "ⲥ": "Ⲥ", + "ⲧ": "Ⲧ", + "ⲩ": "Ⲩ", + "ⲫ": "Ⲫ", + "ⲭ": "Ⲭ", + "ⲯ": "Ⲯ", + "ⲱ": "Ⲱ", + "ⲳ": "Ⲳ", + "ⲵ": "Ⲵ", + "ⲷ": "Ⲷ", + "ⲹ": "Ⲹ", + "ⲻ": "Ⲻ", + "ⲽ": "Ⲽ", + "ⲿ": "Ⲿ", + "ⳁ": "Ⳁ", + "ⳃ": "Ⳃ", + "ⳅ": "Ⳅ", + "ⳇ": "Ⳇ", + "ⳉ": "Ⳉ", + "ⳋ": "Ⳋ", + "ⳍ": "Ⳍ", + "ⳏ": "Ⳏ", + "ⳑ": "Ⳑ", + "ⳓ": "Ⳓ", + "ⳕ": "Ⳕ", + "ⳗ": "Ⳗ", + "ⳙ": "Ⳙ", + "ⳛ": "Ⳛ", + "ⳝ": "Ⳝ", + "ⳟ": "Ⳟ", + "ⳡ": "Ⳡ", + "ⳣ": "Ⳣ", + "ⳬ": "Ⳬ", + "ⳮ": "Ⳮ", + "ⳳ": "Ⳳ", + "ꙁ": "Ꙁ", + "ꙃ": "Ꙃ", + "ꙅ": "Ꙅ", + "ꙇ": "Ꙇ", + "ꙉ": "Ꙉ", + "ꙍ": "Ꙍ", + "ꙏ": "Ꙏ", + "ꙑ": "Ꙑ", + "ꙓ": "Ꙓ", + "ꙕ": "Ꙕ", + "ꙗ": "Ꙗ", + "ꙙ": "Ꙙ", + "ꙛ": "Ꙛ", + "ꙝ": "Ꙝ", + "ꙟ": "Ꙟ", + "ꙡ": "Ꙡ", + "ꙣ": "Ꙣ", + "ꙥ": "Ꙥ", + "ꙧ": "Ꙧ", + "ꙩ": "Ꙩ", + "ꙫ": "Ꙫ", + "ꙭ": "Ꙭ", + "ꚁ": "Ꚁ", + "ꚃ": "Ꚃ", + "ꚅ": "Ꚅ", + "ꚇ": "Ꚇ", + "ꚉ": "Ꚉ", + "ꚋ": "Ꚋ", + "ꚍ": "Ꚍ", + "ꚏ": "Ꚏ", + "ꚑ": "Ꚑ", + "ꚓ": "Ꚓ", + "ꚕ": "Ꚕ", + "ꚗ": "Ꚗ", + "ꚙ": "Ꚙ", + "ꚛ": "Ꚛ", + "ꜣ": "Ꜣ", + "ꜥ": "Ꜥ", + "ꜧ": "Ꜧ", + "ꜩ": "Ꜩ", + "ꜫ": "Ꜫ", + "ꜭ": "Ꜭ", + "ꜯ": "Ꜯ", + "ꜳ": "Ꜳ", + "ꜵ": "Ꜵ", + "ꜷ": "Ꜷ", + "ꜹ": "Ꜹ", + "ꜻ": "Ꜻ", + "ꜽ": "Ꜽ", + "ꜿ": "Ꜿ", + "ꝁ": "Ꝁ", + "ꝃ": "Ꝃ", + "ꝅ": "Ꝅ", + "ꝇ": "Ꝇ", + "ꝉ": "Ꝉ", + "ꝋ": "Ꝋ", + "ꝍ": "Ꝍ", + "ꝏ": "Ꝏ", + "ꝑ": "Ꝑ", + "ꝓ": "Ꝓ", + "ꝕ": "Ꝕ", + "ꝗ": "Ꝗ", + "ꝙ": "Ꝙ", + "ꝛ": "Ꝛ", + "ꝝ": "Ꝝ", + "ꝟ": "Ꝟ", + "ꝡ": "Ꝡ", + "ꝣ": "Ꝣ", + "ꝥ": "Ꝥ", + "ꝧ": "Ꝧ", + "ꝩ": "Ꝩ", + "ꝫ": "Ꝫ", + "ꝭ": "Ꝭ", + "ꝯ": "Ꝯ", + "ꝺ": "Ꝺ", + "ꝼ": "Ꝼ", + "ᵹ": "Ᵹ", + "ꝿ": "Ꝿ", + "ꞁ": "Ꞁ", + "ꞃ": "Ꞃ", + "ꞅ": "Ꞅ", + "ꞇ": "Ꞇ", + "ꞌ": "Ꞌ", + "ɥ": "Ɥ", + "ꞑ": "Ꞑ", + "ꞓ": "Ꞓ", + "ꞗ": "Ꞗ", + "ꞙ": "Ꞙ", + "ꞛ": "Ꞛ", + "ꞝ": "Ꞝ", + "ꞟ": "Ꞟ", + "ꞡ": "Ꞡ", + "ꞣ": "Ꞣ", + "ꞥ": "Ꞥ", + "ꞧ": "Ꞧ", + "ꞩ": "Ꞩ", + "ɦ": "Ɦ", + "ɜ": "Ɜ", + "ɡ": "Ɡ", + "ɬ": "Ɬ", + "ɪ": "Ɪ", + "ʞ": "Ʞ", + "ʇ": "Ʇ", + "ʝ": "Ʝ", + "ꭓ": "Ꭓ", + "ꞵ": "Ꞵ", + "ꞷ": "Ꞷ", + "ꞹ": "Ꞹ", + "ꞻ": "Ꞻ", + "ꞽ": "Ꞽ", + "ꞿ": "Ꞿ", + "ꟁ": "Ꟁ", + "ꟃ": "Ꟃ", + "ꞔ": "Ꞔ", + "ʂ": "Ʂ", + "ᶎ": "Ᶎ", + "ꟈ": "Ꟈ", + "ꟊ": "Ꟊ", + "ꟑ": "Ꟑ", + "ꟗ": "Ꟗ", + "ꟙ": "Ꟙ", + "ꟶ": "Ꟶ", + "Ꭰ": "ꭰ", + "Ꭱ": "ꭱ", + "Ꭲ": "ꭲ", + "Ꭳ": "ꭳ", + "Ꭴ": "ꭴ", + "Ꭵ": "ꭵ", + "Ꭶ": "ꭶ", + "Ꭷ": "ꭷ", + "Ꭸ": "ꭸ", + "Ꭹ": "ꭹ", + "Ꭺ": "ꭺ", + "Ꭻ": "ꭻ", + "Ꭼ": "ꭼ", + "Ꭽ": "ꭽ", + "Ꭾ": "ꭾ", + "Ꭿ": "ꭿ", + "Ꮀ": "ꮀ", + "Ꮁ": "ꮁ", + "Ꮂ": "ꮂ", + "Ꮃ": "ꮃ", + "Ꮄ": "ꮄ", + "Ꮅ": "ꮅ", + "Ꮆ": "ꮆ", + "Ꮇ": "ꮇ", + "Ꮈ": "ꮈ", + "Ꮉ": "ꮉ", + "Ꮊ": "ꮊ", + "Ꮋ": "ꮋ", + "Ꮌ": "ꮌ", + "Ꮍ": "ꮍ", + "Ꮎ": "ꮎ", + "Ꮏ": "ꮏ", + "Ꮐ": "ꮐ", + "Ꮑ": "ꮑ", + "Ꮒ": "ꮒ", + "Ꮓ": "ꮓ", + "Ꮔ": "ꮔ", + "Ꮕ": "ꮕ", + "Ꮖ": "ꮖ", + "Ꮗ": "ꮗ", + "Ꮘ": "ꮘ", + "Ꮙ": "ꮙ", + "Ꮚ": "ꮚ", + "Ꮛ": "ꮛ", + "Ꮜ": "ꮜ", + "Ꮝ": "ꮝ", + "Ꮞ": "ꮞ", + "Ꮟ": "ꮟ", + "Ꮠ": "ꮠ", + "Ꮡ": "ꮡ", + "Ꮢ": "ꮢ", + "Ꮣ": "ꮣ", + "Ꮤ": "ꮤ", + "Ꮥ": "ꮥ", + "Ꮦ": "ꮦ", + "Ꮧ": "ꮧ", + "Ꮨ": "ꮨ", + "Ꮩ": "ꮩ", + "Ꮪ": "ꮪ", + "Ꮫ": "ꮫ", + "Ꮬ": "ꮬ", + "Ꮭ": "ꮭ", + "Ꮮ": "ꮮ", + "Ꮯ": "ꮯ", + "Ꮰ": "ꮰ", + "Ꮱ": "ꮱ", + "Ꮲ": "ꮲ", + "Ꮳ": "ꮳ", + "Ꮴ": "ꮴ", + "Ꮵ": "ꮵ", + "Ꮶ": "ꮶ", + "Ꮷ": "ꮷ", + "Ꮸ": "ꮸ", + "Ꮹ": "ꮹ", + "Ꮺ": "ꮺ", + "Ꮻ": "ꮻ", + "Ꮼ": "ꮼ", + "Ꮽ": "ꮽ", + "Ꮾ": "ꮾ", + "Ꮿ": "ꮿ", + "a": "A", + "b": "B", + "c": "C", + "d": "D", + "e": "E", + "f": "F", + "g": "G", + "h": "H", + "i": "I", + "j": "J", + "k": "K", + "l": "L", + "m": "M", + "n": "N", + "o": "O", + "p": "P", + "q": "Q", + "r": "R", + "s": "S", + "t": "T", + "u": "U", + "v": "V", + "w": "W", + "x": "X", + "y": "Y", + "z": "Z", + "𐐨": "𐐀", + "𐐩": "𐐁", + "𐐪": "𐐂", + "𐐫": "𐐃", + "𐐬": "𐐄", + "𐐭": "𐐅", + "𐐮": "𐐆", + "𐐯": "𐐇", + "𐐰": "𐐈", + "𐐱": "𐐉", + "𐐲": "𐐊", + "𐐳": "𐐋", + "𐐴": "𐐌", + "𐐵": "𐐍", + "𐐶": "𐐎", + "𐐷": "𐐏", + "𐐸": "𐐐", + "𐐹": "𐐑", + "𐐺": "𐐒", + "𐐻": "𐐓", + "𐐼": "𐐔", + "𐐽": "𐐕", + "𐐾": "𐐖", + "𐐿": "𐐗", + "𐑀": "𐐘", + "𐑁": "𐐙", + "𐑂": "𐐚", + "𐑃": "𐐛", + "𐑄": "𐐜", + "𐑅": "𐐝", + "𐑆": "𐐞", + "𐑇": "𐐟", + "𐑈": "𐐠", + "𐑉": "𐐡", + "𐑊": "𐐢", + "𐑋": "𐐣", + "𐑌": "𐐤", + "𐑍": "𐐥", + "𐑎": "𐐦", + "𐑏": "𐐧", + "𐓘": "𐒰", + "𐓙": "𐒱", + "𐓚": "𐒲", + "𐓛": "𐒳", + "𐓜": "𐒴", + "𐓝": "𐒵", + "𐓞": "𐒶", + "𐓟": "𐒷", + "𐓠": "𐒸", + "𐓡": "𐒹", + "𐓢": "𐒺", + "𐓣": "𐒻", + "𐓤": "𐒼", + "𐓥": "𐒽", + "𐓦": "𐒾", + "𐓧": "𐒿", + "𐓨": "𐓀", + "𐓩": "𐓁", + "𐓪": "𐓂", + "𐓫": "𐓃", + "𐓬": "𐓄", + "𐓭": "𐓅", + "𐓮": "𐓆", + "𐓯": "𐓇", + "𐓰": "𐓈", + "𐓱": "𐓉", + "𐓲": "𐓊", + "𐓳": "𐓋", + "𐓴": "𐓌", + "𐓵": "𐓍", + "𐓶": "𐓎", + "𐓷": "𐓏", + "𐓸": "𐓐", + "𐓹": "𐓑", + "𐓺": "𐓒", + "𐓻": "𐓓", + "𐖗": "𐕰", + "𐖘": "𐕱", + "𐖙": "𐕲", + "𐖚": "𐕳", + "𐖛": "𐕴", + "𐖜": "𐕵", + "𐖝": "𐕶", + "𐖞": "𐕷", + "𐖟": "𐕸", + "𐖠": "𐕹", + "𐖡": "𐕺", + "𐖣": "𐕼", + "𐖤": "𐕽", + "𐖥": "𐕾", + "𐖦": "𐕿", + "𐖧": "𐖀", + "𐖨": "𐖁", + "𐖩": "𐖂", + "𐖪": "𐖃", + "𐖫": "𐖄", + "𐖬": "𐖅", + "𐖭": "𐖆", + "𐖮": "𐖇", + "𐖯": "𐖈", + "𐖰": "𐖉", + "𐖱": "𐖊", + "𐖳": "𐖌", + "𐖴": "𐖍", + "𐖵": "𐖎", + "𐖶": "𐖏", + "𐖷": "𐖐", + "𐖸": "𐖑", + "𐖹": "𐖒", + "𐖻": "𐖔", + "𐖼": "𐖕", + "𐳀": "𐲀", + "𐳁": "𐲁", + "𐳂": "𐲂", + "𐳃": "𐲃", + "𐳄": "𐲄", + "𐳅": "𐲅", + "𐳆": "𐲆", + "𐳇": "𐲇", + "𐳈": "𐲈", + "𐳉": "𐲉", + "𐳊": "𐲊", + "𐳋": "𐲋", + "𐳌": "𐲌", + "𐳍": "𐲍", + "𐳎": "𐲎", + "𐳏": "𐲏", + "𐳐": "𐲐", + "𐳑": "𐲑", + "𐳒": "𐲒", + "𐳓": "𐲓", + "𐳔": "𐲔", + "𐳕": "𐲕", + "𐳖": "𐲖", + "𐳗": "𐲗", + "𐳘": "𐲘", + "𐳙": "𐲙", + "𐳚": "𐲚", + "𐳛": "𐲛", + "𐳜": "𐲜", + "𐳝": "𐲝", + "𐳞": "𐲞", + "𐳟": "𐲟", + "𐳠": "𐲠", + "𐳡": "𐲡", + "𐳢": "𐲢", + "𐳣": "𐲣", + "𐳤": "𐲤", + "𐳥": "𐲥", + "𐳦": "𐲦", + "𐳧": "𐲧", + "𐳨": "𐲨", + "𐳩": "𐲩", + "𐳪": "𐲪", + "𐳫": "𐲫", + "𐳬": "𐲬", + "𐳭": "𐲭", + "𐳮": "𐲮", + "𐳯": "𐲯", + "𐳰": "𐲰", + "𐳱": "𐲱", + "𐳲": "𐲲", + "𑣀": "𑢠", + "𑣁": "𑢡", + "𑣂": "𑢢", + "𑣃": "𑢣", + "𑣄": "𑢤", + "𑣅": "𑢥", + "𑣆": "𑢦", + "𑣇": "𑢧", + "𑣈": "𑢨", + "𑣉": "𑢩", + "𑣊": "𑢪", + "𑣋": "𑢫", + "𑣌": "𑢬", + "𑣍": "𑢭", + "𑣎": "𑢮", + "𑣏": "𑢯", + "𑣐": "𑢰", + "𑣑": "𑢱", + "𑣒": "𑢲", + "𑣓": "𑢳", + "𑣔": "𑢴", + "𑣕": "𑢵", + "𑣖": "𑢶", + "𑣗": "𑢷", + "𑣘": "𑢸", + "𑣙": "𑢹", + "𑣚": "𑢺", + "𑣛": "𑢻", + "𑣜": "𑢼", + "𑣝": "𑢽", + "𑣞": "𑢾", + "𑣟": "𑢿", + "𖹠": "𖹀", + "𖹡": "𖹁", + "𖹢": "𖹂", + "𖹣": "𖹃", + "𖹤": "𖹄", + "𖹥": "𖹅", + "𖹦": "𖹆", + "𖹧": "𖹇", + "𖹨": "𖹈", + "𖹩": "𖹉", + "𖹪": "𖹊", + "𖹫": "𖹋", + "𖹬": "𖹌", + "𖹭": "𖹍", + "𖹮": "𖹎", + "𖹯": "𖹏", + "𖹰": "𖹐", + "𖹱": "𖹑", + "𖹲": "𖹒", + "𖹳": "𖹓", + "𖹴": "𖹔", + "𖹵": "𖹕", + "𖹶": "𖹖", + "𖹷": "𖹗", + "𖹸": "𖹘", + "𖹹": "𖹙", + "𖹺": "𖹚", + "𖹻": "𖹛", + "𖹼": "𖹜", + "𖹽": "𖹝", + "𖹾": "𖹞", + "𖹿": "𖹟", + "𞤢": "𞤀", + "𞤣": "𞤁", + "𞤤": "𞤂", + "𞤥": "𞤃", + "𞤦": "𞤄", + "𞤧": "𞤅", + "𞤨": "𞤆", + "𞤩": "𞤇", + "𞤪": "𞤈", + "𞤫": "𞤉", + "𞤬": "𞤊", + "𞤭": "𞤋", + "𞤮": "𞤌", + "𞤯": "𞤍", + "𞤰": "𞤎", + "𞤱": "𞤏", + "𞤲": "𞤐", + "𞤳": "𞤑", + "𞤴": "𞤒", + "𞤵": "𞤓", + "𞤶": "𞤔", + "𞤷": "𞤕", + "𞤸": "𞤖", + "𞤹": "𞤗", + "𞤺": "𞤘", + "𞤻": "𞤙", + "𞤼": "𞤚", + "𞤽": "𞤛", + "𞤾": "𞤜", + "𞤿": "𞤝", + "𞥀": "𞤞", + "𞥁": "𞤟", + "𞥂": "𞤠", + "𞥃": "𞤡" + }, + "S": { + "ß": "ẞ", + "ᾀ": "ᾈ", + "ᾁ": "ᾉ", + "ᾂ": "ᾊ", + "ᾃ": "ᾋ", + "ᾄ": "ᾌ", + "ᾅ": "ᾍ", + "ᾆ": "ᾎ", + "ᾇ": "ᾏ", + "ᾐ": "ᾘ", + "ᾑ": "ᾙ", + "ᾒ": "ᾚ", + "ᾓ": "ᾛ", + "ᾔ": "ᾜ", + "ᾕ": "ᾝ", + "ᾖ": "ᾞ", + "ᾗ": "ᾟ", + "ᾠ": "ᾨ", + "ᾡ": "ᾩ", + "ᾢ": "ᾪ", + "ᾣ": "ᾫ", + "ᾤ": "ᾬ", + "ᾥ": "ᾭ", + "ᾦ": "ᾮ", + "ᾧ": "ᾯ", + "ᾳ": "ᾼ", + "ῃ": "ῌ", + "ῳ": "ῼ" + } +} \ No newline at end of file diff --git a/node_modules/es-abstract/helpers/defaultEndianness.js b/node_modules/es-abstract/helpers/defaultEndianness.js new file mode 100644 index 0000000000000000000000000000000000000000..faba47022e31f6554a131f4f0a8a8ddd9eb9d3ca --- /dev/null +++ b/node_modules/es-abstract/helpers/defaultEndianness.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); +var $Uint32Array = GetIntrinsic('%Uint32Array%', true); + +var typedArrayBuffer = require('typed-array-buffer'); + +var uInt32 = $Uint32Array && new $Uint32Array([0x12345678]); +var uInt8 = uInt32 && new $Uint8Array(typedArrayBuffer(uInt32)); + +module.exports = uInt8 + ? uInt8[0] === 0x78 + ? 'little' + : uInt8[0] === 0x12 + ? 'big' + : uInt8[0] === 0x34 + ? 'mixed' // https://developer.mozilla.org/en-US/docs/Glossary/Endianness + : 'unknown' // ??? + : 'indeterminate'; // no way to know diff --git a/node_modules/es-abstract/helpers/every.js b/node_modules/es-abstract/helpers/every.js new file mode 100644 index 0000000000000000000000000000000000000000..42a458211ede1dc31b1b1b15e7d64160ff9d91ff --- /dev/null +++ b/node_modules/es-abstract/helpers/every.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function every(array, predicate) { + for (var i = 0; i < array.length; i += 1) { + if (!predicate(array[i], i, array)) { + return false; + } + } + return true; +}; diff --git a/node_modules/es-abstract/helpers/forEach.js b/node_modules/es-abstract/helpers/forEach.js new file mode 100644 index 0000000000000000000000000000000000000000..35915a656a07edc2affdc8f872293923426a0ecb --- /dev/null +++ b/node_modules/es-abstract/helpers/forEach.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function forEach(array, callback) { + for (var i = 0; i < array.length; i += 1) { + callback(array[i], i, array); // eslint-disable-line callback-return + } +}; diff --git a/node_modules/es-abstract/helpers/fractionToBinaryString.js b/node_modules/es-abstract/helpers/fractionToBinaryString.js new file mode 100644 index 0000000000000000000000000000000000000000..1ba671da6603fe33b29dadcd120aaff2f4126ae4 --- /dev/null +++ b/node_modules/es-abstract/helpers/fractionToBinaryString.js @@ -0,0 +1,33 @@ +'use strict'; + +var MAX_ITER = 1075; // 1023+52 (subnormals) => BIAS+NUM_SIGNFICAND_BITS-1 +var maxBits = 54; // only 53 bits for fraction + +module.exports = function fractionToBitString(x) { + var str = ''; + if (x === 0) { + return str; + } + var j = MAX_ITER; + + var y; + // Each time we multiply by 2 and find a ones digit, add a '1'; otherwise, add a '0'.. + for (var i = 0; i < MAX_ITER; i += 1) { + y = x * 2; + if (y >= 1) { + x = y - 1; // eslint-disable-line no-param-reassign + str += '1'; + if (j === MAX_ITER) { + j = i; // first 1 + } + } else { + x = y; // eslint-disable-line no-param-reassign + str += '0'; + } + // Stop when we have no more decimals to process or in the event we found a fraction which cannot be represented in a finite number of bits... + if (y === 1 || i - j > maxBits) { + return str; + } + } + return str; +}; diff --git a/node_modules/es-abstract/helpers/fromPropertyDescriptor.js b/node_modules/es-abstract/helpers/fromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..878861271cbed008b3951c7393df91fd43fe1b9b --- /dev/null +++ b/node_modules/es-abstract/helpers/fromPropertyDescriptor.js @@ -0,0 +1,27 @@ +'use strict'; + +module.exports = function fromPropertyDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return Desc; + } + var obj = {}; + if ('[[Value]]' in Desc) { + obj.value = Desc['[[Value]]']; + } + if ('[[Writable]]' in Desc) { + obj.writable = !!Desc['[[Writable]]']; + } + if ('[[Get]]' in Desc) { + obj.get = Desc['[[Get]]']; + } + if ('[[Set]]' in Desc) { + obj.set = Desc['[[Set]]']; + } + if ('[[Enumerable]]' in Desc) { + obj.enumerable = !!Desc['[[Enumerable]]']; + } + if ('[[Configurable]]' in Desc) { + obj.configurable = !!Desc['[[Configurable]]']; + } + return obj; +}; diff --git a/node_modules/es-abstract/helpers/getInferredName.js b/node_modules/es-abstract/helpers/getInferredName.js new file mode 100644 index 0000000000000000000000000000000000000000..5fd24ffa8c614a7aad12a02bdacc96edb2409acb --- /dev/null +++ b/node_modules/es-abstract/helpers/getInferredName.js @@ -0,0 +1,4 @@ +'use strict'; + +// TODO: remove, semver-major +module.exports = require('get-symbol-description/getInferredName'); diff --git a/node_modules/es-abstract/helpers/getIteratorMethod.js b/node_modules/es-abstract/helpers/getIteratorMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..d052645b5a74a8003d0ff7ff3e5ee525c4bc730b --- /dev/null +++ b/node_modules/es-abstract/helpers/getIteratorMethod.js @@ -0,0 +1,47 @@ +'use strict'; + +var hasSymbols = require('has-symbols')(); +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bind/callBound'); +var isString = require('is-string'); + +var $iterator = GetIntrinsic('%Symbol.iterator%', true); +var $stringSlice = callBound('String.prototype.slice'); +var $String = GetIntrinsic('%String%'); + +module.exports = function getIteratorMethod(ES, iterable) { + var usingIterator; + if (hasSymbols) { + usingIterator = ES.GetMethod(iterable, $iterator); + } else if (ES.IsArray(iterable)) { + usingIterator = function () { + var i = -1; + var arr = this; // eslint-disable-line no-invalid-this + return { + next: function () { + i += 1; + return { + done: i >= arr.length, + value: arr[i] + }; + } + }; + }; + } else if (isString(iterable)) { + usingIterator = function () { + var i = 0; + return { + next: function () { + var nextIndex = ES.AdvanceStringIndex($String(iterable), i, true); + var value = $stringSlice(iterable, i, nextIndex); + i = nextIndex; + return { + done: nextIndex > iterable.length, + value: value + }; + } + }; + }; + } + return usingIterator; +}; diff --git a/node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js b/node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..e0f823d108f26a95243430f05c9d6bbde1ec1913 --- /dev/null +++ b/node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js @@ -0,0 +1,5 @@ +'use strict'; + +// TODO: remove, semver-major + +module.exports = require('gopd'); diff --git a/node_modules/es-abstract/helpers/getProto.js b/node_modules/es-abstract/helpers/getProto.js new file mode 100644 index 0000000000000000000000000000000000000000..d63903ad46a8de400feea47eacbc500367850277 --- /dev/null +++ b/node_modules/es-abstract/helpers/getProto.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var originalGetProto = GetIntrinsic('%Object.getPrototypeOf%', true); + +var hasProto = require('has-proto')(); + +module.exports = originalGetProto || ( + hasProto + ? function (O) { + return O.__proto__; // eslint-disable-line no-proto + } + : null +); diff --git a/node_modules/es-abstract/helpers/getSymbolDescription.js b/node_modules/es-abstract/helpers/getSymbolDescription.js new file mode 100644 index 0000000000000000000000000000000000000000..699705f4f9bec1877871db1199c2fee3a85a0087 --- /dev/null +++ b/node_modules/es-abstract/helpers/getSymbolDescription.js @@ -0,0 +1,4 @@ +'use strict'; + +// TODO: remove, semver-major +module.exports = require('get-symbol-description'); diff --git a/node_modules/es-abstract/helpers/intToBinaryString.js b/node_modules/es-abstract/helpers/intToBinaryString.js new file mode 100644 index 0000000000000000000000000000000000000000..beeb2e77dbfa332f51aa0209b505ab57a8e1bcc6 --- /dev/null +++ b/node_modules/es-abstract/helpers/intToBinaryString.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $floor = GetIntrinsic('%Math.floor%'); + +// https://runestone.academy/ns/books/published/pythonds/BasicDS/ConvertingDecimalNumberstoBinaryNumbers.html#:~:text=The%20Divide%20by%202%20algorithm,have%20a%20remainder%20of%200 + +module.exports = function intToBinaryString(x) { + var str = ''; + var y; + + while (x > 0) { + y = x / 2; + x = $floor(y); // eslint-disable-line no-param-reassign + if (y === x) { + str = '0' + str; + } else { + str = '1' + str; + } + } + return str; +}; diff --git a/node_modules/es-abstract/helpers/integerToNBytes.js b/node_modules/es-abstract/helpers/integerToNBytes.js new file mode 100644 index 0000000000000000000000000000000000000000..dd3f98c051891d3b5858a577501f50922a0cb88d --- /dev/null +++ b/node_modules/es-abstract/helpers/integerToNBytes.js @@ -0,0 +1,28 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); +var $BigInt = GetIntrinsic('%BigInt%', true); + +module.exports = function integerToNBytes(intValue, n, isLittleEndian) { + var Z = typeof intValue === 'bigint' ? $BigInt : $Number; + /* + if (intValue >= 0) { // step 3.d + // Let rawBytes be a List containing the n-byte binary encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. + } else { // step 3.e + // Let rawBytes be a List containing the n-byte binary 2's complement encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. + } + */ + if (intValue < 0) { + intValue >>>= 0; // eslint-disable-line no-param-reassign + } + + var rawBytes = []; + for (var i = 0; i < n; i++) { + rawBytes[isLittleEndian ? i : n - 1 - i] = $Number(intValue & Z(0xFF)); + intValue >>= Z(8); // eslint-disable-line no-param-reassign + } + + return rawBytes; // step 4 +}; diff --git a/node_modules/es-abstract/helpers/isAbstractClosure.js b/node_modules/es-abstract/helpers/isAbstractClosure.js new file mode 100644 index 0000000000000000000000000000000000000000..503200dc5d5dfcf0aa38a86671546b51f4385385 --- /dev/null +++ b/node_modules/es-abstract/helpers/isAbstractClosure.js @@ -0,0 +1,9 @@ +'use strict'; + +var functionName = require('function.prototype.name'); + +var anon = functionName(function () {}); + +module.exports = function isAbstractClosure(x) { + return typeof x === 'function' && (!x.prototype || functionName(x) === anon); +}; diff --git a/node_modules/es-abstract/helpers/isByteValue.js b/node_modules/es-abstract/helpers/isByteValue.js new file mode 100644 index 0000000000000000000000000000000000000000..1a7d0d35306475e5a73167751454db5b9df2a3df --- /dev/null +++ b/node_modules/es-abstract/helpers/isByteValue.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isByteValue(value) { + return typeof value === 'number' && value >= 0 && value <= 255 && (value | 0) === value; +}; diff --git a/node_modules/es-abstract/helpers/isCodePoint.js b/node_modules/es-abstract/helpers/isCodePoint.js new file mode 100644 index 0000000000000000000000000000000000000000..acda02e9937893780f1ad28902b0352cf1d17d50 --- /dev/null +++ b/node_modules/es-abstract/helpers/isCodePoint.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isCodePoint(cp) { + return typeof cp === 'number' && cp >= 0 && cp <= 0x10FFFF && (cp | 0) === cp; +}; diff --git a/node_modules/es-abstract/helpers/isFinite.js b/node_modules/es-abstract/helpers/isFinite.js new file mode 100644 index 0000000000000000000000000000000000000000..3bcd663b247937b0c17c685f58bb989e5789fe77 --- /dev/null +++ b/node_modules/es-abstract/helpers/isFinite.js @@ -0,0 +1,5 @@ +'use strict'; + +var $isNaN = require('./isNaN'); + +module.exports = function (x) { return (typeof x === 'number' || typeof x === 'bigint') && !$isNaN(x) && x !== Infinity && x !== -Infinity; }; diff --git a/node_modules/es-abstract/helpers/isFullyPopulatedPropertyDescriptor.js b/node_modules/es-abstract/helpers/isFullyPopulatedPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..88d2ff9e6229f4f4c87c04503bff76752e580504 --- /dev/null +++ b/node_modules/es-abstract/helpers/isFullyPopulatedPropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function isFullyPopulatedPropertyDescriptor(ES, Desc) { + return !!Desc + && typeof Desc === 'object' + && '[[Enumerable]]' in Desc + && '[[Configurable]]' in Desc + && (ES.IsAccessorDescriptor(Desc) || ES.IsDataDescriptor(Desc)); +}; diff --git a/node_modules/es-abstract/helpers/isInteger.js b/node_modules/es-abstract/helpers/isInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..8ff972c7aef8e5d16b5832b8605c5994c47a8d69 --- /dev/null +++ b/node_modules/es-abstract/helpers/isInteger.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); +var $floor = GetIntrinsic('%Math.floor%'); + +var $isNaN = require('./isNaN'); +var $isFinite = require('./isFinite'); + +module.exports = function isInteger(argument) { + if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) { + return false; + } + var absValue = $abs(argument); + return $floor(absValue) === absValue; +}; + diff --git a/node_modules/es-abstract/helpers/isLeadingSurrogate.js b/node_modules/es-abstract/helpers/isLeadingSurrogate.js new file mode 100644 index 0000000000000000000000000000000000000000..fec61b2a573c1defd7a0a449e0aa7dcba7fe70d8 --- /dev/null +++ b/node_modules/es-abstract/helpers/isLeadingSurrogate.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isLeadingSurrogate(charCode) { + return typeof charCode === 'number' && charCode >= 0xD800 && charCode <= 0xDBFF; +}; diff --git a/node_modules/es-abstract/helpers/isLineTerminator.js b/node_modules/es-abstract/helpers/isLineTerminator.js new file mode 100644 index 0000000000000000000000000000000000000000..baa683901616d1a0554617d1a3f59f5bdc6cf626 --- /dev/null +++ b/node_modules/es-abstract/helpers/isLineTerminator.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/5.1/#sec-7.3 + +module.exports = function isLineTerminator(c) { + return c === '\n' || c === '\r' || c === '\u2028' || c === '\u2029'; +}; diff --git a/node_modules/es-abstract/helpers/isMatchRecord.js b/node_modules/es-abstract/helpers/isMatchRecord.js new file mode 100644 index 0000000000000000000000000000000000000000..fbffebb05d0efda217c0f3eae9855a0beb1c9aba --- /dev/null +++ b/node_modules/es-abstract/helpers/isMatchRecord.js @@ -0,0 +1,16 @@ +'use strict'; + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/13.0/#sec-match-records + +module.exports = function isMatchRecord(record) { + return ( + hasOwn(record, '[[StartIndex]]') + && hasOwn(record, '[[EndIndex]]') + && record['[[StartIndex]]'] >= 0 + && record['[[EndIndex]]'] >= record['[[StartIndex]]'] + && String(parseInt(record['[[StartIndex]]'], 10)) === String(record['[[StartIndex]]']) + && String(parseInt(record['[[EndIndex]]'], 10)) === String(record['[[EndIndex]]']) + ); +}; diff --git a/node_modules/es-abstract/helpers/isNaN.js b/node_modules/es-abstract/helpers/isNaN.js new file mode 100644 index 0000000000000000000000000000000000000000..cb8631dca6c00e507c1146b8400c09c5369835c0 --- /dev/null +++ b/node_modules/es-abstract/helpers/isNaN.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = Number.isNaN || function isNaN(a) { + return a !== a; +}; diff --git a/node_modules/es-abstract/helpers/isNegativeZero.js b/node_modules/es-abstract/helpers/isNegativeZero.js new file mode 100644 index 0000000000000000000000000000000000000000..045b36adf29913fcdf76d01dce2e411a6679bec8 --- /dev/null +++ b/node_modules/es-abstract/helpers/isNegativeZero.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isNegativeZero(x) { + return x === 0 && 1 / x === 1 / -0; +}; diff --git a/node_modules/es-abstract/helpers/isPrefixOf.js b/node_modules/es-abstract/helpers/isPrefixOf.js new file mode 100644 index 0000000000000000000000000000000000000000..0f644d746f7405817c6de247469c2faed159bbf1 --- /dev/null +++ b/node_modules/es-abstract/helpers/isPrefixOf.js @@ -0,0 +1,13 @@ +'use strict'; + +var $strSlice = require('call-bind/callBound')('String.prototype.slice'); + +module.exports = function isPrefixOf(prefix, string) { + if (prefix === string) { + return true; + } + if (prefix.length > string.length) { + return false; + } + return $strSlice(string, 0, prefix.length) === prefix; +}; diff --git a/node_modules/es-abstract/helpers/isPrimitive.js b/node_modules/es-abstract/helpers/isPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..06f0bf042525a13635fcd0980e07d4737a09c0c8 --- /dev/null +++ b/node_modules/es-abstract/helpers/isPrimitive.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isPrimitive(value) { + return value === null || (typeof value !== 'function' && typeof value !== 'object'); +}; diff --git a/node_modules/es-abstract/helpers/isPropertyDescriptor.js b/node_modules/es-abstract/helpers/isPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..d223983ce4e6dadfc79de2ec5251b76cb7667384 --- /dev/null +++ b/node_modules/es-abstract/helpers/isPropertyDescriptor.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasOwn = require('hasown'); +var $TypeError = GetIntrinsic('%TypeError%'); + +module.exports = function IsPropertyDescriptor(ES, Desc) { + if (ES.Type(Desc) !== 'Object') { + return false; + } + var allowed = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Get]]': true, + '[[Set]]': true, + '[[Value]]': true, + '[[Writable]]': true + }; + + for (var key in Desc) { // eslint-disable-line no-restricted-syntax + if (hasOwn(Desc, key) && !allowed[key]) { + return false; + } + } + + if (ES.IsDataDescriptor(Desc) && ES.IsAccessorDescriptor(Desc)) { + throw new $TypeError('Property Descriptors may not be both accessor and data descriptors'); + } + return true; +}; diff --git a/node_modules/es-abstract/helpers/isSamePropertyDescriptor.js b/node_modules/es-abstract/helpers/isSamePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..a6162a1d3c79d32c73bf30ce9d78a7121c214055 --- /dev/null +++ b/node_modules/es-abstract/helpers/isSamePropertyDescriptor.js @@ -0,0 +1,20 @@ +'use strict'; + +var every = require('./every'); + +module.exports = function isSamePropertyDescriptor(ES, D1, D2) { + var fields = [ + '[[Configurable]]', + '[[Enumerable]]', + '[[Get]]', + '[[Set]]', + '[[Value]]', + '[[Writable]]' + ]; + return every(fields, function (field) { + if ((field in D1) !== (field in D2)) { + return false; + } + return ES.SameValue(D1[field], D2[field]); + }); +}; diff --git a/node_modules/es-abstract/helpers/isStringOrHole.js b/node_modules/es-abstract/helpers/isStringOrHole.js new file mode 100644 index 0000000000000000000000000000000000000000..dea9aafef2f9351196c959dffb2adb1fdaf7a5bf --- /dev/null +++ b/node_modules/es-abstract/helpers/isStringOrHole.js @@ -0,0 +1,9 @@ +'use strict'; + +// TODO: semver-major: remove + +var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false + +module.exports = function isStringOrHole(item, index, arr) { + return typeof item === 'string' || (canDistinguishSparseFromUndefined ? !(index in arr) : typeof item === 'undefined'); +}; diff --git a/node_modules/es-abstract/helpers/isStringOrUndefined.js b/node_modules/es-abstract/helpers/isStringOrUndefined.js new file mode 100644 index 0000000000000000000000000000000000000000..7fc485779c3adcf76446b4ca7ab06cb0813079b1 --- /dev/null +++ b/node_modules/es-abstract/helpers/isStringOrUndefined.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isStringOrUndefined(item) { + return typeof item === 'string' || typeof item === 'undefined'; +}; diff --git a/node_modules/es-abstract/helpers/isTrailingSurrogate.js b/node_modules/es-abstract/helpers/isTrailingSurrogate.js new file mode 100644 index 0000000000000000000000000000000000000000..002930accf80e17560d182ff69a0dd313c2b3f9e --- /dev/null +++ b/node_modules/es-abstract/helpers/isTrailingSurrogate.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isTrailingSurrogate(charCode) { + return typeof charCode === 'number' && charCode >= 0xDC00 && charCode <= 0xDFFF; +}; diff --git a/node_modules/es-abstract/helpers/maxSafeInteger.js b/node_modules/es-abstract/helpers/maxSafeInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..6eef5f23acf79ce944802bff0c035a799457706b --- /dev/null +++ b/node_modules/es-abstract/helpers/maxSafeInteger.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = Number.MAX_SAFE_INTEGER || 9007199254740991; // Math.pow(2, 53) - 1; diff --git a/node_modules/es-abstract/helpers/maxValue.js b/node_modules/es-abstract/helpers/maxValue.js new file mode 100644 index 0000000000000000000000000000000000000000..71f490309a1b2bdae9424f7137b00fc2c0ffbb36 --- /dev/null +++ b/node_modules/es-abstract/helpers/maxValue.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = Number.MAX_VALUE || 1.7976931348623157e+308; diff --git a/node_modules/es-abstract/helpers/mod.js b/node_modules/es-abstract/helpers/mod.js new file mode 100644 index 0000000000000000000000000000000000000000..67c8b78a26f61bb5ad583a4df553b4fd3aa22441 --- /dev/null +++ b/node_modules/es-abstract/helpers/mod.js @@ -0,0 +1,8 @@ +'use strict'; + +var $floor = Math.floor; + +module.exports = function mod(number, modulo) { + var remain = number % modulo; + return $floor(remain >= 0 ? remain : remain + modulo); +}; diff --git a/node_modules/es-abstract/helpers/modBigInt.js b/node_modules/es-abstract/helpers/modBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..22be2a1a70d8dccabaa77dfe098bf4090f88dc13 --- /dev/null +++ b/node_modules/es-abstract/helpers/modBigInt.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function bigIntMod(BigIntRemainder, bigint, modulo) { + var remain = BigIntRemainder(bigint, modulo); + return remain >= 0 ? remain : remain + modulo; +}; diff --git a/node_modules/es-abstract/helpers/padTimeComponent.js b/node_modules/es-abstract/helpers/padTimeComponent.js new file mode 100644 index 0000000000000000000000000000000000000000..0d8afc059ce07c7a7db999b471d2ec9606c1829b --- /dev/null +++ b/node_modules/es-abstract/helpers/padTimeComponent.js @@ -0,0 +1,9 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var $strSlice = callBound('String.prototype.slice'); + +module.exports = function padTimeComponent(c, count) { + return $strSlice('00' + c, -(count || 2)); +}; diff --git a/node_modules/es-abstract/helpers/reduce.js b/node_modules/es-abstract/helpers/reduce.js new file mode 100644 index 0000000000000000000000000000000000000000..fb9a56f6da123ce9e9af63fc482130dd30283065 --- /dev/null +++ b/node_modules/es-abstract/helpers/reduce.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function reduce(arr, fn, init) { + var acc = init; + for (var i = 0; i < arr.length; i += 1) { + acc = fn(acc, arr[i], i); + } + return acc; +}; diff --git a/node_modules/es-abstract/helpers/regexTester.js b/node_modules/es-abstract/helpers/regexTester.js new file mode 100644 index 0000000000000000000000000000000000000000..41e48bec34c660129f9fbdd749a1d54140845282 --- /dev/null +++ b/node_modules/es-abstract/helpers/regexTester.js @@ -0,0 +1,5 @@ +'use strict'; + +// TODO: remove, semver-major + +module.exports = require('safe-regex-test'); diff --git a/node_modules/es-abstract/helpers/setProto.js b/node_modules/es-abstract/helpers/setProto.js new file mode 100644 index 0000000000000000000000000000000000000000..57092680b604f15ec3a5ce2a0683d75b5bc2ae20 --- /dev/null +++ b/node_modules/es-abstract/helpers/setProto.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var originalSetProto = GetIntrinsic('%Object.setPrototypeOf%', true); + +var hasProto = require('has-proto')(); + +module.exports = originalSetProto || ( + + hasProto + ? function (O, proto) { + O.__proto__ = proto; // eslint-disable-line no-proto, no-param-reassign + return O; + } + : null +); diff --git a/node_modules/es-abstract/helpers/sign.js b/node_modules/es-abstract/helpers/sign.js new file mode 100644 index 0000000000000000000000000000000000000000..598ea7d8b47f46b4ef32edee08ec76f26481b369 --- /dev/null +++ b/node_modules/es-abstract/helpers/sign.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function sign(number) { + return number >= 0 ? 1 : -1; +}; diff --git a/node_modules/es-abstract/helpers/some.js b/node_modules/es-abstract/helpers/some.js new file mode 100644 index 0000000000000000000000000000000000000000..c0b440507745bfb29cec27074f4421fba6a992a3 --- /dev/null +++ b/node_modules/es-abstract/helpers/some.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function some(array, predicate) { + for (var i = 0; i < array.length; i += 1) { + if (predicate(array[i], i, array)) { + return true; + } + } + return false; +}; diff --git a/node_modules/es-abstract/helpers/timeConstants.js b/node_modules/es-abstract/helpers/timeConstants.js new file mode 100644 index 0000000000000000000000000000000000000000..c275b40e70f12b247c58ad2ed44a715904199265 --- /dev/null +++ b/node_modules/es-abstract/helpers/timeConstants.js @@ -0,0 +1,19 @@ +'use strict'; + +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1e3; +var msPerMinute = msPerSecond * SecondsPerMinute; +var msPerHour = msPerMinute * MinutesPerHour; +var msPerDay = 86400000; + +module.exports = { + HoursPerDay: HoursPerDay, + MinutesPerHour: MinutesPerHour, + SecondsPerMinute: SecondsPerMinute, + msPerSecond: msPerSecond, + msPerMinute: msPerMinute, + msPerHour: msPerHour, + msPerDay: msPerDay +}; diff --git a/node_modules/es-abstract/helpers/typedArrayConstructors.js b/node_modules/es-abstract/helpers/typedArrayConstructors.js new file mode 100644 index 0000000000000000000000000000000000000000..2d35fa347b096f68d2f7f2ddafeb9e82ede3674b --- /dev/null +++ b/node_modules/es-abstract/helpers/typedArrayConstructors.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var constructors = { + __proto__: null, + $Int8Array: GetIntrinsic('%Int8Array%', true), + $Uint8Array: GetIntrinsic('%Uint8Array%', true), + $Uint8ClampedArray: GetIntrinsic('%Uint8ClampedArray%', true), + $Int16Array: GetIntrinsic('%Int16Array%', true), + $Uint16Array: GetIntrinsic('%Uint16Array%', true), + $Int32Array: GetIntrinsic('%Int32Array%', true), + $Uint32Array: GetIntrinsic('%Uint32Array%', true), + $BigInt64Array: GetIntrinsic('%BigInt64Array%', true), + $BigUint64Array: GetIntrinsic('%BigUint64Array%', true), + $Float32Array: GetIntrinsic('%Float32Array%', true), + $Float64Array: GetIntrinsic('%Float64Array%', true) +}; + +module.exports = function getConstructor(kind) { + return constructors['$' + kind]; +}; diff --git a/node_modules/es-abstract/helpers/valueToFloat32Bytes.js b/node_modules/es-abstract/helpers/valueToFloat32Bytes.js new file mode 100644 index 0000000000000000000000000000000000000000..cf30576d8b9c607bdcf5d210c8966dd7b3771b70 --- /dev/null +++ b/node_modules/es-abstract/helpers/valueToFloat32Bytes.js @@ -0,0 +1,69 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $abs = GetIntrinsic('%Math.abs%'); +var $floor = GetIntrinsic('%Math.floor%'); +var $pow = GetIntrinsic('%Math.pow%'); + +var isFinite = require('./isFinite'); +var isNaN = require('./isNaN'); +var isNegativeZero = require('./isNegativeZero'); + +var maxFiniteFloat32 = 3.4028234663852886e+38; // roughly 2 ** 128 - 1 + +module.exports = function valueToFloat32Bytes(value, isLittleEndian) { + if (isNaN(value)) { + return isLittleEndian ? [0, 0, 192, 127] : [127, 192, 0, 0]; // hardcoded + } + + var leastSig; + + if (value === 0) { + leastSig = isNegativeZero(value) ? 0x80 : 0; + return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0]; + } + + if ($abs(value) > maxFiniteFloat32 || !isFinite(value)) { + leastSig = value < 0 ? 255 : 127; + return isLittleEndian ? [0, 0, 128, leastSig] : [leastSig, 128, 0, 0]; + } + + var sign = value < 0 ? 1 : 0; + value = $abs(value); // eslint-disable-line no-param-reassign + + var exponent = 0; + while (value >= 2) { + exponent += 1; + value /= 2; // eslint-disable-line no-param-reassign + } + + while (value < 1) { + exponent -= 1; + value *= 2; // eslint-disable-line no-param-reassign + } + + var mantissa = value - 1; + mantissa *= $pow(2, 23) + 0.5; + mantissa = $floor(mantissa); + + exponent += 127; + exponent <<= 23; + + var result = (sign << 31) + | exponent + | mantissa; + + var byte0 = result & 255; + result >>= 8; + var byte1 = result & 255; + result >>= 8; + var byte2 = result & 255; + result >>= 8; + var byte3 = result & 255; + + if (isLittleEndian) { + return [byte0, byte1, byte2, byte3]; + } + return [byte3, byte2, byte1, byte0]; +}; diff --git a/node_modules/es-abstract/helpers/valueToFloat64Bytes.js b/node_modules/es-abstract/helpers/valueToFloat64Bytes.js new file mode 100644 index 0000000000000000000000000000000000000000..3c7d75cfd295259ec0440eb38218098cefeb6450 --- /dev/null +++ b/node_modules/es-abstract/helpers/valueToFloat64Bytes.js @@ -0,0 +1,83 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $parseInt = GetIntrinsic('%parseInt%'); +var $abs = GetIntrinsic('%Math.abs%'); +var $floor = GetIntrinsic('%Math.floor%'); + +var callBound = require('call-bind/callBound'); + +var $strIndexOf = callBound('String.prototype.indexOf'); +var $strSlice = callBound('String.prototype.slice'); + +var fractionToBitString = require('../helpers/fractionToBinaryString'); +var intToBinString = require('../helpers/intToBinaryString'); +var isNegativeZero = require('./isNegativeZero'); + +var float64bias = 1023; + +var elevenOnes = '11111111111'; +var elevenZeroes = '00000000000'; +var fiftyOneZeroes = elevenZeroes + elevenZeroes + elevenZeroes + elevenZeroes + '0000000'; + +// IEEE 754-1985 +module.exports = function valueToFloat64Bytes(value, isLittleEndian) { + var signBit = value < 0 || isNegativeZero(value) ? '1' : '0'; + var exponentBits; + var significandBits; + + if (isNaN(value)) { + exponentBits = elevenOnes; + significandBits = '1' + fiftyOneZeroes; + } else if (!isFinite(value)) { + exponentBits = elevenOnes; + significandBits = '0' + fiftyOneZeroes; + } else if (value === 0) { + exponentBits = elevenZeroes; + significandBits = '0' + fiftyOneZeroes; + } else { + value = $abs(value); // eslint-disable-line no-param-reassign + + // Isolate the integer part (digits before the decimal): + var integerPart = $floor(value); + + var intBinString = intToBinString(integerPart); // bit string for integer part + var fracBinString = fractionToBitString(value - integerPart); // bit string for fractional part + + var numberOfBits; + // find exponent needed to normalize integer+fractional parts + if (intBinString) { + exponentBits = intBinString.length - 1; // move the decimal to the left + } else { + var first1 = $strIndexOf(fracBinString, '1'); + if (first1 > -1) { + numberOfBits = first1 + 1; + } + exponentBits = -numberOfBits; // move the decimal to the right + } + + significandBits = intBinString + fracBinString; + if (exponentBits < 0) { + // subnormals + if (exponentBits <= -float64bias) { + numberOfBits = float64bias - 1; // limit number of removed bits + } + significandBits = $strSlice(significandBits, numberOfBits); // remove all leading 0s and the first 1 for normal values; for subnormals, remove up to `float64bias - 1` leading bits + } else { + significandBits = $strSlice(significandBits, 1); // remove the leading '1' (implicit/hidden bit) + } + exponentBits = $strSlice(elevenZeroes + intToBinString(exponentBits + float64bias), -11); // Convert the exponent to a bit string + + significandBits = $strSlice(significandBits + fiftyOneZeroes + '0', 0, 52); // fill in any trailing zeros and ensure we have only 52 fraction bits + } + + var bits = signBit + exponentBits + significandBits; + var rawBytes = []; + for (var i = 0; i < 8; i++) { + var targetIndex = isLittleEndian ? 8 - i - 1 : i; + rawBytes[targetIndex] = $parseInt($strSlice(bits, i * 8, (i + 1) * 8), 2); + } + + return rawBytes; +}; diff --git a/node_modules/es-abstract/index.js b/node_modules/es-abstract/index.js new file mode 100644 index 0000000000000000000000000000000000000000..11bddca8c16afca42213bf145793c25d323558d8 --- /dev/null +++ b/node_modules/es-abstract/index.js @@ -0,0 +1,34 @@ +'use strict'; + +var assign = require('./helpers/assign'); + +var ES5 = require('./es5'); +var ES2015 = require('./es2015'); +var ES2016 = require('./es2016'); +var ES2017 = require('./es2017'); +var ES2018 = require('./es2018'); +var ES2019 = require('./es2019'); +var ES2020 = require('./es2020'); +var ES2021 = require('./es2021'); +var ES2022 = require('./es2022'); +var ES2023 = require('./es2023'); + +var ES = { + ES5: ES5, + ES6: ES2015, + ES2015: ES2015, + ES7: ES2016, + ES2016: ES2016, + ES2017: ES2017, + ES2018: ES2018, + ES2019: ES2019, + ES2020: ES2020, + ES2021: ES2021, + ES2022: ES2022, + ES2023: ES2023 +}; +assign(ES, ES5); +delete ES.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible +assign(ES, ES2015); + +module.exports = ES; diff --git a/node_modules/es-abstract/operations/.eslintrc b/node_modules/es-abstract/operations/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..bcd76f767154a3d2a632f974f018b6edd0000f76 --- /dev/null +++ b/node_modules/es-abstract/operations/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "id-length": 0, + }, +} diff --git a/node_modules/es-abstract/operations/2015.js b/node_modules/es-abstract/operations/2015.js new file mode 100644 index 0000000000000000000000000000000000000000..9edb26779c4985741f2f51db7bdd584edb9c5997 --- /dev/null +++ b/node_modules/es-abstract/operations/2015.js @@ -0,0 +1,744 @@ +'use strict'; + +module.exports = { + IsPropertyDescriptor: 'https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type', // not actually an abstract op + + abs: { + url: 'https://262.ecma-international.org/6.0/#sec-algorithm-conventions' + }, + 'Abstract Equality Comparison': { + url: 'https://262.ecma-international.org/6.0/#sec-abstract-equality-comparison' + }, + 'Abstract Relational Comparison': { + url: 'https://262.ecma-international.org/6.0/#sec-abstract-relational-comparison' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/6.0/#sec-addrestrictedfunctionproperties' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/6.0/#sec-advancestringindex' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/6.0/#sec-allocatearraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/6.0/#sec-allocatetypedarray' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/6.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-arrayspeciescreate' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-boundfunctioncreate' + }, + Call: { + url: 'https://262.ecma-international.org/6.0/#sec-call' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/6.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/6.0/#sec-canonicalnumericindexstring' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/6.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/6.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/6.0/#sec-clonearraybuffer' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/6.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/6.0/#sec-implicit-completion-values' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/6.0/#sec-completion-record-specification-type' + }, + Construct: { + url: 'https://262.ecma-international.org/6.0/#sec-construct' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/6.0/#sec-copydatablockbytes' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/6.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/6.0/#sec-createarrayiterator' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/6.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/6.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/6.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/6.0/#sec-createdynamicfunction' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/6.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/6.0/#sec-createintrinsics' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/6.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/6.0/#sec-createlistfromarraylike' + }, + CreateListIterator: { + url: 'https://262.ecma-international.org/6.0/#sec-createlistiterator' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/6.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/6.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-createmethodproperty' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/6.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/6.0/#sec-createrealm' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/6.0/#sec-createsetiterator' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/6.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/6.0/#sec-date-number' + }, + Day: { + url: 'https://262.ecma-international.org/6.0/#sec-day-number-and-time-within-day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/6.0/#sec-year-number' + }, + DaylightSavingTA: { + url: 'https://262.ecma-international.org/6.0/#sec-daylight-saving-time-adjustment' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/6.0/#sec-year-number' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/6.0/#sec-month-number' + }, + Decode: { + url: 'https://262.ecma-international.org/6.0/#sec-decode' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/6.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/6.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/6.0/#sec-encode' + }, + EnqueueJob: { + url: 'https://262.ecma-international.org/6.0/#sec-enqueuejob' + }, + EnumerableOwnNames: { + url: 'https://262.ecma-international.org/6.0/#sec-enumerableownnames' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/6.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/6.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/6.0/#sec-evaluatecall' + }, + EvaluateDirectCall: { + url: 'https://262.ecma-international.org/6.0/#sec-evaluatedirectcall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/6.0/#sec-evaluatenew' + }, + floor: { + url: 'https://262.ecma-international.org/6.0/#sec-algorithm-conventions' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/6.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/6.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/6.0/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/6.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/6.0/#sec-fulfillpromise' + }, + FunctionAllocate: { + url: 'https://262.ecma-international.org/6.0/#sec-functionallocate' + }, + FunctionCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-functioncreate' + }, + FunctionInitialize: { + url: 'https://262.ecma-international.org/6.0/#sec-functioninitialize' + }, + GeneratorFunctionCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-generatorfunctioncreate' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/6.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/6.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/6.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/6.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/6.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/6.0/#sec-get-o-p' + }, + GetBase: { + url: 'https://262.ecma-international.org/6.0/#sec-jobs-and-job-queues' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/6.0/#sec-getfunctionrealm' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/6.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/6.0/#sec-getidentifierreference' + }, + GetIterator: { + url: 'https://262.ecma-international.org/6.0/#sec-getiterator' + }, + GetMethod: { + url: 'https://262.ecma-international.org/6.0/#sec-getmethod' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/6.0/#sec-getmodulenamespace' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/6.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/6.0/#sec-getownpropertykeys' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor' + }, + GetReferencedName: { + url: 'https://262.ecma-international.org/6.0/#sec-jobs-and-job-queues' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/6.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/6.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/6.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/6.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/6.0/#sec-getthisvalue' + }, + GetV: { + url: 'https://262.ecma-international.org/6.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/6.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/6.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/6.0/#sec-getviewvalue' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-hasownproperty' + }, + HasPrimitiveBase: { + url: 'https://262.ecma-international.org/6.0/#sec-jobs-and-job-queues' + }, + HasProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-hasproperty' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/6.0/#sec-hours-minutes-second-and-milliseconds' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/6.0/#sec-importedlocalnames' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/6.0/#sec-initializehostdefinedrealm' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/6.0/#sec-initializereferencedbinding' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/6.0/#sec-year-number' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/6.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/6.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/6.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/6.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/6.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/6.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/6.0/#sec-isarray' + }, + IsCallable: { + url: 'https://262.ecma-international.org/6.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/6.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/6.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/6.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/6.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/6.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/6.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/6.0/#sec-isintailposition' + }, + IsInteger: { + url: 'https://262.ecma-international.org/6.0/#sec-isinteger' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/6.0/#sec-islabelledfunction' + }, + IsPromise: { + url: 'https://262.ecma-international.org/6.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/6.0/#sec-ispropertykey' + }, + IsPropertyReference: { + url: 'https://262.ecma-international.org/6.0/#sec-jobs-and-job-queues' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/6.0/#sec-isregexp' + }, + IsStrictReference: { + url: 'https://262.ecma-international.org/6.0/#sec-jobs-and-job-queues' + }, + IsSuperReference: { + url: 'https://262.ecma-international.org/6.0/#sec-jobs-and-job-queues' + }, + IsUnresolvableReference: { + url: 'https://262.ecma-international.org/6.0/#sec-jobs-and-job-queues' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/6.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/6.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/6.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/6.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/6.0/#sec-iteratorstep' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/6.0/#sec-iteratorvalue' + }, + LocalTime: { + url: 'https://262.ecma-international.org/6.0/#sec-localtime' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/6.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/6.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/6.0/#sec-makeargsetter' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/6.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/6.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/6.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/6.0/#sec-makeday' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/6.0/#sec-makemethod' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/6.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/6.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/6.0/#sec-algorithm-conventions' + }, + min: { + url: 'https://262.ecma-international.org/6.0/#sec-algorithm-conventions' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/6.0/#sec-hours-minutes-second-and-milliseconds' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/6.0/#sec-algorithm-conventions' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/6.0/#sec-month-number' + }, + msFromTime: { + url: 'https://262.ecma-international.org/6.0/#sec-hours-minutes-second-and-milliseconds' + }, + msPerDay: { + url: 'https://262.ecma-international.org/6.0/#sec-day-number-and-time-within-day' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/6.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/6.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/6.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/6.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/6.0/#sec-newobjectenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/6.0/#sec-newpromisecapability' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/6.0/#sec-normalcompletion' + }, + ObjectCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-objectcreate' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/6.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/6.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/6.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty' + }, + ParseModule: { + url: 'https://262.ecma-international.org/6.0/#sec-parsemodule' + }, + PerformEval: { + url: 'https://262.ecma-international.org/6.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/6.0/#sec-performpromiseall' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/6.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/6.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/6.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/6.0/#sec-preparefortailcall' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/6.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/6.0/#sec-quotejsonstring' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/6.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/6.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/6.0/#sec-regexpexec' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/6.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/6.0/#sec-rejectpromise' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/6.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/6.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/6.0/#sec-resolvebinding' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/6.0/#sec-resolvethisbinding' + }, + SameValue: { + url: 'https://262.ecma-international.org/6.0/#sec-samevalue' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/6.0/#sec-samevaluezero' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/6.0/#sec-hours-minutes-second-and-milliseconds' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/6.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/6.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/6.0/#sec-setdefaultglobalbindings' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/6.0/#sec-setfunctionname' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/6.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/6.0/#sec-setrealmglobalobject' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/6.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/6.0/#sec-setviewvalue' + }, + sign: { + url: 'https://262.ecma-international.org/6.0/#sec-algorithm-conventions' + }, + SortCompare: { + url: 'https://262.ecma-international.org/6.0/#sec-sortcompare' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/6.0/#sec-speciesconstructor' + }, + SplitMatch: { + url: 'https://262.ecma-international.org/6.0/#sec-splitmatch' + }, + 'Strict Equality Comparison': { + url: 'https://262.ecma-international.org/6.0/#sec-strict-equality-comparison' + }, + StringCreate: { + url: 'https://262.ecma-international.org/6.0/#sec-stringcreate' + }, + StringGetIndexProperty: { + url: 'https://262.ecma-international.org/6.0/#sec-stringgetindexproperty' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/6.0/#sec-symboldescriptivestring' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/6.0/#sec-testintegritylevel' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/6.0/#sec-properties-of-the-string-prototype-object' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/6.0/#sec-properties-of-the-date-prototype-object' + }, + TimeClip: { + url: 'https://262.ecma-international.org/6.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/6.0/#sec-year-number' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/6.0/#sec-day-number-and-time-within-day' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/6.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/6.0/#sec-todatestring' + }, + ToInt16: { + url: 'https://262.ecma-international.org/6.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/6.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/6.0/#sec-toint8' + }, + ToInteger: { + url: 'https://262.ecma-international.org/6.0/#sec-tointeger' + }, + ToLength: { + url: 'https://262.ecma-international.org/6.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/6.0/#sec-tonumber' + }, + ToObject: { + url: 'https://262.ecma-international.org/6.0/#sec-toobject' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/6.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/6.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/6.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/6.0/#sec-tostring' + }, + ToUint16: { + url: 'https://262.ecma-international.org/6.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/6.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/6.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/6.0/#sec-touint8clamp' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/6.0/#sec-triggerpromisereactions' + }, + Type: { + url: 'https://262.ecma-international.org/6.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayFrom: { + url: 'https://262.ecma-international.org/6.0/#sec-typedarrayfrom' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/6.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/6.0/#sec-utc-t' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/6.0/#sec-validateandapplypropertydescriptor' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/6.0/#sec-validatetypedarray' + }, + WeekDay: { + url: 'https://262.ecma-international.org/6.0/#sec-week-day' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/6.0/#sec-year-number' + } +}; diff --git a/node_modules/es-abstract/operations/2016.js b/node_modules/es-abstract/operations/2016.js new file mode 100644 index 0000000000000000000000000000000000000000..66e6d4afc85345378fd784b74fb8afc870dc3c99 --- /dev/null +++ b/node_modules/es-abstract/operations/2016.js @@ -0,0 +1,813 @@ +'use strict'; + +module.exports = { + IsPropertyDescriptor: 'https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type', // not actually an abstract op + + abs: { + url: 'https://262.ecma-international.org/7.0/#sec-algorithm-conventions' + }, + 'Abstract Equality Comparison': { + url: 'https://262.ecma-international.org/7.0/#sec-abstract-equality-comparison' + }, + 'Abstract Relational Comparison': { + url: 'https://262.ecma-international.org/7.0/#sec-abstract-relational-comparison' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/7.0/#sec-addrestrictedfunctionproperties' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/7.0/#sec-advancestringindex' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/7.0/#sec-allocatearraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/7.0/#sec-allocatetypedarray' + }, + AllocateTypedArrayBuffer: { + url: 'https://262.ecma-international.org/7.0/#sec-allocatetypedarraybuffer' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/7.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-arrayspeciescreate' + }, + BlockDeclarationInstantiation: { + url: 'https://262.ecma-international.org/7.0/#sec-blockdeclarationinstantiation' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-boundfunctioncreate' + }, + Call: { + url: 'https://262.ecma-international.org/7.0/#sec-call' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/7.0/#sec-canonicalnumericindexstring' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterRangeOrUnion: { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-characterrangeorunion-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/7.0/#sec-clonearraybuffer' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/7.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/7.0/#sec-completion-record-specification-type' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/7.0/#sec-completion-record-specification-type' + }, + Construct: { + url: 'https://262.ecma-international.org/7.0/#sec-construct' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/7.0/#sec-copydatablockbytes' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/7.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/7.0/#sec-createarrayiterator' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/7.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/7.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/7.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/7.0/#sec-createdynamicfunction' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/7.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/7.0/#sec-createintrinsics' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/7.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/7.0/#sec-createlistfromarraylike' + }, + CreateListIterator: { + url: 'https://262.ecma-international.org/7.0/#sec-createlistiterator' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/7.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/7.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-createmethodproperty' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/7.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/7.0/#sec-createrealm' + }, + CreateResolvingFunctions: { + url: 'https://262.ecma-international.org/7.0/#sec-createresolvingfunctions' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/7.0/#sec-createsetiterator' + }, + CreateStringIterator: { + url: 'https://262.ecma-international.org/7.0/#sec-createstringiterator' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/7.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/7.0/#sec-date-number' + }, + Day: { + url: 'https://262.ecma-international.org/7.0/#sec-day-number-and-time-within-day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/7.0/#sec-year-number' + }, + DaylightSavingTA: { + url: 'https://262.ecma-international.org/7.0/#sec-daylight-saving-time-adjustment' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/7.0/#sec-year-number' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/7.0/#sec-month-number' + }, + Decode: { + url: 'https://262.ecma-international.org/7.0/#sec-decode' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/7.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/7.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/7.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/7.0/#sec-encode' + }, + EnqueueJob: { + url: 'https://262.ecma-international.org/7.0/#sec-enqueuejob' + }, + EnumerableOwnNames: { + url: 'https://262.ecma-international.org/7.0/#sec-enumerableownnames' + }, + EnumerateObjectProperties: { + url: 'https://262.ecma-international.org/7.0/#sec-enumerate-object-properties' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/7.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/7.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/7.0/#sec-evaluatecall' + }, + EvaluateDirectCall: { + url: 'https://262.ecma-international.org/7.0/#sec-evaluatedirectcall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/7.0/#sec-evaluatenew' + }, + floor: { + url: 'https://262.ecma-international.org/7.0/#sec-algorithm-conventions' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/7.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/7.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/7.0/#sec-fulfillpromise' + }, + FunctionAllocate: { + url: 'https://262.ecma-international.org/7.0/#sec-functionallocate' + }, + FunctionCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-functioncreate' + }, + FunctionDeclarationInstantiation: { + url: 'https://262.ecma-international.org/7.0/#sec-functiondeclarationinstantiation' + }, + FunctionInitialize: { + url: 'https://262.ecma-international.org/7.0/#sec-functioninitialize' + }, + GeneratorFunctionCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-generatorfunctioncreate' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/7.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/7.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/7.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/7.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/7.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/7.0/#sec-get-o-p' + }, + GetActiveScriptOrModule: { + url: 'https://262.ecma-international.org/7.0/#sec-getactivescriptormodule' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/7.0/#sec-getfunctionrealm' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/7.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/7.0/#sec-getidentifierreference' + }, + GetIterator: { + url: 'https://262.ecma-international.org/7.0/#sec-getiterator' + }, + GetMethod: { + url: 'https://262.ecma-international.org/7.0/#sec-getmethod' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/7.0/#sec-getmodulenamespace' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/7.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/7.0/#sec-getownpropertykeys' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/7.0/#sec-getprototypefromconstructor' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/7.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/7.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/7.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/7.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/7.0/#sec-getthisvalue' + }, + GetV: { + url: 'https://262.ecma-international.org/7.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/7.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/7.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/7.0/#sec-getviewvalue' + }, + GlobalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/7.0/#sec-globaldeclarationinstantiation' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-hasownproperty' + }, + HasProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-hasproperty' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/7.0/#sec-hours-minutes-second-and-milliseconds' + }, + IfAbruptRejectPromise: { + url: 'https://262.ecma-international.org/7.0/#sec-ifabruptrejectpromise' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/7.0/#sec-importedlocalnames' + }, + InitializeBoundName: { + url: 'https://262.ecma-international.org/7.0/#sec-initializeboundname' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/7.0/#sec-initializehostdefinedrealm' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/7.0/#sec-initializereferencedbinding' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/7.0/#sec-year-number' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/7.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/7.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/7.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/7.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/7.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/7.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/7.0/#sec-isarray' + }, + IsCallable: { + url: 'https://262.ecma-international.org/7.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/7.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/7.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/7.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/7.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/7.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/7.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/7.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/7.0/#sec-isintailposition' + }, + IsInteger: { + url: 'https://262.ecma-international.org/7.0/#sec-isinteger' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/7.0/#sec-islabelledfunction' + }, + IsPromise: { + url: 'https://262.ecma-international.org/7.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/7.0/#sec-ispropertykey' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/7.0/#sec-isregexp' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IterableToArrayLike: { + url: 'https://262.ecma-international.org/7.0/#sec-iterabletoarraylike' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/7.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/7.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/7.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/7.0/#sec-iteratorstep' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/7.0/#sec-iteratorvalue' + }, + LocalTime: { + url: 'https://262.ecma-international.org/7.0/#sec-localtime' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/7.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/7.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/7.0/#sec-makeargsetter' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/7.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/7.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/7.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/7.0/#sec-makeday' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/7.0/#sec-makemethod' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/7.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/7.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/7.0/#sec-algorithm-conventions' + }, + min: { + url: 'https://262.ecma-international.org/7.0/#sec-algorithm-conventions' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/7.0/#sec-hours-minutes-second-and-milliseconds' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/7.0/#sec-algorithm-conventions' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/7.0/#sec-month-number' + }, + msFromTime: { + url: 'https://262.ecma-international.org/7.0/#sec-hours-minutes-second-and-milliseconds' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/7.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/7.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/7.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/7.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/7.0/#sec-newobjectenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/7.0/#sec-newpromisecapability' + }, + NextJob: { + url: 'https://262.ecma-international.org/7.0/#sec-nextjob-result' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/7.0/#sec-normalcompletion' + }, + ObjectCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-objectcreate' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/7.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarydefineownproperty' + }, + OrdinaryDelete: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarydelete' + }, + OrdinaryGet: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinaryget' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarygetownproperty' + }, + OrdinaryGetPrototypeOf: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinaryhasproperty' + }, + OrdinaryIsExtensible: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinaryisextensible' + }, + OrdinaryOwnPropertyKeys: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinaryownpropertykeys' + }, + OrdinaryPreventExtensions: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarypreventextensions' + }, + OrdinarySet: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinaryset' + }, + OrdinarySetPrototypeOf: { + url: 'https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof' + }, + ParseModule: { + url: 'https://262.ecma-international.org/7.0/#sec-parsemodule' + }, + ParseScript: { + url: 'https://262.ecma-international.org/7.0/#sec-parse-script' + }, + PerformEval: { + url: 'https://262.ecma-international.org/7.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/7.0/#sec-performpromiseall' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/7.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/7.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/7.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/7.0/#sec-preparefortailcall' + }, + PromiseReactionJob: { + url: 'https://262.ecma-international.org/7.0/#sec-promisereactionjob' + }, + PromiseResolveThenableJob: { + url: 'https://262.ecma-international.org/7.0/#sec-promiseresolvethenablejob' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/7.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/7.0/#sec-quotejsonstring' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/7.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/7.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/7.0/#sec-regexpexec' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/7.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/7.0/#sec-rejectpromise' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/7.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/7.0/#sec-resolvebinding' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/7.0/#sec-resolvethisbinding' + }, + ReturnIfAbrupt: { + url: 'https://262.ecma-international.org/7.0/#sec-returnifabrupt' + }, + SameValue: { + url: 'https://262.ecma-international.org/7.0/#sec-samevalue' + }, + SameValueNonNumber: { + url: 'https://262.ecma-international.org/7.0/#sec-samevaluenonnumber' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/7.0/#sec-samevaluezero' + }, + ScriptEvaluation: { + url: 'https://262.ecma-international.org/7.0/#sec-runtime-semantics-scriptevaluation' + }, + ScriptEvaluationJob: { + url: 'https://262.ecma-international.org/7.0/#sec-scriptevaluationjob' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/7.0/#sec-hours-minutes-second-and-milliseconds' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/7.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/7.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/7.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/7.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/7.0/#sec-setdefaultglobalbindings' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/7.0/#sec-setfunctionname' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/7.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/7.0/#sec-setrealmglobalobject' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/7.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/7.0/#sec-setviewvalue' + }, + SortCompare: { + url: 'https://262.ecma-international.org/7.0/#sec-sortcompare' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/7.0/#sec-speciesconstructor' + }, + SplitMatch: { + url: 'https://262.ecma-international.org/7.0/#sec-splitmatch' + }, + 'Strict Equality Comparison': { + url: 'https://262.ecma-international.org/7.0/#sec-strict-equality-comparison' + }, + StringCreate: { + url: 'https://262.ecma-international.org/7.0/#sec-stringcreate' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/7.0/#sec-symboldescriptivestring' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/7.0/#sec-testintegritylevel' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/7.0/#sec-thisbooleanvalue' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/7.0/#sec-properties-of-the-number-prototype-object' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/7.0/#sec-properties-of-the-string-prototype-object' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/7.0/#sec-properties-of-the-date-prototype-object' + }, + TimeClip: { + url: 'https://262.ecma-international.org/7.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/7.0/#sec-year-number' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/7.0/#sec-day-number-and-time-within-day' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/7.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/7.0/#sec-todatestring' + }, + ToInt16: { + url: 'https://262.ecma-international.org/7.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/7.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/7.0/#sec-toint8' + }, + ToInteger: { + url: 'https://262.ecma-international.org/7.0/#sec-tointeger' + }, + ToLength: { + url: 'https://262.ecma-international.org/7.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/7.0/#sec-tonumber' + }, + ToObject: { + url: 'https://262.ecma-international.org/7.0/#sec-toobject' + }, + TopLevelModuleEvaluationJob: { + url: 'https://262.ecma-international.org/7.0/#sec-toplevelmoduleevaluationjob' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/7.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/7.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/7.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/7.0/#sec-tostring' + }, + 'ToString Applied to the Number Type': { + url: 'https://262.ecma-international.org/7.0/#sec-tostring-applied-to-the-number-type' + }, + ToUint16: { + url: 'https://262.ecma-international.org/7.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/7.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/7.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/7.0/#sec-touint8clamp' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/7.0/#sec-triggerpromisereactions' + }, + Type: { + url: 'https://262.ecma-international.org/7.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayCreate: { + url: 'https://262.ecma-international.org/7.0/#typedarray-create' + }, + TypedArraySpeciesCreate: { + url: 'https://262.ecma-international.org/7.0/#typedarray-species-create' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/7.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/7.0/#sec-utc-t' + }, + UTF16Decode: { + url: 'https://262.ecma-international.org/7.0/#sec-utf16decode' + }, + UTF16Encoding: { + url: 'https://262.ecma-international.org/7.0/#sec-utf16encoding' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/7.0/#sec-validateandapplypropertydescriptor' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/7.0/#sec-validatetypedarray' + }, + WeekDay: { + url: 'https://262.ecma-international.org/7.0/#sec-week-day' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/7.0/#sec-year-number' + } +}; diff --git a/node_modules/es-abstract/operations/2017.js b/node_modules/es-abstract/operations/2017.js new file mode 100644 index 0000000000000000000000000000000000000000..5fa6e6aeafdbef80e13dfb70414ab54b56b43868 --- /dev/null +++ b/node_modules/es-abstract/operations/2017.js @@ -0,0 +1,954 @@ +'use strict'; + +module.exports = { + IsPropertyDescriptor: 'https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type', // not actually an abstract op + + abs: { + url: 'https://262.ecma-international.org/8.0/#eqn-abs' + }, + 'Abstract Equality Comparison': { + url: 'https://262.ecma-international.org/8.0/#sec-abstract-equality-comparison' + }, + 'Abstract Relational Comparison': { + url: 'https://262.ecma-international.org/8.0/#sec-abstract-relational-comparison' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/8.0/#sec-addrestrictedfunctionproperties' + }, + AddWaiter: { + url: 'https://262.ecma-international.org/8.0/#sec-addwaiter' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/8.0/#sec-advancestringindex' + }, + 'agent-order': { + url: 'https://262.ecma-international.org/8.0/#sec-agent-order' + }, + AgentCanSuspend: { + url: 'https://262.ecma-international.org/8.0/#sec-agentcansuspend' + }, + AgentSignifier: { + url: 'https://262.ecma-international.org/8.0/#sec-agentsignifier' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-allocatearraybuffer' + }, + AllocateSharedArrayBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-allocatesharedarraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/8.0/#sec-allocatetypedarray' + }, + AllocateTypedArrayBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-allocatetypedarraybuffer' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/8.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-arrayspeciescreate' + }, + AsyncFunctionAwait: { + url: 'https://262.ecma-international.org/8.0/#sec-async-functions-abstract-operations-async-function-await' + }, + AsyncFunctionCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-async-functions-abstract-operations-async-function-create' + }, + AsyncFunctionStart: { + url: 'https://262.ecma-international.org/8.0/#sec-async-functions-abstract-operations-async-function-start' + }, + AtomicLoad: { + url: 'https://262.ecma-international.org/8.0/#sec-atomicload' + }, + AtomicReadModifyWrite: { + url: 'https://262.ecma-international.org/8.0/#sec-atomicreadmodifywrite' + }, + BlockDeclarationInstantiation: { + url: 'https://262.ecma-international.org/8.0/#sec-blockdeclarationinstantiation' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-boundfunctioncreate' + }, + Call: { + url: 'https://262.ecma-international.org/8.0/#sec-call' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/8.0/#sec-canonicalnumericindexstring' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterRangeOrUnion: { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-characterrangeorunion-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-clonearraybuffer' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/8.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/8.0/#sec-completion-record-specification-type' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/8.0/#sec-completion-record-specification-type' + }, + ComposeWriteEventBytes: { + url: 'https://262.ecma-international.org/8.0/#sec-composewriteeventbytes' + }, + Construct: { + url: 'https://262.ecma-international.org/8.0/#sec-construct' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/8.0/#sec-copydatablockbytes' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/8.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/8.0/#sec-createarrayiterator' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/8.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/8.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/8.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/8.0/#sec-createdynamicfunction' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/8.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/8.0/#sec-createintrinsics' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/8.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/8.0/#sec-createlistfromarraylike' + }, + CreateListIterator: { + url: 'https://262.ecma-international.org/8.0/#sec-createlistiterator' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/8.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/8.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-createmethodproperty' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/8.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/8.0/#sec-createrealm' + }, + CreateResolvingFunctions: { + url: 'https://262.ecma-international.org/8.0/#sec-createresolvingfunctions' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/8.0/#sec-createsetiterator' + }, + CreateSharedByteDataBlock: { + url: 'https://262.ecma-international.org/8.0/#sec-createsharedbytedatablock' + }, + CreateStringIterator: { + url: 'https://262.ecma-international.org/8.0/#sec-createstringiterator' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/8.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/8.0/#sec-date-number' + }, + Day: { + url: 'https://262.ecma-international.org/8.0/#eqn-Day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/8.0/#eqn-DaysFromYear' + }, + DaylightSavingTA: { + url: 'https://262.ecma-international.org/8.0/#sec-daylight-saving-time-adjustment' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/8.0/#eqn-DaysInYear' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/8.0/#eqn-DayWithinYear' + }, + Decode: { + url: 'https://262.ecma-international.org/8.0/#sec-decode' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/8.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/8.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/8.0/#sec-encode' + }, + EnqueueJob: { + url: 'https://262.ecma-international.org/8.0/#sec-enqueuejob' + }, + EnterCriticalSection: { + url: 'https://262.ecma-international.org/8.0/#sec-entercriticalsection' + }, + EnumerableOwnProperties: { + url: 'https://262.ecma-international.org/8.0/#sec-enumerableownproperties' + }, + EnumerateObjectProperties: { + url: 'https://262.ecma-international.org/8.0/#sec-enumerate-object-properties' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/8.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/8.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/8.0/#sec-evaluatecall' + }, + EvaluateDirectCall: { + url: 'https://262.ecma-international.org/8.0/#sec-evaluatedirectcall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/8.0/#sec-evaluatenew' + }, + EventSet: { + url: 'https://262.ecma-international.org/8.0/#sec-event-set' + }, + floor: { + url: 'https://262.ecma-international.org/8.0/#eqn-floor' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/8.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/8.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/8.0/#sec-fulfillpromise' + }, + FunctionAllocate: { + url: 'https://262.ecma-international.org/8.0/#sec-functionallocate' + }, + FunctionCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-functioncreate' + }, + FunctionDeclarationInstantiation: { + url: 'https://262.ecma-international.org/8.0/#sec-functiondeclarationinstantiation' + }, + FunctionInitialize: { + url: 'https://262.ecma-international.org/8.0/#sec-functioninitialize' + }, + GeneratorFunctionCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-generatorfunctioncreate' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/8.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/8.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/8.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/8.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/8.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/8.0/#sec-get-o-p' + }, + GetActiveScriptOrModule: { + url: 'https://262.ecma-international.org/8.0/#sec-getactivescriptormodule' + }, + GetBase: { + url: 'https://262.ecma-international.org/8.0/#ao-getbase' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/8.0/#sec-getfunctionrealm' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/8.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/8.0/#sec-getidentifierreference' + }, + GetIterator: { + url: 'https://262.ecma-international.org/8.0/#sec-getiterator' + }, + GetMethod: { + url: 'https://262.ecma-international.org/8.0/#sec-getmethod' + }, + GetModifySetValueInBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-getmodifysetvalueinbuffer' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/8.0/#sec-getmodulenamespace' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/8.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/8.0/#sec-getownpropertykeys' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/8.0/#sec-getprototypefromconstructor' + }, + GetReferencedName: { + url: 'https://262.ecma-international.org/8.0/#ao-getreferencedname' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/8.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/8.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/8.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/8.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/8.0/#sec-getthisvalue' + }, + GetV: { + url: 'https://262.ecma-international.org/8.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/8.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/8.0/#sec-getviewvalue' + }, + GetWaiterList: { + url: 'https://262.ecma-international.org/8.0/#sec-getwaiterlist' + }, + GlobalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/8.0/#sec-globaldeclarationinstantiation' + }, + 'happens-before': { + url: 'https://262.ecma-international.org/8.0/#sec-happens-before' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-hasownproperty' + }, + HasPrimitiveBase: { + url: 'https://262.ecma-international.org/8.0/#ao-hasprimitivebase' + }, + HasProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-hasproperty' + }, + 'host-synchronizes-with': { + url: 'https://262.ecma-international.org/8.0/#sec-host-synchronizes-with' + }, + HostEventSet: { + url: 'https://262.ecma-international.org/8.0/#sec-hosteventset' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/8.0/#eqn-HourFromTime' + }, + IfAbruptRejectPromise: { + url: 'https://262.ecma-international.org/8.0/#sec-ifabruptrejectpromise' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/8.0/#sec-importedlocalnames' + }, + InitializeBoundName: { + url: 'https://262.ecma-international.org/8.0/#sec-initializeboundname' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/8.0/#sec-initializehostdefinedrealm' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/8.0/#sec-initializereferencedbinding' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/8.0/#eqn-InLeapYear' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/8.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/8.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/8.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/8.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/8.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/8.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/8.0/#sec-isarray' + }, + IsCallable: { + url: 'https://262.ecma-international.org/8.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/8.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/8.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/8.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/8.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/8.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/8.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/8.0/#sec-isintailposition' + }, + IsInteger: { + url: 'https://262.ecma-international.org/8.0/#sec-isinteger' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/8.0/#sec-islabelledfunction' + }, + IsPromise: { + url: 'https://262.ecma-international.org/8.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/8.0/#sec-ispropertykey' + }, + IsPropertyReference: { + url: 'https://262.ecma-international.org/8.0/#ao-ispropertyreference' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/8.0/#sec-isregexp' + }, + IsSharedArrayBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-issharedarraybuffer' + }, + IsStrictReference: { + url: 'https://262.ecma-international.org/8.0/#ao-isstrictreference' + }, + IsSuperReference: { + url: 'https://262.ecma-international.org/8.0/#ao-issuperreference' + }, + IsUnresolvableReference: { + url: 'https://262.ecma-international.org/8.0/#ao-isunresolvablereference' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IterableToList: { + url: 'https://262.ecma-international.org/8.0/#sec-iterabletolist' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/8.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/8.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/8.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/8.0/#sec-iteratorstep' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/8.0/#sec-iteratorvalue' + }, + LeaveCriticalSection: { + url: 'https://262.ecma-international.org/8.0/#sec-leavecriticalsection' + }, + LocalTime: { + url: 'https://262.ecma-international.org/8.0/#sec-localtime' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/8.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/8.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/8.0/#sec-makeargsetter' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/8.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/8.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/8.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/8.0/#sec-makeday' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/8.0/#sec-makemethod' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/8.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/8.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/8.0/#eqn-max' + }, + 'memory-order': { + url: 'https://262.ecma-international.org/8.0/#sec-memory-order' + }, + min: { + url: 'https://262.ecma-international.org/8.0/#eqn-min' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/8.0/#eqn-MinFromTime' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/8.0/#eqn-modulo' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/8.0/#eqn-MonthFromTime' + }, + msFromTime: { + url: 'https://262.ecma-international.org/8.0/#eqn-msFromTime' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/8.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/8.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/8.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/8.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/8.0/#sec-newobjectenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/8.0/#sec-newpromisecapability' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/8.0/#sec-normalcompletion' + }, + NumberToRawBytes: { + url: 'https://262.ecma-international.org/8.0/#sec-numbertorawbytes' + }, + ObjectCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-objectcreate' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/8.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarydefineownproperty' + }, + OrdinaryDelete: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarydelete' + }, + OrdinaryGet: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinaryget' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarygetownproperty' + }, + OrdinaryGetPrototypeOf: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarygetprototypeof' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinaryhasproperty' + }, + OrdinaryIsExtensible: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinaryisextensible' + }, + OrdinaryOwnPropertyKeys: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinaryownpropertykeys' + }, + OrdinaryPreventExtensions: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarypreventextensions' + }, + OrdinarySet: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinaryset' + }, + OrdinarySetPrototypeOf: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarysetprototypeof' + }, + OrdinaryToPrimitive: { + url: 'https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive' + }, + ParseModule: { + url: 'https://262.ecma-international.org/8.0/#sec-parsemodule' + }, + ParseScript: { + url: 'https://262.ecma-international.org/8.0/#sec-parse-script' + }, + PerformEval: { + url: 'https://262.ecma-international.org/8.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/8.0/#sec-performpromiseall' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/8.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/8.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/8.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/8.0/#sec-preparefortailcall' + }, + PromiseReactionJob: { + url: 'https://262.ecma-international.org/8.0/#sec-promisereactionjob' + }, + PromiseResolveThenableJob: { + url: 'https://262.ecma-international.org/8.0/#sec-promiseresolvethenablejob' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/8.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/8.0/#sec-quotejsonstring' + }, + RawBytesToNumber: { + url: 'https://262.ecma-international.org/8.0/#sec-rawbytestonumber' + }, + 'reads-bytes-from': { + url: 'https://262.ecma-international.org/8.0/#sec-reads-bytes-from' + }, + 'reads-from': { + url: 'https://262.ecma-international.org/8.0/#sec-reads-from' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/8.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/8.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/8.0/#sec-regexpexec' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/8.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/8.0/#sec-rejectpromise' + }, + RemoveWaiter: { + url: 'https://262.ecma-international.org/8.0/#sec-removewaiter' + }, + RemoveWaiters: { + url: 'https://262.ecma-international.org/8.0/#sec-removewaiters' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/8.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/8.0/#sec-resolvebinding' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/8.0/#sec-resolvethisbinding' + }, + ReturnIfAbrupt: { + url: 'https://262.ecma-international.org/8.0/#sec-returnifabrupt' + }, + RunJobs: { + url: 'https://262.ecma-international.org/8.0/#sec-runjobs' + }, + SameValue: { + url: 'https://262.ecma-international.org/8.0/#sec-samevalue' + }, + SameValueNonNumber: { + url: 'https://262.ecma-international.org/8.0/#sec-samevaluenonnumber' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/8.0/#sec-samevaluezero' + }, + ScriptEvaluation: { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-scriptevaluation' + }, + ScriptEvaluationJob: { + url: 'https://262.ecma-international.org/8.0/#sec-scriptevaluationjob' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/8.0/#eqn-SecFromTime' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/8.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/8.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/8.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/8.0/#sec-setdefaultglobalbindings' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/8.0/#sec-setfunctionname' + }, + SetImmutablePrototype: { + url: 'https://262.ecma-international.org/8.0/#sec-set-immutable-prototype' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/8.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/8.0/#sec-setrealmglobalobject' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/8.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/8.0/#sec-setviewvalue' + }, + SharedDataBlockEventSet: { + url: 'https://262.ecma-international.org/8.0/#sec-sharedatablockeventset' + }, + SortCompare: { + url: 'https://262.ecma-international.org/8.0/#sec-sortcompare' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/8.0/#sec-speciesconstructor' + }, + SplitMatch: { + url: 'https://262.ecma-international.org/8.0/#sec-splitmatch' + }, + 'Strict Equality Comparison': { + url: 'https://262.ecma-international.org/8.0/#sec-strict-equality-comparison' + }, + StringCreate: { + url: 'https://262.ecma-international.org/8.0/#sec-stringcreate' + }, + StringGetOwnProperty: { + url: 'https://262.ecma-international.org/8.0/#sec-stringgetownproperty' + }, + Suspend: { + url: 'https://262.ecma-international.org/8.0/#sec-suspend' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/8.0/#sec-symboldescriptivestring' + }, + 'synchronizes-with': { + url: 'https://262.ecma-international.org/8.0/#sec-synchronizes-with' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/8.0/#sec-testintegritylevel' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/8.0/#sec-thisbooleanvalue' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/8.0/#sec-thisnumbervalue' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/8.0/#sec-thisstringvalue' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/8.0/#sec-thistimevalue' + }, + TimeClip: { + url: 'https://262.ecma-international.org/8.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/8.0/#eqn-TimeFromYear' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/8.0/#eqn-TimeWithinDay' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/8.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/8.0/#sec-todatestring' + }, + ToIndex: { + url: 'https://262.ecma-international.org/8.0/#sec-toindex' + }, + ToInt16: { + url: 'https://262.ecma-international.org/8.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/8.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/8.0/#sec-toint8' + }, + ToInteger: { + url: 'https://262.ecma-international.org/8.0/#sec-tointeger' + }, + ToLength: { + url: 'https://262.ecma-international.org/8.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/8.0/#sec-tonumber' + }, + ToObject: { + url: 'https://262.ecma-international.org/8.0/#sec-toobject' + }, + TopLevelModuleEvaluationJob: { + url: 'https://262.ecma-international.org/8.0/#sec-toplevelmoduleevaluationjob' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/8.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/8.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/8.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/8.0/#sec-tostring' + }, + 'ToString Applied to the Number Type': { + url: 'https://262.ecma-international.org/8.0/#sec-tostring-applied-to-the-number-type' + }, + ToUint16: { + url: 'https://262.ecma-international.org/8.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/8.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/8.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/8.0/#sec-touint8clamp' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/8.0/#sec-triggerpromisereactions' + }, + Type: { + url: 'https://262.ecma-international.org/8.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayCreate: { + url: 'https://262.ecma-international.org/8.0/#typedarray-create' + }, + TypedArraySpeciesCreate: { + url: 'https://262.ecma-international.org/8.0/#typedarray-species-create' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/8.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/8.0/#sec-utc-t' + }, + UTF16Decode: { + url: 'https://262.ecma-international.org/8.0/#sec-utf16decode' + }, + UTF16Encoding: { + url: 'https://262.ecma-international.org/8.0/#sec-utf16encoding' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/8.0/#sec-validateandapplypropertydescriptor' + }, + ValidateAtomicAccess: { + url: 'https://262.ecma-international.org/8.0/#sec-validateatomicaccess' + }, + ValidateSharedIntegerTypedArray: { + url: 'https://262.ecma-international.org/8.0/#sec-validatesharedintegertypedarray' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/8.0/#sec-validatetypedarray' + }, + ValueOfReadEvent: { + url: 'https://262.ecma-international.org/8.0/#sec-valueofreadevent' + }, + WakeWaiter: { + url: 'https://262.ecma-international.org/8.0/#sec-wakewaiter' + }, + WeekDay: { + url: 'https://262.ecma-international.org/8.0/#sec-week-day' + }, + WordCharacters: { + url: 'https://262.ecma-international.org/8.0/#sec-runtime-semantics-wordcharacters-abstract-operation' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/8.0/#eqn-YearFromTime' + } +}; diff --git a/node_modules/es-abstract/operations/2018.js b/node_modules/es-abstract/operations/2018.js new file mode 100644 index 0000000000000000000000000000000000000000..251a409205fa4286f09e862442f2c837c694cf8d --- /dev/null +++ b/node_modules/es-abstract/operations/2018.js @@ -0,0 +1,1033 @@ +'use strict'; + +module.exports = { + abs: { + url: 'https://262.ecma-international.org/9.0/#eqn-abs' + }, + 'Abstract Equality Comparison': { + url: 'https://262.ecma-international.org/9.0/#sec-abstract-equality-comparison' + }, + 'Abstract Relational Comparison': { + url: 'https://262.ecma-international.org/9.0/#sec-abstract-relational-comparison' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/9.0/#sec-addrestrictedfunctionproperties' + }, + AddWaiter: { + url: 'https://262.ecma-international.org/9.0/#sec-addwaiter' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/9.0/#sec-advancestringindex' + }, + 'agent-order': { + url: 'https://262.ecma-international.org/9.0/#sec-agent-order' + }, + AgentCanSuspend: { + url: 'https://262.ecma-international.org/9.0/#sec-agentcansuspend' + }, + AgentSignifier: { + url: 'https://262.ecma-international.org/9.0/#sec-agentsignifier' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-allocatearraybuffer' + }, + AllocateSharedArrayBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-allocatesharedarraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/9.0/#sec-allocatetypedarray' + }, + AllocateTypedArrayBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-allocatetypedarraybuffer' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/9.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-arrayspeciescreate' + }, + AsyncFunctionCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-async-functions-abstract-operations-async-function-create' + }, + AsyncFunctionStart: { + url: 'https://262.ecma-international.org/9.0/#sec-async-functions-abstract-operations-async-function-start' + }, + AsyncGeneratorEnqueue: { + url: 'https://262.ecma-international.org/9.0/#sec-asyncgeneratorenqueue' + }, + AsyncGeneratorFunctionCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-asyncgeneratorfunctioncreate' + }, + AsyncGeneratorReject: { + url: 'https://262.ecma-international.org/9.0/#sec-asyncgeneratorreject' + }, + AsyncGeneratorResolve: { + url: 'https://262.ecma-international.org/9.0/#sec-asyncgeneratorresolve' + }, + AsyncGeneratorResumeNext: { + url: 'https://262.ecma-international.org/9.0/#sec-asyncgeneratorresumenext' + }, + AsyncGeneratorStart: { + url: 'https://262.ecma-international.org/9.0/#sec-asyncgeneratorstart' + }, + AsyncGeneratorYield: { + url: 'https://262.ecma-international.org/9.0/#sec-asyncgeneratoryield' + }, + AsyncIteratorClose: { + url: 'https://262.ecma-international.org/9.0/#sec-asynciteratorclose' + }, + AtomicLoad: { + url: 'https://262.ecma-international.org/9.0/#sec-atomicload' + }, + AtomicReadModifyWrite: { + url: 'https://262.ecma-international.org/9.0/#sec-atomicreadmodifywrite' + }, + Await: { + url: 'https://262.ecma-international.org/9.0/#await' + }, + BackreferenceMatcher: { + url: 'https://262.ecma-international.org/9.0/#sec-backreference-matcher' + }, + BlockDeclarationInstantiation: { + url: 'https://262.ecma-international.org/9.0/#sec-blockdeclarationinstantiation' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-boundfunctioncreate' + }, + Call: { + url: 'https://262.ecma-international.org/9.0/#sec-call' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/9.0/#sec-canonicalnumericindexstring' + }, + CaseClauseIsSelected: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-caseclauseisselected' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterRangeOrUnion: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-characterrangeorunion-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-clonearraybuffer' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/9.0/#sec-completion-record-specification-type' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/9.0/#sec-completion-record-specification-type' + }, + ComposeWriteEventBytes: { + url: 'https://262.ecma-international.org/9.0/#sec-composewriteeventbytes' + }, + Construct: { + url: 'https://262.ecma-international.org/9.0/#sec-construct' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/9.0/#sec-copydatablockbytes' + }, + CopyDataProperties: { + url: 'https://262.ecma-international.org/9.0/#sec-copydataproperties' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/9.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/9.0/#sec-createarrayiterator' + }, + CreateAsyncFromSyncIterator: { + url: 'https://262.ecma-international.org/9.0/#sec-createasyncfromsynciterator' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/9.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/9.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/9.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/9.0/#sec-createdynamicfunction' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/9.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/9.0/#sec-createintrinsics' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/9.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/9.0/#sec-createlistfromarraylike' + }, + CreateListIteratorRecord: { + url: 'https://262.ecma-international.org/9.0/#sec-createlistiteratorRecord' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/9.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/9.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-createmethodproperty' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/9.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/9.0/#sec-createrealm' + }, + CreateResolvingFunctions: { + url: 'https://262.ecma-international.org/9.0/#sec-createresolvingfunctions' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/9.0/#sec-createsetiterator' + }, + CreateSharedByteDataBlock: { + url: 'https://262.ecma-international.org/9.0/#sec-createsharedbytedatablock' + }, + CreateStringIterator: { + url: 'https://262.ecma-international.org/9.0/#sec-createstringiterator' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/9.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/9.0/#sec-date-number' + }, + DateString: { + url: 'https://262.ecma-international.org/9.0/#sec-datestring' + }, + Day: { + url: 'https://262.ecma-international.org/9.0/#eqn-Day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/9.0/#eqn-DaysFromYear' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/9.0/#eqn-DaysInYear' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/9.0/#eqn-DayWithinYear' + }, + Decode: { + url: 'https://262.ecma-international.org/9.0/#sec-decode' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/9.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/9.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/9.0/#sec-encode' + }, + EnqueueJob: { + url: 'https://262.ecma-international.org/9.0/#sec-enqueuejob' + }, + EnterCriticalSection: { + url: 'https://262.ecma-international.org/9.0/#sec-entercriticalsection' + }, + EnumerableOwnPropertyNames: { + url: 'https://262.ecma-international.org/9.0/#sec-enumerableownpropertynames' + }, + EnumerateObjectProperties: { + url: 'https://262.ecma-international.org/9.0/#sec-enumerate-object-properties' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/9.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/9.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/9.0/#sec-evaluatecall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/9.0/#sec-evaluatenew' + }, + EventSet: { + url: 'https://262.ecma-international.org/9.0/#sec-event-set' + }, + floor: { + url: 'https://262.ecma-international.org/9.0/#eqn-floor' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/9.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/9.0/#sec-fulfillpromise' + }, + FunctionAllocate: { + url: 'https://262.ecma-international.org/9.0/#sec-functionallocate' + }, + FunctionCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-functioncreate' + }, + FunctionDeclarationInstantiation: { + url: 'https://262.ecma-international.org/9.0/#sec-functiondeclarationinstantiation' + }, + FunctionInitialize: { + url: 'https://262.ecma-international.org/9.0/#sec-functioninitialize' + }, + GeneratorFunctionCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-generatorfunctioncreate' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/9.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/9.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/9.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/9.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/9.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/9.0/#sec-get-o-p' + }, + GetActiveScriptOrModule: { + url: 'https://262.ecma-international.org/9.0/#sec-getactivescriptormodule' + }, + GetBase: { + url: 'https://262.ecma-international.org/9.0/#sec-getbase' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/9.0/#sec-getfunctionrealm' + }, + GetGeneratorKind: { + url: 'https://262.ecma-international.org/9.0/#sec-getgeneratorkind' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/9.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/9.0/#sec-getidentifierreference' + }, + GetIterator: { + url: 'https://262.ecma-international.org/9.0/#sec-getiterator' + }, + GetMethod: { + url: 'https://262.ecma-international.org/9.0/#sec-getmethod' + }, + GetModifySetValueInBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-getmodifysetvalueinbuffer' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/9.0/#sec-getmodulenamespace' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/9.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/9.0/#sec-getownpropertykeys' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/9.0/#sec-getprototypefromconstructor' + }, + GetReferencedName: { + url: 'https://262.ecma-international.org/9.0/#sec-getreferencedname' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/9.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/9.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/9.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/9.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/9.0/#sec-getthisvalue' + }, + GetV: { + url: 'https://262.ecma-international.org/9.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/9.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/9.0/#sec-getviewvalue' + }, + GetWaiterList: { + url: 'https://262.ecma-international.org/9.0/#sec-getwaiterlist' + }, + GlobalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/9.0/#sec-globaldeclarationinstantiation' + }, + 'happens-before': { + url: 'https://262.ecma-international.org/9.0/#sec-happens-before' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-hasownproperty' + }, + HasPrimitiveBase: { + url: 'https://262.ecma-international.org/9.0/#sec-hasprimitivebase' + }, + HasProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-hasproperty' + }, + 'host-synchronizes-with': { + url: 'https://262.ecma-international.org/9.0/#sec-host-synchronizes-with' + }, + HostEventSet: { + url: 'https://262.ecma-international.org/9.0/#sec-hosteventset' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/9.0/#eqn-HourFromTime' + }, + IfAbruptRejectPromise: { + url: 'https://262.ecma-international.org/9.0/#sec-ifabruptrejectpromise' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/9.0/#sec-importedlocalnames' + }, + InitializeBoundName: { + url: 'https://262.ecma-international.org/9.0/#sec-initializeboundname' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/9.0/#sec-initializehostdefinedrealm' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/9.0/#sec-initializereferencedbinding' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/9.0/#eqn-InLeapYear' + }, + InnerModuleEvaluation: { + url: 'https://262.ecma-international.org/9.0/#sec-innermoduleevaluation' + }, + InnerModuleInstantiation: { + url: 'https://262.ecma-international.org/9.0/#sec-innermoduleinstantiation' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/9.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/9.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/9.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/9.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/9.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/9.0/#sec-isarray' + }, + IsCallable: { + url: 'https://262.ecma-international.org/9.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/9.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/9.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/9.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/9.0/#sec-isintailposition' + }, + IsInteger: { + url: 'https://262.ecma-international.org/9.0/#sec-isinteger' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/9.0/#sec-islabelledfunction' + }, + IsPromise: { + url: 'https://262.ecma-international.org/9.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/9.0/#sec-ispropertykey' + }, + IsPropertyReference: { + url: 'https://262.ecma-international.org/9.0/#sec-ispropertyreference' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/9.0/#sec-isregexp' + }, + IsSharedArrayBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-issharedarraybuffer' + }, + IsStrictReference: { + url: 'https://262.ecma-international.org/9.0/#sec-isstrictreference' + }, + IsStringPrefix: { + url: 'https://262.ecma-international.org/9.0/#sec-isstringprefix' + }, + IsSuperReference: { + url: 'https://262.ecma-international.org/9.0/#sec-issuperreference' + }, + IsUnresolvableReference: { + url: 'https://262.ecma-international.org/9.0/#sec-isunresolvablereference' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IterableToList: { + url: 'https://262.ecma-international.org/9.0/#sec-iterabletolist' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/9.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/9.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/9.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/9.0/#sec-iteratorstep' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/9.0/#sec-iteratorvalue' + }, + LeaveCriticalSection: { + url: 'https://262.ecma-international.org/9.0/#sec-leavecriticalsection' + }, + LocalTime: { + url: 'https://262.ecma-international.org/9.0/#sec-localtime' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/9.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/9.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/9.0/#sec-makeargsetter' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/9.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/9.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/9.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/9.0/#sec-makeday' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/9.0/#sec-makemethod' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/9.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/9.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/9.0/#eqn-max' + }, + 'memory-order': { + url: 'https://262.ecma-international.org/9.0/#sec-memory-order' + }, + min: { + url: 'https://262.ecma-international.org/9.0/#eqn-min' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/9.0/#eqn-MinFromTime' + }, + ModuleDeclarationEnvironmentSetup: { + url: 'https://262.ecma-international.org/9.0/#sec-moduledeclarationenvironmentsetup' + }, + ModuleExecution: { + url: 'https://262.ecma-international.org/9.0/#sec-moduleexecution' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/9.0/#eqn-modulo' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/9.0/#eqn-MonthFromTime' + }, + msFromTime: { + url: 'https://262.ecma-international.org/9.0/#eqn-msFromTime' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/9.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/9.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/9.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/9.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/9.0/#sec-newobjectenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/9.0/#sec-newpromisecapability' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/9.0/#sec-normalcompletion' + }, + NumberToRawBytes: { + url: 'https://262.ecma-international.org/9.0/#sec-numbertorawbytes' + }, + NumberToString: { + url: 'https://262.ecma-international.org/9.0/#sec-tostring-applied-to-the-number-type' + }, + ObjectCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-objectcreate' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/9.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarydefineownproperty' + }, + OrdinaryDelete: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarydelete' + }, + OrdinaryGet: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinaryget' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarygetownproperty' + }, + OrdinaryGetPrototypeOf: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarygetprototypeof' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinaryhasproperty' + }, + OrdinaryIsExtensible: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinaryisextensible' + }, + OrdinaryOwnPropertyKeys: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinaryownpropertykeys' + }, + OrdinaryPreventExtensions: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarypreventextensions' + }, + OrdinarySet: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinaryset' + }, + OrdinarySetPrototypeOf: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarysetprototypeof' + }, + OrdinarySetWithOwnDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarysetwithowndescriptor' + }, + OrdinaryToPrimitive: { + url: 'https://262.ecma-international.org/9.0/#sec-ordinarytoprimitive' + }, + ParseModule: { + url: 'https://262.ecma-international.org/9.0/#sec-parsemodule' + }, + ParseScript: { + url: 'https://262.ecma-international.org/9.0/#sec-parse-script' + }, + PerformEval: { + url: 'https://262.ecma-international.org/9.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/9.0/#sec-performpromiseall' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/9.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/9.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/9.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/9.0/#sec-preparefortailcall' + }, + PromiseReactionJob: { + url: 'https://262.ecma-international.org/9.0/#sec-promisereactionjob' + }, + PromiseResolve: { + url: 'https://262.ecma-international.org/9.0/#sec-promise-resolve' + }, + PromiseResolveThenableJob: { + url: 'https://262.ecma-international.org/9.0/#sec-promiseresolvethenablejob' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/9.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/9.0/#sec-quotejsonstring' + }, + RawBytesToNumber: { + url: 'https://262.ecma-international.org/9.0/#sec-rawbytestonumber' + }, + 'reads-bytes-from': { + url: 'https://262.ecma-international.org/9.0/#sec-reads-bytes-from' + }, + 'reads-from': { + url: 'https://262.ecma-international.org/9.0/#sec-reads-from' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/9.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/9.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/9.0/#sec-regexpexec' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/9.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/9.0/#sec-rejectpromise' + }, + RemoveWaiter: { + url: 'https://262.ecma-international.org/9.0/#sec-removewaiter' + }, + RemoveWaiters: { + url: 'https://262.ecma-international.org/9.0/#sec-removewaiters' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/9.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/9.0/#sec-resolvebinding' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/9.0/#sec-resolvethisbinding' + }, + ReturnIfAbrupt: { + url: 'https://262.ecma-international.org/9.0/#sec-returnifabrupt' + }, + RunJobs: { + url: 'https://262.ecma-international.org/9.0/#sec-runjobs' + }, + SameValue: { + url: 'https://262.ecma-international.org/9.0/#sec-samevalue' + }, + SameValueNonNumber: { + url: 'https://262.ecma-international.org/9.0/#sec-samevaluenonnumber' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/9.0/#sec-samevaluezero' + }, + ScriptEvaluation: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-scriptevaluation' + }, + ScriptEvaluationJob: { + url: 'https://262.ecma-international.org/9.0/#sec-scriptevaluationjob' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/9.0/#eqn-SecFromTime' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/9.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/9.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/9.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/9.0/#sec-setdefaultglobalbindings' + }, + SetFunctionLength: { + url: 'https://262.ecma-international.org/9.0/#sec-setfunctionlength' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/9.0/#sec-setfunctionname' + }, + SetImmutablePrototype: { + url: 'https://262.ecma-international.org/9.0/#sec-set-immutable-prototype' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/9.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/9.0/#sec-setrealmglobalobject' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/9.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/9.0/#sec-setviewvalue' + }, + SharedDataBlockEventSet: { + url: 'https://262.ecma-international.org/9.0/#sec-sharedatablockeventset' + }, + SortCompare: { + url: 'https://262.ecma-international.org/9.0/#sec-sortcompare' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/9.0/#sec-speciesconstructor' + }, + SplitMatch: { + url: 'https://262.ecma-international.org/9.0/#sec-splitmatch' + }, + 'Strict Equality Comparison': { + url: 'https://262.ecma-international.org/9.0/#sec-strict-equality-comparison' + }, + StringCreate: { + url: 'https://262.ecma-international.org/9.0/#sec-stringcreate' + }, + StringGetOwnProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-stringgetownproperty' + }, + Suspend: { + url: 'https://262.ecma-international.org/9.0/#sec-suspend' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/9.0/#sec-symboldescriptivestring' + }, + 'synchronizes-with': { + url: 'https://262.ecma-international.org/9.0/#sec-synchronizes-with' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/9.0/#sec-testintegritylevel' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/9.0/#sec-thisbooleanvalue' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/9.0/#sec-thisnumbervalue' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/9.0/#sec-thisstringvalue' + }, + thisSymbolValue: { + url: 'https://262.ecma-international.org/9.0/#sec-thissymbolvalue' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/9.0/#sec-thistimevalue' + }, + ThrowCompletion: { + url: 'https://262.ecma-international.org/9.0/#sec-throwcompletion' + }, + TimeClip: { + url: 'https://262.ecma-international.org/9.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/9.0/#eqn-TimeFromYear' + }, + TimeString: { + url: 'https://262.ecma-international.org/9.0/#sec-timestring' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/9.0/#eqn-TimeWithinDay' + }, + TimeZoneString: { + url: 'https://262.ecma-international.org/9.0/#sec-timezoneestring' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/9.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/9.0/#sec-todatestring' + }, + ToIndex: { + url: 'https://262.ecma-international.org/9.0/#sec-toindex' + }, + ToInt16: { + url: 'https://262.ecma-international.org/9.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/9.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/9.0/#sec-toint8' + }, + ToInteger: { + url: 'https://262.ecma-international.org/9.0/#sec-tointeger' + }, + ToLength: { + url: 'https://262.ecma-international.org/9.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/9.0/#sec-tonumber' + }, + ToObject: { + url: 'https://262.ecma-international.org/9.0/#sec-toobject' + }, + TopLevelModuleEvaluationJob: { + url: 'https://262.ecma-international.org/9.0/#sec-toplevelmoduleevaluationjob' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/9.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/9.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/9.0/#sec-tostring' + }, + ToUint16: { + url: 'https://262.ecma-international.org/9.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/9.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/9.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/9.0/#sec-touint8clamp' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/9.0/#sec-triggerpromisereactions' + }, + Type: { + url: 'https://262.ecma-international.org/9.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayCreate: { + url: 'https://262.ecma-international.org/9.0/#typedarray-create' + }, + TypedArraySpeciesCreate: { + url: 'https://262.ecma-international.org/9.0/#typedarray-species-create' + }, + UnicodeEscape: { + url: 'https://262.ecma-international.org/9.0/#sec-unicodeescape' + }, + UnicodeMatchProperty: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-unicodematchproperty-p' + }, + UnicodeMatchPropertyValue: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-unicodematchpropertyvalue-p-v' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/9.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/9.0/#sec-utc-t' + }, + UTF16Decode: { + url: 'https://262.ecma-international.org/9.0/#sec-utf16decode' + }, + UTF16Encoding: { + url: 'https://262.ecma-international.org/9.0/#sec-utf16encoding' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/9.0/#sec-validateandapplypropertydescriptor' + }, + ValidateAtomicAccess: { + url: 'https://262.ecma-international.org/9.0/#sec-validateatomicaccess' + }, + ValidateSharedIntegerTypedArray: { + url: 'https://262.ecma-international.org/9.0/#sec-validatesharedintegertypedarray' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/9.0/#sec-validatetypedarray' + }, + ValueOfReadEvent: { + url: 'https://262.ecma-international.org/9.0/#sec-valueofreadevent' + }, + WakeWaiter: { + url: 'https://262.ecma-international.org/9.0/#sec-wakewaiter' + }, + WeekDay: { + url: 'https://262.ecma-international.org/9.0/#sec-week-day' + }, + WordCharacters: { + url: 'https://262.ecma-international.org/9.0/#sec-runtime-semantics-wordcharacters-abstract-operation' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/9.0/#eqn-YearFromTime' + } +}; diff --git a/node_modules/es-abstract/operations/2019.js b/node_modules/es-abstract/operations/2019.js new file mode 100644 index 0000000000000000000000000000000000000000..d19150c8dc45cdde052f3a3a6a9ad3017bc5f570 --- /dev/null +++ b/node_modules/es-abstract/operations/2019.js @@ -0,0 +1,1048 @@ +'use strict'; + +module.exports = { + abs: { + url: 'https://262.ecma-international.org/10.0/#eqn-abs' + }, + 'Abstract Equality Comparison': { + url: 'https://262.ecma-international.org/10.0/#sec-abstract-equality-comparison' + }, + 'Abstract Relational Comparison': { + url: 'https://262.ecma-international.org/10.0/#sec-abstract-relational-comparison' + }, + AddEntriesFromIterable: { + url: 'https://262.ecma-international.org/10.0/#sec-add-entries-from-iterable' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/10.0/#sec-addrestrictedfunctionproperties' + }, + AddWaiter: { + url: 'https://262.ecma-international.org/10.0/#sec-addwaiter' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/10.0/#sec-advancestringindex' + }, + 'agent-order': { + url: 'https://262.ecma-international.org/10.0/#sec-agent-order' + }, + AgentCanSuspend: { + url: 'https://262.ecma-international.org/10.0/#sec-agentcansuspend' + }, + AgentSignifier: { + url: 'https://262.ecma-international.org/10.0/#sec-agentsignifier' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-allocatearraybuffer' + }, + AllocateSharedArrayBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-allocatesharedarraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/10.0/#sec-allocatetypedarray' + }, + AllocateTypedArrayBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-allocatetypedarraybuffer' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/10.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-arrayspeciescreate' + }, + AsyncFromSyncIteratorContinuation: { + url: 'https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation' + }, + AsyncFunctionCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-async-functions-abstract-operations-async-function-create' + }, + AsyncFunctionStart: { + url: 'https://262.ecma-international.org/10.0/#sec-async-functions-abstract-operations-async-function-start' + }, + AsyncGeneratorEnqueue: { + url: 'https://262.ecma-international.org/10.0/#sec-asyncgeneratorenqueue' + }, + AsyncGeneratorFunctionCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-asyncgeneratorfunctioncreate' + }, + AsyncGeneratorReject: { + url: 'https://262.ecma-international.org/10.0/#sec-asyncgeneratorreject' + }, + AsyncGeneratorResolve: { + url: 'https://262.ecma-international.org/10.0/#sec-asyncgeneratorresolve' + }, + AsyncGeneratorResumeNext: { + url: 'https://262.ecma-international.org/10.0/#sec-asyncgeneratorresumenext' + }, + AsyncGeneratorStart: { + url: 'https://262.ecma-international.org/10.0/#sec-asyncgeneratorstart' + }, + AsyncGeneratorYield: { + url: 'https://262.ecma-international.org/10.0/#sec-asyncgeneratoryield' + }, + AsyncIteratorClose: { + url: 'https://262.ecma-international.org/10.0/#sec-asynciteratorclose' + }, + AtomicLoad: { + url: 'https://262.ecma-international.org/10.0/#sec-atomicload' + }, + AtomicReadModifyWrite: { + url: 'https://262.ecma-international.org/10.0/#sec-atomicreadmodifywrite' + }, + Await: { + url: 'https://262.ecma-international.org/10.0/#await' + }, + BackreferenceMatcher: { + url: 'https://262.ecma-international.org/10.0/#sec-backreference-matcher' + }, + BlockDeclarationInstantiation: { + url: 'https://262.ecma-international.org/10.0/#sec-blockdeclarationinstantiation' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-boundfunctioncreate' + }, + Call: { + url: 'https://262.ecma-international.org/10.0/#sec-call' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/10.0/#sec-canonicalnumericindexstring' + }, + CaseClauseIsSelected: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-caseclauseisselected' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterRangeOrUnion: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-characterrangeorunion-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-clonearraybuffer' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/10.0/#sec-completion-record-specification-type' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/10.0/#sec-completion-record-specification-type' + }, + ComposeWriteEventBytes: { + url: 'https://262.ecma-international.org/10.0/#sec-composewriteeventbytes' + }, + Construct: { + url: 'https://262.ecma-international.org/10.0/#sec-construct' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/10.0/#sec-copydatablockbytes' + }, + CopyDataProperties: { + url: 'https://262.ecma-international.org/10.0/#sec-copydataproperties' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/10.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/10.0/#sec-createarrayiterator' + }, + CreateAsyncFromSyncIterator: { + url: 'https://262.ecma-international.org/10.0/#sec-createasyncfromsynciterator' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/10.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/10.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/10.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/10.0/#sec-createdynamicfunction' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/10.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/10.0/#sec-createintrinsics' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/10.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/10.0/#sec-createlistfromarraylike' + }, + CreateListIteratorRecord: { + url: 'https://262.ecma-international.org/10.0/#sec-createlistiteratorRecord' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/10.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/10.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-createmethodproperty' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/10.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/10.0/#sec-createrealm' + }, + CreateResolvingFunctions: { + url: 'https://262.ecma-international.org/10.0/#sec-createresolvingfunctions' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/10.0/#sec-createsetiterator' + }, + CreateSharedByteDataBlock: { + url: 'https://262.ecma-international.org/10.0/#sec-createsharedbytedatablock' + }, + CreateStringIterator: { + url: 'https://262.ecma-international.org/10.0/#sec-createstringiterator' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/10.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/10.0/#sec-date-number' + }, + DateString: { + url: 'https://262.ecma-international.org/10.0/#sec-datestring' + }, + Day: { + url: 'https://262.ecma-international.org/10.0/#eqn-Day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/10.0/#eqn-DaysFromYear' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/10.0/#eqn-DaysInYear' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/10.0/#eqn-DayWithinYear' + }, + Decode: { + url: 'https://262.ecma-international.org/10.0/#sec-decode' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/10.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/10.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/10.0/#sec-encode' + }, + EnqueueJob: { + url: 'https://262.ecma-international.org/10.0/#sec-enqueuejob' + }, + EnterCriticalSection: { + url: 'https://262.ecma-international.org/10.0/#sec-entercriticalsection' + }, + EnumerableOwnPropertyNames: { + url: 'https://262.ecma-international.org/10.0/#sec-enumerableownpropertynames' + }, + EnumerateObjectProperties: { + url: 'https://262.ecma-international.org/10.0/#sec-enumerate-object-properties' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/10.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/10.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/10.0/#sec-evaluatecall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/10.0/#sec-evaluatenew' + }, + EventSet: { + url: 'https://262.ecma-international.org/10.0/#sec-event-set' + }, + ExecuteModule: { + url: 'https://262.ecma-international.org/10.0/#sec-source-text-module-record-execute-module' + }, + FlattenIntoArray: { + url: 'https://262.ecma-international.org/10.0/#sec-flattenintoarray' + }, + floor: { + url: 'https://262.ecma-international.org/10.0/#eqn-floor' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/10.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/10.0/#sec-fulfillpromise' + }, + FunctionAllocate: { + url: 'https://262.ecma-international.org/10.0/#sec-functionallocate' + }, + FunctionCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-functioncreate' + }, + FunctionDeclarationInstantiation: { + url: 'https://262.ecma-international.org/10.0/#sec-functiondeclarationinstantiation' + }, + FunctionInitialize: { + url: 'https://262.ecma-international.org/10.0/#sec-functioninitialize' + }, + GeneratorFunctionCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-generatorfunctioncreate' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/10.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/10.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/10.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/10.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/10.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/10.0/#sec-get-o-p' + }, + GetActiveScriptOrModule: { + url: 'https://262.ecma-international.org/10.0/#sec-getactivescriptormodule' + }, + GetBase: { + url: 'https://262.ecma-international.org/10.0/#sec-getbase' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/10.0/#sec-getfunctionrealm' + }, + GetGeneratorKind: { + url: 'https://262.ecma-international.org/10.0/#sec-getgeneratorkind' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/10.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/10.0/#sec-getidentifierreference' + }, + GetIterator: { + url: 'https://262.ecma-international.org/10.0/#sec-getiterator' + }, + GetMethod: { + url: 'https://262.ecma-international.org/10.0/#sec-getmethod' + }, + GetModifySetValueInBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-getmodifysetvalueinbuffer' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/10.0/#sec-getmodulenamespace' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/10.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/10.0/#sec-getownpropertykeys' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/10.0/#sec-getprototypefromconstructor' + }, + GetReferencedName: { + url: 'https://262.ecma-international.org/10.0/#sec-getreferencedname' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/10.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/10.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/10.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/10.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/10.0/#sec-getthisvalue' + }, + GetV: { + url: 'https://262.ecma-international.org/10.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/10.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/10.0/#sec-getviewvalue' + }, + GetWaiterList: { + url: 'https://262.ecma-international.org/10.0/#sec-getwaiterlist' + }, + GlobalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/10.0/#sec-globaldeclarationinstantiation' + }, + 'happens-before': { + url: 'https://262.ecma-international.org/10.0/#sec-happens-before' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-hasownproperty' + }, + HasPrimitiveBase: { + url: 'https://262.ecma-international.org/10.0/#sec-hasprimitivebase' + }, + HasProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-hasproperty' + }, + 'host-synchronizes-with': { + url: 'https://262.ecma-international.org/10.0/#sec-host-synchronizes-with' + }, + HostEventSet: { + url: 'https://262.ecma-international.org/10.0/#sec-hosteventset' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/10.0/#eqn-HourFromTime' + }, + IfAbruptRejectPromise: { + url: 'https://262.ecma-international.org/10.0/#sec-ifabruptrejectpromise' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/10.0/#sec-importedlocalnames' + }, + InitializeBoundName: { + url: 'https://262.ecma-international.org/10.0/#sec-initializeboundname' + }, + InitializeEnvironment: { + url: 'https://262.ecma-international.org/10.0/#sec-source-text-module-record-initialize-environment' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/10.0/#sec-initializehostdefinedrealm' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/10.0/#sec-initializereferencedbinding' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/10.0/#eqn-InLeapYear' + }, + InnerModuleEvaluation: { + url: 'https://262.ecma-international.org/10.0/#sec-innermoduleevaluation' + }, + InnerModuleInstantiation: { + url: 'https://262.ecma-international.org/10.0/#sec-innermoduleinstantiation' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/10.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/10.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/10.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/10.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/10.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/10.0/#sec-isarray' + }, + IsCallable: { + url: 'https://262.ecma-international.org/10.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/10.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/10.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/10.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/10.0/#sec-isintailposition' + }, + IsInteger: { + url: 'https://262.ecma-international.org/10.0/#sec-isinteger' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/10.0/#sec-islabelledfunction' + }, + IsPromise: { + url: 'https://262.ecma-international.org/10.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/10.0/#sec-ispropertykey' + }, + IsPropertyReference: { + url: 'https://262.ecma-international.org/10.0/#sec-ispropertyreference' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/10.0/#sec-isregexp' + }, + IsSharedArrayBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-issharedarraybuffer' + }, + IsStrictReference: { + url: 'https://262.ecma-international.org/10.0/#sec-isstrictreference' + }, + IsStringPrefix: { + url: 'https://262.ecma-international.org/10.0/#sec-isstringprefix' + }, + IsSuperReference: { + url: 'https://262.ecma-international.org/10.0/#sec-issuperreference' + }, + IsUnresolvableReference: { + url: 'https://262.ecma-international.org/10.0/#sec-isunresolvablereference' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IterableToList: { + url: 'https://262.ecma-international.org/10.0/#sec-iterabletolist' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/10.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/10.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/10.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/10.0/#sec-iteratorstep' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/10.0/#sec-iteratorvalue' + }, + LeaveCriticalSection: { + url: 'https://262.ecma-international.org/10.0/#sec-leavecriticalsection' + }, + LocalTime: { + url: 'https://262.ecma-international.org/10.0/#sec-localtime' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/10.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/10.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/10.0/#sec-makeargsetter' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/10.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/10.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/10.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/10.0/#sec-makeday' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/10.0/#sec-makemethod' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/10.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/10.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/10.0/#eqn-max' + }, + 'memory-order': { + url: 'https://262.ecma-international.org/10.0/#sec-memory-order' + }, + min: { + url: 'https://262.ecma-international.org/10.0/#eqn-min' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/10.0/#eqn-MinFromTime' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/10.0/#eqn-modulo' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/10.0/#eqn-MonthFromTime' + }, + msFromTime: { + url: 'https://262.ecma-international.org/10.0/#eqn-msFromTime' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/10.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/10.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/10.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/10.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/10.0/#sec-newobjectenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/10.0/#sec-newpromisecapability' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/10.0/#sec-normalcompletion' + }, + NotifyWaiter: { + url: 'https://262.ecma-international.org/10.0/#sec-notifywaiter' + }, + NumberToRawBytes: { + url: 'https://262.ecma-international.org/10.0/#sec-numbertorawbytes' + }, + NumberToString: { + url: 'https://262.ecma-international.org/10.0/#sec-tostring-applied-to-the-number-type' + }, + ObjectCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-objectcreate' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/10.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarydefineownproperty' + }, + OrdinaryDelete: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarydelete' + }, + OrdinaryGet: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinaryget' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarygetownproperty' + }, + OrdinaryGetPrototypeOf: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarygetprototypeof' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinaryhasproperty' + }, + OrdinaryIsExtensible: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinaryisextensible' + }, + OrdinaryOwnPropertyKeys: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinaryownpropertykeys' + }, + OrdinaryPreventExtensions: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarypreventextensions' + }, + OrdinarySet: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinaryset' + }, + OrdinarySetPrototypeOf: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarysetprototypeof' + }, + OrdinarySetWithOwnDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarysetwithowndescriptor' + }, + OrdinaryToPrimitive: { + url: 'https://262.ecma-international.org/10.0/#sec-ordinarytoprimitive' + }, + ParseModule: { + url: 'https://262.ecma-international.org/10.0/#sec-parsemodule' + }, + ParseScript: { + url: 'https://262.ecma-international.org/10.0/#sec-parse-script' + }, + PerformEval: { + url: 'https://262.ecma-international.org/10.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/10.0/#sec-performpromiseall' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/10.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/10.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/10.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/10.0/#sec-preparefortailcall' + }, + PromiseReactionJob: { + url: 'https://262.ecma-international.org/10.0/#sec-promisereactionjob' + }, + PromiseResolve: { + url: 'https://262.ecma-international.org/10.0/#sec-promise-resolve' + }, + PromiseResolveThenableJob: { + url: 'https://262.ecma-international.org/10.0/#sec-promiseresolvethenablejob' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/10.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/10.0/#sec-quotejsonstring' + }, + RawBytesToNumber: { + url: 'https://262.ecma-international.org/10.0/#sec-rawbytestonumber' + }, + 'reads-bytes-from': { + url: 'https://262.ecma-international.org/10.0/#sec-reads-bytes-from' + }, + 'reads-from': { + url: 'https://262.ecma-international.org/10.0/#sec-reads-from' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/10.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/10.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/10.0/#sec-regexpexec' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/10.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/10.0/#sec-rejectpromise' + }, + RemoveWaiter: { + url: 'https://262.ecma-international.org/10.0/#sec-removewaiter' + }, + RemoveWaiters: { + url: 'https://262.ecma-international.org/10.0/#sec-removewaiters' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/10.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/10.0/#sec-resolvebinding' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/10.0/#sec-resolvethisbinding' + }, + ReturnIfAbrupt: { + url: 'https://262.ecma-international.org/10.0/#sec-returnifabrupt' + }, + RunJobs: { + url: 'https://262.ecma-international.org/10.0/#sec-runjobs' + }, + SameValue: { + url: 'https://262.ecma-international.org/10.0/#sec-samevalue' + }, + SameValueNonNumber: { + url: 'https://262.ecma-international.org/10.0/#sec-samevaluenonnumber' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/10.0/#sec-samevaluezero' + }, + ScriptEvaluation: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-scriptevaluation' + }, + ScriptEvaluationJob: { + url: 'https://262.ecma-international.org/10.0/#sec-scriptevaluationjob' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/10.0/#eqn-SecFromTime' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/10.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/10.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/10.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/10.0/#sec-setdefaultglobalbindings' + }, + SetFunctionLength: { + url: 'https://262.ecma-international.org/10.0/#sec-setfunctionlength' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/10.0/#sec-setfunctionname' + }, + SetImmutablePrototype: { + url: 'https://262.ecma-international.org/10.0/#sec-set-immutable-prototype' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/10.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/10.0/#sec-setrealmglobalobject' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/10.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/10.0/#sec-setviewvalue' + }, + SharedDataBlockEventSet: { + url: 'https://262.ecma-international.org/10.0/#sec-sharedatablockeventset' + }, + SortCompare: { + url: 'https://262.ecma-international.org/10.0/#sec-sortcompare' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/10.0/#sec-speciesconstructor' + }, + SplitMatch: { + url: 'https://262.ecma-international.org/10.0/#sec-splitmatch' + }, + 'Strict Equality Comparison': { + url: 'https://262.ecma-international.org/10.0/#sec-strict-equality-comparison' + }, + StringCreate: { + url: 'https://262.ecma-international.org/10.0/#sec-stringcreate' + }, + StringGetOwnProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-stringgetownproperty' + }, + Suspend: { + url: 'https://262.ecma-international.org/10.0/#sec-suspend' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/10.0/#sec-symboldescriptivestring' + }, + SynchronizeEventSet: { + url: 'https://262.ecma-international.org/10.0/#sec-synchronizeeventset' + }, + 'synchronizes-with': { + url: 'https://262.ecma-international.org/10.0/#sec-synchronizes-with' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/10.0/#sec-testintegritylevel' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/10.0/#sec-thisbooleanvalue' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/10.0/#sec-thisnumbervalue' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/10.0/#sec-thisstringvalue' + }, + thisSymbolValue: { + url: 'https://262.ecma-international.org/10.0/#sec-thissymbolvalue' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/10.0/#sec-thistimevalue' + }, + ThrowCompletion: { + url: 'https://262.ecma-international.org/10.0/#sec-throwcompletion' + }, + TimeClip: { + url: 'https://262.ecma-international.org/10.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/10.0/#eqn-TimeFromYear' + }, + TimeString: { + url: 'https://262.ecma-international.org/10.0/#sec-timestring' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/10.0/#eqn-TimeWithinDay' + }, + TimeZoneString: { + url: 'https://262.ecma-international.org/10.0/#sec-timezoneestring' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/10.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/10.0/#sec-todatestring' + }, + ToIndex: { + url: 'https://262.ecma-international.org/10.0/#sec-toindex' + }, + ToInt16: { + url: 'https://262.ecma-international.org/10.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/10.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/10.0/#sec-toint8' + }, + ToInteger: { + url: 'https://262.ecma-international.org/10.0/#sec-tointeger' + }, + ToLength: { + url: 'https://262.ecma-international.org/10.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/10.0/#sec-tonumber' + }, + ToObject: { + url: 'https://262.ecma-international.org/10.0/#sec-toobject' + }, + TopLevelModuleEvaluationJob: { + url: 'https://262.ecma-international.org/10.0/#sec-toplevelmoduleevaluationjob' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/10.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/10.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/10.0/#sec-tostring' + }, + ToUint16: { + url: 'https://262.ecma-international.org/10.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/10.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/10.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/10.0/#sec-touint8clamp' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/10.0/#sec-triggerpromisereactions' + }, + TrimString: { + url: 'https://262.ecma-international.org/10.0/#sec-trimstring' + }, + Type: { + url: 'https://262.ecma-international.org/10.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayCreate: { + url: 'https://262.ecma-international.org/10.0/#typedarray-create' + }, + TypedArraySpeciesCreate: { + url: 'https://262.ecma-international.org/10.0/#typedarray-species-create' + }, + UnicodeEscape: { + url: 'https://262.ecma-international.org/10.0/#sec-unicodeescape' + }, + UnicodeMatchProperty: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-unicodematchproperty-p' + }, + UnicodeMatchPropertyValue: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-unicodematchpropertyvalue-p-v' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/10.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/10.0/#sec-utc-t' + }, + UTF16Decode: { + url: 'https://262.ecma-international.org/10.0/#sec-utf16decode' + }, + UTF16Encoding: { + url: 'https://262.ecma-international.org/10.0/#sec-utf16encoding' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/10.0/#sec-validateandapplypropertydescriptor' + }, + ValidateAtomicAccess: { + url: 'https://262.ecma-international.org/10.0/#sec-validateatomicaccess' + }, + ValidateSharedIntegerTypedArray: { + url: 'https://262.ecma-international.org/10.0/#sec-validatesharedintegertypedarray' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/10.0/#sec-validatetypedarray' + }, + ValueOfReadEvent: { + url: 'https://262.ecma-international.org/10.0/#sec-valueofreadevent' + }, + WeekDay: { + url: 'https://262.ecma-international.org/10.0/#sec-week-day' + }, + WordCharacters: { + url: 'https://262.ecma-international.org/10.0/#sec-runtime-semantics-wordcharacters-abstract-operation' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/10.0/#eqn-YearFromTime' + } +}; diff --git a/node_modules/es-abstract/operations/2020.js b/node_modules/es-abstract/operations/2020.js new file mode 100644 index 0000000000000000000000000000000000000000..1e448539f245faf0fcfa7ea5e7d5b657b02ae438 --- /dev/null +++ b/node_modules/es-abstract/operations/2020.js @@ -0,0 +1,1228 @@ +'use strict'; + +module.exports = { + abs: { + url: 'https://262.ecma-international.org/11.0/#eqn-abs' + }, + 'Abstract Equality Comparison': { + url: 'https://262.ecma-international.org/11.0/#sec-abstract-equality-comparison' + }, + 'Abstract Relational Comparison': { + url: 'https://262.ecma-international.org/11.0/#sec-abstract-relational-comparison' + }, + AddEntriesFromIterable: { + url: 'https://262.ecma-international.org/11.0/#sec-add-entries-from-iterable' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/11.0/#sec-addrestrictedfunctionproperties' + }, + AddWaiter: { + url: 'https://262.ecma-international.org/11.0/#sec-addwaiter' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/11.0/#sec-advancestringindex' + }, + 'agent-order': { + url: 'https://262.ecma-international.org/11.0/#sec-agent-order' + }, + AgentCanSuspend: { + url: 'https://262.ecma-international.org/11.0/#sec-agentcansuspend' + }, + AgentSignifier: { + url: 'https://262.ecma-international.org/11.0/#sec-agentsignifier' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-allocatearraybuffer' + }, + AllocateSharedArrayBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-allocatesharedarraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/11.0/#sec-allocatetypedarray' + }, + AllocateTypedArrayBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-allocatetypedarraybuffer' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/11.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-arrayspeciescreate' + }, + AsyncFromSyncIteratorContinuation: { + url: 'https://262.ecma-international.org/11.0/#sec-asyncfromsynciteratorcontinuation' + }, + AsyncFunctionStart: { + url: 'https://262.ecma-international.org/11.0/#sec-async-functions-abstract-operations-async-function-start' + }, + AsyncGeneratorEnqueue: { + url: 'https://262.ecma-international.org/11.0/#sec-asyncgeneratorenqueue' + }, + AsyncGeneratorReject: { + url: 'https://262.ecma-international.org/11.0/#sec-asyncgeneratorreject' + }, + AsyncGeneratorResolve: { + url: 'https://262.ecma-international.org/11.0/#sec-asyncgeneratorresolve' + }, + AsyncGeneratorResumeNext: { + url: 'https://262.ecma-international.org/11.0/#sec-asyncgeneratorresumenext' + }, + AsyncGeneratorStart: { + url: 'https://262.ecma-international.org/11.0/#sec-asyncgeneratorstart' + }, + AsyncGeneratorYield: { + url: 'https://262.ecma-international.org/11.0/#sec-asyncgeneratoryield' + }, + AsyncIteratorClose: { + url: 'https://262.ecma-international.org/11.0/#sec-asynciteratorclose' + }, + AtomicLoad: { + url: 'https://262.ecma-international.org/11.0/#sec-atomicload' + }, + AtomicReadModifyWrite: { + url: 'https://262.ecma-international.org/11.0/#sec-atomicreadmodifywrite' + }, + Await: { + url: 'https://262.ecma-international.org/11.0/#await' + }, + BackreferenceMatcher: { + url: 'https://262.ecma-international.org/11.0/#sec-backreference-matcher' + }, + 'BigInt::add': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add' + }, + 'BigInt::bitwiseAND': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND' + }, + 'BigInt::bitwiseNOT': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT' + }, + 'BigInt::bitwiseOR': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR' + }, + 'BigInt::bitwiseXOR': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR' + }, + 'BigInt::divide': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide' + }, + 'BigInt::equal': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal' + }, + 'BigInt::exponentiate': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate' + }, + 'BigInt::leftShift': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift' + }, + 'BigInt::lessThan': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan' + }, + 'BigInt::multiply': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply' + }, + 'BigInt::remainder': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder' + }, + 'BigInt::sameValue': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValue' + }, + 'BigInt::sameValueZero': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValueZero' + }, + 'BigInt::signedRightShift': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift' + }, + 'BigInt::subtract': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract' + }, + 'BigInt::toString': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring' + }, + 'BigInt::unaryMinus': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus' + }, + 'BigInt::unsignedRightShift': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift' + }, + BigIntBitwiseOp: { + url: 'https://262.ecma-international.org/11.0/#sec-bigintbitwiseop' + }, + BinaryAnd: { + url: 'https://262.ecma-international.org/11.0/#sec-binaryand' + }, + BinaryOr: { + url: 'https://262.ecma-international.org/11.0/#sec-binaryor' + }, + BinaryXor: { + url: 'https://262.ecma-international.org/11.0/#sec-binaryxor' + }, + BlockDeclarationInstantiation: { + url: 'https://262.ecma-international.org/11.0/#sec-blockdeclarationinstantiation' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-boundfunctioncreate' + }, + Call: { + url: 'https://262.ecma-international.org/11.0/#sec-call' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/11.0/#sec-canonicalnumericindexstring' + }, + CaseClauseIsSelected: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-caseclauseisselected' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterRangeOrUnion: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-characterrangeorunion-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-clonearraybuffer' + }, + CodePointAt: { + url: 'https://262.ecma-international.org/11.0/#sec-codepointat' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/11.0/#sec-completion-record-specification-type' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/11.0/#sec-completion-record-specification-type' + }, + ComposeWriteEventBytes: { + url: 'https://262.ecma-international.org/11.0/#sec-composewriteeventbytes' + }, + Construct: { + url: 'https://262.ecma-international.org/11.0/#sec-construct' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/11.0/#sec-copydatablockbytes' + }, + CopyDataProperties: { + url: 'https://262.ecma-international.org/11.0/#sec-copydataproperties' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/11.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/11.0/#sec-createarrayiterator' + }, + CreateAsyncFromSyncIterator: { + url: 'https://262.ecma-international.org/11.0/#sec-createasyncfromsynciterator' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/11.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/11.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/11.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/11.0/#sec-createdynamicfunction' + }, + CreateForInIterator: { + url: 'https://262.ecma-international.org/11.0/#sec-createforiniterator' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/11.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/11.0/#sec-createintrinsics' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/11.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/11.0/#sec-createlistfromarraylike' + }, + CreateListIteratorRecord: { + url: 'https://262.ecma-international.org/11.0/#sec-createlistiteratorRecord' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/11.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/11.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-createmethodproperty' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/11.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/11.0/#sec-createrealm' + }, + CreateRegExpStringIterator: { + url: 'https://262.ecma-international.org/11.0/#sec-createregexpstringiterator' + }, + CreateResolvingFunctions: { + url: 'https://262.ecma-international.org/11.0/#sec-createresolvingfunctions' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/11.0/#sec-createsetiterator' + }, + CreateSharedByteDataBlock: { + url: 'https://262.ecma-international.org/11.0/#sec-createsharedbytedatablock' + }, + CreateStringIterator: { + url: 'https://262.ecma-international.org/11.0/#sec-createstringiterator' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/11.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/11.0/#sec-date-number' + }, + DateString: { + url: 'https://262.ecma-international.org/11.0/#sec-datestring' + }, + Day: { + url: 'https://262.ecma-international.org/11.0/#eqn-Day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/11.0/#eqn-DaysFromYear' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/11.0/#eqn-DaysInYear' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/11.0/#eqn-DayWithinYear' + }, + Decode: { + url: 'https://262.ecma-international.org/11.0/#sec-decode' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/11.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/11.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/11.0/#sec-encode' + }, + EnterCriticalSection: { + url: 'https://262.ecma-international.org/11.0/#sec-entercriticalsection' + }, + EnumerableOwnPropertyNames: { + url: 'https://262.ecma-international.org/11.0/#sec-enumerableownpropertynames' + }, + EnumerateObjectProperties: { + url: 'https://262.ecma-international.org/11.0/#sec-enumerate-object-properties' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/11.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/11.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/11.0/#sec-evaluatecall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/11.0/#sec-evaluatenew' + }, + EvaluatePropertyAccessWithExpressionKey: { + url: 'https://262.ecma-international.org/11.0/#sec-evaluate-property-access-with-expression-key' + }, + EvaluatePropertyAccessWithIdentifierKey: { + url: 'https://262.ecma-international.org/11.0/#sec-evaluate-property-access-with-identifier-key' + }, + EventSet: { + url: 'https://262.ecma-international.org/11.0/#sec-event-set' + }, + ExecuteModule: { + url: 'https://262.ecma-international.org/11.0/#sec-source-text-module-record-execute-module' + }, + FinishDynamicImport: { + url: 'https://262.ecma-international.org/11.0/#sec-finishdynamicimport' + }, + FlattenIntoArray: { + url: 'https://262.ecma-international.org/11.0/#sec-flattenintoarray' + }, + floor: { + url: 'https://262.ecma-international.org/11.0/#eqn-floor' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/11.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-forinofheadevaluation' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/11.0/#sec-fulfillpromise' + }, + FunctionDeclarationInstantiation: { + url: 'https://262.ecma-international.org/11.0/#sec-functiondeclarationinstantiation' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/11.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/11.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/11.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/11.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/11.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/11.0/#sec-get-o-p' + }, + GetActiveScriptOrModule: { + url: 'https://262.ecma-international.org/11.0/#sec-getactivescriptormodule' + }, + GetBase: { + url: 'https://262.ecma-international.org/11.0/#sec-getbase' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/11.0/#sec-getfunctionrealm' + }, + GetGeneratorKind: { + url: 'https://262.ecma-international.org/11.0/#sec-getgeneratorkind' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/11.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/11.0/#sec-getidentifierreference' + }, + GetIterator: { + url: 'https://262.ecma-international.org/11.0/#sec-getiterator' + }, + GetMethod: { + url: 'https://262.ecma-international.org/11.0/#sec-getmethod' + }, + GetModifySetValueInBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-getmodifysetvalueinbuffer' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/11.0/#sec-getmodulenamespace' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/11.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/11.0/#sec-getownpropertykeys' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/11.0/#sec-getprototypefromconstructor' + }, + GetReferencedName: { + url: 'https://262.ecma-international.org/11.0/#sec-getreferencedname' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/11.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/11.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/11.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/11.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/11.0/#sec-getthisvalue' + }, + GetV: { + url: 'https://262.ecma-international.org/11.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/11.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/11.0/#sec-getviewvalue' + }, + GetWaiterList: { + url: 'https://262.ecma-international.org/11.0/#sec-getwaiterlist' + }, + GlobalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/11.0/#sec-globaldeclarationinstantiation' + }, + 'happens-before': { + url: 'https://262.ecma-international.org/11.0/#sec-happens-before' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-hasownproperty' + }, + HasPrimitiveBase: { + url: 'https://262.ecma-international.org/11.0/#sec-hasprimitivebase' + }, + HasProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-hasproperty' + }, + 'host-synchronizes-with': { + url: 'https://262.ecma-international.org/11.0/#sec-host-synchronizes-with' + }, + HostEventSet: { + url: 'https://262.ecma-international.org/11.0/#sec-hosteventset' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/11.0/#eqn-HourFromTime' + }, + IfAbruptRejectPromise: { + url: 'https://262.ecma-international.org/11.0/#sec-ifabruptrejectpromise' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/11.0/#sec-importedlocalnames' + }, + InitializeBoundName: { + url: 'https://262.ecma-international.org/11.0/#sec-initializeboundname' + }, + InitializeEnvironment: { + url: 'https://262.ecma-international.org/11.0/#sec-source-text-module-record-initialize-environment' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/11.0/#sec-initializehostdefinedrealm' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/11.0/#sec-initializereferencedbinding' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/11.0/#eqn-InLeapYear' + }, + InnerModuleEvaluation: { + url: 'https://262.ecma-international.org/11.0/#sec-innermoduleevaluation' + }, + InnerModuleLinking: { + url: 'https://262.ecma-international.org/11.0/#sec-InnerModuleLinking' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/11.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/11.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/11.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/11.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/11.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/11.0/#sec-isarray' + }, + IsBigIntElementType: { + url: 'https://262.ecma-international.org/11.0/#sec-isbigintelementtype' + }, + IsCallable: { + url: 'https://262.ecma-international.org/11.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/11.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/11.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/11.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/11.0/#sec-isintailposition' + }, + IsInteger: { + url: 'https://262.ecma-international.org/11.0/#sec-isinteger' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/11.0/#sec-islabelledfunction' + }, + IsNonNegativeInteger: { + url: 'https://262.ecma-international.org/11.0/#sec-isnonnegativeinteger' + }, + IsNoTearConfiguration: { + url: 'https://262.ecma-international.org/11.0/#sec-isnotearconfiguration' + }, + IsPromise: { + url: 'https://262.ecma-international.org/11.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/11.0/#sec-ispropertykey' + }, + IsPropertyReference: { + url: 'https://262.ecma-international.org/11.0/#sec-ispropertyreference' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/11.0/#sec-isregexp' + }, + IsSharedArrayBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-issharedarraybuffer' + }, + IsStrictReference: { + url: 'https://262.ecma-international.org/11.0/#sec-isstrictreference' + }, + IsStringPrefix: { + url: 'https://262.ecma-international.org/11.0/#sec-isstringprefix' + }, + IsSuperReference: { + url: 'https://262.ecma-international.org/11.0/#sec-issuperreference' + }, + IsUnclampedIntegerElementType: { + url: 'https://262.ecma-international.org/11.0/#sec-isunclampedintegerelementtype' + }, + IsUnresolvableReference: { + url: 'https://262.ecma-international.org/11.0/#sec-isunresolvablereference' + }, + IsUnsignedElementType: { + url: 'https://262.ecma-international.org/11.0/#sec-isunsignedelementtype' + }, + IsValidIntegerIndex: { + url: 'https://262.ecma-international.org/11.0/#sec-isvalidintegerindex' + }, + IsValidRegularExpressionLiteral: { + url: 'https://262.ecma-international.org/11.0/#sec-isvalidregularexpressionliteral' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IterableToList: { + url: 'https://262.ecma-international.org/11.0/#sec-iterabletolist' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/11.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/11.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/11.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/11.0/#sec-iteratorstep' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/11.0/#sec-iteratorvalue' + }, + LeaveCriticalSection: { + url: 'https://262.ecma-international.org/11.0/#sec-leavecriticalsection' + }, + LengthOfArrayLike: { + url: 'https://262.ecma-international.org/11.0/#sec-lengthofarraylike' + }, + LocalTime: { + url: 'https://262.ecma-international.org/11.0/#sec-localtime' + }, + LocalTZA: { + url: 'https://262.ecma-international.org/11.0/#sec-local-time-zone-adjustment' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/11.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/11.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/11.0/#sec-makeargsetter' + }, + MakeBasicObject: { + url: 'https://262.ecma-international.org/11.0/#sec-makebasicobject' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/11.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/11.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/11.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/11.0/#sec-makeday' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/11.0/#sec-makemethod' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/11.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/11.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/11.0/#eqn-max' + }, + 'memory-order': { + url: 'https://262.ecma-international.org/11.0/#sec-memory-order' + }, + min: { + url: 'https://262.ecma-international.org/11.0/#eqn-min' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/11.0/#eqn-MinFromTime' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/11.0/#eqn-modulo' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/11.0/#eqn-MonthFromTime' + }, + msFromTime: { + url: 'https://262.ecma-international.org/11.0/#eqn-msFromTime' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/11.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/11.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/11.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/11.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/11.0/#sec-newobjectenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/11.0/#sec-newpromisecapability' + }, + NewPromiseReactionJob: { + url: 'https://262.ecma-international.org/11.0/#sec-newpromisereactionjob' + }, + NewPromiseResolveThenableJob: { + url: 'https://262.ecma-international.org/11.0/#sec-newpromiseresolvethenablejob' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/11.0/#sec-normalcompletion' + }, + NotifyWaiter: { + url: 'https://262.ecma-international.org/11.0/#sec-notifywaiter' + }, + 'Number::add': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-add' + }, + 'Number::bitwiseAND': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseAND' + }, + 'Number::bitwiseNOT': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseNOT' + }, + 'Number::bitwiseOR': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseOR' + }, + 'Number::bitwiseXOR': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseXOR' + }, + 'Number::divide': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-divide' + }, + 'Number::equal': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-equal' + }, + 'Number::exponentiate': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-exponentiate' + }, + 'Number::leftShift': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-leftShift' + }, + 'Number::lessThan': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-lessThan' + }, + 'Number::multiply': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-multiply' + }, + 'Number::remainder': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-remainder' + }, + 'Number::sameValue': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-sameValue' + }, + 'Number::sameValueZero': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-sameValueZero' + }, + 'Number::signedRightShift': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-signedRightShift' + }, + 'Number::subtract': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-subtract' + }, + 'Number::toString': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-tostring' + }, + 'Number::unaryMinus': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-unaryMinus' + }, + 'Number::unsignedRightShift': { + url: 'https://262.ecma-international.org/11.0/#sec-numeric-types-number-unsignedRightShift' + }, + NumberBitwiseOp: { + url: 'https://262.ecma-international.org/11.0/#sec-numberbitwiseop' + }, + NumberToBigInt: { + url: 'https://262.ecma-international.org/11.0/#sec-numbertobigint' + }, + NumericToRawBytes: { + url: 'https://262.ecma-international.org/11.0/#sec-numerictorawbytes' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/11.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarydefineownproperty' + }, + OrdinaryDelete: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarydelete' + }, + OrdinaryFunctionCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinaryfunctioncreate' + }, + OrdinaryGet: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinaryget' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarygetownproperty' + }, + OrdinaryGetPrototypeOf: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarygetprototypeof' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinaryhasproperty' + }, + OrdinaryIsExtensible: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinaryisextensible' + }, + OrdinaryObjectCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinaryobjectcreate' + }, + OrdinaryOwnPropertyKeys: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinaryownpropertykeys' + }, + OrdinaryPreventExtensions: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarypreventextensions' + }, + OrdinarySet: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinaryset' + }, + OrdinarySetPrototypeOf: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarysetprototypeof' + }, + OrdinarySetWithOwnDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarysetwithowndescriptor' + }, + OrdinaryToPrimitive: { + url: 'https://262.ecma-international.org/11.0/#sec-ordinarytoprimitive' + }, + ParseModule: { + url: 'https://262.ecma-international.org/11.0/#sec-parsemodule' + }, + ParseScript: { + url: 'https://262.ecma-international.org/11.0/#sec-parse-script' + }, + PerformEval: { + url: 'https://262.ecma-international.org/11.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/11.0/#sec-performpromiseall' + }, + PerformPromiseAllSettled: { + url: 'https://262.ecma-international.org/11.0/#sec-performpromiseallsettled' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/11.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/11.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/11.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/11.0/#sec-preparefortailcall' + }, + PromiseResolve: { + url: 'https://262.ecma-international.org/11.0/#sec-promise-resolve' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/11.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/11.0/#sec-quotejsonstring' + }, + RawBytesToNumeric: { + url: 'https://262.ecma-international.org/11.0/#sec-rawbytestonumeric' + }, + 'reads-bytes-from': { + url: 'https://262.ecma-international.org/11.0/#sec-reads-bytes-from' + }, + 'reads-from': { + url: 'https://262.ecma-international.org/11.0/#sec-reads-from' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/11.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/11.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/11.0/#sec-regexpexec' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/11.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/11.0/#sec-rejectpromise' + }, + RemoveWaiter: { + url: 'https://262.ecma-international.org/11.0/#sec-removewaiter' + }, + RemoveWaiters: { + url: 'https://262.ecma-international.org/11.0/#sec-removewaiters' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireInternalSlot: { + url: 'https://262.ecma-international.org/11.0/#sec-requireinternalslot' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/11.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/11.0/#sec-resolvebinding' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/11.0/#sec-resolvethisbinding' + }, + ReturnIfAbrupt: { + url: 'https://262.ecma-international.org/11.0/#sec-returnifabrupt' + }, + SameValue: { + url: 'https://262.ecma-international.org/11.0/#sec-samevalue' + }, + SameValueNonNumeric: { + url: 'https://262.ecma-international.org/11.0/#sec-samevaluenonnumeric' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/11.0/#sec-samevaluezero' + }, + ScriptEvaluation: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-scriptevaluation' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/11.0/#eqn-SecFromTime' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/11.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/11.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/11.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/11.0/#sec-setdefaultglobalbindings' + }, + SetFunctionLength: { + url: 'https://262.ecma-international.org/11.0/#sec-setfunctionlength' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/11.0/#sec-setfunctionname' + }, + SetImmutablePrototype: { + url: 'https://262.ecma-international.org/11.0/#sec-set-immutable-prototype' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/11.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/11.0/#sec-setrealmglobalobject' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/11.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/11.0/#sec-setviewvalue' + }, + SharedDataBlockEventSet: { + url: 'https://262.ecma-international.org/11.0/#sec-sharedatablockeventset' + }, + SortCompare: { + url: 'https://262.ecma-international.org/11.0/#sec-sortcompare' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/11.0/#sec-speciesconstructor' + }, + SplitMatch: { + url: 'https://262.ecma-international.org/11.0/#sec-splitmatch' + }, + 'Strict Equality Comparison': { + url: 'https://262.ecma-international.org/11.0/#sec-strict-equality-comparison' + }, + StringCreate: { + url: 'https://262.ecma-international.org/11.0/#sec-stringcreate' + }, + StringGetOwnProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-stringgetownproperty' + }, + StringPad: { + url: 'https://262.ecma-international.org/11.0/#sec-stringpad' + }, + StringToBigInt: { + url: 'https://262.ecma-international.org/11.0/#sec-stringtobigint' + }, + Suspend: { + url: 'https://262.ecma-international.org/11.0/#sec-suspend' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/11.0/#sec-symboldescriptivestring' + }, + 'synchronizes-with': { + url: 'https://262.ecma-international.org/11.0/#sec-synchronizes-with' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/11.0/#sec-testintegritylevel' + }, + thisBigIntValue: { + url: 'https://262.ecma-international.org/11.0/#sec-thisbigintvalue' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/11.0/#sec-thisbooleanvalue' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/11.0/#sec-thisnumbervalue' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/11.0/#sec-thisstringvalue' + }, + thisSymbolValue: { + url: 'https://262.ecma-international.org/11.0/#sec-thissymbolvalue' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/11.0/#sec-thistimevalue' + }, + ThrowCompletion: { + url: 'https://262.ecma-international.org/11.0/#sec-throwcompletion' + }, + TimeClip: { + url: 'https://262.ecma-international.org/11.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/11.0/#eqn-TimeFromYear' + }, + TimeString: { + url: 'https://262.ecma-international.org/11.0/#sec-timestring' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/11.0/#eqn-TimeWithinDay' + }, + TimeZoneString: { + url: 'https://262.ecma-international.org/11.0/#sec-timezoneestring' + }, + ToBigInt: { + url: 'https://262.ecma-international.org/11.0/#sec-tobigint' + }, + ToBigInt64: { + url: 'https://262.ecma-international.org/11.0/#sec-tobigint64' + }, + ToBigUint64: { + url: 'https://262.ecma-international.org/11.0/#sec-tobiguint64' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/11.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/11.0/#sec-todatestring' + }, + ToIndex: { + url: 'https://262.ecma-international.org/11.0/#sec-toindex' + }, + ToInt16: { + url: 'https://262.ecma-international.org/11.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/11.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/11.0/#sec-toint8' + }, + ToInteger: { + url: 'https://262.ecma-international.org/11.0/#sec-tointeger' + }, + ToLength: { + url: 'https://262.ecma-international.org/11.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/11.0/#sec-tonumber' + }, + ToNumeric: { + url: 'https://262.ecma-international.org/11.0/#sec-tonumeric' + }, + ToObject: { + url: 'https://262.ecma-international.org/11.0/#sec-toobject' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/11.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/11.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/11.0/#sec-tostring' + }, + ToUint16: { + url: 'https://262.ecma-international.org/11.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/11.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/11.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/11.0/#sec-touint8clamp' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/11.0/#sec-triggerpromisereactions' + }, + TrimString: { + url: 'https://262.ecma-international.org/11.0/#sec-trimstring' + }, + Type: { + url: 'https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayCreate: { + url: 'https://262.ecma-international.org/11.0/#typedarray-create' + }, + TypedArraySpeciesCreate: { + url: 'https://262.ecma-international.org/11.0/#typedarray-species-create' + }, + UnicodeEscape: { + url: 'https://262.ecma-international.org/11.0/#sec-unicodeescape' + }, + UnicodeMatchProperty: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-unicodematchproperty-p' + }, + UnicodeMatchPropertyValue: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-unicodematchpropertyvalue-p-v' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/11.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/11.0/#sec-utc-t' + }, + UTF16DecodeString: { + url: 'https://262.ecma-international.org/11.0/#sec-utf16decodestring' + }, + UTF16DecodeSurrogatePair: { + url: 'https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair' + }, + UTF16Encode: { + url: 'https://262.ecma-international.org/11.0/#sec-utf16encode' + }, + UTF16Encoding: { + url: 'https://262.ecma-international.org/11.0/#sec-utf16encoding' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/11.0/#sec-validateandapplypropertydescriptor' + }, + ValidateAtomicAccess: { + url: 'https://262.ecma-international.org/11.0/#sec-validateatomicaccess' + }, + ValidateSharedIntegerTypedArray: { + url: 'https://262.ecma-international.org/11.0/#sec-validatesharedintegertypedarray' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/11.0/#sec-validatetypedarray' + }, + ValueOfReadEvent: { + url: 'https://262.ecma-international.org/11.0/#sec-valueofreadevent' + }, + WeekDay: { + url: 'https://262.ecma-international.org/11.0/#sec-week-day' + }, + WordCharacters: { + url: 'https://262.ecma-international.org/11.0/#sec-runtime-semantics-wordcharacters-abstract-operation' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/11.0/#eqn-YearFromTime' + } +}; diff --git a/node_modules/es-abstract/operations/2021.js b/node_modules/es-abstract/operations/2021.js new file mode 100644 index 0000000000000000000000000000000000000000..7d4ff210a596d7364a063af5b392f7f28bda94f2 --- /dev/null +++ b/node_modules/es-abstract/operations/2021.js @@ -0,0 +1,1282 @@ +'use strict'; + +module.exports = { + abs: { + url: 'https://262.ecma-international.org/12.0/#eqn-abs' + }, + 'Abstract Equality Comparison': { + url: 'https://262.ecma-international.org/12.0/#sec-abstract-equality-comparison' + }, + 'Abstract Relational Comparison': { + url: 'https://262.ecma-international.org/12.0/#sec-abstract-relational-comparison' + }, + AddEntriesFromIterable: { + url: 'https://262.ecma-international.org/12.0/#sec-add-entries-from-iterable' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/12.0/#sec-addrestrictedfunctionproperties' + }, + AddToKeptObjects: { + url: 'https://262.ecma-international.org/12.0/#sec-addtokeptobjects' + }, + AddWaiter: { + url: 'https://262.ecma-international.org/12.0/#sec-addwaiter' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/12.0/#sec-advancestringindex' + }, + 'agent-order': { + url: 'https://262.ecma-international.org/12.0/#sec-agent-order' + }, + AgentCanSuspend: { + url: 'https://262.ecma-international.org/12.0/#sec-agentcansuspend' + }, + AgentSignifier: { + url: 'https://262.ecma-international.org/12.0/#sec-agentsignifier' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-allocatearraybuffer' + }, + AllocateSharedArrayBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-allocatesharedarraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/12.0/#sec-allocatetypedarray' + }, + AllocateTypedArrayBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-allocatetypedarraybuffer' + }, + ApplyStringOrNumericBinaryOperator: { + url: 'https://262.ecma-international.org/12.0/#sec-applystringornumericbinaryoperator' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/12.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-arrayspeciescreate' + }, + AsyncFromSyncIteratorContinuation: { + url: 'https://262.ecma-international.org/12.0/#sec-asyncfromsynciteratorcontinuation' + }, + AsyncFunctionStart: { + url: 'https://262.ecma-international.org/12.0/#sec-async-functions-abstract-operations-async-function-start' + }, + AsyncGeneratorEnqueue: { + url: 'https://262.ecma-international.org/12.0/#sec-asyncgeneratorenqueue' + }, + AsyncGeneratorReject: { + url: 'https://262.ecma-international.org/12.0/#sec-asyncgeneratorreject' + }, + AsyncGeneratorResolve: { + url: 'https://262.ecma-international.org/12.0/#sec-asyncgeneratorresolve' + }, + AsyncGeneratorResumeNext: { + url: 'https://262.ecma-international.org/12.0/#sec-asyncgeneratorresumenext' + }, + AsyncGeneratorStart: { + url: 'https://262.ecma-international.org/12.0/#sec-asyncgeneratorstart' + }, + AsyncGeneratorValidate: { + url: 'https://262.ecma-international.org/12.0/#sec-asyncgeneratorvalidate' + }, + AsyncGeneratorYield: { + url: 'https://262.ecma-international.org/12.0/#sec-asyncgeneratoryield' + }, + AsyncIteratorClose: { + url: 'https://262.ecma-international.org/12.0/#sec-asynciteratorclose' + }, + AtomicReadModifyWrite: { + url: 'https://262.ecma-international.org/12.0/#sec-atomicreadmodifywrite' + }, + Await: { + url: 'https://262.ecma-international.org/12.0/#await' + }, + BackreferenceMatcher: { + url: 'https://262.ecma-international.org/12.0/#sec-backreference-matcher' + }, + 'BigInt::add': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-add' + }, + 'BigInt::bitwiseAND': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-bitwiseAND' + }, + 'BigInt::bitwiseNOT': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-bitwiseNOT' + }, + 'BigInt::bitwiseOR': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-bitwiseOR' + }, + 'BigInt::bitwiseXOR': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-bitwiseXOR' + }, + 'BigInt::divide': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-divide' + }, + 'BigInt::equal': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-equal' + }, + 'BigInt::exponentiate': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-exponentiate' + }, + 'BigInt::leftShift': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-leftShift' + }, + 'BigInt::lessThan': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-lessThan' + }, + 'BigInt::multiply': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-multiply' + }, + 'BigInt::remainder': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-remainder' + }, + 'BigInt::sameValue': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-sameValue' + }, + 'BigInt::sameValueZero': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-sameValueZero' + }, + 'BigInt::signedRightShift': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-signedRightShift' + }, + 'BigInt::subtract': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-subtract' + }, + 'BigInt::toString': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-tostring' + }, + 'BigInt::unaryMinus': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-unaryMinus' + }, + 'BigInt::unsignedRightShift': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-bigint-unsignedRightShift' + }, + BigIntBitwiseOp: { + url: 'https://262.ecma-international.org/12.0/#sec-bigintbitwiseop' + }, + BinaryAnd: { + url: 'https://262.ecma-international.org/12.0/#sec-binaryand' + }, + BinaryOr: { + url: 'https://262.ecma-international.org/12.0/#sec-binaryor' + }, + BinaryXor: { + url: 'https://262.ecma-international.org/12.0/#sec-binaryxor' + }, + BlockDeclarationInstantiation: { + url: 'https://262.ecma-international.org/12.0/#sec-blockdeclarationinstantiation' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-boundfunctioncreate' + }, + ByteListBitwiseOp: { + url: 'https://262.ecma-international.org/12.0/#sec-bytelistbitwiseop' + }, + ByteListEqual: { + url: 'https://262.ecma-international.org/12.0/#sec-bytelistequal' + }, + Call: { + url: 'https://262.ecma-international.org/12.0/#sec-call' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/12.0/#sec-canonicalnumericindexstring' + }, + CaseClauseIsSelected: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-caseclauseisselected' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterRangeOrUnion: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-characterrangeorunion-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + clamp: { + url: 'https://262.ecma-international.org/12.0/#clamping' + }, + CleanupFinalizationRegistry: { + url: 'https://262.ecma-international.org/12.0/#sec-cleanup-finalization-registry' + }, + ClearKeptObjects: { + url: 'https://262.ecma-international.org/12.0/#sec-clear-kept-objects' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-clonearraybuffer' + }, + CodePointAt: { + url: 'https://262.ecma-international.org/12.0/#sec-codepointat' + }, + CodePointsToString: { + url: 'https://262.ecma-international.org/12.0/#sec-codepointstostring' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/12.0/#sec-completion-record-specification-type' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/12.0/#sec-completion-record-specification-type' + }, + ComposeWriteEventBytes: { + url: 'https://262.ecma-international.org/12.0/#sec-composewriteeventbytes' + }, + Construct: { + url: 'https://262.ecma-international.org/12.0/#sec-construct' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/12.0/#sec-copydatablockbytes' + }, + CopyDataProperties: { + url: 'https://262.ecma-international.org/12.0/#sec-copydataproperties' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/12.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/12.0/#sec-createarrayiterator' + }, + CreateAsyncFromSyncIterator: { + url: 'https://262.ecma-international.org/12.0/#sec-createasyncfromsynciterator' + }, + CreateAsyncIteratorFromClosure: { + url: 'https://262.ecma-international.org/12.0/#sec-createasynciteratorfromclosure' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/12.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/12.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/12.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/12.0/#sec-createdynamicfunction' + }, + CreateForInIterator: { + url: 'https://262.ecma-international.org/12.0/#sec-createforiniterator' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/12.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/12.0/#sec-createintrinsics' + }, + CreateIteratorFromClosure: { + url: 'https://262.ecma-international.org/12.0/#sec-createiteratorfromclosure' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/12.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/12.0/#sec-createlistfromarraylike' + }, + CreateListIteratorRecord: { + url: 'https://262.ecma-international.org/12.0/#sec-createlistiteratorRecord' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/12.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/12.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-createmethodproperty' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/12.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/12.0/#sec-createrealm' + }, + CreateRegExpStringIterator: { + url: 'https://262.ecma-international.org/12.0/#sec-createregexpstringiterator' + }, + CreateResolvingFunctions: { + url: 'https://262.ecma-international.org/12.0/#sec-createresolvingfunctions' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/12.0/#sec-createsetiterator' + }, + CreateSharedByteDataBlock: { + url: 'https://262.ecma-international.org/12.0/#sec-createsharedbytedatablock' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/12.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/12.0/#sec-date-number' + }, + DateString: { + url: 'https://262.ecma-international.org/12.0/#sec-datestring' + }, + Day: { + url: 'https://262.ecma-international.org/12.0/#eqn-Day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/12.0/#eqn-DaysFromYear' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/12.0/#eqn-DaysInYear' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/12.0/#eqn-DayWithinYear' + }, + Decode: { + url: 'https://262.ecma-international.org/12.0/#sec-decode' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/12.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/12.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/12.0/#sec-encode' + }, + EnterCriticalSection: { + url: 'https://262.ecma-international.org/12.0/#sec-entercriticalsection' + }, + EnumerableOwnPropertyNames: { + url: 'https://262.ecma-international.org/12.0/#sec-enumerableownpropertynames' + }, + EnumerateObjectProperties: { + url: 'https://262.ecma-international.org/12.0/#sec-enumerate-object-properties' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/12.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/12.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/12.0/#sec-evaluatecall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/12.0/#sec-evaluatenew' + }, + EvaluatePropertyAccessWithExpressionKey: { + url: 'https://262.ecma-international.org/12.0/#sec-evaluate-property-access-with-expression-key' + }, + EvaluatePropertyAccessWithIdentifierKey: { + url: 'https://262.ecma-international.org/12.0/#sec-evaluate-property-access-with-identifier-key' + }, + EvaluateStringOrNumericBinaryExpression: { + url: 'https://262.ecma-international.org/12.0/#sec-evaluatestringornumericbinaryexpression' + }, + EventSet: { + url: 'https://262.ecma-international.org/12.0/#sec-event-set' + }, + ExecuteModule: { + url: 'https://262.ecma-international.org/12.0/#sec-source-text-module-record-execute-module' + }, + FinishDynamicImport: { + url: 'https://262.ecma-international.org/12.0/#sec-finishdynamicimport' + }, + FlattenIntoArray: { + url: 'https://262.ecma-international.org/12.0/#sec-flattenintoarray' + }, + floor: { + url: 'https://262.ecma-international.org/12.0/#eqn-floor' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/12.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-forinofheadevaluation' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/12.0/#sec-fulfillpromise' + }, + FunctionDeclarationInstantiation: { + url: 'https://262.ecma-international.org/12.0/#sec-functiondeclarationinstantiation' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/12.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/12.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/12.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/12.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/12.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/12.0/#sec-get-o-p' + }, + GetActiveScriptOrModule: { + url: 'https://262.ecma-international.org/12.0/#sec-getactivescriptormodule' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/12.0/#sec-getfunctionrealm' + }, + GetGeneratorKind: { + url: 'https://262.ecma-international.org/12.0/#sec-getgeneratorkind' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/12.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/12.0/#sec-getidentifierreference' + }, + GetIterator: { + url: 'https://262.ecma-international.org/12.0/#sec-getiterator' + }, + GetMethod: { + url: 'https://262.ecma-international.org/12.0/#sec-getmethod' + }, + GetModifySetValueInBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-getmodifysetvalueinbuffer' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/12.0/#sec-getmodulenamespace' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/12.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/12.0/#sec-getownpropertykeys' + }, + GetPromiseResolve: { + url: 'https://262.ecma-international.org/12.0/#sec-getpromiseresolve' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/12.0/#sec-getprototypefromconstructor' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/12.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/12.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/12.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/12.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/12.0/#sec-getthisvalue' + }, + GetV: { + url: 'https://262.ecma-international.org/12.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/12.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/12.0/#sec-getviewvalue' + }, + GetWaiterList: { + url: 'https://262.ecma-international.org/12.0/#sec-getwaiterlist' + }, + GlobalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/12.0/#sec-globaldeclarationinstantiation' + }, + 'happens-before': { + url: 'https://262.ecma-international.org/12.0/#sec-happens-before' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-hasownproperty' + }, + HasProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-hasproperty' + }, + 'host-synchronizes-with': { + url: 'https://262.ecma-international.org/12.0/#sec-host-synchronizes-with' + }, + HostEventSet: { + url: 'https://262.ecma-international.org/12.0/#sec-hosteventset' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/12.0/#eqn-HourFromTime' + }, + IfAbruptRejectPromise: { + url: 'https://262.ecma-international.org/12.0/#sec-ifabruptrejectpromise' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/12.0/#sec-importedlocalnames' + }, + InitializeBoundName: { + url: 'https://262.ecma-international.org/12.0/#sec-initializeboundname' + }, + InitializeEnvironment: { + url: 'https://262.ecma-international.org/12.0/#sec-source-text-module-record-initialize-environment' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/12.0/#sec-initializehostdefinedrealm' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/12.0/#sec-initializereferencedbinding' + }, + InitializeTypedArrayFromArrayBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-initializetypedarrayfromarraybuffer' + }, + InitializeTypedArrayFromArrayLike: { + url: 'https://262.ecma-international.org/12.0/#sec-initializetypedarrayfromarraylike' + }, + InitializeTypedArrayFromList: { + url: 'https://262.ecma-international.org/12.0/#sec-initializetypedarrayfromlist' + }, + InitializeTypedArrayFromTypedArray: { + url: 'https://262.ecma-international.org/12.0/#sec-initializetypedarrayfromtypedarray' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/12.0/#eqn-InLeapYear' + }, + InnerModuleEvaluation: { + url: 'https://262.ecma-international.org/12.0/#sec-innermoduleevaluation' + }, + InnerModuleLinking: { + url: 'https://262.ecma-international.org/12.0/#sec-InnerModuleLinking' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/12.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/12.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/12.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/12.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/12.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/12.0/#sec-isarray' + }, + IsBigIntElementType: { + url: 'https://262.ecma-international.org/12.0/#sec-isbigintelementtype' + }, + IsCallable: { + url: 'https://262.ecma-international.org/12.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/12.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/12.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/12.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/12.0/#sec-isintailposition' + }, + IsIntegralNumber: { + url: 'https://262.ecma-international.org/12.0/#sec-isintegralnumber' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/12.0/#sec-islabelledfunction' + }, + IsNoTearConfiguration: { + url: 'https://262.ecma-international.org/12.0/#sec-isnotearconfiguration' + }, + IsPromise: { + url: 'https://262.ecma-international.org/12.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/12.0/#sec-ispropertykey' + }, + IsPropertyReference: { + url: 'https://262.ecma-international.org/12.0/#sec-ispropertyreference' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/12.0/#sec-isregexp' + }, + IsSharedArrayBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-issharedarraybuffer' + }, + IsStringPrefix: { + url: 'https://262.ecma-international.org/12.0/#sec-isstringprefix' + }, + IsSuperReference: { + url: 'https://262.ecma-international.org/12.0/#sec-issuperreference' + }, + IsUnclampedIntegerElementType: { + url: 'https://262.ecma-international.org/12.0/#sec-isunclampedintegerelementtype' + }, + IsUnresolvableReference: { + url: 'https://262.ecma-international.org/12.0/#sec-isunresolvablereference' + }, + IsUnsignedElementType: { + url: 'https://262.ecma-international.org/12.0/#sec-isunsignedelementtype' + }, + IsValidIntegerIndex: { + url: 'https://262.ecma-international.org/12.0/#sec-isvalidintegerindex' + }, + IsValidRegularExpressionLiteral: { + url: 'https://262.ecma-international.org/12.0/#sec-isvalidregularexpressionliteral' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IterableToList: { + url: 'https://262.ecma-international.org/12.0/#sec-iterabletolist' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/12.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/12.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/12.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/12.0/#sec-iteratorstep' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/12.0/#sec-iteratorvalue' + }, + LeaveCriticalSection: { + url: 'https://262.ecma-international.org/12.0/#sec-leavecriticalsection' + }, + LengthOfArrayLike: { + url: 'https://262.ecma-international.org/12.0/#sec-lengthofarraylike' + }, + LocalTime: { + url: 'https://262.ecma-international.org/12.0/#sec-localtime' + }, + LocalTZA: { + url: 'https://262.ecma-international.org/12.0/#sec-local-time-zone-adjustment' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/12.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/12.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/12.0/#sec-makeargsetter' + }, + MakeBasicObject: { + url: 'https://262.ecma-international.org/12.0/#sec-makebasicobject' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/12.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/12.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/12.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/12.0/#sec-makeday' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/12.0/#sec-makemethod' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/12.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/12.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/12.0/#eqn-max' + }, + 'memory-order': { + url: 'https://262.ecma-international.org/12.0/#sec-memory-order' + }, + min: { + url: 'https://262.ecma-international.org/12.0/#eqn-min' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/12.0/#eqn-MinFromTime' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/12.0/#eqn-modulo' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/12.0/#eqn-MonthFromTime' + }, + msFromTime: { + url: 'https://262.ecma-international.org/12.0/#eqn-msFromTime' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/12.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/12.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/12.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/12.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/12.0/#sec-newobjectenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/12.0/#sec-newpromisecapability' + }, + NewPromiseReactionJob: { + url: 'https://262.ecma-international.org/12.0/#sec-newpromisereactionjob' + }, + NewPromiseResolveThenableJob: { + url: 'https://262.ecma-international.org/12.0/#sec-newpromiseresolvethenablejob' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/12.0/#sec-normalcompletion' + }, + NotifyWaiter: { + url: 'https://262.ecma-international.org/12.0/#sec-notifywaiter' + }, + 'Number::add': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-add' + }, + 'Number::bitwiseAND': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-bitwiseAND' + }, + 'Number::bitwiseNOT': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-bitwiseNOT' + }, + 'Number::bitwiseOR': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-bitwiseOR' + }, + 'Number::bitwiseXOR': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-bitwiseXOR' + }, + 'Number::divide': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-divide' + }, + 'Number::equal': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-equal' + }, + 'Number::exponentiate': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-exponentiate' + }, + 'Number::leftShift': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-leftShift' + }, + 'Number::lessThan': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-lessThan' + }, + 'Number::multiply': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-multiply' + }, + 'Number::remainder': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-remainder' + }, + 'Number::sameValue': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-sameValue' + }, + 'Number::sameValueZero': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-sameValueZero' + }, + 'Number::signedRightShift': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-signedRightShift' + }, + 'Number::subtract': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-subtract' + }, + 'Number::toString': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-tostring' + }, + 'Number::unaryMinus': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-unaryMinus' + }, + 'Number::unsignedRightShift': { + url: 'https://262.ecma-international.org/12.0/#sec-numeric-types-number-unsignedRightShift' + }, + NumberBitwiseOp: { + url: 'https://262.ecma-international.org/12.0/#sec-numberbitwiseop' + }, + NumberToBigInt: { + url: 'https://262.ecma-international.org/12.0/#sec-numbertobigint' + }, + NumericToRawBytes: { + url: 'https://262.ecma-international.org/12.0/#sec-numerictorawbytes' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/12.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarydefineownproperty' + }, + OrdinaryDelete: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarydelete' + }, + OrdinaryFunctionCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinaryfunctioncreate' + }, + OrdinaryGet: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinaryget' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarygetownproperty' + }, + OrdinaryGetPrototypeOf: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarygetprototypeof' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinaryhasproperty' + }, + OrdinaryIsExtensible: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinaryisextensible' + }, + OrdinaryObjectCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinaryobjectcreate' + }, + OrdinaryOwnPropertyKeys: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinaryownpropertykeys' + }, + OrdinaryPreventExtensions: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarypreventextensions' + }, + OrdinarySet: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinaryset' + }, + OrdinarySetPrototypeOf: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarysetprototypeof' + }, + OrdinarySetWithOwnDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarysetwithowndescriptor' + }, + OrdinaryToPrimitive: { + url: 'https://262.ecma-international.org/12.0/#sec-ordinarytoprimitive' + }, + ParseModule: { + url: 'https://262.ecma-international.org/12.0/#sec-parsemodule' + }, + ParsePattern: { + url: 'https://262.ecma-international.org/12.0/#sec-parsepattern' + }, + ParseScript: { + url: 'https://262.ecma-international.org/12.0/#sec-parse-script' + }, + ParseText: { + url: 'https://262.ecma-international.org/12.0/#sec-parsetext' + }, + PerformEval: { + url: 'https://262.ecma-international.org/12.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/12.0/#sec-performpromiseall' + }, + PerformPromiseAllSettled: { + url: 'https://262.ecma-international.org/12.0/#sec-performpromiseallsettled' + }, + PerformPromiseAny: { + url: 'https://262.ecma-international.org/12.0/#sec-performpromiseany' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/12.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/12.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/12.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/12.0/#sec-preparefortailcall' + }, + PromiseResolve: { + url: 'https://262.ecma-international.org/12.0/#sec-promise-resolve' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/12.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/12.0/#sec-quotejsonstring' + }, + RawBytesToNumeric: { + url: 'https://262.ecma-international.org/12.0/#sec-rawbytestonumeric' + }, + 'reads-bytes-from': { + url: 'https://262.ecma-international.org/12.0/#sec-reads-bytes-from' + }, + 'reads-from': { + url: 'https://262.ecma-international.org/12.0/#sec-reads-from' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/12.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/12.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/12.0/#sec-regexpexec' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/12.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/12.0/#sec-rejectpromise' + }, + RemoveWaiter: { + url: 'https://262.ecma-international.org/12.0/#sec-removewaiter' + }, + RemoveWaiters: { + url: 'https://262.ecma-international.org/12.0/#sec-removewaiters' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireInternalSlot: { + url: 'https://262.ecma-international.org/12.0/#sec-requireinternalslot' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/12.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/12.0/#sec-resolvebinding' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/12.0/#sec-resolvethisbinding' + }, + ReturnIfAbrupt: { + url: 'https://262.ecma-international.org/12.0/#sec-returnifabrupt' + }, + SameValue: { + url: 'https://262.ecma-international.org/12.0/#sec-samevalue' + }, + SameValueNonNumeric: { + url: 'https://262.ecma-international.org/12.0/#sec-samevaluenonnumeric' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/12.0/#sec-samevaluezero' + }, + ScriptEvaluation: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-scriptevaluation' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/12.0/#eqn-SecFromTime' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/12.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/12.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/12.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/12.0/#sec-setdefaultglobalbindings' + }, + SetFunctionLength: { + url: 'https://262.ecma-international.org/12.0/#sec-setfunctionlength' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/12.0/#sec-setfunctionname' + }, + SetImmutablePrototype: { + url: 'https://262.ecma-international.org/12.0/#sec-set-immutable-prototype' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/12.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/12.0/#sec-setrealmglobalobject' + }, + SetTypedArrayFromArrayLike: { + url: 'https://262.ecma-international.org/12.0/#sec-settypedarrayfromarraylike' + }, + SetTypedArrayFromTypedArray: { + url: 'https://262.ecma-international.org/12.0/#sec-settypedarrayfromtypedarray' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/12.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/12.0/#sec-setviewvalue' + }, + SharedDataBlockEventSet: { + url: 'https://262.ecma-international.org/12.0/#sec-sharedatablockeventset' + }, + SortCompare: { + url: 'https://262.ecma-international.org/12.0/#sec-sortcompare' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/12.0/#sec-speciesconstructor' + }, + SplitMatch: { + url: 'https://262.ecma-international.org/12.0/#sec-splitmatch' + }, + 'Strict Equality Comparison': { + url: 'https://262.ecma-international.org/12.0/#sec-strict-equality-comparison' + }, + StringCreate: { + url: 'https://262.ecma-international.org/12.0/#sec-stringcreate' + }, + StringGetOwnProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-stringgetownproperty' + }, + StringIndexOf: { + url: 'https://262.ecma-international.org/12.0/#sec-stringindexof' + }, + StringPad: { + url: 'https://262.ecma-international.org/12.0/#sec-stringpad' + }, + StringToBigInt: { + url: 'https://262.ecma-international.org/12.0/#sec-stringtobigint' + }, + StringToCodePoints: { + url: 'https://262.ecma-international.org/12.0/#sec-stringtocodepoints' + }, + substring: { + url: 'https://262.ecma-international.org/12.0/#substring' + }, + SuspendAgent: { + url: 'https://262.ecma-international.org/12.0/#sec-suspendagent' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/12.0/#sec-symboldescriptivestring' + }, + 'synchronizes-with': { + url: 'https://262.ecma-international.org/12.0/#sec-synchronizes-with' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/12.0/#sec-testintegritylevel' + }, + thisBigIntValue: { + url: 'https://262.ecma-international.org/12.0/#thisbigintvalue' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/12.0/#thisbooleanvalue' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/12.0/#thisnumbervalue' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/12.0/#thisstringvalue' + }, + thisSymbolValue: { + url: 'https://262.ecma-international.org/12.0/#thissymbolvalue' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/12.0/#thistimevalue' + }, + ThrowCompletion: { + url: 'https://262.ecma-international.org/12.0/#sec-throwcompletion' + }, + TimeClip: { + url: 'https://262.ecma-international.org/12.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/12.0/#eqn-TimeFromYear' + }, + TimeString: { + url: 'https://262.ecma-international.org/12.0/#sec-timestring' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/12.0/#eqn-TimeWithinDay' + }, + TimeZoneString: { + url: 'https://262.ecma-international.org/12.0/#sec-timezoneestring' + }, + ToBigInt: { + url: 'https://262.ecma-international.org/12.0/#sec-tobigint' + }, + ToBigInt64: { + url: 'https://262.ecma-international.org/12.0/#sec-tobigint64' + }, + ToBigUint64: { + url: 'https://262.ecma-international.org/12.0/#sec-tobiguint64' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/12.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/12.0/#sec-todatestring' + }, + ToIndex: { + url: 'https://262.ecma-international.org/12.0/#sec-toindex' + }, + ToInt16: { + url: 'https://262.ecma-international.org/12.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/12.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/12.0/#sec-toint8' + }, + ToIntegerOrInfinity: { + url: 'https://262.ecma-international.org/12.0/#sec-tointegerorinfinity' + }, + ToLength: { + url: 'https://262.ecma-international.org/12.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/12.0/#sec-tonumber' + }, + ToNumeric: { + url: 'https://262.ecma-international.org/12.0/#sec-tonumeric' + }, + ToObject: { + url: 'https://262.ecma-international.org/12.0/#sec-toobject' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/12.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/12.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/12.0/#sec-tostring' + }, + ToUint16: { + url: 'https://262.ecma-international.org/12.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/12.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/12.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/12.0/#sec-touint8clamp' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/12.0/#sec-triggerpromisereactions' + }, + TrimString: { + url: 'https://262.ecma-international.org/12.0/#sec-trimstring' + }, + Type: { + url: 'https://262.ecma-international.org/12.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayCreate: { + url: 'https://262.ecma-international.org/12.0/#typedarray-create' + }, + TypedArraySpeciesCreate: { + url: 'https://262.ecma-international.org/12.0/#typedarray-species-create' + }, + UnicodeEscape: { + url: 'https://262.ecma-international.org/12.0/#sec-unicodeescape' + }, + UnicodeMatchProperty: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-unicodematchproperty-p' + }, + UnicodeMatchPropertyValue: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-unicodematchpropertyvalue-p-v' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/12.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/12.0/#sec-utc-t' + }, + UTF16EncodeCodePoint: { + url: 'https://262.ecma-international.org/12.0/#sec-utf16encodecodepoint' + }, + UTF16SurrogatePairToCodePoint: { + url: 'https://262.ecma-international.org/12.0/#sec-utf16decodesurrogatepair' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/12.0/#sec-validateandapplypropertydescriptor' + }, + ValidateAtomicAccess: { + url: 'https://262.ecma-international.org/12.0/#sec-validateatomicaccess' + }, + ValidateIntegerTypedArray: { + url: 'https://262.ecma-international.org/12.0/#sec-validateintegertypedarray' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/12.0/#sec-validatetypedarray' + }, + ValueOfReadEvent: { + url: 'https://262.ecma-international.org/12.0/#sec-valueofreadevent' + }, + WeakRefDeref: { + url: 'https://262.ecma-international.org/12.0/#sec-weakrefderef' + }, + WeekDay: { + url: 'https://262.ecma-international.org/12.0/#sec-week-day' + }, + WordCharacters: { + url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-wordcharacters-abstract-operation' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/12.0/#eqn-YearFromTime' + }, + Yield: { + url: 'https://262.ecma-international.org/12.0/#sec-yield' + } +}; diff --git a/node_modules/es-abstract/operations/2022.js b/node_modules/es-abstract/operations/2022.js new file mode 100644 index 0000000000000000000000000000000000000000..f678e68ead1a3123aad026c63857a0077b22af6d --- /dev/null +++ b/node_modules/es-abstract/operations/2022.js @@ -0,0 +1,1372 @@ +'use strict'; + +module.exports = { + abs: { + url: 'https://262.ecma-international.org/13.0/#eqn-abs' + }, + AddEntriesFromIterable: { + url: 'https://262.ecma-international.org/13.0/#sec-add-entries-from-iterable' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/13.0/#sec-addrestrictedfunctionproperties' + }, + AddToKeptObjects: { + url: 'https://262.ecma-international.org/13.0/#sec-addtokeptobjects' + }, + AddWaiter: { + url: 'https://262.ecma-international.org/13.0/#sec-addwaiter' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/13.0/#sec-advancestringindex' + }, + 'agent-order': { + url: 'https://262.ecma-international.org/13.0/#sec-agent-order' + }, + AgentCanSuspend: { + url: 'https://262.ecma-international.org/13.0/#sec-agentcansuspend' + }, + AgentSignifier: { + url: 'https://262.ecma-international.org/13.0/#sec-agentsignifier' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-allocatearraybuffer' + }, + AllocateSharedArrayBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-allocatesharedarraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/13.0/#sec-allocatetypedarray' + }, + AllocateTypedArrayBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-allocatetypedarraybuffer' + }, + ApplyStringOrNumericBinaryOperator: { + url: 'https://262.ecma-international.org/13.0/#sec-applystringornumericbinaryoperator' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/13.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-arrayspeciescreate' + }, + AsyncBlockStart: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncblockstart' + }, + AsyncFromSyncIteratorContinuation: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncfromsynciteratorcontinuation' + }, + AsyncFunctionStart: { + url: 'https://262.ecma-international.org/13.0/#sec-async-functions-abstract-operations-async-function-start' + }, + AsyncGeneratorAwaitReturn: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratorawaitreturn' + }, + AsyncGeneratorCompleteStep: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratorcompletestep' + }, + AsyncGeneratorDrainQueue: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratordrainqueue' + }, + AsyncGeneratorEnqueue: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratorenqueue' + }, + AsyncGeneratorResume: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratorresume' + }, + AsyncGeneratorStart: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratorstart' + }, + AsyncGeneratorUnwrapYieldResumption: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratorunwrapyieldresumption' + }, + AsyncGeneratorValidate: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratorvalidate' + }, + AsyncGeneratorYield: { + url: 'https://262.ecma-international.org/13.0/#sec-asyncgeneratoryield' + }, + AsyncIteratorClose: { + url: 'https://262.ecma-international.org/13.0/#sec-asynciteratorclose' + }, + AsyncModuleExecutionFulfilled: { + url: 'https://262.ecma-international.org/13.0/#sec-async-module-execution-fulfilled' + }, + AsyncModuleExecutionRejected: { + url: 'https://262.ecma-international.org/13.0/#sec-async-module-execution-rejected' + }, + AtomicReadModifyWrite: { + url: 'https://262.ecma-international.org/13.0/#sec-atomicreadmodifywrite' + }, + Await: { + url: 'https://262.ecma-international.org/13.0/#await' + }, + BackreferenceMatcher: { + url: 'https://262.ecma-international.org/13.0/#sec-backreference-matcher' + }, + 'BigInt::add': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-add' + }, + 'BigInt::bitwiseAND': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-bitwiseAND' + }, + 'BigInt::bitwiseNOT': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-bitwiseNOT' + }, + 'BigInt::bitwiseOR': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-bitwiseOR' + }, + 'BigInt::bitwiseXOR': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-bitwiseXOR' + }, + 'BigInt::divide': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-divide' + }, + 'BigInt::equal': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-equal' + }, + 'BigInt::exponentiate': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-exponentiate' + }, + 'BigInt::leftShift': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-leftShift' + }, + 'BigInt::lessThan': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-lessThan' + }, + 'BigInt::multiply': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-multiply' + }, + 'BigInt::remainder': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-remainder' + }, + 'BigInt::sameValue': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-sameValue' + }, + 'BigInt::sameValueZero': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-sameValueZero' + }, + 'BigInt::signedRightShift': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-signedRightShift' + }, + 'BigInt::subtract': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-subtract' + }, + 'BigInt::toString': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-tostring' + }, + 'BigInt::unaryMinus': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-unaryMinus' + }, + 'BigInt::unsignedRightShift': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-bigint-unsignedRightShift' + }, + BigIntBitwiseOp: { + url: 'https://262.ecma-international.org/13.0/#sec-bigintbitwiseop' + }, + BinaryAnd: { + url: 'https://262.ecma-international.org/13.0/#sec-binaryand' + }, + BinaryOr: { + url: 'https://262.ecma-international.org/13.0/#sec-binaryor' + }, + BinaryXor: { + url: 'https://262.ecma-international.org/13.0/#sec-binaryxor' + }, + BlockDeclarationInstantiation: { + url: 'https://262.ecma-international.org/13.0/#sec-blockdeclarationinstantiation' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-boundfunctioncreate' + }, + ByteListBitwiseOp: { + url: 'https://262.ecma-international.org/13.0/#sec-bytelistbitwiseop' + }, + ByteListEqual: { + url: 'https://262.ecma-international.org/13.0/#sec-bytelistequal' + }, + Call: { + url: 'https://262.ecma-international.org/13.0/#sec-call' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/13.0/#sec-canonicalnumericindexstring' + }, + CaseClauseIsSelected: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-caseclauseisselected' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterRangeOrUnion: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-characterrangeorunion-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + clamp: { + url: 'https://262.ecma-international.org/13.0/#clamping' + }, + CleanupFinalizationRegistry: { + url: 'https://262.ecma-international.org/13.0/#sec-cleanup-finalization-registry' + }, + ClearKeptObjects: { + url: 'https://262.ecma-international.org/13.0/#sec-clear-kept-objects' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-clonearraybuffer' + }, + CodePointAt: { + url: 'https://262.ecma-international.org/13.0/#sec-codepointat' + }, + CodePointsToString: { + url: 'https://262.ecma-international.org/13.0/#sec-codepointstostring' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/13.0/#sec-completion-ao' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/13.0/#sec-completion-record-specification-type' + }, + ComposeWriteEventBytes: { + url: 'https://262.ecma-international.org/13.0/#sec-composewriteeventbytes' + }, + Construct: { + url: 'https://262.ecma-international.org/13.0/#sec-construct' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/13.0/#sec-copydatablockbytes' + }, + CopyDataProperties: { + url: 'https://262.ecma-international.org/13.0/#sec-copydataproperties' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/13.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/13.0/#sec-createarrayiterator' + }, + CreateAsyncFromSyncIterator: { + url: 'https://262.ecma-international.org/13.0/#sec-createasyncfromsynciterator' + }, + CreateAsyncIteratorFromClosure: { + url: 'https://262.ecma-international.org/13.0/#sec-createasynciteratorfromclosure' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/13.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/13.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/13.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/13.0/#sec-createdynamicfunction' + }, + CreateForInIterator: { + url: 'https://262.ecma-international.org/13.0/#sec-createforiniterator' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/13.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/13.0/#sec-createintrinsics' + }, + CreateIteratorFromClosure: { + url: 'https://262.ecma-international.org/13.0/#sec-createiteratorfromclosure' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/13.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/13.0/#sec-createlistfromarraylike' + }, + CreateListIteratorRecord: { + url: 'https://262.ecma-international.org/13.0/#sec-createlistiteratorRecord' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/13.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/13.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-createmethodproperty' + }, + CreateNonEnumerableDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/13.0/#sec-createnonenumerabledatapropertyorthrow' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/13.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/13.0/#sec-createrealm' + }, + CreateRegExpStringIterator: { + url: 'https://262.ecma-international.org/13.0/#sec-createregexpstringiterator' + }, + CreateResolvingFunctions: { + url: 'https://262.ecma-international.org/13.0/#sec-createresolvingfunctions' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/13.0/#sec-createsetiterator' + }, + CreateSharedByteDataBlock: { + url: 'https://262.ecma-international.org/13.0/#sec-createsharedbytedatablock' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/13.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/13.0/#sec-date-number' + }, + DateString: { + url: 'https://262.ecma-international.org/13.0/#sec-datestring' + }, + Day: { + url: 'https://262.ecma-international.org/13.0/#eqn-Day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/13.0/#eqn-DaysFromYear' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/13.0/#eqn-DaysInYear' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/13.0/#eqn-DayWithinYear' + }, + Decode: { + url: 'https://262.ecma-international.org/13.0/#sec-decode' + }, + DefineField: { + url: 'https://262.ecma-international.org/13.0/#sec-definefield' + }, + DefineMethodProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-definemethodproperty' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/13.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/13.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/13.0/#sec-encode' + }, + EnterCriticalSection: { + url: 'https://262.ecma-international.org/13.0/#sec-entercriticalsection' + }, + EnumerableOwnPropertyNames: { + url: 'https://262.ecma-international.org/13.0/#sec-enumerableownpropertynames' + }, + EnumerateObjectProperties: { + url: 'https://262.ecma-international.org/13.0/#sec-enumerate-object-properties' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/13.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/13.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/13.0/#sec-evaluatecall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/13.0/#sec-evaluatenew' + }, + EvaluatePropertyAccessWithExpressionKey: { + url: 'https://262.ecma-international.org/13.0/#sec-evaluate-property-access-with-expression-key' + }, + EvaluatePropertyAccessWithIdentifierKey: { + url: 'https://262.ecma-international.org/13.0/#sec-evaluate-property-access-with-identifier-key' + }, + EvaluateStringOrNumericBinaryExpression: { + url: 'https://262.ecma-international.org/13.0/#sec-evaluatestringornumericbinaryexpression' + }, + EventSet: { + url: 'https://262.ecma-international.org/13.0/#sec-event-set' + }, + ExecuteAsyncModule: { + url: 'https://262.ecma-international.org/13.0/#sec-execute-async-module' + }, + FinishDynamicImport: { + url: 'https://262.ecma-international.org/13.0/#sec-finishdynamicimport' + }, + FlattenIntoArray: { + url: 'https://262.ecma-international.org/13.0/#sec-flattenintoarray' + }, + floor: { + url: 'https://262.ecma-international.org/13.0/#eqn-floor' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/13.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-forinofheadevaluation' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/13.0/#sec-fulfillpromise' + }, + FunctionDeclarationInstantiation: { + url: 'https://262.ecma-international.org/13.0/#sec-functiondeclarationinstantiation' + }, + GatherAvailableAncestors: { + url: 'https://262.ecma-international.org/13.0/#sec-gather-available-ancestors' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/13.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/13.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/13.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/13.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/13.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/13.0/#sec-get-o-p' + }, + GetActiveScriptOrModule: { + url: 'https://262.ecma-international.org/13.0/#sec-getactivescriptormodule' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/13.0/#sec-getfunctionrealm' + }, + GetGeneratorKind: { + url: 'https://262.ecma-international.org/13.0/#sec-getgeneratorkind' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/13.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/13.0/#sec-getidentifierreference' + }, + GetIterator: { + url: 'https://262.ecma-international.org/13.0/#sec-getiterator' + }, + GetMatchIndexPair: { + url: 'https://262.ecma-international.org/13.0/#sec-getmatchindexpair' + }, + GetMatchString: { + url: 'https://262.ecma-international.org/13.0/#sec-getmatchstring' + }, + GetMethod: { + url: 'https://262.ecma-international.org/13.0/#sec-getmethod' + }, + GetModifySetValueInBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-getmodifysetvalueinbuffer' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/13.0/#sec-getmodulenamespace' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/13.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/13.0/#sec-getownpropertykeys' + }, + GetPromiseResolve: { + url: 'https://262.ecma-international.org/13.0/#sec-getpromiseresolve' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/13.0/#sec-getprototypefromconstructor' + }, + GetStringIndex: { + url: 'https://262.ecma-international.org/13.0/#sec-getstringindex' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/13.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/13.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/13.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/13.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/13.0/#sec-getthisvalue' + }, + GetV: { + url: 'https://262.ecma-international.org/13.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/13.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/13.0/#sec-getviewvalue' + }, + GetWaiterList: { + url: 'https://262.ecma-international.org/13.0/#sec-getwaiterlist' + }, + GlobalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/13.0/#sec-globaldeclarationinstantiation' + }, + 'happens-before': { + url: 'https://262.ecma-international.org/13.0/#sec-happens-before' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-hasownproperty' + }, + HasProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-hasproperty' + }, + 'host-synchronizes-with': { + url: 'https://262.ecma-international.org/13.0/#sec-host-synchronizes-with' + }, + HostEventSet: { + url: 'https://262.ecma-international.org/13.0/#sec-hosteventset' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/13.0/#eqn-HourFromTime' + }, + IfAbruptCloseIterator: { + url: 'https://262.ecma-international.org/13.0/#sec-ifabruptcloseiterator' + }, + IfAbruptRejectPromise: { + url: 'https://262.ecma-international.org/13.0/#sec-ifabruptrejectpromise' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/13.0/#sec-importedlocalnames' + }, + InitializeBoundName: { + url: 'https://262.ecma-international.org/13.0/#sec-initializeboundname' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/13.0/#sec-initializehostdefinedrealm' + }, + InitializeInstanceElements: { + url: 'https://262.ecma-international.org/13.0/#sec-initializeinstanceelements' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/13.0/#sec-initializereferencedbinding' + }, + InitializeTypedArrayFromArrayBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-initializetypedarrayfromarraybuffer' + }, + InitializeTypedArrayFromArrayLike: { + url: 'https://262.ecma-international.org/13.0/#sec-initializetypedarrayfromarraylike' + }, + InitializeTypedArrayFromList: { + url: 'https://262.ecma-international.org/13.0/#sec-initializetypedarrayfromlist' + }, + InitializeTypedArrayFromTypedArray: { + url: 'https://262.ecma-international.org/13.0/#sec-initializetypedarrayfromtypedarray' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/13.0/#eqn-InLeapYear' + }, + InnerModuleEvaluation: { + url: 'https://262.ecma-international.org/13.0/#sec-innermoduleevaluation' + }, + InnerModuleLinking: { + url: 'https://262.ecma-international.org/13.0/#sec-InnerModuleLinking' + }, + InstallErrorCause: { + url: 'https://262.ecma-international.org/13.0/#sec-installerrorcause' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/13.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/13.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/13.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/13.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/13.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/13.0/#sec-isarray' + }, + IsBigIntElementType: { + url: 'https://262.ecma-international.org/13.0/#sec-isbigintelementtype' + }, + IsCallable: { + url: 'https://262.ecma-international.org/13.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/13.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/13.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/13.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/13.0/#sec-isintailposition' + }, + IsIntegralNumber: { + url: 'https://262.ecma-international.org/13.0/#sec-isintegralnumber' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/13.0/#sec-islabelledfunction' + }, + IsLessThan: { + url: 'https://262.ecma-international.org/13.0/#sec-islessthan' + }, + IsLooselyEqual: { + url: 'https://262.ecma-international.org/13.0/#sec-islooselyequal' + }, + IsNoTearConfiguration: { + url: 'https://262.ecma-international.org/13.0/#sec-isnotearconfiguration' + }, + IsPrivateReference: { + url: 'https://262.ecma-international.org/13.0/#sec-isprivatereference' + }, + IsPromise: { + url: 'https://262.ecma-international.org/13.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/13.0/#sec-ispropertykey' + }, + IsPropertyReference: { + url: 'https://262.ecma-international.org/13.0/#sec-ispropertyreference' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/13.0/#sec-isregexp' + }, + IsSharedArrayBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-issharedarraybuffer' + }, + IsStrictlyEqual: { + url: 'https://262.ecma-international.org/13.0/#sec-isstrictlyequal' + }, + IsStringPrefix: { + url: 'https://262.ecma-international.org/13.0/#sec-isstringprefix' + }, + IsStringWellFormedUnicode: { + url: 'https://262.ecma-international.org/13.0/#sec-isstringwellformedunicode' + }, + IsSuperReference: { + url: 'https://262.ecma-international.org/13.0/#sec-issuperreference' + }, + IsUnclampedIntegerElementType: { + url: 'https://262.ecma-international.org/13.0/#sec-isunclampedintegerelementtype' + }, + IsUnresolvableReference: { + url: 'https://262.ecma-international.org/13.0/#sec-isunresolvablereference' + }, + IsUnsignedElementType: { + url: 'https://262.ecma-international.org/13.0/#sec-isunsignedelementtype' + }, + IsValidIntegerIndex: { + url: 'https://262.ecma-international.org/13.0/#sec-isvalidintegerindex' + }, + IsValidRegularExpressionLiteral: { + url: 'https://262.ecma-international.org/13.0/#sec-isvalidregularexpressionliteral' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IterableToList: { + url: 'https://262.ecma-international.org/13.0/#sec-iterabletolist' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/13.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/13.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/13.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/13.0/#sec-iteratorstep' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/13.0/#sec-iteratorvalue' + }, + LeaveCriticalSection: { + url: 'https://262.ecma-international.org/13.0/#sec-leavecriticalsection' + }, + LengthOfArrayLike: { + url: 'https://262.ecma-international.org/13.0/#sec-lengthofarraylike' + }, + LocalTime: { + url: 'https://262.ecma-international.org/13.0/#sec-localtime' + }, + LocalTZA: { + url: 'https://262.ecma-international.org/13.0/#sec-local-time-zone-adjustment' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/13.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/13.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/13.0/#sec-makeargsetter' + }, + MakeBasicObject: { + url: 'https://262.ecma-international.org/13.0/#sec-makebasicobject' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/13.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/13.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/13.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/13.0/#sec-makeday' + }, + MakeMatchIndicesIndexPairArray: { + url: 'https://262.ecma-international.org/13.0/#sec-makematchindicesindexpairarray' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/13.0/#sec-makemethod' + }, + MakePrivateReference: { + url: 'https://262.ecma-international.org/13.0/#sec-makeprivatereference' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/13.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/13.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/13.0/#eqn-max' + }, + 'memory-order': { + url: 'https://262.ecma-international.org/13.0/#sec-memory-order' + }, + min: { + url: 'https://262.ecma-international.org/13.0/#eqn-min' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/13.0/#eqn-MinFromTime' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/13.0/#eqn-modulo' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/13.0/#eqn-MonthFromTime' + }, + msFromTime: { + url: 'https://262.ecma-international.org/13.0/#eqn-msFromTime' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/13.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/13.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/13.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/13.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/13.0/#sec-newobjectenvironment' + }, + NewPrivateEnvironment: { + url: 'https://262.ecma-international.org/13.0/#sec-newprivateenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/13.0/#sec-newpromisecapability' + }, + NewPromiseReactionJob: { + url: 'https://262.ecma-international.org/13.0/#sec-newpromisereactionjob' + }, + NewPromiseResolveThenableJob: { + url: 'https://262.ecma-international.org/13.0/#sec-newpromiseresolvethenablejob' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/13.0/#sec-normalcompletion' + }, + NotifyWaiter: { + url: 'https://262.ecma-international.org/13.0/#sec-notifywaiter' + }, + 'Number::add': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-add' + }, + 'Number::bitwiseAND': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-bitwiseAND' + }, + 'Number::bitwiseNOT': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-bitwiseNOT' + }, + 'Number::bitwiseOR': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-bitwiseOR' + }, + 'Number::bitwiseXOR': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-bitwiseXOR' + }, + 'Number::divide': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-divide' + }, + 'Number::equal': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-equal' + }, + 'Number::exponentiate': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-exponentiate' + }, + 'Number::leftShift': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-leftShift' + }, + 'Number::lessThan': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-lessThan' + }, + 'Number::multiply': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-multiply' + }, + 'Number::remainder': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-remainder' + }, + 'Number::sameValue': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-sameValue' + }, + 'Number::sameValueZero': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-sameValueZero' + }, + 'Number::signedRightShift': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-signedRightShift' + }, + 'Number::subtract': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-subtract' + }, + 'Number::toString': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-tostring' + }, + 'Number::unaryMinus': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-unaryMinus' + }, + 'Number::unsignedRightShift': { + url: 'https://262.ecma-international.org/13.0/#sec-numeric-types-number-unsignedRightShift' + }, + NumberBitwiseOp: { + url: 'https://262.ecma-international.org/13.0/#sec-numberbitwiseop' + }, + NumberToBigInt: { + url: 'https://262.ecma-international.org/13.0/#sec-numbertobigint' + }, + NumericToRawBytes: { + url: 'https://262.ecma-international.org/13.0/#sec-numerictorawbytes' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/13.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarydefineownproperty' + }, + OrdinaryDelete: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarydelete' + }, + OrdinaryFunctionCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinaryfunctioncreate' + }, + OrdinaryGet: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinaryget' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarygetownproperty' + }, + OrdinaryGetPrototypeOf: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarygetprototypeof' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinaryhasproperty' + }, + OrdinaryIsExtensible: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinaryisextensible' + }, + OrdinaryObjectCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinaryobjectcreate' + }, + OrdinaryOwnPropertyKeys: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinaryownpropertykeys' + }, + OrdinaryPreventExtensions: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarypreventextensions' + }, + OrdinarySet: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinaryset' + }, + OrdinarySetPrototypeOf: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarysetprototypeof' + }, + OrdinarySetWithOwnDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarysetwithowndescriptor' + }, + OrdinaryToPrimitive: { + url: 'https://262.ecma-international.org/13.0/#sec-ordinarytoprimitive' + }, + ParseModule: { + url: 'https://262.ecma-international.org/13.0/#sec-parsemodule' + }, + ParsePattern: { + url: 'https://262.ecma-international.org/13.0/#sec-parsepattern' + }, + ParseScript: { + url: 'https://262.ecma-international.org/13.0/#sec-parse-script' + }, + ParseText: { + url: 'https://262.ecma-international.org/13.0/#sec-parsetext' + }, + PerformEval: { + url: 'https://262.ecma-international.org/13.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/13.0/#sec-performpromiseall' + }, + PerformPromiseAllSettled: { + url: 'https://262.ecma-international.org/13.0/#sec-performpromiseallsettled' + }, + PerformPromiseAny: { + url: 'https://262.ecma-international.org/13.0/#sec-performpromiseany' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/13.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/13.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/13.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/13.0/#sec-preparefortailcall' + }, + PrivateElementFind: { + url: 'https://262.ecma-international.org/13.0/#sec-privateelementfind' + }, + PrivateFieldAdd: { + url: 'https://262.ecma-international.org/13.0/#sec-privatefieldadd' + }, + PrivateGet: { + url: 'https://262.ecma-international.org/13.0/#sec-privateget' + }, + PrivateMethodOrAccessorAdd: { + url: 'https://262.ecma-international.org/13.0/#sec-privatemethodoraccessoradd' + }, + PrivateSet: { + url: 'https://262.ecma-international.org/13.0/#sec-privateset' + }, + PromiseResolve: { + url: 'https://262.ecma-international.org/13.0/#sec-promise-resolve' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/13.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/13.0/#sec-quotejsonstring' + }, + RawBytesToNumeric: { + url: 'https://262.ecma-international.org/13.0/#sec-rawbytestonumeric' + }, + 'reads-bytes-from': { + url: 'https://262.ecma-international.org/13.0/#sec-reads-bytes-from' + }, + 'reads-from': { + url: 'https://262.ecma-international.org/13.0/#sec-reads-from' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/13.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/13.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/13.0/#sec-regexpexec' + }, + RegExpHasFlag: { + url: 'https://262.ecma-international.org/13.0/#sec-regexphasflag' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/13.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/13.0/#sec-rejectpromise' + }, + RemoveWaiter: { + url: 'https://262.ecma-international.org/13.0/#sec-removewaiter' + }, + RemoveWaiters: { + url: 'https://262.ecma-international.org/13.0/#sec-removewaiters' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireInternalSlot: { + url: 'https://262.ecma-international.org/13.0/#sec-requireinternalslot' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/13.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/13.0/#sec-resolvebinding' + }, + ResolvePrivateIdentifier: { + url: 'https://262.ecma-international.org/13.0/#sec-resolve-private-identifier' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/13.0/#sec-resolvethisbinding' + }, + ReturnIfAbrupt: { + url: 'https://262.ecma-international.org/13.0/#sec-returnifabrupt' + }, + RoundMVResult: { + url: 'https://262.ecma-international.org/13.0/#sec-roundmvresult' + }, + SameValue: { + url: 'https://262.ecma-international.org/13.0/#sec-samevalue' + }, + SameValueNonNumeric: { + url: 'https://262.ecma-international.org/13.0/#sec-samevaluenonnumeric' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/13.0/#sec-samevaluezero' + }, + ScriptEvaluation: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-scriptevaluation' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/13.0/#eqn-SecFromTime' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/13.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/13.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/13.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/13.0/#sec-setdefaultglobalbindings' + }, + SetFunctionLength: { + url: 'https://262.ecma-international.org/13.0/#sec-setfunctionlength' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/13.0/#sec-setfunctionname' + }, + SetImmutablePrototype: { + url: 'https://262.ecma-international.org/13.0/#sec-set-immutable-prototype' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/13.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/13.0/#sec-setrealmglobalobject' + }, + SetTypedArrayFromArrayLike: { + url: 'https://262.ecma-international.org/13.0/#sec-settypedarrayfromarraylike' + }, + SetTypedArrayFromTypedArray: { + url: 'https://262.ecma-international.org/13.0/#sec-settypedarrayfromtypedarray' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/13.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/13.0/#sec-setviewvalue' + }, + SharedDataBlockEventSet: { + url: 'https://262.ecma-international.org/13.0/#sec-sharedatablockeventset' + }, + SortIndexedProperties: { + url: 'https://262.ecma-international.org/13.0/#sec-sortindexedproperties' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/13.0/#sec-speciesconstructor' + }, + StringCreate: { + url: 'https://262.ecma-international.org/13.0/#sec-stringcreate' + }, + StringGetOwnProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-stringgetownproperty' + }, + StringIndexOf: { + url: 'https://262.ecma-international.org/13.0/#sec-stringindexof' + }, + StringPad: { + url: 'https://262.ecma-international.org/13.0/#sec-stringpad' + }, + StringToBigInt: { + url: 'https://262.ecma-international.org/13.0/#sec-stringtobigint' + }, + StringToCodePoints: { + url: 'https://262.ecma-international.org/13.0/#sec-stringtocodepoints' + }, + StringToNumber: { + url: 'https://262.ecma-international.org/13.0/#sec-stringtonumber' + }, + substring: { + url: 'https://262.ecma-international.org/13.0/#substring' + }, + SuspendAgent: { + url: 'https://262.ecma-international.org/13.0/#sec-suspendagent' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/13.0/#sec-symboldescriptivestring' + }, + 'synchronizes-with': { + url: 'https://262.ecma-international.org/13.0/#sec-synchronizes-with' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/13.0/#sec-testintegritylevel' + }, + thisBigIntValue: { + url: 'https://262.ecma-international.org/13.0/#thisbigintvalue' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/13.0/#thisbooleanvalue' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/13.0/#thisnumbervalue' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/13.0/#thisstringvalue' + }, + thisSymbolValue: { + url: 'https://262.ecma-international.org/13.0/#thissymbolvalue' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/13.0/#thistimevalue' + }, + ThrowCompletion: { + url: 'https://262.ecma-international.org/13.0/#sec-throwcompletion' + }, + TimeClip: { + url: 'https://262.ecma-international.org/13.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/13.0/#eqn-TimeFromYear' + }, + TimeString: { + url: 'https://262.ecma-international.org/13.0/#sec-timestring' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/13.0/#eqn-TimeWithinDay' + }, + TimeZoneString: { + url: 'https://262.ecma-international.org/13.0/#sec-timezoneestring' + }, + ToBigInt: { + url: 'https://262.ecma-international.org/13.0/#sec-tobigint' + }, + ToBigInt64: { + url: 'https://262.ecma-international.org/13.0/#sec-tobigint64' + }, + ToBigUint64: { + url: 'https://262.ecma-international.org/13.0/#sec-tobiguint64' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/13.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/13.0/#sec-todatestring' + }, + ToIndex: { + url: 'https://262.ecma-international.org/13.0/#sec-toindex' + }, + ToInt16: { + url: 'https://262.ecma-international.org/13.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/13.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/13.0/#sec-toint8' + }, + ToIntegerOrInfinity: { + url: 'https://262.ecma-international.org/13.0/#sec-tointegerorinfinity' + }, + ToLength: { + url: 'https://262.ecma-international.org/13.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/13.0/#sec-tonumber' + }, + ToNumeric: { + url: 'https://262.ecma-international.org/13.0/#sec-tonumeric' + }, + ToObject: { + url: 'https://262.ecma-international.org/13.0/#sec-toobject' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/13.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/13.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/13.0/#sec-tostring' + }, + ToUint16: { + url: 'https://262.ecma-international.org/13.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/13.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/13.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/13.0/#sec-touint8clamp' + }, + ToZeroPaddedDecimalString: { + url: 'https://262.ecma-international.org/13.0/#sec-tozeropaddeddecimalstring' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/13.0/#sec-triggerpromisereactions' + }, + TrimString: { + url: 'https://262.ecma-international.org/13.0/#sec-trimstring' + }, + Type: { + url: 'https://262.ecma-international.org/13.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayCreate: { + url: 'https://262.ecma-international.org/13.0/#typedarray-create' + }, + TypedArrayElementSize: { + url: 'https://262.ecma-international.org/13.0/#sec-typedarrayelementsize' + }, + TypedArrayElementType: { + url: 'https://262.ecma-international.org/13.0/#sec-typedarrayelementtype' + }, + TypedArraySpeciesCreate: { + url: 'https://262.ecma-international.org/13.0/#typedarray-species-create' + }, + UnicodeEscape: { + url: 'https://262.ecma-international.org/13.0/#sec-unicodeescape' + }, + UnicodeMatchProperty: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-unicodematchproperty-p' + }, + UnicodeMatchPropertyValue: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-unicodematchpropertyvalue-p-v' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/13.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/13.0/#sec-utc-t' + }, + UTF16EncodeCodePoint: { + url: 'https://262.ecma-international.org/13.0/#sec-utf16encodecodepoint' + }, + UTF16SurrogatePairToCodePoint: { + url: 'https://262.ecma-international.org/13.0/#sec-utf16decodesurrogatepair' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/13.0/#sec-validateandapplypropertydescriptor' + }, + ValidateAtomicAccess: { + url: 'https://262.ecma-international.org/13.0/#sec-validateatomicaccess' + }, + ValidateIntegerTypedArray: { + url: 'https://262.ecma-international.org/13.0/#sec-validateintegertypedarray' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/13.0/#sec-validatetypedarray' + }, + ValueOfReadEvent: { + url: 'https://262.ecma-international.org/13.0/#sec-valueofreadevent' + }, + WeakRefDeref: { + url: 'https://262.ecma-international.org/13.0/#sec-weakrefderef' + }, + WeekDay: { + url: 'https://262.ecma-international.org/13.0/#sec-week-day' + }, + WordCharacters: { + url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-wordcharacters-abstract-operation' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/13.0/#eqn-YearFromTime' + }, + Yield: { + url: 'https://262.ecma-international.org/13.0/#sec-yield' + } +}; diff --git a/node_modules/es-abstract/operations/2023.js b/node_modules/es-abstract/operations/2023.js new file mode 100644 index 0000000000000000000000000000000000000000..9bd85dd79be49173d7ba9786fd18bdcd88bcbb3b --- /dev/null +++ b/node_modules/es-abstract/operations/2023.js @@ -0,0 +1,1441 @@ +'use strict'; + +module.exports = { + abs: { + url: 'https://262.ecma-international.org/14.0/#eqn-abs' + }, + AddEntriesFromIterable: { + url: 'https://262.ecma-international.org/14.0/#sec-add-entries-from-iterable' + }, + AddRestrictedFunctionProperties: { + url: 'https://262.ecma-international.org/14.0/#sec-addrestrictedfunctionproperties' + }, + AddToKeptObjects: { + url: 'https://262.ecma-international.org/14.0/#sec-addtokeptobjects' + }, + AddWaiter: { + url: 'https://262.ecma-international.org/14.0/#sec-addwaiter' + }, + AdvanceStringIndex: { + url: 'https://262.ecma-international.org/14.0/#sec-advancestringindex' + }, + 'agent-order': { + url: 'https://262.ecma-international.org/14.0/#sec-agent-order' + }, + AgentCanSuspend: { + url: 'https://262.ecma-international.org/14.0/#sec-agentcansuspend' + }, + AgentSignifier: { + url: 'https://262.ecma-international.org/14.0/#sec-agentsignifier' + }, + AllocateArrayBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-allocatearraybuffer' + }, + AllocateSharedArrayBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-allocatesharedarraybuffer' + }, + AllocateTypedArray: { + url: 'https://262.ecma-international.org/14.0/#sec-allocatetypedarray' + }, + AllocateTypedArrayBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-allocatetypedarraybuffer' + }, + ApplyStringOrNumericBinaryOperator: { + url: 'https://262.ecma-international.org/14.0/#sec-applystringornumericbinaryoperator' + }, + ArrayCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-arraycreate' + }, + ArraySetLength: { + url: 'https://262.ecma-international.org/14.0/#sec-arraysetlength' + }, + ArraySpeciesCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-arrayspeciescreate' + }, + AsyncBlockStart: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncblockstart' + }, + AsyncFromSyncIteratorContinuation: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncfromsynciteratorcontinuation' + }, + AsyncFunctionStart: { + url: 'https://262.ecma-international.org/14.0/#sec-async-functions-abstract-operations-async-function-start' + }, + AsyncGeneratorAwaitReturn: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratorawaitreturn' + }, + AsyncGeneratorCompleteStep: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratorcompletestep' + }, + AsyncGeneratorDrainQueue: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratordrainqueue' + }, + AsyncGeneratorEnqueue: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratorenqueue' + }, + AsyncGeneratorResume: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratorresume' + }, + AsyncGeneratorStart: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratorstart' + }, + AsyncGeneratorUnwrapYieldResumption: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratorunwrapyieldresumption' + }, + AsyncGeneratorValidate: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratorvalidate' + }, + AsyncGeneratorYield: { + url: 'https://262.ecma-international.org/14.0/#sec-asyncgeneratoryield' + }, + AsyncIteratorClose: { + url: 'https://262.ecma-international.org/14.0/#sec-asynciteratorclose' + }, + AsyncModuleExecutionFulfilled: { + url: 'https://262.ecma-international.org/14.0/#sec-async-module-execution-fulfilled' + }, + AsyncModuleExecutionRejected: { + url: 'https://262.ecma-international.org/14.0/#sec-async-module-execution-rejected' + }, + AtomicReadModifyWrite: { + url: 'https://262.ecma-international.org/14.0/#sec-atomicreadmodifywrite' + }, + Await: { + url: 'https://262.ecma-international.org/14.0/#await' + }, + BackreferenceMatcher: { + url: 'https://262.ecma-international.org/14.0/#sec-backreference-matcher' + }, + 'BigInt::add': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-add' + }, + 'BigInt::bitwiseAND': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-bitwiseAND' + }, + 'BigInt::bitwiseNOT': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-bitwiseNOT' + }, + 'BigInt::bitwiseOR': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-bitwiseOR' + }, + 'BigInt::bitwiseXOR': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-bitwiseXOR' + }, + 'BigInt::divide': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-divide' + }, + 'BigInt::equal': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-equal' + }, + 'BigInt::exponentiate': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-exponentiate' + }, + 'BigInt::leftShift': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-leftShift' + }, + 'BigInt::lessThan': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-lessThan' + }, + 'BigInt::multiply': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-multiply' + }, + 'BigInt::remainder': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-remainder' + }, + 'BigInt::signedRightShift': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-signedRightShift' + }, + 'BigInt::subtract': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-subtract' + }, + 'BigInt::toString': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-tostring' + }, + 'BigInt::unaryMinus': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-unaryMinus' + }, + 'BigInt::unsignedRightShift': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-unsignedRightShift' + }, + BigIntBitwiseOp: { + url: 'https://262.ecma-international.org/14.0/#sec-bigintbitwiseop' + }, + BinaryAnd: { + url: 'https://262.ecma-international.org/14.0/#sec-binaryand' + }, + BinaryOr: { + url: 'https://262.ecma-international.org/14.0/#sec-binaryor' + }, + BinaryXor: { + url: 'https://262.ecma-international.org/14.0/#sec-binaryxor' + }, + BlockDeclarationInstantiation: { + url: 'https://262.ecma-international.org/14.0/#sec-blockdeclarationinstantiation' + }, + BoundFunctionCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-boundfunctioncreate' + }, + ByteListBitwiseOp: { + url: 'https://262.ecma-international.org/14.0/#sec-bytelistbitwiseop' + }, + ByteListEqual: { + url: 'https://262.ecma-international.org/14.0/#sec-bytelistequal' + }, + Call: { + url: 'https://262.ecma-international.org/14.0/#sec-call' + }, + CanBeHeldWeakly: { + url: 'https://262.ecma-international.org/14.0/#sec-canbeheldweakly' + }, + Canonicalize: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-canonicalize-ch' + }, + CanonicalNumericIndexString: { + url: 'https://262.ecma-international.org/14.0/#sec-canonicalnumericindexstring' + }, + CaseClauseIsSelected: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-caseclauseisselected' + }, + CharacterRange: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-characterrange-abstract-operation' + }, + CharacterRangeOrUnion: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-characterrangeorunion-abstract-operation' + }, + CharacterSetMatcher: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-charactersetmatcher-abstract-operation' + }, + clamp: { + url: 'https://262.ecma-international.org/14.0/#clamping' + }, + CleanupFinalizationRegistry: { + url: 'https://262.ecma-international.org/14.0/#sec-cleanup-finalization-registry' + }, + ClearKeptObjects: { + url: 'https://262.ecma-international.org/14.0/#sec-clear-kept-objects' + }, + CloneArrayBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-clonearraybuffer' + }, + CodePointAt: { + url: 'https://262.ecma-international.org/14.0/#sec-codepointat' + }, + CodePointsToString: { + url: 'https://262.ecma-international.org/14.0/#sec-codepointstostring' + }, + CompareArrayElements: { + url: 'https://262.ecma-international.org/14.0/#sec-comparearrayelements' + }, + CompareTypedArrayElements: { + url: 'https://262.ecma-international.org/14.0/#sec-comparetypedarrayelements' + }, + CompletePropertyDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-completepropertydescriptor' + }, + Completion: { + url: 'https://262.ecma-international.org/14.0/#sec-completion-ao' + }, + CompletionRecord: { + url: 'https://262.ecma-international.org/14.0/#sec-completion-record-specification-type' + }, + ComposeWriteEventBytes: { + url: 'https://262.ecma-international.org/14.0/#sec-composewriteeventbytes' + }, + Construct: { + url: 'https://262.ecma-international.org/14.0/#sec-construct' + }, + ContinueDynamicImport: { + url: 'https://262.ecma-international.org/14.0/#sec-ContinueDynamicImport' + }, + ContinueModuleLoading: { + url: 'https://262.ecma-international.org/14.0/#sec-ContinueModuleLoading' + }, + CopyDataBlockBytes: { + url: 'https://262.ecma-international.org/14.0/#sec-copydatablockbytes' + }, + CopyDataProperties: { + url: 'https://262.ecma-international.org/14.0/#sec-copydataproperties' + }, + CountLeftCapturingParensBefore: { + url: 'https://262.ecma-international.org/14.0/#sec-countleftcapturingparensbefore' + }, + CountLeftCapturingParensWithin: { + url: 'https://262.ecma-international.org/14.0/#sec-countleftcapturingparenswithin' + }, + CreateArrayFromList: { + url: 'https://262.ecma-international.org/14.0/#sec-createarrayfromlist' + }, + CreateArrayIterator: { + url: 'https://262.ecma-international.org/14.0/#sec-createarrayiterator' + }, + CreateAsyncFromSyncIterator: { + url: 'https://262.ecma-international.org/14.0/#sec-createasyncfromsynciterator' + }, + CreateAsyncIteratorFromClosure: { + url: 'https://262.ecma-international.org/14.0/#sec-createasynciteratorfromclosure' + }, + CreateBuiltinFunction: { + url: 'https://262.ecma-international.org/14.0/#sec-createbuiltinfunction' + }, + CreateByteDataBlock: { + url: 'https://262.ecma-international.org/14.0/#sec-createbytedatablock' + }, + CreateDataProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-createdataproperty' + }, + CreateDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/14.0/#sec-createdatapropertyorthrow' + }, + CreateDynamicFunction: { + url: 'https://262.ecma-international.org/14.0/#sec-createdynamicfunction' + }, + CreateForInIterator: { + url: 'https://262.ecma-international.org/14.0/#sec-createforiniterator' + }, + CreateHTML: { + url: 'https://262.ecma-international.org/14.0/#sec-createhtml' + }, + CreateIntrinsics: { + url: 'https://262.ecma-international.org/14.0/#sec-createintrinsics' + }, + CreateIteratorFromClosure: { + url: 'https://262.ecma-international.org/14.0/#sec-createiteratorfromclosure' + }, + CreateIterResultObject: { + url: 'https://262.ecma-international.org/14.0/#sec-createiterresultobject' + }, + CreateListFromArrayLike: { + url: 'https://262.ecma-international.org/14.0/#sec-createlistfromarraylike' + }, + CreateListIteratorRecord: { + url: 'https://262.ecma-international.org/14.0/#sec-createlistiteratorRecord' + }, + CreateMapIterator: { + url: 'https://262.ecma-international.org/14.0/#sec-createmapiterator' + }, + CreateMappedArgumentsObject: { + url: 'https://262.ecma-international.org/14.0/#sec-createmappedargumentsobject' + }, + CreateMethodProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-createmethodproperty' + }, + CreateNonEnumerableDataPropertyOrThrow: { + url: 'https://262.ecma-international.org/14.0/#sec-createnonenumerabledatapropertyorthrow' + }, + CreatePerIterationEnvironment: { + url: 'https://262.ecma-international.org/14.0/#sec-createperiterationenvironment' + }, + CreateRealm: { + url: 'https://262.ecma-international.org/14.0/#sec-createrealm' + }, + CreateRegExpStringIterator: { + url: 'https://262.ecma-international.org/14.0/#sec-createregexpstringiterator' + }, + CreateResolvingFunctions: { + url: 'https://262.ecma-international.org/14.0/#sec-createresolvingfunctions' + }, + CreateSetIterator: { + url: 'https://262.ecma-international.org/14.0/#sec-createsetiterator' + }, + CreateSharedByteDataBlock: { + url: 'https://262.ecma-international.org/14.0/#sec-createsharedbytedatablock' + }, + CreateUnmappedArgumentsObject: { + url: 'https://262.ecma-international.org/14.0/#sec-createunmappedargumentsobject' + }, + DateFromTime: { + url: 'https://262.ecma-international.org/14.0/#sec-date-number' + }, + DateString: { + url: 'https://262.ecma-international.org/14.0/#sec-datestring' + }, + Day: { + url: 'https://262.ecma-international.org/14.0/#eqn-Day' + }, + DayFromYear: { + url: 'https://262.ecma-international.org/14.0/#eqn-DaysFromYear' + }, + DaysInYear: { + url: 'https://262.ecma-international.org/14.0/#eqn-DaysInYear' + }, + DayWithinYear: { + url: 'https://262.ecma-international.org/14.0/#eqn-DayWithinYear' + }, + Decode: { + url: 'https://262.ecma-international.org/14.0/#sec-decode' + }, + DefaultTimeZone: { + url: 'https://262.ecma-international.org/14.0/#sec-defaulttimezone' + }, + DefineField: { + url: 'https://262.ecma-international.org/14.0/#sec-definefield' + }, + DefineMethodProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-definemethodproperty' + }, + DefinePropertyOrThrow: { + url: 'https://262.ecma-international.org/14.0/#sec-definepropertyorthrow' + }, + DeletePropertyOrThrow: { + url: 'https://262.ecma-international.org/14.0/#sec-deletepropertyorthrow' + }, + DetachArrayBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-detacharraybuffer' + }, + Encode: { + url: 'https://262.ecma-international.org/14.0/#sec-encode' + }, + EnterCriticalSection: { + url: 'https://262.ecma-international.org/14.0/#sec-entercriticalsection' + }, + EnumerableOwnProperties: { + url: 'https://262.ecma-international.org/14.0/#sec-enumerableownproperties' + }, + EnumerateObjectProperties: { + url: 'https://262.ecma-international.org/14.0/#sec-enumerate-object-properties' + }, + EscapeRegExpPattern: { + url: 'https://262.ecma-international.org/14.0/#sec-escaperegexppattern' + }, + EvalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/14.0/#sec-evaldeclarationinstantiation' + }, + EvaluateCall: { + url: 'https://262.ecma-international.org/14.0/#sec-evaluatecall' + }, + EvaluateNew: { + url: 'https://262.ecma-international.org/14.0/#sec-evaluatenew' + }, + EvaluatePropertyAccessWithExpressionKey: { + url: 'https://262.ecma-international.org/14.0/#sec-evaluate-property-access-with-expression-key' + }, + EvaluatePropertyAccessWithIdentifierKey: { + url: 'https://262.ecma-international.org/14.0/#sec-evaluate-property-access-with-identifier-key' + }, + EvaluateStringOrNumericBinaryExpression: { + url: 'https://262.ecma-international.org/14.0/#sec-evaluatestringornumericbinaryexpression' + }, + EventSet: { + url: 'https://262.ecma-international.org/14.0/#sec-event-set' + }, + ExecuteAsyncModule: { + url: 'https://262.ecma-international.org/14.0/#sec-execute-async-module' + }, + '𝔽': { + url: 'https://262.ecma-international.org/14.0/#𝔽' + }, + FindViaPredicate: { + url: 'https://262.ecma-international.org/14.0/#sec-findviapredicate' + }, + FinishLoadingImportedModule: { + url: 'https://262.ecma-international.org/14.0/#sec-FinishLoadingImportedModule' + }, + FlattenIntoArray: { + url: 'https://262.ecma-international.org/14.0/#sec-flattenintoarray' + }, + floor: { + url: 'https://262.ecma-international.org/14.0/#eqn-floor' + }, + ForBodyEvaluation: { + url: 'https://262.ecma-international.org/14.0/#sec-forbodyevaluation' + }, + 'ForIn/OfBodyEvaluation': { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset' + }, + 'ForIn/OfHeadEvaluation': { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-forinofheadevaluation' + }, + FromPropertyDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-frompropertydescriptor' + }, + FulfillPromise: { + url: 'https://262.ecma-international.org/14.0/#sec-fulfillpromise' + }, + FunctionDeclarationInstantiation: { + url: 'https://262.ecma-international.org/14.0/#sec-functiondeclarationinstantiation' + }, + GatherAvailableAncestors: { + url: 'https://262.ecma-international.org/14.0/#sec-gather-available-ancestors' + }, + GeneratorResume: { + url: 'https://262.ecma-international.org/14.0/#sec-generatorresume' + }, + GeneratorResumeAbrupt: { + url: 'https://262.ecma-international.org/14.0/#sec-generatorresumeabrupt' + }, + GeneratorStart: { + url: 'https://262.ecma-international.org/14.0/#sec-generatorstart' + }, + GeneratorValidate: { + url: 'https://262.ecma-international.org/14.0/#sec-generatorvalidate' + }, + GeneratorYield: { + url: 'https://262.ecma-international.org/14.0/#sec-generatoryield' + }, + Get: { + url: 'https://262.ecma-international.org/14.0/#sec-get-o-p' + }, + GetActiveScriptOrModule: { + url: 'https://262.ecma-international.org/14.0/#sec-getactivescriptormodule' + }, + GetFunctionRealm: { + url: 'https://262.ecma-international.org/14.0/#sec-getfunctionrealm' + }, + GetGeneratorKind: { + url: 'https://262.ecma-international.org/14.0/#sec-getgeneratorkind' + }, + GetGlobalObject: { + url: 'https://262.ecma-international.org/14.0/#sec-getglobalobject' + }, + GetIdentifierReference: { + url: 'https://262.ecma-international.org/14.0/#sec-getidentifierreference' + }, + GetImportedModule: { + url: 'https://262.ecma-international.org/14.0/#sec-GetImportedModule' + }, + GetIterator: { + url: 'https://262.ecma-international.org/14.0/#sec-getiterator' + }, + GetIteratorFromMethod: { + url: 'https://262.ecma-international.org/14.0/#sec-getiteratorfrommethod' + }, + GetMatchIndexPair: { + url: 'https://262.ecma-international.org/14.0/#sec-getmatchindexpair' + }, + GetMatchString: { + url: 'https://262.ecma-international.org/14.0/#sec-getmatchstring' + }, + GetMethod: { + url: 'https://262.ecma-international.org/14.0/#sec-getmethod' + }, + GetModifySetValueInBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-getmodifysetvalueinbuffer' + }, + GetModuleNamespace: { + url: 'https://262.ecma-international.org/14.0/#sec-getmodulenamespace' + }, + GetNamedTimeZoneEpochNanoseconds: { + url: 'https://262.ecma-international.org/14.0/#sec-getnamedtimezoneepochnanoseconds' + }, + GetNamedTimeZoneOffsetNanoseconds: { + url: 'https://262.ecma-international.org/14.0/#sec-getnamedtimezoneoffsetnanoseconds' + }, + GetNewTarget: { + url: 'https://262.ecma-international.org/14.0/#sec-getnewtarget' + }, + GetOwnPropertyKeys: { + url: 'https://262.ecma-international.org/14.0/#sec-getownpropertykeys' + }, + GetPromiseResolve: { + url: 'https://262.ecma-international.org/14.0/#sec-getpromiseresolve' + }, + GetPrototypeFromConstructor: { + url: 'https://262.ecma-international.org/14.0/#sec-getprototypefromconstructor' + }, + GetStringIndex: { + url: 'https://262.ecma-international.org/14.0/#sec-getstringindex' + }, + GetSubstitution: { + url: 'https://262.ecma-international.org/14.0/#sec-getsubstitution' + }, + GetSuperConstructor: { + url: 'https://262.ecma-international.org/14.0/#sec-getsuperconstructor' + }, + GetTemplateObject: { + url: 'https://262.ecma-international.org/14.0/#sec-gettemplateobject' + }, + GetThisEnvironment: { + url: 'https://262.ecma-international.org/14.0/#sec-getthisenvironment' + }, + GetThisValue: { + url: 'https://262.ecma-international.org/14.0/#sec-getthisvalue' + }, + GetUTCEpochNanoseconds: { + url: 'https://262.ecma-international.org/14.0/#sec-getutcepochnanoseconds' + }, + GetV: { + url: 'https://262.ecma-international.org/14.0/#sec-getv' + }, + GetValue: { + url: 'https://262.ecma-international.org/14.0/#sec-getvalue' + }, + GetValueFromBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-getvaluefrombuffer' + }, + GetViewValue: { + url: 'https://262.ecma-international.org/14.0/#sec-getviewvalue' + }, + GetWaiterList: { + url: 'https://262.ecma-international.org/14.0/#sec-getwaiterlist' + }, + GlobalDeclarationInstantiation: { + url: 'https://262.ecma-international.org/14.0/#sec-globaldeclarationinstantiation' + }, + GroupSpecifiersThatMatch: { + url: 'https://262.ecma-international.org/14.0/#sec-groupspecifiersthatmatch' + }, + 'happens-before': { + url: 'https://262.ecma-international.org/14.0/#sec-happens-before' + }, + HasOwnProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-hasownproperty' + }, + HasProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-hasproperty' + }, + 'host-synchronizes-with': { + url: 'https://262.ecma-international.org/14.0/#sec-host-synchronizes-with' + }, + HostEventSet: { + url: 'https://262.ecma-international.org/14.0/#sec-hosteventset' + }, + HourFromTime: { + url: 'https://262.ecma-international.org/14.0/#eqn-HourFromTime' + }, + IfAbruptCloseIterator: { + url: 'https://262.ecma-international.org/14.0/#sec-ifabruptcloseiterator' + }, + IfAbruptRejectPromise: { + url: 'https://262.ecma-international.org/14.0/#sec-ifabruptrejectpromise' + }, + ImportedLocalNames: { + url: 'https://262.ecma-international.org/14.0/#sec-importedlocalnames' + }, + InitializeBoundName: { + url: 'https://262.ecma-international.org/14.0/#sec-initializeboundname' + }, + InitializeHostDefinedRealm: { + url: 'https://262.ecma-international.org/14.0/#sec-initializehostdefinedrealm' + }, + InitializeInstanceElements: { + url: 'https://262.ecma-international.org/14.0/#sec-initializeinstanceelements' + }, + InitializeReferencedBinding: { + url: 'https://262.ecma-international.org/14.0/#sec-initializereferencedbinding' + }, + InitializeTypedArrayFromArrayBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-initializetypedarrayfromarraybuffer' + }, + InitializeTypedArrayFromArrayLike: { + url: 'https://262.ecma-international.org/14.0/#sec-initializetypedarrayfromarraylike' + }, + InitializeTypedArrayFromList: { + url: 'https://262.ecma-international.org/14.0/#sec-initializetypedarrayfromlist' + }, + InitializeTypedArrayFromTypedArray: { + url: 'https://262.ecma-international.org/14.0/#sec-initializetypedarrayfromtypedarray' + }, + InLeapYear: { + url: 'https://262.ecma-international.org/14.0/#eqn-InLeapYear' + }, + InnerModuleEvaluation: { + url: 'https://262.ecma-international.org/14.0/#sec-innermoduleevaluation' + }, + InnerModuleLinking: { + url: 'https://262.ecma-international.org/14.0/#sec-InnerModuleLinking' + }, + InnerModuleLoading: { + url: 'https://262.ecma-international.org/14.0/#sec-InnerModuleLoading' + }, + InstallErrorCause: { + url: 'https://262.ecma-international.org/14.0/#sec-installerrorcause' + }, + InstanceofOperator: { + url: 'https://262.ecma-international.org/14.0/#sec-instanceofoperator' + }, + IntegerIndexedElementGet: { + url: 'https://262.ecma-international.org/14.0/#sec-integerindexedelementget' + }, + IntegerIndexedElementSet: { + url: 'https://262.ecma-international.org/14.0/#sec-integerindexedelementset' + }, + IntegerIndexedObjectCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-integerindexedobjectcreate' + }, + InternalizeJSONProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-internalizejsonproperty' + }, + Invoke: { + url: 'https://262.ecma-international.org/14.0/#sec-invoke' + }, + IsAccessorDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-isaccessordescriptor' + }, + IsAnonymousFunctionDefinition: { + url: 'https://262.ecma-international.org/14.0/#sec-isanonymousfunctiondefinition' + }, + IsArray: { + url: 'https://262.ecma-international.org/14.0/#sec-isarray' + }, + IsBigIntElementType: { + url: 'https://262.ecma-international.org/14.0/#sec-isbigintelementtype' + }, + IsCallable: { + url: 'https://262.ecma-international.org/14.0/#sec-iscallable' + }, + IsCompatiblePropertyDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-iscompatiblepropertydescriptor' + }, + IsConcatSpreadable: { + url: 'https://262.ecma-international.org/14.0/#sec-isconcatspreadable' + }, + IsConstructor: { + url: 'https://262.ecma-international.org/14.0/#sec-isconstructor' + }, + IsDataDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-isdatadescriptor' + }, + IsDetachedBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-isdetachedbuffer' + }, + IsExtensible: { + url: 'https://262.ecma-international.org/14.0/#sec-isextensible-o' + }, + IsGenericDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-isgenericdescriptor' + }, + IsInTailPosition: { + url: 'https://262.ecma-international.org/14.0/#sec-isintailposition' + }, + IsIntegralNumber: { + url: 'https://262.ecma-international.org/14.0/#sec-isintegralnumber' + }, + IsLabelledFunction: { + url: 'https://262.ecma-international.org/14.0/#sec-islabelledfunction' + }, + IsLessThan: { + url: 'https://262.ecma-international.org/14.0/#sec-islessthan' + }, + IsLooselyEqual: { + url: 'https://262.ecma-international.org/14.0/#sec-islooselyequal' + }, + IsNoTearConfiguration: { + url: 'https://262.ecma-international.org/14.0/#sec-isnotearconfiguration' + }, + IsPrivateReference: { + url: 'https://262.ecma-international.org/14.0/#sec-isprivatereference' + }, + IsPromise: { + url: 'https://262.ecma-international.org/14.0/#sec-ispromise' + }, + IsPropertyKey: { + url: 'https://262.ecma-international.org/14.0/#sec-ispropertykey' + }, + IsPropertyReference: { + url: 'https://262.ecma-international.org/14.0/#sec-ispropertyreference' + }, + IsRegExp: { + url: 'https://262.ecma-international.org/14.0/#sec-isregexp' + }, + IsSharedArrayBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-issharedarraybuffer' + }, + IsStrictlyEqual: { + url: 'https://262.ecma-international.org/14.0/#sec-isstrictlyequal' + }, + IsStringWellFormedUnicode: { + url: 'https://262.ecma-international.org/14.0/#sec-isstringwellformedunicode' + }, + IsSuperReference: { + url: 'https://262.ecma-international.org/14.0/#sec-issuperreference' + }, + IsTimeZoneOffsetString: { + url: 'https://262.ecma-international.org/14.0/#sec-istimezoneoffsetstring' + }, + IsUnclampedIntegerElementType: { + url: 'https://262.ecma-international.org/14.0/#sec-isunclampedintegerelementtype' + }, + IsUnresolvableReference: { + url: 'https://262.ecma-international.org/14.0/#sec-isunresolvablereference' + }, + IsUnsignedElementType: { + url: 'https://262.ecma-international.org/14.0/#sec-isunsignedelementtype' + }, + IsValidIntegerIndex: { + url: 'https://262.ecma-international.org/14.0/#sec-isvalidintegerindex' + }, + IsValidRegularExpressionLiteral: { + url: 'https://262.ecma-international.org/14.0/#sec-isvalidregularexpressionliteral' + }, + IsWordChar: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-iswordchar-abstract-operation' + }, + IteratorClose: { + url: 'https://262.ecma-international.org/14.0/#sec-iteratorclose' + }, + IteratorComplete: { + url: 'https://262.ecma-international.org/14.0/#sec-iteratorcomplete' + }, + IteratorNext: { + url: 'https://262.ecma-international.org/14.0/#sec-iteratornext' + }, + IteratorStep: { + url: 'https://262.ecma-international.org/14.0/#sec-iteratorstep' + }, + IteratorToList: { + url: 'https://262.ecma-international.org/14.0/#sec-iteratortolist' + }, + IteratorValue: { + url: 'https://262.ecma-international.org/14.0/#sec-iteratorvalue' + }, + KeyForSymbol: { + url: 'https://262.ecma-international.org/14.0/#sec-keyforsymbol' + }, + LeaveCriticalSection: { + url: 'https://262.ecma-international.org/14.0/#sec-leavecriticalsection' + }, + LengthOfArrayLike: { + url: 'https://262.ecma-international.org/14.0/#sec-lengthofarraylike' + }, + LocalTime: { + url: 'https://262.ecma-international.org/14.0/#sec-localtime' + }, + LoopContinues: { + url: 'https://262.ecma-international.org/14.0/#sec-loopcontinues' + }, + MakeArgGetter: { + url: 'https://262.ecma-international.org/14.0/#sec-makearggetter' + }, + MakeArgSetter: { + url: 'https://262.ecma-international.org/14.0/#sec-makeargsetter' + }, + MakeBasicObject: { + url: 'https://262.ecma-international.org/14.0/#sec-makebasicobject' + }, + MakeClassConstructor: { + url: 'https://262.ecma-international.org/14.0/#sec-makeclassconstructor' + }, + MakeConstructor: { + url: 'https://262.ecma-international.org/14.0/#sec-makeconstructor' + }, + MakeDate: { + url: 'https://262.ecma-international.org/14.0/#sec-makedate' + }, + MakeDay: { + url: 'https://262.ecma-international.org/14.0/#sec-makeday' + }, + MakeMatchIndicesIndexPairArray: { + url: 'https://262.ecma-international.org/14.0/#sec-makematchindicesindexpairarray' + }, + MakeMethod: { + url: 'https://262.ecma-international.org/14.0/#sec-makemethod' + }, + MakePrivateReference: { + url: 'https://262.ecma-international.org/14.0/#sec-makeprivatereference' + }, + MakeSuperPropertyReference: { + url: 'https://262.ecma-international.org/14.0/#sec-makesuperpropertyreference' + }, + MakeTime: { + url: 'https://262.ecma-international.org/14.0/#sec-maketime' + }, + max: { + url: 'https://262.ecma-international.org/14.0/#eqn-max' + }, + 'memory-order': { + url: 'https://262.ecma-international.org/14.0/#sec-memory-order' + }, + min: { + url: 'https://262.ecma-international.org/14.0/#eqn-min' + }, + MinFromTime: { + url: 'https://262.ecma-international.org/14.0/#eqn-MinFromTime' + }, + ModuleNamespaceCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-modulenamespacecreate' + }, + modulo: { + url: 'https://262.ecma-international.org/14.0/#eqn-modulo' + }, + MonthFromTime: { + url: 'https://262.ecma-international.org/14.0/#eqn-MonthFromTime' + }, + msFromTime: { + url: 'https://262.ecma-international.org/14.0/#eqn-msFromTime' + }, + NewDeclarativeEnvironment: { + url: 'https://262.ecma-international.org/14.0/#sec-newdeclarativeenvironment' + }, + NewFunctionEnvironment: { + url: 'https://262.ecma-international.org/14.0/#sec-newfunctionenvironment' + }, + NewGlobalEnvironment: { + url: 'https://262.ecma-international.org/14.0/#sec-newglobalenvironment' + }, + NewModuleEnvironment: { + url: 'https://262.ecma-international.org/14.0/#sec-newmoduleenvironment' + }, + NewObjectEnvironment: { + url: 'https://262.ecma-international.org/14.0/#sec-newobjectenvironment' + }, + NewPrivateEnvironment: { + url: 'https://262.ecma-international.org/14.0/#sec-newprivateenvironment' + }, + NewPromiseCapability: { + url: 'https://262.ecma-international.org/14.0/#sec-newpromisecapability' + }, + NewPromiseReactionJob: { + url: 'https://262.ecma-international.org/14.0/#sec-newpromisereactionjob' + }, + NewPromiseResolveThenableJob: { + url: 'https://262.ecma-international.org/14.0/#sec-newpromiseresolvethenablejob' + }, + NormalCompletion: { + url: 'https://262.ecma-international.org/14.0/#sec-normalcompletion' + }, + NotifyWaiter: { + url: 'https://262.ecma-international.org/14.0/#sec-notifywaiter' + }, + 'Number::add': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-add' + }, + 'Number::bitwiseAND': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-bitwiseAND' + }, + 'Number::bitwiseNOT': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-bitwiseNOT' + }, + 'Number::bitwiseOR': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-bitwiseOR' + }, + 'Number::bitwiseXOR': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-bitwiseXOR' + }, + 'Number::divide': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-divide' + }, + 'Number::equal': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-equal' + }, + 'Number::exponentiate': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-exponentiate' + }, + 'Number::leftShift': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-leftShift' + }, + 'Number::lessThan': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-lessThan' + }, + 'Number::multiply': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-multiply' + }, + 'Number::remainder': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-remainder' + }, + 'Number::sameValue': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-sameValue' + }, + 'Number::sameValueZero': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-sameValueZero' + }, + 'Number::signedRightShift': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-signedRightShift' + }, + 'Number::subtract': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-subtract' + }, + 'Number::toString': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-tostring' + }, + 'Number::unaryMinus': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-unaryMinus' + }, + 'Number::unsignedRightShift': { + url: 'https://262.ecma-international.org/14.0/#sec-numeric-types-number-unsignedRightShift' + }, + NumberBitwiseOp: { + url: 'https://262.ecma-international.org/14.0/#sec-numberbitwiseop' + }, + NumberToBigInt: { + url: 'https://262.ecma-international.org/14.0/#sec-numbertobigint' + }, + NumericToRawBytes: { + url: 'https://262.ecma-international.org/14.0/#sec-numerictorawbytes' + }, + ObjectDefineProperties: { + url: 'https://262.ecma-international.org/14.0/#sec-objectdefineproperties' + }, + OrdinaryCallBindThis: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarycallbindthis' + }, + OrdinaryCallEvaluateBody: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarycallevaluatebody' + }, + OrdinaryCreateFromConstructor: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarycreatefromconstructor' + }, + OrdinaryDefineOwnProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarydefineownproperty' + }, + OrdinaryDelete: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarydelete' + }, + OrdinaryFunctionCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinaryfunctioncreate' + }, + OrdinaryGet: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinaryget' + }, + OrdinaryGetOwnProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarygetownproperty' + }, + OrdinaryGetPrototypeOf: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarygetprototypeof' + }, + OrdinaryHasInstance: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinaryhasinstance' + }, + OrdinaryHasProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinaryhasproperty' + }, + OrdinaryIsExtensible: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinaryisextensible' + }, + OrdinaryObjectCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinaryobjectcreate' + }, + OrdinaryOwnPropertyKeys: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinaryownpropertykeys' + }, + OrdinaryPreventExtensions: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarypreventextensions' + }, + OrdinarySet: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinaryset' + }, + OrdinarySetPrototypeOf: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarysetprototypeof' + }, + OrdinarySetWithOwnDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarysetwithowndescriptor' + }, + OrdinaryToPrimitive: { + url: 'https://262.ecma-international.org/14.0/#sec-ordinarytoprimitive' + }, + ParseHexOctet: { + url: 'https://262.ecma-international.org/14.0/#sec-parsehexoctet' + }, + ParseModule: { + url: 'https://262.ecma-international.org/14.0/#sec-parsemodule' + }, + ParsePattern: { + url: 'https://262.ecma-international.org/14.0/#sec-parsepattern' + }, + ParseScript: { + url: 'https://262.ecma-international.org/14.0/#sec-parse-script' + }, + ParseText: { + url: 'https://262.ecma-international.org/14.0/#sec-parsetext' + }, + ParseTimeZoneOffsetString: { + url: 'https://262.ecma-international.org/14.0/#sec-parsetimezoneoffsetstring' + }, + PerformEval: { + url: 'https://262.ecma-international.org/14.0/#sec-performeval' + }, + PerformPromiseAll: { + url: 'https://262.ecma-international.org/14.0/#sec-performpromiseall' + }, + PerformPromiseAllSettled: { + url: 'https://262.ecma-international.org/14.0/#sec-performpromiseallsettled' + }, + PerformPromiseAny: { + url: 'https://262.ecma-international.org/14.0/#sec-performpromiseany' + }, + PerformPromiseRace: { + url: 'https://262.ecma-international.org/14.0/#sec-performpromiserace' + }, + PerformPromiseThen: { + url: 'https://262.ecma-international.org/14.0/#sec-performpromisethen' + }, + PrepareForOrdinaryCall: { + url: 'https://262.ecma-international.org/14.0/#sec-prepareforordinarycall' + }, + PrepareForTailCall: { + url: 'https://262.ecma-international.org/14.0/#sec-preparefortailcall' + }, + PrivateElementFind: { + url: 'https://262.ecma-international.org/14.0/#sec-privateelementfind' + }, + PrivateFieldAdd: { + url: 'https://262.ecma-international.org/14.0/#sec-privatefieldadd' + }, + PrivateGet: { + url: 'https://262.ecma-international.org/14.0/#sec-privateget' + }, + PrivateMethodOrAccessorAdd: { + url: 'https://262.ecma-international.org/14.0/#sec-privatemethodoraccessoradd' + }, + PrivateSet: { + url: 'https://262.ecma-international.org/14.0/#sec-privateset' + }, + PromiseResolve: { + url: 'https://262.ecma-international.org/14.0/#sec-promise-resolve' + }, + ProxyCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-proxycreate' + }, + PutValue: { + url: 'https://262.ecma-international.org/14.0/#sec-putvalue' + }, + QuoteJSONString: { + url: 'https://262.ecma-international.org/14.0/#sec-quotejsonstring' + }, + ℝ: { + url: 'https://262.ecma-international.org/14.0/#ℝ' + }, + RawBytesToNumeric: { + url: 'https://262.ecma-international.org/14.0/#sec-rawbytestonumeric' + }, + 'reads-bytes-from': { + url: 'https://262.ecma-international.org/14.0/#sec-reads-bytes-from' + }, + 'reads-from': { + url: 'https://262.ecma-international.org/14.0/#sec-reads-from' + }, + RegExpAlloc: { + url: 'https://262.ecma-international.org/14.0/#sec-regexpalloc' + }, + RegExpBuiltinExec: { + url: 'https://262.ecma-international.org/14.0/#sec-regexpbuiltinexec' + }, + RegExpCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-regexpcreate' + }, + RegExpExec: { + url: 'https://262.ecma-international.org/14.0/#sec-regexpexec' + }, + RegExpHasFlag: { + url: 'https://262.ecma-international.org/14.0/#sec-regexphasflag' + }, + RegExpInitialize: { + url: 'https://262.ecma-international.org/14.0/#sec-regexpinitialize' + }, + RejectPromise: { + url: 'https://262.ecma-international.org/14.0/#sec-rejectpromise' + }, + RemoveWaiter: { + url: 'https://262.ecma-international.org/14.0/#sec-removewaiter' + }, + RemoveWaiters: { + url: 'https://262.ecma-international.org/14.0/#sec-removewaiters' + }, + RepeatMatcher: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-repeatmatcher-abstract-operation' + }, + RequireInternalSlot: { + url: 'https://262.ecma-international.org/14.0/#sec-requireinternalslot' + }, + RequireObjectCoercible: { + url: 'https://262.ecma-international.org/14.0/#sec-requireobjectcoercible' + }, + ResolveBinding: { + url: 'https://262.ecma-international.org/14.0/#sec-resolvebinding' + }, + ResolvePrivateIdentifier: { + url: 'https://262.ecma-international.org/14.0/#sec-resolve-private-identifier' + }, + ResolveThisBinding: { + url: 'https://262.ecma-international.org/14.0/#sec-resolvethisbinding' + }, + ReturnIfAbrupt: { + url: 'https://262.ecma-international.org/14.0/#sec-returnifabrupt' + }, + RoundMVResult: { + url: 'https://262.ecma-international.org/14.0/#sec-roundmvresult' + }, + SameValue: { + url: 'https://262.ecma-international.org/14.0/#sec-samevalue' + }, + SameValueNonNumber: { + url: 'https://262.ecma-international.org/14.0/#sec-samevaluenonnumber' + }, + SameValueZero: { + url: 'https://262.ecma-international.org/14.0/#sec-samevaluezero' + }, + ScriptEvaluation: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-scriptevaluation' + }, + SecFromTime: { + url: 'https://262.ecma-international.org/14.0/#eqn-SecFromTime' + }, + SerializeJSONArray: { + url: 'https://262.ecma-international.org/14.0/#sec-serializejsonarray' + }, + SerializeJSONObject: { + url: 'https://262.ecma-international.org/14.0/#sec-serializejsonobject' + }, + SerializeJSONProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-serializejsonproperty' + }, + Set: { + url: 'https://262.ecma-international.org/14.0/#sec-set-o-p-v-throw' + }, + SetDefaultGlobalBindings: { + url: 'https://262.ecma-international.org/14.0/#sec-setdefaultglobalbindings' + }, + SetFunctionLength: { + url: 'https://262.ecma-international.org/14.0/#sec-setfunctionlength' + }, + SetFunctionName: { + url: 'https://262.ecma-international.org/14.0/#sec-setfunctionname' + }, + SetImmutablePrototype: { + url: 'https://262.ecma-international.org/14.0/#sec-set-immutable-prototype' + }, + SetIntegrityLevel: { + url: 'https://262.ecma-international.org/14.0/#sec-setintegritylevel' + }, + SetRealmGlobalObject: { + url: 'https://262.ecma-international.org/14.0/#sec-setrealmglobalobject' + }, + SetTypedArrayFromArrayLike: { + url: 'https://262.ecma-international.org/14.0/#sec-settypedarrayfromarraylike' + }, + SetTypedArrayFromTypedArray: { + url: 'https://262.ecma-international.org/14.0/#sec-settypedarrayfromtypedarray' + }, + SetValueInBuffer: { + url: 'https://262.ecma-international.org/14.0/#sec-setvalueinbuffer' + }, + SetViewValue: { + url: 'https://262.ecma-international.org/14.0/#sec-setviewvalue' + }, + SharedDataBlockEventSet: { + url: 'https://262.ecma-international.org/14.0/#sec-sharedatablockeventset' + }, + SortIndexedProperties: { + url: 'https://262.ecma-international.org/14.0/#sec-sortindexedproperties' + }, + SpeciesConstructor: { + url: 'https://262.ecma-international.org/14.0/#sec-speciesconstructor' + }, + StringCreate: { + url: 'https://262.ecma-international.org/14.0/#sec-stringcreate' + }, + StringGetOwnProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-stringgetownproperty' + }, + StringIndexOf: { + url: 'https://262.ecma-international.org/14.0/#sec-stringindexof' + }, + StringPad: { + url: 'https://262.ecma-international.org/14.0/#sec-stringpad' + }, + StringToBigInt: { + url: 'https://262.ecma-international.org/14.0/#sec-stringtobigint' + }, + StringToCodePoints: { + url: 'https://262.ecma-international.org/14.0/#sec-stringtocodepoints' + }, + StringToNumber: { + url: 'https://262.ecma-international.org/14.0/#sec-stringtonumber' + }, + substring: { + url: 'https://262.ecma-international.org/14.0/#substring' + }, + SuspendAgent: { + url: 'https://262.ecma-international.org/14.0/#sec-suspendagent' + }, + SymbolDescriptiveString: { + url: 'https://262.ecma-international.org/14.0/#sec-symboldescriptivestring' + }, + 'synchronizes-with': { + url: 'https://262.ecma-international.org/14.0/#sec-synchronizes-with' + }, + TemplateString: { + url: 'https://262.ecma-international.org/14.0/#sec-templatestring' + }, + TestIntegrityLevel: { + url: 'https://262.ecma-international.org/14.0/#sec-testintegritylevel' + }, + thisBigIntValue: { + url: 'https://262.ecma-international.org/14.0/#thisbigintvalue' + }, + thisBooleanValue: { + url: 'https://262.ecma-international.org/14.0/#thisbooleanvalue' + }, + thisNumberValue: { + url: 'https://262.ecma-international.org/14.0/#thisnumbervalue' + }, + thisStringValue: { + url: 'https://262.ecma-international.org/14.0/#thisstringvalue' + }, + thisSymbolValue: { + url: 'https://262.ecma-international.org/14.0/#thissymbolvalue' + }, + thisTimeValue: { + url: 'https://262.ecma-international.org/14.0/#thistimevalue' + }, + ThrowCompletion: { + url: 'https://262.ecma-international.org/14.0/#sec-throwcompletion' + }, + TimeClip: { + url: 'https://262.ecma-international.org/14.0/#sec-timeclip' + }, + TimeFromYear: { + url: 'https://262.ecma-international.org/14.0/#eqn-TimeFromYear' + }, + TimeString: { + url: 'https://262.ecma-international.org/14.0/#sec-timestring' + }, + TimeWithinDay: { + url: 'https://262.ecma-international.org/14.0/#eqn-TimeWithinDay' + }, + TimeZoneString: { + url: 'https://262.ecma-international.org/14.0/#sec-timezoneestring' + }, + ToBigInt: { + url: 'https://262.ecma-international.org/14.0/#sec-tobigint' + }, + ToBigInt64: { + url: 'https://262.ecma-international.org/14.0/#sec-tobigint64' + }, + ToBigUint64: { + url: 'https://262.ecma-international.org/14.0/#sec-tobiguint64' + }, + ToBoolean: { + url: 'https://262.ecma-international.org/14.0/#sec-toboolean' + }, + ToDateString: { + url: 'https://262.ecma-international.org/14.0/#sec-todatestring' + }, + ToIndex: { + url: 'https://262.ecma-international.org/14.0/#sec-toindex' + }, + ToInt16: { + url: 'https://262.ecma-international.org/14.0/#sec-toint16' + }, + ToInt32: { + url: 'https://262.ecma-international.org/14.0/#sec-toint32' + }, + ToInt8: { + url: 'https://262.ecma-international.org/14.0/#sec-toint8' + }, + ToIntegerOrInfinity: { + url: 'https://262.ecma-international.org/14.0/#sec-tointegerorinfinity' + }, + ToLength: { + url: 'https://262.ecma-international.org/14.0/#sec-tolength' + }, + ToNumber: { + url: 'https://262.ecma-international.org/14.0/#sec-tonumber' + }, + ToNumeric: { + url: 'https://262.ecma-international.org/14.0/#sec-tonumeric' + }, + ToObject: { + url: 'https://262.ecma-international.org/14.0/#sec-toobject' + }, + ToPrimitive: { + url: 'https://262.ecma-international.org/14.0/#sec-toprimitive' + }, + ToPropertyDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-topropertydescriptor' + }, + ToPropertyKey: { + url: 'https://262.ecma-international.org/14.0/#sec-topropertykey' + }, + ToString: { + url: 'https://262.ecma-international.org/14.0/#sec-tostring' + }, + ToUint16: { + url: 'https://262.ecma-international.org/14.0/#sec-touint16' + }, + ToUint32: { + url: 'https://262.ecma-international.org/14.0/#sec-touint32' + }, + ToUint8: { + url: 'https://262.ecma-international.org/14.0/#sec-touint8' + }, + ToUint8Clamp: { + url: 'https://262.ecma-international.org/14.0/#sec-touint8clamp' + }, + ToZeroPaddedDecimalString: { + url: 'https://262.ecma-international.org/14.0/#sec-tozeropaddeddecimalstring' + }, + TriggerPromiseReactions: { + url: 'https://262.ecma-international.org/14.0/#sec-triggerpromisereactions' + }, + TrimString: { + url: 'https://262.ecma-international.org/14.0/#sec-trimstring' + }, + truncate: { + url: 'https://262.ecma-international.org/14.0/#eqn-truncate' + }, + Type: { + url: 'https://262.ecma-international.org/14.0/#sec-ecmascript-data-types-and-values' + }, + TypedArrayCreate: { + url: 'https://262.ecma-international.org/14.0/#typedarray-create' + }, + TypedArrayCreateSameType: { + url: 'https://262.ecma-international.org/14.0/#sec-typedarray-create-same-type' + }, + TypedArrayElementSize: { + url: 'https://262.ecma-international.org/14.0/#sec-typedarrayelementsize' + }, + TypedArrayElementType: { + url: 'https://262.ecma-international.org/14.0/#sec-typedarrayelementtype' + }, + TypedArraySpeciesCreate: { + url: 'https://262.ecma-international.org/14.0/#typedarray-species-create' + }, + UnicodeEscape: { + url: 'https://262.ecma-international.org/14.0/#sec-unicodeescape' + }, + UnicodeMatchProperty: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-unicodematchproperty-p' + }, + UnicodeMatchPropertyValue: { + url: 'https://262.ecma-international.org/14.0/#sec-runtime-semantics-unicodematchpropertyvalue-p-v' + }, + UpdateEmpty: { + url: 'https://262.ecma-international.org/14.0/#sec-updateempty' + }, + UTC: { + url: 'https://262.ecma-international.org/14.0/#sec-utc-t' + }, + UTF16EncodeCodePoint: { + url: 'https://262.ecma-international.org/14.0/#sec-utf16encodecodepoint' + }, + UTF16SurrogatePairToCodePoint: { + url: 'https://262.ecma-international.org/14.0/#sec-utf16decodesurrogatepair' + }, + ValidateAndApplyPropertyDescriptor: { + url: 'https://262.ecma-international.org/14.0/#sec-validateandapplypropertydescriptor' + }, + ValidateAtomicAccess: { + url: 'https://262.ecma-international.org/14.0/#sec-validateatomicaccess' + }, + ValidateIntegerTypedArray: { + url: 'https://262.ecma-international.org/14.0/#sec-validateintegertypedarray' + }, + ValidateNonRevokedProxy: { + url: 'https://262.ecma-international.org/14.0/#sec-validatenonrevokedproxy' + }, + ValidateTypedArray: { + url: 'https://262.ecma-international.org/14.0/#sec-validatetypedarray' + }, + ValueOfReadEvent: { + url: 'https://262.ecma-international.org/14.0/#sec-valueofreadevent' + }, + WeakRefDeref: { + url: 'https://262.ecma-international.org/14.0/#sec-weakrefderef' + }, + WeekDay: { + url: 'https://262.ecma-international.org/14.0/#sec-week-day' + }, + WordCharacters: { + url: 'https://262.ecma-international.org/14.0/#sec-wordcharacters' + }, + YearFromTime: { + url: 'https://262.ecma-international.org/14.0/#eqn-YearFromTime' + }, + Yield: { + url: 'https://262.ecma-international.org/14.0/#sec-yield' + }, + ℤ: { + url: 'https://262.ecma-international.org/14.0/#ℤ' + } +}; diff --git a/node_modules/es-abstract/operations/build-unicode.mjs b/node_modules/es-abstract/operations/build-unicode.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f3300991b1c7656778773342cc0d68de37c58cdf --- /dev/null +++ b/node_modules/es-abstract/operations/build-unicode.mjs @@ -0,0 +1,19 @@ +import fs from 'fs'; +import path from 'path'; + +import C from '@unicode/unicode-15.0.0/Case_Folding/C/symbols.js'; +import S from '@unicode/unicode-15.0.0/Case_Folding/S/symbols.js'; + +function normalize(map) { + return Object.fromEntries(Array.from(map, ([o, i]) => [i, [].concat(o)[0]])); +} + +const cases = { + C: normalize(C), + S: normalize(S), +}; + +fs.writeFileSync( + path.join(process.cwd(), './helpers/caseFolding.json'), + JSON.stringify(cases, null, '\t'), +); diff --git a/node_modules/es-abstract/package.json b/node_modules/es-abstract/package.json new file mode 100644 index 0000000000000000000000000000000000000000..95243deefd5df50f18a3b22a2a6a042a1b4a0317 --- /dev/null +++ b/node_modules/es-abstract/package.json @@ -0,0 +1,166 @@ +{ + "name": "es-abstract", + "version": "1.22.3", + "author": { + "name": "Jordan Harband", + "email": "ljharb@gmail.com", + "url": "http://ljharb.codes" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "contributors": [ + { + "name": "Jordan Harband", + "email": "ljharb@gmail.com", + "url": "http://ljharb.codes" + } + ], + "description": "ECMAScript spec abstract operations.", + "license": "MIT", + "main": "index.js", + "browser": { + "worker_threads": false + }, + "type": "commonjs", + "sideEffects": false, + "scripts": { + "prespackle": "git ls-files | xargs git check-attr spackled | grep -v 'unspecified$' | cut -d: -f1 | xargs rm || true", + "spackle": "node operations/spackle 1 && node operations/build-unicode.mjs", + "postspackle": "git ls-files | xargs git check-attr spackled | grep -v 'unspecified$' | cut -d: -f1 | xargs git add", + "prepack": "npmignore --auto --commentLines=autogenerated", + "prepublish": "not-in-publish || npm run prepublishOnly", + "prepublishOnly": "safe-publish-latest && npm run spackle", + "pretest": "npm run lint", + "test": "npm run tests-only && npm run test:ses", + "test:ses": "node test/ses-compat", + "posttest": "aud --production", + "tests-only": "nyc node --stack-size=5120 test", + "lint": "eslint .", + "eccheck": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/es-abstract.git" + }, + "keywords": [ + "ECMAScript", + "ES", + "abstract", + "operation", + "abstract operation", + "JavaScript", + "ES5", + "ES6", + "ES7" + ], + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "arraybuffer.prototype.slice": "^1.0.2", + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.5", + "es-set-tostringtag": "^2.0.1", + "es-to-primitive": "^1.2.1", + "function.prototype.name": "^1.1.6", + "get-intrinsic": "^1.2.2", + "get-symbol-description": "^1.0.0", + "globalthis": "^1.0.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0", + "internal-slot": "^1.0.5", + "is-array-buffer": "^3.0.2", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "is-string": "^1.0.7", + "is-typed-array": "^1.1.12", + "is-weakref": "^1.0.2", + "object-inspect": "^1.13.1", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.5.1", + "safe-array-concat": "^1.0.1", + "safe-regex-test": "^1.0.0", + "string.prototype.trim": "^1.2.8", + "string.prototype.trimend": "^1.0.7", + "string.prototype.trimstart": "^1.0.7", + "typed-array-buffer": "^1.0.0", + "typed-array-byte-length": "^1.0.0", + "typed-array-byte-offset": "^1.0.0", + "typed-array-length": "^1.0.4", + "unbox-primitive": "^1.0.2", + "which-typed-array": "^1.1.13" + }, + "devDependencies": { + "@ljharb/eslint-config": "^21.1.0", + "@unicode/unicode-15.0.0": "^1.5.2", + "array.from": "^1.1.5", + "array.prototype.filter": "^1.0.3", + "array.prototype.flatmap": "^1.3.2", + "array.prototype.indexof": "^1.0.6", + "aud": "^2.0.3", + "available-regexp-flags": "^1.0.2", + "cheerio": "=1.0.0-rc.3", + "diff": "^5.1.0", + "eclint": "^2.8.1", + "es-value-fixtures": "^1.4.2", + "eslint": "=8.8.0", + "for-each": "^0.3.3", + "function-bind": "^1.1.2", + "functions-have-names": "^1.2.3", + "has-bigints": "^1.0.2", + "has-strict-mode": "^1.0.1", + "in-publish": "^2.0.1", + "is-core-module": "^2.13.1", + "is-registered-symbol": "^1.0.1", + "make-arrow-function": "^1.2.0", + "make-async-function": "^1.0.0", + "make-async-generator-function": "^1.0.0", + "make-generator-function": "^2.0.0", + "mock-property": "^1.0.2", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "object.fromentries": "^2.0.7", + "safe-publish-latest": "^2.0.0", + "ses": "^0.18.8", + "tape": "^5.7.2" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "publishConfig": { + "ignore": [ + ".github", + "", + "# dev scripts", + "operations/*.js", + "!operations/20*.js", + "", + "test/", + "", + ".gitattributes" + ] + } +} diff --git a/node_modules/es-to-primitive/.eslintrc b/node_modules/es-to-primitive/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..b6639b96c4a2c13bb8422f31c03227205dc01dbf --- /dev/null +++ b/node_modules/es-to-primitive/.eslintrc @@ -0,0 +1,22 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "complexity": [2, 14], + "func-name-matching": 0, + "id-length": [2, { "min": 1, "max": 24, "properties": "never" }], + "max-statements": [2, 20], + "new-cap": [2, { "capIsNewExceptions": ["GetMethod"] }] + }, + + "overrides": [ + { + "files": "test/**", + "rules": { + "max-lines-per-function": [2, { "max": 68 }], + }, + } + ], +} diff --git a/node_modules/es-to-primitive/.github/FUNDING.yml b/node_modules/es-to-primitive/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..9f928ae809d50c18aa9d24bea66f7dea85da323c --- /dev/null +++ b/node_modules/es-to-primitive/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/es-to-primitive +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/es-to-primitive/.travis.yml b/node_modules/es-to-primitive/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..d4c5a842fab66cb30953a8ced3ebb202a597f28e --- /dev/null +++ b/node_modules/es-to-primitive/.travis.yml @@ -0,0 +1,15 @@ +version: ~> 1.0 +language: node_js +cache: + directories: + - "$(nvm cache dir)" +os: + - linux +import: + - ljharb/travis-ci:node/all.yml + - ljharb/travis-ci:node/pretest.yml + - ljharb/travis-ci:node/posttest.yml + - ljharb/travis-ci:node/coverage.yml +matrix: + allow_failures: + - env: COVERAGE=true diff --git a/node_modules/es-to-primitive/CHANGELOG.md b/node_modules/es-to-primitive/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..0a5dda78062074a04a700b096e098462fc728b80 --- /dev/null +++ b/node_modules/es-to-primitive/CHANGELOG.md @@ -0,0 +1,49 @@ +1.2.1 / 2019-11-08 +================= + * [readme] remove testling URLs + * [meta] add `funding` field + * [meta] create FUNDING.yml + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `replace`, `semver`, `tape`, `function.prototype.name` + * [Tests] use shared travis-ci configs + * [Tests] Add es5 tests for `symbol` types (#45) + * [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops + * [Tests] remove `jscs` + +1.2.0 / 2018-09-27 +================= + * [New] create ES2015 entry point/property, to replace ES6 + * [Fix] Ensure optional arguments are not part of the length (#29) + * [Deps] update `is-callable` + * [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver`, `object-inspect`, `replace` + * [Tests] avoid util.inspect bug with `new Date(NaN)` on node v6.0 and v6.1. + * [Tests] up to `node` `v10.11`, `v9.11`, `v8.12`, `v6.14`, `v4.9` + +1.1.1 / 2016-01-03 +================= + * [Fix: ES5] fix coercion logic: ES5’s ToPrimitive does not coerce any primitive value, regardless of hint (#2) + +1.1.0 / 2015-12-27 +================= + * [New] add `Symbol.toPrimitive` support + * [Deps] update `is-callable`, `is-date-object` + * [Dev Deps] update `eslint`, `tape`, `semver`, `jscs`, `covert`, `nsp`, `@ljharb/eslint-config` + * [Dev Deps] remove unused deps + * [Tests] up to `node` `v5.3` + * [Tests] fix npm upgrades on older node versions + * [Tests] fix testling + * [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG + +1.0.1 / 2016-01-03 +================= + * [Fix: ES5] fix coercion logic: ES5’s ToPrimitive does not coerce any primitive value, regardless of hint (#2) + * [Deps] update `is-callable`, `is-date-object` + * [Dev Deps] update `eslint`, `tape`, `semver`, `jscs`, `covert`, `nsp`, `@ljharb/eslint-config` + * [Dev Deps] remove unused deps + * [Tests] up to `node` `v5.3` + * [Tests] fix npm upgrades on older node versions + * [Tests] fix testling + * [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG + +1.0.0 / 2015-03-19 +================= + * Initial release. diff --git a/node_modules/es-to-primitive/LICENSE b/node_modules/es-to-primitive/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b43df444e518288ceef6eaa9badd33388191b1d3 --- /dev/null +++ b/node_modules/es-to-primitive/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +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. + diff --git a/node_modules/es-to-primitive/Makefile b/node_modules/es-to-primitive/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b9e4fe1aab3dde87b3071e9b39e45a22ce3bf33a --- /dev/null +++ b/node_modules/es-to-primitive/Makefile @@ -0,0 +1,61 @@ +# Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) + + # The files that need updating when incrementing the version number. +VERSIONED_FILES := *.js *.json README* + + +# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. +# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment +# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. +export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") +UTILS := semver +# Make sure that all required utilities can be located. +UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) + +# Default target (by virtue of being the first non '.'-prefixed in the file). +.PHONY: _no-target-specified +_no-target-specified: + $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) + +# Lists all targets defined in this makefile. +.PHONY: list +list: + @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort + +# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). +.PHONY: test +test: + @npm test + +.PHONY: _ensure-tag +_ensure-tag: +ifndef TAG + $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) +endif + +CHANGELOG_ERROR = $(error No CHANGELOG specified) +.PHONY: _ensure-changelog +_ensure-changelog: + @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) + +# Ensures that the git workspace is clean. +.PHONY: _ensure-clean +_ensure-clean: + @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } + +# Makes a release; invoke with `make TAG= release`. +.PHONY: release +release: _ensure-tag _ensure-changelog _ensure-clean + @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ + new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ + if printf "$$new_ver" | command grep -q '^[0-9]'; then \ + semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ + semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ + else \ + new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ + fi; \ + printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ + replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ + git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ + git tag -a -m "v$$new_ver" "v$$new_ver" diff --git a/node_modules/es-to-primitive/README.md b/node_modules/es-to-primitive/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5ce322bfac162ec0333072c195607e4954d3c1bf --- /dev/null +++ b/node_modules/es-to-primitive/README.md @@ -0,0 +1,49 @@ +# es-to-primitive [![Version Badge][npm-version-svg]][package-url] + +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES2015 versions. +When different versions of the spec conflict, the default export will be the latest version of the abstract operation. +Alternative versions will also be available under an `es5`/`es2015` exported property if you require a specific version. + +## Example + +```js +var toPrimitive = require('es-to-primitive'); +var assert = require('assert'); + +assert(toPrimitive(function () {}) === String(function () {})); + +var date = new Date(); +assert(toPrimitive(date) === String(date)); + +assert(toPrimitive({ valueOf: function () { return 3; } }) === 3); + +assert(toPrimitive(['a', 'b', 3]) === String(['a', 'b', 3])); + +var sym = Symbol(); +assert(toPrimitive(Object(sym)) === sym); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/es-to-primitive +[npm-version-svg]: http://versionbadg.es/ljharb/es-to-primitive.svg +[travis-svg]: https://travis-ci.org/ljharb/es-to-primitive.svg +[travis-url]: https://travis-ci.org/ljharb/es-to-primitive +[deps-svg]: https://david-dm.org/ljharb/es-to-primitive.svg +[deps-url]: https://david-dm.org/ljharb/es-to-primitive +[dev-deps-svg]: https://david-dm.org/ljharb/es-to-primitive/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/es-to-primitive#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/es-to-primitive.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/es-to-primitive.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/es-to-primitive.svg +[downloads-url]: http://npm-stat.com/charts.html?package=es-to-primitive diff --git a/node_modules/es-to-primitive/es2015.js b/node_modules/es-to-primitive/es2015.js new file mode 100644 index 0000000000000000000000000000000000000000..4a11a346c608c970b38e39609a903c91a6fc4496 --- /dev/null +++ b/node_modules/es-to-primitive/es2015.js @@ -0,0 +1,75 @@ +'use strict'; + +var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; + +var isPrimitive = require('./helpers/isPrimitive'); +var isCallable = require('is-callable'); +var isDate = require('is-date-object'); +var isSymbol = require('is-symbol'); + +var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) { + if (typeof O === 'undefined' || O === null) { + throw new TypeError('Cannot call method on ' + O); + } + if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) { + throw new TypeError('hint must be "string" or "number"'); + } + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + var method, result, i; + for (i = 0; i < methodNames.length; ++i) { + method = O[methodNames[i]]; + if (isCallable(method)) { + result = method.call(O); + if (isPrimitive(result)) { + return result; + } + } + } + throw new TypeError('No default value'); +}; + +var GetMethod = function GetMethod(O, P) { + var func = O[P]; + if (func !== null && typeof func !== 'undefined') { + if (!isCallable(func)) { + throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function'); + } + return func; + } + return void 0; +}; + +// http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive +module.exports = function ToPrimitive(input) { + if (isPrimitive(input)) { + return input; + } + var hint = 'default'; + if (arguments.length > 1) { + if (arguments[1] === String) { + hint = 'string'; + } else if (arguments[1] === Number) { + hint = 'number'; + } + } + + var exoticToPrim; + if (hasSymbols) { + if (Symbol.toPrimitive) { + exoticToPrim = GetMethod(input, Symbol.toPrimitive); + } else if (isSymbol(input)) { + exoticToPrim = Symbol.prototype.valueOf; + } + } + if (typeof exoticToPrim !== 'undefined') { + var result = exoticToPrim.call(input, hint); + if (isPrimitive(result)) { + return result; + } + throw new TypeError('unable to convert exotic object to primitive'); + } + if (hint === 'default' && (isDate(input) || isSymbol(input))) { + hint = 'string'; + } + return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint); +}; diff --git a/node_modules/es-to-primitive/es5.js b/node_modules/es-to-primitive/es5.js new file mode 100644 index 0000000000000000000000000000000000000000..602aa362c7e3e33d89e6aff51618eb8e08794475 --- /dev/null +++ b/node_modules/es-to-primitive/es5.js @@ -0,0 +1,45 @@ +'use strict'; + +var toStr = Object.prototype.toString; + +var isPrimitive = require('./helpers/isPrimitive'); + +var isCallable = require('is-callable'); + +// http://ecma-international.org/ecma-262/5.1/#sec-8.12.8 +var ES5internalSlots = { + '[[DefaultValue]]': function (O) { + var actualHint; + if (arguments.length > 1) { + actualHint = arguments[1]; + } else { + actualHint = toStr.call(O) === '[object Date]' ? String : Number; + } + + if (actualHint === String || actualHint === Number) { + var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + var value, i; + for (i = 0; i < methods.length; ++i) { + if (isCallable(O[methods[i]])) { + value = O[methods[i]](); + if (isPrimitive(value)) { + return value; + } + } + } + throw new TypeError('No default value'); + } + throw new TypeError('invalid [[DefaultValue]] hint supplied'); + } +}; + +// http://ecma-international.org/ecma-262/5.1/#sec-9.1 +module.exports = function ToPrimitive(input) { + if (isPrimitive(input)) { + return input; + } + if (arguments.length > 1) { + return ES5internalSlots['[[DefaultValue]]'](input, arguments[1]); + } + return ES5internalSlots['[[DefaultValue]]'](input); +}; diff --git a/node_modules/es-to-primitive/es6.js b/node_modules/es-to-primitive/es6.js new file mode 100644 index 0000000000000000000000000000000000000000..2d1f4dc927a904056054c0030c14db3703e9d1d7 --- /dev/null +++ b/node_modules/es-to-primitive/es6.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./es2015'); diff --git a/node_modules/es-to-primitive/helpers/isPrimitive.js b/node_modules/es-to-primitive/helpers/isPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..06f0bf042525a13635fcd0980e07d4737a09c0c8 --- /dev/null +++ b/node_modules/es-to-primitive/helpers/isPrimitive.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isPrimitive(value) { + return value === null || (typeof value !== 'function' && typeof value !== 'object'); +}; diff --git a/node_modules/es-to-primitive/index.js b/node_modules/es-to-primitive/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e60d912e1133258cb2092b14af2a183b10cf4834 --- /dev/null +++ b/node_modules/es-to-primitive/index.js @@ -0,0 +1,17 @@ +'use strict'; + +var ES5 = require('./es5'); +var ES6 = require('./es6'); +var ES2015 = require('./es2015'); + +if (Object.defineProperty) { + Object.defineProperty(ES2015, 'ES5', { enumerable: false, value: ES5 }); + Object.defineProperty(ES2015, 'ES6', { enumerable: false, value: ES6 }); + Object.defineProperty(ES2015, 'ES2015', { enumerable: false, value: ES2015 }); +} else { + ES6.ES5 = ES5; + ES6.ES6 = ES6; + ES6.ES2015 = ES2015; +} + +module.exports = ES2015; diff --git a/node_modules/es-to-primitive/package.json b/node_modules/es-to-primitive/package.json new file mode 100644 index 0000000000000000000000000000000000000000..136f87783cd25c1166ae49a779a3993ff72f375f --- /dev/null +++ b/node_modules/es-to-primitive/package.json @@ -0,0 +1,81 @@ +{ + "name": "es-to-primitive", + "version": "1.2.1", + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "description": "ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES2015 versions.", + "license": "MIT", + "main": "index.js", + "scripts": { + "pretest": "npm run --silent lint", + "test": "npm run --silent tests-only", + "posttest": "npx aud", + "tests-only": "node --es-staging test", + "coverage": "covert test/*.js", + "coverage-quiet": "covert test/*.js --quiet", + "lint": "eslint ." + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/es-to-primitive.git" + }, + "keywords": [ + "primitive", + "abstract", + "ecmascript", + "es5", + "es6", + "es2015", + "toPrimitive", + "coerce", + "type", + "object", + "string", + "number", + "boolean", + "symbol", + "null", + "undefined" + ], + "dependencies": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + }, + "devDependencies": { + "@ljharb/eslint-config": "^15.0.0", + "covert": "^1.1.1", + "eslint": "^6.6.0", + "foreach": "^2.0.5", + "function.prototype.name": "^1.1.1", + "has-symbols": "^1.0.0", + "object-inspect": "^1.6.0", + "object-is": "^1.0.1", + "replace": "^1.1.1", + "semver": "^6.3.0", + "tape": "^4.11.0" + }, + "testling": { + "files": "test", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + } +} diff --git a/node_modules/es-to-primitive/test/es2015.js b/node_modules/es-to-primitive/test/es2015.js new file mode 100644 index 0000000000000000000000000000000000000000..80f4083dd931521efd792ee137583b6cce3db1f5 --- /dev/null +++ b/node_modules/es-to-primitive/test/es2015.js @@ -0,0 +1,151 @@ +'use strict'; + +var test = require('tape'); +var toPrimitive = require('../es2015'); +var is = require('object-is'); +var forEach = require('foreach'); +var functionName = require('function.prototype.name'); +var debug = require('object-inspect'); + +var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; +var hasSymbolToPrimitive = hasSymbols && typeof Symbol.toPrimitive === 'symbol'; + +test('function properties', function (t) { + t.equal(toPrimitive.length, 1, 'length is 1'); + t.equal(functionName(toPrimitive), 'ToPrimitive', 'name is ToPrimitive'); + + t.end(); +}); + +var primitives = [null, undefined, true, false, 0, -0, 42, NaN, Infinity, -Infinity, '', 'abc']; + +test('primitives', function (t) { + forEach(primitives, function (i) { + t.ok(is(toPrimitive(i), i), 'toPrimitive(' + debug(i) + ') returns the same value'); + t.ok(is(toPrimitive(i, String), i), 'toPrimitive(' + debug(i) + ', String) returns the same value'); + t.ok(is(toPrimitive(i, Number), i), 'toPrimitive(' + debug(i) + ', Number) returns the same value'); + }); + t.end(); +}); + +test('Symbols', { skip: !hasSymbols }, function (t) { + var symbols = [ + Symbol('foo'), + Symbol.iterator, + Symbol['for']('foo') // eslint-disable-line no-restricted-properties + ]; + forEach(symbols, function (sym) { + t.equal(toPrimitive(sym), sym, 'toPrimitive(' + debug(sym) + ') returns the same value'); + t.equal(toPrimitive(sym, String), sym, 'toPrimitive(' + debug(sym) + ', String) returns the same value'); + t.equal(toPrimitive(sym, Number), sym, 'toPrimitive(' + debug(sym) + ', Number) returns the same value'); + }); + + var primitiveSym = Symbol('primitiveSym'); + var objectSym = Object(primitiveSym); + t.equal(toPrimitive(objectSym), primitiveSym, 'toPrimitive(' + debug(objectSym) + ') returns ' + debug(primitiveSym)); + t.equal(toPrimitive(objectSym, String), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', String) returns ' + debug(primitiveSym)); + t.equal(toPrimitive(objectSym, Number), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', Number) returns ' + debug(primitiveSym)); + t.end(); +}); + +test('Arrays', function (t) { + var arrays = [[], ['a', 'b'], [1, 2]]; + forEach(arrays, function (arr) { + t.equal(toPrimitive(arr), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + t.equal(toPrimitive(arr, String), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + t.equal(toPrimitive(arr, Number), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + }); + t.end(); +}); + +test('Dates', function (t) { + var dates = [new Date(), new Date(0), new Date(NaN)]; + forEach(dates, function (date) { + t.equal(toPrimitive(date), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date'); + t.equal(toPrimitive(date, String), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date'); + t.ok(is(toPrimitive(date, Number), Number(date)), 'toPrimitive(' + debug(date) + ') returns the number version of the date'); + }); + t.end(); +}); + +var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; +var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; +var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; +var coercibleFnObject = { + valueOf: function () { return function valueOfFn() {}; }, + toString: function () { return 42; } +}; +var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; +var uncoercibleFnObject = { + valueOf: function () { return function valueOfFn() {}; }, + toString: function () { return function toStrFn() {}; } +}; + +test('Objects', function (t) { + t.equal(toPrimitive(coercibleObject), coercibleObject.valueOf(), 'coercibleObject with no hint coerces to valueOf'); + t.equal(toPrimitive(coercibleObject, Number), coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf'); + t.equal(toPrimitive(coercibleObject, String), coercibleObject.toString(), 'coercibleObject with hint String coerces to non-stringified toString'); + + t.equal(toPrimitive(coercibleFnObject), coercibleFnObject.toString(), 'coercibleFnObject coerces to non-stringified toString'); + t.equal(toPrimitive(coercibleFnObject, Number), coercibleFnObject.toString(), 'coercibleFnObject with hint Number coerces to non-stringified toString'); + t.equal(toPrimitive(coercibleFnObject, String), coercibleFnObject.toString(), 'coercibleFnObject with hint String coerces to non-stringified toString'); + + t.equal(toPrimitive({}), '[object Object]', '{} with no hint coerces to Object#toString'); + t.equal(toPrimitive({}, Number), '[object Object]', '{} with hint Number coerces to Object#toString'); + t.equal(toPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); + + t.equal(toPrimitive(toStringOnlyObject), toStringOnlyObject.toString(), 'toStringOnlyObject returns non-stringified toString'); + t.equal(toPrimitive(toStringOnlyObject, Number), toStringOnlyObject.toString(), 'toStringOnlyObject with hint Number returns non-stringified toString'); + t.equal(toPrimitive(toStringOnlyObject, String), toStringOnlyObject.toString(), 'toStringOnlyObject with hint String returns non-stringified toString'); + + t.equal(toPrimitive(valueOfOnlyObject), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, Number), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint Number returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, String), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint String returns non-stringified valueOf'); + + t.test('Symbol.toPrimitive', { skip: !hasSymbolToPrimitive }, function (st) { + var overriddenObject = { toString: st.fail, valueOf: st.fail }; + overriddenObject[Symbol.toPrimitive] = function (hint) { return String(hint); }; + + st.equal(toPrimitive(overriddenObject), 'default', 'object with Symbol.toPrimitive + no hint invokes that'); + st.equal(toPrimitive(overriddenObject, Number), 'number', 'object with Symbol.toPrimitive + hint Number invokes that'); + st.equal(toPrimitive(overriddenObject, String), 'string', 'object with Symbol.toPrimitive + hint String invokes that'); + + var nullToPrimitive = { toString: coercibleObject.toString, valueOf: coercibleObject.valueOf }; + nullToPrimitive[Symbol.toPrimitive] = null; + st.equal(toPrimitive(nullToPrimitive), toPrimitive(coercibleObject), 'object with no hint + null Symbol.toPrimitive ignores it'); + st.equal(toPrimitive(nullToPrimitive, Number), toPrimitive(coercibleObject, Number), 'object with hint Number + null Symbol.toPrimitive ignores it'); + st.equal(toPrimitive(nullToPrimitive, String), toPrimitive(coercibleObject, String), 'object with hint String + null Symbol.toPrimitive ignores it'); + + st.test('exceptions', function (sst) { + var nonFunctionToPrimitive = { toString: sst.fail, valueOf: sst.fail }; + nonFunctionToPrimitive[Symbol.toPrimitive] = {}; + sst['throws'](toPrimitive.bind(null, nonFunctionToPrimitive), TypeError, 'Symbol.toPrimitive returning a non-function throws'); + + var uncoercibleToPrimitive = { toString: sst.fail, valueOf: sst.fail }; + uncoercibleToPrimitive[Symbol.toPrimitive] = function (hint) { + return { toString: function () { return hint; } }; + }; + sst['throws'](toPrimitive.bind(null, uncoercibleToPrimitive), TypeError, 'Symbol.toPrimitive returning an object throws'); + + var throwingToPrimitive = { toString: sst.fail, valueOf: sst.fail }; + throwingToPrimitive[Symbol.toPrimitive] = function (hint) { throw new RangeError(hint); }; + sst['throws'](toPrimitive.bind(null, throwingToPrimitive), RangeError, 'Symbol.toPrimitive throwing throws'); + + sst.end(); + }); + + st.end(); + }); + + t.test('exceptions', function (st) { + st['throws'](toPrimitive.bind(null, uncoercibleObject), TypeError, 'uncoercibleObject throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleObject, Number), TypeError, 'uncoercibleObject with hint Number throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleObject, String), TypeError, 'uncoercibleObject with hint String throws a TypeError'); + + st['throws'](toPrimitive.bind(null, uncoercibleFnObject), TypeError, 'uncoercibleFnObject throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleFnObject, Number), TypeError, 'uncoercibleFnObject with hint Number throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleFnObject, String), TypeError, 'uncoercibleFnObject with hint String throws a TypeError'); + st.end(); + }); + t.end(); +}); diff --git a/node_modules/es-to-primitive/test/es5.js b/node_modules/es-to-primitive/test/es5.js new file mode 100644 index 0000000000000000000000000000000000000000..79444b0b4c091afef36dc7c906557e3047a1ff18 --- /dev/null +++ b/node_modules/es-to-primitive/test/es5.js @@ -0,0 +1,118 @@ +'use strict'; + +var test = require('tape'); +var toPrimitive = require('../es5'); +var is = require('object-is'); +var forEach = require('foreach'); +var functionName = require('function.prototype.name'); +var debug = require('object-inspect'); +var hasSymbols = require('has-symbols')(); + +test('function properties', function (t) { + t.equal(toPrimitive.length, 1, 'length is 1'); + t.equal(functionName(toPrimitive), 'ToPrimitive', 'name is ToPrimitive'); + + t.end(); +}); + +var primitives = [null, undefined, true, false, 0, -0, 42, NaN, Infinity, -Infinity, '', 'abc']; + +test('primitives', function (t) { + forEach(primitives, function (i) { + t.ok(is(toPrimitive(i), i), 'toPrimitive(' + debug(i) + ') returns the same value'); + t.ok(is(toPrimitive(i, String), i), 'toPrimitive(' + debug(i) + ', String) returns the same value'); + t.ok(is(toPrimitive(i, Number), i), 'toPrimitive(' + debug(i) + ', Number) returns the same value'); + }); + t.end(); +}); + +test('Symbols', { skip: !hasSymbols }, function (t) { + var symbols = [ + Symbol('foo'), + Symbol.iterator, + Symbol['for']('foo') // eslint-disable-line no-restricted-properties + ]; + forEach(symbols, function (sym) { + t.equal(toPrimitive(sym), sym, 'toPrimitive(' + debug(sym) + ') returns the same value'); + t.equal(toPrimitive(sym, String), sym, 'toPrimitive(' + debug(sym) + ', String) returns the same value'); + t.equal(toPrimitive(sym, Number), sym, 'toPrimitive(' + debug(sym) + ', Number) returns the same value'); + }); + + var primitiveSym = Symbol('primitiveSym'); + var stringSym = Symbol.prototype.toString.call(primitiveSym); + var objectSym = Object(primitiveSym); + t.equal(toPrimitive(objectSym), primitiveSym, 'toPrimitive(' + debug(objectSym) + ') returns ' + debug(primitiveSym)); + + // This is different from ES2015, as the ES5 algorithm doesn't account for the existence of Symbols: + t.equal(toPrimitive(objectSym, String), stringSym, 'toPrimitive(' + debug(objectSym) + ', String) returns ' + debug(stringSym)); + t.equal(toPrimitive(objectSym, Number), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', Number) returns ' + debug(primitiveSym)); + t.end(); +}); + +test('Arrays', function (t) { + var arrays = [[], ['a', 'b'], [1, 2]]; + forEach(arrays, function (arr) { + t.ok(is(toPrimitive(arr), arr.toString()), 'toPrimitive(' + debug(arr) + ') returns toString of the array'); + t.equal(toPrimitive(arr, String), arr.toString(), 'toPrimitive(' + debug(arr) + ') returns toString of the array'); + t.ok(is(toPrimitive(arr, Number), arr.toString()), 'toPrimitive(' + debug(arr) + ') returns toString of the array'); + }); + t.end(); +}); + +test('Dates', function (t) { + var dates = [new Date(), new Date(0), new Date(NaN)]; + forEach(dates, function (date) { + t.equal(toPrimitive(date), date.toString(), 'toPrimitive(' + debug(date) + ') returns toString of the date'); + t.equal(toPrimitive(date, String), date.toString(), 'toPrimitive(' + debug(date) + ') returns toString of the date'); + t.ok(is(toPrimitive(date, Number), date.valueOf()), 'toPrimitive(' + debug(date) + ') returns valueOf of the date'); + }); + t.end(); +}); + +var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; +var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; +var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; +var coercibleFnObject = { + valueOf: function () { return function valueOfFn() {}; }, + toString: function () { return 42; } +}; +var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; +var uncoercibleFnObject = { + valueOf: function () { return function valueOfFn() {}; }, + toString: function () { return function toStrFn() {}; } +}; + +test('Objects', function (t) { + t.equal(toPrimitive(coercibleObject), coercibleObject.valueOf(), 'coercibleObject with no hint coerces to valueOf'); + t.equal(toPrimitive(coercibleObject, String), coercibleObject.toString(), 'coercibleObject with hint String coerces to toString'); + t.equal(toPrimitive(coercibleObject, Number), coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf'); + + t.equal(toPrimitive(coercibleFnObject), coercibleFnObject.toString(), 'coercibleFnObject coerces to toString'); + t.equal(toPrimitive(coercibleFnObject, String), coercibleFnObject.toString(), 'coercibleFnObject with hint String coerces to toString'); + t.equal(toPrimitive(coercibleFnObject, Number), coercibleFnObject.toString(), 'coercibleFnObject with hint Number coerces to toString'); + + t.ok(is(toPrimitive({}), '[object Object]'), '{} with no hint coerces to Object#toString'); + t.equal(toPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); + t.ok(is(toPrimitive({}, Number), '[object Object]'), '{} with hint Number coerces to Object#toString'); + + t.equal(toPrimitive(toStringOnlyObject), toStringOnlyObject.toString(), 'toStringOnlyObject returns toString'); + t.equal(toPrimitive(toStringOnlyObject, String), toStringOnlyObject.toString(), 'toStringOnlyObject with hint String returns toString'); + t.equal(toPrimitive(toStringOnlyObject, Number), toStringOnlyObject.toString(), 'toStringOnlyObject with hint Number returns toString'); + + t.equal(toPrimitive(valueOfOnlyObject), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, String), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint String returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, Number), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint Number returns valueOf'); + + t.test('exceptions', function (st) { + st['throws'](toPrimitive.bind(null, uncoercibleObject), TypeError, 'uncoercibleObject throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleObject, String), TypeError, 'uncoercibleObject with hint String throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleObject, Number), TypeError, 'uncoercibleObject with hint Number throws a TypeError'); + + st['throws'](toPrimitive.bind(null, uncoercibleFnObject), TypeError, 'uncoercibleFnObject throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleFnObject, String), TypeError, 'uncoercibleFnObject with hint String throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleFnObject, Number), TypeError, 'uncoercibleFnObject with hint Number throws a TypeError'); + st.end(); + }); + + t.end(); +}); diff --git a/node_modules/es-to-primitive/test/es6.js b/node_modules/es-to-primitive/test/es6.js new file mode 100644 index 0000000000000000000000000000000000000000..16ea0e8f3f680d6acaff7c37124972bb301aefd3 --- /dev/null +++ b/node_modules/es-to-primitive/test/es6.js @@ -0,0 +1,151 @@ +'use strict'; + +var test = require('tape'); +var toPrimitive = require('../es6'); +var is = require('object-is'); +var forEach = require('foreach'); +var functionName = require('function.prototype.name'); +var debug = require('object-inspect'); + +var hasSymbols = require('has-symbols')(); +var hasSymbolToPrimitive = hasSymbols && typeof Symbol.toPrimitive === 'symbol'; + +test('function properties', function (t) { + t.equal(toPrimitive.length, 1, 'length is 1'); + t.equal(functionName(toPrimitive), 'ToPrimitive', 'name is ToPrimitive'); + + t.end(); +}); + +var primitives = [null, undefined, true, false, 0, -0, 42, NaN, Infinity, -Infinity, '', 'abc']; + +test('primitives', function (t) { + forEach(primitives, function (i) { + t.ok(is(toPrimitive(i), i), 'toPrimitive(' + debug(i) + ') returns the same value'); + t.ok(is(toPrimitive(i, String), i), 'toPrimitive(' + debug(i) + ', String) returns the same value'); + t.ok(is(toPrimitive(i, Number), i), 'toPrimitive(' + debug(i) + ', Number) returns the same value'); + }); + t.end(); +}); + +test('Symbols', { skip: !hasSymbols }, function (t) { + var symbols = [ + Symbol('foo'), + Symbol.iterator, + Symbol['for']('foo') // eslint-disable-line no-restricted-properties + ]; + forEach(symbols, function (sym) { + t.equal(toPrimitive(sym), sym, 'toPrimitive(' + debug(sym) + ') returns the same value'); + t.equal(toPrimitive(sym, String), sym, 'toPrimitive(' + debug(sym) + ', String) returns the same value'); + t.equal(toPrimitive(sym, Number), sym, 'toPrimitive(' + debug(sym) + ', Number) returns the same value'); + }); + + var primitiveSym = Symbol('primitiveSym'); + var objectSym = Object(primitiveSym); + t.equal(toPrimitive(objectSym), primitiveSym, 'toPrimitive(' + debug(objectSym) + ') returns ' + debug(primitiveSym)); + t.equal(toPrimitive(objectSym, String), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', String) returns ' + debug(primitiveSym)); + t.equal(toPrimitive(objectSym, Number), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', Number) returns ' + debug(primitiveSym)); + t.end(); +}); + +test('Arrays', function (t) { + var arrays = [[], ['a', 'b'], [1, 2]]; + forEach(arrays, function (arr) { + t.equal(toPrimitive(arr), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + t.equal(toPrimitive(arr, String), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + t.equal(toPrimitive(arr, Number), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + }); + t.end(); +}); + +test('Dates', function (t) { + var dates = [new Date(), new Date(0), new Date(NaN)]; + forEach(dates, function (date) { + t.equal(toPrimitive(date), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date'); + t.equal(toPrimitive(date, String), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date'); + t.ok(is(toPrimitive(date, Number), Number(date)), 'toPrimitive(' + debug(date) + ') returns the number version of the date'); + }); + t.end(); +}); + +var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; +var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; +var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; +var coercibleFnObject = { + valueOf: function () { return function valueOfFn() {}; }, + toString: function () { return 42; } +}; +var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; +var uncoercibleFnObject = { + valueOf: function () { return function valueOfFn() {}; }, + toString: function () { return function toStrFn() {}; } +}; + +test('Objects', function (t) { + t.equal(toPrimitive(coercibleObject), coercibleObject.valueOf(), 'coercibleObject with no hint coerces to valueOf'); + t.equal(toPrimitive(coercibleObject, Number), coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf'); + t.equal(toPrimitive(coercibleObject, String), coercibleObject.toString(), 'coercibleObject with hint String coerces to non-stringified toString'); + + t.equal(toPrimitive(coercibleFnObject), coercibleFnObject.toString(), 'coercibleFnObject coerces to non-stringified toString'); + t.equal(toPrimitive(coercibleFnObject, Number), coercibleFnObject.toString(), 'coercibleFnObject with hint Number coerces to non-stringified toString'); + t.equal(toPrimitive(coercibleFnObject, String), coercibleFnObject.toString(), 'coercibleFnObject with hint String coerces to non-stringified toString'); + + t.equal(toPrimitive({}), '[object Object]', '{} with no hint coerces to Object#toString'); + t.equal(toPrimitive({}, Number), '[object Object]', '{} with hint Number coerces to Object#toString'); + t.equal(toPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); + + t.equal(toPrimitive(toStringOnlyObject), toStringOnlyObject.toString(), 'toStringOnlyObject returns non-stringified toString'); + t.equal(toPrimitive(toStringOnlyObject, Number), toStringOnlyObject.toString(), 'toStringOnlyObject with hint Number returns non-stringified toString'); + t.equal(toPrimitive(toStringOnlyObject, String), toStringOnlyObject.toString(), 'toStringOnlyObject with hint String returns non-stringified toString'); + + t.equal(toPrimitive(valueOfOnlyObject), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, Number), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint Number returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, String), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint String returns non-stringified valueOf'); + + t.test('Symbol.toPrimitive', { skip: !hasSymbolToPrimitive }, function (st) { + var overriddenObject = { toString: st.fail, valueOf: st.fail }; + overriddenObject[Symbol.toPrimitive] = function (hint) { return String(hint); }; + + st.equal(toPrimitive(overriddenObject), 'default', 'object with Symbol.toPrimitive + no hint invokes that'); + st.equal(toPrimitive(overriddenObject, Number), 'number', 'object with Symbol.toPrimitive + hint Number invokes that'); + st.equal(toPrimitive(overriddenObject, String), 'string', 'object with Symbol.toPrimitive + hint String invokes that'); + + var nullToPrimitive = { toString: coercibleObject.toString, valueOf: coercibleObject.valueOf }; + nullToPrimitive[Symbol.toPrimitive] = null; + st.equal(toPrimitive(nullToPrimitive), toPrimitive(coercibleObject), 'object with no hint + null Symbol.toPrimitive ignores it'); + st.equal(toPrimitive(nullToPrimitive, Number), toPrimitive(coercibleObject, Number), 'object with hint Number + null Symbol.toPrimitive ignores it'); + st.equal(toPrimitive(nullToPrimitive, String), toPrimitive(coercibleObject, String), 'object with hint String + null Symbol.toPrimitive ignores it'); + + st.test('exceptions', function (sst) { + var nonFunctionToPrimitive = { toString: sst.fail, valueOf: sst.fail }; + nonFunctionToPrimitive[Symbol.toPrimitive] = {}; + sst['throws'](toPrimitive.bind(null, nonFunctionToPrimitive), TypeError, 'Symbol.toPrimitive returning a non-function throws'); + + var uncoercibleToPrimitive = { toString: sst.fail, valueOf: sst.fail }; + uncoercibleToPrimitive[Symbol.toPrimitive] = function (hint) { + return { toString: function () { return hint; } }; + }; + sst['throws'](toPrimitive.bind(null, uncoercibleToPrimitive), TypeError, 'Symbol.toPrimitive returning an object throws'); + + var throwingToPrimitive = { toString: sst.fail, valueOf: sst.fail }; + throwingToPrimitive[Symbol.toPrimitive] = function (hint) { throw new RangeError(hint); }; + sst['throws'](toPrimitive.bind(null, throwingToPrimitive), RangeError, 'Symbol.toPrimitive throwing throws'); + + sst.end(); + }); + + st.end(); + }); + + t.test('exceptions', function (st) { + st['throws'](toPrimitive.bind(null, uncoercibleObject), TypeError, 'uncoercibleObject throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleObject, Number), TypeError, 'uncoercibleObject with hint Number throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleObject, String), TypeError, 'uncoercibleObject with hint String throws a TypeError'); + + st['throws'](toPrimitive.bind(null, uncoercibleFnObject), TypeError, 'uncoercibleFnObject throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleFnObject, Number), TypeError, 'uncoercibleFnObject with hint Number throws a TypeError'); + st['throws'](toPrimitive.bind(null, uncoercibleFnObject, String), TypeError, 'uncoercibleFnObject with hint String throws a TypeError'); + st.end(); + }); + t.end(); +}); diff --git a/node_modules/es-to-primitive/test/index.js b/node_modules/es-to-primitive/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ad71f39e2581e72e94435c3bbf8086fbaa29e8a6 --- /dev/null +++ b/node_modules/es-to-primitive/test/index.js @@ -0,0 +1,20 @@ +'use strict'; + +var toPrimitive = require('../'); +var ES5 = require('../es5'); +var ES6 = require('../es6'); +var ES2015 = require('../es2015'); + +var test = require('tape'); + +test('default export', function (t) { + t.equal(toPrimitive, ES2015, 'default export is ES2015'); + t.equal(toPrimitive.ES5, ES5, 'ES5 property has ES5 method'); + t.equal(toPrimitive.ES6, ES6, 'ES6 property has ES6 method'); + t.equal(toPrimitive.ES2015, ES2015, 'ES2015 property has ES2015 method'); + t.end(); +}); + +require('./es5'); +require('./es6'); +require('./es2015'); diff --git a/node_modules/escape-string-regexp/index.d.ts b/node_modules/escape-string-regexp/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d34edc7c5488acb084509b460634bc76bd9f4ec --- /dev/null +++ b/node_modules/escape-string-regexp/index.d.ts @@ -0,0 +1,18 @@ +/** +Escape RegExp special characters. + +You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character class. + +@example +``` +import escapeStringRegexp = require('escape-string-regexp'); + +const escapedString = escapeStringRegexp('How much $ for a 🦄?'); +//=> 'How much \\$ for a 🦄\\?' + +new RegExp(escapedString); +``` +*/ +declare const escapeStringRegexp: (string: string) => string; + +export = escapeStringRegexp; diff --git a/node_modules/escape-string-regexp/index.js b/node_modules/escape-string-regexp/index.js new file mode 100644 index 0000000000000000000000000000000000000000..387c5615a776b4a3441e7d1fd526f460d61e595e --- /dev/null +++ b/node_modules/escape-string-regexp/index.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = string => { + if (typeof string !== 'string') { + throw new TypeError('Expected a string'); + } + + // Escape characters with special meaning either inside or outside character sets. + // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. + return string + .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') + .replace(/-/g, '\\x2d'); +}; diff --git a/node_modules/escape-string-regexp/license b/node_modules/escape-string-regexp/license new file mode 100644 index 0000000000000000000000000000000000000000..fa7ceba3eb4a9657a9db7f3ffca4e4e97a9019de --- /dev/null +++ b/node_modules/escape-string-regexp/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (https://sindresorhus.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. diff --git a/node_modules/escape-string-regexp/package.json b/node_modules/escape-string-regexp/package.json new file mode 100644 index 0000000000000000000000000000000000000000..c6eb4a91bc914b2cb46f1e09117af3a4774f4d44 --- /dev/null +++ b/node_modules/escape-string-regexp/package.json @@ -0,0 +1,38 @@ +{ + "name": "escape-string-regexp", + "version": "4.0.0", + "description": "Escape RegExp special characters", + "license": "MIT", + "repository": "sindresorhus/escape-string-regexp", + "funding": "https://github.com/sponsors/sindresorhus", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "https://sindresorhus.com" + }, + "engines": { + "node": ">=10" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "escape", + "regex", + "regexp", + "regular", + "expression", + "string", + "special", + "characters" + ], + "devDependencies": { + "ava": "^1.4.1", + "tsd": "^0.11.0", + "xo": "^0.28.3" + } +} diff --git a/node_modules/escape-string-regexp/readme.md b/node_modules/escape-string-regexp/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..2945dfcb23ea118a6f7abeb12741d139a92eecb0 --- /dev/null +++ b/node_modules/escape-string-regexp/readme.md @@ -0,0 +1,34 @@ +# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp) + +> Escape RegExp special characters + +## Install + +``` +$ npm install escape-string-regexp +``` + +## Usage + +```js +const escapeStringRegexp = require('escape-string-regexp'); + +const escapedString = escapeStringRegexp('How much $ for a 🦄?'); +//=> 'How much \\$ for a 🦄\\?' + +new RegExp(escapedString); +``` + +You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character class. + +--- + +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
diff --git a/node_modules/estree-walker/CHANGELOG.md b/node_modules/estree-walker/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..06b21e967f02ef5b5e77323fde568bf64426e8e4 --- /dev/null +++ b/node_modules/estree-walker/CHANGELOG.md @@ -0,0 +1,55 @@ +# changelog + +## 0.6.1 + +* Only traverse nodes that exist and have a type ([#9](https://github.com/Rich-Harris/estree-walker/pull/9)) +* Only cache keys for nodes with a type ([#8](https://github.com/Rich-Harris/estree-walker/pull/8)) + +## 0.6.0 + +* Fix walker context type +* Update deps, remove unncessary Bublé transformation + +## 0.5.2 + +* Add types to package + +## 0.5.1 + +* Prevent context corruption when `walk()` is called during a walk + +## 0.5.0 + +* Export `childKeys`, for manually fixing in case of malformed ASTs + +## 0.4.0 + +* Add TypeScript typings ([#3](https://github.com/Rich-Harris/estree-walker/pull/3)) + +## 0.3.1 + +* Include `pkg.repository` ([#2](https://github.com/Rich-Harris/estree-walker/pull/2)) + +## 0.3.0 + +* More predictable ordering + +## 0.2.1 + +* Keep `context` shape + +## 0.2.0 + +* Add ES6 build + +## 0.1.3 + +* npm snafu + +## 0.1.2 + +* Pass current prop and index to `enter`/`leave` callbacks + +## 0.1.1 + +* First release diff --git a/node_modules/estree-walker/README.md b/node_modules/estree-walker/README.md new file mode 100644 index 0000000000000000000000000000000000000000..94dd400564518ea8c2f2105b7de28b18e136a29e --- /dev/null +++ b/node_modules/estree-walker/README.md @@ -0,0 +1,45 @@ +# estree-walker + +Simple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn). + + +## Installation + +```bash +npm i estree-walker +``` + + +## Usage + +```js +var walk = require( 'estree-walker' ).walk; +var acorn = require( 'acorn' ); + +ast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn + +walk( ast, { + enter: function ( node, parent, prop, index ) { + // some code happens + }, + leave: function ( node, parent, prop, index ) { + // some code happens + } +}); +``` + +Inside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called. + + +## Why not use estraverse? + +The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys. + +estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.) + +None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful. + + +## License + +MIT diff --git a/node_modules/estree-walker/dist/estree-walker.umd.js b/node_modules/estree-walker/dist/estree-walker.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..f070f179c17acc59321b75053b6075da22978315 --- /dev/null +++ b/node_modules/estree-walker/dist/estree-walker.umd.js @@ -0,0 +1,65 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.estreeWalker = {}))); +}(this, (function (exports) { 'use strict'; + + function walk(ast, { enter, leave }) { + visit(ast, null, enter, leave); + } + + let shouldSkip = false; + const context = { skip: () => shouldSkip = true }; + + const childKeys = {}; + + const toString = Object.prototype.toString; + + function isArray(thing) { + return toString.call(thing) === '[object Array]'; + } + + function visit(node, parent, enter, leave, prop, index) { + if (!node) return; + + if (enter) { + const _shouldSkip = shouldSkip; + shouldSkip = false; + enter.call(context, node, parent, prop, index); + const skipped = shouldSkip; + shouldSkip = _shouldSkip; + + if (skipped) return; + } + + const keys = node.type && childKeys[node.type] || ( + childKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object') + ); + + for (let i = 0; i < keys.length; i += 1) { + const key = keys[i]; + const value = node[key]; + + if (isArray(value)) { + for (let j = 0; j < value.length; j += 1) { + value[j] && value[j].type && visit(value[j], node, enter, leave, key, j); + } + } + + else if (value && value.type) { + visit(value, node, enter, leave, key, null); + } + } + + if (leave) { + leave(node, parent, prop, index); + } + } + + exports.walk = walk; + exports.childKeys = childKeys; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=estree-walker.umd.js.map diff --git a/node_modules/estree-walker/dist/estree-walker.umd.js.map b/node_modules/estree-walker/dist/estree-walker.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3bc386209868ac9a588ba1e68e5d8274947eb4a0 --- /dev/null +++ b/node_modules/estree-walker/dist/estree-walker.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"estree-walker.umd.js","sources":["../src/estree-walker.js"],"sourcesContent":["export function walk(ast, { enter, leave }) {\n\tvisit(ast, null, enter, leave);\n}\n\nlet shouldSkip = false;\nconst context = { skip: () => shouldSkip = true };\n\nexport const childKeys = {};\n\nconst toString = Object.prototype.toString;\n\nfunction isArray(thing) {\n\treturn toString.call(thing) === '[object Array]';\n}\n\nfunction visit(node, parent, enter, leave, prop, index) {\n\tif (!node) return;\n\n\tif (enter) {\n\t\tconst _shouldSkip = shouldSkip;\n\t\tshouldSkip = false;\n\t\tenter.call(context, node, parent, prop, index);\n\t\tconst skipped = shouldSkip;\n\t\tshouldSkip = _shouldSkip;\n\n\t\tif (skipped) return;\n\t}\n\n\tconst keys = node.type && childKeys[node.type] || (\n\t\tchildKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object')\n\t);\n\n\tfor (let i = 0; i < keys.length; i += 1) {\n\t\tconst key = keys[i];\n\t\tconst value = node[key];\n\n\t\tif (isArray(value)) {\n\t\t\tfor (let j = 0; j < value.length; j += 1) {\n\t\t\t\tvalue[j] && value[j].type && visit(value[j], node, enter, leave, key, j);\n\t\t\t}\n\t\t}\n\n\t\telse if (value && value.type) {\n\t\t\tvisit(value, node, enter, leave, key, null);\n\t\t}\n\t}\n\n\tif (leave) {\n\t\tleave(node, parent, prop, index);\n\t}\n}\n"],"names":[],"mappings":";;;;;;CAAO,SAAS,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;CAC5C,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;CAChC,CAAC;;CAED,IAAI,UAAU,GAAG,KAAK,CAAC;CACvB,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,GAAG,IAAI,EAAE,CAAC;;AAElD,AAAY,OAAC,SAAS,GAAG,EAAE,CAAC;;CAE5B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;;CAE3C,SAAS,OAAO,CAAC,KAAK,EAAE;CACxB,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,gBAAgB,CAAC;CAClD,CAAC;;CAED,SAAS,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;CACxD,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO;;CAEnB,CAAC,IAAI,KAAK,EAAE;CACZ,EAAE,MAAM,WAAW,GAAG,UAAU,CAAC;CACjC,EAAE,UAAU,GAAG,KAAK,CAAC;CACrB,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACjD,EAAE,MAAM,OAAO,GAA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I,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACnC,EAAE;CACF,CAAC;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/estree-walker/index.d.ts b/node_modules/estree-walker/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..37fe76a02c5683ebdfd36a23c5e729216cd00a56 --- /dev/null +++ b/node_modules/estree-walker/index.d.ts @@ -0,0 +1,27 @@ +declare module "estree-walker" { + export interface Node { + start: number; + end: number; + type: string; + [propName: string]: any; + } + + export type WalkerContext = { + skip: () => void; + }; + + export type WalkerListener = ( + this: WalkerContext, + node: Node, + parent?: Node, + prop?: string, + index?: number + ) => void; + + export interface WalkerOptions { + enter?: WalkerListener; + leave?: WalkerListener; + } + + export function walk(ast: Node, options: WalkerOptions): void; +} diff --git a/node_modules/estree-walker/package.json b/node_modules/estree-walker/package.json new file mode 100644 index 0000000000000000000000000000000000000000..00a2544fc9114e78b2ccfa2f4ab0c297fbdafbda --- /dev/null +++ b/node_modules/estree-walker/package.json @@ -0,0 +1,30 @@ +{ + "name": "estree-walker", + "description": "Traverse an ESTree-compliant AST", + "version": "0.6.1", + "author": "Rich Harris", + "license": "MIT", + "typings": "index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/Rich-Harris/estree-walker" + }, + "main": "dist/estree-walker.umd.js", + "module": "src/estree-walker.js", + "scripts": { + "prepublishOnly": "npm test", + "build": "rollup -c", + "test": "mocha test/test.js", + "pretest": "npm run build" + }, + "devDependencies": { + "mocha": "^5.2.0", + "rollup": "^0.67.3" + }, + "files": [ + "src", + "dist", + "index.d.ts", + "README.md" + ] +} diff --git a/node_modules/estree-walker/src/estree-walker.js b/node_modules/estree-walker/src/estree-walker.js new file mode 100644 index 0000000000000000000000000000000000000000..6ecd498f484255b6910a357c1f15d9f32e5bfbe5 --- /dev/null +++ b/node_modules/estree-walker/src/estree-walker.js @@ -0,0 +1,51 @@ +export function walk(ast, { enter, leave }) { + visit(ast, null, enter, leave); +} + +let shouldSkip = false; +const context = { skip: () => shouldSkip = true }; + +export const childKeys = {}; + +const toString = Object.prototype.toString; + +function isArray(thing) { + return toString.call(thing) === '[object Array]'; +} + +function visit(node, parent, enter, leave, prop, index) { + if (!node) return; + + if (enter) { + const _shouldSkip = shouldSkip; + shouldSkip = false; + enter.call(context, node, parent, prop, index); + const skipped = shouldSkip; + shouldSkip = _shouldSkip; + + if (skipped) return; + } + + const keys = node.type && childKeys[node.type] || ( + childKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object') + ); + + for (let i = 0; i < keys.length; i += 1) { + const key = keys[i]; + const value = node[key]; + + if (isArray(value)) { + for (let j = 0; j < value.length; j += 1) { + value[j] && value[j].type && visit(value[j], node, enter, leave, key, j); + } + } + + else if (value && value.type) { + visit(value, node, enter, leave, key, null); + } + } + + if (leave) { + leave(node, parent, prop, index); + } +} diff --git a/node_modules/exit-hook/index.d.ts b/node_modules/exit-hook/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f7aed9770bc6603a6304feca2acfbea25f37de5f --- /dev/null +++ b/node_modules/exit-hook/index.d.ts @@ -0,0 +1,37 @@ +/** +Run some code when the process exits. + +The `process.on('exit')` event doesn't catch all the ways a process can exit. + +This package is useful for cleaning up before exiting. + +@param callback - The callback to execute when the process exits. +@returns A function that removes the hook when called. + +@example +``` +import exitHook = require('exit-hook'); + +exitHook(() => { + console.log('Exiting'); +}); + +// You can add multiple hooks, even across files +exitHook(() => { + console.log('Exiting 2'); +}); + +throw new Error('🦄'); + +//=> 'Exiting' +//=> 'Exiting 2' + +// Removing an exit hook: +const unsubscribe = exitHook(() => {}); + +unsubscribe(); +``` +*/ +declare function exitHook(callback: () => void): () => void; + +export = exitHook; diff --git a/node_modules/exit-hook/index.js b/node_modules/exit-hook/index.js new file mode 100644 index 0000000000000000000000000000000000000000..fc309b0fbb51671054b1c0e43263d3c58c9b9f45 --- /dev/null +++ b/node_modules/exit-hook/index.js @@ -0,0 +1,46 @@ +'use strict'; + +const callbacks = new Set(); +let isCalled = false; +let isRegistered = false; + +function exit(exit, signal) { + if (isCalled) { + return; + } + + isCalled = true; + + for (const callback of callbacks) { + callback(); + } + + if (exit === true) { + process.exit(128 + signal); // eslint-disable-line unicorn/no-process-exit + } +} + +module.exports = callback => { + callbacks.add(callback); + + if (!isRegistered) { + isRegistered = true; + + process.once('exit', exit); + process.once('SIGINT', exit.bind(null, true, 2)); + process.once('SIGTERM', exit.bind(null, true, 15)); + + // PM2 Cluster shutdown message. Caught to support async handlers with pm2, needed because + // explicitly calling process.exit() doesn't trigger the beforeExit event, and the exit + // event cannot support async handlers, since the event loop is never called after it. + process.on('message', message => { + if (message === 'shutdown') { + exit(true, -128); + } + }); + } + + return () => { + callbacks.delete(callback); + }; +}; diff --git a/node_modules/exit-hook/license b/node_modules/exit-hook/license new file mode 100644 index 0000000000000000000000000000000000000000..fa7ceba3eb4a9657a9db7f3ffca4e4e97a9019de --- /dev/null +++ b/node_modules/exit-hook/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (https://sindresorhus.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. diff --git a/node_modules/exit-hook/package.json b/node_modules/exit-hook/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3ef0ea86dc9b54d2b6ab509760fa64f43cc1a671 --- /dev/null +++ b/node_modules/exit-hook/package.json @@ -0,0 +1,45 @@ +{ + "name": "exit-hook", + "version": "2.2.1", + "description": "Run some code when the process exits", + "license": "MIT", + "repository": "sindresorhus/exit-hook", + "funding": "https://github.com/sponsors/sindresorhus", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "https://sindresorhus.com" + }, + "engines": { + "node": ">=6" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "exit", + "quit", + "process", + "hook", + "graceful", + "handler", + "shutdown", + "sigterm", + "sigint", + "terminate", + "kill", + "stop", + "event", + "signal" + ], + "devDependencies": { + "ava": "^1.4.1", + "execa": "^1.0.0", + "tsd": "^0.7.2", + "xo": "^0.24.0" + } +} diff --git a/node_modules/exit-hook/readme.md b/node_modules/exit-hook/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7a2cb9129fe3606871b3d651ac3415ac3a7f --- /dev/null +++ b/node_modules/exit-hook/readme.md @@ -0,0 +1,67 @@ +# exit-hook + +> Run some code when the process exits + +The `process.on('exit')` event doesn't catch all the ways a process can exit. + +This package is useful for cleaning up before exiting. + +## Install + +``` +$ npm install exit-hook +``` + +## Usage + +```js +const exitHook = require('exit-hook'); + +exitHook(() => { + console.log('Exiting'); +}); + +// You can add multiple hooks, even across files +exitHook(() => { + console.log('Exiting 2'); +}); + +throw new Error('🦄'); + +//=> 'Exiting' +//=> 'Exiting 2' +``` + +Removing an exit hook: + +```js +const exitHook = require('exit-hook'); + +const unsubscribe = exitHook(() => {}); + +unsubscribe(); +``` + +## API + +### exitHook(callback) + +Returns a function that removes the hook when called. + +#### callback + +Type: `Function` + +The callback to execute when the process exits. + +--- + +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
diff --git a/node_modules/extend/.editorconfig b/node_modules/extend/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..bc228f8269443bf772b437890dde7756a3e8a894 --- /dev/null +++ b/node_modules/extend/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 150 + +[CHANGELOG.md] +indent_style = space +indent_size = 2 + +[*.json] +max_line_length = off + +[Makefile] +max_line_length = off diff --git a/node_modules/extend/.eslintrc b/node_modules/extend/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..a34cf2831b7c383001ea86570f8b63686c285c60 --- /dev/null +++ b/node_modules/extend/.eslintrc @@ -0,0 +1,17 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "complexity": [2, 20], + "eqeqeq": [2, "allow-null"], + "func-name-matching": [1], + "max-depth": [1, 4], + "max-statements": [2, 26], + "no-extra-parens": [1], + "no-magic-numbers": [0], + "no-restricted-syntax": [2, "BreakStatement", "ContinueStatement", "DebuggerStatement", "LabeledStatement", "WithStatement"], + "sort-keys": [0], + } +} diff --git a/node_modules/extend/.jscs.json b/node_modules/extend/.jscs.json new file mode 100644 index 0000000000000000000000000000000000000000..3cce01d7832943debaf60e58033d8a110daacbca --- /dev/null +++ b/node_modules/extend/.jscs.json @@ -0,0 +1,175 @@ +{ + "es3": true, + + "additionalRules": [], + + "requireSemicolons": true, + + "disallowMultipleSpaces": true, + + "disallowIdentifierNames": [], + + "requireCurlyBraces": { + "allExcept": [], + "keywords": ["if", "else", "for", "while", "do", "try", "catch"] + }, + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "disallowSpaceBeforeComma": true, + "disallowSpaceAfterComma": false, + "disallowSpaceBeforeSemicolon": true, + + "disallowNodeTypes": [ + "DebuggerStatement", + "LabeledStatement", + "SwitchCase", + "SwitchStatement", + "WithStatement" + ], + + "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] }, + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": { "allExcept": ["keywords"] }, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + }, + + "disallowOperatorBeforeLineBreak": [], + + "requireSpaceBeforeKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "finally", + "while", + "with", + "return" + ], + + "validateAlignedFunctionParameters": { + "lineBreakAfterOpeningBraces": true, + "lineBreakBeforeClosingBraces": true + }, + + "requirePaddingNewLinesBeforeExport": true, + + "validateNewlineAfterArrayElements": { + "maximum": 6 + }, + + "requirePaddingNewLinesAfterUseStrict": true, + + "disallowArrowFunctions": true, + + "disallowMultiLineTernary": true, + + "validateOrderInObjectKeys": false, + + "disallowIdenticalDestructuringNames": true, + + "disallowNestedTernaries": { "maxLevel": 1 }, + + "requireSpaceAfterComma": { "allExcept": ["trailing"] }, + "requireAlignedMultilineParams": false, + + "requireSpacesInGenerator": { + "afterStar": true + }, + + "disallowSpacesInGenerator": { + "beforeStar": true + }, + + "disallowVar": false, + + "requireArrayDestructuring": false, + + "requireEnhancedObjectLiterals": false, + + "requireObjectDestructuring": false, + + "requireEarlyReturn": false, + + "requireCapitalizedConstructorsNew": { + "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] + }, + + "requireImportAlphabetized": false, + + "requireSpaceBeforeObjectValues": true, + "requireSpaceBeforeDestructuredValues": true, + + "disallowSpacesInsideTemplateStringPlaceholders": true, + + "disallowArrayDestructuringReturn": false, + + "requireNewlineBeforeSingleStatementsInIf": false, + + "disallowUnusedVariables": true, + + "requireSpacesInsideImportedObjectBraces": true, + + "requireUseStrict": true +} + diff --git a/node_modules/extend/.travis.yml b/node_modules/extend/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..5ccdfc4948155fbc286e92c049aa2a4468858762 --- /dev/null +++ b/node_modules/extend/.travis.yml @@ -0,0 +1,230 @@ +language: node_js +os: + - linux +node_js: + - "10.7" + - "9.11" + - "8.11" + - "7.10" + - "6.14" + - "5.12" + - "4.9" + - "iojs-v3.3" + - "iojs-v2.5" + - "iojs-v1.8" + - "0.12" + - "0.10" + - "0.8" +before_install: + - 'case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac' + - 'nvm install-latest-npm' +install: + - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' +script: + - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi' + - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi' + - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi' + - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi' +sudo: false +env: + - TEST=true +matrix: + fast_finish: true + include: + - node_js: "lts/*" + env: PRETEST=true + - node_js: "lts/*" + env: POSTTEST=true + - node_js: "4" + env: COVERAGE=true + - node_js: "10.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "10.5" + env: TEST=true ALLOW_FAILURE=true + - node_js: "10.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "10.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "10.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "10.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "10.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.10" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.9" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.8" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.7" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.5" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "9.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.10" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.9" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.8" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.7" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.5" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "8.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.9" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.8" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.7" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.5" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "7.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.13" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.12" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.11" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.10" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.9" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.8" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.7" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.5" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "6.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.11" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.10" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.9" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.8" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.7" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.5" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "5.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.8" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.7" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.5" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "4.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v3.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v3.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v3.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v2.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v2.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v2.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v2.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v2.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v1.7" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v1.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v1.5" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v1.4" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v1.3" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v1.2" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v1.1" + env: TEST=true ALLOW_FAILURE=true + - node_js: "iojs-v1.0" + env: TEST=true ALLOW_FAILURE=true + - node_js: "0.11" + env: TEST=true ALLOW_FAILURE=true + - node_js: "0.9" + env: TEST=true ALLOW_FAILURE=true + - node_js: "0.6" + env: TEST=true ALLOW_FAILURE=true + - node_js: "0.4" + env: TEST=true ALLOW_FAILURE=true + allow_failures: + - os: osx + - env: TEST=true ALLOW_FAILURE=true diff --git a/node_modules/extend/CHANGELOG.md b/node_modules/extend/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..2cf7de6fb3ae5dc0c67aeb92f2d6969adc36630d --- /dev/null +++ b/node_modules/extend/CHANGELOG.md @@ -0,0 +1,83 @@ +3.0.2 / 2018-07-19 +================== + * [Fix] Prevent merging `__proto__` property (#48) + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` + * [Tests] up to `node` `v10.7`, `v9.11`, `v8.11`, `v7.10`, `v6.14`, `v4.9`; use `nvm install-latest-npm` + +3.0.1 / 2017-04-27 +================== + * [Fix] deep extending should work with a non-object (#46) + * [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config` + * [Tests] up to `node` `v7.9`, `v6.10`, `v4.8`; improve matrix + * [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. + * [Docs] Add example to readme (#34) + +3.0.0 / 2015-07-01 +================== + * [Possible breaking change] Use global "strict" directive (#32) + * [Tests] `int` is an ES3 reserved word + * [Tests] Test up to `io.js` `v2.3` + * [Tests] Add `npm run eslint` + * [Dev Deps] Update `covert`, `jscs` + +2.0.1 / 2015-04-25 +================== + * Use an inline `isArray` check, for ES3 browsers. (#27) + * Some old browsers fail when an identifier is `toString` + * Test latest `node` and `io.js` versions on `travis-ci`; speed up builds + * Add license info to package.json (#25) + * Update `tape`, `jscs` + * Adding a CHANGELOG + +2.0.0 / 2014-10-01 +================== + * Increase code coverage to 100%; run code coverage as part of tests + * Add `npm run lint`; Run linter as part of tests + * Remove nodeType and setInterval checks in isPlainObject + * Updating `tape`, `jscs`, `covert` + * General style and README cleanup + +1.3.0 / 2014-06-20 +================== + * Add component.json for browser support (#18) + * Use SVG for badges in README (#16) + * Updating `tape`, `covert` + * Updating travis-ci to work with multiple node versions + * Fix `deep === false` bug (returning target as {}) (#14) + * Fixing constructor checks in isPlainObject + * Adding additional test coverage + * Adding `npm run coverage` + * Add LICENSE (#13) + * Adding a warning about `false`, per #11 + * General style and whitespace cleanup + +1.2.1 / 2013-09-14 +================== + * Fixing hasOwnProperty bugs that would only have shown up in specific browsers. Fixes #8 + * Updating `tape` + +1.2.0 / 2013-09-02 +================== + * Updating the README: add badges + * Adding a missing variable reference. + * Using `tape` instead of `buster` for tests; add more tests (#7) + * Adding node 0.10 to Travis CI (#6) + * Enabling "npm test" and cleaning up package.json (#5) + * Add Travis CI. + +1.1.3 / 2012-12-06 +================== + * Added unit tests. + * Ensure extend function is named. (Looks nicer in a stack trace.) + * README cleanup. + +1.1.1 / 2012-11-07 +================== + * README cleanup. + * Added installation instructions. + * Added a missing semicolon + +1.0.0 / 2012-04-08 +================== + * Initial commit + diff --git a/node_modules/extend/LICENSE b/node_modules/extend/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..e16d6a56ca64e235d9065c37f4566a0fe0be28d4 --- /dev/null +++ b/node_modules/extend/LICENSE @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) 2014 Stefan Thomas + +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. + diff --git a/node_modules/extend/README.md b/node_modules/extend/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5b8249aa95e5d34927c0b44988b29fcda85cb1cd --- /dev/null +++ b/node_modules/extend/README.md @@ -0,0 +1,81 @@ +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] + +# extend() for Node.js [![Version Badge][npm-version-png]][npm-url] + +`node-extend` is a port of the classic extend() method from jQuery. It behaves as you expect. It is simple, tried and true. + +Notes: + +* Since Node.js >= 4, + [`Object.assign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) + now offers the same functionality natively (but without the "deep copy" option). + See [ECMAScript 2015 (ES6) in Node.js](https://nodejs.org/en/docs/es6). +* Some native implementations of `Object.assign` in both Node.js and many + browsers (since NPM modules are for the browser too) may not be fully + spec-compliant. + Check [`object.assign`](https://www.npmjs.com/package/object.assign) module for + a compliant candidate. + +## Installation + +This package is available on [npm][npm-url] as: `extend` + +``` sh +npm install extend +``` + +## Usage + +**Syntax:** extend **(** [`deep`], `target`, `object1`, [`objectN`] **)** + +*Extend one object with one or more others, returning the modified object.* + +**Example:** + +``` js +var extend = require('extend'); +extend(targetObject, object1, object2); +``` + +Keep in mind that the target object will be modified, and will be returned from extend(). + +If a boolean true is specified as the first argument, extend performs a deep copy, recursively copying any objects it finds. Otherwise, the copy will share structure with the original object(s). +Undefined properties are not copied. However, properties inherited from the object's prototype will be copied over. +Warning: passing `false` as the first argument is not supported. + +### Arguments + +* `deep` *Boolean* (optional) +If set, the merge becomes recursive (i.e. deep copy). +* `target` *Object* +The object to extend. +* `object1` *Object* +The object that will be merged into the first. +* `objectN` *Object* (Optional) +More objects to merge into the first. + +## License + +`node-extend` is licensed under the [MIT License][mit-license-url]. + +## Acknowledgements + +All credit to the jQuery authors for perfecting this amazing utility. + +Ported to Node.js by [Stefan Thomas][github-justmoon] with contributions by [Jonathan Buchanan][github-insin] and [Jordan Harband][github-ljharb]. + +[travis-svg]: https://travis-ci.org/justmoon/node-extend.svg +[travis-url]: https://travis-ci.org/justmoon/node-extend +[npm-url]: https://npmjs.org/package/extend +[mit-license-url]: http://opensource.org/licenses/MIT +[github-justmoon]: https://github.com/justmoon +[github-insin]: https://github.com/insin +[github-ljharb]: https://github.com/ljharb +[npm-version-png]: http://versionbadg.es/justmoon/node-extend.svg +[deps-svg]: https://david-dm.org/justmoon/node-extend.svg +[deps-url]: https://david-dm.org/justmoon/node-extend +[dev-deps-svg]: https://david-dm.org/justmoon/node-extend/dev-status.svg +[dev-deps-url]: https://david-dm.org/justmoon/node-extend#info=devDependencies + diff --git a/node_modules/extend/component.json b/node_modules/extend/component.json new file mode 100644 index 0000000000000000000000000000000000000000..1500a2f37181823ef8500854e8bbe613fbc5215a --- /dev/null +++ b/node_modules/extend/component.json @@ -0,0 +1,32 @@ +{ + "name": "extend", + "author": "Stefan Thomas (http://www.justmoon.net)", + "version": "3.0.0", + "description": "Port of jQuery.extend for node.js and the browser.", + "scripts": [ + "index.js" + ], + "contributors": [ + { + "name": "Jordan Harband", + "url": "https://github.com/ljharb" + } + ], + "keywords": [ + "extend", + "clone", + "merge" + ], + "repository" : { + "type": "git", + "url": "https://github.com/justmoon/node-extend.git" + }, + "dependencies": { + }, + "devDependencies": { + "tape" : "~3.0.0", + "covert": "~0.4.0", + "jscs": "~1.6.2" + } +} + diff --git a/node_modules/extend/index.js b/node_modules/extend/index.js new file mode 100644 index 0000000000000000000000000000000000000000..2aa3faae68c43e0221134e0ee72a713fd7d47a5f --- /dev/null +++ b/node_modules/extend/index.js @@ -0,0 +1,117 @@ +'use strict'; + +var hasOwn = Object.prototype.hasOwnProperty; +var toStr = Object.prototype.toString; +var defineProperty = Object.defineProperty; +var gOPD = Object.getOwnPropertyDescriptor; + +var isArray = function isArray(arr) { + if (typeof Array.isArray === 'function') { + return Array.isArray(arr); + } + + return toStr.call(arr) === '[object Array]'; +}; + +var isPlainObject = function isPlainObject(obj) { + if (!obj || toStr.call(obj) !== '[object Object]') { + return false; + } + + var hasOwnConstructor = hasOwn.call(obj, 'constructor'); + var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); + // Not own constructor property must be Object + if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + var key; + for (key in obj) { /**/ } + + return typeof key === 'undefined' || hasOwn.call(obj, key); +}; + +// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target +var setProperty = function setProperty(target, options) { + if (defineProperty && options.name === '__proto__') { + defineProperty(target, options.name, { + enumerable: true, + configurable: true, + value: options.newValue, + writable: true + }); + } else { + target[options.name] = options.newValue; + } +}; + +// Return undefined instead of __proto__ if '__proto__' is not an own property +var getProperty = function getProperty(obj, name) { + if (name === '__proto__') { + if (!hasOwn.call(obj, name)) { + return void 0; + } else if (gOPD) { + // In early versions of node, obj['__proto__'] is buggy when obj has + // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. + return gOPD(obj, name).value; + } + } + + return obj[name]; +}; + +module.exports = function extend() { + var options, name, src, copy, copyIsArray, clone; + var target = arguments[0]; + var i = 1; + var length = arguments.length; + var deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { + target = {}; + } + + for (; i < length; ++i) { + options = arguments[i]; + // Only deal with non-null/undefined values + if (options != null) { + // Extend the base object + for (name in options) { + src = getProperty(target, name); + copy = getProperty(options, name); + + // Prevent never-ending loop + if (target !== copy) { + // Recurse if we're merging plain objects or arrays + if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { + if (copyIsArray) { + copyIsArray = false; + clone = src && isArray(src) ? src : []; + } else { + clone = src && isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); + + // Don't bring in undefined values + } else if (typeof copy !== 'undefined') { + setProperty(target, { name: name, newValue: copy }); + } + } + } + } + } + + // Return the modified object + return target; +}; diff --git a/node_modules/extend/package.json b/node_modules/extend/package.json new file mode 100644 index 0000000000000000000000000000000000000000..85279f78054e5cc6d7f9899afaf9fca60b77d740 --- /dev/null +++ b/node_modules/extend/package.json @@ -0,0 +1,42 @@ +{ + "name": "extend", + "author": "Stefan Thomas (http://www.justmoon.net)", + "version": "3.0.2", + "description": "Port of jQuery.extend for node.js and the browser", + "main": "index", + "scripts": { + "pretest": "npm run lint", + "test": "npm run tests-only", + "posttest": "npm run coverage-quiet", + "tests-only": "node test", + "coverage": "covert test/index.js", + "coverage-quiet": "covert test/index.js --quiet", + "lint": "npm run jscs && npm run eslint", + "jscs": "jscs *.js */*.js", + "eslint": "eslint *.js */*.js" + }, + "contributors": [ + { + "name": "Jordan Harband", + "url": "https://github.com/ljharb" + } + ], + "keywords": [ + "extend", + "clone", + "merge" + ], + "repository": { + "type": "git", + "url": "https://github.com/justmoon/node-extend.git" + }, + "dependencies": {}, + "devDependencies": { + "@ljharb/eslint-config": "^12.2.1", + "covert": "^1.1.0", + "eslint": "^4.19.1", + "jscs": "^3.0.7", + "tape": "^4.9.1" + }, + "license": "MIT" +} diff --git a/node_modules/extsprintf/.gitmodules b/node_modules/extsprintf/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/node_modules/extsprintf/.npmignore b/node_modules/extsprintf/.npmignore new file mode 100644 index 0000000000000000000000000000000000000000..6ed1ae975080f16a48aefcf50082cb636a5146a8 --- /dev/null +++ b/node_modules/extsprintf/.npmignore @@ -0,0 +1,2 @@ +/deps +/examples diff --git a/node_modules/extsprintf/LICENSE b/node_modules/extsprintf/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..cbc0bb3ba3b0629c66c042111fe01c664a6f812f --- /dev/null +++ b/node_modules/extsprintf/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012, Joyent, Inc. All rights reserved. + +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 diff --git a/node_modules/extsprintf/Makefile b/node_modules/extsprintf/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..db845189ad1ba05a37c881e06b8c6e082420148d --- /dev/null +++ b/node_modules/extsprintf/Makefile @@ -0,0 +1,24 @@ +# +# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# +# Makefile: top-level Makefile +# +# This Makefile contains only repo-specific logic and uses included makefiles +# to supply common targets (javascriptlint, jsstyle, restdown, etc.), which are +# used by other repos as well. +# + +# +# Files +# +JSL = jsl +JSSTYLE = jsstyle +JS_FILES := $(shell find examples lib -name '*.js') +JSL_FILES_NODE = $(JS_FILES) +JSSTYLE_FILES = $(JS_FILES) +JSL_CONF_NODE = jsl.node.conf + +# Default target is "check" +check: + +include ./Makefile.targ diff --git a/node_modules/extsprintf/Makefile.targ b/node_modules/extsprintf/Makefile.targ new file mode 100644 index 0000000000000000000000000000000000000000..2a64fe7e950f41db5e957cd8390318b53ca584db --- /dev/null +++ b/node_modules/extsprintf/Makefile.targ @@ -0,0 +1,285 @@ +# -*- mode: makefile -*- +# +# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# +# Makefile.targ: common targets. +# +# NOTE: This makefile comes from the "eng" repo. It's designed to be dropped +# into other repos as-is without requiring any modifications. If you find +# yourself changing this file, you should instead update the original copy in +# eng.git and then update your repo to use the new version. +# +# This Makefile defines several useful targets and rules. You can use it by +# including it from a Makefile that specifies some of the variables below. +# +# Targets defined in this Makefile: +# +# check Checks JavaScript files for lint and style +# Checks bash scripts for syntax +# Checks SMF manifests for validity against the SMF DTD +# +# clean Removes built files +# +# docs Builds restdown documentation in docs/ +# +# prepush Depends on "check" and "test" +# +# test Does nothing (you should override this) +# +# xref Generates cscope (source cross-reference index) +# +# For details on what these targets are supposed to do, see the Joyent +# Engineering Guide. +# +# To make use of these targets, you'll need to set some of these variables. Any +# variables left unset will simply not be used. +# +# BASH_FILES Bash scripts to check for syntax +# (paths relative to top-level Makefile) +# +# CLEAN_FILES Files to remove as part of the "clean" target. Note +# that files generated by targets in this Makefile are +# automatically included in CLEAN_FILES. These include +# restdown-generated HTML and JSON files. +# +# DOC_FILES Restdown (documentation source) files. These are +# assumed to be contained in "docs/", and must NOT +# contain the "docs/" prefix. +# +# JSL_CONF_NODE Specify JavaScriptLint configuration files +# JSL_CONF_WEB (paths relative to top-level Makefile) +# +# Node.js and Web configuration files are separate +# because you'll usually want different global variable +# configurations. If no file is specified, none is given +# to jsl, which causes it to use a default configuration, +# which probably isn't what you want. +# +# JSL_FILES_NODE JavaScript files to check with Node config file. +# JSL_FILES_WEB JavaScript files to check with Web config file. +# +# You can also override these variables: +# +# BASH Path to bash (default: bash) +# +# CSCOPE_DIRS Directories to search for source files for the cscope +# index. (default: ".") +# +# JSL Path to JavaScriptLint (default: "jsl") +# +# JSL_FLAGS_NODE Additional flags to pass through to JSL +# JSL_FLAGS_WEB +# JSL_FLAGS +# +# JSSTYLE Path to jsstyle (default: jsstyle) +# +# JSSTYLE_FLAGS Additional flags to pass through to jsstyle +# + +# +# Defaults for the various tools we use. +# +BASH ?= bash +BASHSTYLE ?= tools/bashstyle +CP ?= cp +CSCOPE ?= cscope +CSCOPE_DIRS ?= . +JSL ?= jsl +JSSTYLE ?= jsstyle +MKDIR ?= mkdir -p +MV ?= mv +RESTDOWN_FLAGS ?= +RMTREE ?= rm -rf +JSL_FLAGS ?= --nologo --nosummary + +ifeq ($(shell uname -s),SunOS) + TAR ?= gtar +else + TAR ?= tar +endif + + +# +# Defaults for other fixed values. +# +BUILD = build +DISTCLEAN_FILES += $(BUILD) +DOC_BUILD = $(BUILD)/docs/public + +# +# Configure JSL_FLAGS_{NODE,WEB} based on JSL_CONF_{NODE,WEB}. +# +ifneq ($(origin JSL_CONF_NODE), undefined) + JSL_FLAGS_NODE += --conf=$(JSL_CONF_NODE) +endif + +ifneq ($(origin JSL_CONF_WEB), undefined) + JSL_FLAGS_WEB += --conf=$(JSL_CONF_WEB) +endif + +# +# Targets. For descriptions on what these are supposed to do, see the +# Joyent Engineering Guide. +# + +# +# Instruct make to keep around temporary files. We have rules below that +# automatically update git submodules as needed, but they employ a deps/*/.git +# temporary file. Without this directive, make tries to remove these .git +# directories after the build has completed. +# +.SECONDARY: $($(wildcard deps/*):%=%/.git) + +# +# This rule enables other rules that use files from a git submodule to have +# those files depend on deps/module/.git and have "make" automatically check +# out the submodule as needed. +# +deps/%/.git: + git submodule update --init deps/$* + +# +# These recipes make heavy use of dynamically-created phony targets. The parent +# Makefile defines a list of input files like BASH_FILES. We then say that each +# of these files depends on a fake target called filename.bashchk, and then we +# define a pattern rule for those targets that runs bash in check-syntax-only +# mode. This mechanism has the nice properties that if you specify zero files, +# the rule becomes a noop (unlike a single rule to check all bash files, which +# would invoke bash with zero files), and you can check individual files from +# the command line with "make filename.bashchk". +# +.PHONY: check-bash +check-bash: $(BASH_FILES:%=%.bashchk) $(BASH_FILES:%=%.bashstyle) + +%.bashchk: % + $(BASH) -n $^ + +%.bashstyle: % + $(BASHSTYLE) $^ + +.PHONY: check-jsl check-jsl-node check-jsl-web +check-jsl: check-jsl-node check-jsl-web + +check-jsl-node: $(JSL_FILES_NODE:%=%.jslnodechk) + +check-jsl-web: $(JSL_FILES_WEB:%=%.jslwebchk) + +%.jslnodechk: % $(JSL_EXEC) + $(JSL) $(JSL_FLAGS) $(JSL_FLAGS_NODE) $< + +%.jslwebchk: % $(JSL_EXEC) + $(JSL) $(JSL_FLAGS) $(JSL_FLAGS_WEB) $< + +.PHONY: check-jsstyle +check-jsstyle: $(JSSTYLE_FILES:%=%.jsstylechk) + +%.jsstylechk: % $(JSSTYLE_EXEC) + $(JSSTYLE) $(JSSTYLE_FLAGS) $< + +.PHONY: check +check: check-jsl check-jsstyle check-bash + @echo check ok + +.PHONY: clean +clean:: + -$(RMTREE) $(CLEAN_FILES) + +.PHONY: distclean +distclean:: clean + -$(RMTREE) $(DISTCLEAN_FILES) + +CSCOPE_FILES = cscope.in.out cscope.out cscope.po.out +CLEAN_FILES += $(CSCOPE_FILES) + +.PHONY: xref +xref: cscope.files + $(CSCOPE) -bqR + +.PHONY: cscope.files +cscope.files: + find $(CSCOPE_DIRS) -name '*.c' -o -name '*.h' -o -name '*.cc' \ + -o -name '*.js' -o -name '*.s' -o -name '*.cpp' > $@ + +# +# The "docs" target is complicated because we do several things here: +# +# (1) Use restdown to build HTML and JSON files from each of DOC_FILES. +# +# (2) Copy these files into $(DOC_BUILD) (build/docs/public), which +# functions as a complete copy of the documentation that could be +# mirrored or served over HTTP. +# +# (3) Then copy any directories and media from docs/media into +# $(DOC_BUILD)/media. This allows projects to include their own media, +# including files that will override same-named files provided by +# restdown. +# +# Step (3) is the surprisingly complex part: in order to do this, we need to +# identify the subdirectories in docs/media, recreate them in +# $(DOC_BUILD)/media, then do the same with the files. +# +DOC_MEDIA_DIRS := $(shell find docs/media -type d 2>/dev/null | grep -v "^docs/media$$") +DOC_MEDIA_DIRS := $(DOC_MEDIA_DIRS:docs/media/%=%) +DOC_MEDIA_DIRS_BUILD := $(DOC_MEDIA_DIRS:%=$(DOC_BUILD)/media/%) + +DOC_MEDIA_FILES := $(shell find docs/media -type f 2>/dev/null) +DOC_MEDIA_FILES := $(DOC_MEDIA_FILES:docs/media/%=%) +DOC_MEDIA_FILES_BUILD := $(DOC_MEDIA_FILES:%=$(DOC_BUILD)/media/%) + +# +# Like the other targets, "docs" just depends on the final files we want to +# create in $(DOC_BUILD), leveraging other targets and recipes to define how +# to get there. +# +.PHONY: docs +docs: \ + $(DOC_FILES:%.restdown=$(DOC_BUILD)/%.html) \ + $(DOC_FILES:%.restdown=$(DOC_BUILD)/%.json) \ + $(DOC_MEDIA_FILES_BUILD) + +# +# We keep the intermediate files so that the next build can see whether the +# files in DOC_BUILD are up to date. +# +.PRECIOUS: \ + $(DOC_FILES:%.restdown=docs/%.html) \ + $(DOC_FILES:%.restdown=docs/%json) + +# +# We do clean those intermediate files, as well as all of DOC_BUILD. +# +CLEAN_FILES += \ + $(DOC_BUILD) \ + $(DOC_FILES:%.restdown=docs/%.html) \ + $(DOC_FILES:%.restdown=docs/%.json) + +# +# Before installing the files, we must make sure the directories exist. The | +# syntax tells make that the dependency need only exist, not be up to date. +# Otherwise, it might try to rebuild spuriously because the directory itself +# appears out of date. +# +$(DOC_MEDIA_FILES_BUILD): | $(DOC_MEDIA_DIRS_BUILD) + +$(DOC_BUILD)/%: docs/% | $(DOC_BUILD) + $(CP) $< $@ + +docs/%.json docs/%.html: docs/%.restdown | $(DOC_BUILD) $(RESTDOWN_EXEC) + $(RESTDOWN) $(RESTDOWN_FLAGS) -m $(DOC_BUILD) $< + +$(DOC_BUILD): + $(MKDIR) $@ + +$(DOC_MEDIA_DIRS_BUILD): + $(MKDIR) $@ + +# +# The default "test" target does nothing. This should usually be overridden by +# the parent Makefile. It's included here so we can define "prepush" without +# requiring the repo to define "test". +# +.PHONY: test +test: + +.PHONY: prepush +prepush: check test diff --git a/node_modules/extsprintf/README.md b/node_modules/extsprintf/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b22998d63af16c426d238a6edbfa46913c04337b --- /dev/null +++ b/node_modules/extsprintf/README.md @@ -0,0 +1,46 @@ +# extsprintf: extended POSIX-style sprintf + +Stripped down version of s[n]printf(3c). We make a best effort to throw an +exception when given a format string we don't understand, rather than ignoring +it, so that we won't break existing programs if/when we go implement the rest +of this. + +This implementation currently supports specifying + +* field alignment ('-' flag), +* zero-pad ('0' flag) +* always show numeric sign ('+' flag), +* field width +* conversions for strings, decimal integers, and floats (numbers). +* argument size specifiers. These are all accepted but ignored, since + Javascript has no notion of the physical size of an argument. + +Everything else is currently unsupported, most notably: precision, unsigned +numbers, non-decimal numbers, and characters. + +Besides the usual POSIX conversions, this implementation supports: + +* `%j`: pretty-print a JSON object (using node's "inspect") +* `%r`: pretty-print an Error object + +# Example + +First, install it: + + # npm install extsprintf + +Now, use it: + + var mod_extsprintf = require('extsprintf'); + console.log(mod_extsprintf.sprintf('hello %25s', 'world')); + +outputs: + + hello world + +# Also supported + +**printf**: same args as sprintf, but prints the result to stdout + +**fprintf**: same args as sprintf, preceded by a Node stream. Prints the result +to the given stream. diff --git a/node_modules/extsprintf/jsl.node.conf b/node_modules/extsprintf/jsl.node.conf new file mode 100644 index 0000000000000000000000000000000000000000..03f787ffbdee4e63a4e0aa8179da4561337fb316 --- /dev/null +++ b/node_modules/extsprintf/jsl.node.conf @@ -0,0 +1,137 @@ +# +# Configuration File for JavaScript Lint +# +# This configuration file can be used to lint a collection of scripts, or to enable +# or disable warnings for scripts that are linted via the command line. +# + +### Warnings +# Enable or disable warnings based on requirements. +# Use "+WarningName" to display or "-WarningName" to suppress. +# ++ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent ++ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity ++ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement ++anon_no_return_value # anonymous function does not always return value ++assign_to_function_call # assignment to a function call +-block_without_braces # block statement without curly braces ++comma_separated_stmts # multiple statements separated by commas (use semicolons?) ++comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==) ++default_not_at_end # the default case is not at the end of the switch statement ++dup_option_explicit # duplicate "option explicit" control comment ++duplicate_case_in_switch # duplicate case in switch statement ++duplicate_formal # duplicate formal argument {name} ++empty_statement # empty statement or extra semicolon ++identifier_hides_another # identifer {name} hides an identifier in a parent scope +-inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement ++incorrect_version # Expected /*jsl:content-type*/ control comment. The script was parsed with the wrong version. ++invalid_fallthru # unexpected "fallthru" control comment ++invalid_pass # unexpected "pass" control comment ++jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax ++leading_decimal_point # leading decimal point may indicate a number or an object member ++legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax ++meaningless_block # meaningless block; curly braces have no impact ++mismatch_ctrl_comments # mismatched control comment; "ignore" and "end" control comments must have a one-to-one correspondence ++misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma ++missing_break # missing break statement ++missing_break_for_last_case # missing break statement for last case in switch ++missing_default_case # missing default case in switch statement ++missing_option_explicit # the "option explicit" control comment is missing ++missing_semicolon # missing semicolon ++missing_semicolon_for_lambda # missing semicolon for lambda assignment ++multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs ++nested_comment # nested comment ++no_return_value # function {name} does not always return a value ++octal_number # leading zeros make an octal number ++parseint_missing_radix # parseInt missing radix parameter ++partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag ++redeclared_var # redeclaration of {name} ++trailing_comma_in_array # extra comma is not recommended in array initializers ++trailing_decimal_point # trailing decimal point may indicate a number or an object member ++undeclared_identifier # undeclared identifier: {name} ++unreachable_code # unreachable code +-unreferenced_argument # argument declared but never referenced: {name} +-unreferenced_function # function is declared but never referenced: {name} ++unreferenced_variable # variable is declared but never referenced: {name} ++unsupported_version # JavaScript {version} is not supported ++use_of_label # use of label ++useless_assign # useless assignment ++useless_comparison # useless comparison; comparing identical expressions +-useless_quotes # the quotation marks are unnecessary ++useless_void # use of the void type may be unnecessary (void is always undefined) ++var_hides_arg # variable {name} hides argument ++want_assign_or_call # expected an assignment or function call ++with_statement # with statement hides undeclared variables; use temporary variable instead + + +### Output format +# Customize the format of the error message. +# __FILE__ indicates current file path +# __FILENAME__ indicates current file name +# __LINE__ indicates current line +# __COL__ indicates current column +# __ERROR__ indicates error message (__ERROR_PREFIX__: __ERROR_MSG__) +# __ERROR_NAME__ indicates error name (used in configuration file) +# __ERROR_PREFIX__ indicates error prefix +# __ERROR_MSG__ indicates error message +# +# For machine-friendly output, the output format can be prefixed with +# "encode:". If specified, all items will be encoded with C-slashes. +# +# Visual Studio syntax (default): ++output-format __FILE__(__LINE__): __ERROR__ +# Alternative syntax: +#+output-format __FILE__:__LINE__: __ERROR__ + + +### Context +# Show the in-line position of the error. +# Use "+context" to display or "-context" to suppress. +# ++context + + +### Control Comments +# Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for +# the /*@keyword@*/ control comments and JScript conditional comments. (The latter is +# enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason, +# although legacy control comments are enabled by default for backward compatibility. +# +-legacy_control_comments + + +### Defining identifiers +# By default, "option explicit" is enabled on a per-file basis. +# To enable this for all files, use "+always_use_option_explicit" +-always_use_option_explicit + +# Define certain identifiers of which the lint is not aware. +# (Use this in conjunction with the "undeclared identifier" warning.) +# +# Common uses for webpages might be: ++define __dirname ++define clearInterval ++define clearTimeout ++define console ++define exports ++define global ++define process ++define require ++define setInterval ++define setTimeout ++define Buffer ++define JSON ++define Math + +### JavaScript Version +# To change the default JavaScript version: +#+default-type text/javascript;version=1.5 +#+default-type text/javascript;e4x=1 + +### Files +# Specify which files to lint +# Use "+recurse" to enable recursion (disabled by default). +# To add a set of files, use "+process FileName", "+process Folder\Path\*.js", +# or "+process Folder\Path\*.htm". +# + diff --git a/node_modules/extsprintf/lib/extsprintf.js b/node_modules/extsprintf/lib/extsprintf.js new file mode 100644 index 0000000000000000000000000000000000000000..ed883d32b9a4a49e362ea090438d4f855c29942a --- /dev/null +++ b/node_modules/extsprintf/lib/extsprintf.js @@ -0,0 +1,183 @@ +/* + * extsprintf.js: extended POSIX-style sprintf + */ + +var mod_assert = require('assert'); +var mod_util = require('util'); + +/* + * Public interface + */ +exports.sprintf = jsSprintf; +exports.printf = jsPrintf; +exports.fprintf = jsFprintf; + +/* + * Stripped down version of s[n]printf(3c). We make a best effort to throw an + * exception when given a format string we don't understand, rather than + * ignoring it, so that we won't break existing programs if/when we go implement + * the rest of this. + * + * This implementation currently supports specifying + * - field alignment ('-' flag), + * - zero-pad ('0' flag) + * - always show numeric sign ('+' flag), + * - field width + * - conversions for strings, decimal integers, and floats (numbers). + * - argument size specifiers. These are all accepted but ignored, since + * Javascript has no notion of the physical size of an argument. + * + * Everything else is currently unsupported, most notably precision, unsigned + * numbers, non-decimal numbers, and characters. + */ +function jsSprintf(fmt) +{ + var regex = [ + '([^%]*)', /* normal text */ + '%', /* start of format */ + '([\'\\-+ #0]*?)', /* flags (optional) */ + '([1-9]\\d*)?', /* width (optional) */ + '(\\.([1-9]\\d*))?', /* precision (optional) */ + '[lhjztL]*?', /* length mods (ignored) */ + '([diouxXfFeEgGaAcCsSp%jr])' /* conversion */ + ].join(''); + + var re = new RegExp(regex); + var args = Array.prototype.slice.call(arguments, 1); + var flags, width, precision, conversion; + var left, pad, sign, arg, match; + var ret = ''; + var argn = 1; + + mod_assert.equal('string', typeof (fmt)); + + while ((match = re.exec(fmt)) !== null) { + ret += match[1]; + fmt = fmt.substring(match[0].length); + + flags = match[2] || ''; + width = match[3] || 0; + precision = match[4] || ''; + conversion = match[6]; + left = false; + sign = false; + pad = ' '; + + if (conversion == '%') { + ret += '%'; + continue; + } + + if (args.length === 0) + throw (new Error('too few args to sprintf')); + + arg = args.shift(); + argn++; + + if (flags.match(/[\' #]/)) + throw (new Error( + 'unsupported flags: ' + flags)); + + if (precision.length > 0) + throw (new Error( + 'non-zero precision not supported')); + + if (flags.match(/-/)) + left = true; + + if (flags.match(/0/)) + pad = '0'; + + if (flags.match(/\+/)) + sign = true; + + switch (conversion) { + case 's': + if (arg === undefined || arg === null) + throw (new Error('argument ' + argn + + ': attempted to print undefined or null ' + + 'as a string')); + ret += doPad(pad, width, left, arg.toString()); + break; + + case 'd': + arg = Math.floor(arg); + /*jsl:fallthru*/ + case 'f': + sign = sign && arg > 0 ? '+' : ''; + ret += sign + doPad(pad, width, left, + arg.toString()); + break; + + case 'x': + ret += doPad(pad, width, left, arg.toString(16)); + break; + + case 'j': /* non-standard */ + if (width === 0) + width = 10; + ret += mod_util.inspect(arg, false, width); + break; + + case 'r': /* non-standard */ + ret += dumpException(arg); + break; + + default: + throw (new Error('unsupported conversion: ' + + conversion)); + } + } + + ret += fmt; + return (ret); +} + +function jsPrintf() { + var args = Array.prototype.slice.call(arguments); + args.unshift(process.stdout); + jsFprintf.apply(null, args); +} + +function jsFprintf(stream) { + var args = Array.prototype.slice.call(arguments, 1); + return (stream.write(jsSprintf.apply(this, args))); +} + +function doPad(chr, width, left, str) +{ + var ret = str; + + while (ret.length < width) { + if (left) + ret += chr; + else + ret = chr + ret; + } + + return (ret); +} + +/* + * This function dumps long stack traces for exceptions having a cause() method. + * See node-verror for an example. + */ +function dumpException(ex) +{ + var ret; + + if (!(ex instanceof Error)) + throw (new Error(jsSprintf('invalid type for %%r: %j', ex))); + + /* Note that V8 prepends "ex.stack" with ex.toString(). */ + ret = 'EXCEPTION: ' + ex.constructor.name + ': ' + ex.stack; + + if (ex.cause && typeof (ex.cause) === 'function') { + var cex = ex.cause(); + if (cex) { + ret += '\nCaused by: ' + dumpException(cex); + } + } + + return (ret); +} diff --git a/node_modules/extsprintf/package.json b/node_modules/extsprintf/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b788895cd3f16de5481f10880219835a4039227f --- /dev/null +++ b/node_modules/extsprintf/package.json @@ -0,0 +1,14 @@ +{ + "name": "extsprintf", + "version": "1.3.0", + "description": "extended POSIX-style sprintf", + "main": "./lib/extsprintf.js", + "repository": { + "type": "git", + "url": "git://github.com/davepacheco/node-extsprintf.git" + }, + "engines": [ + "node >=0.6.0" + ], + "license": "MIT" +} diff --git a/node_modules/fast-json-stable-stringify/.eslintrc.yml b/node_modules/fast-json-stable-stringify/.eslintrc.yml new file mode 100644 index 0000000000000000000000000000000000000000..1c77b0d479035958b213209cbb1f65092f17496b --- /dev/null +++ b/node_modules/fast-json-stable-stringify/.eslintrc.yml @@ -0,0 +1,26 @@ +extends: eslint:recommended +env: + node: true + browser: true +rules: + block-scoped-var: 2 + callback-return: 2 + dot-notation: 2 + indent: 2 + linebreak-style: [2, unix] + new-cap: 2 + no-console: [2, allow: [warn, error]] + no-else-return: 2 + no-eq-null: 2 + no-fallthrough: 2 + no-invalid-this: 2 + no-return-assign: 2 + no-shadow: 1 + no-trailing-spaces: 2 + no-use-before-define: [2, nofunc] + quotes: [2, single, avoid-escape] + semi: [2, always] + strict: [2, global] + valid-jsdoc: [2, requireReturn: false] + no-control-regex: 0 + no-useless-escape: 2 diff --git a/node_modules/fast-json-stable-stringify/.github/FUNDING.yml b/node_modules/fast-json-stable-stringify/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..61f9daa955b012ea7138d91cdd7470ed50523a07 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/.github/FUNDING.yml @@ -0,0 +1 @@ +tidelift: "npm/fast-json-stable-stringify" diff --git a/node_modules/fast-json-stable-stringify/.travis.yml b/node_modules/fast-json-stable-stringify/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..b61e8f0dc9dccdd5acdb9357ac635b715528effe --- /dev/null +++ b/node_modules/fast-json-stable-stringify/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - "8" + - "10" + - "12" + - "13" +after_script: + - coveralls < coverage/lcov.info diff --git a/node_modules/fast-json-stable-stringify/LICENSE b/node_modules/fast-json-stable-stringify/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c932223b1e2c2f3ca84e318c83ce4ce5201ebd5b --- /dev/null +++ b/node_modules/fast-json-stable-stringify/LICENSE @@ -0,0 +1,21 @@ +This software is released under the MIT license: + +Copyright (c) 2017 Evgeny Poberezkin +Copyright (c) 2013 James Halliday + +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. diff --git a/node_modules/fast-json-stable-stringify/README.md b/node_modules/fast-json-stable-stringify/README.md new file mode 100644 index 0000000000000000000000000000000000000000..02cf49ff385b8bd478b67c2e2392f2e392d8926a --- /dev/null +++ b/node_modules/fast-json-stable-stringify/README.md @@ -0,0 +1,131 @@ +# fast-json-stable-stringify + +Deterministic `JSON.stringify()` - a faster version of [@substack](https://github.com/substack)'s json-stable-strigify without [jsonify](https://github.com/substack/jsonify). + +You can also pass in a custom comparison function. + +[![Build Status](https://travis-ci.org/epoberezkin/fast-json-stable-stringify.svg?branch=master)](https://travis-ci.org/epoberezkin/fast-json-stable-stringify) +[![Coverage Status](https://coveralls.io/repos/github/epoberezkin/fast-json-stable-stringify/badge.svg?branch=master)](https://coveralls.io/github/epoberezkin/fast-json-stable-stringify?branch=master) + +# example + +``` js +var stringify = require('fast-json-stable-stringify'); +var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 }; +console.log(stringify(obj)); +``` + +output: + +``` +{"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8} +``` + + +# methods + +``` js +var stringify = require('fast-json-stable-stringify') +``` + +## var str = stringify(obj, opts) + +Return a deterministic stringified string `str` from the object `obj`. + + +## options + +### cmp + +If `opts` is given, you can supply an `opts.cmp` to have a custom comparison +function for object keys. Your function `opts.cmp` is called with these +parameters: + +``` js +opts.cmp({ key: akey, value: avalue }, { key: bkey, value: bvalue }) +``` + +For example, to sort on the object key names in reverse order you could write: + +``` js +var stringify = require('fast-json-stable-stringify'); + +var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 }; +var s = stringify(obj, function (a, b) { + return a.key < b.key ? 1 : -1; +}); +console.log(s); +``` + +which results in the output string: + +``` +{"c":8,"b":[{"z":6,"y":5,"x":4},7],"a":3} +``` + +Or if you wanted to sort on the object values in reverse order, you could write: + +``` +var stringify = require('fast-json-stable-stringify'); + +var obj = { d: 6, c: 5, b: [{z:3,y:2,x:1},9], a: 10 }; +var s = stringify(obj, function (a, b) { + return a.value < b.value ? 1 : -1; +}); +console.log(s); +``` + +which outputs: + +``` +{"d":6,"c":5,"b":[{"z":3,"y":2,"x":1},9],"a":10} +``` + +### cycles + +Pass `true` in `opts.cycles` to stringify circular property as `__cycle__` - the result will not be a valid JSON string in this case. + +TypeError will be thrown in case of circular object without this option. + + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install fast-json-stable-stringify +``` + + +# benchmark + +To run benchmark (requires Node.js 6+): +``` +node benchmark +``` + +Results: +``` +fast-json-stable-stringify x 17,189 ops/sec ±1.43% (83 runs sampled) +json-stable-stringify x 13,634 ops/sec ±1.39% (85 runs sampled) +fast-stable-stringify x 20,212 ops/sec ±1.20% (84 runs sampled) +faster-stable-stringify x 15,549 ops/sec ±1.12% (84 runs sampled) +The fastest is fast-stable-stringify +``` + + +## Enterprise support + +fast-json-stable-stringify package is a part of [Tidelift enterprise subscription](https://tidelift.com/subscription/pkg/npm-fast-json-stable-stringify?utm_source=npm-fast-json-stable-stringify&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers. + + +## Security contact + +To report a security vulnerability, please use the +[Tidelift security contact](https://tidelift.com/security). +Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues. + + +# license + +[MIT](https://github.com/epoberezkin/fast-json-stable-stringify/blob/master/LICENSE) diff --git a/node_modules/fast-json-stable-stringify/benchmark/index.js b/node_modules/fast-json-stable-stringify/benchmark/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e725f9fc5f1e8fe9ba16c9b4df47aae9b2162a25 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/benchmark/index.js @@ -0,0 +1,31 @@ +'use strict'; + +const Benchmark = require('benchmark'); +const suite = new Benchmark.Suite; +const testData = require('./test.json'); + + +const stringifyPackages = { + // 'JSON.stringify': JSON.stringify, + 'fast-json-stable-stringify': require('../index'), + 'json-stable-stringify': true, + 'fast-stable-stringify': true, + 'faster-stable-stringify': true +}; + + +for (const name in stringifyPackages) { + let func = stringifyPackages[name]; + if (func === true) func = require(name); + + suite.add(name, function() { + func(testData); + }); +} + +suite + .on('cycle', (event) => console.log(String(event.target))) + .on('complete', function () { + console.log('The fastest is ' + this.filter('fastest').map('name')); + }) + .run({async: true}); diff --git a/node_modules/fast-json-stable-stringify/benchmark/test.json b/node_modules/fast-json-stable-stringify/benchmark/test.json new file mode 100644 index 0000000000000000000000000000000000000000..c9118c11f5905b57f4d954209abad70de3e9e56a --- /dev/null +++ b/node_modules/fast-json-stable-stringify/benchmark/test.json @@ -0,0 +1,137 @@ +[ + { + "_id": "59ef4a83ee8364808d761beb", + "index": 0, + "guid": "e50ffae9-7128-4148-9ee5-40c3fc523c5d", + "isActive": false, + "balance": "$2,341.81", + "picture": "http://placehold.it/32x32", + "age": 28, + "eyeColor": "brown", + "name": "Carey Savage", + "gender": "female", + "company": "VERAQ", + "email": "careysavage@veraq.com", + "phone": "+1 (897) 574-3014", + "address": "458 Willow Street, Henrietta, California, 7234", + "about": "Nisi reprehenderit nulla ad officia pariatur non dolore laboris irure cupidatat laborum. Minim eu ex Lorem adipisicing exercitation irure minim sunt est enim mollit incididunt voluptate nulla. Ut mollit anim reprehenderit et aliqua ex esse aliquip. Aute sit duis deserunt do incididunt consequat minim qui dolor commodo deserunt et voluptate.\r\n", + "registered": "2014-05-21T01:56:51 -01:00", + "latitude": 63.89502, + "longitude": 62.369807, + "tags": [ + "nostrud", + "nisi", + "consectetur", + "ullamco", + "cupidatat", + "culpa", + "commodo" + ], + "friends": [ + { + "id": 0, + "name": "Henry Walls" + }, + { + "id": 1, + "name": "Janice Baker" + }, + { + "id": 2, + "name": "Russell Bush" + } + ], + "greeting": "Hello, Carey Savage! You have 4 unread messages.", + "favoriteFruit": "banana" + }, + { + "_id": "59ef4a83ff5774a691454e89", + "index": 1, + "guid": "2bee9efc-4095-4c2e-87ef-d08c8054c89d", + "isActive": true, + "balance": "$1,618.15", + "picture": "http://placehold.it/32x32", + "age": 35, + "eyeColor": "blue", + "name": "Elinor Pearson", + "gender": "female", + "company": "FLEXIGEN", + "email": "elinorpearson@flexigen.com", + "phone": "+1 (923) 548-3751", + "address": "600 Bayview Avenue, Draper, Montana, 3088", + "about": "Mollit commodo ea sit Lorem velit. Irure anim esse Lorem sint quis officia ut. Aliqua nisi dolore in aute deserunt mollit ex ea in mollit.\r\n", + "registered": "2017-04-22T07:58:41 -01:00", + "latitude": -87.824919, + "longitude": 69.538927, + "tags": [ + "fugiat", + "labore", + "proident", + "quis", + "eiusmod", + "qui", + "est" + ], + "friends": [ + { + "id": 0, + "name": "Massey Wagner" + }, + { + "id": 1, + "name": "Marcella Ferrell" + }, + { + "id": 2, + "name": "Evans Mckee" + } + ], + "greeting": "Hello, Elinor Pearson! You have 3 unread messages.", + "favoriteFruit": "strawberry" + }, + { + "_id": "59ef4a839ec8a4be4430b36b", + "index": 2, + "guid": "ddd6e8c0-95bd-416d-8b46-a768d6363809", + "isActive": false, + "balance": "$2,046.95", + "picture": "http://placehold.it/32x32", + "age": 40, + "eyeColor": "green", + "name": "Irwin Davidson", + "gender": "male", + "company": "DANJA", + "email": "irwindavidson@danja.com", + "phone": "+1 (883) 537-2041", + "address": "439 Cook Street, Chapin, Kentucky, 7398", + "about": "Irure velit non commodo aliqua exercitation ut nostrud minim magna. Dolor ad ad ut irure eu. Non pariatur dolor eiusmod ipsum do et exercitation cillum. Et amet laboris minim eiusmod ullamco magna ea reprehenderit proident sunt.\r\n", + "registered": "2016-09-01T07:49:08 -01:00", + "latitude": -49.803812, + "longitude": 104.93279, + "tags": [ + "consequat", + "enim", + "quis", + "magna", + "est", + "culpa", + "tempor" + ], + "friends": [ + { + "id": 0, + "name": "Ruth Hansen" + }, + { + "id": 1, + "name": "Kathrine Austin" + }, + { + "id": 2, + "name": "Rivera Munoz" + } + ], + "greeting": "Hello, Irwin Davidson! You have 2 unread messages.", + "favoriteFruit": "banana" + } +] diff --git a/node_modules/fast-json-stable-stringify/example/key_cmp.js b/node_modules/fast-json-stable-stringify/example/key_cmp.js new file mode 100644 index 0000000000000000000000000000000000000000..d5f66752d82e15116b68c731ce0751e8799c3d5e --- /dev/null +++ b/node_modules/fast-json-stable-stringify/example/key_cmp.js @@ -0,0 +1,7 @@ +var stringify = require('../'); + +var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 }; +var s = stringify(obj, function (a, b) { + return a.key < b.key ? 1 : -1; +}); +console.log(s); diff --git a/node_modules/fast-json-stable-stringify/example/nested.js b/node_modules/fast-json-stable-stringify/example/nested.js new file mode 100644 index 0000000000000000000000000000000000000000..9a672fc65fb0fcf3112e578571df647a1acf0f46 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/example/nested.js @@ -0,0 +1,3 @@ +var stringify = require('../'); +var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 }; +console.log(stringify(obj)); diff --git a/node_modules/fast-json-stable-stringify/example/str.js b/node_modules/fast-json-stable-stringify/example/str.js new file mode 100644 index 0000000000000000000000000000000000000000..9b4b3cd289570ec16943219e4a076ca1a767924b --- /dev/null +++ b/node_modules/fast-json-stable-stringify/example/str.js @@ -0,0 +1,3 @@ +var stringify = require('../'); +var obj = { c: 6, b: [4,5], a: 3 }; +console.log(stringify(obj)); diff --git a/node_modules/fast-json-stable-stringify/example/value_cmp.js b/node_modules/fast-json-stable-stringify/example/value_cmp.js new file mode 100644 index 0000000000000000000000000000000000000000..09f1c5f79b2167308e0aae89de38d79fcdf52624 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/example/value_cmp.js @@ -0,0 +1,7 @@ +var stringify = require('../'); + +var obj = { d: 6, c: 5, b: [{z:3,y:2,x:1},9], a: 10 }; +var s = stringify(obj, function (a, b) { + return a.value < b.value ? 1 : -1; +}); +console.log(s); diff --git a/node_modules/fast-json-stable-stringify/index.d.ts b/node_modules/fast-json-stable-stringify/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..23e46cafc140a3ed99104ba1997f34b2414f9ef4 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/index.d.ts @@ -0,0 +1,4 @@ +declare module 'fast-json-stable-stringify' { + function stringify(obj: any): string; + export = stringify; +} diff --git a/node_modules/fast-json-stable-stringify/index.js b/node_modules/fast-json-stable-stringify/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c44e6a4137212cc1c577b8499bf963de2eda00e5 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/index.js @@ -0,0 +1,59 @@ +'use strict'; + +module.exports = function (data, opts) { + if (!opts) opts = {}; + if (typeof opts === 'function') opts = { cmp: opts }; + var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false; + + var cmp = opts.cmp && (function (f) { + return function (node) { + return function (a, b) { + var aobj = { key: a, value: node[a] }; + var bobj = { key: b, value: node[b] }; + return f(aobj, bobj); + }; + }; + })(opts.cmp); + + var seen = []; + return (function stringify (node) { + if (node && node.toJSON && typeof node.toJSON === 'function') { + node = node.toJSON(); + } + + if (node === undefined) return; + if (typeof node == 'number') return isFinite(node) ? '' + node : 'null'; + if (typeof node !== 'object') return JSON.stringify(node); + + var i, out; + if (Array.isArray(node)) { + out = '['; + for (i = 0; i < node.length; i++) { + if (i) out += ','; + out += stringify(node[i]) || 'null'; + } + return out + ']'; + } + + if (node === null) return 'null'; + + if (seen.indexOf(node) !== -1) { + if (cycles) return JSON.stringify('__cycle__'); + throw new TypeError('Converting circular structure to JSON'); + } + + var seenIndex = seen.push(node) - 1; + var keys = Object.keys(node).sort(cmp && cmp(node)); + out = ''; + for (i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = stringify(node[key]); + + if (!value) continue; + if (out) out += ','; + out += JSON.stringify(key) + ':' + value; + } + seen.splice(seenIndex, 1); + return '{' + out + '}'; + })(data); +}; diff --git a/node_modules/fast-json-stable-stringify/package.json b/node_modules/fast-json-stable-stringify/package.json new file mode 100644 index 0000000000000000000000000000000000000000..ad2c8bff7c94e2f361b6245146a51667c6c27dc4 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/package.json @@ -0,0 +1,52 @@ +{ + "name": "fast-json-stable-stringify", + "version": "2.1.0", + "description": "deterministic `JSON.stringify()` - a faster version of substack's json-stable-strigify without jsonify", + "main": "index.js", + "types": "index.d.ts", + "dependencies": {}, + "devDependencies": { + "benchmark": "^2.1.4", + "coveralls": "^3.0.0", + "eslint": "^6.7.0", + "fast-stable-stringify": "latest", + "faster-stable-stringify": "latest", + "json-stable-stringify": "latest", + "nyc": "^14.1.0", + "pre-commit": "^1.2.2", + "tape": "^4.11.0" + }, + "scripts": { + "eslint": "eslint index.js test", + "test-spec": "tape test/*.js", + "test": "npm run eslint && nyc npm run test-spec" + }, + "repository": { + "type": "git", + "url": "git://github.com/epoberezkin/fast-json-stable-stringify.git" + }, + "homepage": "https://github.com/epoberezkin/fast-json-stable-stringify", + "keywords": [ + "json", + "stringify", + "deterministic", + "hash", + "stable" + ], + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "license": "MIT", + "nyc": { + "exclude": [ + "test", + "node_modules" + ], + "reporter": [ + "lcov", + "text-summary" + ] + } +} diff --git a/node_modules/fast-json-stable-stringify/test/cmp.js b/node_modules/fast-json-stable-stringify/test/cmp.js new file mode 100644 index 0000000000000000000000000000000000000000..4efd6b59721f9f875aa8ec869293fa398569c555 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/test/cmp.js @@ -0,0 +1,13 @@ +'use strict'; + +var test = require('tape'); +var stringify = require('../'); + +test('custom comparison function', function (t) { + t.plan(1); + var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 }; + var s = stringify(obj, function (a, b) { + return a.key < b.key ? 1 : -1; + }); + t.equal(s, '{"c":8,"b":[{"z":6,"y":5,"x":4},7],"a":3}'); +}); diff --git a/node_modules/fast-json-stable-stringify/test/nested.js b/node_modules/fast-json-stable-stringify/test/nested.js new file mode 100644 index 0000000000000000000000000000000000000000..167a358e09a2963784915cf0272b128de8d3d1e5 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/test/nested.js @@ -0,0 +1,44 @@ +'use strict'; + +var test = require('tape'); +var stringify = require('../'); + +test('nested', function (t) { + t.plan(1); + var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 }; + t.equal(stringify(obj), '{"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8}'); +}); + +test('cyclic (default)', function (t) { + t.plan(1); + var one = { a: 1 }; + var two = { a: 2, one: one }; + one.two = two; + try { + stringify(one); + } catch (ex) { + t.equal(ex.toString(), 'TypeError: Converting circular structure to JSON'); + } +}); + +test('cyclic (specifically allowed)', function (t) { + t.plan(1); + var one = { a: 1 }; + var two = { a: 2, one: one }; + one.two = two; + t.equal(stringify(one, {cycles:true}), '{"a":1,"two":{"a":2,"one":"__cycle__"}}'); +}); + +test('repeated non-cyclic value', function(t) { + t.plan(1); + var one = { x: 1 }; + var two = { a: one, b: one }; + t.equal(stringify(two), '{"a":{"x":1},"b":{"x":1}}'); +}); + +test('acyclic but with reused obj-property pointers', function (t) { + t.plan(1); + var x = { a: 1 }; + var y = { b: x, c: x }; + t.equal(stringify(y), '{"b":{"a":1},"c":{"a":1}}'); +}); diff --git a/node_modules/fast-json-stable-stringify/test/str.js b/node_modules/fast-json-stable-stringify/test/str.js new file mode 100644 index 0000000000000000000000000000000000000000..99a9ade18bb85760a173ffbc76e6d51ae0a25eaf --- /dev/null +++ b/node_modules/fast-json-stable-stringify/test/str.js @@ -0,0 +1,46 @@ +'use strict'; + +var test = require('tape'); +var stringify = require('../'); + +test('simple object', function (t) { + t.plan(1); + var obj = { c: 6, b: [4,5], a: 3, z: null }; + t.equal(stringify(obj), '{"a":3,"b":[4,5],"c":6,"z":null}'); +}); + +test('object with undefined', function (t) { + t.plan(1); + var obj = { a: 3, z: undefined }; + t.equal(stringify(obj), '{"a":3}'); +}); + +test('object with null', function (t) { + t.plan(1); + var obj = { a: 3, z: null }; + t.equal(stringify(obj), '{"a":3,"z":null}'); +}); + +test('object with NaN and Infinity', function (t) { + t.plan(1); + var obj = { a: 3, b: NaN, c: Infinity }; + t.equal(stringify(obj), '{"a":3,"b":null,"c":null}'); +}); + +test('array with undefined', function (t) { + t.plan(1); + var obj = [4, undefined, 6]; + t.equal(stringify(obj), '[4,null,6]'); +}); + +test('object with empty string', function (t) { + t.plan(1); + var obj = { a: 3, z: '' }; + t.equal(stringify(obj), '{"a":3,"z":""}'); +}); + +test('array with empty string', function (t) { + t.plan(1); + var obj = [4, '', 6]; + t.equal(stringify(obj), '[4,"",6]'); +}); diff --git a/node_modules/fast-json-stable-stringify/test/to-json.js b/node_modules/fast-json-stable-stringify/test/to-json.js new file mode 100644 index 0000000000000000000000000000000000000000..2fb2cfa3e8754a5d84eab3c61968d4af441ae217 --- /dev/null +++ b/node_modules/fast-json-stable-stringify/test/to-json.js @@ -0,0 +1,22 @@ +'use strict'; + +var test = require('tape'); +var stringify = require('../'); + +test('toJSON function', function (t) { + t.plan(1); + var obj = { one: 1, two: 2, toJSON: function() { return { one: 1 }; } }; + t.equal(stringify(obj), '{"one":1}' ); +}); + +test('toJSON returns string', function (t) { + t.plan(1); + var obj = { one: 1, two: 2, toJSON: function() { return 'one'; } }; + t.equal(stringify(obj), '"one"'); +}); + +test('toJSON returns array', function (t) { + t.plan(1); + var obj = { one: 1, two: 2, toJSON: function() { return ['one']; } }; + t.equal(stringify(obj), '["one"]'); +}); diff --git a/node_modules/file-type/index.js b/node_modules/file-type/index.js new file mode 100644 index 0000000000000000000000000000000000000000..f498c10b8348d2689ed3d35995044ae6e563b185 --- /dev/null +++ b/node_modules/file-type/index.js @@ -0,0 +1,452 @@ +'use strict'; +module.exports = function (buf) { + if (!(buf && buf.length > 1)) { + return null; + } + + if (buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF) { + return { + ext: 'jpg', + mime: 'image/jpeg' + }; + } + + if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) { + return { + ext: 'png', + mime: 'image/png' + }; + } + + if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) { + return { + ext: 'gif', + mime: 'image/gif' + }; + } + + if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) { + return { + ext: 'webp', + mime: 'image/webp' + }; + } + + if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x49 && buf[3] === 0x46) { + return { + ext: 'flif', + mime: 'image/flif' + }; + } + + // needs to be before `tif` check + if (((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) && buf[8] === 0x43 && buf[9] === 0x52) { + return { + ext: 'cr2', + mime: 'image/x-canon-cr2' + }; + } + + if ((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) { + return { + ext: 'tif', + mime: 'image/tiff' + }; + } + + if (buf[0] === 0x42 && buf[1] === 0x4D) { + return { + ext: 'bmp', + mime: 'image/bmp' + }; + } + + if (buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0xBC) { + return { + ext: 'jxr', + mime: 'image/vnd.ms-photo' + }; + } + + if (buf[0] === 0x38 && buf[1] === 0x42 && buf[2] === 0x50 && buf[3] === 0x53) { + return { + ext: 'psd', + mime: 'image/vnd.adobe.photoshop' + }; + } + + // needs to be before `zip` check + if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x6D && buf[31] === 0x69 && buf[32] === 0x6D && buf[33] === 0x65 && buf[34] === 0x74 && buf[35] === 0x79 && buf[36] === 0x70 && buf[37] === 0x65 && buf[38] === 0x61 && buf[39] === 0x70 && buf[40] === 0x70 && buf[41] === 0x6C && buf[42] === 0x69 && buf[43] === 0x63 && buf[44] === 0x61 && buf[45] === 0x74 && buf[46] === 0x69 && buf[47] === 0x6F && buf[48] === 0x6E && buf[49] === 0x2F && buf[50] === 0x65 && buf[51] === 0x70 && buf[52] === 0x75 && buf[53] === 0x62 && buf[54] === 0x2B && buf[55] === 0x7A && buf[56] === 0x69 && buf[57] === 0x70) { + return { + ext: 'epub', + mime: 'application/epub+zip' + }; + } + + // needs to be before `zip` check + // assumes signed .xpi from addons.mozilla.org + if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x4D && buf[31] === 0x45 && buf[32] === 0x54 && buf[33] === 0x41 && buf[34] === 0x2D && buf[35] === 0x49 && buf[36] === 0x4E && buf[37] === 0x46 && buf[38] === 0x2F && buf[39] === 0x6D && buf[40] === 0x6F && buf[41] === 0x7A && buf[42] === 0x69 && buf[43] === 0x6C && buf[44] === 0x6C && buf[45] === 0x61 && buf[46] === 0x2E && buf[47] === 0x72 && buf[48] === 0x73 && buf[49] === 0x61) { + return { + ext: 'xpi', + mime: 'application/x-xpinstall' + }; + } + + if (buf[0] === 0x50 && buf[1] === 0x4B && (buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) && (buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)) { + return { + ext: 'zip', + mime: 'application/zip' + }; + } + + if (buf[257] === 0x75 && buf[258] === 0x73 && buf[259] === 0x74 && buf[260] === 0x61 && buf[261] === 0x72) { + return { + ext: 'tar', + mime: 'application/x-tar' + }; + } + + if (buf[0] === 0x52 && buf[1] === 0x61 && buf[2] === 0x72 && buf[3] === 0x21 && buf[4] === 0x1A && buf[5] === 0x7 && (buf[6] === 0x0 || buf[6] === 0x1)) { + return { + ext: 'rar', + mime: 'application/x-rar-compressed' + }; + } + + if (buf[0] === 0x1F && buf[1] === 0x8B && buf[2] === 0x8) { + return { + ext: 'gz', + mime: 'application/gzip' + }; + } + + if (buf[0] === 0x42 && buf[1] === 0x5A && buf[2] === 0x68) { + return { + ext: 'bz2', + mime: 'application/x-bzip2' + }; + } + + if (buf[0] === 0x37 && buf[1] === 0x7A && buf[2] === 0xBC && buf[3] === 0xAF && buf[4] === 0x27 && buf[5] === 0x1C) { + return { + ext: '7z', + mime: 'application/x-7z-compressed' + }; + } + + if (buf[0] === 0x78 && buf[1] === 0x01) { + return { + ext: 'dmg', + mime: 'application/x-apple-diskimage' + }; + } + + if ( + (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && (buf[3] === 0x18 || buf[3] === 0x20) && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) || + (buf[0] === 0x33 && buf[1] === 0x67 && buf[2] === 0x70 && buf[3] === 0x35) || + (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[16] === 0x6D && buf[17] === 0x70 && buf[18] === 0x34 && buf[19] === 0x31 && buf[20] === 0x6D && buf[21] === 0x70 && buf[22] === 0x34 && buf[23] === 0x32 && buf[24] === 0x69 && buf[25] === 0x73 && buf[26] === 0x6F && buf[27] === 0x6D) || + (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x69 && buf[9] === 0x73 && buf[10] === 0x6F && buf[11] === 0x6D) || + (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1c && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[12] === 0x0 && buf[13] === 0x0 && buf[14] === 0x0 && buf[15] === 0x0) + ) { + return { + ext: 'mp4', + mime: 'video/mp4' + }; + } + + if ((buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x56)) { + return { + ext: 'm4v', + mime: 'video/x-m4v' + }; + } + + if (buf[0] === 0x4D && buf[1] === 0x54 && buf[2] === 0x68 && buf[3] === 0x64) { + return { + ext: 'mid', + mime: 'audio/midi' + }; + } + + // needs to be before the `webm` check + if (buf[31] === 0x6D && buf[32] === 0x61 && buf[33] === 0x74 && buf[34] === 0x72 && buf[35] === 0x6f && buf[36] === 0x73 && buf[37] === 0x6B && buf[38] === 0x61) { + return { + ext: 'mkv', + mime: 'video/x-matroska' + }; + } + + if (buf[0] === 0x1A && buf[1] === 0x45 && buf[2] === 0xDF && buf[3] === 0xA3) { + return { + ext: 'webm', + mime: 'video/webm' + }; + } + + if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x14 && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) { + return { + ext: 'mov', + mime: 'video/quicktime' + }; + } + + if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x41 && buf[9] === 0x56 && buf[10] === 0x49) { + return { + ext: 'avi', + mime: 'video/x-msvideo' + }; + } + + if (buf[0] === 0x30 && buf[1] === 0x26 && buf[2] === 0xB2 && buf[3] === 0x75 && buf[4] === 0x8E && buf[5] === 0x66 && buf[6] === 0xCF && buf[7] === 0x11 && buf[8] === 0xA6 && buf[9] === 0xD9) { + return { + ext: 'wmv', + mime: 'video/x-ms-wmv' + }; + } + + if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x1 && buf[3].toString(16)[0] === 'b') { + return { + ext: 'mpg', + mime: 'video/mpeg' + }; + } + + if ((buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) || (buf[0] === 0xFF && buf[1] === 0xfb)) { + return { + ext: 'mp3', + mime: 'audio/mpeg' + }; + } + + if ((buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x41) || (buf[0] === 0x4D && buf[1] === 0x34 && buf[2] === 0x41 && buf[3] === 0x20)) { + return { + ext: 'm4a', + mime: 'audio/m4a' + }; + } + + // needs to be before `ogg` check + if (buf[28] === 0x4F && buf[29] === 0x70 && buf[30] === 0x75 && buf[31] === 0x73 && buf[32] === 0x48 && buf[33] === 0x65 && buf[34] === 0x61 && buf[35] === 0x64) { + return { + ext: 'opus', + mime: 'audio/opus' + }; + } + + if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) { + return { + ext: 'ogg', + mime: 'audio/ogg' + }; + } + + if (buf[0] === 0x66 && buf[1] === 0x4C && buf[2] === 0x61 && buf[3] === 0x43) { + return { + ext: 'flac', + mime: 'audio/x-flac' + }; + } + + if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x57 && buf[9] === 0x41 && buf[10] === 0x56 && buf[11] === 0x45) { + return { + ext: 'wav', + mime: 'audio/x-wav' + }; + } + + if (buf[0] === 0x23 && buf[1] === 0x21 && buf[2] === 0x41 && buf[3] === 0x4D && buf[4] === 0x52 && buf[5] === 0x0A) { + return { + ext: 'amr', + mime: 'audio/amr' + }; + } + + if (buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) { + return { + ext: 'pdf', + mime: 'application/pdf' + }; + } + + if (buf[0] === 0x4D && buf[1] === 0x5A) { + return { + ext: 'exe', + mime: 'application/x-msdownload' + }; + } + + if ((buf[0] === 0x43 || buf[0] === 0x46) && buf[1] === 0x57 && buf[2] === 0x53) { + return { + ext: 'swf', + mime: 'application/x-shockwave-flash' + }; + } + + if (buf[0] === 0x7B && buf[1] === 0x5C && buf[2] === 0x72 && buf[3] === 0x74 && buf[4] === 0x66) { + return { + ext: 'rtf', + mime: 'application/rtf' + }; + } + + if ( + (buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x46) && + ( + (buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) || + (buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F) + ) + ) { + return { + ext: 'woff', + mime: 'application/font-woff' + }; + } + + if ( + (buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x32) && + ( + (buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) || + (buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F) + ) + ) { + return { + ext: 'woff2', + mime: 'application/font-woff' + }; + } + + if ( + (buf[34] === 0x4C && buf[35] === 0x50) && + ( + (buf[8] === 0x00 && buf[9] === 0x00 && buf[10] === 0x01) || + (buf[8] === 0x01 && buf[9] === 0x00 && buf[10] === 0x02) || + (buf[8] === 0x02 && buf[9] === 0x00 && buf[10] === 0x02) + ) + ) { + return { + ext: 'eot', + mime: 'application/octet-stream' + }; + } + + if (buf[0] === 0x00 && buf[1] === 0x01 && buf[2] === 0x00 && buf[3] === 0x00 && buf[4] === 0x00) { + return { + ext: 'ttf', + mime: 'application/font-sfnt' + }; + } + + if (buf[0] === 0x4F && buf[1] === 0x54 && buf[2] === 0x54 && buf[3] === 0x4F && buf[4] === 0x00) { + return { + ext: 'otf', + mime: 'application/font-sfnt' + }; + } + + if (buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) { + return { + ext: 'ico', + mime: 'image/x-icon' + }; + } + + if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x56 && buf[3] === 0x01) { + return { + ext: 'flv', + mime: 'video/x-flv' + }; + } + + if (buf[0] === 0x25 && buf[1] === 0x21) { + return { + ext: 'ps', + mime: 'application/postscript' + }; + } + + if (buf[0] === 0xFD && buf[1] === 0x37 && buf[2] === 0x7A && buf[3] === 0x58 && buf[4] === 0x5A && buf[5] === 0x00) { + return { + ext: 'xz', + mime: 'application/x-xz' + }; + } + + if (buf[0] === 0x53 && buf[1] === 0x51 && buf[2] === 0x4C && buf[3] === 0x69) { + return { + ext: 'sqlite', + mime: 'application/x-sqlite3' + }; + } + + if (buf[0] === 0x4E && buf[1] === 0x45 && buf[2] === 0x53 && buf[3] === 0x1A) { + return { + ext: 'nes', + mime: 'application/x-nintendo-nes-rom' + }; + } + + if (buf[0] === 0x43 && buf[1] === 0x72 && buf[2] === 0x32 && buf[3] === 0x34) { + return { + ext: 'crx', + mime: 'application/x-google-chrome-extension' + }; + } + + if ( + (buf[0] === 0x4D && buf[1] === 0x53 && buf[2] === 0x43 && buf[3] === 0x46) || + (buf[0] === 0x49 && buf[1] === 0x53 && buf[2] === 0x63 && buf[3] === 0x28) + ) { + return { + ext: 'cab', + mime: 'application/vnd.ms-cab-compressed' + }; + } + + // needs to be before `ar` check + if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E && buf[7] === 0x0A && buf[8] === 0x64 && buf[9] === 0x65 && buf[10] === 0x62 && buf[11] === 0x69 && buf[12] === 0x61 && buf[13] === 0x6E && buf[14] === 0x2D && buf[15] === 0x62 && buf[16] === 0x69 && buf[17] === 0x6E && buf[18] === 0x61 && buf[19] === 0x72 && buf[20] === 0x79) { + return { + ext: 'deb', + mime: 'application/x-deb' + }; + } + + if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E) { + return { + ext: 'ar', + mime: 'application/x-unix-archive' + }; + } + + if (buf[0] === 0xED && buf[1] === 0xAB && buf[2] === 0xEE && buf[3] === 0xDB) { + return { + ext: 'rpm', + mime: 'application/x-rpm' + }; + } + + if ( + (buf[0] === 0x1F && buf[1] === 0xA0) || + (buf[0] === 0x1F && buf[1] === 0x9D) + ) { + return { + ext: 'Z', + mime: 'application/x-compress' + }; + } + + if (buf[0] === 0x4C && buf[1] === 0x5A && buf[2] === 0x49 && buf[3] === 0x50) { + return { + ext: 'lz', + mime: 'application/x-lzip' + }; + } + + if (buf[0] === 0xD0 && buf[1] === 0xCF && buf[2] === 0x11 && buf[3] === 0xE0 && buf[4] === 0xA1 && buf[5] === 0xB1 && buf[6] === 0x1A && buf[7] === 0xE1) { + return { + ext: 'msi', + mime: 'application/x-msi' + }; + } + + return null; +}; diff --git a/node_modules/file-type/license b/node_modules/file-type/license new file mode 100644 index 0000000000000000000000000000000000000000..654d0bfe943437d43242325b1fbcff5f400d84ee --- /dev/null +++ b/node_modules/file-type/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.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. diff --git a/node_modules/file-type/package.json b/node_modules/file-type/package.json new file mode 100644 index 0000000000000000000000000000000000000000..caf66d673ca1884dcf063db572eed3cf59616f7a --- /dev/null +++ b/node_modules/file-type/package.json @@ -0,0 +1,103 @@ +{ + "name": "file-type", + "version": "3.9.0", + "description": "Detect the file type of a Buffer/Uint8Array", + "license": "MIT", + "repository": "sindresorhus/file-type", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "mime", + "file", + "type", + "archive", + "image", + "img", + "pic", + "picture", + "flash", + "photo", + "video", + "type", + "detect", + "check", + "is", + "exif", + "exe", + "binary", + "buffer", + "uint8array", + "jpg", + "png", + "gif", + "webp", + "flif", + "cr2", + "tif", + "bmp", + "jxr", + "psd", + "zip", + "tar", + "rar", + "gz", + "bz2", + "7z", + "dmg", + "mp4", + "m4v", + "mid", + "mkv", + "webm", + "mov", + "avi", + "mpg", + "mp3", + "m4a", + "ogg", + "opus", + "flac", + "wav", + "amr", + "pdf", + "epub", + "exe", + "swf", + "rtf", + "woff", + "woff2", + "eot", + "ttf", + "otf", + "ico", + "flv", + "ps", + "xz", + "sqlite", + "xpi", + "cab", + "deb", + "ar", + "rpm", + "Z", + "lz", + "msi" + ], + "devDependencies": { + "ava": "*", + "read-chunk": "^2.0.0", + "xo": "*" + } +} diff --git a/node_modules/file-type/readme.md b/node_modules/file-type/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..32ecf09dccd262259188800ac0d8a2c368a70564 --- /dev/null +++ b/node_modules/file-type/readme.md @@ -0,0 +1,149 @@ +# file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type) + +> Detect the file type of a Buffer/Uint8Array + +The file type is detected by checking the [magic number](http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer. + + +## Install + +``` +$ npm install --save file-type +``` + + +## Usage + +##### Node.js + +```js +const readChunk = require('read-chunk'); // npm install read-chunk +const fileType = require('file-type'); +const buffer = readChunk.sync('unicorn.png', 0, 262); + +fileType(buffer); +//=> {ext: 'png', mime: 'image/png'} +``` + +or from a remote location: + +```js +const http = require('http'); +const fileType = require('file-type'); +const url = 'http://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif'; + +http.get(url, res => { + res.once('data', chunk => { + res.destroy(); + console.log(fileType(chunk)); + //=> {ext: 'gif', mime: 'image/gif'} + }); +}); +``` + +##### Browser + +```js +const xhr = new XMLHttpRequest(); +xhr.open('GET', 'unicorn.png'); +xhr.responseType = 'arraybuffer'; + +xhr.onload = () => { + fileType(new Uint8Array(this.response)); + //=> {ext: 'png', mime: 'image/png'} +}; + +xhr.send(); +``` + + +## API + +### fileType(buffer) + +Returns an `Object` (or `null` when no match) with: + +- `ext` - one of the [supported file types](#supported-file-types) +- `mime` - the [MIME type](http://en.wikipedia.org/wiki/Internet_media_type) + +#### buffer + +Type: `Buffer` `Uint8Array` + +It only needs the first 262 bytes. + + +## Supported file types + +- [`jpg`](https://en.wikipedia.org/wiki/JPEG) +- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics) +- [`gif`](https://en.wikipedia.org/wiki/GIF) +- [`webp`](https://en.wikipedia.org/wiki/WebP) +- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format) +- [`cr2`](http://fileinfo.com/extension/cr2) +- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format) +- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format) +- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR) +- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format) +- [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format)) +- [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format) +- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format)) +- [`gz`](https://en.wikipedia.org/wiki/Gzip) +- [`bz2`](https://en.wikipedia.org/wiki/Bzip2) +- [`7z`](https://en.wikipedia.org/wiki/7z) +- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image) +- [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions) +- [`m4v`](https://en.wikipedia.org/wiki/M4V) +- [`mid`](https://en.wikipedia.org/wiki/MIDI) +- [`mkv`](https://en.wikipedia.org/wiki/Matroska) +- [`webm`](https://en.wikipedia.org/wiki/WebM) +- [`mov`](https://en.wikipedia.org/wiki/QuickTime_File_Format) +- [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave) +- [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video) +- [`mpg`](https://en.wikipedia.org/wiki/MPEG-1) +- [`mp3`](https://en.wikipedia.org/wiki/MP3) +- [`m4a`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#.MP4_versus_.M4A) +- [`ogg`](https://en.wikipedia.org/wiki/Ogg) +- [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format)) +- [`flac`](https://en.wikipedia.org/wiki/FLAC) +- [`wav`](https://en.wikipedia.org/wiki/WAV) +- [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec) +- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format) +- [`epub`](https://en.wikipedia.org/wiki/EPUB) +- [`exe`](https://en.wikipedia.org/wiki/.exe) +- [`swf`](https://en.wikipedia.org/wiki/SWF) +- [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format) +- [`woff`](https://en.wikipedia.org/wiki/Web_Open_Font_Format) +- [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format) +- [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType) +- [`ttf`](https://en.wikipedia.org/wiki/TrueType) +- [`otf`](https://en.wikipedia.org/wiki/OpenType) +- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format)) +- [`flv`](https://en.wikipedia.org/wiki/Flash_Video) +- [`ps`](https://en.wikipedia.org/wiki/Postscript) +- [`xz`](https://en.wikipedia.org/wiki/Xz) +- [`sqlite`](https://www.sqlite.org/fileformat2.html) +- [`nes`](http://fileinfo.com/extension/nes) +- [`crx`](https://developer.chrome.com/extensions/crx) +- [`xpi`](https://en.wikipedia.org/wiki/XPInstall) +- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format)) +- [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format)) +- [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix)) +- [`rpm`](http://fileinfo.com/extension/rpm) +- [`Z`](http://fileinfo.com/extension/z) +- [`lz`](https://en.wikipedia.org/wiki/Lzip) +- [`msi`](https://en.wikipedia.org/wiki/Windows_Installer) + +*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).* + +*PR welcome for additional commonly used file types.* + + +## Related + +- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/function-bind/.eslintrc b/node_modules/function-bind/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..71a054fd370a627af5171153377e7c78ba8937f9 --- /dev/null +++ b/node_modules/function-bind/.eslintrc @@ -0,0 +1,21 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "func-name-matching": 0, + "indent": [2, 4], + "no-new-func": [1], + }, + + "overrides": [ + { + "files": "test/**", + "rules": { + "max-lines-per-function": 0, + "strict": [0] + }, + }, + ], +} diff --git a/node_modules/function-bind/.github/FUNDING.yml b/node_modules/function-bind/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..74482195934a98d0ce03d92cdabbc8a36e647d6f --- /dev/null +++ b/node_modules/function-bind/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/function-bind +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/function-bind/.github/SECURITY.md b/node_modules/function-bind/.github/SECURITY.md new file mode 100644 index 0000000000000000000000000000000000000000..82e4285adc6285693cd6c06af02d606e09dd8fcd --- /dev/null +++ b/node_modules/function-bind/.github/SECURITY.md @@ -0,0 +1,3 @@ +# Security + +Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report. diff --git a/node_modules/function-bind/.nycrc b/node_modules/function-bind/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..1826526e091b89c896e7099ccd891db79165e329 --- /dev/null +++ b/node_modules/function-bind/.nycrc @@ -0,0 +1,13 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "lines": 86, + "statements": 85.93, + "functions": 82.43, + "branches": 76.06, + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/function-bind/CHANGELOG.md b/node_modules/function-bind/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..f9e6cc078dadd58957c92af75542453c18169d73 --- /dev/null +++ b/node_modules/function-bind/CHANGELOG.md @@ -0,0 +1,136 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.1.2](https://github.com/ljharb/function-bind/compare/v1.1.1...v1.1.2) - 2023-10-12 + +### Merged + +- Point to the correct file [`#16`](https://github.com/ljharb/function-bind/pull/16) + +### Commits + +- [Tests] migrate tests to Github Actions [`4f8b57c`](https://github.com/ljharb/function-bind/commit/4f8b57c02f2011fe9ae353d5e74e8745f0988af8) +- [Tests] remove `jscs` [`90eb2ed`](https://github.com/ljharb/function-bind/commit/90eb2edbeefd5b76cd6c3a482ea3454db169b31f) +- [meta] update `.gitignore` [`53fcdc3`](https://github.com/ljharb/function-bind/commit/53fcdc371cd66634d6e9b71c836a50f437e89fed) +- [Tests] up to `node` `v11.10`, `v10.15`, `v9.11`, `v8.15`, `v6.16`, `v4.9`; use `nvm install-latest-npm`; run audit script in tests [`1fe8f6e`](https://github.com/ljharb/function-bind/commit/1fe8f6e9aed0dfa8d8b3cdbd00c7f5ea0cd2b36e) +- [meta] add `auto-changelog` [`1921fcb`](https://github.com/ljharb/function-bind/commit/1921fcb5b416b63ffc4acad051b6aad5722f777d) +- [Robustness] remove runtime dependency on all builtins except `.apply` [`f743e61`](https://github.com/ljharb/function-bind/commit/f743e61aa6bb2360358c04d4884c9db853d118b7) +- Docs: enable badges; update wording [`503cb12`](https://github.com/ljharb/function-bind/commit/503cb12d998b5f91822776c73332c7adcd6355dd) +- [readme] update badges [`290c5db`](https://github.com/ljharb/function-bind/commit/290c5dbbbda7264efaeb886552a374b869a4bb48) +- [Tests] switch to nyc for coverage [`ea360ba`](https://github.com/ljharb/function-bind/commit/ea360ba907fc2601ed18d01a3827fa2d3533cdf8) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`cae5e9e`](https://github.com/ljharb/function-bind/commit/cae5e9e07a5578dc6df26c03ee22851ce05b943c) +- [meta] add `funding` field; create FUNDING.yml [`c9f4274`](https://github.com/ljharb/function-bind/commit/c9f4274aa80ea3aae9657a3938fdba41a3b04ca6) +- [Tests] fix eslint errors from #15 [`f69aaa2`](https://github.com/ljharb/function-bind/commit/f69aaa2beb2fdab4415bfb885760a699d0b9c964) +- [actions] fix permissions [`99a0cd9`](https://github.com/ljharb/function-bind/commit/99a0cd9f3b5bac223a0d572f081834cd73314be7) +- [meta] use `npmignore` to autogenerate an npmignore file [`f03b524`](https://github.com/ljharb/function-bind/commit/f03b524ca91f75a109a5d062f029122c86ecd1ae) +- [Dev Deps] update `@ljharb/eslint‑config`, `eslint`, `tape` [`7af9300`](https://github.com/ljharb/function-bind/commit/7af930023ae2ce7645489532821e4fbbcd7a2280) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `tape` [`64a9127`](https://github.com/ljharb/function-bind/commit/64a9127ab0bd331b93d6572eaf6e9971967fc08c) +- [Tests] use `aud` instead of `npm audit` [`e75069c`](https://github.com/ljharb/function-bind/commit/e75069c50010a8fcce2a9ce2324934c35fdb4386) +- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`d03555c`](https://github.com/ljharb/function-bind/commit/d03555ca59dea3b71ce710045e4303b9e2619e28) +- [meta] add `safe-publish-latest` [`9c8f809`](https://github.com/ljharb/function-bind/commit/9c8f8092aed027d7e80c94f517aa892385b64f09) +- [Dev Deps] update `@ljharb/eslint-config`, `tape` [`baf6893`](https://github.com/ljharb/function-bind/commit/baf6893e27f5b59abe88bc1995e6f6ed1e527397) +- [meta] create SECURITY.md [`4db1779`](https://github.com/ljharb/function-bind/commit/4db17799f1f28ae294cb95e0081ca2b591c3911b) +- [Tests] add `npm run audit` [`c8b38ec`](https://github.com/ljharb/function-bind/commit/c8b38ec40ed3f85dabdee40ed4148f1748375bc2) +- Revert "Point to the correct file" [`05cdf0f`](https://github.com/ljharb/function-bind/commit/05cdf0fa205c6a3c5ba40bbedd1dfa9874f915c9) + +## [v1.1.1](https://github.com/ljharb/function-bind/compare/v1.1.0...v1.1.1) - 2017-08-28 + +### Commits + +- [Tests] up to `node` `v8`; newer npm breaks on older node; fix scripts [`817f7d2`](https://github.com/ljharb/function-bind/commit/817f7d28470fdbff8ef608d4d565dd4d1430bc5e) +- [Dev Deps] update `eslint`, `jscs`, `tape`, `@ljharb/eslint-config` [`854288b`](https://github.com/ljharb/function-bind/commit/854288b1b6f5c555f89aceb9eff1152510262084) +- [Dev Deps] update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`83e639f`](https://github.com/ljharb/function-bind/commit/83e639ff74e6cd6921285bccec22c1bcf72311bd) +- Only apps should have lockfiles [`5ed97f5`](https://github.com/ljharb/function-bind/commit/5ed97f51235c17774e0832e122abda0f3229c908) +- Use a SPDX-compliant “license” field. [`5feefea`](https://github.com/ljharb/function-bind/commit/5feefea0dc0193993e83e5df01ded424403a5381) + +## [v1.1.0](https://github.com/ljharb/function-bind/compare/v1.0.2...v1.1.0) - 2016-02-14 + +### Commits + +- Update `eslint`, `tape`; use my personal shared `eslint` config [`9c9062a`](https://github.com/ljharb/function-bind/commit/9c9062abbe9dd70b59ea2c3a3c3a81f29b457097) +- Add `npm run eslint` [`dd96c56`](https://github.com/ljharb/function-bind/commit/dd96c56720034a3c1ffee10b8a59a6f7c53e24ad) +- [New] return the native `bind` when available. [`82186e0`](https://github.com/ljharb/function-bind/commit/82186e03d73e580f95ff167e03f3582bed90ed72) +- [Dev Deps] update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`a3dd767`](https://github.com/ljharb/function-bind/commit/a3dd76720c795cb7f4586b0544efabf8aa107b8b) +- Update `eslint` [`3dae2f7`](https://github.com/ljharb/function-bind/commit/3dae2f7423de30a2d20313ddb1edc19660142fe9) +- Update `tape`, `covert`, `jscs` [`a181eee`](https://github.com/ljharb/function-bind/commit/a181eee0cfa24eb229c6e843a971f36e060a2f6a) +- [Tests] up to `node` `v5.6`, `v4.3` [`964929a`](https://github.com/ljharb/function-bind/commit/964929a6a4ddb36fb128de2bcc20af5e4f22e1ed) +- Test up to `io.js` `v2.1` [`2be7310`](https://github.com/ljharb/function-bind/commit/2be7310f2f74886a7124ca925be411117d41d5ea) +- Update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`45f3d68`](https://github.com/ljharb/function-bind/commit/45f3d6865c6ca93726abcef54febe009087af101) +- [Dev Deps] update `tape`, `jscs` [`6e1340d`](https://github.com/ljharb/function-bind/commit/6e1340d94642deaecad3e717825db641af4f8b1f) +- [Tests] up to `io.js` `v3.3`, `node` `v4.1` [`d9bad2b`](https://github.com/ljharb/function-bind/commit/d9bad2b778b1b3a6dd2876087b88b3acf319f8cc) +- Update `eslint` [`935590c`](https://github.com/ljharb/function-bind/commit/935590caa024ab356102e4858e8fc315b2ccc446) +- [Dev Deps] update `jscs`, `eslint`, `@ljharb/eslint-config` [`8c9a1ef`](https://github.com/ljharb/function-bind/commit/8c9a1efd848e5167887aa8501857a0940a480c57) +- Test on `io.js` `v2.2` [`9a3a38c`](https://github.com/ljharb/function-bind/commit/9a3a38c92013aed6e108666e7bd40969b84ac86e) +- Run `travis-ci` tests on `iojs` and `node` v0.12; speed up builds; allow 0.8 failures. [`69afc26`](https://github.com/ljharb/function-bind/commit/69afc2617405b147dd2a8d8ae73ca9e9283f18b4) +- [Dev Deps] Update `tape`, `eslint` [`36c1be0`](https://github.com/ljharb/function-bind/commit/36c1be0ab12b45fe5df6b0fdb01a5d5137fd0115) +- Update `tape`, `jscs` [`98d8303`](https://github.com/ljharb/function-bind/commit/98d8303cd5ca1c6b8f985469f86b0d44d7d45f6e) +- Update `jscs` [`9633a4e`](https://github.com/ljharb/function-bind/commit/9633a4e9fbf82051c240855166e468ba8ba0846f) +- Update `tape`, `jscs` [`c80ef0f`](https://github.com/ljharb/function-bind/commit/c80ef0f46efc9791e76fa50de4414092ac147831) +- Test up to `io.js` `v3.0` [`7e2c853`](https://github.com/ljharb/function-bind/commit/7e2c8537d52ab9cf5a655755561d8917684c0df4) +- Test on `io.js` `v2.4` [`5a199a2`](https://github.com/ljharb/function-bind/commit/5a199a27ba46795ba5eaf0845d07d4b8232895c9) +- Test on `io.js` `v2.3` [`a511b88`](https://github.com/ljharb/function-bind/commit/a511b8896de0bddf3b56862daa416c701f4d0453) +- Fixing a typo from 822b4e1938db02dc9584aa434fd3a45cb20caf43 [`732d6b6`](https://github.com/ljharb/function-bind/commit/732d6b63a9b33b45230e630dbcac7a10855d3266) +- Update `jscs` [`da52a48`](https://github.com/ljharb/function-bind/commit/da52a4886c06d6490f46ae30b15e4163ba08905d) +- Lock covert to v1.0.0. [`d6150fd`](https://github.com/ljharb/function-bind/commit/d6150fda1e6f486718ebdeff823333d9e48e7430) + +## [v1.0.2](https://github.com/ljharb/function-bind/compare/v1.0.1...v1.0.2) - 2014-10-04 + +## [v1.0.1](https://github.com/ljharb/function-bind/compare/v1.0.0...v1.0.1) - 2014-10-03 + +### Merged + +- make CI build faster [`#3`](https://github.com/ljharb/function-bind/pull/3) + +### Commits + +- Using my standard jscs.json [`d8ee94c`](https://github.com/ljharb/function-bind/commit/d8ee94c993eff0a84cf5744fe6a29627f5cffa1a) +- Adding `npm run lint` [`7571ab7`](https://github.com/ljharb/function-bind/commit/7571ab7dfdbd99b25a1dbb2d232622bd6f4f9c10) +- Using consistent indentation [`e91a1b1`](https://github.com/ljharb/function-bind/commit/e91a1b13a61e99ec1e530e299b55508f74218a95) +- Updating jscs [`7e17892`](https://github.com/ljharb/function-bind/commit/7e1789284bc629bc9c1547a61c9b227bbd8c7a65) +- Using consistent quotes [`c50b57f`](https://github.com/ljharb/function-bind/commit/c50b57fcd1c5ec38320979c837006069ebe02b77) +- Adding keywords [`cb94631`](https://github.com/ljharb/function-bind/commit/cb946314eed35f21186a25fb42fc118772f9ee00) +- Directly export a function expression instead of using a declaration, and relying on hoisting. [`5a33c5f`](https://github.com/ljharb/function-bind/commit/5a33c5f45642de180e0d207110bf7d1843ceb87c) +- Naming npm URL and badge in README; use SVG [`2aef8fc`](https://github.com/ljharb/function-bind/commit/2aef8fcb79d54e63a58ae557c4e60949e05d5e16) +- Naming deps URLs in README [`04228d7`](https://github.com/ljharb/function-bind/commit/04228d766670ee45ca24e98345c1f6a7621065b5) +- Naming travis-ci URLs in README; using SVG [`62c810c`](https://github.com/ljharb/function-bind/commit/62c810c2f54ced956cd4d4ab7b793055addfe36e) +- Make sure functions are invoked correctly (also passing coverage tests) [`2b289b4`](https://github.com/ljharb/function-bind/commit/2b289b4dfbf037ffcfa4dc95eb540f6165e9e43a) +- Removing the strict mode pragmas; they make tests fail. [`1aa701d`](https://github.com/ljharb/function-bind/commit/1aa701d199ddc3782476e8f7eef82679be97b845) +- Adding myself as a contributor [`85fd57b`](https://github.com/ljharb/function-bind/commit/85fd57b0860e5a7af42de9a287f3f265fc6d72fc) +- Adding strict mode pragmas [`915b08e`](https://github.com/ljharb/function-bind/commit/915b08e084c86a722eafe7245e21db74aa21ca4c) +- Adding devDeps URLs to README [`4ccc731`](https://github.com/ljharb/function-bind/commit/4ccc73112c1769859e4ca3076caf4086b3cba2cd) +- Fixing the description. [`a7a472c`](https://github.com/ljharb/function-bind/commit/a7a472cf649af515c635cf560fc478fbe48999c8) +- Using a function expression instead of a function declaration. [`b5d3e4e`](https://github.com/ljharb/function-bind/commit/b5d3e4ea6aaffc63888953eeb1fbc7ff45f1fa14) +- Updating tape [`f086be6`](https://github.com/ljharb/function-bind/commit/f086be6029fb56dde61a258c1340600fa174d1e0) +- Updating jscs [`5f9bdb3`](https://github.com/ljharb/function-bind/commit/5f9bdb375ab13ba48f30852aab94029520c54d71) +- Updating jscs [`9b409ba`](https://github.com/ljharb/function-bind/commit/9b409ba6118e23395a4e5d83ef39152aab9d3bfc) +- Run coverage as part of tests. [`8e1b6d4`](https://github.com/ljharb/function-bind/commit/8e1b6d459f047d1bd4fee814e01247c984c80bd0) +- Run linter as part of tests [`c1ca83f`](https://github.com/ljharb/function-bind/commit/c1ca83f832df94587d09e621beba682fabfaa987) +- Updating covert [`701e837`](https://github.com/ljharb/function-bind/commit/701e83774b57b4d3ef631e1948143f43a72f4bb9) + +## [v1.0.0](https://github.com/ljharb/function-bind/compare/v0.2.0...v1.0.0) - 2014-08-09 + +### Commits + +- Make sure old and unstable nodes don't fail Travis [`27adca3`](https://github.com/ljharb/function-bind/commit/27adca34a4ab6ad67b6dfde43942a1b103ce4d75) +- Fixing an issue when the bound function is called as a constructor in ES3. [`e20122d`](https://github.com/ljharb/function-bind/commit/e20122d267d92ce553859b280cbbea5d27c07731) +- Adding `npm run coverage` [`a2e29c4`](https://github.com/ljharb/function-bind/commit/a2e29c4ecaef9e2f6cd1603e868c139073375502) +- Updating tape [`b741168`](https://github.com/ljharb/function-bind/commit/b741168b12b235b1717ff696087645526b69213c) +- Upgrading tape [`63631a0`](https://github.com/ljharb/function-bind/commit/63631a04c7fbe97cc2fa61829cc27246d6986f74) +- Updating tape [`363cb46`](https://github.com/ljharb/function-bind/commit/363cb46dafb23cb3e347729a22f9448051d78464) + +## v0.2.0 - 2014-03-23 + +### Commits + +- Updating test coverage to match es5-shim. [`aa94d44`](https://github.com/ljharb/function-bind/commit/aa94d44b8f9d7f69f10e060db7709aa7a694e5d4) +- initial [`942ee07`](https://github.com/ljharb/function-bind/commit/942ee07e94e542d91798137bc4b80b926137e066) +- Setting the bound function's length properly. [`079f46a`](https://github.com/ljharb/function-bind/commit/079f46a2d3515b7c0b308c2c13fceb641f97ca25) +- Ensuring that some older browsers will throw when given a regex. [`36ac55b`](https://github.com/ljharb/function-bind/commit/36ac55b87f460d4330253c92870aa26fbfe8227f) +- Removing npm scripts that don't have dependencies [`9d2be60`](https://github.com/ljharb/function-bind/commit/9d2be600002cb8bc8606f8f3585ad3e05868c750) +- Updating tape [`297a4ac`](https://github.com/ljharb/function-bind/commit/297a4acc5464db381940aafb194d1c88f4e678f3) +- Skipping length tests for now. [`d9891ea`](https://github.com/ljharb/function-bind/commit/d9891ea4d2aaffa69f408339cdd61ff740f70565) +- don't take my tea [`dccd930`](https://github.com/ljharb/function-bind/commit/dccd930bfd60ea10cb178d28c97550c3bc8c1e07) diff --git a/node_modules/function-bind/LICENSE b/node_modules/function-bind/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..62d6d237ff179b118746a64a34967f7ff4b5dff8 --- /dev/null +++ b/node_modules/function-bind/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2013 Raynos. + +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. + diff --git a/node_modules/function-bind/README.md b/node_modules/function-bind/README.md new file mode 100644 index 0000000000000000000000000000000000000000..814c20b5a9e3c97f41dde308939b358f9ed93931 --- /dev/null +++ b/node_modules/function-bind/README.md @@ -0,0 +1,46 @@ +# function-bind [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] + +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Implementation of function.prototype.bind + +Old versions of phantomjs, Internet Explorer < 9, and node < 0.6 don't support `Function.prototype.bind`. + +## Example + +```js +Function.prototype.bind = require("function-bind") +``` + +## Installation + +`npm install function-bind` + +## Contributors + + - Raynos + +## MIT Licenced + +[package-url]: https://npmjs.org/package/function-bind +[npm-version-svg]: https://versionbadg.es/Raynos/function-bind.svg +[deps-svg]: https://david-dm.org/Raynos/function-bind.svg +[deps-url]: https://david-dm.org/Raynos/function-bind +[dev-deps-svg]: https://david-dm.org/Raynos/function-bind/dev-status.svg +[dev-deps-url]: https://david-dm.org/Raynos/function-bind#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/function-bind.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/function-bind.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/function-bind.svg +[downloads-url]: https://npm-stat.com/charts.html?package=function-bind +[codecov-image]: https://codecov.io/gh/Raynos/function-bind/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/Raynos/function-bind/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/Raynos/function-bind +[actions-url]: https://github.com/Raynos/function-bind/actions diff --git a/node_modules/function-bind/implementation.js b/node_modules/function-bind/implementation.js new file mode 100644 index 0000000000000000000000000000000000000000..fd4384cc0c34ce3e1e411bc8b0557680cf000eff --- /dev/null +++ b/node_modules/function-bind/implementation.js @@ -0,0 +1,84 @@ +'use strict'; + +/* eslint no-invalid-this: 1 */ + +var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; +var toStr = Object.prototype.toString; +var max = Math.max; +var funcType = '[object Function]'; + +var concatty = function concatty(a, b) { + var arr = []; + + for (var i = 0; i < a.length; i += 1) { + arr[i] = a[i]; + } + for (var j = 0; j < b.length; j += 1) { + arr[j + a.length] = b[j]; + } + + return arr; +}; + +var slicy = function slicy(arrLike, offset) { + var arr = []; + for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) { + arr[j] = arrLike[i]; + } + return arr; +}; + +var joiny = function (arr, joiner) { + var str = ''; + for (var i = 0; i < arr.length; i += 1) { + str += arr[i]; + if (i + 1 < arr.length) { + str += joiner; + } + } + return str; +}; + +module.exports = function bind(that) { + var target = this; + if (typeof target !== 'function' || toStr.apply(target) !== funcType) { + throw new TypeError(ERROR_MESSAGE + target); + } + var args = slicy(arguments, 1); + + var bound; + var binder = function () { + if (this instanceof bound) { + var result = target.apply( + this, + concatty(args, arguments) + ); + if (Object(result) === result) { + return result; + } + return this; + } + return target.apply( + that, + concatty(args, arguments) + ); + + }; + + var boundLength = max(0, target.length - args.length); + var boundArgs = []; + for (var i = 0; i < boundLength; i++) { + boundArgs[i] = '$' + i; + } + + bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder); + + if (target.prototype) { + var Empty = function Empty() {}; + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + Empty.prototype = null; + } + + return bound; +}; diff --git a/node_modules/function-bind/index.js b/node_modules/function-bind/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3bb6b9609889f8131b2d6732ff1606e01e1365b2 --- /dev/null +++ b/node_modules/function-bind/index.js @@ -0,0 +1,5 @@ +'use strict'; + +var implementation = require('./implementation'); + +module.exports = Function.prototype.bind || implementation; diff --git a/node_modules/function-bind/package.json b/node_modules/function-bind/package.json new file mode 100644 index 0000000000000000000000000000000000000000..618596389779061eb7f6f34edc61add4a517ca4f --- /dev/null +++ b/node_modules/function-bind/package.json @@ -0,0 +1,87 @@ +{ + "name": "function-bind", + "version": "1.1.2", + "description": "Implementation of Function.prototype.bind", + "keywords": [ + "function", + "bind", + "shim", + "es5" + ], + "author": "Raynos ", + "repository": { + "type": "git", + "url": "https://github.com/Raynos/function-bind.git" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "main": "index", + "homepage": "https://github.com/Raynos/function-bind", + "contributors": [ + { + "name": "Raynos" + }, + { + "name": "Jordan Harband", + "url": "https://github.com/ljharb" + } + ], + "bugs": { + "url": "https://github.com/Raynos/function-bind/issues", + "email": "raynos2@gmail.com" + }, + "devDependencies": { + "@ljharb/eslint-config": "^21.1.0", + "aud": "^2.0.3", + "auto-changelog": "^2.4.0", + "eslint": "=8.8.0", + "in-publish": "^2.0.1", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "safe-publish-latest": "^2.0.0", + "tape": "^5.7.1" + }, + "license": "MIT", + "scripts": { + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "prepack": "npmignore --auto --commentLines=autogenerated", + "pretest": "npm run lint", + "test": "npm run tests-only", + "posttest": "aud --production", + "tests-only": "nyc tape 'test/**/*.js'", + "lint": "eslint --ext=js,mjs .", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "ie/8..latest", + "firefox/16..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] + } +} diff --git a/node_modules/function-bind/test/.eslintrc b/node_modules/function-bind/test/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..8a56d5b72fb008043cc69939648790ef482cdab8 --- /dev/null +++ b/node_modules/function-bind/test/.eslintrc @@ -0,0 +1,9 @@ +{ + "rules": { + "array-bracket-newline": 0, + "array-element-newline": 0, + "max-statements-per-line": [2, { "max": 2 }], + "no-invalid-this": 0, + "no-magic-numbers": 0, + } +} diff --git a/node_modules/function-bind/test/index.js b/node_modules/function-bind/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..2edecce2f0fa5adcc88ebc609440221621048c05 --- /dev/null +++ b/node_modules/function-bind/test/index.js @@ -0,0 +1,252 @@ +// jscs:disable requireUseStrict + +var test = require('tape'); + +var functionBind = require('../implementation'); +var getCurrentContext = function () { return this; }; + +test('functionBind is a function', function (t) { + t.equal(typeof functionBind, 'function'); + t.end(); +}); + +test('non-functions', function (t) { + var nonFunctions = [true, false, [], {}, 42, 'foo', NaN, /a/g]; + t.plan(nonFunctions.length); + for (var i = 0; i < nonFunctions.length; ++i) { + try { functionBind.call(nonFunctions[i]); } catch (ex) { + t.ok(ex instanceof TypeError, 'throws when given ' + String(nonFunctions[i])); + } + } + t.end(); +}); + +test('without a context', function (t) { + t.test('binds properly', function (st) { + var args, context; + var namespace = { + func: functionBind.call(function () { + args = Array.prototype.slice.call(arguments); + context = this; + }) + }; + namespace.func(1, 2, 3); + st.deepEqual(args, [1, 2, 3]); + st.equal(context, getCurrentContext.call()); + st.end(); + }); + + t.test('binds properly, and still supplies bound arguments', function (st) { + var args, context; + var namespace = { + func: functionBind.call(function () { + args = Array.prototype.slice.call(arguments); + context = this; + }, undefined, 1, 2, 3) + }; + namespace.func(4, 5, 6); + st.deepEqual(args, [1, 2, 3, 4, 5, 6]); + st.equal(context, getCurrentContext.call()); + st.end(); + }); + + t.test('returns properly', function (st) { + var args; + var namespace = { + func: functionBind.call(function () { + args = Array.prototype.slice.call(arguments); + return this; + }, null) + }; + var context = namespace.func(1, 2, 3); + st.equal(context, getCurrentContext.call(), 'returned context is namespaced context'); + st.deepEqual(args, [1, 2, 3], 'passed arguments are correct'); + st.end(); + }); + + t.test('returns properly with bound arguments', function (st) { + var args; + var namespace = { + func: functionBind.call(function () { + args = Array.prototype.slice.call(arguments); + return this; + }, null, 1, 2, 3) + }; + var context = namespace.func(4, 5, 6); + st.equal(context, getCurrentContext.call(), 'returned context is namespaced context'); + st.deepEqual(args, [1, 2, 3, 4, 5, 6], 'passed arguments are correct'); + st.end(); + }); + + t.test('called as a constructor', function (st) { + var thunkify = function (value) { + return function () { return value; }; + }; + st.test('returns object value', function (sst) { + var expectedReturnValue = [1, 2, 3]; + var Constructor = functionBind.call(thunkify(expectedReturnValue), null); + var result = new Constructor(); + sst.equal(result, expectedReturnValue); + sst.end(); + }); + + st.test('does not return primitive value', function (sst) { + var Constructor = functionBind.call(thunkify(42), null); + var result = new Constructor(); + sst.notEqual(result, 42); + sst.end(); + }); + + st.test('object from bound constructor is instance of original and bound constructor', function (sst) { + var A = function (x) { + this.name = x || 'A'; + }; + var B = functionBind.call(A, null, 'B'); + + var result = new B(); + sst.ok(result instanceof B, 'result is instance of bound constructor'); + sst.ok(result instanceof A, 'result is instance of original constructor'); + sst.end(); + }); + + st.end(); + }); + + t.end(); +}); + +test('with a context', function (t) { + t.test('with no bound arguments', function (st) { + var args, context; + var boundContext = {}; + var namespace = { + func: functionBind.call(function () { + args = Array.prototype.slice.call(arguments); + context = this; + }, boundContext) + }; + namespace.func(1, 2, 3); + st.equal(context, boundContext, 'binds a context properly'); + st.deepEqual(args, [1, 2, 3], 'supplies passed arguments'); + st.end(); + }); + + t.test('with bound arguments', function (st) { + var args, context; + var boundContext = {}; + var namespace = { + func: functionBind.call(function () { + args = Array.prototype.slice.call(arguments); + context = this; + }, boundContext, 1, 2, 3) + }; + namespace.func(4, 5, 6); + st.equal(context, boundContext, 'binds a context properly'); + st.deepEqual(args, [1, 2, 3, 4, 5, 6], 'supplies bound and passed arguments'); + st.end(); + }); + + t.test('returns properly', function (st) { + var boundContext = {}; + var args; + var namespace = { + func: functionBind.call(function () { + args = Array.prototype.slice.call(arguments); + return this; + }, boundContext) + }; + var context = namespace.func(1, 2, 3); + st.equal(context, boundContext, 'returned context is bound context'); + st.notEqual(context, getCurrentContext.call(), 'returned context is not lexical context'); + st.deepEqual(args, [1, 2, 3], 'passed arguments are correct'); + st.end(); + }); + + t.test('returns properly with bound arguments', function (st) { + var boundContext = {}; + var args; + var namespace = { + func: functionBind.call(function () { + args = Array.prototype.slice.call(arguments); + return this; + }, boundContext, 1, 2, 3) + }; + var context = namespace.func(4, 5, 6); + st.equal(context, boundContext, 'returned context is bound context'); + st.notEqual(context, getCurrentContext.call(), 'returned context is not lexical context'); + st.deepEqual(args, [1, 2, 3, 4, 5, 6], 'passed arguments are correct'); + st.end(); + }); + + t.test('passes the correct arguments when called as a constructor', function (st) { + var expected = { name: 'Correct' }; + var namespace = { + Func: functionBind.call(function (arg) { + return arg; + }, { name: 'Incorrect' }) + }; + var returned = new namespace.Func(expected); + st.equal(returned, expected, 'returns the right arg when called as a constructor'); + st.end(); + }); + + t.test('has the new instance\'s context when called as a constructor', function (st) { + var actualContext; + var expectedContext = { foo: 'bar' }; + var namespace = { + Func: functionBind.call(function () { + actualContext = this; + }, expectedContext) + }; + var result = new namespace.Func(); + st.equal(result instanceof namespace.Func, true); + st.notEqual(actualContext, expectedContext); + st.end(); + }); + + t.end(); +}); + +test('bound function length', function (t) { + t.test('sets a correct length without thisArg', function (st) { + var subject = functionBind.call(function (a, b, c) { return a + b + c; }); + st.equal(subject.length, 3); + st.equal(subject(1, 2, 3), 6); + st.end(); + }); + + t.test('sets a correct length with thisArg', function (st) { + var subject = functionBind.call(function (a, b, c) { return a + b + c; }, {}); + st.equal(subject.length, 3); + st.equal(subject(1, 2, 3), 6); + st.end(); + }); + + t.test('sets a correct length without thisArg and first argument', function (st) { + var subject = functionBind.call(function (a, b, c) { return a + b + c; }, undefined, 1); + st.equal(subject.length, 2); + st.equal(subject(2, 3), 6); + st.end(); + }); + + t.test('sets a correct length with thisArg and first argument', function (st) { + var subject = functionBind.call(function (a, b, c) { return a + b + c; }, {}, 1); + st.equal(subject.length, 2); + st.equal(subject(2, 3), 6); + st.end(); + }); + + t.test('sets a correct length without thisArg and too many arguments', function (st) { + var subject = functionBind.call(function (a, b, c) { return a + b + c; }, undefined, 1, 2, 3, 4); + st.equal(subject.length, 0); + st.equal(subject(), 6); + st.end(); + }); + + t.test('sets a correct length with thisArg and too many arguments', function (st) { + var subject = functionBind.call(function (a, b, c) { return a + b + c; }, {}, 1, 2, 3, 4); + st.equal(subject.length, 0); + st.equal(subject(), 6); + st.end(); + }); +}); diff --git a/node_modules/function.prototype.name/.editorconfig b/node_modules/function.prototype.name/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..b2bccd44f96034bd21da8a118076d0fd319f8cb6 --- /dev/null +++ b/node_modules/function.prototype.name/.editorconfig @@ -0,0 +1,24 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = off + +[CHANGELOG.md] +indent_style = space +indent_size = 2 + +[README.md] +indent_style = space +indent_size = 2 + +[*.json] +max_line_length = off + +[Makefile] +max_line_length = off diff --git a/node_modules/function.prototype.name/.eslintrc b/node_modules/function.prototype.name/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..92e59ca6f08aa3d2cc87b815c73fdb2395372997 --- /dev/null +++ b/node_modules/function.prototype.name/.eslintrc @@ -0,0 +1,15 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "max-lines-per-function": 0, + "new-cap": [2, { + "capIsNewExceptions": [ + "HasOwnProperty", + "IsCallable", + ], + }], + }, +} diff --git a/node_modules/function.prototype.name/.github/FUNDING.yml b/node_modules/function.prototype.name/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..6a3b00c775c8d02646a5060d22d7c2d3517f0778 --- /dev/null +++ b/node_modules/function.prototype.name/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/function.prototype.name +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/function.prototype.name/.nycrc b/node_modules/function.prototype.name/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/function.prototype.name/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/function.prototype.name/CHANGELOG.md b/node_modules/function.prototype.name/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..6ad93bc1477ec4fef298fb0c49cc20f1742f328f --- /dev/null +++ b/node_modules/function.prototype.name/CHANGELOG.md @@ -0,0 +1,123 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.1.6](https://github.com/es-shims/Function.prototype.name/compare/v1.1.5...v1.1.6) - 2023-08-28 + +### Commits + +- [actions] reuse common workflows [`5f6bfba`](https://github.com/es-shims/Function.prototype.name/commit/5f6bfba9d2c42fbac8f4812396bc71f79464846c) +- [meta] use `npmignore` to autogenerate an npmignore file [`28ea2f9`](https://github.com/es-shims/Function.prototype.name/commit/28ea2f9a9dd48623cba04e94c491033f1c9d1e90) +- [Fix] properly recognize `document.all` in IE 6-8 [`316d676`](https://github.com/es-shims/Function.prototype.name/commit/316d67641d54bf221ed5edfdb9e04af3b98caad8) +- [Fix] only return an own `name` [`d647609`](https://github.com/es-shims/Function.prototype.name/commit/d6476090e110733b52a922f4d0dbfdbc9478c653) +- [Tests] add browserstack browser tests [`67ae402`](https://github.com/es-shims/Function.prototype.name/commit/67ae402aabcad83df2f7d7e356d059a84fe71f44) +- [meta] better `eccheck` command [`728df4c`](https://github.com/es-shims/Function.prototype.name/commit/728df4cc81a51a131a36c0768c4adb7668ad7569) +- [meta] add `auto-changelog` [`dbb700b`](https://github.com/es-shims/Function.prototype.name/commit/dbb700b38ef4c18e0ce0670a2ffface9ffd251a0) +- [readme] fix eclint [`c98fdf1`](https://github.com/es-shims/Function.prototype.name/commit/c98fdf1bc5451de667945c41187a67022f750001) +- [readme] add tested browsers [`d41325c`](https://github.com/es-shims/Function.prototype.name/commit/d41325ceec61627f63281d0649e4e0004f3e0609) +- [actions] update rebase action to use reusable workflow [`085f340`](https://github.com/es-shims/Function.prototype.name/commit/085f3400785cd4f3fb762b73b095f5dfb795a0b3) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `safe-publish-latest`, `tape` [`3f071ce`](https://github.com/es-shims/Function.prototype.name/commit/3f071cef2e1feebfd7d0daea7d6392c2feada091) +- [actions] update codecov uploader [`a187b4f`](https://github.com/es-shims/Function.prototype.name/commit/a187b4fd07dbbeee12e8dc60651f122ab3f41f8d) +- [Deps] update `define-properties`, `es-abstract` [`3ca42ef`](https://github.com/es-shims/Function.prototype.name/commit/3ca42ef76d5d4016d1ea87d806dc7e4a09d9b4f8) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`8de25d2`](https://github.com/es-shims/Function.prototype.name/commit/8de25d2b9b523bd385b0bf3bb9213c11ecf8f1ba) +- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud`, `tape` [`8b04da7`](https://github.com/es-shims/Function.prototype.name/commit/8b04da71695a1b9cf285ee926ffeec55b543595b) +- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`39d8538`](https://github.com/es-shims/Function.prototype.name/commit/39d853854136a749c94e10f9fb06ba73903671a6) +- [meta] reorder scripts [`054f96b`](https://github.com/es-shims/Function.prototype.name/commit/054f96b5e88e08e65c4e27bcb799c7cea2bc3462) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`bebee89`](https://github.com/es-shims/Function.prototype.name/commit/bebee894a7989aef6e9db0dc8b16cbd9134b629c) +- [Dev Deps] update `aud`, `tape` [`8e68159`](https://github.com/es-shims/Function.prototype.name/commit/8e681599b4fbf26e921f61fd603da0524369b72c) +- [Tests] handle Function.prototype in Opera 12.1 [`f3b8f9a`](https://github.com/es-shims/Function.prototype.name/commit/f3b8f9a40b88f6da5ad41b874c3f2acf6fb30378) +- [Deps] update `es-abstract`, `functions-have-names` [`6a59889`](https://github.com/es-shims/Function.prototype.name/commit/6a598893f013182070479a8cc52afd44e556561f) +- [Deps] update `define-properties`, `es-abstract` [`cd1c5e7`](https://github.com/es-shims/Function.prototype.name/commit/cd1c5e773c3740ec563a26e657d764aba7c35a8c) +- [Deps] update `es-abstract` [`3584585`](https://github.com/es-shims/Function.prototype.name/commit/35845851109f767e3bc84ebef989ca93e5851276) +- [Deps] update `es-abstract` [`0e2f6d9`](https://github.com/es-shims/Function.prototype.name/commit/0e2f6d99d554a8b6b7c835702c8408832f9a2684) +- [Deps] update `es-abstract` [`b11748e`](https://github.com/es-shims/Function.prototype.name/commit/b11748ebbda2d840ac625ae6627cfdb090b94434) +- [Dev Deps] update `tape` [`d787a81`](https://github.com/es-shims/Function.prototype.name/commit/d787a81a1e1ce6d00dda6272e93a43bb193b1286) +- [Deps] update `es-abstract` [`4692639`](https://github.com/es-shims/Function.prototype.name/commit/469263915b07db8342f0aad29ad7eba083bea277) +- [Dev Deps] add `in-publish` [`568e263`](https://github.com/es-shims/Function.prototype.name/commit/568e2635099de326768f40d9e0eacbd024861676) + + +1.1.5 / 2021-10-01 +================= + * [Deps] update `es-abstract` + * [meta] use `prepublishOnly` script for npm 7+ + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `aud`, `tape` + * [actions] update workflows + * [actions] use `node/install` instead of `node/run`; use `codecov` action + +1.1.4 / 2021-02-22 +================= + * [readme] remove travis badge + * [meta] remove audit-level + * [meta] gitignore coverage output + * [meta] do not publish github action workflow files + * [Deps] update `call-bind`, `es-abstract`, `functions-have-names` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-strict-mode`, `tape` + * [Tests] increase coverage + * [actions] update workflows + +1.1.3 / 2020-11-27 +================= + * [Deps] update `es-abstract`, `functions-have-names`; use `call-bind` where applicable + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`, `make-arrow-function`, `make-generator-function`; add `aud`, `make-async-function` + * [actions] add "Allow Edits" workflow + * [actions] switch Automatic Rebase workflow to `pull_request_target` event + * [Tests] migrate tests to Github Actions + * [Tests] run `nyc` on all tests + * [Tests] add `implementation` test; run `es-shim-api` in postlint; use `tape` runner + * [Tests] only audit prod deps + +1.1.2 / 2019-12-14 +================= + * [Refactor] use `es-abstract` + * [Deps] update `functions-have-names` + * [meta] add `funding` field + * [meta] fix repo capitalization + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest` + * [Tests] use shared travis-ci configs + * [actions] add automatic rebasing / merge commit blocking + +1.1.1 / 2019-07-24 +================= + * [Refactor] use `functions-have-names` + * [meta] clean up package.json scripts + * [meta] update links + * [meta] create FUNDING.yml + * [Deps] update `is-callable`, `define-properties` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`, `safe-publish-latest`, `covert` + * [Tests] use `eccheck` over `editorconfig-tools` + * [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops + * [Tests] up to `node` `v11.7`, `v10.15`, `v9.11`, `v8.15`, `v6.16`, `v4.9` + * [Test] remove `jscs` + +1.1.0 / 2017-12-31 +================= + * [New] add `auto` entry point + * [Deps] update `function-bind` + * [Dev Deps] update `uglify-register`, `tape`, `nsp`, `eslint`, `@ljharb/eslint-config`, `@es-shims/api` + * [Tests] up to `node` `v9.3`, `v8.9`, `v6.12`; use `nvm install-latest-npm`; pin included builds to LTS + +1.0.3 / 2017-07-21 +================= + * [Fix] be robust against function name mangling + * [Refactor] move function name detection to separate file + +1.0.2 / 2017-07-14 +================= + * [Refactor] shim: Remove unnecessary `!functionsHaveNames` check + +1.0.1 / 2017-07-11 +================= + * [Fix] in IE 9-11, we must rely on `.call` being available (#13) + * [Fix] ensure that `Function.prototype.name` does not erase the getter + * [Deps] update `is-callable` + * [Dev Deps] add `safe-publish-latest` + * [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `@es-shims/api` + * [Tests] up to `node` `v8.1`; `v7.10`, `v6.11`, `v4.8`; improve matrix; newer npm fails on older nodes + * [Tests] use `Object` to avoid function name inference in node 7 + +1.0.0 / 2016-02-27 +================= + * Initial release. diff --git a/node_modules/function.prototype.name/LICENSE b/node_modules/function.prototype.name/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..44f679ad414f6f5d5b0c510a2ce31dfe811e5d47 --- /dev/null +++ b/node_modules/function.prototype.name/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Jordan Harband + +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. diff --git a/node_modules/function.prototype.name/README.md b/node_modules/function.prototype.name/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d1ce7ce3798541f9d7383f538ea5d012c13ad645 --- /dev/null +++ b/node_modules/function.prototype.name/README.md @@ -0,0 +1,55 @@ +# function.prototype.name [![Version Badge][2]][1] + +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +An ES2015 spec-compliant `Function.prototype.name` shim. Invoke its "shim" method to shim Function.prototype.name if it is unavailable. +*Note*: `Function#name` requires a true ES5 environment - specifically, one with ES5 getters. + +This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES5-supported environment and complies with the [spec](https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags). + +Most common usage: + +## Example + +```js +var functionName = require('function.prototype.name'); +var assert = require('assert'); + +assert.equal(functionName(function foo() {}), 'foo'); + +functionName.shim(); +assert.equal(function foo() {}.name, 'foo'); +``` + +## Supported engines +Automatically tested in every minor version of node. + +Manually tested in: + - Safari: v4 - v15 (4, 5, 5.1, 6.0.5, 6.2, 7.1, 8, 9.1.3, 10.1.2, 11.1.2, 12.1, 13.1.2, 14.1.2, 15.3, 15.6.1) + - Chrome: v15 - v81, v83 - v106(every integer version) + - Note: This includes Edge v80+ and Opera v15+, which matches Chrome + - Firefox: v3, v3.6, v4 - v105 (every integer version) + - Note: in v42 - v63, `Function.prototype.toString` throws on HTML element constructors, or a Proxy to a function + - Note: in v20 - v35, HTML element constructors are not callable, despite having typeof `function` + - IE: v6 - v11(every integer version + - Opera: v11.1, v11.5, v11.6, v12.0, v12.1, v12.14, v12.15, v12.16, v15+ v15+ matches Chrome + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/function.prototype.name +[2]: https://versionbadg.es/es-shims/Function.prototype.name.svg +[5]: https://david-dm.org/es-shims/Function.prototype.name.svg +[6]: https://david-dm.org/es-shims/Function.prototype.name +[7]: https://david-dm.org/es-shims/Function.prototype.name/dev-status.svg +[8]: https://david-dm.org/es-shims/Function.prototype.name#info=devDependencies +[11]: https://nodei.co/npm/function.prototype.name.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/function.prototype.name.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/function.prototype.name.svg +[downloads-url]: https://npm-stat.com/charts.html?package=function.prototype.name diff --git a/node_modules/function.prototype.name/auto.js b/node_modules/function.prototype.name/auto.js new file mode 100644 index 0000000000000000000000000000000000000000..8ebf606cb02ff3a8c6ef786afa37d21a19254f46 --- /dev/null +++ b/node_modules/function.prototype.name/auto.js @@ -0,0 +1,3 @@ +'use strict'; + +require('./shim')(); diff --git a/node_modules/function.prototype.name/helpers/functionsHaveNames.js b/node_modules/function.prototype.name/helpers/functionsHaveNames.js new file mode 100644 index 0000000000000000000000000000000000000000..0aa8532eaeb3bedd408b39ce6efb7462a577f8e6 --- /dev/null +++ b/node_modules/function.prototype.name/helpers/functionsHaveNames.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('functions-have-names')(); + +// TODO: semver-major, remove diff --git a/node_modules/function.prototype.name/implementation.js b/node_modules/function.prototype.name/implementation.js new file mode 100644 index 0000000000000000000000000000000000000000..a43a5988a014009478740f2a553a49d8c63607c3 --- /dev/null +++ b/node_modules/function.prototype.name/implementation.js @@ -0,0 +1,72 @@ +'use strict'; + +var IsCallable = require('es-abstract/2023/IsCallable'); +var HasOwnProperty = require('es-abstract/2023/HasOwnProperty'); +var functionsHaveNames = require('functions-have-names')(); +var callBound = require('call-bind/callBound'); +var $functionToString = callBound('Function.prototype.toString'); +var $stringMatch = callBound('String.prototype.match'); +var toStr = callBound('Object.prototype.toString'); + +var classRegex = /^class /; + +var isClass = function isClassConstructor(fn) { + if (IsCallable(fn)) { + return false; + } + if (typeof fn !== 'function') { + return false; + } + try { + var match = $stringMatch($functionToString(fn), classRegex); + return !!match; + } catch (e) {} + return false; +}; + +var regex = /\s*function\s+([^(\s]*)\s*/; + +var isIE68 = !(0 in [,]); // eslint-disable-line no-sparse-arrays, comma-spacing + +var objectClass = '[object Object]'; +var ddaClass = '[object HTMLAllCollection]'; + +var functionProto = Function.prototype; + +var isDDA = function isDocumentDotAll() { + return false; +}; +if (typeof document === 'object') { + // Firefox 3 canonicalizes DDA to undefined when it's not accessed directly + var all = document.all; + if (toStr(all) === toStr(document.all)) { + isDDA = function isDocumentDotAll(value) { + /* globals document: false */ + // in IE 6-8, typeof document.all is "object" and it's truthy + if ((isIE68 || !value) && (typeof value === 'undefined' || typeof value === 'object')) { + try { + var str = toStr(value); + // IE 6-8 uses `objectClass` + return (str === ddaClass || str === objectClass) && value('') == null; // eslint-disable-line eqeqeq + } catch (e) { /**/ } + } + return false; + }; + } +} + +module.exports = function getName() { + if (isDDA(this) || (!isClass(this) && !IsCallable(this))) { + throw new TypeError('Function.prototype.name sham getter called on non-function'); + } + if (functionsHaveNames && HasOwnProperty(this, 'name')) { + return this.name; + } + if (this === functionProto) { + return ''; + } + var str = $functionToString(this); + var match = $stringMatch(str, regex); + var name = match && match[1]; + return name; +}; diff --git a/node_modules/function.prototype.name/index.js b/node_modules/function.prototype.name/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ee9573a889fa845f06f2cf8a6af8c763fb7f9848 --- /dev/null +++ b/node_modules/function.prototype.name/index.js @@ -0,0 +1,18 @@ +'use strict'; + +var define = require('define-properties'); +var callBind = require('call-bind'); + +var implementation = require('./implementation'); +var getPolyfill = require('./polyfill'); +var shim = require('./shim'); + +var bound = callBind(implementation); + +define(bound, { + getPolyfill: getPolyfill, + implementation: implementation, + shim: shim +}); + +module.exports = bound; diff --git a/node_modules/function.prototype.name/package.json b/node_modules/function.prototype.name/package.json new file mode 100644 index 0000000000000000000000000000000000000000..06f97046512ee9e182fd187e7e178b11b7b70948 --- /dev/null +++ b/node_modules/function.prototype.name/package.json @@ -0,0 +1,99 @@ +{ + "name": "function.prototype.name", + "version": "1.1.6", + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "description": "An ES2015 spec-compliant `Function.prototype.name` shim", + "license": "MIT", + "main": "index.js", + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated", + "prepublish": "not-in-publish || npm run prepublishOnly", + "prepublishOnly": "safe-publish-latest", + "pretest": "npm run lint", + "test": "npm run --silent tests-only", + "posttest": "aud --production", + "tests-only": "nyc tape 'test/**/*.js'", + "prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')", + "lint": "eslint --ext=js,mjs .", + "postlint": "es-shim-api --bound", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git://github.com/es-shims/Function.prototype.name.git" + }, + "keywords": [ + "Function.prototype.name", + "function", + "name", + "ES6", + "ES2015", + "shim", + "polyfill", + "es-shim API" + ], + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "functions-have-names": "^1.2.3" + }, + "devDependencies": { + "@es-shims/api": "^2.4.2", + "@ljharb/eslint-config": "^21.1.0", + "aud": "^2.0.3", + "auto-changelog": "^2.4.0", + "eclint": "^2.8.1", + "eslint": "=8.8.0", + "for-each": "^0.3.3", + "has-strict-mode": "^1.0.1", + "in-publish": "^2.0.1", + "make-arrow-function": "^1.2.0", + "make-async-function": "^1.0.0", + "make-generator-function": "^2.0.0", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "safe-publish-latest": "^2.0.0", + "tape": "^5.6.6", + "uglify-register": "^1.0.1" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/9.0..latest", + "firefox/4.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/11.6..latest", + "opera/next", + "safari/5.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true, + "startingVersion": "v1.1.6" + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] + } +} diff --git a/node_modules/function.prototype.name/polyfill.js b/node_modules/function.prototype.name/polyfill.js new file mode 100644 index 0000000000000000000000000000000000000000..382fb9b6a45f316dedaef6d020645616b6becded --- /dev/null +++ b/node_modules/function.prototype.name/polyfill.js @@ -0,0 +1,7 @@ +'use strict'; + +var implementation = require('./implementation'); + +module.exports = function getPolyfill() { + return implementation; +}; diff --git a/node_modules/function.prototype.name/shim.js b/node_modules/function.prototype.name/shim.js new file mode 100644 index 0000000000000000000000000000000000000000..587e3e94ccc8284ffc1da6edf7748f31d9218b7e --- /dev/null +++ b/node_modules/function.prototype.name/shim.js @@ -0,0 +1,35 @@ +'use strict'; + +var supportsDescriptors = require('define-properties').supportsDescriptors; +var functionsHaveNames = require('functions-have-names')(); +var getPolyfill = require('./polyfill'); +var defineProperty = Object.defineProperty; +var TypeErr = TypeError; + +module.exports = function shimName() { + var polyfill = getPolyfill(); + if (functionsHaveNames) { + return polyfill; + } + if (!supportsDescriptors) { + throw new TypeErr('Shimming Function.prototype.name support requires ES5 property descriptor support.'); + } + var functionProto = Function.prototype; + defineProperty(functionProto, 'name', { + configurable: true, + enumerable: false, + get: function () { + var name = polyfill.call(this); + if (this !== functionProto) { + defineProperty(this, 'name', { + configurable: true, + enumerable: false, + value: name, + writable: false + }); + } + return name; + } + }); + return polyfill; +}; diff --git a/node_modules/function.prototype.name/test/implementation.js b/node_modules/function.prototype.name/test/implementation.js new file mode 100644 index 0000000000000000000000000000000000000000..7fdf95b7da1a541ef76ccf4f576a323b2c97097b --- /dev/null +++ b/node_modules/function.prototype.name/test/implementation.js @@ -0,0 +1,20 @@ +'use strict'; + +var implementation = require('../implementation'); +var callBind = require('call-bind'); +var test = require('tape'); +var hasStrictMode = require('has-strict-mode')(); +var runTests = require('./tests'); + +test('as a function', function (t) { + t.test('bad array/this value', { skip: !hasStrictMode }, function (st) { + /* eslint no-useless-call: 0 */ + st['throws'](function () { implementation.call(undefined); }, TypeError, 'undefined is not an object'); + st['throws'](function () { implementation.call(null); }, TypeError, 'null is not an object'); + st.end(); + }); + + runTests(callBind(implementation), t); + + t.end(); +}); diff --git a/node_modules/function.prototype.name/test/index.js b/node_modules/function.prototype.name/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..68e33af686db38674f7a30d86f991e6436c42cfa --- /dev/null +++ b/node_modules/function.prototype.name/test/index.js @@ -0,0 +1,23 @@ +'use strict'; + +var getName = require('../'); +var test = require('tape'); +var runTests = require('./tests'); + +test('as a function', function (t) { + t.test('non-functions', function (st) { + st['throws'](function () { getName(); }, TypeError, 'undefined is not a function'); + st['throws'](function () { getName(null); }, TypeError, 'null is not a function'); + st['throws'](function () { getName(true); }, TypeError, 'true is not a function'); + st['throws'](function () { getName(false); }, TypeError, 'false is not a function'); + st['throws'](function () { getName('foo'); }, TypeError, '"foo" is not a function'); + st['throws'](function () { getName([]); }, TypeError, '[] is not a function'); + st['throws'](function () { getName({}); }, TypeError, '{} is not a function'); + st['throws'](function () { getName(/a/g); }, TypeError, '/a/g is not a function'); + st.end(); + }); + + runTests(getName, t); + + t.end(); +}); diff --git a/node_modules/function.prototype.name/test/shimmed.js b/node_modules/function.prototype.name/test/shimmed.js new file mode 100644 index 0000000000000000000000000000000000000000..c2ed13a3df2ff04a5640192abf006bf6450bfcee --- /dev/null +++ b/node_modules/function.prototype.name/test/shimmed.js @@ -0,0 +1,21 @@ +'use strict'; + +require('../auto'); + +var test = require('tape'); +var supportsDescriptors = require('define-properties').supportsDescriptors; +var isEnumerable = Object.prototype.propertyIsEnumerable; + +var runTests = require('./tests'); + +test('shimmed', function (t) { + t.test('enumerability', { skip: !supportsDescriptors }, function (et) { + et.equal(false, isEnumerable.call(Function.prototype, 'name'), 'Function#name is not enumerable'); + et.equal(false, isEnumerable.call(function foo() {}, 'name'), 'a function’s name is not enumerable'); + et.end(); + }); + + runTests(function (fn) { return fn.name; }, t); + + t.end(); +}); diff --git a/node_modules/function.prototype.name/test/tests.js b/node_modules/function.prototype.name/test/tests.js new file mode 100644 index 0000000000000000000000000000000000000000..81761a697272569326a4c098ed35c5f81caedf04 --- /dev/null +++ b/node_modules/function.prototype.name/test/tests.js @@ -0,0 +1,104 @@ +'use strict'; + +var functionsHaveNames = require('functions-have-names')(); +var arrows = require('make-arrow-function').list(); +var generators = require('make-generator-function')(); +var asyncs = require('make-async-function').list(); +var IsCallable = require('es-abstract/2023/IsCallable'); +var forEach = require('for-each'); + +var foo = Object(function foo() {}); +var anon = Object(function () {}); +var evalled = Object(Function()); // eslint-disable-line no-new-func + +module.exports = function (getName, t) { + t.test('functions', function (st) { + if (functionsHaveNames) { + st.equal(getName(foo), foo.name, 'foo has name "foo"'); + st.equal(getName(anon), anon.name, 'anonymous function has name of empty string'); + st.equal(getName(evalled), evalled.name, 'eval-d function has name "anonymous" (or empty string)'); + } + st.equal(getName(foo), 'foo', 'foo has name "foo"'); + st.equal(getName(anon), '', 'anonymous function has name of empty string'); + var evalledName = getName(evalled); + st.equal(evalledName === 'anonymous' || evalledName === '', true, 'eval-d function has name "anonymous" (or empty string'); + st.end(); + }); + + t.test('arrow functions', { skip: arrows.length === 0 }, function (st) { + st.equal(true, functionsHaveNames, 'functions have names in any env with arrow functions'); + forEach(arrows, function (arrowFn) { + st.equal(getName(arrowFn), arrowFn.name, 'arrow function name matches for ' + arrowFn); + }); + st.end(); + }); + + t.test('generators', { skip: generators.length === 0 }, function (st) { + st.equal(true, functionsHaveNames, 'functions have names in any env with generator functions'); + forEach(generators, function (genFn) { + st.equal(getName(genFn), genFn.name, 'generator function name matches for ' + genFn); + }); + st.end(); + }); + + t.test('asyncs', { skip: asyncs.length === 0 }, function (st) { + st.equal(true, functionsHaveNames, 'functions have names in any env with async functions'); + forEach(asyncs, function (asyncFn) { + st.equal(getName(asyncFn), asyncFn.name, 'async function name matches for ' + asyncFn); + }); + st.end(); + }); + + t.test('Function.prototype.name', function (st) { + st.equal(getName(function before() {}), 'before', 'function prior to accessing Function.prototype has the right name'); + var protoName = getName(Function.prototype); + // on <= node v2.5, this is "Empty"; on Opera 12.1, "Function.prototype" - otherwise, the empty string + st.equal(protoName === '' || protoName === 'Empty' || protoName === 'Function.prototype', true, 'Function.prototype has the right name'); + st.equal(getName(function after() {}), 'after', 'function after accessing Function.prototype has the right name'); + + st.end(); + }); + + t.test('DOM', function (st) { + /* eslint-env browser */ + + st.test('document.all', { skip: typeof document !== 'object' }, function (s2t) { + s2t['throws']( + function () { getName(document.all); }, + TypeError, + 'a document.all has no name' + ); + + s2t.end(); + }); + + forEach([ + 'HTMLElement', + 'HTMLAnchorElement' + ], function (name) { + var constructor = global[name]; + + st.test(name, { skip: !constructor }, function (s2t) { + s2t.match(typeof constructor, /^(?:function|object)$/, name + ' is a function or an object'); + + if (IsCallable(constructor)) { + try { + s2t.equal(getName(constructor), name, name + ' has the right name'); + } catch (e) { + s2t.fail(e); + } + } else { + s2t['throws']( + function () { getName(constructor); }, + TypeError, + name + ' is not callable' + ); + } + + s2t.end(); + }); + }); + + st.end(); + }); +}; diff --git a/node_modules/function.prototype.name/test/uglified.js b/node_modules/function.prototype.name/test/uglified.js new file mode 100644 index 0000000000000000000000000000000000000000..77733abd85d034121f65b477a02b39647c62b479 --- /dev/null +++ b/node_modules/function.prototype.name/test/uglified.js @@ -0,0 +1,17 @@ +'use strict'; + +var test = require('tape'); +var runTests = require('./tests'); + +test('with uglify', function (t) { + /* eslint global-require: 0 */ + require('uglify-register/api').register({ + exclude: [/\/node_modules\//, /\/test\//], + uglify: { mangle: true } + }); + + var getName = require('../'); + runTests(getName, t); + + t.end(); +}); diff --git a/node_modules/functions-have-names/.editorconfig b/node_modules/functions-have-names/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..bc228f8269443bf772b437890dde7756a3e8a894 --- /dev/null +++ b/node_modules/functions-have-names/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 150 + +[CHANGELOG.md] +indent_style = space +indent_size = 2 + +[*.json] +max_line_length = off + +[Makefile] +max_line_length = off diff --git a/node_modules/functions-have-names/.eslintrc b/node_modules/functions-have-names/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..2807df70cb18de3075f1e15022b5bd38c8ff175e --- /dev/null +++ b/node_modules/functions-have-names/.eslintrc @@ -0,0 +1,19 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "func-name-matching": [2, "always"], + "id-length": 1, + }, + + "overrides": [ + { + "files": "test/**", + "rules": { + "func-name-matching": 0, + }, + }, + ], +} diff --git a/node_modules/functions-have-names/.github/FUNDING.yml b/node_modules/functions-have-names/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..1b81d18bc0ae25b735729ca3f5cbbb3ed23a574a --- /dev/null +++ b/node_modules/functions-have-names/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/functions-have-names +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/functions-have-names/.nycrc b/node_modules/functions-have-names/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/functions-have-names/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/functions-have-names/CHANGELOG.md b/node_modules/functions-have-names/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..1026b701d7865bc75a2869f9d543ccd926792712 --- /dev/null +++ b/node_modules/functions-have-names/CHANGELOG.md @@ -0,0 +1,89 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.2.3](https://github.com/inspect-js/functions-have-names/compare/v1.2.2...v1.2.3) - 2022-04-19 + +### Fixed + +- [Fix] in IE 9-11, the descriptor is absent [`#11`](https://github.com/inspect-js/functions-have-names/issues/11) [`#25`](https://github.com/es-shims/RegExp.prototype.flags/issues/25) + +### Commits + +- [actions] reuse common workflows [`4ed274a`](https://github.com/inspect-js/functions-have-names/commit/4ed274a2441c7fd38ff6add741c309e268550d97) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`96dfcaa`](https://github.com/inspect-js/functions-have-names/commit/96dfcaaf1c9c5305f2b66ef69f9cddf1d9d9a578) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`9e674f8`](https://github.com/inspect-js/functions-have-names/commit/9e674f85520a93235e412a3fd7671d2356c6e45b) +- [readme] add github actions/codecov badges; update URLs [`d913f5b`](https://github.com/inspect-js/functions-have-names/commit/d913f5bf38ccab32d5fbea4a044b9cd93a4b9bec) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `safe-publish-latest`, `tape` [`f61058f`](https://github.com/inspect-js/functions-have-names/commit/f61058fe1e34f2cfa9235283a4fc6c0c0172c91a) +- [actions] update codecov uploader [`3348839`](https://github.com/inspect-js/functions-have-names/commit/33488394e7cadbf499bee4775c627c1370d033d0) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `tape` [`ee1a321`](https://github.com/inspect-js/functions-have-names/commit/ee1a3211a40902af59aa629e3ac41ec36360dc1b) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`b8dc1a2`](https://github.com/inspect-js/functions-have-names/commit/b8dc1a277b08362bebedfeba2faca8964f68283b) +- [Dev Deps] update `@ljharb/eslint-config`, `tape` [`0e825c4`](https://github.com/inspect-js/functions-have-names/commit/0e825c4ba8525b02d9acaaf2511371f76c0562ce) +- [meta] use `prepublishOnly` script for npm 7+ [`9489d66`](https://github.com/inspect-js/functions-have-names/commit/9489d666c59702ea6bafd3ff611b3eadfee6570e) + +## [v1.2.2](https://github.com/inspect-js/functions-have-names/compare/v1.2.1...v1.2.2) - 2020-12-14 + +### Commits + +- [Tests] migrate tests to Github Actions [`39bf4fe`](https://github.com/inspect-js/functions-have-names/commit/39bf4fe5ae5b3610a80ba13726f3ee00e3c49e2f) +- [meta] do not publish github action workflow files [`45ab0cb`](https://github.com/inspect-js/functions-have-names/commit/45ab0cbdc0da2efd64f5deb9810be63009bac4a0) +- [readme] add docs, fix URLs [`fad3af6`](https://github.com/inspect-js/functions-have-names/commit/fad3af61e9cbc27f47d2097614f43c62ae1022dd) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`82df94a`](https://github.com/inspect-js/functions-have-names/commit/82df94ae06f05a5fa321dda9b7d902ac9fc26424) +- [Tests] run `nyc` on all tests; use `tape` runner [`8038329`](https://github.com/inspect-js/functions-have-names/commit/8038329fec493043639d9d8c779141dcb7d00c2d) +- [actions] add automatic rebasing / merge commit blocking [`49795eb`](https://github.com/inspect-js/functions-have-names/commit/49795ebf38ae3ba724ff7ac5c53598ec66ab814b) +- [actions] add "Allow Edits" workflow [`2096fe6`](https://github.com/inspect-js/functions-have-names/commit/2096fe6d67d435c0e0da25f3cfe9ff02991c41e6) +- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`ec1c6fe`](https://github.com/inspect-js/functions-have-names/commit/ec1c6fe209419c722d732cd512e4375c48366392) +- [Dev Deps] update `auto-changelog`; add `aud` [`79fdb23`](https://github.com/inspect-js/functions-have-names/commit/79fdb23d1ed2b4125f443be193c37330e634e654) +- [Tests] only audit prod deps [`d9ca245`](https://github.com/inspect-js/functions-have-names/commit/d9ca2455e26a45994024d1027344c268a06818bd) +- [Dev Deps] update `auto-changelog`, `tape` [`ac026d4`](https://github.com/inspect-js/functions-have-names/commit/ac026d4bda77e9820b74456fc752d2069e5b8a7f) +- [Dev Deps] update `tape` [`a8c5ee3`](https://github.com/inspect-js/functions-have-names/commit/a8c5ee3622b487938462f82698dae3ceb32da1a7) +- [Dev Deps] update `@ljharb/eslint-config` [`b25fafd`](https://github.com/inspect-js/functions-have-names/commit/b25fafd0923dcf53c3aeca92268e497ffd96ec34) + +## [v1.2.1](https://github.com/inspect-js/functions-have-names/compare/v1.2.0...v1.2.1) - 2020-01-19 + +### Commits + +- [Tests] use shared travis-ci configs [`612823a`](https://github.com/inspect-js/functions-have-names/commit/612823a064b4be4c61a1e52d1009abed4a4fc4fb) +- [Fix] IE 8 has a broken `Object.getOwnPropertyDescriptor` [`ba01c22`](https://github.com/inspect-js/functions-have-names/commit/ba01c22795162b787a698950ea34250ce68a7bb1) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`; add `safe-publish-latest` [`b28d9d2`](https://github.com/inspect-js/functions-have-names/commit/b28d9d2e8bc0b758671bcaf2f7aa0d4ad4b42046) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`a62fbd6`](https://github.com/inspect-js/functions-have-names/commit/a62fbd69a34a2b1d1860acfa2afc6dcc839bc180) +- [meta] add `funding` field [`8734a94`](https://github.com/inspect-js/functions-have-names/commit/8734a940e39acdf7619eb89e358746bd278b4c90) + +## [v1.2.0](https://github.com/inspect-js/functions-have-names/compare/v1.1.1...v1.2.0) - 2019-10-20 + +### Commits + +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog` [`7e07444`](https://github.com/inspect-js/functions-have-names/commit/7e0744437789641ea462005d2e350ef476aa7141) +- [New] add `boundFunctionsHaveNames()` [`05661be`](https://github.com/inspect-js/functions-have-names/commit/05661be26c3c260bb3984e433dc9cea3fd82f9ac) + +## [v1.1.1](https://github.com/inspect-js/functions-have-names/compare/v1.1.0...v1.1.1) - 2019-07-24 + +### Commits + +- [Tests] fix linting errors [`0cb8017`](https://github.com/inspect-js/functions-have-names/commit/0cb8017203ae37d1e019bb1c99120f3f56a266a5) +- [Tests] fix tests when name is not configurable [`38a8aee`](https://github.com/inspect-js/functions-have-names/commit/38a8aeee0403bd7aa7f35da76dc433cbcdd3f85a) +- [Fix] ensure function name mangling does not break detection [`f6926ab`](https://github.com/inspect-js/functions-have-names/commit/f6926abaaebc81366f73cf0c3f874ad7e4ba16d2) + +## [v1.1.0](https://github.com/inspect-js/functions-have-names/compare/v1.0.0...v1.1.0) - 2019-07-23 + +### Commits + +- [New] add `functionsHaveConfigurableNames` function on main export [`ce73f75`](https://github.com/inspect-js/functions-have-names/commit/ce73f75891640a462326df7266d90b09519a5fca) + +## v1.0.0 - 2019-07-22 + +### Commits + +- [Tests] add travis.yml [`06ed096`](https://github.com/inspect-js/functions-have-names/commit/06ed09681a3dc067094562e8d21a31400a782add) +- Initial commit [`ced60bd`](https://github.com/inspect-js/functions-have-names/commit/ced60bd089539eb228c68fc2ad7c7bc04b959b02) +- npm init [`79088ab`](https://github.com/inspect-js/functions-have-names/commit/79088ab607e7e91a402e198ab6d1837a317c6fa9) +- add tests [`c9e8e09`](https://github.com/inspect-js/functions-have-names/commit/c9e8e09c5153797c97c324cca4b837540eddeff8) +- [Tests] add `npm run lint` [`988b924`](https://github.com/inspect-js/functions-have-names/commit/988b924a8a49ea5c0f30d5aa2b2ea9add0b39474) +- [meta] create FUNDING.yml [`2e443ef`](https://github.com/inspect-js/functions-have-names/commit/2e443ef67748214d05898b3da76f908a7e2d7488) +- [meta] add version scripts [`52005e3`](https://github.com/inspect-js/functions-have-names/commit/52005e3794fd0799db5963a5359846798cb95c14) +- implementation [`b7b4942`](https://github.com/inspect-js/functions-have-names/commit/b7b49421ef69fb5e042194a650cb4f71bb4996e4) +- Only apps should have lockfiles [`81d2e04`](https://github.com/inspect-js/functions-have-names/commit/81d2e04e7a43cbff2e46e72781bb0693dbb67800) +- [Tests] use `npx aud` [`baa92d8`](https://github.com/inspect-js/functions-have-names/commit/baa92d8aba331fe8821663bc14baf2e11685474a) diff --git a/node_modules/functions-have-names/LICENSE b/node_modules/functions-have-names/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..3900dd7e2ffe6d5205fde1cd3f890aa51ea36234 --- /dev/null +++ b/node_modules/functions-have-names/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Jordan Harband + +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. diff --git a/node_modules/functions-have-names/README.md b/node_modules/functions-have-names/README.md new file mode 100644 index 0000000000000000000000000000000000000000..70962607cd607096143845a1aaf636aa8a90c484 --- /dev/null +++ b/node_modules/functions-have-names/README.md @@ -0,0 +1,40 @@ +# functions-have-names [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Does this JS environment support the `name` property on functions? + +## Example + +```js +var functionsHaveNames = require('functions-have-names'); +var assert = require('assert'); + +assert.equal(functionsHaveNames(), true); // will be `false` in IE 6-8 +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/functions-have-names +[npm-version-svg]: https://versionbadg.es/inspect-js/functions-have-names.svg +[deps-svg]: https://david-dm.org/inspect-js/functions-have-names.svg +[deps-url]: https://david-dm.org/inspect-js/functions-have-names +[dev-deps-svg]: https://david-dm.org/inspect-js/functions-have-names/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/functions-have-names#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/functions-have-names.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/functions-have-names.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/functions-have-names.svg +[downloads-url]: https://npm-stat.com/charts.html?package=functions-have-names +[codecov-image]: https://codecov.io/gh/inspect-js/functions-have-names/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/functions-have-names/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/functions-have-names +[actions-url]: https://github.com/inspect-js/functions-have-names/actions diff --git a/node_modules/functions-have-names/index.js b/node_modules/functions-have-names/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9d699dc190ed16b7ee94ca532fa4805eb602505e --- /dev/null +++ b/node_modules/functions-have-names/index.js @@ -0,0 +1,31 @@ +'use strict'; + +var functionsHaveNames = function functionsHaveNames() { + return typeof function f() {}.name === 'string'; +}; + +var gOPD = Object.getOwnPropertyDescriptor; +if (gOPD) { + try { + gOPD([], 'length'); + } catch (e) { + // IE 8 has a broken gOPD + gOPD = null; + } +} + +functionsHaveNames.functionsHaveConfigurableNames = function functionsHaveConfigurableNames() { + if (!functionsHaveNames() || !gOPD) { + return false; + } + var desc = gOPD(function () {}, 'name'); + return !!desc && !!desc.configurable; +}; + +var $bind = Function.prototype.bind; + +functionsHaveNames.boundFunctionsHaveNames = function boundFunctionsHaveNames() { + return functionsHaveNames() && typeof $bind === 'function' && function f() {}.bind().name !== ''; +}; + +module.exports = functionsHaveNames; diff --git a/node_modules/functions-have-names/package.json b/node_modules/functions-have-names/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3a513cb3e6cc0535500ed9ee2f281a4b552b7854 --- /dev/null +++ b/node_modules/functions-have-names/package.json @@ -0,0 +1,55 @@ +{ + "name": "functions-have-names", + "version": "1.2.3", + "description": "Does this JS environment support the `name` property on functions?", + "main": "index.js", + "scripts": { + "prepublish": "not-in-publish || npm run prepublishOnly", + "prepublishOnly": "safe-publish-latest", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"", + "lint": "eslint --ext=js,mjs .", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/inspect-js/functions-have-names.git" + }, + "keywords": [ + "function", + "name", + "es5", + "names", + "functions", + "ie" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/functions-have-names/issues" + }, + "homepage": "https://github.com/inspect-js/functions-have-names#readme", + "devDependencies": { + "@ljharb/eslint-config": "^21.0.0", + "aud": "^2.0.0", + "auto-changelog": "^2.4.0", + "eslint": "=8.8.0", + "nyc": "^10.3.2", + "safe-publish-latest": "^2.0.0", + "tape": "^5.5.3" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + } +} diff --git a/node_modules/functions-have-names/test/index.js b/node_modules/functions-have-names/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0d451ce62b6ed51787a3ae7048f91b9f46b13ec7 --- /dev/null +++ b/node_modules/functions-have-names/test/index.js @@ -0,0 +1,65 @@ +'use strict'; + +var test = require('tape'); + +var hasNames = require('../'); + +test('named functions', function (t) { + function f() {} // eslint-disable-line func-style + var g = function h() {}; + + t.equal(typeof hasNames, 'function', 'is a function'); + t.equal(hasNames(), f.name === 'f' && g.name === 'h', 'functions have names or not as expected'); + + t.end(); +}); + +var oDP = Object.defineProperty; +if (oDP) { + try { + oDP({}, 'a', { value: 1 }); + } catch (e) { + oDP = null; + } +} + +test('functionsHaveConfigurableNames', function (t) { + t.equal(typeof hasNames.functionsHaveConfigurableNames, 'function', 'is a function'); + + if (hasNames()) { + var fn = function f() {}; + if (oDP) { + try { + oDP(fn, 'name', { configurable: true, value: 'foo' }); + } catch (e) {} + if (fn.name === 'f') { + t.equal(hasNames.functionsHaveConfigurableNames(), false, 'function names are not configurable'); + } else if (fn.name === 'foo') { + t.equal(hasNames.functionsHaveConfigurableNames(), true, 'function names are not configurable'); + } else { + t.fail('functions have names, but something surprising has happened. Please report this!'); + } + } else { + t.equal(hasNames.functionsHaveConfigurableNames(), false, 'function names are not configurable'); + } + } else { + t.equal(hasNames.functionsHaveConfigurableNames(), false, 'functions do not have names'); + } + + t.end(); +}); + +test('boundFunctionsHaveNames', function (t) { + t.equal(typeof hasNames.boundFunctionsHaveNames, 'function', 'is a function'); + + var fn = function f() {}; + if (typeof fn.bind !== 'function') { + t.equal(hasNames.boundFunctionsHaveNames(), false, 'bound functions do not have names, because .bind does not exist'); + } else if (hasNames()) { + t.equal(hasNames.boundFunctionsHaveNames(), fn.bind().name !== '', 'bound functions have names'); + } else { + t.equal(hasNames.boundFunctionsHaveNames(), false, 'bound functions do not have names, because none do'); + } + + t.end(); +}); diff --git a/node_modules/get-intrinsic/.eslintrc b/node_modules/get-intrinsic/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..8376636235836c26c93bb23afd5fdf74c0cb67af --- /dev/null +++ b/node_modules/get-intrinsic/.eslintrc @@ -0,0 +1,38 @@ +{ + "root": true, + + "extends": "@ljharb", + + "env": { + "es6": true, + "es2017": true, + "es2020": true, + "es2021": true, + "es2022": true, + }, + + "rules": { + "array-bracket-newline": 0, + "complexity": 0, + "eqeqeq": [2, "allow-null"], + "func-name-matching": 0, + "id-length": 0, + "max-lines": 0, + "max-lines-per-function": [2, 90], + "max-params": [2, 4], + "max-statements": 0, + "max-statements-per-line": [2, { "max": 2 }], + "multiline-comment-style": 0, + "no-magic-numbers": 0, + "sort-keys": 0, + }, + + "overrides": [ + { + "files": "test/**", + "rules": { + "new-cap": 0, + }, + }, + ], +} diff --git a/node_modules/get-intrinsic/.github/FUNDING.yml b/node_modules/get-intrinsic/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..8e8da0dda153deb6bf1bfbb2c1a7e5e19aea08c5 --- /dev/null +++ b/node_modules/get-intrinsic/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/get-intrinsic +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/get-intrinsic/.nycrc b/node_modules/get-intrinsic/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/get-intrinsic/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/get-intrinsic/CHANGELOG.md b/node_modules/get-intrinsic/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..870b590ce797257fdbbe20f33704ceec0e87bc7d --- /dev/null +++ b/node_modules/get-intrinsic/CHANGELOG.md @@ -0,0 +1,125 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.2.2](https://github.com/ljharb/get-intrinsic/compare/v1.2.1...v1.2.2) - 2023-10-20 + +### Commits + +- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `call-bind`, `es-abstract`, `mock-property`, `object-inspect`, `tape` [`f51bcf2`](https://github.com/ljharb/get-intrinsic/commit/f51bcf26412d58d17ce17c91c9afd0ad271f0762) +- [Refactor] use `hasown` instead of `has` [`18d14b7`](https://github.com/ljharb/get-intrinsic/commit/18d14b799bea6b5765e1cec91890830cbcdb0587) +- [Deps] update `function-bind` [`6e109c8`](https://github.com/ljharb/get-intrinsic/commit/6e109c81e03804cc5e7824fb64353cdc3d8ee2c7) + +## [v1.2.1](https://github.com/ljharb/get-intrinsic/compare/v1.2.0...v1.2.1) - 2023-05-13 + +### Commits + +- [Fix] avoid a crash in envs without `__proto__` [`7bad8d0`](https://github.com/ljharb/get-intrinsic/commit/7bad8d061bf8721733b58b73a2565af2b6756b64) +- [Dev Deps] update `es-abstract` [`c60e6b7`](https://github.com/ljharb/get-intrinsic/commit/c60e6b7b4cf9660c7f27ed970970fd55fac48dc5) + +## [v1.2.0](https://github.com/ljharb/get-intrinsic/compare/v1.1.3...v1.2.0) - 2023-01-19 + +### Commits + +- [actions] update checkout action [`ca6b12f`](https://github.com/ljharb/get-intrinsic/commit/ca6b12f31eaacea4ea3b055e744cd61623385ffb) +- [Dev Deps] update `@ljharb/eslint-config`, `es-abstract`, `object-inspect`, `tape` [`41a3727`](https://github.com/ljharb/get-intrinsic/commit/41a3727d0026fa04273ae216a5f8e12eefd72da8) +- [Fix] ensure `Error.prototype` is undeniable [`c511e97`](https://github.com/ljharb/get-intrinsic/commit/c511e97ae99c764c4524b540dee7a70757af8da3) +- [Dev Deps] update `aud`, `es-abstract`, `tape` [`1bef8a8`](https://github.com/ljharb/get-intrinsic/commit/1bef8a8fd439ebb80863199b6189199e0851ac67) +- [Dev Deps] update `aud`, `es-abstract` [`0d41f16`](https://github.com/ljharb/get-intrinsic/commit/0d41f16bcd500bc28b7bfc98043ebf61ea081c26) +- [New] add `BigInt64Array` and `BigUint64Array` [`a6cca25`](https://github.com/ljharb/get-intrinsic/commit/a6cca25f29635889b7e9bd669baf9e04be90e48c) +- [Tests] use `gopd` [`ecf7722`](https://github.com/ljharb/get-intrinsic/commit/ecf7722240d15cfd16edda06acf63359c10fb9bd) + +## [v1.1.3](https://github.com/ljharb/get-intrinsic/compare/v1.1.2...v1.1.3) - 2022-09-12 + +### Commits + +- [Dev Deps] update `es-abstract`, `es-value-fixtures`, `tape` [`07ff291`](https://github.com/ljharb/get-intrinsic/commit/07ff291816406ebe5a12d7f16965bde0942dd688) +- [Fix] properly check for % signs [`50ac176`](https://github.com/ljharb/get-intrinsic/commit/50ac1760fe99c227e64eabde76e9c0e44cd881b5) + +## [v1.1.2](https://github.com/ljharb/get-intrinsic/compare/v1.1.1...v1.1.2) - 2022-06-08 + +### Fixed + +- [Fix] properly validate against extra % signs [`#16`](https://github.com/ljharb/get-intrinsic/issues/16) + +### Commits + +- [actions] reuse common workflows [`0972547`](https://github.com/ljharb/get-intrinsic/commit/0972547efd0abc863fe4c445a6ca7eb4f8c6901d) +- [meta] use `npmignore` to autogenerate an npmignore file [`5ba0b51`](https://github.com/ljharb/get-intrinsic/commit/5ba0b51d8d8d4f1c31d426d74abc0770fd106bad) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`c364492`](https://github.com/ljharb/get-intrinsic/commit/c364492af4af51333e6f81c0bf21fd3d602c3661) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `es-abstract`, `object-inspect`, `tape` [`dc04dad`](https://github.com/ljharb/get-intrinsic/commit/dc04dad86f6e5608775a2640cb0db5927ae29ed9) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `es-abstract`, `object-inspect`, `safe-publish-latest`, `tape` [`1c14059`](https://github.com/ljharb/get-intrinsic/commit/1c1405984e86dd2dc9366c15d8a0294a96a146a5) +- [Tests] use `mock-property` [`b396ef0`](https://github.com/ljharb/get-intrinsic/commit/b396ef05bb73b1d699811abd64b0d9b97997fdda) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`c2c758d`](https://github.com/ljharb/get-intrinsic/commit/c2c758d3b90af4fef0a76910d8d3c292ec8d1d3e) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `es-abstract`, `es-value-fixtures`, `object-inspect`, `tape` [`29e3c09`](https://github.com/ljharb/get-intrinsic/commit/29e3c091c2bf3e17099969847e8729d0e46896de) +- [actions] update codecov uploader [`8cbc141`](https://github.com/ljharb/get-intrinsic/commit/8cbc1418940d7a8941f3a7985cbc4ac095c5e13d) +- [Dev Deps] update `@ljharb/eslint-config`, `es-abstract`, `es-value-fixtures`, `object-inspect`, `tape` [`10b6f5c`](https://github.com/ljharb/get-intrinsic/commit/10b6f5c02593fb3680c581d696ac124e30652932) +- [readme] add github actions/codecov badges [`4e25400`](https://github.com/ljharb/get-intrinsic/commit/4e25400d9f51ae9eb059cbe22d9144e70ea214e8) +- [Tests] use `for-each` instead of `foreach` [`c05b957`](https://github.com/ljharb/get-intrinsic/commit/c05b957ad9a7bc7721af7cc9e9be1edbfe057496) +- [Dev Deps] update `es-abstract` [`29b05ae`](https://github.com/ljharb/get-intrinsic/commit/29b05aec3e7330e9ad0b8e0f685a9112c20cdd97) +- [meta] use `prepublishOnly` script for npm 7+ [`95c285d`](https://github.com/ljharb/get-intrinsic/commit/95c285da810516057d3bbfa871176031af38f05d) +- [Deps] update `has-symbols` [`593cb4f`](https://github.com/ljharb/get-intrinsic/commit/593cb4fb38e7922e40e42c183f45274b636424cd) +- [readme] fix repo URLs [`1c8305b`](https://github.com/ljharb/get-intrinsic/commit/1c8305b5365827c9b6fc785434aac0e1328ff2f5) +- [Deps] update `has-symbols` [`c7138b6`](https://github.com/ljharb/get-intrinsic/commit/c7138b6c6d73132d859471fb8c13304e1e7c8b20) +- [Dev Deps] remove unused `has-bigints` [`bd63aff`](https://github.com/ljharb/get-intrinsic/commit/bd63aff6ad8f3a986c557fcda2914187bdaab359) + +## [v1.1.1](https://github.com/ljharb/get-intrinsic/compare/v1.1.0...v1.1.1) - 2021-02-03 + +### Fixed + +- [meta] export `./package.json` [`#9`](https://github.com/ljharb/get-intrinsic/issues/9) + +### Commits + +- [readme] flesh out the readme; use `evalmd` [`d12f12c`](https://github.com/ljharb/get-intrinsic/commit/d12f12c15345a0a0772cc65a7c64369529abd614) +- [eslint] set up proper globals config [`5a8c098`](https://github.com/ljharb/get-intrinsic/commit/5a8c0984e3319d1ac0e64b102f8ec18b64e79f36) +- [Dev Deps] update `eslint` [`7b9a5c0`](https://github.com/ljharb/get-intrinsic/commit/7b9a5c0d31a90ca1a1234181c74988fb046701cd) + +## [v1.1.0](https://github.com/ljharb/get-intrinsic/compare/v1.0.2...v1.1.0) - 2021-01-25 + +### Fixed + +- [Refactor] delay `Function` eval until syntax-derived values are requested [`#3`](https://github.com/ljharb/get-intrinsic/issues/3) + +### Commits + +- [Tests] migrate tests to Github Actions [`2ab762b`](https://github.com/ljharb/get-intrinsic/commit/2ab762b48164aea8af37a40ba105bbc8246ab8c4) +- [meta] do not publish github action workflow files [`5e7108e`](https://github.com/ljharb/get-intrinsic/commit/5e7108e4768b244d48d9567ba4f8a6cab9c65b8e) +- [Tests] add some coverage [`01ac7a8`](https://github.com/ljharb/get-intrinsic/commit/01ac7a87ac29738567e8524cd8c9e026b1fa8cb3) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `call-bind`, `es-abstract`, `tape`; add `call-bind` [`911b672`](https://github.com/ljharb/get-intrinsic/commit/911b672fbffae433a96924c6ce013585e425f4b7) +- [Refactor] rearrange evalled constructors a bit [`7e7e4bf`](https://github.com/ljharb/get-intrinsic/commit/7e7e4bf583f3799c8ac1c6c5e10d2cb553957347) +- [meta] add Automatic Rebase and Require Allow Edits workflows [`0199968`](https://github.com/ljharb/get-intrinsic/commit/01999687a263ffce0a3cb011dfbcb761754aedbc) + +## [v1.0.2](https://github.com/ljharb/get-intrinsic/compare/v1.0.1...v1.0.2) - 2020-12-17 + +### Commits + +- [Fix] Throw for non‑existent intrinsics [`68f873b`](https://github.com/ljharb/get-intrinsic/commit/68f873b013c732a05ad6f5fc54f697e55515461b) +- [Fix] Throw for non‑existent segments in the intrinsic path [`8325dee`](https://github.com/ljharb/get-intrinsic/commit/8325deee43128f3654d3399aa9591741ebe17b21) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-bigints`, `object-inspect` [`0c227a7`](https://github.com/ljharb/get-intrinsic/commit/0c227a7d8b629166f25715fd242553892e458525) +- [meta] do not lint coverage output [`70d2419`](https://github.com/ljharb/get-intrinsic/commit/70d24199b620043cd9110fc5f426d214ebe21dc9) + +## [v1.0.1](https://github.com/ljharb/get-intrinsic/compare/v1.0.0...v1.0.1) - 2020-10-30 + +### Commits + +- [Tests] gather coverage data on every job [`d1d280d`](https://github.com/ljharb/get-intrinsic/commit/d1d280dec714e3f0519cc877dbcb193057d9cac6) +- [Fix] add missing dependencies [`5031771`](https://github.com/ljharb/get-intrinsic/commit/5031771bb1095b38be88ce7c41d5de88718e432e) +- [Tests] use `es-value-fixtures` [`af48765`](https://github.com/ljharb/get-intrinsic/commit/af48765a23c5323fb0b6b38dbf00eb5099c7bebc) + +## v1.0.0 - 2020-10-29 + +### Commits + +- Implementation [`bbce57c`](https://github.com/ljharb/get-intrinsic/commit/bbce57c6f33d05b2d8d3efa273ceeb3ee01127bb) +- Tests [`17b4f0d`](https://github.com/ljharb/get-intrinsic/commit/17b4f0d56dea6b4059b56fc30ef3ee4d9500ebc2) +- Initial commit [`3153294`](https://github.com/ljharb/get-intrinsic/commit/31532948de363b0a27dd9fd4649e7b7028ec4b44) +- npm init [`fb326c4`](https://github.com/ljharb/get-intrinsic/commit/fb326c4d2817c8419ec31de1295f06bb268a7902) +- [meta] add Automatic Rebase and Require Allow Edits workflows [`48862fb`](https://github.com/ljharb/get-intrinsic/commit/48862fb2508c8f6a57968e6d08b7c883afc9d550) +- [meta] add `auto-changelog` [`5f28ad0`](https://github.com/ljharb/get-intrinsic/commit/5f28ad019e060a353d8028f9f2591a9cc93074a1) +- [meta] add "funding"; create `FUNDING.yml` [`c2bbdde`](https://github.com/ljharb/get-intrinsic/commit/c2bbddeba73a875be61484ee4680b129a6d4e0a1) +- [Tests] add `npm run lint` [`0a84b98`](https://github.com/ljharb/get-intrinsic/commit/0a84b98b22b7cf7a748666f705b0003a493c35fd) +- Only apps should have lockfiles [`9586c75`](https://github.com/ljharb/get-intrinsic/commit/9586c75866c1ee678e4d5d4dbbdef6997e511b05) diff --git a/node_modules/get-intrinsic/LICENSE b/node_modules/get-intrinsic/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..48f05d01d0acae75acada5bd42a3442d0699d067 --- /dev/null +++ b/node_modules/get-intrinsic/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Jordan Harband + +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. diff --git a/node_modules/get-intrinsic/README.md b/node_modules/get-intrinsic/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3aa0bba4037e57211920a2cf8b57194b61eb24d9 --- /dev/null +++ b/node_modules/get-intrinsic/README.md @@ -0,0 +1,71 @@ +# get-intrinsic [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Get and robustly cache all JS language-level intrinsics at first require time. + +See the syntax described [in the JS spec](https://tc39.es/ecma262/#sec-well-known-intrinsic-objects) for reference. + +## Example + +```js +var GetIntrinsic = require('get-intrinsic'); +var assert = require('assert'); + +// static methods +assert.equal(GetIntrinsic('%Math.pow%'), Math.pow); +assert.equal(Math.pow(2, 3), 8); +assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8); +delete Math.pow; +assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8); + +// instance methods +var arr = [1]; +assert.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push); +assert.deepEqual(arr, [1]); + +arr.push(2); +assert.deepEqual(arr, [1, 2]); + +GetIntrinsic('%Array.prototype.push%').call(arr, 3); +assert.deepEqual(arr, [1, 2, 3]); + +delete Array.prototype.push; +GetIntrinsic('%Array.prototype.push%').call(arr, 4); +assert.deepEqual(arr, [1, 2, 3, 4]); + +// missing features +delete JSON.parse; // to simulate a real intrinsic that is missing in the environment +assert.throws(() => GetIntrinsic('%JSON.parse%')); +assert.equal(undefined, GetIntrinsic('%JSON.parse%', true)); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +## Security + +Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report. + +[package-url]: https://npmjs.org/package/get-intrinsic +[npm-version-svg]: https://versionbadg.es/ljharb/get-intrinsic.svg +[deps-svg]: https://david-dm.org/ljharb/get-intrinsic.svg +[deps-url]: https://david-dm.org/ljharb/get-intrinsic +[dev-deps-svg]: https://david-dm.org/ljharb/get-intrinsic/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/get-intrinsic#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/get-intrinsic.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/get-intrinsic.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/get-intrinsic.svg +[downloads-url]: https://npm-stat.com/charts.html?package=get-intrinsic +[codecov-image]: https://codecov.io/gh/ljharb/get-intrinsic/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/ljharb/get-intrinsic/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/get-intrinsic +[actions-url]: https://github.com/ljharb/get-intrinsic/actions diff --git a/node_modules/get-intrinsic/index.js b/node_modules/get-intrinsic/index.js new file mode 100644 index 0000000000000000000000000000000000000000..be180b0ae9cedcc65f99d7a164f68b6f3b65ef53 --- /dev/null +++ b/node_modules/get-intrinsic/index.js @@ -0,0 +1,351 @@ +'use strict'; + +var undefined; + +var $SyntaxError = SyntaxError; +var $Function = Function; +var $TypeError = TypeError; + +// eslint-disable-next-line consistent-return +var getEvalledConstructor = function (expressionSyntax) { + try { + return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')(); + } catch (e) {} +}; + +var $gOPD = Object.getOwnPropertyDescriptor; +if ($gOPD) { + try { + $gOPD({}, ''); + } catch (e) { + $gOPD = null; // this is IE 8, which has a broken gOPD + } +} + +var throwTypeError = function () { + throw new $TypeError(); +}; +var ThrowTypeError = $gOPD + ? (function () { + try { + // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties + arguments.callee; // IE 8 does not throw here + return throwTypeError; + } catch (calleeThrows) { + try { + // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '') + return $gOPD(arguments, 'callee').get; + } catch (gOPDthrows) { + return throwTypeError; + } + } + }()) + : throwTypeError; + +var hasSymbols = require('has-symbols')(); +var hasProto = require('has-proto')(); + +var getProto = Object.getPrototypeOf || ( + hasProto + ? function (x) { return x.__proto__; } // eslint-disable-line no-proto + : null +); + +var needsEval = {}; + +var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined : getProto(Uint8Array); + +var INTRINSICS = { + '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError, + '%Array%': Array, + '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer, + '%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined, + '%AsyncFromSyncIteratorPrototype%': undefined, + '%AsyncFunction%': needsEval, + '%AsyncGenerator%': needsEval, + '%AsyncGeneratorFunction%': needsEval, + '%AsyncIteratorPrototype%': needsEval, + '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics, + '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt, + '%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined : BigInt64Array, + '%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined : BigUint64Array, + '%Boolean%': Boolean, + '%DataView%': typeof DataView === 'undefined' ? undefined : DataView, + '%Date%': Date, + '%decodeURI%': decodeURI, + '%decodeURIComponent%': decodeURIComponent, + '%encodeURI%': encodeURI, + '%encodeURIComponent%': encodeURIComponent, + '%Error%': Error, + '%eval%': eval, // eslint-disable-line no-eval + '%EvalError%': EvalError, + '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array, + '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array, + '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry, + '%Function%': $Function, + '%GeneratorFunction%': needsEval, + '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array, + '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array, + '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array, + '%isFinite%': isFinite, + '%isNaN%': isNaN, + '%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined, + '%JSON%': typeof JSON === 'object' ? JSON : undefined, + '%Map%': typeof Map === 'undefined' ? undefined : Map, + '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()), + '%Math%': Math, + '%Number%': Number, + '%Object%': Object, + '%parseFloat%': parseFloat, + '%parseInt%': parseInt, + '%Promise%': typeof Promise === 'undefined' ? undefined : Promise, + '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy, + '%RangeError%': RangeError, + '%ReferenceError%': ReferenceError, + '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect, + '%RegExp%': RegExp, + '%Set%': typeof Set === 'undefined' ? undefined : Set, + '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Set()[Symbol.iterator]()), + '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer, + '%String%': String, + '%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined, + '%Symbol%': hasSymbols ? Symbol : undefined, + '%SyntaxError%': $SyntaxError, + '%ThrowTypeError%': ThrowTypeError, + '%TypedArray%': TypedArray, + '%TypeError%': $TypeError, + '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array, + '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray, + '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array, + '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array, + '%URIError%': URIError, + '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap, + '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef, + '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet +}; + +if (getProto) { + try { + null.error; // eslint-disable-line no-unused-expressions + } catch (e) { + // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229 + var errorProto = getProto(getProto(e)); + INTRINSICS['%Error.prototype%'] = errorProto; + } +} + +var doEval = function doEval(name) { + var value; + if (name === '%AsyncFunction%') { + value = getEvalledConstructor('async function () {}'); + } else if (name === '%GeneratorFunction%') { + value = getEvalledConstructor('function* () {}'); + } else if (name === '%AsyncGeneratorFunction%') { + value = getEvalledConstructor('async function* () {}'); + } else if (name === '%AsyncGenerator%') { + var fn = doEval('%AsyncGeneratorFunction%'); + if (fn) { + value = fn.prototype; + } + } else if (name === '%AsyncIteratorPrototype%') { + var gen = doEval('%AsyncGenerator%'); + if (gen && getProto) { + value = getProto(gen.prototype); + } + } + + INTRINSICS[name] = value; + + return value; +}; + +var LEGACY_ALIASES = { + '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'], + '%ArrayPrototype%': ['Array', 'prototype'], + '%ArrayProto_entries%': ['Array', 'prototype', 'entries'], + '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'], + '%ArrayProto_keys%': ['Array', 'prototype', 'keys'], + '%ArrayProto_values%': ['Array', 'prototype', 'values'], + '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'], + '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'], + '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'], + '%BooleanPrototype%': ['Boolean', 'prototype'], + '%DataViewPrototype%': ['DataView', 'prototype'], + '%DatePrototype%': ['Date', 'prototype'], + '%ErrorPrototype%': ['Error', 'prototype'], + '%EvalErrorPrototype%': ['EvalError', 'prototype'], + '%Float32ArrayPrototype%': ['Float32Array', 'prototype'], + '%Float64ArrayPrototype%': ['Float64Array', 'prototype'], + '%FunctionPrototype%': ['Function', 'prototype'], + '%Generator%': ['GeneratorFunction', 'prototype'], + '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'], + '%Int8ArrayPrototype%': ['Int8Array', 'prototype'], + '%Int16ArrayPrototype%': ['Int16Array', 'prototype'], + '%Int32ArrayPrototype%': ['Int32Array', 'prototype'], + '%JSONParse%': ['JSON', 'parse'], + '%JSONStringify%': ['JSON', 'stringify'], + '%MapPrototype%': ['Map', 'prototype'], + '%NumberPrototype%': ['Number', 'prototype'], + '%ObjectPrototype%': ['Object', 'prototype'], + '%ObjProto_toString%': ['Object', 'prototype', 'toString'], + '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'], + '%PromisePrototype%': ['Promise', 'prototype'], + '%PromiseProto_then%': ['Promise', 'prototype', 'then'], + '%Promise_all%': ['Promise', 'all'], + '%Promise_reject%': ['Promise', 'reject'], + '%Promise_resolve%': ['Promise', 'resolve'], + '%RangeErrorPrototype%': ['RangeError', 'prototype'], + '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'], + '%RegExpPrototype%': ['RegExp', 'prototype'], + '%SetPrototype%': ['Set', 'prototype'], + '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'], + '%StringPrototype%': ['String', 'prototype'], + '%SymbolPrototype%': ['Symbol', 'prototype'], + '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'], + '%TypedArrayPrototype%': ['TypedArray', 'prototype'], + '%TypeErrorPrototype%': ['TypeError', 'prototype'], + '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'], + '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'], + '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'], + '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'], + '%URIErrorPrototype%': ['URIError', 'prototype'], + '%WeakMapPrototype%': ['WeakMap', 'prototype'], + '%WeakSetPrototype%': ['WeakSet', 'prototype'] +}; + +var bind = require('function-bind'); +var hasOwn = require('hasown'); +var $concat = bind.call(Function.call, Array.prototype.concat); +var $spliceApply = bind.call(Function.apply, Array.prototype.splice); +var $replace = bind.call(Function.call, String.prototype.replace); +var $strSlice = bind.call(Function.call, String.prototype.slice); +var $exec = bind.call(Function.call, RegExp.prototype.exec); + +/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */ +var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; +var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */ +var stringToPath = function stringToPath(string) { + var first = $strSlice(string, 0, 1); + var last = $strSlice(string, -1); + if (first === '%' && last !== '%') { + throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`'); + } else if (last === '%' && first !== '%') { + throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`'); + } + var result = []; + $replace(string, rePropName, function (match, number, quote, subString) { + result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match; + }); + return result; +}; +/* end adaptation */ + +var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) { + var intrinsicName = name; + var alias; + if (hasOwn(LEGACY_ALIASES, intrinsicName)) { + alias = LEGACY_ALIASES[intrinsicName]; + intrinsicName = '%' + alias[0] + '%'; + } + + if (hasOwn(INTRINSICS, intrinsicName)) { + var value = INTRINSICS[intrinsicName]; + if (value === needsEval) { + value = doEval(intrinsicName); + } + if (typeof value === 'undefined' && !allowMissing) { + throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!'); + } + + return { + alias: alias, + name: intrinsicName, + value: value + }; + } + + throw new $SyntaxError('intrinsic ' + name + ' does not exist!'); +}; + +module.exports = function GetIntrinsic(name, allowMissing) { + if (typeof name !== 'string' || name.length === 0) { + throw new $TypeError('intrinsic name must be a non-empty string'); + } + if (arguments.length > 1 && typeof allowMissing !== 'boolean') { + throw new $TypeError('"allowMissing" argument must be a boolean'); + } + + if ($exec(/^%?[^%]*%?$/, name) === null) { + throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name'); + } + var parts = stringToPath(name); + var intrinsicBaseName = parts.length > 0 ? parts[0] : ''; + + var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing); + var intrinsicRealName = intrinsic.name; + var value = intrinsic.value; + var skipFurtherCaching = false; + + var alias = intrinsic.alias; + if (alias) { + intrinsicBaseName = alias[0]; + $spliceApply(parts, $concat([0, 1], alias)); + } + + for (var i = 1, isOwn = true; i < parts.length; i += 1) { + var part = parts[i]; + var first = $strSlice(part, 0, 1); + var last = $strSlice(part, -1); + if ( + ( + (first === '"' || first === "'" || first === '`') + || (last === '"' || last === "'" || last === '`') + ) + && first !== last + ) { + throw new $SyntaxError('property names with quotes must have matching quotes'); + } + if (part === 'constructor' || !isOwn) { + skipFurtherCaching = true; + } + + intrinsicBaseName += '.' + part; + intrinsicRealName = '%' + intrinsicBaseName + '%'; + + if (hasOwn(INTRINSICS, intrinsicRealName)) { + value = INTRINSICS[intrinsicRealName]; + } else if (value != null) { + if (!(part in value)) { + if (!allowMissing) { + throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.'); + } + return void undefined; + } + if ($gOPD && (i + 1) >= parts.length) { + var desc = $gOPD(value, part); + isOwn = !!desc; + + // By convention, when a data property is converted to an accessor + // property to emulate a data property that does not suffer from + // the override mistake, that accessor's getter is marked with + // an `originalValue` property. Here, when we detect this, we + // uphold the illusion by pretending to see that original data + // property, i.e., returning the value rather than the getter + // itself. + if (isOwn && 'get' in desc && !('originalValue' in desc.get)) { + value = desc.get; + } else { + value = value[part]; + } + } else { + isOwn = hasOwn(value, part); + value = value[part]; + } + + if (isOwn && !skipFurtherCaching) { + INTRINSICS[intrinsicRealName] = value; + } + } + } + return value; +}; diff --git a/node_modules/get-intrinsic/package.json b/node_modules/get-intrinsic/package.json new file mode 100644 index 0000000000000000000000000000000000000000..ffffe09c0241034ad850ff0d78931fc7416a7ff5 --- /dev/null +++ b/node_modules/get-intrinsic/package.json @@ -0,0 +1,93 @@ +{ + "name": "get-intrinsic", + "version": "1.2.2", + "description": "Get and robustly cache all JS language-level intrinsics at first require time", + "main": "index.js", + "exports": { + ".": [ + { + "default": "./index.js" + }, + "./index.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated", + "prepublish": "not-in-publish || npm run prepublishOnly", + "prepublishOnly": "safe-publish-latest", + "prelint": "evalmd README.md", + "lint": "eslint --ext=.js,.mjs .", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ljharb/get-intrinsic.git" + }, + "keywords": [ + "javascript", + "ecmascript", + "es", + "js", + "intrinsic", + "getintrinsic", + "es-abstract" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/ljharb/get-intrinsic/issues" + }, + "homepage": "https://github.com/ljharb/get-intrinsic#readme", + "devDependencies": { + "@ljharb/eslint-config": "^21.1.0", + "aud": "^2.0.3", + "auto-changelog": "^2.4.0", + "call-bind": "^1.0.5", + "es-abstract": "^1.22.2", + "es-value-fixtures": "^1.4.2", + "eslint": "=8.8.0", + "evalmd": "^0.0.19", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "make-async-function": "^1.0.0", + "make-async-generator-function": "^1.0.0", + "make-generator-function": "^2.0.0", + "mock-property": "^1.0.2", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "object-inspect": "^1.13.1", + "safe-publish-latest": "^2.0.0", + "tape": "^5.7.2" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + }, + "dependencies": { + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "testling": { + "files": "test/GetIntrinsic.js" + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] + } +} diff --git a/node_modules/get-intrinsic/test/GetIntrinsic.js b/node_modules/get-intrinsic/test/GetIntrinsic.js new file mode 100644 index 0000000000000000000000000000000000000000..1cc08e00ce925497d3247253d0d86f4b8ad5ee24 --- /dev/null +++ b/node_modules/get-intrinsic/test/GetIntrinsic.js @@ -0,0 +1,274 @@ +'use strict'; + +var GetIntrinsic = require('../'); + +var test = require('tape'); +var forEach = require('for-each'); +var debug = require('object-inspect'); +var generatorFns = require('make-generator-function')(); +var asyncFns = require('make-async-function').list(); +var asyncGenFns = require('make-async-generator-function')(); +var mockProperty = require('mock-property'); + +var callBound = require('call-bind/callBound'); +var v = require('es-value-fixtures'); +var $gOPD = require('gopd'); +var DefinePropertyOrThrow = require('es-abstract/2021/DefinePropertyOrThrow'); + +var $isProto = callBound('%Object.prototype.isPrototypeOf%'); + +test('export', function (t) { + t.equal(typeof GetIntrinsic, 'function', 'it is a function'); + t.equal(GetIntrinsic.length, 2, 'function has length of 2'); + + t.end(); +}); + +test('throws', function (t) { + t['throws']( + function () { GetIntrinsic('not an intrinsic'); }, + SyntaxError, + 'nonexistent intrinsic throws a syntax error' + ); + + t['throws']( + function () { GetIntrinsic(''); }, + TypeError, + 'empty string intrinsic throws a type error' + ); + + t['throws']( + function () { GetIntrinsic('.'); }, + SyntaxError, + '"just a dot" intrinsic throws a syntax error' + ); + + t['throws']( + function () { GetIntrinsic('%String'); }, + SyntaxError, + 'Leading % without trailing % throws a syntax error' + ); + + t['throws']( + function () { GetIntrinsic('String%'); }, + SyntaxError, + 'Trailing % without leading % throws a syntax error' + ); + + t['throws']( + function () { GetIntrinsic("String['prototype]"); }, + SyntaxError, + 'Dynamic property access is disallowed for intrinsics (unterminated string)' + ); + + t['throws']( + function () { GetIntrinsic('%Proxy.prototype.undefined%'); }, + TypeError, + "Throws when middle part doesn't exist (%Proxy.prototype.undefined%)" + ); + + t['throws']( + function () { GetIntrinsic('%Array.prototype%garbage%'); }, + SyntaxError, + 'Throws with extra percent signs' + ); + + t['throws']( + function () { GetIntrinsic('%Array.prototype%push%'); }, + SyntaxError, + 'Throws with extra percent signs, even on an existing intrinsic' + ); + + forEach(v.nonStrings, function (nonString) { + t['throws']( + function () { GetIntrinsic(nonString); }, + TypeError, + debug(nonString) + ' is not a String' + ); + }); + + forEach(v.nonBooleans, function (nonBoolean) { + t['throws']( + function () { GetIntrinsic('%', nonBoolean); }, + TypeError, + debug(nonBoolean) + ' is not a Boolean' + ); + }); + + forEach([ + 'toString', + 'propertyIsEnumerable', + 'hasOwnProperty' + ], function (objectProtoMember) { + t['throws']( + function () { GetIntrinsic(objectProtoMember); }, + SyntaxError, + debug(objectProtoMember) + ' is not an intrinsic' + ); + }); + + t.end(); +}); + +test('base intrinsics', function (t) { + t.equal(GetIntrinsic('%Object%'), Object, '%Object% yields Object'); + t.equal(GetIntrinsic('Object'), Object, 'Object yields Object'); + t.equal(GetIntrinsic('%Array%'), Array, '%Array% yields Array'); + t.equal(GetIntrinsic('Array'), Array, 'Array yields Array'); + + t.end(); +}); + +test('dotted paths', function (t) { + t.equal(GetIntrinsic('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% yields Object.prototype.toString'); + t.equal(GetIntrinsic('Object.prototype.toString'), Object.prototype.toString, 'Object.prototype.toString yields Object.prototype.toString'); + t.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push, '%Array.prototype.push% yields Array.prototype.push'); + t.equal(GetIntrinsic('Array.prototype.push'), Array.prototype.push, 'Array.prototype.push yields Array.prototype.push'); + + test('underscore paths are aliases for dotted paths', { skip: !Object.isFrozen || Object.isFrozen(Object.prototype) }, function (st) { + var original = GetIntrinsic('%ObjProto_toString%'); + + forEach([ + '%Object.prototype.toString%', + 'Object.prototype.toString', + '%ObjectPrototype.toString%', + 'ObjectPrototype.toString', + '%ObjProto_toString%', + 'ObjProto_toString' + ], function (name) { + DefinePropertyOrThrow(Object.prototype, 'toString', { + '[[Value]]': function toString() { + return original.apply(this, arguments); + } + }); + st.equal(GetIntrinsic(name), original, name + ' yields original Object.prototype.toString'); + }); + + DefinePropertyOrThrow(Object.prototype, 'toString', { '[[Value]]': original }); + st.end(); + }); + + test('dotted paths cache', { skip: !Object.isFrozen || Object.isFrozen(Object.prototype) }, function (st) { + var original = GetIntrinsic('%Object.prototype.propertyIsEnumerable%'); + + forEach([ + '%Object.prototype.propertyIsEnumerable%', + 'Object.prototype.propertyIsEnumerable', + '%ObjectPrototype.propertyIsEnumerable%', + 'ObjectPrototype.propertyIsEnumerable' + ], function (name) { + var restore = mockProperty(Object.prototype, 'propertyIsEnumerable', { + value: function propertyIsEnumerable() { + return original.apply(this, arguments); + } + }); + st.equal(GetIntrinsic(name), original, name + ' yields cached Object.prototype.propertyIsEnumerable'); + + restore(); + }); + + st.end(); + }); + + test('dotted path reports correct error', function (st) { + st['throws'](function () { + GetIntrinsic('%NonExistentIntrinsic.prototype.property%'); + }, /%NonExistentIntrinsic%/, 'The base intrinsic of %NonExistentIntrinsic.prototype.property% is %NonExistentIntrinsic%'); + + st['throws'](function () { + GetIntrinsic('%NonExistentIntrinsicPrototype.property%'); + }, /%NonExistentIntrinsicPrototype%/, 'The base intrinsic of %NonExistentIntrinsicPrototype.property% is %NonExistentIntrinsicPrototype%'); + + st.end(); + }); + + t.end(); +}); + +test('accessors', { skip: !$gOPD || typeof Map !== 'function' }, function (t) { + var actual = $gOPD(Map.prototype, 'size'); + t.ok(actual, 'Map.prototype.size has a descriptor'); + t.equal(typeof actual.get, 'function', 'Map.prototype.size has a getter function'); + t.equal(GetIntrinsic('%Map.prototype.size%'), actual.get, '%Map.prototype.size% yields the getter for it'); + t.equal(GetIntrinsic('Map.prototype.size'), actual.get, 'Map.prototype.size yields the getter for it'); + + t.end(); +}); + +test('generator functions', { skip: !generatorFns.length }, function (t) { + var $GeneratorFunction = GetIntrinsic('%GeneratorFunction%'); + var $GeneratorFunctionPrototype = GetIntrinsic('%Generator%'); + var $GeneratorPrototype = GetIntrinsic('%GeneratorPrototype%'); + + forEach(generatorFns, function (genFn) { + var fnName = genFn.name; + fnName = fnName ? "'" + fnName + "'" : 'genFn'; + + t.ok(genFn instanceof $GeneratorFunction, fnName + ' instanceof %GeneratorFunction%'); + t.ok($isProto($GeneratorFunctionPrototype, genFn), '%Generator% is prototype of ' + fnName); + t.ok($isProto($GeneratorPrototype, genFn.prototype), '%GeneratorPrototype% is prototype of ' + fnName + '.prototype'); + }); + + t.end(); +}); + +test('async functions', { skip: !asyncFns.length }, function (t) { + var $AsyncFunction = GetIntrinsic('%AsyncFunction%'); + var $AsyncFunctionPrototype = GetIntrinsic('%AsyncFunctionPrototype%'); + + forEach(asyncFns, function (asyncFn) { + var fnName = asyncFn.name; + fnName = fnName ? "'" + fnName + "'" : 'asyncFn'; + + t.ok(asyncFn instanceof $AsyncFunction, fnName + ' instanceof %AsyncFunction%'); + t.ok($isProto($AsyncFunctionPrototype, asyncFn), '%AsyncFunctionPrototype% is prototype of ' + fnName); + }); + + t.end(); +}); + +test('async generator functions', { skip: asyncGenFns.length === 0 }, function (t) { + var $AsyncGeneratorFunction = GetIntrinsic('%AsyncGeneratorFunction%'); + var $AsyncGeneratorFunctionPrototype = GetIntrinsic('%AsyncGenerator%'); + var $AsyncGeneratorPrototype = GetIntrinsic('%AsyncGeneratorPrototype%'); + + forEach(asyncGenFns, function (asyncGenFn) { + var fnName = asyncGenFn.name; + fnName = fnName ? "'" + fnName + "'" : 'asyncGenFn'; + + t.ok(asyncGenFn instanceof $AsyncGeneratorFunction, fnName + ' instanceof %AsyncGeneratorFunction%'); + t.ok($isProto($AsyncGeneratorFunctionPrototype, asyncGenFn), '%AsyncGenerator% is prototype of ' + fnName); + t.ok($isProto($AsyncGeneratorPrototype, asyncGenFn.prototype), '%AsyncGeneratorPrototype% is prototype of ' + fnName + '.prototype'); + }); + + t.end(); +}); + +test('%ThrowTypeError%', function (t) { + var $ThrowTypeError = GetIntrinsic('%ThrowTypeError%'); + + t.equal(typeof $ThrowTypeError, 'function', 'is a function'); + t['throws']( + $ThrowTypeError, + TypeError, + '%ThrowTypeError% throws a TypeError' + ); + + t.end(); +}); + +test('allowMissing', { skip: asyncGenFns.length > 0 }, function (t) { + t['throws']( + function () { GetIntrinsic('%AsyncGeneratorPrototype%'); }, + TypeError, + 'throws when missing' + ); + + t.equal( + GetIntrinsic('%AsyncGeneratorPrototype%', true), + undefined, + 'does not throw when allowMissing' + ); + + t.end(); +}); diff --git a/node_modules/getpass/.npmignore b/node_modules/getpass/.npmignore new file mode 100644 index 0000000000000000000000000000000000000000..a4261fc06feaaf4b143bbddee42f3d168b5bc702 --- /dev/null +++ b/node_modules/getpass/.npmignore @@ -0,0 +1,8 @@ +.gitmodules +deps +docs +Makefile +node_modules +test +tools +coverage diff --git a/node_modules/getpass/.travis.yml b/node_modules/getpass/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..d8b5833a71b22c980143e6be23b777e768ed54f6 --- /dev/null +++ b/node_modules/getpass/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - "5.10" + - "4.4" + - "4.1" + - "0.12" + - "0.10" +before_install: + - "make check" diff --git a/node_modules/getpass/LICENSE b/node_modules/getpass/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..f6d947d2f61c41777fb3bbb66334a93122bf5fdc --- /dev/null +++ b/node_modules/getpass/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. All rights reserved. +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. diff --git a/node_modules/getpass/README.md b/node_modules/getpass/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6e4a50f63f7f00d0c628f8f80b44e1964c6841e5 --- /dev/null +++ b/node_modules/getpass/README.md @@ -0,0 +1,32 @@ +## getpass + +Get a password from the terminal. Sounds simple? Sounds like the `readline` +module should be able to do it? NOPE. + +## Install and use it + +```bash +npm install --save getpass +``` + +```javascript +const mod_getpass = require('getpass'); +``` + +## API + +### `mod_getpass.getPass([options, ]callback)` + +Gets a password from the terminal. If available, this uses `/dev/tty` to avoid +interfering with any data being piped in or out of stdio. + +This function prints a prompt (by default `Password:`) and then accepts input +without echoing. + +Parameters: + + * `options`, an Object, with properties: + * `prompt`, an optional String + * `callback`, a `Func(error, password)`, with arguments: + * `error`, either `null` (no error) or an `Error` instance + * `password`, a String diff --git a/node_modules/getpass/lib/index.js b/node_modules/getpass/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..55a7718c0f7f72c82858d6fb51d3c93e3d517541 --- /dev/null +++ b/node_modules/getpass/lib/index.js @@ -0,0 +1,123 @@ +/* + * Copyright 2016, Joyent, Inc. All rights reserved. + * Author: Alex Wilson + * + * 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. +*/ + +module.exports = { + getPass: getPass +}; + +const mod_tty = require('tty'); +const mod_fs = require('fs'); +const mod_assert = require('assert-plus'); + +var BACKSPACE = String.fromCharCode(127); +var CTRLC = '\u0003'; +var CTRLD = '\u0004'; + +function getPass(opts, cb) { + if (typeof (opts) === 'function' && cb === undefined) { + cb = opts; + opts = {}; + } + mod_assert.object(opts, 'options'); + mod_assert.func(cb, 'callback'); + + mod_assert.optionalString(opts.prompt, 'options.prompt'); + if (opts.prompt === undefined) + opts.prompt = 'Password'; + + openTTY(function (err, rfd, wfd, rtty, wtty) { + if (err) { + cb(err); + return; + } + + wtty.write(opts.prompt + ':'); + rtty.resume(); + rtty.setRawMode(true); + rtty.resume(); + rtty.setEncoding('utf8'); + + var pw = ''; + rtty.on('data', onData); + + function onData(data) { + var str = data.toString('utf8'); + for (var i = 0; i < str.length; ++i) { + var ch = str[i]; + switch (ch) { + case '\r': + case '\n': + case CTRLD: + cleanup(); + cb(null, pw); + return; + case CTRLC: + cleanup(); + cb(new Error('Aborted')); + return; + case BACKSPACE: + pw = pw.slice(0, pw.length - 1); + break; + default: + pw += ch; + break; + } + } + } + + function cleanup() { + wtty.write('\r\n'); + rtty.setRawMode(false); + rtty.pause(); + rtty.removeListener('data', onData); + if (wfd !== undefined && wfd !== rfd) { + wtty.end(); + mod_fs.closeSync(wfd); + } + if (rfd !== undefined) { + rtty.end(); + mod_fs.closeSync(rfd); + } + } + }); +} + +function openTTY(cb) { + mod_fs.open('/dev/tty', 'r+', function (err, rttyfd) { + if ((err && (err.code === 'ENOENT' || err.code === 'EACCES')) || + (process.version.match(/^v0[.][0-8][.]/))) { + cb(null, undefined, undefined, process.stdin, + process.stdout); + return; + } + var rtty = new mod_tty.ReadStream(rttyfd); + mod_fs.open('/dev/tty', 'w+', function (err3, wttyfd) { + var wtty = new mod_tty.WriteStream(wttyfd); + if (err3) { + cb(err3); + return; + } + cb(null, rttyfd, wttyfd, rtty, wtty); + }); + }); +} diff --git a/node_modules/getpass/package.json b/node_modules/getpass/package.json new file mode 100644 index 0000000000000000000000000000000000000000..f1638eb3cdd27f139831736b4df029b4e18bbe62 --- /dev/null +++ b/node_modules/getpass/package.json @@ -0,0 +1,18 @@ +{ + "name": "getpass", + "version": "0.1.7", + "description": "getpass for node.js", + "main": "lib/index.js", + "dependencies": { + "assert-plus": "^1.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/arekinath/node-getpass.git" + }, + "scripts": { + "test": "tape test/*.test.js" + }, + "author": "Alex Wilson ", + "license": "MIT" +} diff --git a/node_modules/glob-to-regexp/.travis.yml b/node_modules/glob-to-regexp/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..ddc9c4f9899fed53bf73cdf47101a33d0cde1acc --- /dev/null +++ b/node_modules/glob-to-regexp/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.8 + - "0.10" \ No newline at end of file diff --git a/node_modules/glob-to-regexp/README.md b/node_modules/glob-to-regexp/README.md new file mode 100644 index 0000000000000000000000000000000000000000..afb41142a452a7576a22a1011e6fe5ed7438c4ee --- /dev/null +++ b/node_modules/glob-to-regexp/README.md @@ -0,0 +1,75 @@ +# Glob To Regular Expression + +[![Build Status](https://travis-ci.org/fitzgen/glob-to-regexp.png?branch=master)](https://travis-ci.org/fitzgen/glob-to-regexp) + +Turn a \*-wildcard style glob (`"*.min.js"`) into a regular expression +(`/^.*\.min\.js$/`)! + +To match bash-like globs, eg. `?` for any single-character match, `[a-z]` for +character ranges, and `{*.html, *.js}` for multiple alternatives, call with +`{ extended: true }`. + +To obey [globstars `**`](https://github.com/isaacs/node-glob#glob-primer) rules set option `{globstar: true}`. +NOTE: This changes the behavior of `*` when `globstar` is `true` as shown below: +When `{globstar: true}`: `/foo/**` will match any string that starts with `/foo/` +like `/foo/index.htm`, `/foo/bar/baz.txt`, etc. Also, `/foo/**/*.txt` will match +any string that starts with `/foo/` and ends with `.txt` like `/foo/bar.txt`, +`/foo/bar/baz.txt`, etc. +Whereas `/foo/*` (single `*`, not a globstar) will match strings that start with +`/foo/` like `/foo/index.htm`, `/foo/baz.txt` but will not match strings that +contain a `/` to the right like `/foo/bar/baz.txt`, `/foo/bar/baz/qux.dat`, etc. + +Set flags on the resulting `RegExp` object by adding the `flags` property to the option object, eg `{ flags: "i" }` for ignoring case. + +## Install + + npm install glob-to-regexp + +## Usage +```js +var globToRegExp = require('glob-to-regexp'); +var re = globToRegExp("p*uck"); +re.test("pot luck"); // true +re.test("pluck"); // true +re.test("puck"); // true + +re = globToRegExp("*.min.js"); +re.test("http://example.com/jquery.min.js"); // true +re.test("http://example.com/jquery.min.js.map"); // false + +re = globToRegExp("*/www/*.js"); +re.test("http://example.com/www/app.js"); // true +re.test("http://example.com/www/lib/factory-proxy-model-observer.js"); // true + +// Extended globs +re = globToRegExp("*/www/{*.js,*.html}", { extended: true }); +re.test("http://example.com/www/app.js"); // true +re.test("http://example.com/www/index.html"); // true +``` + +## License + +Copyright (c) 2013, Nick Fitzgerald + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/glob-to-regexp/index.js b/node_modules/glob-to-regexp/index.js new file mode 100644 index 0000000000000000000000000000000000000000..365cf227effa2101c296de5ee5dc8364eea171fb --- /dev/null +++ b/node_modules/glob-to-regexp/index.js @@ -0,0 +1,130 @@ +module.exports = function (glob, opts) { + if (typeof glob !== 'string') { + throw new TypeError('Expected a string'); + } + + var str = String(glob); + + // The regexp we are building, as a string. + var reStr = ""; + + // Whether we are matching so called "extended" globs (like bash) and should + // support single character matching, matching ranges of characters, group + // matching, etc. + var extended = opts ? !!opts.extended : false; + + // When globstar is _false_ (default), '/foo/*' is translated a regexp like + // '^\/foo\/.*$' which will match any string beginning with '/foo/' + // When globstar is _true_, '/foo/*' is translated to regexp like + // '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' BUT + // which does not have a '/' to the right of it. + // E.g. with '/foo/*' these will match: '/foo/bar', '/foo/bar.txt' but + // these will not '/foo/bar/baz', '/foo/bar/baz.txt' + // Lastely, when globstar is _true_, '/foo/**' is equivelant to '/foo/*' when + // globstar is _false_ + var globstar = opts ? !!opts.globstar : false; + + // If we are doing extended matching, this boolean is true when we are inside + // a group (eg {*.html,*.js}), and false otherwise. + var inGroup = false; + + // RegExp flags (eg "i" ) to pass in to RegExp constructor. + var flags = opts && typeof( opts.flags ) === "string" ? opts.flags : ""; + + var c; + for (var i = 0, len = str.length; i < len; i++) { + c = str[i]; + + switch (c) { + case "/": + case "$": + case "^": + case "+": + case ".": + case "(": + case ")": + case "=": + case "!": + case "|": + reStr += "\\" + c; + break; + + case "?": + if (extended) { + reStr += "."; + break; + } + + case "[": + case "]": + if (extended) { + reStr += c; + break; + } + + case "{": + if (extended) { + inGroup = true; + reStr += "("; + break; + } + + case "}": + if (extended) { + inGroup = false; + reStr += ")"; + break; + } + + case ",": + if (inGroup) { + reStr += "|"; + break; + } + reStr += "\\" + c; + break; + + case "*": + // Move over all consecutive "*"'s. + // Also store the previous and next characters + var prevChar = str[i - 1]; + var starCount = 1; + while(str[i + 1] === "*") { + starCount++; + i++; + } + var nextChar = str[i + 1]; + + if (!globstar) { + // globstar is disabled, so treat any number of "*" as one + reStr += ".*"; + } else { + // globstar is enabled, so determine if this is a globstar segment + var isGlobstar = starCount > 1 // multiple "*"'s + && (prevChar === "/" || prevChar === undefined) // from the start of the segment + && (nextChar === "/" || nextChar === undefined) // to the end of the segment + + if (isGlobstar) { + // it's a globstar, so match zero or more path segments + reStr += "((?:[^/]*(?:\/|$))*)"; + i++; // move over the "/" + } else { + // it's not a globstar, so only match one path segment + reStr += "([^/]*)"; + } + } + break; + + default: + reStr += c; + } + } + + // When regexp 'g' flag is specified don't + // constrain the regular expression with ^ & $ + if (!flags || !~flags.indexOf('g')) { + reStr = "^" + reStr + "$"; + } + + return new RegExp(reStr, flags); +}; diff --git a/node_modules/glob-to-regexp/package.json b/node_modules/glob-to-regexp/package.json new file mode 100644 index 0000000000000000000000000000000000000000..467daf31e53d0380dbcda6d4d178ded2e5c9ac40 --- /dev/null +++ b/node_modules/glob-to-regexp/package.json @@ -0,0 +1,23 @@ +{ + "name": "glob-to-regexp", + "version": "0.4.1", + "description": "Convert globs to regular expressions", + "main": "index.js", + "scripts": { + "test": "node test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/fitzgen/glob-to-regexp.git" + }, + "keywords": [ + "regexp", + "glob", + "regexps", + "regular expressions", + "regular expression", + "wildcard" + ], + "author": "Nick Fitzgerald ", + "license": "BSD-2-Clause" +} diff --git a/node_modules/glob-to-regexp/test.js b/node_modules/glob-to-regexp/test.js new file mode 100644 index 0000000000000000000000000000000000000000..58ee622c722832c6a58087cb72e0466b1aca1227 --- /dev/null +++ b/node_modules/glob-to-regexp/test.js @@ -0,0 +1,235 @@ +var globToRegexp = require("./index.js"); +var assert = require("assert"); + +function assertMatch(glob, str, opts) { + //console.log(glob, globToRegexp(glob, opts)); + assert.ok(globToRegexp(glob, opts).test(str)); +} + +function assertNotMatch(glob, str, opts) { + //console.log(glob, globToRegexp(glob, opts)); + assert.equal(false, globToRegexp(glob, opts).test(str)); +} + +function test(globstar) { + // Match everything + assertMatch("*", "foo"); + assertMatch("*", "foo", { flags: 'g' }); + + // Match the end + assertMatch("f*", "foo"); + assertMatch("f*", "foo", { flags: 'g' }); + + // Match the start + assertMatch("*o", "foo"); + assertMatch("*o", "foo", { flags: 'g' }); + + // Match the middle + assertMatch("f*uck", "firetruck"); + assertMatch("f*uck", "firetruck", { flags: 'g' }); + + // Don't match without Regexp 'g' + assertNotMatch("uc", "firetruck"); + // Match anywhere with RegExp 'g' + assertMatch("uc", "firetruck", { flags: 'g' }); + + // Match zero characters + assertMatch("f*uck", "fuck"); + assertMatch("f*uck", "fuck", { flags: 'g' }); + + // More complex matches + assertMatch("*.min.js", "http://example.com/jquery.min.js", {globstar: false}); + assertMatch("*.min.*", "http://example.com/jquery.min.js", {globstar: false}); + assertMatch("*/js/*.js", "http://example.com/js/jquery.min.js", {globstar: false}); + + // More complex matches with RegExp 'g' flag (complex regression) + assertMatch("*.min.*", "http://example.com/jquery.min.js", { flags: 'g' }); + assertMatch("*.min.js", "http://example.com/jquery.min.js", { flags: 'g' }); + assertMatch("*/js/*.js", "http://example.com/js/jquery.min.js", { flags: 'g' }); + + // Test string "\\\\/$^+?.()=!|{},[].*" represents \\/$^+?.()=!|{},[].* + // The equivalent regex is: /^\\\/\$\^\+\?\.\(\)\=\!\|\{\}\,\[\]\..*$/ + // Both glob and regex match: \/$^+?.()=!|{},[].* + var testStr = "\\\\/$^+?.()=!|{},[].*"; + var targetStr = "\\/$^+?.()=!|{},[].*"; + assertMatch(testStr, targetStr); + assertMatch(testStr, targetStr, { flags: 'g' }); + + // Equivalent matches without/with using RegExp 'g' + assertNotMatch(".min.", "http://example.com/jquery.min.js"); + assertMatch("*.min.*", "http://example.com/jquery.min.js"); + assertMatch(".min.", "http://example.com/jquery.min.js", { flags: 'g' }); + + assertNotMatch("http:", "http://example.com/jquery.min.js"); + assertMatch("http:*", "http://example.com/jquery.min.js"); + assertMatch("http:", "http://example.com/jquery.min.js", { flags: 'g' }); + + assertNotMatch("min.js", "http://example.com/jquery.min.js"); + assertMatch("*.min.js", "http://example.com/jquery.min.js"); + assertMatch("min.js", "http://example.com/jquery.min.js", { flags: 'g' }); + + // Match anywhere (globally) using RegExp 'g' + assertMatch("min", "http://example.com/jquery.min.js", { flags: 'g' }); + assertMatch("/js/", "http://example.com/js/jquery.min.js", { flags: 'g' }); + + assertNotMatch("/js*jq*.js", "http://example.com/js/jquery.min.js"); + assertMatch("/js*jq*.js", "http://example.com/js/jquery.min.js", { flags: 'g' }); + + // Extended mode + + // ?: Match one character, no more and no less + assertMatch("f?o", "foo", { extended: true }); + assertNotMatch("f?o", "fooo", { extended: true }); + assertNotMatch("f?oo", "foo", { extended: true }); + + // ?: Match one character with RegExp 'g' + assertMatch("f?o", "foo", { extended: true, globstar: globstar, flags: 'g' }); + assertMatch("f?o", "fooo", { extended: true, globstar: globstar, flags: 'g' }); + assertMatch("f?o?", "fooo", { extended: true, globstar: globstar, flags: 'g' }); + assertNotMatch("?fo", "fooo", { extended: true, globstar: globstar, flags: 'g' }); + assertNotMatch("f?oo", "foo", { extended: true, globstar: globstar, flags: 'g' }); + assertNotMatch("foo?", "foo", { extended: true, globstar: globstar, flags: 'g' }); + + // []: Match a character range + assertMatch("fo[oz]", "foo", { extended: true }); + assertMatch("fo[oz]", "foz", { extended: true }); + assertNotMatch("fo[oz]", "fog", { extended: true }); + + // []: Match a character range and RegExp 'g' (regresion) + assertMatch("fo[oz]", "foo", { extended: true, globstar: globstar, flags: 'g' }); + assertMatch("fo[oz]", "foz", { extended: true, globstar: globstar, flags: 'g' }); + assertNotMatch("fo[oz]", "fog", { extended: true, globstar: globstar, flags: 'g' }); + + // {}: Match a choice of different substrings + assertMatch("foo{bar,baaz}", "foobaaz", { extended: true }); + assertMatch("foo{bar,baaz}", "foobar", { extended: true }); + assertNotMatch("foo{bar,baaz}", "foobuzz", { extended: true }); + assertMatch("foo{bar,b*z}", "foobuzz", { extended: true }); + + // {}: Match a choice of different substrings and RegExp 'g' (regression) + assertMatch("foo{bar,baaz}", "foobaaz", { extended: true, globstar: globstar, flags: 'g' }); + assertMatch("foo{bar,baaz}", "foobar", { extended: true, globstar: globstar, flags: 'g' }); + assertNotMatch("foo{bar,baaz}", "foobuzz", { extended: true, globstar: globstar, flags: 'g' }); + assertMatch("foo{bar,b*z}", "foobuzz", { extended: true, globstar: globstar, flags: 'g' }); + + // More complex extended matches + assertMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://foo.baaz.com/jquery.min.js", + { extended: true }); + assertMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://moz.buzz.com/index.html", + { extended: true }); + assertNotMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://moz.buzz.com/index.htm", + { extended: true }); + assertNotMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://moz.bar.com/index.html", + { extended: true }); + assertNotMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://flozz.buzz.com/index.html", + { extended: true }); + + // More complex extended matches and RegExp 'g' (regresion) + assertMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://foo.baaz.com/jquery.min.js", + { extended: true, globstar: globstar, flags: 'g' }); + assertMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://moz.buzz.com/index.html", + { extended: true, globstar: globstar, flags: 'g' }); + assertNotMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://moz.buzz.com/index.htm", + { extended: true, globstar: globstar, flags: 'g' }); + assertNotMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://moz.bar.com/index.html", + { extended: true, globstar: globstar, flags: 'g' }); + assertNotMatch("http://?o[oz].b*z.com/{*.js,*.html}", + "http://flozz.buzz.com/index.html", + { extended: true, globstar: globstar, flags: 'g' }); + + // globstar + assertMatch("http://foo.com/**/{*.js,*.html}", + "http://foo.com/bar/jquery.min.js", + { extended: true, globstar: globstar, flags: 'g' }); + assertMatch("http://foo.com/**/{*.js,*.html}", + "http://foo.com/bar/baz/jquery.min.js", + { extended: true, globstar: globstar, flags: 'g' }); + assertMatch("http://foo.com/**", + "http://foo.com/bar/baz/jquery.min.js", + { extended: true, globstar: globstar, flags: 'g' }); + + // Remaining special chars should still match themselves + // Test string "\\\\/$^+.()=!|,.*" represents \\/$^+.()=!|,.* + // The equivalent regex is: /^\\\/\$\^\+\.\(\)\=\!\|\,\..*$/ + // Both glob and regex match: \/$^+.()=!|,.* + var testExtStr = "\\\\/$^+.()=!|,.*"; + var targetExtStr = "\\/$^+.()=!|,.*"; + assertMatch(testExtStr, targetExtStr, { extended: true }); + assertMatch(testExtStr, targetExtStr, { extended: true, globstar: globstar, flags: 'g' }); +} + +// regression +// globstar false +test(false) +// globstar true +test(true); + +// globstar specific tests +assertMatch("/foo/*", "/foo/bar.txt", {globstar: true }); +assertMatch("/foo/**", "/foo/baz.txt", {globstar: true }); +assertMatch("/foo/**", "/foo/bar/baz.txt", {globstar: true }); +assertMatch("/foo/*/*.txt", "/foo/bar/baz.txt", {globstar: true }); +assertMatch("/foo/**/*.txt", "/foo/bar/baz.txt", {globstar: true }); +assertMatch("/foo/**/*.txt", "/foo/bar/baz/qux.txt", {globstar: true }); +assertMatch("/foo/**/bar.txt", "/foo/bar.txt", {globstar: true }); +assertMatch("/foo/**/**/bar.txt", "/foo/bar.txt", {globstar: true }); +assertMatch("/foo/**/*/baz.txt", "/foo/bar/baz.txt", {globstar: true }); +assertMatch("/foo/**/*.txt", "/foo/bar.txt", {globstar: true }); +assertMatch("/foo/**/**/*.txt", "/foo/bar.txt", {globstar: true }); +assertMatch("/foo/**/*/*.txt", "/foo/bar/baz.txt", {globstar: true }); +assertMatch("**/*.txt", "/foo/bar/baz/qux.txt", {globstar: true }); +assertMatch("**/foo.txt", "foo.txt", {globstar: true }); +assertMatch("**/*.txt", "foo.txt", {globstar: true }); + +assertNotMatch("/foo/*", "/foo/bar/baz.txt", {globstar: true }); +assertNotMatch("/foo/*.txt", "/foo/bar/baz.txt", {globstar: true }); +assertNotMatch("/foo/*/*.txt", "/foo/bar/baz/qux.txt", {globstar: true }); +assertNotMatch("/foo/*/bar.txt", "/foo/bar.txt", {globstar: true }); +assertNotMatch("/foo/*/*/baz.txt", "/foo/bar/baz.txt", {globstar: true }); +assertNotMatch("/foo/**.txt", "/foo/bar/baz/qux.txt", {globstar: true }); +assertNotMatch("/foo/bar**/*.txt", "/foo/bar/baz/qux.txt", {globstar: true }); +assertNotMatch("/foo/bar**", "/foo/bar/baz.txt", {globstar: true }); +assertNotMatch("**/.txt", "/foo/bar/baz/qux.txt", {globstar: true }); +assertNotMatch("*/*.txt", "/foo/bar/baz/qux.txt", {globstar: true }); +assertNotMatch("*/*.txt", "foo.txt", {globstar: true }); + +assertNotMatch("http://foo.com/*", + "http://foo.com/bar/baz/jquery.min.js", + { extended: true, globstar: true }); +assertNotMatch("http://foo.com/*", + "http://foo.com/bar/baz/jquery.min.js", + { globstar: true }); + +assertMatch("http://foo.com/*", + "http://foo.com/bar/baz/jquery.min.js", + { globstar: false }); +assertMatch("http://foo.com/**", + "http://foo.com/bar/baz/jquery.min.js", + { globstar: true }); + +assertMatch("http://foo.com/*/*/jquery.min.js", + "http://foo.com/bar/baz/jquery.min.js", + { globstar: true }); +assertMatch("http://foo.com/**/jquery.min.js", + "http://foo.com/bar/baz/jquery.min.js", + { globstar: true }); +assertMatch("http://foo.com/*/*/jquery.min.js", + "http://foo.com/bar/baz/jquery.min.js", + { globstar: false }); +assertMatch("http://foo.com/*/jquery.min.js", + "http://foo.com/bar/baz/jquery.min.js", + { globstar: false }); +assertNotMatch("http://foo.com/*/jquery.min.js", + "http://foo.com/bar/baz/jquery.min.js", + { globstar: true }); + +console.log("Ok!"); diff --git a/node_modules/har-schema/LICENSE b/node_modules/har-schema/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..ca55c91af4ec5f1f6a4e2df5e3db25ca689d8bab --- /dev/null +++ b/node_modules/har-schema/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2015, Ahmad Nassri + +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. diff --git a/node_modules/har-schema/README.md b/node_modules/har-schema/README.md new file mode 100644 index 0000000000000000000000000000000000000000..cd0a28e1a722367ab382e84d46b72ffc9f32a8da --- /dev/null +++ b/node_modules/har-schema/README.md @@ -0,0 +1,49 @@ +# HAR Schema [![version][npm-version]][npm-url] [![License][npm-license]][license-url] + +> JSON Schema for HTTP Archive ([HAR][spec]). + +[![Build Status][travis-image]][travis-url] +[![Downloads][npm-downloads]][npm-url] +[![Code Climate][codeclimate-quality]][codeclimate-url] +[![Coverage Status][codeclimate-coverage]][codeclimate-url] +[![Dependency Status][dependencyci-image]][dependencyci-url] +[![Dependencies][david-image]][david-url] + +## Install + +```bash +npm install --only=production --save har-schema +``` + +## Usage + +Compatible with any [JSON Schema validation tool][validator]. + +---- +> :copyright: [ahmadnassri.com](https://www.ahmadnassri.com/)  ·  +> License: [ISC][license-url]  ·  +> Github: [@ahmadnassri](https://github.com/ahmadnassri)  ·  +> Twitter: [@ahmadnassri](https://twitter.com/ahmadnassri) + +[license-url]: http://choosealicense.com/licenses/isc/ + +[travis-url]: https://travis-ci.org/ahmadnassri/har-schema +[travis-image]: https://img.shields.io/travis/ahmadnassri/har-schema.svg?style=flat-square + +[npm-url]: https://www.npmjs.com/package/har-schema +[npm-license]: https://img.shields.io/npm/l/har-schema.svg?style=flat-square +[npm-version]: https://img.shields.io/npm/v/har-schema.svg?style=flat-square +[npm-downloads]: https://img.shields.io/npm/dm/har-schema.svg?style=flat-square + +[codeclimate-url]: https://codeclimate.com/github/ahmadnassri/har-schema +[codeclimate-quality]: https://img.shields.io/codeclimate/github/ahmadnassri/har-schema.svg?style=flat-square +[codeclimate-coverage]: https://img.shields.io/codeclimate/coverage/github/ahmadnassri/har-schema.svg?style=flat-square + +[david-url]: https://david-dm.org/ahmadnassri/har-schema +[david-image]: https://img.shields.io/david/ahmadnassri/har-schema.svg?style=flat-square + +[dependencyci-url]: https://dependencyci.com/github/ahmadnassri/har-schema +[dependencyci-image]: https://dependencyci.com/github/ahmadnassri/har-schema/badge?style=flat-square + +[spec]: https://github.com/ahmadnassri/har-spec/blob/master/versions/1.2.md +[validator]: https://github.com/ahmadnassri/har-validator diff --git a/node_modules/har-schema/lib/afterRequest.json b/node_modules/har-schema/lib/afterRequest.json new file mode 100644 index 0000000000000000000000000000000000000000..5f525815498f07a5fcc04c5baa9888dc2932add2 --- /dev/null +++ b/node_modules/har-schema/lib/afterRequest.json @@ -0,0 +1,30 @@ +{ + "$id": "afterRequest.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "optional": true, + "required": [ + "lastAccess", + "eTag", + "hitCount" + ], + "properties": { + "expires": { + "type": "string", + "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))?" + }, + "lastAccess": { + "type": "string", + "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))?" + }, + "eTag": { + "type": "string" + }, + "hitCount": { + "type": "integer" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/beforeRequest.json b/node_modules/har-schema/lib/beforeRequest.json new file mode 100644 index 0000000000000000000000000000000000000000..c7b5c1016a7b607db4fddf1d7f2eb71d9dbf7594 --- /dev/null +++ b/node_modules/har-schema/lib/beforeRequest.json @@ -0,0 +1,30 @@ +{ + "$id": "beforeRequest.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "optional": true, + "required": [ + "lastAccess", + "eTag", + "hitCount" + ], + "properties": { + "expires": { + "type": "string", + "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))?" + }, + "lastAccess": { + "type": "string", + "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))?" + }, + "eTag": { + "type": "string" + }, + "hitCount": { + "type": "integer" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/browser.json b/node_modules/har-schema/lib/browser.json new file mode 100644 index 0000000000000000000000000000000000000000..d6869f75ac483d68d834d258764a3ad15e7c63c8 --- /dev/null +++ b/node_modules/har-schema/lib/browser.json @@ -0,0 +1,20 @@ +{ + "$id": "browser.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "name", + "version" + ], + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/cache.json b/node_modules/har-schema/lib/cache.json new file mode 100644 index 0000000000000000000000000000000000000000..30a7182eb900508777eee8f5f6fa300429148e67 --- /dev/null +++ b/node_modules/har-schema/lib/cache.json @@ -0,0 +1,21 @@ +{ + "$id": "cache.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "properties": { + "beforeRequest": { + "oneOf": [ + { "type": "null" }, + { "$ref": "beforeRequest.json#" } + ] + }, + "afterRequest": { + "oneOf": [ + { "type": "null" }, + { "$ref": "afterRequest.json#" } + ] + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/content.json b/node_modules/har-schema/lib/content.json new file mode 100644 index 0000000000000000000000000000000000000000..43944bfa18f4739a58e4875b5baad13fac3f3306 --- /dev/null +++ b/node_modules/har-schema/lib/content.json @@ -0,0 +1,29 @@ +{ + "$id": "content.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "size", + "mimeType" + ], + "properties": { + "size": { + "type": "integer" + }, + "compression": { + "type": "integer" + }, + "mimeType": { + "type": "string" + }, + "text": { + "type": "string" + }, + "encoding": { + "type": "string" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/cookie.json b/node_modules/har-schema/lib/cookie.json new file mode 100644 index 0000000000000000000000000000000000000000..661f7f32aca1a43ad33c691abba4f6ebde9366c6 --- /dev/null +++ b/node_modules/har-schema/lib/cookie.json @@ -0,0 +1,36 @@ +{ + "$id": "cookie.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "path": { + "type": "string" + }, + "domain": { + "type": "string" + }, + "expires": { + "type": ["string", "null"], + "format": "date-time" + }, + "httpOnly": { + "type": "boolean" + }, + "secure": { + "type": "boolean" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/creator.json b/node_modules/har-schema/lib/creator.json new file mode 100644 index 0000000000000000000000000000000000000000..71a75cd41434a11c0cb9042393b166b27a153f60 --- /dev/null +++ b/node_modules/har-schema/lib/creator.json @@ -0,0 +1,20 @@ +{ + "$id": "creator.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "name", + "version" + ], + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/entry.json b/node_modules/har-schema/lib/entry.json new file mode 100644 index 0000000000000000000000000000000000000000..18025f4337341a75a95a22ae476c7f3b79d7794e --- /dev/null +++ b/node_modules/har-schema/lib/entry.json @@ -0,0 +1,53 @@ +{ + "$id": "entry.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "optional": true, + "required": [ + "startedDateTime", + "time", + "request", + "response", + "cache", + "timings" + ], + "properties": { + "pageref": { + "type": "string" + }, + "startedDateTime": { + "type": "string", + "format": "date-time", + "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))" + }, + "time": { + "type": "number", + "min": 0 + }, + "request": { + "$ref": "request.json#" + }, + "response": { + "$ref": "response.json#" + }, + "cache": { + "$ref": "cache.json#" + }, + "timings": { + "$ref": "timings.json#" + }, + "serverIPAddress": { + "type": "string", + "oneOf": [ + { "format": "ipv4" }, + { "format": "ipv6" } + ] + }, + "connection": { + "type": "string" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/har.json b/node_modules/har-schema/lib/har.json new file mode 100644 index 0000000000000000000000000000000000000000..d1a1de551c4cb333cb3d65b8c43e5b9e2d36f758 --- /dev/null +++ b/node_modules/har-schema/lib/har.json @@ -0,0 +1,13 @@ +{ + "$id": "har.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "log" + ], + "properties": { + "log": { + "$ref": "log.json#" + } + } +} diff --git a/node_modules/har-schema/lib/header.json b/node_modules/har-schema/lib/header.json new file mode 100644 index 0000000000000000000000000000000000000000..103d949a33b50044f99fc7d1f8eedc7f25908fd9 --- /dev/null +++ b/node_modules/har-schema/lib/header.json @@ -0,0 +1,20 @@ +{ + "$id": "header.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/index.js b/node_modules/har-schema/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..244c08e04e23cbd27c1f5f7488c8371a9a3118e1 --- /dev/null +++ b/node_modules/har-schema/lib/index.js @@ -0,0 +1,22 @@ +'use strict' + +module.exports = { + afterRequest: require('./afterRequest.json'), + beforeRequest: require('./beforeRequest.json'), + browser: require('./browser.json'), + cache: require('./cache.json'), + content: require('./content.json'), + cookie: require('./cookie.json'), + creator: require('./creator.json'), + entry: require('./entry.json'), + har: require('./har.json'), + header: require('./header.json'), + log: require('./log.json'), + page: require('./page.json'), + pageTimings: require('./pageTimings.json'), + postData: require('./postData.json'), + query: require('./query.json'), + request: require('./request.json'), + response: require('./response.json'), + timings: require('./timings.json') +} diff --git a/node_modules/har-schema/lib/log.json b/node_modules/har-schema/lib/log.json new file mode 100644 index 0000000000000000000000000000000000000000..c353b40f13d24ae58f4e39276ddcfa4027676af4 --- /dev/null +++ b/node_modules/har-schema/lib/log.json @@ -0,0 +1,36 @@ +{ + "$id": "log.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "version", + "creator", + "entries" + ], + "properties": { + "version": { + "type": "string" + }, + "creator": { + "$ref": "creator.json#" + }, + "browser": { + "$ref": "browser.json#" + }, + "pages": { + "type": "array", + "items": { + "$ref": "page.json#" + } + }, + "entries": { + "type": "array", + "items": { + "$ref": "entry.json#" + } + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/page.json b/node_modules/har-schema/lib/page.json new file mode 100644 index 0000000000000000000000000000000000000000..e24a3cee68aec526975e6381f2497ef232a69cbf --- /dev/null +++ b/node_modules/har-schema/lib/page.json @@ -0,0 +1,32 @@ +{ + "$id": "page.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "optional": true, + "required": [ + "startedDateTime", + "id", + "title", + "pageTimings" + ], + "properties": { + "startedDateTime": { + "type": "string", + "format": "date-time", + "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))" + }, + "id": { + "type": "string", + "unique": true + }, + "title": { + "type": "string" + }, + "pageTimings": { + "$ref": "pageTimings.json#" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/pageTimings.json b/node_modules/har-schema/lib/pageTimings.json new file mode 100644 index 0000000000000000000000000000000000000000..130411fee6a2fca9d9ab09558ca5bca13ba72376 --- /dev/null +++ b/node_modules/har-schema/lib/pageTimings.json @@ -0,0 +1,18 @@ +{ + "$id": "pageTimings.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "properties": { + "onContentLoad": { + "type": "number", + "min": -1 + }, + "onLoad": { + "type": "number", + "min": -1 + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/postData.json b/node_modules/har-schema/lib/postData.json new file mode 100644 index 0000000000000000000000000000000000000000..3aa6294a43a79f148ff2fddc3cc899ac3749534e --- /dev/null +++ b/node_modules/har-schema/lib/postData.json @@ -0,0 +1,43 @@ +{ + "$id": "postData.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "optional": true, + "required": [ + "mimeType" + ], + "properties": { + "mimeType": { + "type": "string" + }, + "text": { + "type": "string" + }, + "params": { + "type": "array", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "comment": { + "type": "string" + } + } + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/query.json b/node_modules/har-schema/lib/query.json new file mode 100644 index 0000000000000000000000000000000000000000..f82d8d8dac1a20f39849bb8ed900e26829fbc42b --- /dev/null +++ b/node_modules/har-schema/lib/query.json @@ -0,0 +1,20 @@ +{ + "$id": "query.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/request.json b/node_modules/har-schema/lib/request.json new file mode 100644 index 0000000000000000000000000000000000000000..0e2566dedc207247a54296c854c8cdadec410f6b --- /dev/null +++ b/node_modules/har-schema/lib/request.json @@ -0,0 +1,57 @@ +{ + "$id": "request.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "method", + "url", + "httpVersion", + "cookies", + "headers", + "queryString", + "headersSize", + "bodySize" + ], + "properties": { + "method": { + "type": "string" + }, + "url": { + "type": "string", + "format": "uri" + }, + "httpVersion": { + "type": "string" + }, + "cookies": { + "type": "array", + "items": { + "$ref": "cookie.json#" + } + }, + "headers": { + "type": "array", + "items": { + "$ref": "header.json#" + } + }, + "queryString": { + "type": "array", + "items": { + "$ref": "query.json#" + } + }, + "postData": { + "$ref": "postData.json#" + }, + "headersSize": { + "type": "integer" + }, + "bodySize": { + "type": "integer" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/response.json b/node_modules/har-schema/lib/response.json new file mode 100644 index 0000000000000000000000000000000000000000..ec30f802bac6e8370bc6e231a8af446d31f1e41f --- /dev/null +++ b/node_modules/har-schema/lib/response.json @@ -0,0 +1,54 @@ +{ + "$id": "response.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "status", + "statusText", + "httpVersion", + "cookies", + "headers", + "content", + "redirectURL", + "headersSize", + "bodySize" + ], + "properties": { + "status": { + "type": "integer" + }, + "statusText": { + "type": "string" + }, + "httpVersion": { + "type": "string" + }, + "cookies": { + "type": "array", + "items": { + "$ref": "cookie.json#" + } + }, + "headers": { + "type": "array", + "items": { + "$ref": "header.json#" + } + }, + "content": { + "$ref": "content.json#" + }, + "redirectURL": { + "type": "string" + }, + "headersSize": { + "type": "integer" + }, + "bodySize": { + "type": "integer" + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/lib/timings.json b/node_modules/har-schema/lib/timings.json new file mode 100644 index 0000000000000000000000000000000000000000..5fe7dc7a5e829b205e43db30cf9dde6f302e5297 --- /dev/null +++ b/node_modules/har-schema/lib/timings.json @@ -0,0 +1,42 @@ +{ + "$id": "timings.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "required": [ + "send", + "wait", + "receive" + ], + "properties": { + "dns": { + "type": "number", + "min": -1 + }, + "connect": { + "type": "number", + "min": -1 + }, + "blocked": { + "type": "number", + "min": -1 + }, + "send": { + "type": "number", + "min": -1 + }, + "wait": { + "type": "number", + "min": -1 + }, + "receive": { + "type": "number", + "min": -1 + }, + "ssl": { + "type": "number", + "min": -1 + }, + "comment": { + "type": "string" + } + } +} diff --git a/node_modules/har-schema/package.json b/node_modules/har-schema/package.json new file mode 100644 index 0000000000000000000000000000000000000000..d14650bd78261de27b7e89ae0f6215f3db3e7499 --- /dev/null +++ b/node_modules/har-schema/package.json @@ -0,0 +1,54 @@ +{ + "version": "2.0.0", + "name": "har-schema", + "description": "JSON Schema for HTTP Archive (HAR)", + "author": "Ahmad Nassri (https://www.ahmadnassri.com/)", + "contributors": [ + "Evgeny Poberezkin " + ], + "homepage": "https://github.com/ahmadnassri/har-schema", + "repository": { + "type": "git", + "url": "https://github.com/ahmadnassri/har-schema.git" + }, + "license": "ISC", + "main": "lib/index.js", + "keywords": [ + "har", + "http", + "archive", + "JSON", + "schema", + "JSON-schema" + ], + "engines": { + "node": ">=4" + }, + "files": [ + "lib" + ], + "bugs": { + "url": "https://github.com/ahmadnassri/har-schema/issues" + }, + "scripts": { + "test": "tap test --reporter spec", + "pretest": "snazzy && echint", + "coverage": "tap test --reporter silent --coverage", + "codeclimate": "tap --coverage-report=text-lcov | codeclimate-test-reporter", + "semantic-release": "semantic-release pre && npm publish && semantic-release post" + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } + }, + "devDependencies": { + "ajv": "^5.0.0", + "codeclimate-test-reporter": "^0.4.0", + "cz-conventional-changelog": "^1.2.0", + "echint": "^2.1.0", + "semantic-release": "^6.3.2", + "snazzy": "^5.0.0", + "tap": "^8.0.1" + } +} \ No newline at end of file diff --git a/node_modules/har-validator/LICENSE b/node_modules/har-validator/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..a54526625e0240d01899d0942f17753d60c20744 --- /dev/null +++ b/node_modules/har-validator/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2018 Ahmad Nassri + +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. diff --git a/node_modules/har-validator/README.md b/node_modules/har-validator/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ea944cc5c7bd89cbf111d5602a3a4bf87478c5e6 --- /dev/null +++ b/node_modules/har-validator/README.md @@ -0,0 +1,43 @@ +# HAR Validator + +[![license][license-img]][license-url] +[![version][npm-img]][npm-url] +[![super linter][super-linter-img]][super-linter-url] +[![test][test-img]][test-url] +[![release][release-img]][release-url] + +[license-url]: LICENSE +[license-img]: https://badgen.net/github/license/ahmadnassri/node-har-validator + +[npm-url]: https://www.npmjs.com/package/har-validator +[npm-img]: https://badgen.net/npm/v/har-validator + +[super-linter-url]: https://github.com/ahmadnassri/node-har-validator/actions?query=workflow%3Asuper-linter +[super-linter-img]: https://github.com/ahmadnassri/node-har-validator/workflows/super-linter/badge.svg + +[test-url]: https://github.com/ahmadnassri/node-har-validator/actions?query=workflow%3Atest +[test-img]: https://github.com/ahmadnassri/node-har-validator/workflows/test/badge.svg + +[release-url]: https://github.com/ahmadnassri/node-har-validator/actions?query=workflow%3Arelease +[release-img]: https://github.com/ahmadnassri/node-har-validator/workflows/release/badge.svg + +> Extremely fast HTTP Archive ([HAR](https://github.com/ahmadnassri/har-spec/blob/master/versions/1.2.md)) validator using JSON Schema. + +## Install + +```bash +npm install har-validator +``` + +## CLI Usage + +Please refer to [`har-cli`](https://github.com/ahmadnassri/har-cli) for more info. + +## API + +**Note**: as of [`v2.0.0`](https://github.com/ahmadnassri/node-har-validator/releases/tag/v2.0.0) this module defaults to Promise based API. +_For backward compatibility with `v1.x` an [async/callback API](docs/async.md) is also provided_ + +- [async API](docs/async.md) +- [callback API](docs/async.md) +- [Promise API](docs/promise.md) _(default)_ diff --git a/node_modules/har-validator/lib/async.js b/node_modules/har-validator/lib/async.js new file mode 100644 index 0000000000000000000000000000000000000000..90701f253f71ed60cedb82e3032853bd01154f57 --- /dev/null +++ b/node_modules/har-validator/lib/async.js @@ -0,0 +1,105 @@ +var Ajv = require('ajv') +var HARError = require('./error') +var schemas = require('har-schema') + +var ajv + +function createAjvInstance () { + var ajv = new Ajv({ + allErrors: true + }) + ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')) + ajv.addSchema(schemas) + + return ajv +} + +function validate (name, data, next) { + data = data || {} + + // validator config + ajv = ajv || createAjvInstance() + + var validate = ajv.getSchema(name + '.json') + + var valid = validate(data) + + // callback? + if (typeof next === 'function') { + return next(!valid ? new HARError(validate.errors) : null, valid) + } + + return valid +} + +exports.afterRequest = function (data, next) { + return validate('afterRequest', data, next) +} + +exports.beforeRequest = function (data, next) { + return validate('beforeRequest', data, next) +} + +exports.browser = function (data, next) { + return validate('browser', data, next) +} + +exports.cache = function (data, next) { + return validate('cache', data, next) +} + +exports.content = function (data, next) { + return validate('content', data, next) +} + +exports.cookie = function (data, next) { + return validate('cookie', data, next) +} + +exports.creator = function (data, next) { + return validate('creator', data, next) +} + +exports.entry = function (data, next) { + return validate('entry', data, next) +} + +exports.har = function (data, next) { + return validate('har', data, next) +} + +exports.header = function (data, next) { + return validate('header', data, next) +} + +exports.log = function (data, next) { + return validate('log', data, next) +} + +exports.page = function (data, next) { + return validate('page', data, next) +} + +exports.pageTimings = function (data, next) { + return validate('pageTimings', data, next) +} + +exports.postData = function (data, next) { + return validate('postData', data, next) +} + +exports.query = function (data, next) { + return validate('query', data, next) +} + +exports.request = function (data, next) { + return validate('request', data, next) +} + +exports.response = function (data, next) { + return validate('response', data, next) +} + +exports.timings = function (data, next) { + return validate('timings', data, next) +} diff --git a/node_modules/har-validator/lib/error.js b/node_modules/har-validator/lib/error.js new file mode 100644 index 0000000000000000000000000000000000000000..f2618dc4f3c44ac7670e4111df90efe94ff1a876 --- /dev/null +++ b/node_modules/har-validator/lib/error.js @@ -0,0 +1,17 @@ +function HARError (errors) { + var message = 'validation failed' + + this.name = 'HARError' + this.message = message + this.errors = errors + + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor) + } else { + this.stack = (new Error(message)).stack + } +} + +HARError.prototype = Error.prototype + +module.exports = HARError diff --git a/node_modules/har-validator/lib/promise.js b/node_modules/har-validator/lib/promise.js new file mode 100644 index 0000000000000000000000000000000000000000..46f46479786fa32abff3e93a8dac7820f59c33cb --- /dev/null +++ b/node_modules/har-validator/lib/promise.js @@ -0,0 +1,102 @@ +var Ajv = require('ajv') +var HARError = require('./error') +var schemas = require('har-schema') + +var ajv + +function createAjvInstance () { + var ajv = new Ajv({ + allErrors: true + }) + ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')) + ajv.addSchema(schemas) + + return ajv +} + +function validate (name, data) { + data = data || {} + + // validator config + ajv = ajv || createAjvInstance() + + var validate = ajv.getSchema(name + '.json') + + return new Promise(function (resolve, reject) { + var valid = validate(data) + + !valid ? reject(new HARError(validate.errors)) : resolve(data) + }) +} + +exports.afterRequest = function (data) { + return validate('afterRequest', data) +} + +exports.beforeRequest = function (data) { + return validate('beforeRequest', data) +} + +exports.browser = function (data) { + return validate('browser', data) +} + +exports.cache = function (data) { + return validate('cache', data) +} + +exports.content = function (data) { + return validate('content', data) +} + +exports.cookie = function (data) { + return validate('cookie', data) +} + +exports.creator = function (data) { + return validate('creator', data) +} + +exports.entry = function (data) { + return validate('entry', data) +} + +exports.har = function (data) { + return validate('har', data) +} + +exports.header = function (data) { + return validate('header', data) +} + +exports.log = function (data) { + return validate('log', data) +} + +exports.page = function (data) { + return validate('page', data) +} + +exports.pageTimings = function (data) { + return validate('pageTimings', data) +} + +exports.postData = function (data) { + return validate('postData', data) +} + +exports.query = function (data) { + return validate('query', data) +} + +exports.request = function (data) { + return validate('request', data) +} + +exports.response = function (data) { + return validate('response', data) +} + +exports.timings = function (data) { + return validate('timings', data) +} diff --git a/node_modules/har-validator/package.json b/node_modules/har-validator/package.json new file mode 100644 index 0000000000000000000000000000000000000000..8d1eed1798f9108d3a4472ab0b6b15182c6bfd03 --- /dev/null +++ b/node_modules/har-validator/package.json @@ -0,0 +1,43 @@ +{ + "version": "5.1.5", + "name": "har-validator", + "description": "Extremely fast HTTP Archive (HAR) validator using JSON Schema", + "author": "Ahmad Nassri (https://www.ahmadnassri.com/)", + "homepage": "https://github.com/ahmadnassri/node-har-validator", + "repository": { + "type": "git", + "url": "https://github.com/ahmadnassri/node-har-validator.git" + }, + "license": "MIT", + "main": "lib/promise.js", + "keywords": [ + "har", + "cli", + "ajv", + "http", + "archive", + "validate", + "validator" + ], + "engines": { + "node": ">=6" + }, + "files": [ + "lib" + ], + "bugs": { + "url": "https://github.com/ahmadnassri/node-har-validator/issues" + }, + "scripts": { + "lint": "npx run-p lint:*", + "test": "tap test --no-coverage", + "test:coverage": "tap test --coverage-report=lcov --no-browser" + }, + "devDependencies": { + "tap": "^14.10.8" + }, + "dependencies": { + "ajv": "^6.12.3", + "har-schema": "^2.0.0" + } +} diff --git a/node_modules/has-property-descriptors/.eslintrc b/node_modules/has-property-descriptors/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..2fcc002b0a7f59de19f8b130d5b09bfeb99124a6 --- /dev/null +++ b/node_modules/has-property-descriptors/.eslintrc @@ -0,0 +1,13 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "func-name-matching": 0, + "id-length": 0, + "new-cap": [2, { + "capIsNewExceptions": ["GetIntrinsic"], + }], + }, +} diff --git a/node_modules/has-property-descriptors/.github/FUNDING.yml b/node_modules/has-property-descriptors/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..817aacf1f4268093d88f152efd214e45ef6a7bc7 --- /dev/null +++ b/node_modules/has-property-descriptors/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/has-property-descriptors +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/has-property-descriptors/.nycrc b/node_modules/has-property-descriptors/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/has-property-descriptors/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/has-property-descriptors/CHANGELOG.md b/node_modules/has-property-descriptors/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..2cec99c888a010d43f80359ad1a9c49faab34266 --- /dev/null +++ b/node_modules/has-property-descriptors/CHANGELOG.md @@ -0,0 +1,27 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.1](https://github.com/inspect-js/has-property-descriptors/compare/v1.0.0...v1.0.1) - 2023-10-20 + +### Commits + +- [meta] use `npmignore` to autogenerate an npmignore file [`5bbf4da`](https://github.com/inspect-js/has-property-descriptors/commit/5bbf4dae1b58950d87bb3af508bee7513e640868) +- [actions] update rebase action to use reusable workflow [`3a5585b`](https://github.com/inspect-js/has-property-descriptors/commit/3a5585bf74988f71a8f59e67a07d594e62c51fd8) +- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`e5c1212`](https://github.com/inspect-js/has-property-descriptors/commit/e5c1212048a8fda549794c47863724ca60b89cae) +- [Dev Deps] update `aud`, `tape` [`e942917`](https://github.com/inspect-js/has-property-descriptors/commit/e942917b6c2f7c090d5623048989cf20d0834ebf) +- [Deps] update `get-intrinsic` [`f4a44ec`](https://github.com/inspect-js/has-property-descriptors/commit/f4a44ec6d94146fa6c550d3c15c31a2062c83ef4) +- [Deps] update `get-intrinsic` [`eeb275b`](https://github.com/inspect-js/has-property-descriptors/commit/eeb275b473e5d72ca843b61ca25cfcb06a5d4300) + +## v1.0.0 - 2022-04-14 + +### Commits + +- Initial implementation, tests [`303559f`](https://github.com/inspect-js/has-property-descriptors/commit/303559f2a72dfe7111573a1aec475ed4a184c35a) +- Initial commit [`3a7ca2d`](https://github.com/inspect-js/has-property-descriptors/commit/3a7ca2dc49f1fff0279a28bb16265e7615e14749) +- read me [`dd73dce`](https://github.com/inspect-js/has-property-descriptors/commit/dd73dce09d89d0f7a4a6e3b1e562a506f979a767) +- npm init [`c1e6557`](https://github.com/inspect-js/has-property-descriptors/commit/c1e655779de632d68cb944c50da6b71bcb7b8c85) +- Only apps should have lockfiles [`e72f7c6`](https://github.com/inspect-js/has-property-descriptors/commit/e72f7c68de534b2d273ee665f8b18d4ecc7f70b0) diff --git a/node_modules/has-property-descriptors/LICENSE b/node_modules/has-property-descriptors/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..2e7b9a3eacf263cb418f4c16b087290ef78c39b2 --- /dev/null +++ b/node_modules/has-property-descriptors/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Inspect JS + +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. diff --git a/node_modules/has-property-descriptors/README.md b/node_modules/has-property-descriptors/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d81fbd99e91a3ec97fc930ffb985819dacae39a6 --- /dev/null +++ b/node_modules/has-property-descriptors/README.md @@ -0,0 +1,43 @@ +# has-property-descriptors [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Does the environment have full property descriptor support? Handles IE 8's broken defineProperty/gOPD. + +## Example + +```js +var hasPropertyDescriptors = require('has-property-descriptors'); +var assert = require('assert'); + +assert.equal(hasPropertyDescriptors(), true); // will be `false` in IE 6-8, and ES5 engines + +// Arrays can not have their length `[[Defined]]` in some engines +assert.equal(hasPropertyDescriptors.hasArrayLengthDefineBug(), false); // will be `true` in Firefox 4-22, and node v0.6 +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/has-property-descriptors +[npm-version-svg]: https://versionbadg.es/inspect-js/has-property-descriptors.svg +[deps-svg]: https://david-dm.org/inspect-js/has-property-descriptors.svg +[deps-url]: https://david-dm.org/inspect-js/has-property-descriptors +[dev-deps-svg]: https://david-dm.org/inspect-js/has-property-descriptors/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/has-property-descriptors#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/has-property-descriptors.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/has-property-descriptors.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/has-property-descriptors.svg +[downloads-url]: https://npm-stat.com/charts.html?package=has-property-descriptors +[codecov-image]: https://codecov.io/gh/inspect-js/has-property-descriptors/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/has-property-descriptors/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/has-property-descriptors +[actions-url]: https://github.com/inspect-js/has-property-descriptors/actions diff --git a/node_modules/has-property-descriptors/index.js b/node_modules/has-property-descriptors/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8e30683e39e98ba72620f9dacb6d58af6176cea2 --- /dev/null +++ b/node_modules/has-property-descriptors/index.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); + +var hasPropertyDescriptors = function hasPropertyDescriptors() { + if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + return true; + } catch (e) { + // IE 8 has a broken defineProperty + return false; + } + } + return false; +}; + +hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() { + // node v0.6 has a bug where array lengths can be Set but not Defined + if (!hasPropertyDescriptors()) { + return null; + } + try { + return $defineProperty([], 'length', { value: 1 }).length !== 1; + } catch (e) { + // In Firefox 4-22, defining length on an array throws an exception. + return true; + } +}; + +module.exports = hasPropertyDescriptors; diff --git a/node_modules/has-property-descriptors/package.json b/node_modules/has-property-descriptors/package.json new file mode 100644 index 0000000000000000000000000000000000000000..831e0184fa04a1c30f46dd65fabfeb57801c3303 --- /dev/null +++ b/node_modules/has-property-descriptors/package.json @@ -0,0 +1,77 @@ +{ + "name": "has-property-descriptors", + "version": "1.0.1", + "description": "Does the environment have full property descriptor support? Handles IE 8's broken defineProperty/gOPD.", + "main": "index.js", + "exports": { + ".": "./index.js", + "./package.json": "./package.json" + }, + "sideEffects": false, + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated", + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "pretest": "npm run lint", + "prelint": "evalmd README.md", + "lint": "eslint --ext=js,mjs .", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/inspect-js/has-property-descriptors.git" + }, + "keywords": [ + "property", + "descriptors", + "has", + "environment", + "env", + "defineProperty", + "getOwnPropertyDescriptor" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/has-property-descriptors/issues" + }, + "homepage": "https://github.com/inspect-js/has-property-descriptors#readme", + "devDependencies": { + "@ljharb/eslint-config": "^21.1.0", + "aud": "^2.0.3", + "auto-changelog": "^2.4.0", + "eslint": "=8.8.0", + "evalmd": "^0.0.19", + "in-publish": "^2.0.1", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "safe-publish-latest": "^2.0.0", + "tape": "^5.7.2" + }, + "dependencies": { + "get-intrinsic": "^1.2.2" + }, + "testling": { + "files": "test/index.js" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] + } +} diff --git a/node_modules/has-property-descriptors/test/index.js b/node_modules/has-property-descriptors/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7f02bd3e68e63a7e8ff2ee3016a57dfe35463918 --- /dev/null +++ b/node_modules/has-property-descriptors/test/index.js @@ -0,0 +1,57 @@ +'use strict'; + +var test = require('tape'); + +var hasPropertyDescriptors = require('../'); + +var sentinel = {}; + +test('hasPropertyDescriptors', function (t) { + t.equal(typeof hasPropertyDescriptors, 'function', 'is a function'); + t.equal(typeof hasPropertyDescriptors.hasArrayLengthDefineBug, 'function', '`hasArrayLengthDefineBug` property is a function'); + + var yes = hasPropertyDescriptors(); + t.test('property descriptors', { skip: !yes }, function (st) { + var o = { a: sentinel }; + + st.deepEqual( + Object.getOwnPropertyDescriptor(o, 'a'), + { + configurable: true, + enumerable: true, + value: sentinel, + writable: true + }, + 'has expected property descriptor' + ); + + Object.defineProperty(o, 'a', { enumerable: false, writable: false }); + + st.deepEqual( + Object.getOwnPropertyDescriptor(o, 'a'), + { + configurable: true, + enumerable: false, + value: sentinel, + writable: false + }, + 'has expected property descriptor after [[Define]]' + ); + + st.end(); + }); + + var arrayBug = hasPropertyDescriptors.hasArrayLengthDefineBug(); + t.test('defining array lengths', { skip: !yes || arrayBug }, function (st) { + var arr = [1, , 3]; // eslint-disable-line no-sparse-arrays + st.equal(arr.length, 3, 'array starts with length 3'); + + Object.defineProperty(arr, 'length', { value: 5 }); + + st.equal(arr.length, 5, 'array ends with length 5'); + + st.end(); + }); + + t.end(); +}); diff --git a/node_modules/has-proto/.eslintrc b/node_modules/has-proto/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..3b5d9e90ec405f85dd7f9066656efccc51193697 --- /dev/null +++ b/node_modules/has-proto/.eslintrc @@ -0,0 +1,5 @@ +{ + "root": true, + + "extends": "@ljharb", +} diff --git a/node_modules/has-proto/.github/FUNDING.yml b/node_modules/has-proto/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..613705c7eb37d52c2ab1c67862b167714b9b2f57 --- /dev/null +++ b/node_modules/has-proto/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/has-proto +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/has-proto/CHANGELOG.md b/node_modules/has-proto/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..c350e809bf94c881458159502e30600ddb081a51 --- /dev/null +++ b/node_modules/has-proto/CHANGELOG.md @@ -0,0 +1,23 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.1](https://github.com/inspect-js/has-proto/compare/v1.0.0...v1.0.1) - 2022-12-21 + +### Commits + +- [meta] correct URLs and description [`ef34483`](https://github.com/inspect-js/has-proto/commit/ef34483ca0d35680f271b6b96e35526151b25dfc) +- [patch] add an additional criteria [`e81959e`](https://github.com/inspect-js/has-proto/commit/e81959ed7c7a77fbf459f00cb4ef824f1099497f) +- [Dev Deps] update `aud` [`2bec2c4`](https://github.com/inspect-js/has-proto/commit/2bec2c47b072b122ff5443fba0263f6dc649531f) + +## v1.0.0 - 2022-12-12 + +### Commits + +- Initial implementation, tests, readme [`6886fea`](https://github.com/inspect-js/has-proto/commit/6886fea578f67daf69a7920b2eb7637ea6ebb0bc) +- Initial commit [`99129c8`](https://github.com/inspect-js/has-proto/commit/99129c8f42471ac89cb681ba9cb9d52a583eb94f) +- npm init [`2844ad8`](https://github.com/inspect-js/has-proto/commit/2844ad8e75b84d66a46765b3bab9d2e8ea692e10) +- Only apps should have lockfiles [`c65bc5e`](https://github.com/inspect-js/has-proto/commit/c65bc5e40b9004463f7336d47c67245fb139a36a) diff --git a/node_modules/has-proto/LICENSE b/node_modules/has-proto/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..2e7b9a3eacf263cb418f4c16b087290ef78c39b2 --- /dev/null +++ b/node_modules/has-proto/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Inspect JS + +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. diff --git a/node_modules/has-proto/README.md b/node_modules/has-proto/README.md new file mode 100644 index 0000000000000000000000000000000000000000..145676547c24d5f7a2da6ee82a1b78fe272f0326 --- /dev/null +++ b/node_modules/has-proto/README.md @@ -0,0 +1,38 @@ +# has-proto [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Does this environment have the ability to set the [[Prototype]] of an object on creation with `__proto__`? + +## Example + +```js +var hasProto = require('has-proto'); +var assert = require('assert'); + +assert.equal(typeof hasProto(), 'boolean'); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/has-proto +[npm-version-svg]: https://versionbadg.es/inspect-js/has-proto.svg +[deps-svg]: https://david-dm.org/inspect-js/has-proto.svg +[deps-url]: https://david-dm.org/inspect-js/has-proto +[dev-deps-svg]: https://david-dm.org/inspect-js/has-proto/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/has-proto#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/has-proto.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/has-proto.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/has-proto.svg +[downloads-url]: https://npm-stat.com/charts.html?package=has-proto +[codecov-image]: https://codecov.io/gh/inspect-js/has-proto/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/has-proto/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/has-proto +[actions-url]: https://github.com/inspect-js/has-proto/actions diff --git a/node_modules/has-proto/index.js b/node_modules/has-proto/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d3e4be4ebfe44ef960b3911a7f9af9fef209fa5f --- /dev/null +++ b/node_modules/has-proto/index.js @@ -0,0 +1,11 @@ +'use strict'; + +var test = { + foo: {} +}; + +var $Object = Object; + +module.exports = function hasProto() { + return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object); +}; diff --git a/node_modules/has-proto/package.json b/node_modules/has-proto/package.json new file mode 100644 index 0000000000000000000000000000000000000000..706f9510dd13ef06b427eb1021fcbfb9997fb17b --- /dev/null +++ b/node_modules/has-proto/package.json @@ -0,0 +1,74 @@ +{ + "name": "has-proto", + "version": "1.0.1", + "description": "Does this environment have the ability to get the [[Prototype]] of an object on creation with `__proto__`?", + "main": "index.js", + "exports": { + ".": "./index.js", + "./package.json": "./package.json" + }, + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated", + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "lint": "eslint --ext=js,mjs .", + "pretest": "npm run lint", + "tests-only": "tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/inspect-js/has-proto.git" + }, + "keywords": [ + "prototype", + "proto", + "set", + "get", + "__proto__", + "getPrototypeOf", + "setPrototypeOf", + "has" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/has-proto/issues" + }, + "homepage": "https://github.com/inspect-js/has-proto#readme", + "testling": { + "files": "test/index.js" + }, + "devDependencies": { + "@ljharb/eslint-config": "^21.0.0", + "aud": "^2.0.2", + "auto-changelog": "^2.4.0", + "eslint": "=8.8.0", + "in-publish": "^2.0.1", + "npmignore": "^0.3.0", + "safe-publish-latest": "^2.0.0", + "tape": "^5.6.1" + }, + "engines": { + "node": ">= 0.4" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] + } +} diff --git a/node_modules/has-proto/test/index.js b/node_modules/has-proto/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5da1a3aa6c686463071db25151aa4d2683d5dc5a --- /dev/null +++ b/node_modules/has-proto/test/index.js @@ -0,0 +1,19 @@ +'use strict'; + +var test = require('tape'); +var hasProto = require('../'); + +test('hasProto', function (t) { + var result = hasProto(); + t.equal(typeof result, 'boolean', 'returns a boolean (' + result + ')'); + + var obj = { __proto__: null }; + if (result) { + t.notOk('toString' in obj, 'null object lacks toString'); + } else { + t.ok('toString' in obj, 'without proto, null object has toString'); + t.equal(obj.__proto__, null); // eslint-disable-line no-proto + } + + t.end(); +}); diff --git a/node_modules/has-tostringtag/.eslintrc b/node_modules/has-tostringtag/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..2d9a66a8acdbacede413918d9c0c8eaaacee7457 --- /dev/null +++ b/node_modules/has-tostringtag/.eslintrc @@ -0,0 +1,11 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "max-statements-per-line": [2, { "max": 2 }], + "no-magic-numbers": 0, + "multiline-comment-style": 0, + } +} diff --git a/node_modules/has-tostringtag/.github/FUNDING.yml b/node_modules/has-tostringtag/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..7a450e70826f140f9e92de4b5bc6967db78eafca --- /dev/null +++ b/node_modules/has-tostringtag/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/has-tostringtag +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/has-tostringtag/CHANGELOG.md b/node_modules/has-tostringtag/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..39fb77cf7dbc2d7933e45e5c34cdfcdd35880099 --- /dev/null +++ b/node_modules/has-tostringtag/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## v1.0.0 - 2021-08-05 + +### Commits + +- Tests [`6b6f573`](https://github.com/inspect-js/has-tostringtag/commit/6b6f5734dc2058badb300ff0783efdad95fe1a65) +- Initial commit [`2f8190e`](https://github.com/inspect-js/has-tostringtag/commit/2f8190e799fac32ba9b95a076c0255e01d7ce475) +- [meta] do not publish github action workflow files [`6e08cc4`](https://github.com/inspect-js/has-tostringtag/commit/6e08cc4e0fea7ec71ef66e70734b2af2c4a8b71b) +- readme [`94bed6c`](https://github.com/inspect-js/has-tostringtag/commit/94bed6c9560cbbfda034f8d6c260bb7b0db33c1a) +- npm init [`be67840`](https://github.com/inspect-js/has-tostringtag/commit/be67840ab92ee7adb98bcc65261975543f815fa5) +- Implementation [`c4914ec`](https://github.com/inspect-js/has-tostringtag/commit/c4914ecc51ddee692c85b471ae0a5d8123030fbf) +- [meta] use `auto-changelog` [`4aaf768`](https://github.com/inspect-js/has-tostringtag/commit/4aaf76895ae01d7b739f2b19f967ef2372506cd7) +- Only apps should have lockfiles [`bc4d99e`](https://github.com/inspect-js/has-tostringtag/commit/bc4d99e4bf494afbaa235c5f098df6e642edf724) +- [meta] add `safe-publish-latest` [`6523c05`](https://github.com/inspect-js/has-tostringtag/commit/6523c05c9b87140f3ae74c9daf91633dd9ff4e1f) diff --git a/node_modules/has-tostringtag/LICENSE b/node_modules/has-tostringtag/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..7948bc02a7937478ae009ff3796e76b25bdfbb08 --- /dev/null +++ b/node_modules/has-tostringtag/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Inspect JS + +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. diff --git a/node_modules/has-tostringtag/README.md b/node_modules/has-tostringtag/README.md new file mode 100644 index 0000000000000000000000000000000000000000..67a5e929dfce41c47370c4141ed9fae8ba6aea21 --- /dev/null +++ b/node_modules/has-tostringtag/README.md @@ -0,0 +1,46 @@ +# has-tostringtag [![Version Badge][2]][1] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams. + +## Example + +```js +var hasSymbolToStringTag = require('has-tostringtag'); + +hasSymbolToStringTag() === true; // if the environment has native Symbol.toStringTag support. Not polyfillable, not forgeable. + +var hasSymbolToStringTagKinda = require('has-tostringtag/shams'); +hasSymbolToStringTagKinda() === true; // if the environment has a Symbol.toStringTag sham that mostly follows the spec. +``` + +## Supported Symbol shams + - get-own-property-symbols [npm](https://www.npmjs.com/package/get-own-property-symbols) | [github](https://github.com/WebReflection/get-own-property-symbols) + - core-js [npm](https://www.npmjs.com/package/core-js) | [github](https://github.com/zloirock/core-js) + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/has-tostringtag +[2]: https://versionbadg.es/inspect-js/has-tostringtag.svg +[5]: https://david-dm.org/inspect-js/has-tostringtag.svg +[6]: https://david-dm.org/inspect-js/has-tostringtag +[7]: https://david-dm.org/inspect-js/has-tostringtag/dev-status.svg +[8]: https://david-dm.org/inspect-js/has-tostringtag#info=devDependencies +[11]: https://nodei.co/npm/has-tostringtag.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/has-tostringtag.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/has-tostringtag.svg +[downloads-url]: https://npm-stat.com/charts.html?package=has-tostringtag +[codecov-image]: https://codecov.io/gh/inspect-js/has-tostringtag/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/has-tostringtag/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/has-tostringtag +[actions-url]: https://github.com/inspect-js/has-tostringtag/actions diff --git a/node_modules/has-tostringtag/index.js b/node_modules/has-tostringtag/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d626b7a82cf9daf881acac8d1d0d7a71e3abc149 --- /dev/null +++ b/node_modules/has-tostringtag/index.js @@ -0,0 +1,7 @@ +'use strict'; + +var hasSymbols = require('has-symbols'); + +module.exports = function hasToStringTag() { + return hasSymbols() && typeof Symbol.toStringTag === 'symbol'; +}; diff --git a/node_modules/has-tostringtag/package.json b/node_modules/has-tostringtag/package.json new file mode 100644 index 0000000000000000000000000000000000000000..9c74d6416ac08cf09e7948a5d557513dfa5fbbdc --- /dev/null +++ b/node_modules/has-tostringtag/package.json @@ -0,0 +1,84 @@ +{ + "name": "has-tostringtag", + "version": "1.0.0", + "author": { + "name": "Jordan Harband", + "email": "ljharb@gmail.com", + "url": "http://ljharb.codes" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "contributors": [ + { + "name": "Jordan Harband", + "email": "ljharb@gmail.com", + "url": "http://ljharb.codes" + } + ], + "description": "Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams.", + "license": "MIT", + "main": "index.js", + "exports": { + ".": "./index.js", + "./shams": "./shams.js", + "./package.json": "./package.json" + }, + "scripts": { + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "pretest": "npm run --silent lint", + "test": "npm run tests-only", + "posttest": "aud --production", + "tests-only": "npm run test:stock && npm run test:staging && npm run test:shams", + "test:stock": "nyc node test", + "test:staging": "nyc node --harmony --es-staging test", + "test:shams": "npm run --silent test:shams:getownpropertysymbols && npm run --silent test:shams:corejs", + "test:shams:corejs": "nyc node test/shams/core-js.js", + "test:shams:getownpropertysymbols": "nyc node test/shams/get-own-property-symbols.js", + "lint": "eslint --ext=js,mjs .", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/inspect-js/has-tostringtag.git" + }, + "bugs": { + "url": "https://github.com/inspect-js/has-tostringtag/issues" + }, + "homepage": "https://github.com/inspect-js/has-tostringtag#readme", + "keywords": [ + "javascript", + "ecmascript", + "symbol", + "symbols", + "tostringtag", + "Symbol.toStringTag" + ], + "dependencies": { + "has-symbols": "^1.0.2" + }, + "devDependencies": { + "@ljharb/eslint-config": "^17.6.0", + "aud": "^1.1.5", + "auto-changelog": "^2.3.0", + "core-js": "^2.6.12", + "eslint": "^7.32.0", + "get-own-property-symbols": "^0.9.5", + "nyc": "^10.3.2", + "safe-publish-latest": "^1.1.4", + "tape": "^5.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + } +} diff --git a/node_modules/has-tostringtag/shams.js b/node_modules/has-tostringtag/shams.js new file mode 100644 index 0000000000000000000000000000000000000000..8b7e4011777266697b1e3a6b491f3e99e4c676fb --- /dev/null +++ b/node_modules/has-tostringtag/shams.js @@ -0,0 +1,7 @@ +'use strict'; + +var hasSymbols = require('has-symbols/shams'); + +module.exports = function hasToStringTagShams() { + return hasSymbols() && !!Symbol.toStringTag; +}; diff --git a/node_modules/has-tostringtag/test/index.js b/node_modules/has-tostringtag/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0679afdfa78bffebe91fda3023491bba375b53a6 --- /dev/null +++ b/node_modules/has-tostringtag/test/index.js @@ -0,0 +1,21 @@ +'use strict'; + +var test = require('tape'); +var hasSymbolToStringTag = require('../'); +var runSymbolTests = require('./tests'); + +test('interface', function (t) { + t.equal(typeof hasSymbolToStringTag, 'function', 'is a function'); + t.equal(typeof hasSymbolToStringTag(), 'boolean', 'returns a boolean'); + t.end(); +}); + +test('Symbol.toStringTag exists', { skip: !hasSymbolToStringTag() }, function (t) { + runSymbolTests(t); + t.end(); +}); + +test('Symbol.toStringTag does not exist', { skip: hasSymbolToStringTag() }, function (t) { + t.equal(typeof Symbol === 'undefined' ? 'undefined' : typeof Symbol.toStringTag, 'undefined', 'global Symbol.toStringTag is undefined'); + t.end(); +}); diff --git a/node_modules/has-tostringtag/test/shams/core-js.js b/node_modules/has-tostringtag/test/shams/core-js.js new file mode 100644 index 0000000000000000000000000000000000000000..692b86eb9af0e89223d50ea768f0870417376111 --- /dev/null +++ b/node_modules/has-tostringtag/test/shams/core-js.js @@ -0,0 +1,28 @@ +'use strict'; + +var test = require('tape'); + +if (typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol') { + test('has native Symbol.toStringTag support', function (t) { + t.equal(typeof Symbol, 'function'); + t.equal(typeof Symbol.toStringTag, 'symbol'); + t.end(); + }); + return; +} + +var hasSymbolToStringTag = require('../../shams'); + +test('polyfilled Symbols', function (t) { + /* eslint-disable global-require */ + t.equal(hasSymbolToStringTag(), false, 'hasSymbolToStringTag is false before polyfilling'); + require('core-js/fn/symbol'); + require('core-js/fn/symbol/to-string-tag'); + + require('../tests')(t); + + var hasToStringTagAfter = hasSymbolToStringTag(); + t.equal(hasToStringTagAfter, true, 'hasSymbolToStringTag is true after polyfilling'); + /* eslint-enable global-require */ + t.end(); +}); diff --git a/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js b/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js new file mode 100644 index 0000000000000000000000000000000000000000..489fe83632f7c6a5ab028fe69466befcc98456f1 --- /dev/null +++ b/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js @@ -0,0 +1,28 @@ +'use strict'; + +var test = require('tape'); + +if (typeof Symbol === 'function' && typeof Symbol() === 'symbol') { + test('has native Symbol support', function (t) { + t.equal(typeof Symbol, 'function'); + t.equal(typeof Symbol(), 'symbol'); + t.end(); + }); + return; +} + +var hasSymbolToStringTag = require('../../shams'); + +test('polyfilled Symbols', function (t) { + /* eslint-disable global-require */ + t.equal(hasSymbolToStringTag(), false, 'hasSymbolToStringTag is false before polyfilling'); + + require('get-own-property-symbols'); + + require('../tests')(t); + + var hasToStringTagAfter = hasSymbolToStringTag(); + t.equal(hasToStringTagAfter, true, 'hasSymbolToStringTag is true after polyfilling'); + /* eslint-enable global-require */ + t.end(); +}); diff --git a/node_modules/has-tostringtag/test/tests.js b/node_modules/has-tostringtag/test/tests.js new file mode 100644 index 0000000000000000000000000000000000000000..0dae885c0ba5b5ed8689891e31d34652a56dd7e4 --- /dev/null +++ b/node_modules/has-tostringtag/test/tests.js @@ -0,0 +1,14 @@ +'use strict'; + +// eslint-disable-next-line consistent-return +module.exports = function runSymbolTests(t) { + t.equal(typeof Symbol, 'function', 'global Symbol is a function'); + t.ok(Symbol.toStringTag, 'Symbol.toStringTag exists'); + + if (typeof Symbol !== 'function' || !Symbol.toStringTag) { return false; } + + var obj = {}; + obj[Symbol.toStringTag] = 'test'; + + t.equal(Object.prototype.toString.call(obj), '[object test]'); +}; diff --git a/node_modules/hasown/.eslintrc b/node_modules/hasown/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..3b5d9e90ec405f85dd7f9066656efccc51193697 --- /dev/null +++ b/node_modules/hasown/.eslintrc @@ -0,0 +1,5 @@ +{ + "root": true, + + "extends": "@ljharb", +} diff --git a/node_modules/hasown/.github/FUNDING.yml b/node_modules/hasown/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..d68c8b716ff04186cd4c0ed8f85af474cfbfbc6a --- /dev/null +++ b/node_modules/hasown/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/hasown +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with a single custom sponsorship URL diff --git a/node_modules/hasown/.nycrc b/node_modules/hasown/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..1826526e091b89c896e7099ccd891db79165e329 --- /dev/null +++ b/node_modules/hasown/.nycrc @@ -0,0 +1,13 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "lines": 86, + "statements": 85.93, + "functions": 82.43, + "branches": 76.06, + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/hasown/CHANGELOG.md b/node_modules/hasown/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..1cbd1f5f63f2fcb67dcb11a04c88d7b01c3f1202 --- /dev/null +++ b/node_modules/hasown/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v2.0.0](https://github.com/inspect-js/hasOwn/compare/v1.0.1...v2.0.0) - 2023-10-19 + +### Commits + +- revamped implementation, tests, readme [`72bf8b3`](https://github.com/inspect-js/hasOwn/commit/72bf8b338e77a638f0a290c63ffaed18339c36b4) +- [meta] revamp package.json [`079775f`](https://github.com/inspect-js/hasOwn/commit/079775fb1ec72c1c6334069593617a0be3847458) +- Only apps should have lockfiles [`6640e23`](https://github.com/inspect-js/hasOwn/commit/6640e233d1bb8b65260880f90787637db157d215) + +## v1.0.1 - 2023-10-10 + +### Commits + +- Initial commit [`8dbfde6`](https://github.com/inspect-js/hasOwn/commit/8dbfde6e8fb0ebb076fab38d138f2984eb340a62) diff --git a/node_modules/hasown/LICENSE b/node_modules/hasown/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0314929078de8a733a0af9c8ba5bc00aca094cc9 --- /dev/null +++ b/node_modules/hasown/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Jordan Harband and contributors + +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. diff --git a/node_modules/hasown/README.md b/node_modules/hasown/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f759b8a8396e3993fb7901d7551d38ee2a786b31 --- /dev/null +++ b/node_modules/hasown/README.md @@ -0,0 +1,40 @@ +# hasown [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +A robust, ES3 compatible, "has own property" predicate. + +## Example + +```js +const assert = require('assert'); +const hasOwn = require('hasown'); + +assert.equal(hasOwn({}, 'toString'), false); +assert.equal(hasOwn([], 'length'), true); +assert.equal(hasOwn({ a: 42 }, 'a'), true); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/hasown +[npm-version-svg]: https://versionbadg.es/inspect-js/hasown.svg +[deps-svg]: https://david-dm.org/inspect-js/hasOwn.svg +[deps-url]: https://david-dm.org/inspect-js/hasOwn +[dev-deps-svg]: https://david-dm.org/inspect-js/hasOwn/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/hasOwn#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/hasown.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/hasown.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/hasown.svg +[downloads-url]: https://npm-stat.com/charts.html?package=hasown +[codecov-image]: https://codecov.io/gh/inspect-js/hasOwn/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/hasOwn/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/hasOwn +[actions-url]: https://github.com/inspect-js/hasOwn/actions diff --git a/node_modules/hasown/index.d.ts b/node_modules/hasown/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..caf4a060e07f4a200a6cffe0c071fb35dc4a1ee8 --- /dev/null +++ b/node_modules/hasown/index.d.ts @@ -0,0 +1,3 @@ +declare const _exports: (o: {}, p: PropertyKey) => p is never; +export = _exports; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/hasown/index.d.ts.map b/node_modules/hasown/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..d40068a52f66793849a78bf86e1226acc7cdbed8 --- /dev/null +++ b/node_modules/hasown/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"4BAMe,EAAE,KAAK,WAAW"} \ No newline at end of file diff --git a/node_modules/hasown/index.js b/node_modules/hasown/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3b91618323842ff7bce62e17d17f381591ea9748 --- /dev/null +++ b/node_modules/hasown/index.js @@ -0,0 +1,8 @@ +'use strict'; + +var call = Function.prototype.call; +var $hasOwn = Object.prototype.hasOwnProperty; +var bind = require('function-bind'); + +/** @type {(o: {}, p: PropertyKey) => p is keyof o} */ +module.exports = bind.call(call, $hasOwn); diff --git a/node_modules/hasown/package.json b/node_modules/hasown/package.json new file mode 100644 index 0000000000000000000000000000000000000000..954500640223c2ea2911d170d8a417f15b2ded97 --- /dev/null +++ b/node_modules/hasown/package.json @@ -0,0 +1,91 @@ +{ + "name": "hasown", + "version": "2.0.0", + "description": "A robust, ES3 compatible, \"has own property\" predicate.", + "main": "index.js", + "exports": { + ".": "./index.js", + "./package.json": "./package.json" + }, + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated && npm run emit-types", + "prepublish": "not-in-publish || npm run prepublishOnly", + "prepublishOnly": "safe-publish-latest", + "prelint": "evalmd README.md", + "lint": "eslint --ext=js,mjs .", + "postlint": "npm run tsc", + "preemit-types": "rm -f *.ts *.ts.map test/*.ts test/*.ts.map", + "emit-types": "npm run tsc -- --noEmit false --emitDeclarationOnly", + "pretest": "npm run lint", + "tsc": "tsc -p .", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/inspect-js/hasOwn.git" + }, + "keywords": [ + "has", + "hasOwnProperty", + "hasOwn", + "has-own", + "own", + "has", + "property", + "in", + "javascript", + "ecmascript" + ], + "author": "Jordan Harband ", + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/hasOwn/issues" + }, + "homepage": "https://github.com/inspect-js/hasOwn#readme", + "dependencies": { + "function-bind": "^1.1.2" + }, + "devDependencies": { + "@ljharb/eslint-config": "^21.1.0", + "@types/function-bind": "^1.1.9", + "@types/mock-property": "^1.0.1", + "@types/tape": "^5.6.3", + "aud": "^2.0.3", + "auto-changelog": "^2.4.0", + "eslint": "=8.8.0", + "evalmd": "^0.0.19", + "in-publish": "^2.0.1", + "mock-property": "^1.0.2", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "safe-publish-latest": "^2.0.0", + "tape": "^5.7.1", + "typescript": "^5.3.0-dev.20231019" + }, + "engines": { + "node": ">= 0.4" + }, + "testling": { + "files": "test/index.js" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + }, + "publishConfig": { + "ignore": [ + ".github/workflows", + "test", + "!*.d.ts", + "!*.d.ts.map" + ] + } +} diff --git a/node_modules/hasown/tsconfig.json b/node_modules/hasown/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..fdab34fe3115774b0c77f42a46ba251f95ce150a --- /dev/null +++ b/node_modules/hasown/tsconfig.json @@ -0,0 +1,49 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + "typeRoots": ["types"], /* Specify multiple folders that act like './node_modules/@types'. */ + "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + + /* JavaScript Support */ + "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + "declarationMap": true, /* Create sourcemaps for d.ts files. */ + "noEmit": true, /* Disable emitting files from a compilation. */ + + /* Interop Constraints */ + "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + + /* Completeness */ + //"skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "exclude": [ + "coverage" + ] +} diff --git a/node_modules/http-signature/CHANGES.md b/node_modules/http-signature/CHANGES.md new file mode 100644 index 0000000000000000000000000000000000000000..cd2015c0d28dc6f096b6153d3011100ffcc36651 --- /dev/null +++ b/node_modules/http-signature/CHANGES.md @@ -0,0 +1,92 @@ +# node-http-signature changelog + +## not yet released + +(nothing yet) + +## 1.3.6 + +* Update jsprim due to vulnerability in json-schema (#123) + +## 1.3.5 + +* Add keyPassphrase option to signer (#115) +* Add support for created and expires values (#110) + +## 1.3.4 + +* Fix breakage in v1.3.3 with the setting of the "algorithm" field in the + Authorization header (#102) + +## 1.3.3 + +**Bad release. Use 1.3.4.** + +* Add support for an opaque param in the Authorization header (#101) +* Add support for adding the keyId and algorithm params into the signing string (#100) + +## 1.3.2 + +* Allow Buffers to be used for verifyHMAC (#98) + +## 1.3.1 + +* Fix node 0.10 usage (#90) + +## 1.3.0 + +**Known issue:** This release broken http-signature with node 0.10. + +* Bump dependency `sshpk` +* Add `Signature` header support (#83) + +## 1.2.0 + +* Bump dependency `assert-plus` +* Add ability to pass a custom header name +* Replaced dependency `node-uuid` with `uuid` + +## 1.1.1 + +* Version of dependency `assert-plus` updated: old version was missing + some license information +* Corrected examples in `http_signing.md`, added auto-tests to + automatically validate these examples + +## 1.1.0 + +* Bump version of `sshpk` dependency, remove peerDependency on it since + it now supports exchanging objects between multiple versions of itself + where possible + +## 1.0.2 + +* Bump min version of `jsprim` dependency, to include fixes for using + http-signature with `browserify` + +## 1.0.1 + +* Bump minimum version of `sshpk` dependency, to include fixes for + whitespace tolerance in key parsing. + +## 1.0.0 + +* First semver release. +* #36: Ensure verifySignature does not leak useful timing information +* #42: Bring the library up to the latest version of the spec (including the + request-target changes) +* Support for ECDSA keys and signatures. +* Now uses `sshpk` for key parsing, validation and conversion. +* Fixes for #21, #47, #39 and compatibility with node 0.8 + +## 0.11.0 + +* Split up HMAC and Signature verification to avoid vulnerabilities where a + key intended for use with one can be validated against the other method + instead. + +## 0.10.2 + +* Updated versions of most dependencies. +* Utility functions exported for PEM => SSH-RSA conversion. +* Improvements to tests and examples. diff --git a/node_modules/http-signature/LICENSE b/node_modules/http-signature/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..f6d947d2f61c41777fb3bbb66334a93122bf5fdc --- /dev/null +++ b/node_modules/http-signature/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. All rights reserved. +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. diff --git a/node_modules/http-signature/README.md b/node_modules/http-signature/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9246c1e903a195ddac971246720cb9f4f4adbf0c --- /dev/null +++ b/node_modules/http-signature/README.md @@ -0,0 +1,80 @@ +# node-http-signature + +node-http-signature is a node.js library that has client and server components +for Joyent's [HTTP Signature Scheme](http_signing.md). + +## Usage + +Note the example below signs a request with the same key/cert used to start an +HTTP server. This is almost certainly not what you actually want, but is just +used to illustrate the API calls; you will need to provide your own key +management in addition to this library. + +### Client + +```js +var fs = require('fs'); +var https = require('https'); +var httpSignature = require('http-signature'); + +var key = fs.readFileSync('./key.pem', 'ascii'); + +var options = { + host: 'localhost', + port: 8443, + path: '/', + method: 'GET', + headers: {} +}; + +// Adds a 'Date' header in, signs it, and adds the +// 'Authorization' header in. +var req = https.request(options, function(res) { + console.log(res.statusCode); +}); + + +httpSignature.sign(req, { + key: key, + keyId: './cert.pem', + keyPassphrase: 'secret' // (optional) +}); + +req.end(); +``` + +### Server + +```js +var fs = require('fs'); +var https = require('https'); +var httpSignature = require('http-signature'); + +var options = { + key: fs.readFileSync('./key.pem'), + cert: fs.readFileSync('./cert.pem') +}; + +https.createServer(options, function (req, res) { + var rc = 200; + var parsed = httpSignature.parseRequest(req); + var pub = fs.readFileSync(parsed.keyId, 'ascii'); + if (!httpSignature.verifySignature(parsed, pub)) + rc = 401; + + res.writeHead(rc); + res.end(); +}).listen(8443); +``` + +## Installation + + npm install http-signature + +## License + +MIT. + +## Bugs + +See . diff --git a/node_modules/http-signature/lib/index.js b/node_modules/http-signature/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..54d46030f1c152d1f0cc8d729a3137d07a7b9414 --- /dev/null +++ b/node_modules/http-signature/lib/index.js @@ -0,0 +1,29 @@ +// Copyright 2015 Joyent, Inc. + +var parser = require('./parser'); +var signer = require('./signer'); +var verify = require('./verify'); +var utils = require('./utils'); + + + +///--- API + +module.exports = { + + parse: parser.parseRequest, + parseRequest: parser.parseRequest, + + sign: signer.signRequest, + signRequest: signer.signRequest, + createSigner: signer.createSigner, + isSigner: signer.isSigner, + + sshKeyToPEM: utils.sshKeyToPEM, + sshKeyFingerprint: utils.fingerprint, + pemToRsaSSHKey: utils.pemToRsaSSHKey, + + verify: verify.verifySignature, + verifySignature: verify.verifySignature, + verifyHMAC: verify.verifyHMAC +}; diff --git a/node_modules/http-signature/lib/parser.js b/node_modules/http-signature/lib/parser.js new file mode 100644 index 0000000000000000000000000000000000000000..ab4e5d2cb365c2c5046d0a8680c0c6e863c5b04c --- /dev/null +++ b/node_modules/http-signature/lib/parser.js @@ -0,0 +1,377 @@ +// Copyright 2012 Joyent, Inc. All rights reserved. + +var assert = require('assert-plus'); +var util = require('util'); +var utils = require('./utils'); + + + +///--- Globals + +var HASH_ALGOS = utils.HASH_ALGOS; +var PK_ALGOS = utils.PK_ALGOS; +var HttpSignatureError = utils.HttpSignatureError; +var InvalidAlgorithmError = utils.InvalidAlgorithmError; +var validateAlgorithm = utils.validateAlgorithm; + +var State = { + New: 0, + Params: 1 +}; + +var ParamsState = { + Name: 0, + Quote: 1, + Value: 2, + Comma: 3, + Number: 4 +}; + +///--- Specific Errors + + +function ExpiredRequestError(message) { + HttpSignatureError.call(this, message, ExpiredRequestError); +} +util.inherits(ExpiredRequestError, HttpSignatureError); + + +function InvalidHeaderError(message) { + HttpSignatureError.call(this, message, InvalidHeaderError); +} +util.inherits(InvalidHeaderError, HttpSignatureError); + + +function InvalidParamsError(message) { + HttpSignatureError.call(this, message, InvalidParamsError); +} +util.inherits(InvalidParamsError, HttpSignatureError); + + +function MissingHeaderError(message) { + HttpSignatureError.call(this, message, MissingHeaderError); +} +util.inherits(MissingHeaderError, HttpSignatureError); + +function StrictParsingError(message) { + HttpSignatureError.call(this, message, StrictParsingError); +} +util.inherits(StrictParsingError, HttpSignatureError); + +///--- Exported API + +module.exports = { + + /** + * Parses the 'Authorization' header out of an http.ServerRequest object. + * + * Note that this API will fully validate the Authorization header, and throw + * on any error. It will not however check the signature, or the keyId format + * as those are specific to your environment. You can use the options object + * to pass in extra constraints. + * + * As a response object you can expect this: + * + * { + * "scheme": "Signature", + * "params": { + * "keyId": "foo", + * "algorithm": "rsa-sha256", + * "headers": [ + * "date" or "x-date", + * "digest" + * ], + * "signature": "base64" + * }, + * "signingString": "ready to be passed to crypto.verify()" + * } + * + * @param {Object} request an http.ServerRequest. + * @param {Object} options an optional options object with: + * - clockSkew: allowed clock skew in seconds (default 300). + * - headers: required header names (def: date or x-date) + * - algorithms: algorithms to support (default: all). + * - strict: should enforce latest spec parsing + * (default: false). + * @return {Object} parsed out object (see above). + * @throws {TypeError} on invalid input. + * @throws {InvalidHeaderError} on an invalid Authorization header error. + * @throws {InvalidParamsError} if the params in the scheme are invalid. + * @throws {MissingHeaderError} if the params indicate a header not present, + * either in the request headers from the params, + * or not in the params from a required header + * in options. + * @throws {StrictParsingError} if old attributes are used in strict parsing + * mode. + * @throws {ExpiredRequestError} if the value of date or x-date exceeds skew. + */ + parseRequest: function parseRequest(request, options) { + assert.object(request, 'request'); + assert.object(request.headers, 'request.headers'); + if (options === undefined) { + options = {}; + } + assert.object(options, 'options'); + assert.optionalFinite(options.clockSkew, 'options.clockSkew'); + + var headers = [request.headers['x-date'] ? 'x-date' : 'date']; + if (options.headers !== undefined) { + assert.arrayOfString(headers, 'options.headers'); + headers = options.headers; + } + + var authzHeaderName = options.authorizationHeaderName; + var authz = request.headers[authzHeaderName] || + request.headers[utils.HEADER.AUTH] || request.headers[utils.HEADER.SIG]; + + if (!authz) { + var errHeader = authzHeaderName ? authzHeaderName : + utils.HEADER.AUTH + ' or ' + utils.HEADER.SIG; + + throw new MissingHeaderError('no ' + errHeader + ' header ' + + 'present in the request'); + } + + options.clockSkew = options.clockSkew || 300; + + + var i = 0; + var state = authz === request.headers[utils.HEADER.SIG] ? + State.Params : State.New; + var substate = ParamsState.Name; + var tmpName = ''; + var tmpValue = ''; + + var parsed = { + scheme: authz === request.headers[utils.HEADER.SIG] ? 'Signature' : '', + params: {}, + signingString: '' + }; + + for (i = 0; i < authz.length; i++) { + var c = authz.charAt(i); + + switch (Number(state)) { + + case State.New: + if (c !== ' ') parsed.scheme += c; + else state = State.Params; + break; + + case State.Params: + switch (Number(substate)) { + + case ParamsState.Name: + var code = c.charCodeAt(0); + // restricted name of A-Z / a-z + if ((code >= 0x41 && code <= 0x5a) || // A-Z + (code >= 0x61 && code <= 0x7a)) { // a-z + tmpName += c; + } else if (c === '=') { + if (tmpName.length === 0) + throw new InvalidHeaderError('bad param format'); + substate = ParamsState.Quote; + } else { + throw new InvalidHeaderError('bad param format'); + } + break; + + case ParamsState.Quote: + if (c === '"') { + tmpValue = ''; + substate = ParamsState.Value; + } else { + //number + substate = ParamsState.Number; + code = c.charCodeAt(0); + if (code < 0x30 || code > 0x39) { //character not in 0-9 + throw new InvalidHeaderError('bad param format'); + } + tmpValue = c; + } + break; + + case ParamsState.Value: + if (c === '"') { + parsed.params[tmpName] = tmpValue; + substate = ParamsState.Comma; + } else { + tmpValue += c; + } + break; + + case ParamsState.Number: + if (c === ',') { + parsed.params[tmpName] = parseInt(tmpValue, 10); + tmpName = ''; + substate = ParamsState.Name; + } else { + code = c.charCodeAt(0); + if (code < 0x30 || code > 0x39) { //character not in 0-9 + throw new InvalidHeaderError('bad param format'); + } + tmpValue += c; + } + break; + + + case ParamsState.Comma: + if (c === ',') { + tmpName = ''; + substate = ParamsState.Name; + } else { + throw new InvalidHeaderError('bad param format'); + } + break; + + default: + throw new Error('Invalid substate'); + } + break; + + default: + throw new Error('Invalid substate'); + } + + } + + if (!parsed.params.headers || parsed.params.headers === '') { + if (request.headers['x-date']) { + parsed.params.headers = ['x-date']; + } else { + parsed.params.headers = ['date']; + } + } else { + parsed.params.headers = parsed.params.headers.split(' '); + } + + // Minimally validate the parsed object + if (!parsed.scheme || parsed.scheme !== 'Signature') + throw new InvalidHeaderError('scheme was not "Signature"'); + + if (!parsed.params.keyId) + throw new InvalidHeaderError('keyId was not specified'); + + if (!parsed.params.algorithm) + throw new InvalidHeaderError('algorithm was not specified'); + + if (!parsed.params.signature) + throw new InvalidHeaderError('signature was not specified'); + + // Check the algorithm against the official list + try { + validateAlgorithm(parsed.params.algorithm); + } catch (e) { + if (e instanceof InvalidAlgorithmError) + throw (new InvalidParamsError(parsed.params.algorithm + ' is not ' + + 'supported')); + else + throw (e); + } + + // Build the signingString + for (i = 0; i < parsed.params.headers.length; i++) { + var h = parsed.params.headers[i].toLowerCase(); + parsed.params.headers[i] = h; + + if (h === 'request-line') { + if (!options.strict) { + /* + * We allow headers from the older spec drafts if strict parsing isn't + * specified in options. + */ + parsed.signingString += + request.method + ' ' + request.url + ' HTTP/' + request.httpVersion; + } else { + /* Strict parsing doesn't allow older draft headers. */ + throw (new StrictParsingError('request-line is not a valid header ' + + 'with strict parsing enabled.')); + } + } else if (h === '(request-target)') { + parsed.signingString += + '(request-target): ' + request.method.toLowerCase() + ' ' + + request.url; + } else if (h === '(keyid)') { + parsed.signingString += '(keyid): ' + parsed.params.keyId; + } else if (h === '(algorithm)') { + parsed.signingString += '(algorithm): ' + parsed.params.algorithm; + } else if (h === '(opaque)') { + var opaque = parsed.params.opaque; + if (opaque === undefined) { + throw new MissingHeaderError('opaque param was not in the ' + + authzHeaderName + ' header'); + } + parsed.signingString += '(opaque): ' + opaque; + } else if (h === '(created)') { + parsed.signingString += '(created): ' + parsed.params.created; + } else if (h === '(expires)') { + parsed.signingString += '(expires): ' + parsed.params.expires; + } else { + var value = request.headers[h]; + if (value === undefined) + throw new MissingHeaderError(h + ' was not in the request'); + parsed.signingString += h + ': ' + value; + } + + if ((i + 1) < parsed.params.headers.length) + parsed.signingString += '\n'; + } + + // Check against the constraints + var date; + var skew; + if (request.headers.date || request.headers['x-date']) { + if (request.headers['x-date']) { + date = new Date(request.headers['x-date']); + } else { + date = new Date(request.headers.date); + } + var now = new Date(); + skew = Math.abs(now.getTime() - date.getTime()); + + if (skew > options.clockSkew * 1000) { + throw new ExpiredRequestError('clock skew of ' + + (skew / 1000) + + 's was greater than ' + + options.clockSkew + 's'); + } + } + + if (parsed.params.created) { + skew = parsed.params.created - Math.floor(Date.now() / 1000); + if (skew > options.clockSkew) { + throw new ExpiredRequestError('Created lies in the future (with ' + + 'skew ' + skew + 's greater than allowed ' + options.clockSkew + + 's'); + } + } + + if (parsed.params.expires) { + var expiredSince = Math.floor(Date.now() / 1000) - parsed.params.expires; + if (expiredSince > options.clockSkew) { + throw new ExpiredRequestError('Request expired with skew ' + + expiredSince + 's greater than allowed ' + options.clockSkew + 's'); + } + } + + headers.forEach(function (hdr) { + // Remember that we already checked any headers in the params + // were in the request, so if this passes we're good. + if (parsed.params.headers.indexOf(hdr.toLowerCase()) < 0) + throw new MissingHeaderError(hdr + ' was not a signed header'); + }); + + parsed.params.algorithm = parsed.params.algorithm.toLowerCase(); + if (options.algorithms) { + if (options.algorithms.indexOf(parsed.params.algorithm) === -1) + throw new InvalidParamsError(parsed.params.algorithm + + ' is not a supported algorithm'); + } + + parsed.algorithm = parsed.params.algorithm.toUpperCase(); + parsed.keyId = parsed.params.keyId; + parsed.opaque = parsed.params.opaque; + return parsed; + } + +}; diff --git a/node_modules/http-signature/lib/signer.js b/node_modules/http-signature/lib/signer.js new file mode 100644 index 0000000000000000000000000000000000000000..aa2ef3a39d732b54dd45b52a84b7408d182a9328 --- /dev/null +++ b/node_modules/http-signature/lib/signer.js @@ -0,0 +1,483 @@ +// Copyright 2012 Joyent, Inc. All rights reserved. + +var assert = require('assert-plus'); +var crypto = require('crypto'); +var util = require('util'); +var sshpk = require('sshpk'); +var jsprim = require('jsprim'); +var utils = require('./utils'); + +var sprintf = require('util').format; + +var HASH_ALGOS = utils.HASH_ALGOS; +var PK_ALGOS = utils.PK_ALGOS; +var InvalidAlgorithmError = utils.InvalidAlgorithmError; +var HttpSignatureError = utils.HttpSignatureError; +var validateAlgorithm = utils.validateAlgorithm; + +///--- Globals + +var AUTHZ_PARAMS = [ 'keyId', 'algorithm', 'created', 'expires', 'opaque', + 'headers', 'signature' ]; + +///--- Specific Errors + +function MissingHeaderError(message) { + HttpSignatureError.call(this, message, MissingHeaderError); +} +util.inherits(MissingHeaderError, HttpSignatureError); + +function StrictParsingError(message) { + HttpSignatureError.call(this, message, StrictParsingError); +} +util.inherits(StrictParsingError, HttpSignatureError); + +function FormatAuthz(prefix, params) { + assert.string(prefix, 'prefix'); + assert.object(params, 'params'); + + var authz = ''; + for (var i = 0; i < AUTHZ_PARAMS.length; i++) { + var param = AUTHZ_PARAMS[i]; + var value = params[param]; + if (value === undefined) + continue; + if (typeof (value) === 'number') { + authz += prefix + sprintf('%s=%d', param, value); + } else { + assert.string(value, 'params.' + param); + + authz += prefix + sprintf('%s="%s"', param, value); + } + prefix = ','; + } + + return (authz); +} + +/* See createSigner() */ +function RequestSigner(options) { + assert.object(options, 'options'); + + var alg = []; + if (options.algorithm !== undefined) { + assert.string(options.algorithm, 'options.algorithm'); + alg = validateAlgorithm(options.algorithm); + } + this.rs_alg = alg; + + /* + * RequestSigners come in two varieties: ones with an rs_signFunc, and ones + * with an rs_signer. + * + * rs_signFunc-based RequestSigners have to build up their entire signing + * string within the rs_lines array and give it to rs_signFunc as a single + * concat'd blob. rs_signer-based RequestSigners can add a line at a time to + * their signing state by using rs_signer.update(), thus only needing to + * buffer the hash function state and one line at a time. + */ + if (options.sign !== undefined) { + assert.func(options.sign, 'options.sign'); + this.rs_signFunc = options.sign; + + } else if (alg[0] === 'hmac' && options.key !== undefined) { + assert.string(options.keyId, 'options.keyId'); + this.rs_keyId = options.keyId; + + if (typeof (options.key) !== 'string' && !Buffer.isBuffer(options.key)) + throw (new TypeError('options.key for HMAC must be a string or Buffer')); + + /* + * Make an rs_signer for HMACs, not a rs_signFunc -- HMACs digest their + * data in chunks rather than requiring it all to be given in one go + * at the end, so they are more similar to signers than signFuncs. + */ + this.rs_signer = crypto.createHmac(alg[1].toUpperCase(), options.key); + this.rs_signer.sign = function () { + var digest = this.digest('base64'); + return ({ + hashAlgorithm: alg[1], + toString: function () { return (digest); } + }); + }; + + } else if (options.key !== undefined) { + var key = options.key; + if (typeof (key) === 'string' || Buffer.isBuffer(key)) + assert.optionalString(options.keyPassphrase, 'options.keyPassphrase'); + key = sshpk.parsePrivateKey(key, 'auto', { + passphrase: options.keyPassphrase + }); + + assert.ok(sshpk.PrivateKey.isPrivateKey(key, [1, 2]), + 'options.key must be a sshpk.PrivateKey'); + this.rs_key = key; + + assert.string(options.keyId, 'options.keyId'); + this.rs_keyId = options.keyId; + + if (!PK_ALGOS[key.type]) { + throw (new InvalidAlgorithmError(key.type.toUpperCase() + ' type ' + + 'keys are not supported')); + } + + if (alg[0] !== undefined && key.type !== alg[0]) { + throw (new InvalidAlgorithmError('options.key must be a ' + + alg[0].toUpperCase() + ' key, was given a ' + + key.type.toUpperCase() + ' key instead')); + } + + this.rs_signer = key.createSign(alg[1]); + + } else { + throw (new TypeError('options.sign (func) or options.key is required')); + } + + this.rs_headers = []; + this.rs_lines = []; +} + +/** + * Adds a header to be signed, with its value, into this signer. + * + * @param {String} header + * @param {String} value + * @return {String} value written + */ +RequestSigner.prototype.writeHeader = function (header, value) { + assert.string(header, 'header'); + header = header.toLowerCase(); + assert.string(value, 'value'); + + this.rs_headers.push(header); + + if (this.rs_signFunc) { + this.rs_lines.push(header + ': ' + value); + + } else { + var line = header + ': ' + value; + if (this.rs_headers.length > 0) + line = '\n' + line; + this.rs_signer.update(line); + } + + return (value); +}; + +/** + * Adds a default Date header, returning its value. + * + * @return {String} + */ +RequestSigner.prototype.writeDateHeader = function () { + return (this.writeHeader('date', jsprim.rfc1123(new Date()))); +}; + +/** + * Adds the request target line to be signed. + * + * @param {String} method, HTTP method (e.g. 'get', 'post', 'put') + * @param {String} path + */ +RequestSigner.prototype.writeTarget = function (method, path) { + assert.string(method, 'method'); + assert.string(path, 'path'); + method = method.toLowerCase(); + this.writeHeader('(request-target)', method + ' ' + path); +}; + +/** + * Calculate the value for the Authorization header on this request + * asynchronously. + * + * @param {Func} callback (err, authz) + */ +RequestSigner.prototype.sign = function (cb) { + assert.func(cb, 'callback'); + + if (this.rs_headers.length < 1) + throw (new Error('At least one header must be signed')); + + var alg, authz; + if (this.rs_signFunc) { + var data = this.rs_lines.join('\n'); + var self = this; + this.rs_signFunc(data, function (err, sig) { + if (err) { + cb(err); + return; + } + try { + assert.object(sig, 'signature'); + assert.string(sig.keyId, 'signature.keyId'); + assert.string(sig.algorithm, 'signature.algorithm'); + assert.string(sig.signature, 'signature.signature'); + alg = validateAlgorithm(sig.algorithm); + + authz = FormatAuthz('Signature ', { + keyId: sig.keyId, + algorithm: sig.algorithm, + headers: self.rs_headers.join(' '), + signature: sig.signature + }); + } catch (e) { + cb(e); + return; + } + cb(null, authz); + }); + + } else { + try { + var sigObj = this.rs_signer.sign(); + } catch (e) { + cb(e); + return; + } + alg = (this.rs_alg[0] || this.rs_key.type) + '-' + sigObj.hashAlgorithm; + var signature = sigObj.toString(); + authz = FormatAuthz('Signature ', { + keyId: this.rs_keyId, + algorithm: alg, + headers: this.rs_headers.join(' '), + signature: signature + }); + cb(null, authz); + } +}; + +///--- Exported API + +module.exports = { + /** + * Identifies whether a given object is a request signer or not. + * + * @param {Object} object, the object to identify + * @returns {Boolean} + */ + isSigner: function (obj) { + if (typeof (obj) === 'object' && obj instanceof RequestSigner) + return (true); + return (false); + }, + + /** + * Creates a request signer, used to asynchronously build a signature + * for a request (does not have to be an http.ClientRequest). + * + * @param {Object} options, either: + * - {String} keyId + * - {String|Buffer} key + * - {String} algorithm (optional, required for HMAC) + * - {String} keyPassphrase (optional, not for HMAC) + * or: + * - {Func} sign (data, cb) + * @return {RequestSigner} + */ + createSigner: function createSigner(options) { + return (new RequestSigner(options)); + }, + + /** + * Adds an 'Authorization' header to an http.ClientRequest object. + * + * Note that this API will add a Date header if it's not already set. Any + * other headers in the options.headers array MUST be present, or this + * will throw. + * + * You shouldn't need to check the return type; it's just there if you want + * to be pedantic. + * + * The optional flag indicates whether parsing should use strict enforcement + * of the version draft-cavage-http-signatures-04 of the spec or beyond. + * The default is to be loose and support + * older versions for compatibility. + * + * @param {Object} request an instance of http.ClientRequest. + * @param {Object} options signing parameters object: + * - {String} keyId required. + * - {String} key required (either a PEM or HMAC key). + * - {Array} headers optional; defaults to ['date']. + * - {String} algorithm optional (unless key is HMAC); + * default is the same as the sshpk default + * signing algorithm for the type of key given + * - {String} httpVersion optional; defaults to '1.1'. + * - {Boolean} strict optional; defaults to 'false'. + * - {int} expiresIn optional; defaults to 60. The + * seconds after which the signature should + * expire; + * - {String} keyPassphrase optional; The passphrase to + * pass to sshpk to parse the privateKey. + * This doesn't do anything if algorithm is + * HMAC. + * @return {Boolean} true if Authorization (and optionally Date) were added. + * @throws {TypeError} on bad parameter types (input). + * @throws {InvalidAlgorithmError} if algorithm was bad or incompatible with + * the given key. + * @throws {sshpk.KeyParseError} if key was bad. + * @throws {MissingHeaderError} if a header to be signed was specified but + * was not present. + */ + signRequest: function signRequest(request, options) { + assert.object(request, 'request'); + assert.object(options, 'options'); + assert.optionalString(options.algorithm, 'options.algorithm'); + assert.string(options.keyId, 'options.keyId'); + assert.optionalString(options.opaque, 'options.opaque'); + assert.optionalArrayOfString(options.headers, 'options.headers'); + assert.optionalString(options.httpVersion, 'options.httpVersion'); + assert.optionalNumber(options.expiresIn, 'options.expiresIn'); + assert.optionalString(options.keyPassphrase, 'options.keyPassphrase'); + + if (!request.getHeader('Date')) + request.setHeader('Date', jsprim.rfc1123(new Date())); + var headers = ['date']; + if (options.headers) + headers = options.headers; + if (!options.httpVersion) + options.httpVersion = '1.1'; + + var alg = []; + if (options.algorithm) { + options.algorithm = options.algorithm.toLowerCase(); + alg = validateAlgorithm(options.algorithm); + } + + var key = options.key; + if (alg[0] === 'hmac') { + if (typeof (key) !== 'string' && !Buffer.isBuffer(key)) + throw (new TypeError('options.key must be a string or Buffer')); + } else { + if (typeof (key) === 'string' || Buffer.isBuffer(key)) + key = sshpk.parsePrivateKey(options.key, 'auto', { + passphrase: options.keyPassphrase + }); + + assert.ok(sshpk.PrivateKey.isPrivateKey(key, [1, 2]), + 'options.key must be a sshpk.PrivateKey'); + + if (!PK_ALGOS[key.type]) { + throw (new InvalidAlgorithmError(key.type.toUpperCase() + ' type ' + + 'keys are not supported')); + } + + if (alg[0] === undefined) { + alg[0] = key.type; + } else if (key.type !== alg[0]) { + throw (new InvalidAlgorithmError('options.key must be a ' + + alg[0].toUpperCase() + ' key, was given a ' + + key.type.toUpperCase() + ' key instead')); + } + if (alg[1] === undefined) { + alg[1] = key.defaultHashAlgorithm(); + } + + options.algorithm = alg[0] + '-' + alg[1]; + } + + var params = { + 'keyId': options.keyId, + 'algorithm': options.algorithm + }; + + var i; + var stringToSign = ''; + for (i = 0; i < headers.length; i++) { + if (typeof (headers[i]) !== 'string') + throw new TypeError('options.headers must be an array of Strings'); + + var h = headers[i].toLowerCase(); + + if (h === 'request-line') { + if (!options.strict) { + /** + * We allow headers from the older spec drafts if strict parsing isn't + * specified in options. + */ + stringToSign += + request.method + ' ' + request.path + ' HTTP/' + + options.httpVersion; + } else { + /* Strict parsing doesn't allow older draft headers. */ + throw (new StrictParsingError('request-line is not a valid header ' + + 'with strict parsing enabled.')); + } + } else if (h === '(request-target)') { + stringToSign += + '(request-target): ' + request.method.toLowerCase() + ' ' + + request.path; + } else if (h === '(keyid)') { + stringToSign += '(keyid): ' + options.keyId; + } else if (h === '(algorithm)') { + stringToSign += '(algorithm): ' + options.algorithm; + } else if (h === '(opaque)') { + var opaque = options.opaque; + if (opaque == undefined || opaque === '') { + throw new MissingHeaderError('options.opaque was not in the request'); + } + stringToSign += '(opaque): ' + opaque; + } else if (h === '(created)') { + var created = Math.floor(Date.now() / 1000); + params.created = created; + stringToSign += '(created): ' + created; + } else if (h === '(expires)') { + var expiresIn = options.expiresIn; + if (expiresIn === undefined) { + expiresIn = 60; + } + const expires = Math.floor(Date.now() / 1000) + expiresIn; + params.expires = expires; + stringToSign += '(expires): ' + expires; + } else { + var value = request.getHeader(h); + if (value === undefined || value === '') { + throw new MissingHeaderError(h + ' was not in the request'); + } + stringToSign += h + ': ' + value; + } + + if ((i + 1) < headers.length) + stringToSign += '\n'; + } + + /* This is just for unit tests. */ + if (request.hasOwnProperty('_stringToSign')) { + request._stringToSign = stringToSign; + } + + var signature; + if (alg[0] === 'hmac') { + var hmac = crypto.createHmac(alg[1].toUpperCase(), key); + hmac.update(stringToSign); + signature = hmac.digest('base64'); + } else { + var signer = key.createSign(alg[1]); + signer.update(stringToSign); + var sigObj = signer.sign(); + if (!HASH_ALGOS[sigObj.hashAlgorithm]) { + throw (new InvalidAlgorithmError(sigObj.hashAlgorithm.toUpperCase() + + ' is not a supported hash algorithm')); + } + assert.strictEqual(alg[1], sigObj.hashAlgorithm, + 'hash algorithm mismatch'); + signature = sigObj.toString(); + assert.notStrictEqual(signature, '', 'empty signature produced'); + } + + var authzHeaderName = options.authorizationHeaderName || 'Authorization'; + var prefix = authzHeaderName.toLowerCase() === utils.HEADER.SIG ? + '' : 'Signature '; + + params.signature = signature; + + if (options.opaque) + params.opaque = options.opaque; + if (options.headers) + params.headers = options.headers.join(' '); + + request.setHeader(authzHeaderName, FormatAuthz(prefix, params)); + + return true; + } + +}; diff --git a/node_modules/http-signature/lib/utils.js b/node_modules/http-signature/lib/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..65a4b8f7e55a391389ae8bd19b76bdb8c1f0e3b5 --- /dev/null +++ b/node_modules/http-signature/lib/utils.js @@ -0,0 +1,118 @@ +// Copyright 2012 Joyent, Inc. All rights reserved. + +var assert = require('assert-plus'); +var sshpk = require('sshpk'); +var util = require('util'); + +var HASH_ALGOS = { + 'sha1': true, + 'sha256': true, + 'sha512': true +}; + +var PK_ALGOS = { + 'rsa': true, + 'dsa': true, + 'ecdsa': true +}; + +var HEADER = { + AUTH: 'authorization', + SIG: 'signature' +}; + +function HttpSignatureError(message, caller) { + if (Error.captureStackTrace) + Error.captureStackTrace(this, caller || HttpSignatureError); + + this.message = message; + this.name = caller.name; +} +util.inherits(HttpSignatureError, Error); + +function InvalidAlgorithmError(message) { + HttpSignatureError.call(this, message, InvalidAlgorithmError); +} +util.inherits(InvalidAlgorithmError, HttpSignatureError); + +function validateAlgorithm(algorithm) { + var alg = algorithm.toLowerCase().split('-'); + + if (alg.length !== 2) { + throw (new InvalidAlgorithmError(alg[0].toUpperCase() + ' is not a ' + + 'valid algorithm')); + } + + if (alg[0] !== 'hmac' && !PK_ALGOS[alg[0]]) { + throw (new InvalidAlgorithmError(alg[0].toUpperCase() + ' type keys ' + + 'are not supported')); + } + + if (!HASH_ALGOS[alg[1]]) { + throw (new InvalidAlgorithmError(alg[1].toUpperCase() + ' is not a ' + + 'supported hash algorithm')); + } + + return (alg); +} + +///--- API + +module.exports = { + HEADER: HEADER, + + HASH_ALGOS: HASH_ALGOS, + PK_ALGOS: PK_ALGOS, + + HttpSignatureError: HttpSignatureError, + InvalidAlgorithmError: InvalidAlgorithmError, + + validateAlgorithm: validateAlgorithm, + + /** + * Converts an OpenSSH public key (rsa only) to a PKCS#8 PEM file. + * + * The intent of this module is to interoperate with OpenSSL only, + * specifically the node crypto module's `verify` method. + * + * @param {String} key an OpenSSH public key. + * @return {String} PEM encoded form of the RSA public key. + * @throws {TypeError} on bad input. + * @throws {Error} on invalid ssh key formatted data. + */ + sshKeyToPEM: function sshKeyToPEM(key) { + assert.string(key, 'ssh_key'); + + var k = sshpk.parseKey(key, 'ssh'); + return (k.toString('pem')); + }, + + + /** + * Generates an OpenSSH fingerprint from an ssh public key. + * + * @param {String} key an OpenSSH public key. + * @return {String} key fingerprint. + * @throws {TypeError} on bad input. + * @throws {Error} if what you passed doesn't look like an ssh public key. + */ + fingerprint: function fingerprint(key) { + assert.string(key, 'ssh_key'); + + var k = sshpk.parseKey(key, 'ssh'); + return (k.fingerprint('md5').toString('hex')); + }, + + /** + * Converts a PKGCS#8 PEM file to an OpenSSH public key (rsa) + * + * The reverse of the above function. + */ + pemToRsaSSHKey: function pemToRsaSSHKey(pem, comment) { + assert.equal('string', typeof (pem), 'typeof pem'); + + var k = sshpk.parseKey(pem, 'pem'); + k.comment = comment; + return (k.toString('ssh')); + } +}; diff --git a/node_modules/http-signature/lib/verify.js b/node_modules/http-signature/lib/verify.js new file mode 100644 index 0000000000000000000000000000000000000000..4dba40024be4075b9d5eb51e200b86c81cbe6f5a --- /dev/null +++ b/node_modules/http-signature/lib/verify.js @@ -0,0 +1,88 @@ +// Copyright 2015 Joyent, Inc. + +var assert = require('assert-plus'); +var crypto = require('crypto'); +var sshpk = require('sshpk'); +var utils = require('./utils'); + +var HASH_ALGOS = utils.HASH_ALGOS; +var PK_ALGOS = utils.PK_ALGOS; +var InvalidAlgorithmError = utils.InvalidAlgorithmError; +var HttpSignatureError = utils.HttpSignatureError; +var validateAlgorithm = utils.validateAlgorithm; + +///--- Exported API + +module.exports = { + /** + * Verify RSA/DSA signature against public key. You are expected to pass in + * an object that was returned from `parse()`. + * + * @param {Object} parsedSignature the object you got from `parse`. + * @param {String} pubkey RSA/DSA private key PEM. + * @return {Boolean} true if valid, false otherwise. + * @throws {TypeError} if you pass in bad arguments. + * @throws {InvalidAlgorithmError} + */ + verifySignature: function verifySignature(parsedSignature, pubkey) { + assert.object(parsedSignature, 'parsedSignature'); + if (typeof (pubkey) === 'string' || Buffer.isBuffer(pubkey)) + pubkey = sshpk.parseKey(pubkey); + assert.ok(sshpk.Key.isKey(pubkey, [1, 1]), 'pubkey must be a sshpk.Key'); + + var alg = validateAlgorithm(parsedSignature.algorithm); + if (alg[0] === 'hmac' || alg[0] !== pubkey.type) + return (false); + + var v = pubkey.createVerify(alg[1]); + v.update(parsedSignature.signingString); + return (v.verify(parsedSignature.params.signature, 'base64')); + }, + + /** + * Verify HMAC against shared secret. You are expected to pass in an object + * that was returned from `parse()`. + * + * @param {Object} parsedSignature the object you got from `parse`. + * @param {String} or {Buffer} secret HMAC shared secret. + * @return {Boolean} true if valid, false otherwise. + * @throws {TypeError} if you pass in bad arguments. + * @throws {InvalidAlgorithmError} + */ + verifyHMAC: function verifyHMAC(parsedSignature, secret) { + assert.object(parsedSignature, 'parsedHMAC'); + assert(typeof (secret) === 'string' || Buffer.isBuffer(secret)); + + var alg = validateAlgorithm(parsedSignature.algorithm); + if (alg[0] !== 'hmac') + return (false); + + var hashAlg = alg[1].toUpperCase(); + + var hmac = crypto.createHmac(hashAlg, secret); + hmac.update(parsedSignature.signingString); + + /* + * Now double-hash to avoid leaking timing information - there's + * no easy constant-time compare in JS, so we use this approach + * instead. See for more info: + * https://www.isecpartners.com/blog/2011/february/double-hmac- + * verification.aspx + */ + var h1 = crypto.createHmac(hashAlg, secret); + h1.update(hmac.digest()); + h1 = h1.digest(); + var h2 = crypto.createHmac(hashAlg, secret); + h2.update(new Buffer(parsedSignature.params.signature, 'base64')); + h2 = h2.digest(); + + /* Node 0.8 returns strings from .digest(). */ + if (typeof (h1) === 'string') + return (h1 === h2); + /* And node 0.10 lacks the .equals() method on Buffers. */ + if (Buffer.isBuffer(h1) && !h1.equals) + return (h1.toString('binary') === h2.toString('binary')); + + return (h1.equals(h2)); + } +}; diff --git a/node_modules/http-signature/package.json b/node_modules/http-signature/package.json new file mode 100644 index 0000000000000000000000000000000000000000..c278e85eccf7fca2ebc68637b3f6ae142afc6d15 --- /dev/null +++ b/node_modules/http-signature/package.json @@ -0,0 +1,41 @@ +{ + "name": "http-signature", + "description": "Reference implementation of Joyent's HTTP Signature scheme.", + "version": "1.3.6", + "license": "MIT", + "author": "Joyent, Inc", + "contributors": [ + "Mark Cavage ", + "David I. Lehn ", + "Patrick Mooney " + ], + "repository": { + "type": "git", + "url": "git://github.com/joyent/node-http-signature.git" + }, + "homepage": "https://github.com/joyent/node-http-signature/", + "bugs": "https://github.com/joyent/node-http-signature/issues", + "keywords": [ + "https", + "request" + ], + "engines": { + "node": ">=0.10" + }, + "main": "lib/index.js", + "files": [ + "lib" + ], + "scripts": { + "test": "tap test/*.js" + }, + "dependencies": { + "assert-plus": "^1.0.0", + "jsprim": "^2.0.2", + "sshpk": "^1.14.1" + }, + "devDependencies": { + "tap": "0.4.2", + "uuid": "^2.0.2" + } +} diff --git a/node_modules/inherits/LICENSE b/node_modules/inherits/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..dea3013d6710ee273f49ac606a65d5211d480c88 --- /dev/null +++ b/node_modules/inherits/LICENSE @@ -0,0 +1,16 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter + +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. + diff --git a/node_modules/inherits/README.md b/node_modules/inherits/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b1c56658557b8162aa9f5ba8610ed03a5e558d9d --- /dev/null +++ b/node_modules/inherits/README.md @@ -0,0 +1,42 @@ +Browser-friendly inheritance fully compatible with standard node.js +[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor). + +This package exports standard `inherits` from node.js `util` module in +node environment, but also provides alternative browser-friendly +implementation through [browser +field](https://gist.github.com/shtylman/4339901). Alternative +implementation is a literal copy of standard one located in standalone +module to avoid requiring of `util`. It also has a shim for old +browsers with no `Object.create` support. + +While keeping you sure you are using standard `inherits` +implementation in node.js environment, it allows bundlers such as +[browserify](https://github.com/substack/node-browserify) to not +include full `util` package to your client code if all you need is +just `inherits` function. It worth, because browser shim for `util` +package is large and `inherits` is often the single function you need +from it. + +It's recommended to use this package instead of +`require('util').inherits` for any code that has chances to be used +not only in node.js but in browser too. + +## usage + +```js +var inherits = require('inherits'); +// then use exactly as the standard one +``` + +## note on version ~1.0 + +Version ~1.0 had completely different motivation and is not compatible +neither with 2.0 nor with standard node.js `inherits`. + +If you are using version ~1.0 and planning to switch to ~2.0, be +careful: + +* new version uses `super_` instead of `super` for referencing + superclass +* new version overwrites current prototype while old one preserves any + existing fields on it diff --git a/node_modules/inherits/inherits.js b/node_modules/inherits/inherits.js new file mode 100644 index 0000000000000000000000000000000000000000..f71f2d93294a67ad5d9300aae07973e259f26068 --- /dev/null +++ b/node_modules/inherits/inherits.js @@ -0,0 +1,9 @@ +try { + var util = require('util'); + /* istanbul ignore next */ + if (typeof util.inherits !== 'function') throw ''; + module.exports = util.inherits; +} catch (e) { + /* istanbul ignore next */ + module.exports = require('./inherits_browser.js'); +} diff --git a/node_modules/inherits/inherits_browser.js b/node_modules/inherits/inherits_browser.js new file mode 100644 index 0000000000000000000000000000000000000000..86bbb3dc29e4847df14de2c2b4b168e065184643 --- /dev/null +++ b/node_modules/inherits/inherits_browser.js @@ -0,0 +1,27 @@ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } + } +} diff --git a/node_modules/inherits/package.json b/node_modules/inherits/package.json new file mode 100644 index 0000000000000000000000000000000000000000..37b4366b83e63e037cd447090ec25b39fce27e01 --- /dev/null +++ b/node_modules/inherits/package.json @@ -0,0 +1,29 @@ +{ + "name": "inherits", + "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", + "version": "2.0.4", + "keywords": [ + "inheritance", + "class", + "klass", + "oop", + "object-oriented", + "inherits", + "browser", + "browserify" + ], + "main": "./inherits.js", + "browser": "./inherits_browser.js", + "repository": "git://github.com/isaacs/inherits", + "license": "ISC", + "scripts": { + "test": "tap" + }, + "devDependencies": { + "tap": "^14.2.4" + }, + "files": [ + "inherits.js", + "inherits_browser.js" + ] +} diff --git a/node_modules/is-array-buffer/.eslintrc b/node_modules/is-array-buffer/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..46f3b120b8724f7a62ece8975157c2df19e5f1b3 --- /dev/null +++ b/node_modules/is-array-buffer/.eslintrc @@ -0,0 +1,13 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "new-cap": ["error", { + "capIsNewExceptions": [ + "GetIntrinsic", + ], + }], + }, +} diff --git a/node_modules/is-array-buffer/.github/FUNDING.yml b/node_modules/is-array-buffer/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..61d7d6ce568c71f306d99253f991b7e19aa4630b --- /dev/null +++ b/node_modules/is-array-buffer/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/is-array-buffer +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/is-array-buffer/.nycrc b/node_modules/is-array-buffer/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/is-array-buffer/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/is-array-buffer/CHANGELOG.md b/node_modules/is-array-buffer/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..0c84af712b61643fc22f71a770624f0ae4c64a68 --- /dev/null +++ b/node_modules/is-array-buffer/CHANGELOG.md @@ -0,0 +1,58 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v3.0.2](https://github.com/fengyuanchen/is-array-buffer/compare/v3.0.1...v3.0.2) - 2023-03-01 + +### Commits + +- [Fix] `node` 0.8: an object arg to a TA only throws a RangeError when it is an ArrayBuffer of an incompatible byte length [`d5108f6`](https://github.com/fengyuanchen/is-array-buffer/commit/d5108f6d06245e616b6c563995f214a38732243c) +- [Dev Deps] update `object-inspect`, `tape` [`400f456`](https://github.com/fengyuanchen/is-array-buffer/commit/400f4563ccbe27c7fbb485665352c76210bba9cb) +- [Deps] update `get-intrinsic` [`133732e`](https://github.com/fengyuanchen/is-array-buffer/commit/133732ec88f8dded1c705b758badc2240077a6d8) + +## [v3.0.1](https://github.com/fengyuanchen/is-array-buffer/compare/v3.0.0...v3.0.1) - 2023-01-05 + +### Commits + +- [Fix] in node 0.8, TAs do not coerce Uint8Arrays to an ArrayBuffer properly [`e488763`](https://github.com/fengyuanchen/is-array-buffer/commit/e48876346f446825dad619e55dcc830ed93f2853) +- [Dev Deps] update `@ljharb/eslint-config`, `aud` [`8eebfa2`](https://github.com/fengyuanchen/is-array-buffer/commit/8eebfa21881f3a9fa5094f8c486f00e496658ea9) + +## [v3.0.0](https://github.com/fengyuanchen/is-array-buffer/compare/v2.0.0...v3.0.0) - 2023-01-04 + +### Commits + +- [Breaking] replace package implementation [`b65f929`](https://github.com/fengyuanchen/is-array-buffer/commit/b65f929d856d2a42f043be0f5a0fc2e067370ed1) +- Initial implementation, tests, readme [`06afa73`](https://github.com/fengyuanchen/is-array-buffer/commit/06afa73e775960802ea9257cc6b4cdf768c72d3f) +- Initial commit [`051813f`](https://github.com/fengyuanchen/is-array-buffer/commit/051813f15e3cbf515e2447306761dd9c42819150) +- npm init [`946d3de`](https://github.com/fengyuanchen/is-array-buffer/commit/946d3de82b15471fb2c00a4a2a5a52eb0515eb04) +- [meta] use `npmignore` to autogenerate an npmignore file [`ca4c446`](https://github.com/fengyuanchen/is-array-buffer/commit/ca4c446f37daf5ab8cc590f2194574c2706561ed) +- Only apps should have lockfiles [`be7d8eb`](https://github.com/fengyuanchen/is-array-buffer/commit/be7d8eb09dc5033c04df85d7ba9a8714f4e54357) +- docs: fix badge link [`9ea7fb6`](https://github.com/fengyuanchen/is-array-buffer/commit/9ea7fb638e79f8938161b3b7370cb965d8e93a8b) + + + +## 2.0.0 (Feb 12, 2021) + +- Refactor in TypeScript. +- Drop the `dist` directory. +- Drop the UMD bundled file. +- Add a declaration file for TypeScript. + +## 1.0.1 (Apr 1, 2018) + +- Improve code style. + +## 1.0.0 (Jul 25, 2017) + +- Supports UMD, CommonJS and ES Module. + +## 0.1.0 (Nov 28, 2015) + +- Check if ArrayBuffer is defined first. + +## 0.0.1 (Nov 11, 2015) + +- Initial release. diff --git a/node_modules/is-array-buffer/LICENSE b/node_modules/is-array-buffer/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..a9b309c224b7b2fca6babe7f08f6bd42b7a27181 --- /dev/null +++ b/node_modules/is-array-buffer/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2015 Chen Gengyuan, Inspect JS + +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. diff --git a/node_modules/is-array-buffer/README.md b/node_modules/is-array-buffer/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7b0292f6d40ba1c00d9277224299ca922b3a9276 --- /dev/null +++ b/node_modules/is-array-buffer/README.md @@ -0,0 +1,56 @@ +# is-array-buffer [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Is this value a JS ArrayBuffer? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag. + +## Example + +```js +var assert = require('assert'); +var isArrayBuffer = require('is-array-buffer'); + +assert(!isArrayBuffer(function () {})); +assert(!isArrayBuffer(null)); +assert(!isArrayBuffer(function* () { yield 42; return Infinity; }); +assert(!isArrayBuffer(Symbol('foo'))); +assert(!isArrayBuffer(1n)); +assert(!isArrayBuffer(Object(1n))); + +assert(!isArrayBuffer(new Set())); +assert(!isArrayBuffer(new WeakSet())); +assert(!isArrayBuffer(new Map())); +assert(!isArrayBuffer(new WeakMap())); +assert(!isArrayBuffer(new WeakRef({}))); +assert(!isArrayBuffer(new FinalizationRegistry(() => {}))); +assert(!isArrayBuffer(new SharedArrayBuffer())); + +assert(isArrayBuffer(new ArrayBuffer())); + +class MyArrayBuffer extends ArrayBuffer {} +assert(isArrayBuffer(new MyArrayBuffer())); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/is-array-buffer +[npm-version-svg]: https://versionbadg.es/inspect-js/is-array-buffer.svg +[deps-svg]: https://david-dm.org/inspect-js/is-array-buffer.svg +[deps-url]: https://david-dm.org/inspect-js/is-array-buffer +[dev-deps-svg]: https://david-dm.org/inspect-js/is-array-buffer/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/is-array-buffer#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/is-array-buffer.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/is-array-buffer.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/is-array-buffer.svg +[downloads-url]: https://npm-stat.com/charts.html?package=is-array-buffer +[codecov-image]: https://codecov.io/gh/inspect-js/is-array-buffer/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/is-array-buffer/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-array-buffer +[actions-url]: https://github.com/inspect-js/is-array-buffer/actions diff --git a/node_modules/is-array-buffer/index.js b/node_modules/is-array-buffer/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7674285eee05c164d1603bc68a07ed7aaa178548 --- /dev/null +++ b/node_modules/is-array-buffer/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var callBind = require('call-bind'); +var callBound = require('call-bind/callBound'); +var GetIntrinsic = require('get-intrinsic'); +var isTypedArray = require('is-typed-array'); + +var $ArrayBuffer = GetIntrinsic('ArrayBuffer', true); +var $Float32Array = GetIntrinsic('Float32Array', true); +var $byteLength = callBound('ArrayBuffer.prototype.byteLength', true); + +// in node 0.10, ArrayBuffers have no prototype methods, but have an own slot-checking `slice` method +var abSlice = $ArrayBuffer && !$byteLength && new $ArrayBuffer().slice; +var $abSlice = abSlice && callBind(abSlice); + +module.exports = $byteLength || $abSlice + ? function isArrayBuffer(obj) { + if (!obj || typeof obj !== 'object') { + return false; + } + try { + if ($byteLength) { + $byteLength(obj); + } else { + $abSlice(obj, 0); + } + return true; + } catch (e) { + return false; + } + } + : $Float32Array + // in node 0.8, ArrayBuffers have no prototype or own methods + ? function IsArrayBuffer(obj) { + try { + return (new $Float32Array(obj)).buffer === obj && !isTypedArray(obj); + } catch (e) { + return typeof obj === 'object' && e.name === 'RangeError'; + } + } + : function isArrayBuffer(obj) { // eslint-disable-line no-unused-vars + return false; + }; diff --git a/node_modules/is-array-buffer/package.json b/node_modules/is-array-buffer/package.json new file mode 100644 index 0000000000000000000000000000000000000000..6b1f125750fb1295f9767db0e216ad3b1b92eb8e --- /dev/null +++ b/node_modules/is-array-buffer/package.json @@ -0,0 +1,78 @@ +{ + "name": "is-array-buffer", + "version": "3.0.2", + "description": "Is this value a JS ArrayBuffer?", + "main": "index.js", + "exports": { + ".": "./index.js", + "./package.json": "./package.json" + }, + "sideEffects": false, + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated", + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "lint": "eslint --ext=.js,.mjs .", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only --", + "posttest": "aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/inspect-js/is-array-buffer.git" + }, + "keywords": [ + "javascript", + "ecmascript", + "is", + "arraybuffer", + "array", + "buffer" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/is-array-buffer/issues" + }, + "homepage": "https://github.com/inspect-js/is-array-buffer#readme", + "devDependencies": { + "@ljharb/eslint-config": "^21.0.1", + "aud": "^2.0.2", + "auto-changelog": "^2.4.0", + "available-typed-arrays": "^1.0.5", + "es-value-fixtures": "^1.4.2", + "eslint": "=8.8.0", + "for-each": "^0.3.3", + "in-publish": "^2.0.1", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "object-inspect": "^1.12.3", + "safe-publish-latest": "^2.0.0", + "tape": "^5.6.3" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true, + "startingVersion": "2.0.1" + }, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.0", + "is-typed-array": "^1.1.10" + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] + } +} diff --git a/node_modules/is-array-buffer/test/index.js b/node_modules/is-array-buffer/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7ddf9d72fc737d914d99a513cc3fd83c0943f525 --- /dev/null +++ b/node_modules/is-array-buffer/test/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var test = require('tape'); +var inspect = require('object-inspect'); +var forEach = require('for-each'); +var v = require('es-value-fixtures'); +var availableTypedArrays = require('available-typed-arrays')(); + +var isArrayBuffer = require('..'); + +test('isArrayBuffer', function (t) { + t.equal(typeof isArrayBuffer, 'function', 'is a function'); + + var nonABs = v.primitives.concat( + v.objects, + typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer() : [] + ); + forEach(nonABs, function (nonAB) { + t.equal(isArrayBuffer(nonAB), false, inspect(nonAB) + ' is not an ArrayBuffer'); + }); + + t.test('actual ArrayBuffer instances', { skip: typeof ArrayBuffer === 'undefined' }, function (st) { + var ab = new ArrayBuffer(); + st.equal(isArrayBuffer(ab), true, inspect(ab) + ' is an ArrayBuffer'); + + var ab42 = new ArrayBuffer(42); + st.equal(isArrayBuffer(ab42), true, inspect(ab42) + ' is an ArrayBuffer'); + + st.end(); + }); + + t.test('Typed Arrays', { skip: availableTypedArrays.length === 0 }, function (st) { + forEach(availableTypedArrays, function (TypedArray) { + var ta = new global[TypedArray](0); + st.equal(isArrayBuffer(ta.buffer), true, inspect(ta.buffer) + ', the TA\'s buffer, is an ArrayBuffer'); + st.equal(isArrayBuffer(ta), false, inspect(ta) + ' is not an ArrayBuffer'); + }); + + st.end(); + }); + + t.end(); +}); diff --git a/node_modules/is-bigint/.eslintignore b/node_modules/is-bigint/.eslintignore new file mode 100644 index 0000000000000000000000000000000000000000..404abb22121cdcbb710c56f4ba2684789cb2868c --- /dev/null +++ b/node_modules/is-bigint/.eslintignore @@ -0,0 +1 @@ +coverage/ diff --git a/node_modules/is-bigint/.eslintrc b/node_modules/is-bigint/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..1283fcf6ee4402782d72369b4ce01fa18ec70605 --- /dev/null +++ b/node_modules/is-bigint/.eslintrc @@ -0,0 +1,10 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "new-cap": [2, { "capIsNewExceptions": ["BigInt"] }], + "operator-linebreak": [2, "before"], + }, +} diff --git a/node_modules/is-bigint/.github/FUNDING.yml b/node_modules/is-bigint/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..59d03ba7df819be65723e1a62e7db6f3c6b1e8ab --- /dev/null +++ b/node_modules/is-bigint/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/is-bigint +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/is-bigint/.nycrc b/node_modules/is-bigint/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/is-bigint/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/is-bigint/CHANGELOG.md b/node_modules/is-bigint/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..c1b0271ef8dc5ad5a75fb0c3f441bc539284972c --- /dev/null +++ b/node_modules/is-bigint/CHANGELOG.md @@ -0,0 +1,71 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.4](https://github.com/inspect-js/is-bigint/compare/v1.0.3...v1.0.4) - 2021-08-11 + +### Commits + +- [eslint] remove unnecessary eslintrc file [`7220aa5`](https://github.com/inspect-js/is-bigint/commit/7220aa515c51649b48ba57bb77f92d85e27557d8) +- [readme] add github actions/codecov badges [`053a071`](https://github.com/inspect-js/is-bigint/commit/053a07123511eef5a91fd7889ae2d8323fbcf7d7) +- [Deps] add `has-bigints` as a runtime dependency [`0fc3c9d`](https://github.com/inspect-js/is-bigint/commit/0fc3c9d5165f62500ea9c27943cb302df65432f7) +- [Dev Deps] update `tape` [`145f11d`](https://github.com/inspect-js/is-bigint/commit/145f11d1d285d92b3144f48178fe0fb3b2f828d9) + +## [v1.0.3](https://github.com/inspect-js/is-bigint/compare/v1.0.2...v1.0.3) - 2021-08-06 + +### Commits + +- [Tests] use `has-tostringtag` for easier checking of Symbol.toStringTag [`3b44080`](https://github.com/inspect-js/is-bigint/commit/3b440801b69689d907b33184134f00d7e8a35f9f) +- [Dev Deps] update `auto-changelog`, `eslint`, `object-inspect`, `tape` [`e4d4a6c`](https://github.com/inspect-js/is-bigint/commit/e4d4a6c2ab743b52eda906abd1ed4b0608952533) +- [Fix] use `has-bigints` for more robust BigInt detection [`7bb9d7a`](https://github.com/inspect-js/is-bigint/commit/7bb9d7ab42214c12ce25e9f0cfe2af769388c3bb) + +## [v1.0.2](https://github.com/inspect-js/is-bigint/compare/v1.0.1...v1.0.2) - 2021-05-04 + +### Commits + +- [meta] do not publish github action workflow files [`276d677`](https://github.com/inspect-js/is-bigint/commit/276d677d1eac61e990a2f2b523c7cdef70784865) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`cea7fb6`](https://github.com/inspect-js/is-bigint/commit/cea7fb6e882ad7e2f550de2bd9317a4409bcd735) +- [readme] fix repo URLs; remove travis badge [`c8e7c36`](https://github.com/inspect-js/is-bigint/commit/c8e7c3651f3303fddafa61cf29cfbb79ea2d5d4b) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-symbols`, `object-inspect`, `tape` [`32f3d90`](https://github.com/inspect-js/is-bigint/commit/32f3d909363045fe5d40dde9e4db354344ab4d50) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `tape` [`c2f20f5`](https://github.com/inspect-js/is-bigint/commit/c2f20f577d84e68b4e3224abb51024fbc4b9b2ba) +- [meta] remove unneeded token; update checkout action [`94e46e9`](https://github.com/inspect-js/is-bigint/commit/94e46e92a1a85ec022c8febf8d5d3c2369b46e97) +- [meta] use `prepublishOnly` script for npm 7+ [`3e663ec`](https://github.com/inspect-js/is-bigint/commit/3e663ecb09bfdc5dbaaa37aaef4adf28b5e49035) + +## [v1.0.1](https://github.com/inspect-js/is-bigint/compare/v1.0.0...v1.0.1) - 2020-11-30 + +### Commits + +- [Tests] use shared travis-ci configs [`28f1211`](https://github.com/inspect-js/is-bigint/commit/28f1211132ad2a6495d816140680fa16c12eb6f3) +- [Tests] migrate tests to Github Actions [`0998c64`](https://github.com/inspect-js/is-bigint/commit/0998c6443d603028f8b988bcdd52d23dbf513031) +- [meta] add `auto-changelog` [`2352de6`](https://github.com/inspect-js/is-bigint/commit/2352de6df8385b256d75ce50c360947243a599f6) +- [Tests] run `nyc` on all tests [`9c16a9a`](https://github.com/inspect-js/is-bigint/commit/9c16a9a5ddaf7c2c578542ab8f00dd4e72eff541) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `object-inspect`, `tape` [`4cd0edd`](https://github.com/inspect-js/is-bigint/commit/4cd0edd1917f789501291315c9eac5f895fd719e) +- [actions] add automatic rebasing / merge commit blocking [`f0f4b91`](https://github.com/inspect-js/is-bigint/commit/f0f4b91dba029dbca5b3cd27ef91c4fb8e3ec51a) +- [actions] add "Allow Edits" workflow [`7f4f46e`](https://github.com/inspect-js/is-bigint/commit/7f4f46ec07679c00e22287ec55b39ff1e4f809cf) +- [meta] create FUNDING.yml [`2d0cb9a`](https://github.com/inspect-js/is-bigint/commit/2d0cb9ae8ddf635f2c472ce49f95f717f2c432bf) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud` [`0ee110e`](https://github.com/inspect-js/is-bigint/commit/0ee110effdcaa96d90f21a0ec6e625941f77c45a) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `has-symbols`, `object-inspect`, `tape` [`5bb7f3a`](https://github.com/inspect-js/is-bigint/commit/5bb7f3a8de6ec5ee2aa573c22e41884f3d2d1cc3) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `tape` [`d3d67d0`](https://github.com/inspect-js/is-bigint/commit/d3d67d05f8a3f4cb07085811629f56ef872949c3) +- [Dev Deps] update `auto-changelog`, `tape` [`54e270f`](https://github.com/inspect-js/is-bigint/commit/54e270fa29856dba90f86785fa61bffc79a2825d) +- [Dev Deps] update `@ljharb/eslint-config`, `tape` [`d82bfe7`](https://github.com/inspect-js/is-bigint/commit/d82bfe75c63aeda40f7e473c57f26cea8790ba3a) +- [Dev Deps] update `auto-changelog`; add `aud` [`9c34bd1`](https://github.com/inspect-js/is-bigint/commit/9c34bd1873f08d77c82d8e54ad90c5a1a035e7ea) +- [Tests] add missing `posttest` script [`0690bd9`](https://github.com/inspect-js/is-bigint/commit/0690bd9868d4d8b43424b4224cdbb8659a1c6423) +- [meta] add `funding` field [`7ca36d0`](https://github.com/inspect-js/is-bigint/commit/7ca36d06ebcf6b01a592ecd6758bd2b39c0fb0db) +- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`5ffa8da`](https://github.com/inspect-js/is-bigint/commit/5ffa8dad9f634891cf739ee118f1b43142b0f01d) +- [Dev Deps] update `eslint` [`8512c2f`](https://github.com/inspect-js/is-bigint/commit/8512c2f29a9267fe8fe19209bcf77df94f127172) +- [Tests] only audit prod deps [`f2147dc`](https://github.com/inspect-js/is-bigint/commit/f2147dc54e72594985e8f6db3932a4f0819dc4db) +- [readme] fix header [`d6eff75`](https://github.com/inspect-js/is-bigint/commit/d6eff75d00471f465768deb92867e878c27733b3) + +## v1.0.0 - 2018-09-20 + +### Commits + +- [Tests] add tests [`847f12a`](https://github.com/inspect-js/is-bigint/commit/847f12af125fcefb75ed3517550feedf7dd73e88) +- Initial commit [`b53f3c6`](https://github.com/inspect-js/is-bigint/commit/b53f3c6754e7fd7a9982ff5b1466c4dc9799dad9) +- readme [`66c15fe`](https://github.com/inspect-js/is-bigint/commit/66c15fe1a0d965b8c78bf3a3bfc289dcfec53ee1) +- Implementation [`c2c0974`](https://github.com/inspect-js/is-bigint/commit/c2c0974397825a2a56e1ea8af0546171309d4805) +- package.json [`98b174c`](https://github.com/inspect-js/is-bigint/commit/98b174c24b070053f0548e58f9b87bc9dbdf922a) +- Only apps should have lockfiles [`a77c74b`](https://github.com/inspect-js/is-bigint/commit/a77c74bd8ca5f058f1e6165ae7b33bb84adef98c) diff --git a/node_modules/is-bigint/LICENSE b/node_modules/is-bigint/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..9dd868f0f9e1cf5cd2d18fe0070c909a9b36cc62 --- /dev/null +++ b/node_modules/is-bigint/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Jordan Harband + +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. diff --git a/node_modules/is-bigint/README.md b/node_modules/is-bigint/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d64549fca08940bdbff8c366cea662af9df09d68 --- /dev/null +++ b/node_modules/is-bigint/README.md @@ -0,0 +1,44 @@ +# is-bigint [![Version Badge][2]][1] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +Is this an ES BigInt value? + +## Example + +```js +var isBigInt = require('is-bigint'); +assert(!isBigInt(function () {})); +assert(!isBigInt(null)); +assert(!isBigInt(function* () { yield 42; return Infinity; }); +assert(!isBigInt(Symbol('foo'))); + +assert(isBigInt(1n)); +assert(isBigInt(Object(1n))); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/is-bigint +[2]: https://versionbadg.es/inspect-js/is-bigint.svg +[5]: https://david-dm.org/inspect-js/is-bigint.svg +[6]: https://david-dm.org/inspect-js/is-bigint +[7]: https://david-dm.org/inspect-js/is-bigint/dev-status.svg +[8]: https://david-dm.org/inspect-js/is-bigint#info=devDependencies +[11]: https://nodei.co/npm/is-bigint.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/is-bigint.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/is-bigint.svg +[downloads-url]: https://npm-stat.com/charts.html?package=is-bigint +[codecov-image]: https://codecov.io/gh/inspect-js/is-bigint/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/is-bigint/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-bigint +[actions-url]: https://github.com/inspect-js/is-bigint/actions diff --git a/node_modules/is-bigint/index.js b/node_modules/is-bigint/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8da47d7438e4429006c29178e3cbe4817f66d540 --- /dev/null +++ b/node_modules/is-bigint/index.js @@ -0,0 +1,38 @@ +'use strict'; + +var hasBigInts = require('has-bigints')(); + +if (hasBigInts) { + var bigIntValueOf = BigInt.prototype.valueOf; + var tryBigInt = function tryBigIntObject(value) { + try { + bigIntValueOf.call(value); + return true; + } catch (e) { + } + return false; + }; + + module.exports = function isBigInt(value) { + if ( + value === null + || typeof value === 'undefined' + || typeof value === 'boolean' + || typeof value === 'string' + || typeof value === 'number' + || typeof value === 'symbol' + || typeof value === 'function' + ) { + return false; + } + if (typeof value === 'bigint') { + return true; + } + + return tryBigInt(value); + }; +} else { + module.exports = function isBigInt(value) { + return false && value; + }; +} diff --git a/node_modules/is-bigint/package.json b/node_modules/is-bigint/package.json new file mode 100644 index 0000000000000000000000000000000000000000..850dbd82bd1c5387041309bd7c31c9941a3a4b03 --- /dev/null +++ b/node_modules/is-bigint/package.json @@ -0,0 +1,58 @@ +{ + "name": "is-bigint", + "version": "1.0.4", + "description": "Is this value an ES BigInt?", + "main": "index.js", + "scripts": { + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "lint": "eslint .", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/inspect-js/is-bigint.git" + }, + "keywords": [ + "bigint", + "es", + "integer", + "is" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/is-bigint/issues" + }, + "homepage": "https://github.com/inspect-js/is-bigint#readme", + "dependencies": { + "has-bigints": "^1.0.1" + }, + "devDependencies": { + "@ljharb/eslint-config": "^17.6.0", + "aud": "^1.1.5", + "auto-changelog": "^2.3.0", + "eslint": "^7.32.0", + "has-symbols": "^1.0.2", + "nyc": "^10.3.2", + "object-inspect": "^1.11.0", + "safe-publish-latest": "^1.1.4", + "tape": "^5.3.1" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + } +} diff --git a/node_modules/is-bigint/test/index.js b/node_modules/is-bigint/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..21537d6a3f40afb59d27b3ca419fd567e10f9e60 --- /dev/null +++ b/node_modules/is-bigint/test/index.js @@ -0,0 +1,81 @@ +'use strict'; + +var test = require('tape'); +var inspect = require('object-inspect'); +var hasBigInts = require('has-bigints')(); +var hasSymbols = require('has-symbols')(); +var hasToStringTag = require('has-tostringtag/shams')(); + +var isBigInt = require('../'); + +var debug = function (v, m) { return inspect(v) + ' ' + m; }; + +var forEach = function (arr, func) { + var i; + for (i = 0; i < arr.length; ++i) { + func(arr[i], i, arr); + } +}; + +test('non-BigInt values', function (t) { + var nonBigInts = [ + true, + false, + Object(true), + Object(false), + null, + undefined, + {}, + [], + /a/g, + 'string', + 42, + new Date(), + function () {}, + NaN + ]; + if (hasSymbols) { + nonBigInts.push(Symbol.iterator, Symbol('foo')); + } + t.plan(nonBigInts.length); + forEach(nonBigInts, function (nonBigInt) { + t.equal(false, isBigInt(nonBigInt), debug(nonBigInt, 'is not a BigInt')); + }); + t.end(); +}); + +test('faked BigInt values', function (t) { + t.test('real BigInt valueOf', { skip: !hasBigInts }, function (st) { + var fakeBigInt = { valueOf: function () { return BigInt(42); } }; + st.equal(false, isBigInt(fakeBigInt), 'object with valueOf returning a BigInt is not a BigInt'); + st.end(); + }); + + t.test('faked @@toStringTag', { skip: !hasBigInts || !hasToStringTag }, function (st) { + var fakeBigInt = { valueOf: function () { return BigInt(42); } }; + fakeBigInt[Symbol.toStringTag] = 'BigInt'; + st.equal(false, isBigInt(fakeBigInt), 'object with fake BigInt @@toStringTag and valueOf returning a BigInt is not a BigInt'); + + var notSoFakeBigInt = { valueOf: function () { return 42; } }; + notSoFakeBigInt[Symbol.toStringTag] = 'BigInt'; + st.equal(false, isBigInt(notSoFakeBigInt), 'object with fake BigInt @@toStringTag and valueOf not returning a BigInt is not a BigInt'); + st.end(); + }); + + var fakeBigIntString = { toString: function () { return '42n'; } }; + t.equal(false, isBigInt(fakeBigIntString), 'object with toString returning 42n is not a BigInt'); + + t.end(); +}); + +test('BigInt support', { skip: !hasBigInts }, function (t) { + forEach([ + Function('return 42n')(), // eslint-disable-line no-new-func + BigInt(42), + Object(BigInt(42)) + ], function (bigInt) { + t.equal(true, isBigInt(bigInt), debug(bigInt, 'is a BigInt')); + }); + + t.end(); +}); diff --git a/node_modules/is-binary-path/index.d.ts b/node_modules/is-binary-path/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..19dcd4327beddb4d48ffc5a79eb8c306903574b4 --- /dev/null +++ b/node_modules/is-binary-path/index.d.ts @@ -0,0 +1,17 @@ +/** +Check if a file path is a binary file. + +@example +``` +import isBinaryPath = require('is-binary-path'); + +isBinaryPath('source/unicorn.png'); +//=> true + +isBinaryPath('source/unicorn.txt'); +//=> false +``` +*/ +declare function isBinaryPath(filePath: string): boolean; + +export = isBinaryPath; diff --git a/node_modules/is-binary-path/index.js b/node_modules/is-binary-path/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ef7548c8303298520e15e7e680bf99aee21f787a --- /dev/null +++ b/node_modules/is-binary-path/index.js @@ -0,0 +1,7 @@ +'use strict'; +const path = require('path'); +const binaryExtensions = require('binary-extensions'); + +const extensions = new Set(binaryExtensions); + +module.exports = filePath => extensions.has(path.extname(filePath).slice(1).toLowerCase()); diff --git a/node_modules/is-binary-path/license b/node_modules/is-binary-path/license new file mode 100644 index 0000000000000000000000000000000000000000..401b1c731bcd3ed3193b94d7cbb81bd3b4a1dd47 --- /dev/null +++ b/node_modules/is-binary-path/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2019 Sindre Sorhus (https://sindresorhus.com), Paul Miller (https://paulmillr.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. diff --git a/node_modules/is-binary-path/package.json b/node_modules/is-binary-path/package.json new file mode 100644 index 0000000000000000000000000000000000000000..a8d005aed80f8729749e0302d16bf0a6f2ab7eb6 --- /dev/null +++ b/node_modules/is-binary-path/package.json @@ -0,0 +1,40 @@ +{ + "name": "is-binary-path", + "version": "2.1.0", + "description": "Check if a file path is a binary file", + "license": "MIT", + "repository": "sindresorhus/is-binary-path", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "binary", + "extensions", + "extension", + "file", + "path", + "check", + "detect", + "is" + ], + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "devDependencies": { + "ava": "^1.4.1", + "tsd": "^0.7.2", + "xo": "^0.24.0" + } +} diff --git a/node_modules/is-binary-path/readme.md b/node_modules/is-binary-path/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..b4ab02519b0fdefb0f64748adcc1d35111a2cf75 --- /dev/null +++ b/node_modules/is-binary-path/readme.md @@ -0,0 +1,34 @@ +# is-binary-path [![Build Status](https://travis-ci.org/sindresorhus/is-binary-path.svg?branch=master)](https://travis-ci.org/sindresorhus/is-binary-path) + +> Check if a file path is a binary file + + +## Install + +``` +$ npm install is-binary-path +``` + + +## Usage + +```js +const isBinaryPath = require('is-binary-path'); + +isBinaryPath('source/unicorn.png'); +//=> true + +isBinaryPath('source/unicorn.txt'); +//=> false +``` + + +## Related + +- [binary-extensions](https://github.com/sindresorhus/binary-extensions) - List of binary file extensions +- [is-text-path](https://github.com/sindresorhus/is-text-path) - Check if a filepath is a text file + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com), [Paul Miller](https://paulmillr.com) diff --git a/node_modules/is-date-object/.editorconfig b/node_modules/is-date-object/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..bc228f8269443bf772b437890dde7756a3e8a894 --- /dev/null +++ b/node_modules/is-date-object/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 150 + +[CHANGELOG.md] +indent_style = space +indent_size = 2 + +[*.json] +max_line_length = off + +[Makefile] +max_line_length = off diff --git a/node_modules/is-date-object/.eslintignore b/node_modules/is-date-object/.eslintignore new file mode 100644 index 0000000000000000000000000000000000000000..404abb22121cdcbb710c56f4ba2684789cb2868c --- /dev/null +++ b/node_modules/is-date-object/.eslintignore @@ -0,0 +1 @@ +coverage/ diff --git a/node_modules/is-date-object/.eslintrc b/node_modules/is-date-object/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..1228f975c9973895e0ec9ec5791f4691a8a40fbf --- /dev/null +++ b/node_modules/is-date-object/.eslintrc @@ -0,0 +1,9 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "max-statements": [2, 12] + } +} diff --git a/node_modules/is-date-object/.github/FUNDING.yml b/node_modules/is-date-object/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..9cfa9fde08ee19c449a24db5dfd90e3f8866ff7f --- /dev/null +++ b/node_modules/is-date-object/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/is-date-object +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/is-date-object/.nycrc b/node_modules/is-date-object/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..a69aa2d8273d8c598f8e3aa5c8d779e28d63862f --- /dev/null +++ b/node_modules/is-date-object/.nycrc @@ -0,0 +1,10 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test", + "test-corejs.js" + ] +} diff --git a/node_modules/is-date-object/CHANGELOG.md b/node_modules/is-date-object/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..49f624a4251f2e2c21e831cb51150a00c210055d --- /dev/null +++ b/node_modules/is-date-object/CHANGELOG.md @@ -0,0 +1,114 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.5](https://github.com/inspect-js/is-date-object/compare/v1.0.4...v1.0.5) - 2021-08-05 + +### Commits + +- [meta] remove `.jscs.json` [`31c731c`](https://github.com/inspect-js/is-date-object/commit/31c731c5efc5b1b86e6426d904373dc6225b929f) +- [Fix] use `has-tostringtag` to behave correctly in the presence of symbol shams [`17a6df4`](https://github.com/inspect-js/is-date-object/commit/17a6df4a3ab9bcb1395a638ced14f571f9549427) +- [Dev Deps] update `eslint`, `auto-changelog`, `tape` [`79db3af`](https://github.com/inspect-js/is-date-object/commit/79db3af1a745042a0a11e03c7dd7db910b5e0d01) + +## [v1.0.4](https://github.com/inspect-js/is-date-object/compare/v1.0.3...v1.0.4) - 2021-05-07 + +### Commits + +- [Fix] do not use `Object.prototype.toString` when `Symbol.toStringTag` is shammed [`8943a4a`](https://github.com/inspect-js/is-date-object/commit/8943a4a5035b3f2c8cee9a5edabb55579c16983d) +- [readme] make all URLs https [`1d4d6cd`](https://github.com/inspect-js/is-date-object/commit/1d4d6cd37365c3a36f98e3f82cfe6262227437db) +- [Dev Deps] update `eslint` [`a7abeaa`](https://github.com/inspect-js/is-date-object/commit/a7abeaa2409d3a34fccebcb5b362e0b90d0a8883) + +## [v1.0.3](https://github.com/inspect-js/is-date-object/compare/v1.0.2...v1.0.3) - 2021-05-05 + +### Commits + +- [Tests] migrate tests to Github Actions [`023504f`](https://github.com/inspect-js/is-date-object/commit/023504f4d48fc8788ff52ee525a1d9ec74fa7df5) +- [readme] add actions and codecov badges [`e63305f`](https://github.com/inspect-js/is-date-object/commit/e63305f2fb9ff3eb0dab7e0716585507a4f95a75) +- [meta] do not publish github action workflow files [`017d906`](https://github.com/inspect-js/is-date-object/commit/017d90679b6b1c16b398c0157904f91f56160219) +- [Tests] run `nyc` on all tests [`0376b6f`](https://github.com/inspect-js/is-date-object/commit/0376b6fb7a0ffcc42107c3c579ba0b3ab635b9e4) +- [readme] fix repo URLs; remove defunct badges [`1c148c6`](https://github.com/inspect-js/is-date-object/commit/1c148c6cb6eb0892b3186e814df3367dabb9732d) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`c7a3f54`](https://github.com/inspect-js/is-date-object/commit/c7a3f54a207a6056ffafaa58178889ea1b1b77f7) +- [actions] add "Allow Edits" workflow [`e79b5b2`](https://github.com/inspect-js/is-date-object/commit/e79b5b25c173c3201e8b42a614d5f12c48b74a86) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`da28980`](https://github.com/inspect-js/is-date-object/commit/da28980c5fe86528585b2a420319ca8fc35f763a) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog` [`5cabae9`](https://github.com/inspect-js/is-date-object/commit/5cabae9f00bf458a470bde68b734540b8ab78c3b) +- [readme] add actions and codecov badges [`33dfb88`](https://github.com/inspect-js/is-date-object/commit/33dfb881b7abf668cd3bf956e2947a1ece552f25) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`745eb04`](https://github.com/inspect-js/is-date-object/commit/745eb0462ef3838df65f41f4a95453cc4f0aa06e) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`466c62b`](https://github.com/inspect-js/is-date-object/commit/466c62b45af5a5a83963f6ef8617da887b0ab272) +- [actions] use checkout v2; remove unneeded env [`ff87a16`](https://github.com/inspect-js/is-date-object/commit/ff87a161e36d76d081d70933bf801a357c3b25fe) +- [Dev Deps] update `auto-changelog`, `tape` [`93188f5`](https://github.com/inspect-js/is-date-object/commit/93188f58e4b2c2b5e978a61a45380101d01f9838) +- [meta] use `prepublishOnly` script for npm 7+ [`1d0e3ea`](https://github.com/inspect-js/is-date-object/commit/1d0e3ea672971f02bb48c88b49079789ab41f574) +- [actions] update workflows [`4d1a235`](https://github.com/inspect-js/is-date-object/commit/4d1a2358de35a9fbe23a1dee10735748ed276301) +- [Dev Deps] update `auto-changelog`; add `aud` [`67be59a`](https://github.com/inspect-js/is-date-object/commit/67be59aa3c0ba44b982aaefb7e42adfb14eb279b) +- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`a6661c2`](https://github.com/inspect-js/is-date-object/commit/a6661c26af701a7782f6e06ad1b34587ce2b09bc) +- [Tests] only audit prod deps [`dd4a47f`](https://github.com/inspect-js/is-date-object/commit/dd4a47f8bcf82c3090826d890a7766f50d6f7af9) + +## [v1.0.2](https://github.com/inspect-js/is-date-object/compare/v1.0.1...v1.0.2) - 2019-12-18 + +### Commits + +- [Tests] use shared travis-ci configs [`8a378b8`](https://github.com/inspect-js/is-date-object/commit/8a378b8fd6a4202fffc9ec193aca02efe937bc35) +- [Tests] on all node minors; use `nvm install-latest-npm`; fix scripts; improve matrix [`6e97a21`](https://github.com/inspect-js/is-date-object/commit/6e97a21276cf448ce424fb9ea13edd4587f289f1) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `is`, `jscs`, `nsp`, `semver`, `tape` [`8472b90`](https://github.com/inspect-js/is-date-object/commit/8472b90f82e5153c22e7a8a7726a5cc6110e93d7) +- [Tests] up to `node` `v10.0`, `v9.11`, `v8.11`, `v6.14`, `v4.9` [`ae73e38`](https://github.com/inspect-js/is-date-object/commit/ae73e3890df7da0bc4449088e30340cb4df3294d) +- [meta] add `auto-changelog` [`82f8f47`](https://github.com/inspect-js/is-date-object/commit/82f8f473a6ee45e2b66810cb743e0122c18381c5) +- [meta] remove unused Makefile and associated utilities [`788a2cd`](https://github.com/inspect-js/is-date-object/commit/788a2cdfd0bc8f1903967219897f6d00c4c6a26b) +- [Tests] up to `node` `v11.4`, `v10.14`, `v8.14`, `v6.15` [`b9caf7c`](https://github.com/inspect-js/is-date-object/commit/b9caf7c814e5e2549454cb444f8b739f9ce1a388) +- [Tests] up to `node` `v12.4`, `v11.15`, `v10.15`, `v8.15`, `v6.17`; use `nvm install-latest-npm` [`cda0abc`](https://github.com/inspect-js/is-date-object/commit/cda0abc04a21c9b5ec72eabd010155c988032056) +- [Tests] up to `node` `v12.10`, `v10.16`, `v8.16` [`49bc482`](https://github.com/inspect-js/is-date-object/commit/49bc482fd9f71436b663c07144083a8423697299) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `semver`, `tape`; add `safe-publish-latest` [`f77fec4`](https://github.com/inspect-js/is-date-object/commit/f77fec48057e156b2276b4c14cf303306116b9f6) +- [actions] add automatic rebasing / merge commit blocking [`68605fc`](https://github.com/inspect-js/is-date-object/commit/68605fcb6bc0341ff0aae14a94bf5d18e1bc73be) +- [meta] create FUNDING.yml [`4f82d88`](https://github.com/inspect-js/is-date-object/commit/4f82d88e1e6ac1b97f0ce96aa0aa057ad758a581) +- [Dev Deps] update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`3cbf28a`](https://github.com/inspect-js/is-date-object/commit/3cbf28a185ced940cfce8a09fa8479cc83575876) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config@`, `is`, `semver`, `tape` [`abf9fb0`](https://github.com/inspect-js/is-date-object/commit/abf9fb0d55ef0697e64e888d74f2e5fe53d7cdcb) +- [Tests] switch from `nsp` to `npm audit` [`6543c7d`](https://github.com/inspect-js/is-date-object/commit/6543c7d559d1fb79215b46c8b79e0e3e2a83f5de) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `tape` [`ba5d2d7`](https://github.com/inspect-js/is-date-object/commit/ba5d2d7fc0975d7c03b8f2b7f43a09af93e365ba) +- [Dev Deps] update `eslint`, `nsp`, `semver`, `tape` [`c1e3525`](https://github.com/inspect-js/is-date-object/commit/c1e3525afa76a696f7cf1b58aab7f55d220b2c20) +- [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops [`14e4824`](https://github.com/inspect-js/is-date-object/commit/14e4824188c85207ed3b86627b09e9f64b135db7) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest` [`68ead64`](https://github.com/inspect-js/is-date-object/commit/68ead64a07e0de282ea3cd38e12cc8b0e0f6d3cd) +- [Dev Deps] update `eslint`, semver`, `tape`, `semver` [`f55453f`](https://github.com/inspect-js/is-date-object/commit/f55453f200903277465d7e9307a9c49120a4f419) +- Only apps should have lockfiles [`6c848eb`](https://github.com/inspect-js/is-date-object/commit/6c848eba982cc58053d4cca08c01f12a433f3695) +- [Tests] remove `jscs` [`3fd3a62`](https://github.com/inspect-js/is-date-object/commit/3fd3a62121607ad074b7fc977f3fc6575b66f755) +- [Dev Deps] update `eslint`, `tape` [`77d3130`](https://github.com/inspect-js/is-date-object/commit/77d3130a0039e5dae24c17de790dd510c265edc6) +- [meta] add `funding` field [`9ef6d58`](https://github.com/inspect-js/is-date-object/commit/9ef6d5888bf829a5812b3b091dc99839d48c355e) + +## [v1.0.1](https://github.com/inspect-js/is-date-object/compare/v1.0.0...v1.0.1) - 2015-09-27 + +### Commits + +- Update `tape`, `semver`, `eslint`; use my personal shared `eslint` config. [`731aa13`](https://github.com/inspect-js/is-date-object/commit/731aa134b0b8dc84e302d0b2264a415cb456ccab) +- Update `is`, `tape`, `covert`, `jscs`, `editorconfig-tools`, `nsp`, `eslint`, `semver` [`53e43a6`](https://github.com/inspect-js/is-date-object/commit/53e43a627dd01757cf3d469599f3dffd9d72b150) +- Update `eslint` [`d2fc304`](https://github.com/inspect-js/is-date-object/commit/d2fc3046f087b0026448ffde0cf46b1f741cbd4e) +- Update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`c9568df`](https://github.com/inspect-js/is-date-object/commit/c9568df228fa698dc6fcc9553b5d612e7ee427aa) +- Test on latest `node` and `io.js` versions. [`a21d537`](https://github.com/inspect-js/is-date-object/commit/a21d537562166ebd18bde3a262fd157dd774ae17) +- Update `nsp`, `eslint`, `semver` [`9e1d908`](https://github.com/inspect-js/is-date-object/commit/9e1d9087c0c79c34fcb2abfc701cdfa1efcb327c) +- Update `covert`, `jscs`, `eslint`, `semver` [`f198f6b`](https://github.com/inspect-js/is-date-object/commit/f198f6b997912da10a3d821a089e1581edc730a0) +- [Dev Deps] update `tape`, `jscs`, `eslint` [`ab9bdbb`](https://github.com/inspect-js/is-date-object/commit/ab9bdbbc189cef033346508db47cd1feb04a69d3) +- If `@@toStringTag` is not present, use the old-school `Object#toString` test. [`c03afce`](https://github.com/inspect-js/is-date-object/commit/c03afce001368b29eb929900075749b113a252c8) +- [Dev Deps] update `jscs`, `nsp`, `tape`, `eslint`, `@ljharb/eslint-config` [`9d94ccb`](https://github.com/inspect-js/is-date-object/commit/9d94ccbab4160d2fa649123e37951d86b69a8b15) +- [Dev Deps] update `is`, `eslint`, `@ljharb/eslint-config`, `semver` [`35cbff7`](https://github.com/inspect-js/is-date-object/commit/35cbff7f7c8216fbb79c799f74b2336eaf0d726a) +- Test up to `io.js` `v2.3` [`be5d11e`](https://github.com/inspect-js/is-date-object/commit/be5d11e7ebd9473d7ae554179b3769082485f6f4) +- [Tests] on `io.js` `v3.3`, up to `node` `v4.1` [`20221a3`](https://github.com/inspect-js/is-date-object/commit/20221a34858d2b21e23bdc2c08df23f0bc08d11e) +- [Tests] up to `io.js` `v3.2 ` [`7009b4a`](https://github.com/inspect-js/is-date-object/commit/7009b4a9999e14eacbdf6068afd82f478473f007) +- Test on `io.js` `v2.1` [`68b29b1`](https://github.com/inspect-js/is-date-object/commit/68b29b19a07e6589a7ca37ab764be28f144ac88e) +- Remove `editorconfig-tools` [`8d3972c`](https://github.com/inspect-js/is-date-object/commit/8d3972c1795fdcfd337680e11ab610e4885fb079) +- [Dev Deps] update `tape` [`204945d`](https://github.com/inspect-js/is-date-object/commit/204945d8658a3513ca6315ddf795e4034adb4545) +- Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. [`7bff214`](https://github.com/inspect-js/is-date-object/commit/7bff214dcb2317b96219921476f990814afbb401) +- Test on `io.js` `v2.5` [`92f7bd6`](https://github.com/inspect-js/is-date-object/commit/92f7bd6747e3259b0ddc9c287876f46a9cd4c270) +- Test on `io.js` `v2.4` [`ebb34bf`](https://github.com/inspect-js/is-date-object/commit/ebb34bf1f58949768063f86ac012f1ca5d7cf6d9) +- Fix tests for faked @@toStringTag [`3b9c26c`](https://github.com/inspect-js/is-date-object/commit/3b9c26c15040af6a87f8d77ce6c85a7bef7a4304) +- Test on `io.js` `v3.0` [`5eedf4b`](https://github.com/inspect-js/is-date-object/commit/5eedf4bea76380a08813fd0977469c2480302a82) + +## v1.0.0 - 2015-01-28 + +### Commits + +- Dotfiles. [`5b6a929`](https://github.com/inspect-js/is-date-object/commit/5b6a9298c6f70882e78e66d64c9c019f85790f52) +- `make release` [`e8d40ce`](https://github.com/inspect-js/is-date-object/commit/e8d40ceca85acd0aa4b2753faa6e41c0c54cf6c3) +- package.json [`a107259`](https://github.com/inspect-js/is-date-object/commit/a1072591ea510a2998298be6cef827b123f4643f) +- Read me [`eb92695`](https://github.com/inspect-js/is-date-object/commit/eb92695664bdee8fc49891cd73aa2f41075f53cb) +- Initial commit [`4fc7755`](https://github.com/inspect-js/is-date-object/commit/4fc7755ff12f1d7a55cf841d486bf6b2350fe5a0) +- Tests. [`b6f432f`](https://github.com/inspect-js/is-date-object/commit/b6f432fb6801c5ff8d89cfec7601d59478e23dd1) +- Implementation. [`dd0fd96`](https://github.com/inspect-js/is-date-object/commit/dd0fd96c4016a66cec7cd59db0fde37c2ef3cdb5) diff --git a/node_modules/is-date-object/LICENSE b/node_modules/is-date-object/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b43df444e518288ceef6eaa9badd33388191b1d3 --- /dev/null +++ b/node_modules/is-date-object/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +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. + diff --git a/node_modules/is-date-object/README.md b/node_modules/is-date-object/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1c084add99ae5b39a8d3c333cac94ff7ee894a6b --- /dev/null +++ b/node_modules/is-date-object/README.md @@ -0,0 +1,52 @@ +# is-date-object [![Version Badge][2]][1] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag. + +## Example + +```js +var isDate = require('is-date-object'); +var assert = require('assert'); + +assert.notOk(isDate(undefined)); +assert.notOk(isDate(null)); +assert.notOk(isDate(false)); +assert.notOk(isDate(true)); +assert.notOk(isDate(42)); +assert.notOk(isDate('foo')); +assert.notOk(isDate(function () {})); +assert.notOk(isDate([])); +assert.notOk(isDate({})); +assert.notOk(isDate(/a/g)); +assert.notOk(isDate(new RegExp('a', 'g'))); + +assert.ok(isDate(new Date())); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/is-date-object +[2]: https://versionbadg.es/inspect-js/is-date-object.svg +[5]: https://david-dm.org/inspect-js/is-date-object.svg +[6]: https://david-dm.org/inspect-js/is-date-object +[7]: https://david-dm.org/inspect-js/is-date-object/dev-status.svg +[8]: https://david-dm.org/inspect-js/is-date-object#info=devDependencies +[11]: https://nodei.co/npm/is-date-object.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/is-date-object.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/is-date-object.svg +[downloads-url]: https://npm-stat.com/charts.html?package=is-date-object +[codecov-image]: https://codecov.io/gh/inspect-js/is-date-object/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/is-date-object/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-date-object +[actions-url]: https://github.com/inspect-js/is-date-object/actions diff --git a/node_modules/is-date-object/index.js b/node_modules/is-date-object/index.js new file mode 100644 index 0000000000000000000000000000000000000000..11628f3bba919b9a5fd5ea06189039dc16d0a7df --- /dev/null +++ b/node_modules/is-date-object/index.js @@ -0,0 +1,22 @@ +'use strict'; + +var getDay = Date.prototype.getDay; +var tryDateObject = function tryDateGetDayCall(value) { + try { + getDay.call(value); + return true; + } catch (e) { + return false; + } +}; + +var toStr = Object.prototype.toString; +var dateClass = '[object Date]'; +var hasToStringTag = require('has-tostringtag/shams')(); + +module.exports = function isDateObject(value) { + if (typeof value !== 'object' || value === null) { + return false; + } + return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass; +}; diff --git a/node_modules/is-date-object/package.json b/node_modules/is-date-object/package.json new file mode 100644 index 0000000000000000000000000000000000000000..7b32ed8a1cdc82787bb78718b9c9265c5350bd99 --- /dev/null +++ b/node_modules/is-date-object/package.json @@ -0,0 +1,79 @@ +{ + "name": "is-date-object", + "version": "1.0.5", + "author": "Jordan Harband", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "description": "Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", + "license": "MIT", + "main": "index.js", + "scripts": { + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "pretest": "npm run lint", + "test": "npm run tests-only && npm run test:corejs", + "tests-only": "nyc tape 'test/**/*.js'", + "test:corejs": "nyc tape test-corejs.js", + "posttest": "aud --production", + "lint": "eslint .", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git://github.com/inspect-js/is-date-object.git" + }, + "keywords": [ + "Date", + "ES6", + "toStringTag", + "@@toStringTag", + "Date object" + ], + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "devDependencies": { + "@ljharb/eslint-config": "^17.6.0", + "aud": "^1.1.5", + "auto-changelog": "^2.3.0", + "core-js": "^3.12.0", + "eslint": "^7.32.0", + "foreach": "^2.0.5", + "indexof": "^0.0.1", + "is": "^3.3.0", + "nyc": "^10.3.2", + "safe-publish-latest": "^1.1.4", + "tape": "^5.3.0" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + } +} diff --git a/node_modules/is-date-object/test/index.js b/node_modules/is-date-object/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5279dad068a126ecd67666665b72cfeea28a8964 --- /dev/null +++ b/node_modules/is-date-object/test/index.js @@ -0,0 +1,36 @@ +'use strict'; + +var test = require('tape'); +var isDate = require('../'); +var hasToStringTag = require('has-tostringtag/shams')(); + +test('not Dates', function (t) { + t.notOk(isDate(), 'undefined is not Date'); + t.notOk(isDate(null), 'null is not Date'); + t.notOk(isDate(false), 'false is not Date'); + t.notOk(isDate(true), 'true is not Date'); + t.notOk(isDate(42), 'number is not Date'); + t.notOk(isDate('foo'), 'string is not Date'); + t.notOk(isDate([]), 'array is not Date'); + t.notOk(isDate({}), 'object is not Date'); + t.notOk(isDate(function () {}), 'function is not Date'); + t.notOk(isDate(/a/g), 'regex literal is not Date'); + t.notOk(isDate(new RegExp('a', 'g')), 'regex object is not Date'); + t.end(); +}); + +test('@@toStringTag', { skip: !hasToStringTag }, function (t) { + var realDate = new Date(); + var fakeDate = { + toString: function () { return String(realDate); }, + valueOf: function () { return realDate.getTime(); } + }; + fakeDate[Symbol.toStringTag] = 'Date'; + t.notOk(isDate(fakeDate), 'fake Date with @@toStringTag "Date" is not Date'); + t.end(); +}); + +test('Dates', function (t) { + t.ok(isDate(new Date()), 'new Date() is Date'); + t.end(); +}); diff --git a/node_modules/is-glob/LICENSE b/node_modules/is-glob/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..3f2eca18f1bc0f3117748e2cea9251e5182db2f7 --- /dev/null +++ b/node_modules/is-glob/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-2017, Jon Schlinkert. + +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. diff --git a/node_modules/is-glob/README.md b/node_modules/is-glob/README.md new file mode 100644 index 0000000000000000000000000000000000000000..740724b276e289aec14ee6ce99d42ab9a6eb4b48 --- /dev/null +++ b/node_modules/is-glob/README.md @@ -0,0 +1,206 @@ +# is-glob [![NPM version](https://img.shields.io/npm/v/is-glob.svg?style=flat)](https://www.npmjs.com/package/is-glob) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![NPM total downloads](https://img.shields.io/npm/dt/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![Build Status](https://img.shields.io/github/workflow/status/micromatch/is-glob/dev)](https://github.com/micromatch/is-glob/actions) + +> Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience. + +Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. + +## Install + +Install with [npm](https://www.npmjs.com/): + +```sh +$ npm install --save is-glob +``` + +You might also be interested in [is-valid-glob](https://github.com/jonschlinkert/is-valid-glob) and [has-glob](https://github.com/jonschlinkert/has-glob). + +## Usage + +```js +var isGlob = require('is-glob'); +``` + +### Default behavior + +**True** + +Patterns that have glob characters or regex patterns will return `true`: + +```js +isGlob('!foo.js'); +isGlob('*.js'); +isGlob('**/abc.js'); +isGlob('abc/*.js'); +isGlob('abc/(aaa|bbb).js'); +isGlob('abc/[a-z].js'); +isGlob('abc/{a,b}.js'); +//=> true +``` + +Extglobs + +```js +isGlob('abc/@(a).js'); +isGlob('abc/!(a).js'); +isGlob('abc/+(a).js'); +isGlob('abc/*(a).js'); +isGlob('abc/?(a).js'); +//=> true +``` + +**False** + +Escaped globs or extglobs return `false`: + +```js +isGlob('abc/\\@(a).js'); +isGlob('abc/\\!(a).js'); +isGlob('abc/\\+(a).js'); +isGlob('abc/\\*(a).js'); +isGlob('abc/\\?(a).js'); +isGlob('\\!foo.js'); +isGlob('\\*.js'); +isGlob('\\*\\*/abc.js'); +isGlob('abc/\\*.js'); +isGlob('abc/\\(aaa|bbb).js'); +isGlob('abc/\\[a-z].js'); +isGlob('abc/\\{a,b}.js'); +//=> false +``` + +Patterns that do not have glob patterns return `false`: + +```js +isGlob('abc.js'); +isGlob('abc/def/ghi.js'); +isGlob('foo.js'); +isGlob('abc/@.js'); +isGlob('abc/+.js'); +isGlob('abc/?.js'); +isGlob(); +isGlob(null); +//=> false +``` + +Arrays are also `false` (If you want to check if an array has a glob pattern, use [has-glob](https://github.com/jonschlinkert/has-glob)): + +```js +isGlob(['**/*.js']); +isGlob(['foo.js']); +//=> false +``` + +### Option strict + +When `options.strict === false` the behavior is less strict in determining if a pattern is a glob. Meaning that +some patterns that would return `false` may return `true`. This is done so that matching libraries like [micromatch](https://github.com/micromatch/micromatch) have a chance at determining if the pattern is a glob or not. + +**True** + +Patterns that have glob characters or regex patterns will return `true`: + +```js +isGlob('!foo.js', {strict: false}); +isGlob('*.js', {strict: false}); +isGlob('**/abc.js', {strict: false}); +isGlob('abc/*.js', {strict: false}); +isGlob('abc/(aaa|bbb).js', {strict: false}); +isGlob('abc/[a-z].js', {strict: false}); +isGlob('abc/{a,b}.js', {strict: false}); +//=> true +``` + +Extglobs + +```js +isGlob('abc/@(a).js', {strict: false}); +isGlob('abc/!(a).js', {strict: false}); +isGlob('abc/+(a).js', {strict: false}); +isGlob('abc/*(a).js', {strict: false}); +isGlob('abc/?(a).js', {strict: false}); +//=> true +``` + +**False** + +Escaped globs or extglobs return `false`: + +```js +isGlob('\\!foo.js', {strict: false}); +isGlob('\\*.js', {strict: false}); +isGlob('\\*\\*/abc.js', {strict: false}); +isGlob('abc/\\*.js', {strict: false}); +isGlob('abc/\\(aaa|bbb).js', {strict: false}); +isGlob('abc/\\[a-z].js', {strict: false}); +isGlob('abc/\\{a,b}.js', {strict: false}); +//=> false +``` + +## About + +
+Contributing + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). + +
+ +
+Running Tests + +Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: + +```sh +$ npm install && npm test +``` + +
+ +
+Building docs + +_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ + +To generate the readme, run the following command: + +```sh +$ npm install -g verbose/verb#dev verb-generate-readme && verb +``` + +
+ +### Related projects + +You might also be interested in these projects: + +* [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble "Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit") +* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks") +* [update](https://www.npmjs.com/package/update): Be scalable! Update is a new, open source developer framework and CLI for automating updates… [more](https://github.com/update/update) | [homepage](https://github.com/update/update "Be scalable! Update is a new, open source developer framework and CLI for automating updates of any kind in code projects.") +* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://github.com/verbose/verb) | [homepage](https://github.com/verbose/verb "Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of all sizes to generate everything from API docs to readmes.") + +### Contributors + +| **Commits** | **Contributor** | +| --- | --- | +| 47 | [jonschlinkert](https://github.com/jonschlinkert) | +| 5 | [doowb](https://github.com/doowb) | +| 1 | [phated](https://github.com/phated) | +| 1 | [danhper](https://github.com/danhper) | +| 1 | [paulmillr](https://github.com/paulmillr) | + +### Author + +**Jon Schlinkert** + +* [GitHub Profile](https://github.com/jonschlinkert) +* [Twitter Profile](https://twitter.com/jonschlinkert) +* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) + +### License + +Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert). +Released under the [MIT License](LICENSE). + +*** + +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on March 27, 2019._ \ No newline at end of file diff --git a/node_modules/is-glob/index.js b/node_modules/is-glob/index.js new file mode 100644 index 0000000000000000000000000000000000000000..620f563eccf081ce0d2db2dda5c9989baf778183 --- /dev/null +++ b/node_modules/is-glob/index.js @@ -0,0 +1,150 @@ +/*! + * is-glob + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ + +var isExtglob = require('is-extglob'); +var chars = { '{': '}', '(': ')', '[': ']'}; +var strictCheck = function(str) { + if (str[0] === '!') { + return true; + } + var index = 0; + var pipeIndex = -2; + var closeSquareIndex = -2; + var closeCurlyIndex = -2; + var closeParenIndex = -2; + var backSlashIndex = -2; + while (index < str.length) { + if (str[index] === '*') { + return true; + } + + if (str[index + 1] === '?' && /[\].+)]/.test(str[index])) { + return true; + } + + if (closeSquareIndex !== -1 && str[index] === '[' && str[index + 1] !== ']') { + if (closeSquareIndex < index) { + closeSquareIndex = str.indexOf(']', index); + } + if (closeSquareIndex > index) { + if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) { + return true; + } + backSlashIndex = str.indexOf('\\', index); + if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) { + return true; + } + } + } + + if (closeCurlyIndex !== -1 && str[index] === '{' && str[index + 1] !== '}') { + closeCurlyIndex = str.indexOf('}', index); + if (closeCurlyIndex > index) { + backSlashIndex = str.indexOf('\\', index); + if (backSlashIndex === -1 || backSlashIndex > closeCurlyIndex) { + return true; + } + } + } + + if (closeParenIndex !== -1 && str[index] === '(' && str[index + 1] === '?' && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ')') { + closeParenIndex = str.indexOf(')', index); + if (closeParenIndex > index) { + backSlashIndex = str.indexOf('\\', index); + if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) { + return true; + } + } + } + + if (pipeIndex !== -1 && str[index] === '(' && str[index + 1] !== '|') { + if (pipeIndex < index) { + pipeIndex = str.indexOf('|', index); + } + if (pipeIndex !== -1 && str[pipeIndex + 1] !== ')') { + closeParenIndex = str.indexOf(')', pipeIndex); + if (closeParenIndex > pipeIndex) { + backSlashIndex = str.indexOf('\\', pipeIndex); + if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) { + return true; + } + } + } + } + + if (str[index] === '\\') { + var open = str[index + 1]; + index += 2; + var close = chars[open]; + + if (close) { + var n = str.indexOf(close, index); + if (n !== -1) { + index = n + 1; + } + } + + if (str[index] === '!') { + return true; + } + } else { + index++; + } + } + return false; +}; + +var relaxedCheck = function(str) { + if (str[0] === '!') { + return true; + } + var index = 0; + while (index < str.length) { + if (/[*?{}()[\]]/.test(str[index])) { + return true; + } + + if (str[index] === '\\') { + var open = str[index + 1]; + index += 2; + var close = chars[open]; + + if (close) { + var n = str.indexOf(close, index); + if (n !== -1) { + index = n + 1; + } + } + + if (str[index] === '!') { + return true; + } + } else { + index++; + } + } + return false; +}; + +module.exports = function isGlob(str, options) { + if (typeof str !== 'string' || str === '') { + return false; + } + + if (isExtglob(str)) { + return true; + } + + var check = strictCheck; + + // optionally relax check + if (options && options.strict === false) { + check = relaxedCheck; + } + + return check(str); +}; diff --git a/node_modules/is-glob/package.json b/node_modules/is-glob/package.json new file mode 100644 index 0000000000000000000000000000000000000000..858af0378e9d36813353b51271aec88ee0d3328b --- /dev/null +++ b/node_modules/is-glob/package.json @@ -0,0 +1,81 @@ +{ + "name": "is-glob", + "description": "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience.", + "version": "4.0.3", + "homepage": "https://github.com/micromatch/is-glob", + "author": "Jon Schlinkert (https://github.com/jonschlinkert)", + "contributors": [ + "Brian Woodward (https://twitter.com/doowb)", + "Daniel Perez (https://tuvistavie.com)", + "Jon Schlinkert (http://twitter.com/jonschlinkert)" + ], + "repository": "micromatch/is-glob", + "bugs": { + "url": "https://github.com/micromatch/is-glob/issues" + }, + "license": "MIT", + "files": [ + "index.js" + ], + "main": "index.js", + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha && node benchmark.js" + }, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "devDependencies": { + "gulp-format-md": "^0.1.10", + "mocha": "^3.0.2" + }, + "keywords": [ + "bash", + "braces", + "check", + "exec", + "expression", + "extglob", + "glob", + "globbing", + "globstar", + "is", + "match", + "matches", + "pattern", + "regex", + "regular", + "string", + "test" + ], + "verb": { + "layout": "default", + "plugins": [ + "gulp-format-md" + ], + "related": { + "list": [ + "assemble", + "base", + "update", + "verb" + ] + }, + "reflinks": [ + "assemble", + "bach", + "base", + "composer", + "gulp", + "has-glob", + "is-valid-glob", + "micromatch", + "npm", + "scaffold", + "verb", + "vinyl" + ] + } +} diff --git a/node_modules/is-negative-zero/.editorconfig b/node_modules/is-negative-zero/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..aaac3258bea46fa996fd8aceb2386575c4ed8001 --- /dev/null +++ b/node_modules/is-negative-zero/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/node_modules/is-negative-zero/.eslintignore b/node_modules/is-negative-zero/.eslintignore new file mode 100644 index 0000000000000000000000000000000000000000..404abb22121cdcbb710c56f4ba2684789cb2868c --- /dev/null +++ b/node_modules/is-negative-zero/.eslintignore @@ -0,0 +1 @@ +coverage/ diff --git a/node_modules/is-negative-zero/.eslintrc b/node_modules/is-negative-zero/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..f858c0ab1bfe1ae45fdc1161524594e17f4ed1b2 --- /dev/null +++ b/node_modules/is-negative-zero/.eslintrc @@ -0,0 +1,9 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "no-magic-numbers": 0 + } +} diff --git a/node_modules/is-negative-zero/.github/FUNDING.yml b/node_modules/is-negative-zero/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..e34502b1cc247011ac11906200f57fd4df7d79ab --- /dev/null +++ b/node_modules/is-negative-zero/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: ljharb +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/is-negative-zero +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/is-negative-zero/.nycrc b/node_modules/is-negative-zero/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/is-negative-zero/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/is-negative-zero/CHANGELOG.md b/node_modules/is-negative-zero/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..d00e7261ee47a1cd8e5c923b6a446e9f3988bd84 --- /dev/null +++ b/node_modules/is-negative-zero/CHANGELOG.md @@ -0,0 +1,136 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v2.0.2](https://github.com/inspect-js/is-negative-zero/compare/v2.0.1...v2.0.2) - 2021-12-10 + +### Commits + +- [actions] reuse common workflows [`ece923d`](https://github.com/inspect-js/is-negative-zero/commit/ece923d6b50820b7832150957774047da43d1743) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`3a26f43`](https://github.com/inspect-js/is-negative-zero/commit/3a26f435434bbfb8a254ddd32d6079bf50263121) +- [meta] do not publish workflow files [`2cea0c2`](https://github.com/inspect-js/is-negative-zero/commit/2cea0c20c7f8b167bb6064f916f3285642bf5ab1) +- [readme] add github actions/codecov badges; update URLs [`0c0be3e`](https://github.com/inspect-js/is-negative-zero/commit/0c0be3eb148ccf9d764e8ed515ef0e1d0ffeed9d) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `tape` [`a93d16e`](https://github.com/inspect-js/is-negative-zero/commit/a93d16eddf46cad6bc9b71a92968ce758e6f4ea4) +- [meta] create FUNDING.yml [`b4f425e`](https://github.com/inspect-js/is-negative-zero/commit/b4f425e49edb8c4aa1efa6ba34c2d5c1150b2a26) +- [actions] update codecov uploader [`7999db3`](https://github.com/inspect-js/is-negative-zero/commit/7999db3bff3f0f9cc729529940b9077a586822e2) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `safe-publish-latest`, `tape` [`140e4d9`](https://github.com/inspect-js/is-negative-zero/commit/140e4d95eda9ad821608c28a5f705d84a906096d) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`23a8b6d`](https://github.com/inspect-js/is-negative-zero/commit/23a8b6d257cea0b8a608b2319739562ecbc6ba75) +- [readme] add actions and codecov badges [`fe92126`](https://github.com/inspect-js/is-negative-zero/commit/fe9212634346ced7a45905d958cb85d129e4c10b) +- [readme] fix repo URLs [`50c428e`](https://github.com/inspect-js/is-negative-zero/commit/50c428e423e5861a6c231440b8b3e746cbf6230f) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`688155f`](https://github.com/inspect-js/is-negative-zero/commit/688155ff0214da72cbafa4c438c3b9629265d82b) +- [meta] use `prepublishOnly` script for npm 7+ [`83171f9`](https://github.com/inspect-js/is-negative-zero/commit/83171f9131aed266f475d7a3283d9c2fc77e1436) +- [actions] update workflows [`e9823db`](https://github.com/inspect-js/is-negative-zero/commit/e9823db3054887d8bb5b3f2c8f698b93cdce7d82) + +## [v2.0.1](https://github.com/inspect-js/is-negative-zero/compare/v2.0.0...v2.0.1) - 2020-12-04 + +### Commits + +- [Tests] use shared travis-ci configs [`5b92482`](https://github.com/inspect-js/is-negative-zero/commit/5b92482ed26e55e1aafcc6b6310d279958af8204) +- [Tests] up to `node` `v11.7`, `v10.15`, `v9.11`, `v8.15`, `v7.10`, `v6.16`, `v5.12`, `v4.9`; use `nvm install-latest-npm`; fix test scripts [`0f5d2f8`](https://github.com/inspect-js/is-negative-zero/commit/0f5d2f85ea7fe83de47f39b6b35e489b866d88a7) +- [Tests] migrate tests to Github Actions [`b80f05a`](https://github.com/inspect-js/is-negative-zero/commit/b80f05adb11a6a3232860fb50272b101aacb504f) +- [Tests] remove `jscs` [`7ccaf41`](https://github.com/inspect-js/is-negative-zero/commit/7ccaf4100281b614d61d7c9122e6f87943a89295) +- [meta] add missing changelog [`992bdde`](https://github.com/inspect-js/is-negative-zero/commit/992bddee362cbae71f2cdfd8666f4774b252412e) +- [readme] fix repo URLs; remove defunct badges [`80fd18d`](https://github.com/inspect-js/is-negative-zero/commit/80fd18d2b0191321afe0e1b572200e4c025eb664) +- [Tests] run `nyc` on all tests [`df26f14`](https://github.com/inspect-js/is-negative-zero/commit/df26f14b0b854d82b0d3ca7b4949811c9f151357) +- Update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`d7723aa`](https://github.com/inspect-js/is-negative-zero/commit/d7723aa70e5b478adc36d98e1338abe741c1906a) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`9fdaabe`](https://github.com/inspect-js/is-negative-zero/commit/9fdaabecfdb25e6e860e5007a91b60ee0f20734f) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `tape` [`f07eeb2`](https://github.com/inspect-js/is-negative-zero/commit/f07eeb2740037c53f270e95d2f62edc051cafc56) +- [Dev Deps] update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`bd5c751`](https://github.com/inspect-js/is-negative-zero/commit/bd5c751fa4850ba8726dc1c197ed6c843a227b05) +- [actions] add automatic rebasing / merge commit blocking [`5666a91`](https://github.com/inspect-js/is-negative-zero/commit/5666a917db6bdcee63c0a3e28e5e281359975abc) +- [meta] add `auto-changelog` [`f70fb2b`](https://github.com/inspect-js/is-negative-zero/commit/f70fb2b5b9ea53dc52729310717553648292189e) +- [actions] add "Allow Edits" workflow [`2b040a8`](https://github.com/inspect-js/is-negative-zero/commit/2b040a87d362f17d8cab2b0d48058b80e426ad4e) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`; add `safe-publish-latest` [`09e2e53`](https://github.com/inspect-js/is-negative-zero/commit/09e2e537390225c1d1a6912be64267eaec6ea367) +- [Tests] use `npm audit` instead of `nsp` [`7df2669`](https://github.com/inspect-js/is-negative-zero/commit/7df2669013ac9328d424e9d8c82a53a0458f0888) +- [Tests] up to `io.js` `v3.3`, `node` `v4.1` [`4ff97c5`](https://github.com/inspect-js/is-negative-zero/commit/4ff97c5891c7a241a91c03fb54bd83e78570ef22) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog` [`9e8cb7b`](https://github.com/inspect-js/is-negative-zero/commit/9e8cb7bca46d325ecf202187c0fde7da8722bcab) +- [Dev Deps] update `jscs`, `eslint`, `@ljharb/eslint-config`, `nsp` [`70b9888`](https://github.com/inspect-js/is-negative-zero/commit/70b988802a99c84ab7eb8da287bb8ff0efc5c055) +- [Dev Deps] update `jscs` [`59d0c42`](https://github.com/inspect-js/is-negative-zero/commit/59d0c42131020b74e68fd444798b9a3bf247fb2d) +- Add `npm run security` [`eb418ed`](https://github.com/inspect-js/is-negative-zero/commit/eb418ed7e79216808c206388fbd360cc7a75655f) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`86a758d`](https://github.com/inspect-js/is-negative-zero/commit/86a758d42eb7d17a18f7f584c337d8820b842758) +- Only apps should have lockfiles [`a0ab621`](https://github.com/inspect-js/is-negative-zero/commit/a0ab6215590bf6adb3eaf1ff9e7c036d72e807ec) +- [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops [`5c51349`](https://github.com/inspect-js/is-negative-zero/commit/5c513498fc5a8b2fd06f5e0c1b38b8e93c3477ac) +- [meta] add `funding` field [`1d0b2f4`](https://github.com/inspect-js/is-negative-zero/commit/1d0b2f43bf5bf75176859a440346b3e338ee510e) +- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`9b12367`](https://github.com/inspect-js/is-negative-zero/commit/9b12367706f1c269a3df406c8e2c211558671a15) +- [Dev Deps] update `auto-changelog`, `tape` [`6d98b8d`](https://github.com/inspect-js/is-negative-zero/commit/6d98b8d1f512c3844d4062215c793070084d1164) +- [Dev Deps] Update `tape`, `eslint` [`a258cdb`](https://github.com/inspect-js/is-negative-zero/commit/a258cdb86691725482d1d43a1f9e7953c3c6733f) +- [Dev Deps] update `auto-changelog`; add `aud` [`2ca2afb`](https://github.com/inspect-js/is-negative-zero/commit/2ca2afb9efef4ebc8b3c19046ab1ab3ad516ea9a) +- Test up to `io.js` `v3.0` [`1254ae8`](https://github.com/inspect-js/is-negative-zero/commit/1254ae80b7706616331ac914654d7a17bff31039) +- [Dev Deps] update `auto-changelog` [`4b54722`](https://github.com/inspect-js/is-negative-zero/commit/4b547228fceaae8f9eccabc9ad8a49046492348d) +- [Tests] only audit prod deps [`86d298b`](https://github.com/inspect-js/is-negative-zero/commit/86d298b56db90f81617ee5d942476eda34afb374) +- [Dev Deps] update `tape` [`3a47e27`](https://github.com/inspect-js/is-negative-zero/commit/3a47e2730f889539f666ef0eb09a93fb9c80bfd1) +- Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. [`128d9bd`](https://github.com/inspect-js/is-negative-zero/commit/128d9bd4c12385fb5e478ac3dd3138fa4360a777) + +## [v2.0.0](https://github.com/inspect-js/is-negative-zero/compare/v1.0.0...v2.0.0) - 2015-07-24 + +### Commits + +- Update `tape`, `eslint`; use my personal shared `eslint` config. [`648d002`](https://github.com/inspect-js/is-negative-zero/commit/648d0029b177886428a11b07307f233ae2d3175b) +- Add `npm run eslint` [`5a52d80`](https://github.com/inspect-js/is-negative-zero/commit/5a52d80ab052e377044b9b181991a32afaaa3090) +- Using my standard jscs.json file [`5a667d9`](https://github.com/inspect-js/is-negative-zero/commit/5a667d9f8b7402ca3bd134080cd4435b5c7f1462) +- Adding `npm run lint` [`9a85ed9`](https://github.com/inspect-js/is-negative-zero/commit/9a85ed934da65d8733a38bf6ad3c89fd62115194) +- Update `tape`, `covert`, `jscs` [`c6cd3a6`](https://github.com/inspect-js/is-negative-zero/commit/c6cd3a64ea5b98100e10537549f50a9eeadc30ec) +- Update `eslint` [`e9c9b6e`](https://github.com/inspect-js/is-negative-zero/commit/e9c9b6e9623f021b7f3ae4091bf9ea2571ab02b4) +- Test on latest `io.js` [`2f7c8a9`](https://github.com/inspect-js/is-negative-zero/commit/2f7c8a9d174066400c072841d7bcf02cf90f8ebf) +- Adding license and downloads badges [`717087a`](https://github.com/inspect-js/is-negative-zero/commit/717087a013b4cfc9dc7847d3d4a64faf19341be4) +- Remove Number type coercion. [`481295d`](https://github.com/inspect-js/is-negative-zero/commit/481295dbd09dbf81d196dc77382f1b92f534de3f) +- Test up to `io.js` `v2.1` [`139a84a`](https://github.com/inspect-js/is-negative-zero/commit/139a84a3dbdec29682044c6e7ac884a7382ae6e1) +- Update `eslint` [`2f5fbfb`](https://github.com/inspect-js/is-negative-zero/commit/2f5fbfbc436ccd8676fc36fcd9f0edcdda33a1e7) +- Update `eslint` [`53cb4c5`](https://github.com/inspect-js/is-negative-zero/commit/53cb4c5eccecdf2d874e78e5c38cca762ed76a9d) +- Test on `io.js` `v2.2` [`98a1824`](https://github.com/inspect-js/is-negative-zero/commit/98a1824c86366f8a03cf303f46acecd67409f94b) +- All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. [`772d6cd`](https://github.com/inspect-js/is-negative-zero/commit/772d6cdf397e6fc1b26e5ed5f279d07a5ead6df8) +- Run `travis-ci` tests on `iojs` and `node` v0.12; speed up builds; allow 0.8 failures. [`3e6147e`](https://github.com/inspect-js/is-negative-zero/commit/3e6147ebb5ecdfda4a2bffa441572fe017c7bb73) +- Use SVG badges instead of PNG [`d986cb4`](https://github.com/inspect-js/is-negative-zero/commit/d986cb450e5bd4f373041255b69e18f47c252a1e) +- Update `tape`, `jscs` [`9f9d7e7`](https://github.com/inspect-js/is-negative-zero/commit/9f9d7e751bcf4ceeed8e36e75e31d29c76326b3f) +- Update `jscs` [`079eaf6`](https://github.com/inspect-js/is-negative-zero/commit/079eaf699d53e7e32c54e5233259a00f5f494d9a) +- Update `tape`, `jscs` [`cffe3fc`](https://github.com/inspect-js/is-negative-zero/commit/cffe3fc17c6bfaa6996bf7402446b160631a04b3) +- Update `tape`, `jscs` [`3a16616`](https://github.com/inspect-js/is-negative-zero/commit/3a166165ae8770d59c296794d28547379cebec58) +- Use consistent quotes [`9509a81`](https://github.com/inspect-js/is-negative-zero/commit/9509a8110027b12c5762ba48d03b649a921847d5) +- Test on `io.js` `v2.4` [`a9150a3`](https://github.com/inspect-js/is-negative-zero/commit/a9150a3397db339d992e9e4e6ddb52d1237fd617) +- Test on `io.js` `v2.3` [`36d7acf`](https://github.com/inspect-js/is-negative-zero/commit/36d7acf5bb9193a2b35585e2c49ae8be9f45a55e) +- Lock covert to v1.0.0. [`29d8917`](https://github.com/inspect-js/is-negative-zero/commit/29d89171c3aad69ace372edbf641ec3a5468c760) +- Updating jscs [`fe09c8a`](https://github.com/inspect-js/is-negative-zero/commit/fe09c8a6d16c637ecd83a9a8a7f6192faef0754a) +- Updating jscs [`5877bc7`](https://github.com/inspect-js/is-negative-zero/commit/5877bc7c2ed44c1ecc5d31e1c484c523450722d8) +- Running linter as part of tests [`9e77756`](https://github.com/inspect-js/is-negative-zero/commit/9e777563905f511d915ec7257e2637811b911bd6) +- Updating covert [`520a695`](https://github.com/inspect-js/is-negative-zero/commit/520a695164465b88c76860a638baafd4192bce5c) + +## [v1.0.0](https://github.com/inspect-js/is-negative-zero/compare/v0.1.1...v1.0.0) - 2014-08-08 + +### Commits + +- Updating tape [`31d1942`](https://github.com/inspect-js/is-negative-zero/commit/31d19422ecd9d453677851a9d5a8d9372a16fb39) +- Updating tape [`e7143bf`](https://github.com/inspect-js/is-negative-zero/commit/e7143bf3b67d8881b1b6ee0444637647d7bb1d2b) + +## [v0.1.1](https://github.com/inspect-js/is-negative-zero/compare/v0.1.0...v0.1.1) - 2014-05-13 + +### Merged + +- Simplify code [`#1`](https://github.com/inspect-js/is-negative-zero/pull/1) + +### Commits + +- Adding a trailing newline [`61fb37f`](https://github.com/inspect-js/is-negative-zero/commit/61fb37f677e871cca53d9309e765d808ddddfd5a) + +## [v0.1.0](https://github.com/inspect-js/is-negative-zero/compare/v0.0.0...v0.1.0) - 2014-05-13 + +### Commits + +- Make sure old and unstable nodes don't break Travis [`f627215`](https://github.com/inspect-js/is-negative-zero/commit/f627215527a95dc1ca014600650e00f15fe122c5) +- Updating deps [`b502f48`](https://github.com/inspect-js/is-negative-zero/commit/b502f48e807d7671cb07e2ca247ae2daa62e4165) +- Oops, negative numbers were negative zero! [`746cb97`](https://github.com/inspect-js/is-negative-zero/commit/746cb975d82c0fa0c5058e8e031807f9afcfd6db) +- Updating covert [`99ef4ed`](https://github.com/inspect-js/is-negative-zero/commit/99ef4ed97d2f76f2a5afbef029bf794f1b5bcffa) +- Updating tape [`ee9cfc2`](https://github.com/inspect-js/is-negative-zero/commit/ee9cfc2fd0039bdb65b6493ce0b8e47d18aa17cd) +- Testing on node 0.6 again [`6a9bf0a`](https://github.com/inspect-js/is-negative-zero/commit/6a9bf0a09e210cca09c7a8a225d08ef1e6789b5a) + +## v0.0.0 - 2014-01-19 + +### Commits + +- package.json [`8411d92`](https://github.com/inspect-js/is-negative-zero/commit/8411d92ec787fd522a1b5e65154ae88e9024a23f) +- read me [`5c8bf3c`](https://github.com/inspect-js/is-negative-zero/commit/5c8bf3ce4867dbf2997ef01ea6b712aa294ec959) +- Initial commit [`c06f7dc`](https://github.com/inspect-js/is-negative-zero/commit/c06f7dcf926f5b35ba678787a0f16cdd7b544054) +- Tests. [`5c554d4`](https://github.com/inspect-js/is-negative-zero/commit/5c554d405bfb323a7413fde395d8dc39c5316356) +- Travis CI [`334d000`](https://github.com/inspect-js/is-negative-zero/commit/334d000941fc926493cc7dbdb4e5f7ae481a311b) +- Implementation. [`4ef4491`](https://github.com/inspect-js/is-negative-zero/commit/4ef449189c36d471d283e40aa20a8ebfa4985882) diff --git a/node_modules/is-negative-zero/LICENSE b/node_modules/is-negative-zero/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..47b7b5078fce38783c58381828d9a7f762db7866 --- /dev/null +++ b/node_modules/is-negative-zero/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Jordan Harband + +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. diff --git a/node_modules/is-negative-zero/README.md b/node_modules/is-negative-zero/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e8193a48873bbfcc88d5a352600c4f03348e5d88 --- /dev/null +++ b/node_modules/is-negative-zero/README.md @@ -0,0 +1,54 @@ +# is-negative-zero [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Is this value negative zero? === will lie to you. + +## Example + +```js +var isNegativeZero = require('is-negative-zero'); +var assert = require('assert'); + +assert.notOk(isNegativeZero(undefined)); +assert.notOk(isNegativeZero(null)); +assert.notOk(isNegativeZero(false)); +assert.notOk(isNegativeZero(true)); +assert.notOk(isNegativeZero(0)); +assert.notOk(isNegativeZero(42)); +assert.notOk(isNegativeZero(Infinity)); +assert.notOk(isNegativeZero(-Infinity)); +assert.notOk(isNegativeZero(NaN)); +assert.notOk(isNegativeZero('foo')); +assert.notOk(isNegativeZero(function () {})); +assert.notOk(isNegativeZero([])); +assert.notOk(isNegativeZero({})); + +assert.ok(isNegativeZero(-0)); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/is-negative-zero +[npm-version-svg]: https://versionbadg.es/inspect-js/is-negative-zero.svg +[deps-svg]: https://david-dm.org/inspect-js/is-negative-zero.svg +[deps-url]: https://david-dm.org/inspect-js/is-negative-zero +[dev-deps-svg]: https://david-dm.org/inspect-js/is-negative-zero/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/is-negative-zero#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/is-negative-zero.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/is-negative-zero.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/is-negative-zero.svg +[downloads-url]: https://npm-stat.com/charts.html?package=is-negative-zero +[codecov-image]: https://codecov.io/gh/inspect-js/is-negative-zero/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/is-negative-zero/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-negative-zero +[actions-url]: https://github.com/inspect-js/is-negative-zero/actions diff --git a/node_modules/is-negative-zero/index.js b/node_modules/is-negative-zero/index.js new file mode 100644 index 0000000000000000000000000000000000000000..400e5d1f4ab62cd8746f7563f765f6a097a5b85c --- /dev/null +++ b/node_modules/is-negative-zero/index.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function isNegativeZero(number) { + return number === 0 && (1 / number) === -Infinity; +}; + diff --git a/node_modules/is-negative-zero/package.json b/node_modules/is-negative-zero/package.json new file mode 100644 index 0000000000000000000000000000000000000000..d0aa3d9c15e93ff487fe31606b9abdd8fed98250 --- /dev/null +++ b/node_modules/is-negative-zero/package.json @@ -0,0 +1,79 @@ +{ + "name": "is-negative-zero", + "version": "2.0.2", + "description": "Is this value negative zero? === will lie to you", + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "main": "index.js", + "scripts": { + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "pretest": "npm run lint", + "test": "npm run tests-only", + "tests-only": "nyc tape 'test/**/*.js'", + "posttest": "aud --production", + "lint": "eslint --ext=js,mjs .", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git://github.com/inspect-js/is-negative-zero.git" + }, + "bugs": { + "url": "https://github.com/inspect-js/is-negative-zero/issues" + }, + "homepage": "https://github.com/inspect-js/is-negative-zero", + "keywords": [ + "is", + "negative", + "zero", + "negative zero", + "number", + "positive", + "0", + "-0" + ], + "devDependencies": { + "@ljharb/eslint-config": "^20.0.0", + "aud": "^1.1.5", + "auto-changelog": "^2.3.0", + "eslint": "^8.4.1", + "nyc": "^10.3.2", + "safe-publish-latest": "^2.0.0", + "tape": "^5.3.2" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..12.0", + "opera/15.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + } +} diff --git a/node_modules/is-negative-zero/test/index.js b/node_modules/is-negative-zero/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8fd7d16bfafaa8ce623ef3c3ce92b7558556cd64 --- /dev/null +++ b/node_modules/is-negative-zero/test/index.js @@ -0,0 +1,28 @@ +'use strict'; + +var test = require('tape'); +var isNegativeZero = require('../'); + +test('not negative zero', function (t) { + t.notOk(isNegativeZero(), 'undefined is not negative zero'); + t.notOk(isNegativeZero(null), 'null is not negative zero'); + t.notOk(isNegativeZero(false), 'false is not negative zero'); + t.notOk(isNegativeZero(true), 'true is not negative zero'); + t.notOk(isNegativeZero(0), 'positive zero is not negative zero'); + t.notOk(isNegativeZero(Infinity), 'Infinity is not negative zero'); + t.notOk(isNegativeZero(-Infinity), '-Infinity is not negative zero'); + t.notOk(isNegativeZero(NaN), 'NaN is not negative zero'); + t.notOk(isNegativeZero('foo'), 'string is not negative zero'); + t.notOk(isNegativeZero([]), 'array is not negative zero'); + t.notOk(isNegativeZero({}), 'object is not negative zero'); + t.notOk(isNegativeZero(function () {}), 'function is not negative zero'); + t.notOk(isNegativeZero(-1), '-1 is not negative zero'); + + t.end(); +}); + +test('negative zero', function (t) { + t.ok(isNegativeZero(-0), 'negative zero is negative zero'); + t.end(); +}); + diff --git a/node_modules/is-number-object/.editorconfig b/node_modules/is-number-object/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..4e36aeeec4a662c78fd99c3a0cd7a8f71f9d1331 --- /dev/null +++ b/node_modules/is-number-object/.editorconfig @@ -0,0 +1,23 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 150 + +[CHANGELOG.md] +indent_style = space +indent_size = 2 + +[*.json] +max_line_length = off + +[Makefile] +max_line_length = off + +[CHANGELOG.md] +max_line_length = off diff --git a/node_modules/is-number-object/.eslintrc b/node_modules/is-number-object/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..c7933f4d718ed0a9d9f19f4fca1d3718fe71bc7f --- /dev/null +++ b/node_modules/is-number-object/.eslintrc @@ -0,0 +1,16 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "func-name-matching": 0, + }, + + "overrides": [ + { + "files": "test-core-js.js", + "extends": "@ljharb/eslint-config/tests", + }, + ], +} diff --git a/node_modules/is-number-object/.github/FUNDING.yml b/node_modules/is-number-object/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..17f4dc55da78f7f54e4323578f166c3b6d71ff60 --- /dev/null +++ b/node_modules/is-number-object/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/is-number-object +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/is-number-object/.nycrc b/node_modules/is-number-object/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..a69aa2d8273d8c598f8e3aa5c8d779e28d63862f --- /dev/null +++ b/node_modules/is-number-object/.nycrc @@ -0,0 +1,10 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test", + "test-corejs.js" + ] +} diff --git a/node_modules/is-number-object/CHANGELOG.md b/node_modules/is-number-object/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..028b484a3648b3722c79301f696977914f94df4a --- /dev/null +++ b/node_modules/is-number-object/CHANGELOG.md @@ -0,0 +1,125 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.7](https://github.com/inspect-js/is-number-object/compare/v1.0.6...v1.0.7) - 2022-04-01 + +### Commits + +- [actions] reuse common workflows [`8f9a1b0`](https://github.com/inspect-js/is-number-object/commit/8f9a1b040a435a5c5d12150952d0e6f96d4f713a) +- [meta] better `eccheck` command [`9dc8dff`](https://github.com/inspect-js/is-number-object/commit/9dc8dff273e4d0b954fd4f2a2eacc849d321b646) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `core-js`, `safe-publish-latest`, `tape` [`c50ecbf`](https://github.com/inspect-js/is-number-object/commit/c50ecbfc7577c69324fca4d2b40dd354c5156be9) +- [actions] update codecov uploader [`f1a2560`](https://github.com/inspect-js/is-number-object/commit/f1a2560d4a996abea90f7a792069a35359869b67) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `core-js`, `tape` [`4b06ace`](https://github.com/inspect-js/is-number-object/commit/4b06aceeba2ebf0887af020aa89caad8950e5f47) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `core-js`, `tape` [`3dc0e8b`](https://github.com/inspect-js/is-number-object/commit/3dc0e8b0fcc96a9bc9936e9a62a523fe67bafca5) +- [meta] add `bugs`/`homepage` package.json fields [`d7e0bcf`](https://github.com/inspect-js/is-number-object/commit/d7e0bcf1fe1b4a48d6500266c8b4058c854fecba) + +## [v1.0.6](https://github.com/inspect-js/is-number-object/compare/v1.0.5...v1.0.6) - 2021-08-05 + +### Commits + +- [Tests] run tests with core-js as well [`5177312`](https://github.com/inspect-js/is-number-object/commit/51773120b18e27bfe8a3bd228ef2e21f5802f338) +- [Refactor] use `has-tostringtag` to behave correctly in the presence of symbol shams [`ca2b31d`](https://github.com/inspect-js/is-number-object/commit/ca2b31d81c5d7d9b11e812dee58cd627a6d634e2) +- [Dev Deps] update `auto-changelog`, `core-js`, `eslint`, `tape` [`50950f9`](https://github.com/inspect-js/is-number-object/commit/50950f962a4b1188c478f6034194d7eb4314c884) + +## [v1.0.5](https://github.com/inspect-js/is-number-object/compare/v1.0.4...v1.0.5) - 2021-05-07 + +### Commits + +- [Tests] migrate tests to Github Actions [`9666737`](https://github.com/inspect-js/is-number-object/commit/96667372f8e36f70516218f86318f957f8c175ad) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`7815ce2`](https://github.com/inspect-js/is-number-object/commit/7815ce21cb5662c2d1651b3ec302f186aa8a016b) +- [meta] do not publish github action workflow files [`80ccb75`](https://github.com/inspect-js/is-number-object/commit/80ccb7509f91732675b018cc1a636d649a92889e) +- [Tests] run `nyc` on all tests [`c9ffb74`](https://github.com/inspect-js/is-number-object/commit/c9ffb74443690ef22f9aa7dd35855fd1e3be5184) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`7e84161`](https://github.com/inspect-js/is-number-object/commit/7e84161d089c87ef42e3639ac1889642624ebd28) +- [readme] add actions and codecov badges [`0c5ec7a`](https://github.com/inspect-js/is-number-object/commit/0c5ec7aa87dac27bdcda2365124c3aa0ccf9c278) +- [actions] add Require Allow Edits workflow [`dd0fb74`](https://github.com/inspect-js/is-number-object/commit/dd0fb74b2ecb630ea7778a6f06dcc017323a3c1d) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-symbols`, `tape` [`2d36f80`](https://github.com/inspect-js/is-number-object/commit/2d36f809a7b9896958b0b0f3b69be0067caedb45) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog` [`77d3140`](https://github.com/inspect-js/is-number-object/commit/77d3140557d483e467ce070b21bf384e9a7562d5) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`75d4abf`](https://github.com/inspect-js/is-number-object/commit/75d4abf34168e69d73f621c696a16179ddc0873c) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`0c2a917`](https://github.com/inspect-js/is-number-object/commit/0c2a917e4802b102888759fad912bd9faa5587f7) +- [Fix] do not use `Object.prototype.toString` when `Symbol.toStringTag` is shammed [`8b6ebc4`](https://github.com/inspect-js/is-number-object/commit/8b6ebc489db14a0c369214e081413f326fc0d598) +- [Dev Deps] update `auto-changelog`, `tape`; add `aud` [`62045fc`](https://github.com/inspect-js/is-number-object/commit/62045fcaddb9e4d3ef81068e99d07d21cd62023b) +- [actions] use checkout v2; remove unneeded env [`d48cd06`](https://github.com/inspect-js/is-number-object/commit/d48cd06720ea71f278a6d35c6f0a8ec04242a58f) +- [meta] use `prepublishOnly` script for npm 7+ [`827ab0d`](https://github.com/inspect-js/is-number-object/commit/827ab0d52d25f46d232ae7442ece270dec2de1df) +- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`bfed500`](https://github.com/inspect-js/is-number-object/commit/bfed500e6cc3cd3b9e7ffea78429c59857035791) +- [meta] remove explicit audit level config [`ce23e5e`](https://github.com/inspect-js/is-number-object/commit/ce23e5e49fbebe190267d8c99ddfd880a963b7ee) +- [meta] gitignore coverage output [`f1ad981`](https://github.com/inspect-js/is-number-object/commit/f1ad98106549c1c88322d8cb206068ea4c5bd424) + +## [v1.0.4](https://github.com/inspect-js/is-number-object/compare/v1.0.3...v1.0.4) - 2019-12-18 + +### Commits + +- [Tests] use shared travis-ci configs [`792b5aa`](https://github.com/inspect-js/is-number-object/commit/792b5aa5e7313ddf5507f7283bb7d5d5c646b11b) +- [Tests] up to `node` `v12.4`, `v11.15`, `v10.15`, `v9.11`, `v8.15`, `v7.10`, `v6.17`, `v5.12`, `v4.9`; use `nvm install-latest-npm` [`dc66db7`](https://github.com/inspect-js/is-number-object/commit/dc66db7dd1eca0263f6602597eb40601519e912e) +- Update `eslint`, `tape`, `semver`; use my personal shared `eslint` config [`7660fed`](https://github.com/inspect-js/is-number-object/commit/7660fed03a7060eb5c91e74b9a17303d4fac1056) +- [Tests] remove `jscs` [`f1fee97`](https://github.com/inspect-js/is-number-object/commit/f1fee97423478bcc653c844fadda55138d9b9a54) +- [meta] add `auto-changelog` [`4b1c225`](https://github.com/inspect-js/is-number-object/commit/4b1c2253770eb18761a1e8b157772028d6f742c4) +- [meta] remove unused Makefile and associated utilities [`379b979`](https://github.com/inspect-js/is-number-object/commit/379b9793d9c61d7889e53bd9de9578dca9964ebc) +- Update `covert`, `jscs`, `eslint`, `semver` [`16d2af8`](https://github.com/inspect-js/is-number-object/commit/16d2af82a6c93aee614f7a4b2c468411c743e95f) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `is`, `replace`, `semver`, `tape` [`21c0f04`](https://github.com/inspect-js/is-number-object/commit/21c0f0431984b87443c6acb9f003368feb7b4368) +- Update `is`, `tape`, `covert`, `jscs`, `editorconfig-tools`, `nsp`, `eslint`, `semver`. Add `replace`. Use `^` instead of `~`. [`19d6ee3`](https://github.com/inspect-js/is-number-object/commit/19d6ee3a3d4a87764d57316804fd8b882ba5197c) +- Update `eslint` [`d32754b`](https://github.com/inspect-js/is-number-object/commit/d32754bcca0033e01eba531c4353d1239e992203) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `replace` [`1df8165`](https://github.com/inspect-js/is-number-object/commit/1df8165dd63d9f2f78ccb78e905d0a6b3e302884) +- Update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`675372b`](https://github.com/inspect-js/is-number-object/commit/675372b115fb20b5034f40bcbb5560c6c0512746) +- [readme] clean up readme; remove testling; fix repo URLs [`80e29c4`](https://github.com/inspect-js/is-number-object/commit/80e29c4d6d0811fc361e95ee83b81280bf3ae3f5) +- [Tests] up to `node` `v12.7`, `v10.16`, `v8.16` [`287a968`](https://github.com/inspect-js/is-number-object/commit/287a9687b1fc3d091ec231c06f19a19ff7b0e8f6) +- Test on latest `iojs` and `node` versions. [`11c98a2`](https://github.com/inspect-js/is-number-object/commit/11c98a23b232cb21c7daab797fd63875c2970681) +- [actions] add automatic rebasing / merge commit blocking [`022d026`](https://github.com/inspect-js/is-number-object/commit/022d026129df445f239ba2ecd8d47a2786242d75) +- [meta] create FUNDING.yml [`7f52710`](https://github.com/inspect-js/is-number-object/commit/7f527107168aad7108b7c262d295dcf44e03214d) +- [Dev Deps] update `is`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver` [`bc8cd50`](https://github.com/inspect-js/is-number-object/commit/bc8cd508fe4440168f9b049be3ddf93c56c06c49) +- [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops [`1f9200b`](https://github.com/inspect-js/is-number-object/commit/1f9200b7c56840dc23eeeca5d0ee4f64a0446e08) +- [Tests] up to `node` `v12.11` [`706d50a`](https://github.com/inspect-js/is-number-object/commit/706d50a779b90feb3f4d2ae88d8189d19b913073) +- [Dev Deps] update `jscs` [`e3591a4`](https://github.com/inspect-js/is-number-object/commit/e3591a445b1af25d46632eafea51efa07b4eb6dc) +- [Tests] up to `io.js` `v3.3`, `node` `v4.1` [`baf4ee7`](https://github.com/inspect-js/is-number-object/commit/baf4ee749fb65ec12e9cab102e77aa0e14312109) +- Update `nsp`, `eslint` [`61b18d5`](https://github.com/inspect-js/is-number-object/commit/61b18d5b44542fddf4950534d506b20d8c8b1f44) +- Update `eslint`, `semver` [`52e61bd`](https://github.com/inspect-js/is-number-object/commit/52e61bd4334c0a1afacd147fd0bc1e2c1be10df5) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `has-symbols`; add `safe-publish-latest` [`79db7f6`](https://github.com/inspect-js/is-number-object/commit/79db7f610d2bcf5f0d6e8ca834f7402504101072) +- Only apps should have lockfiles [`677b9b4`](https://github.com/inspect-js/is-number-object/commit/677b9b4fb6ad9d7b984cb0f89c8b5a6df143b29a) +- Test on `io.js` `v2.2` [`e8a38b2`](https://github.com/inspect-js/is-number-object/commit/e8a38b2fe73b841b0ed55d9f60573d460a4f2a62) +- [meta] add `funding` field [`85315e7`](https://github.com/inspect-js/is-number-object/commit/85315e75c119a2aef70a766f2ddc1079b64d006b) +- [Dev Deps] update `eslint`, `tape` [`f3581aa`](https://github.com/inspect-js/is-number-object/commit/f3581aaea310546f6ee4612990468d39f058d320) +- [Tests] use `eclint` instead of `editorconfig-tools` [`7b53680`](https://github.com/inspect-js/is-number-object/commit/7b5368071000eb1c715aeeee5ff47ffdbee9fe5c) +- [Dev Deps] update `semver`, `tape` [`d6b524a`](https://github.com/inspect-js/is-number-object/commit/d6b524ac2e8c0240c436cbe8828671e383d51fd5) +- [Dev Deps] Update `tape`, `eslint` [`be19203`](https://github.com/inspect-js/is-number-object/commit/be19203dee0aa70ff8f09823bf880a38b824e1ed) +- Test up to `io.js` `v2.1` [`feb7ba6`](https://github.com/inspect-js/is-number-object/commit/feb7ba63a0816f1d36419ce240f96e9b4e4c90ba) +- Test up to `io.js` `v3.0` [`7be1f0a`](https://github.com/inspect-js/is-number-object/commit/7be1f0a25dc59b6606be9ee1ace38cb7039a59d2) +- [Dev Deps] update `tape` [`d9a2318`](https://github.com/inspect-js/is-number-object/commit/d9a2318bc82477e9321e961def11e28d364e5562) +- Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. [`a6cd411`](https://github.com/inspect-js/is-number-object/commit/a6cd411c6bd92691a48b52683afce584c2c6b21b) +- Test on `io.js` `v2.4` [`46c2e7f`](https://github.com/inspect-js/is-number-object/commit/46c2e7f2ce8ad7f8ab3c1da827d93fc2780eff06) +- Test on `io.js` `v2.3` [`9c344b0`](https://github.com/inspect-js/is-number-object/commit/9c344b0df83628908a1f776a3f2e5fc4fae1d4d2) +- Fix tests for faked @@toStringTag [`f8c446e`](https://github.com/inspect-js/is-number-object/commit/f8c446e9fc320c23807717356e259529f494b9f3) + +## [v1.0.3](https://github.com/inspect-js/is-number-object/compare/v1.0.2...v1.0.3) - 2015-01-29 + +### Commits + +- If @@toStringTag is not present, use the old-school Object#toString test. [`9b2a4df`](https://github.com/inspect-js/is-number-object/commit/9b2a4df6ccf903e89198d4244eeb7f47a7056327) + +## [v1.0.2](https://github.com/inspect-js/is-number-object/compare/v1.0.1...v1.0.2) - 2015-01-29 + +### Commits + +- Improve optimizability of the non-try/catch part. [`7e6be2f`](https://github.com/inspect-js/is-number-object/commit/7e6be2fd2346557fc81bd544ac8745021c50e266) +- Fix package.json [`4f2ebea`](https://github.com/inspect-js/is-number-object/commit/4f2ebeae09c45e1eefeb2c10a011ff2ef0aca921) + +## [v1.0.1](https://github.com/inspect-js/is-number-object/compare/v1.0.0...v1.0.1) - 2015-01-29 + +### Commits + +- Use Object() instead of new Number() [`1aaa746`](https://github.com/inspect-js/is-number-object/commit/1aaa746c26878a0f698aabea4d88215311f2a38d) +- Add early exits for typeof number, or typeof not "object". [`eae4337`](https://github.com/inspect-js/is-number-object/commit/eae43375d3f88e04bb10eabd954e5a6b66ad5305) + +## v1.0.0 - 2015-01-28 + +### Commits + +- Dotfiles. [`9c74e3e`](https://github.com/inspect-js/is-number-object/commit/9c74e3eb2b10398d4022de7c4015531e874f06c8) +- `make release` [`a99e5ae`](https://github.com/inspect-js/is-number-object/commit/a99e5aeb3995a7d543fc5833722bc02011fabad6) +- package.json [`4fed9ef`](https://github.com/inspect-js/is-number-object/commit/4fed9ef7c35ccfc45ca8acd3c92c9cb91c7daa6d) +- Read me [`c91d6ba`](https://github.com/inspect-js/is-number-object/commit/c91d6ba00de79eaaac5fec7c9d8866d61d0abb62) +- Initial commit [`629fb96`](https://github.com/inspect-js/is-number-object/commit/629fb969f076e0802c799b368c7b02556bb0750e) +- Tests. [`a39de62`](https://github.com/inspect-js/is-number-object/commit/a39de624785cc204ed7c0ea5518f1c878870ceb1) +- Implementation. [`aedd91e`](https://github.com/inspect-js/is-number-object/commit/aedd91e6fc23f00852ad1266b6c19f32b7f93a22) diff --git a/node_modules/is-number-object/LICENSE b/node_modules/is-number-object/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b43df444e518288ceef6eaa9badd33388191b1d3 --- /dev/null +++ b/node_modules/is-number-object/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +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. + diff --git a/node_modules/is-number-object/README.md b/node_modules/is-number-object/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a5f1e5b1f001aba4bf7a462746d247c85ce2a712 --- /dev/null +++ b/node_modules/is-number-object/README.md @@ -0,0 +1,55 @@ +# is-number-object [![Version Badge][2]][1] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +Is this value a JS Number object? This module works cross-realm/iframe, and despite ES6 @@toStringTag. + +## Example + +```js +var isNumber = require('is-number-object'); +var assert = require('assert'); + +assert.notOk(isNumber(undefined)); +assert.notOk(isNumber(null)); +assert.notOk(isNumber(false)); +assert.notOk(isNumber(true)); +assert.notOk(isNumber('foo')); +assert.notOk(isNumber(function () {})); +assert.notOk(isNumber([])); +assert.notOk(isNumber({})); +assert.notOk(isNumber(/a/g)); +assert.notOk(isNumber(new RegExp('a', 'g'))); +assert.notOk(isNumber(new Date())); + +assert.ok(isNumber(42)); +assert.ok(isNumber(NaN)); +assert.ok(isNumber(Infinity)); +assert.ok(isNumber(new Number(42))); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/is-number-object +[2]: https://versionbadg.es/inspect-js/is-number-object.svg +[5]: https://david-dm.org/inspect-js/is-number-object.svg +[6]: https://david-dm.org/inspect-js/is-number-object +[7]: https://david-dm.org/inspect-js/is-number-object/dev-status.svg +[8]: https://david-dm.org/inspect-js/is-number-object#info=devDependencies +[11]: https://nodei.co/npm/is-number-object.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/is-number-object.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/is-number-object.svg +[downloads-url]: https://npm-stat.com/charts.html?package=is-number-object +[codecov-image]: https://codecov.io/gh/inspect-js/is-number-object/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/is-number-object/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-number-object +[actions-url]: https://github.com/inspect-js/is-number-object/actions diff --git a/node_modules/is-number-object/index.js b/node_modules/is-number-object/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9107c31c0be6cd2049294606d1c8815a1036c1ff --- /dev/null +++ b/node_modules/is-number-object/index.js @@ -0,0 +1,24 @@ +'use strict'; + +var numToStr = Number.prototype.toString; +var tryNumberObject = function tryNumberObject(value) { + try { + numToStr.call(value); + return true; + } catch (e) { + return false; + } +}; +var toStr = Object.prototype.toString; +var numClass = '[object Number]'; +var hasToStringTag = require('has-tostringtag/shams')(); + +module.exports = function isNumberObject(value) { + if (typeof value === 'number') { + return true; + } + if (typeof value !== 'object') { + return false; + } + return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass; +}; diff --git a/node_modules/is-number-object/package.json b/node_modules/is-number-object/package.json new file mode 100644 index 0000000000000000000000000000000000000000..2c8b16d6e30ced93060bf5cf54c1531a4b6cb3e5 --- /dev/null +++ b/node_modules/is-number-object/package.json @@ -0,0 +1,85 @@ +{ + "name": "is-number-object", + "version": "1.0.7", + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "description": "Is this value a JS Number object? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", + "main": "index.js", + "scripts": { + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test:corejs": "nyc tape test-corejs.js", + "test": "npm run tests-only && npm run test:corejs", + "posttest": "aud --production", + "prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')", + "lint": "eslint --ext=js,mjs .", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git://github.com/inspect-js/is-number-object.git" + }, + "keywords": [ + "Number", + "ES6", + "toStringTag", + "@@toStringTag", + "Number object" + ], + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/is-number-object/issues" + }, + "homepage": "https://github.com/inspect-js/is-number-object#readme", + "devDependencies": { + "@ljharb/eslint-config": "^20.2.3", + "aud": "^2.0.0", + "auto-changelog": "^2.4.0", + "core-js": "^3.21.1", + "eclint": "^2.8.1", + "eslint": "=8.8.0", + "foreach": "^2.0.5", + "indexof": "^0.0.1", + "is": "^3.3.0", + "nyc": "^10.3.2", + "safe-publish-latest": "^2.0.0", + "tape": "^5.5.2" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + }, + "dependencies": { + "has-tostringtag": "^1.0.0" + } +} diff --git a/node_modules/is-number-object/test/index.js b/node_modules/is-number-object/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..bca48b28e3e0bf517f4a5f9feacad4f111085d0b --- /dev/null +++ b/node_modules/is-number-object/test/index.js @@ -0,0 +1,38 @@ +'use strict'; + +var test = require('tape'); +var isNumber = require('../'); +var hasToStringTag = require('has-tostringtag/shams')(); + +test('not Numbers', function (t) { + t.notOk(isNumber(), 'undefined is not Number'); + t.notOk(isNumber(null), 'null is not Number'); + t.notOk(isNumber(false), 'false is not Number'); + t.notOk(isNumber(true), 'true is not Number'); + t.notOk(isNumber('foo'), 'string is not Number'); + t.notOk(isNumber([]), 'array is not Number'); + t.notOk(isNumber({}), 'object is not Number'); + t.notOk(isNumber(function () {}), 'function is not Number'); + t.notOk(isNumber(/a/g), 'regex literal is not Number'); + t.notOk(isNumber(new RegExp('a', 'g')), 'regex object is not Number'); + t.notOk(isNumber(new Date()), 'new Date() is not Number'); + t.end(); +}); + +test('@@toStringTag', { skip: !hasToStringTag }, function (t) { + var fakeNumber = { + toString: function () { return '7'; }, + valueOf: function () { return 42; } + }; + fakeNumber[Symbol.toStringTag] = 'Number'; + t.notOk(isNumber(fakeNumber), 'fake Number with @@toStringTag "Number" is not Number'); + t.end(); +}); + +test('Numbers', function (t) { + t.ok(isNumber(42), 'number is Number'); + t.ok(isNumber(Object(42)), 'number object is Number'); + t.ok(isNumber(NaN), 'NaN is Number'); + t.ok(isNumber(Infinity), 'Infinity is Number'); + t.end(); +}); diff --git a/node_modules/is-symbol/.editorconfig b/node_modules/is-symbol/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..eaa214161f5cdb409c32465fd822624c633a6bd8 --- /dev/null +++ b/node_modules/is-symbol/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = tab; +insert_final_newline = true; +quote_type = auto; +space_after_anonymous_functions = true; +space_after_control_statements = true; +spaces_around_operators = true; +trim_trailing_whitespace = true; +spaces_in_brackets = false; +end_of_line = lf; + diff --git a/node_modules/is-symbol/.eslintignore b/node_modules/is-symbol/.eslintignore new file mode 100644 index 0000000000000000000000000000000000000000..404abb22121cdcbb710c56f4ba2684789cb2868c --- /dev/null +++ b/node_modules/is-symbol/.eslintignore @@ -0,0 +1 @@ +coverage/ diff --git a/node_modules/is-symbol/.eslintrc b/node_modules/is-symbol/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..046dd071413e73d54b0fc23a48536fc7960e3c82 --- /dev/null +++ b/node_modules/is-symbol/.eslintrc @@ -0,0 +1,14 @@ +{ + "root": true, + + "extends": "@ljharb", + + "overrides": [ + { + "files": "test/**", + "rules": { + "no-restricted-properties": 0, + }, + }, + ], +} diff --git a/node_modules/is-symbol/.github/FUNDING.yml b/node_modules/is-symbol/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..a65600e7f6b73e5f445dbeda8ccbed22cc8e3235 --- /dev/null +++ b/node_modules/is-symbol/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/is-symbol +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/is-symbol/.nycrc b/node_modules/is-symbol/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/is-symbol/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/is-symbol/CHANGELOG.md b/node_modules/is-symbol/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..ce8dd991259cb9a17f17cdb1694e68d9e880fc57 --- /dev/null +++ b/node_modules/is-symbol/CHANGELOG.md @@ -0,0 +1,113 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.4](https://github.com/inspect-js/is-symbol/compare/v1.0.3...v1.0.4) - 2021-05-08 + +### Commits + +- [Tests] migrate tests to Github Actions [`997d43c`](https://github.com/inspect-js/is-symbol/commit/997d43c091d1f8d3a2b3d7dfb17a73cdc5a75dde) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`fe0ccb7`](https://github.com/inspect-js/is-symbol/commit/fe0ccb7b7b64e74e095ef782dcc1d24d6c4b0be4) +- [meta] remove unused Makefile and associated utilities [`3ab2748`](https://github.com/inspect-js/is-symbol/commit/3ab2748ab6c2de21fc24f131bb880c68ba0b7b34) +- [meta] do not publish github action workflow files [`f20fafe`](https://github.com/inspect-js/is-symbol/commit/f20fafeb21585c7b4871ea19f104fd7696734fe8) +- [Tests] run `nyc` on all tests [`5c332fc`](https://github.com/inspect-js/is-symbol/commit/5c332fc92cecbed4a2041bc0c52b991b4a593f34) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`c5a58a8`](https://github.com/inspect-js/is-symbol/commit/c5a58a8bea390a9b02e1c8c4aac30c223370297b) +- [readme] fix repo URLs; remove travis badge [`bcd9258`](https://github.com/inspect-js/is-symbol/commit/bcd9258d161fe709148fcc47962df3372c544727) +- [actions] add "Allow Edits" workflow [`33ae2d3`](https://github.com/inspect-js/is-symbol/commit/33ae2d3940e9daa6003a84c232874ee558b2fb44) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`e53def0`](https://github.com/inspect-js/is-symbol/commit/e53def0b77c38cbfae87fd8bbfd78953b845ea94) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect` [`ae36504`](https://github.com/inspect-js/is-symbol/commit/ae365048c0c1b13457faa78658b80561f5a0bcd0) +- [readme] add actions and codecov badges [`aae7f09`](https://github.com/inspect-js/is-symbol/commit/aae7f09bd59d36df69d3b66d9b351c39fe072330) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`d993fae`](https://github.com/inspect-js/is-symbol/commit/d993fae6d89856d4ab7818874be597249cb8a8cc) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`51808a5`](https://github.com/inspect-js/is-symbol/commit/51808a55f272023201f40a59b2459ec6305bf73a) +- [Dev Deps] update `auto-changelog`, `tape` [`c90040f`](https://github.com/inspect-js/is-symbol/commit/c90040f0aeded8d0071a78d5cd593b385f8828ee) +- [Dev Deps] update `eslint`, `tape` [`9fee159`](https://github.com/inspect-js/is-symbol/commit/9fee159403d499a5ed2f5cb5db03747d09ab1766) +- [meta] use `prepublishOnly` script for npm 7+ [`b166afc`](https://github.com/inspect-js/is-symbol/commit/b166afc3ae3c6d11721a9558ddb112a28261688d) +- [meta] gitignore coverage output [`4a0fe3a`](https://github.com/inspect-js/is-symbol/commit/4a0fe3aa074b933074fcc231ce739005e1fec195) +- [actions] update workflows [`fbcbc9e`](https://github.com/inspect-js/is-symbol/commit/fbcbc9eb5bfe2cf9a77d5bd86bb1dece8e5f81d0) +- [Dev Deps] update `auto-changelog`; add `aud` [`e66ab98`](https://github.com/inspect-js/is-symbol/commit/e66ab989e48b81b48bd443d35dba0071950c5d7a) +- [Deps] update `has-symbols` [`6ce7de5`](https://github.com/inspect-js/is-symbol/commit/6ce7de53c866c068de2c28d97b3a64cf6d5f6a76) +- [actions] update rebase action to use checkout v2 [`1173c79`](https://github.com/inspect-js/is-symbol/commit/1173c79914076d73aec9aebc22dce4122e7bd3ae) +- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`94a6348`](https://github.com/inspect-js/is-symbol/commit/94a6348f6274eac9bf4c5a6057b4f6120fc7d1d1) +- [Tests] only audit prod deps [`0692681`](https://github.com/inspect-js/is-symbol/commit/06926811fa029fe0fded5d0af4553a7808c143d1) +- [meta] do not publish .nvmrc file [`ed47833`](https://github.com/inspect-js/is-symbol/commit/ed478333c72384f8dbeb51e5fd501238f52a4972) + +## [v1.0.3](https://github.com/inspect-js/is-symbol/compare/v1.0.2...v1.0.3) - 2019-11-20 + +### Commits + +- [Tests] use shared travis-ci configs [`034afdd`](https://github.com/inspect-js/is-symbol/commit/034afdd677c1b72b76751f3e5131acc927a32916) +- [Tests] remove `jscs` [`0c026a0`](https://github.com/inspect-js/is-symbol/commit/0c026a06815e46a33a8a5b4b1be8965d32d38e5c) +- [meta] add `auto-changelog` [`9a1776b`](https://github.com/inspect-js/is-symbol/commit/9a1776bb49f3e6ac12a5b3a447edcc651216891b) +- [Tests] up to `node` `v12.10`, `v11.15`, `v10.16`, `v8.16`, `v6.17` [`23a6db4`](https://github.com/inspect-js/is-symbol/commit/23a6db49a338d19eab19d876745513820bb6a9dc) +- [Tests] up to `node` `v11.7`, `v10.15`, `v8.15`, `v6.16` [`892d92e`](https://github.com/inspect-js/is-symbol/commit/892d92e7c40f3c0577583a98134106181c38bb7e) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `semver`, `tape` [`c2e6d6a`](https://github.com/inspect-js/is-symbol/commit/c2e6d6a71f839522bbd124b7419f5fc42ffff6d3) +- [readme] fix repo URLs [`655c288`](https://github.com/inspect-js/is-symbol/commit/655c288a815856e647dba4b6049b1743cec3533c) +- [actions] add automatic rebasing / merge commit blocking [`97b1229`](https://github.com/inspect-js/is-symbol/commit/97b12296bf8fa1ce0c6121bf3de56c413da10aae) +- [meta] add FUNDING.yml [`94c64a3`](https://github.com/inspect-js/is-symbol/commit/94c64a367a1c34f960cf6007fc65cfbbcba34ba3) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `tape`, `semver` [`71ab543`](https://github.com/inspect-js/is-symbol/commit/71ab543e09b820378362f4f66248addd410c6388) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `semver`, `tape` [`c6212f9`](https://github.com/inspect-js/is-symbol/commit/c6212f94e28622c94bb37189ffc241ee88b5b1dd) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `object-inspect` [`91bc802`](https://github.com/inspect-js/is-symbol/commit/91bc802e18e63f4e8230ee0148302ce849e2f733) +- [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops [`8cbe69c`](https://github.com/inspect-js/is-symbol/commit/8cbe69c3fafe9cfbe7d27f710c88d02d2d2c6a00) +- [Tests] use `npm audit` instead of `nsp` [`741b51d`](https://github.com/inspect-js/is-symbol/commit/741b51dac868f6b22736c204910d257bcf4d5044) +- [meta] add `funding` field [`65b58d1`](https://github.com/inspect-js/is-symbol/commit/65b58d1e9fc572712d462d615e6b2418627d8fb9) +- [Deps] update `has-symbols` [`9cb5b2a`](https://github.com/inspect-js/is-symbol/commit/9cb5b2a9a3b89e8e0246be8df4fff3f5ceac7309) + +## [v1.0.2](https://github.com/inspect-js/is-symbol/compare/v1.0.1...v1.0.2) - 2018-09-20 + +### Commits + +- Update `eslint`, `tape`, `semver`; use my personal shared `eslint` config [`e86aaea`](https://github.com/inspect-js/is-symbol/commit/e86aaea8d81356801ecfc60540523e9b809a55f4) +- [Tests] on all node minors; improve test matrix [`50bc07f`](https://github.com/inspect-js/is-symbol/commit/50bc07f2ff73e5499b02a61f0a00ea48a84ae213) +- [Dev Deps] update `tape`, `jscs`, `nsp`, `semver`, `eslint`, `@ljharb/eslint-config` [`45e17bd`](https://github.com/inspect-js/is-symbol/commit/45e17bdf145846f30122348a94c5e506b90836ba) +- [Tests] up to `node` `v10.0`, `v9.11`, `v8.11`, `v6.14`, `v4.9`; use `nvm install-latest-npm` [`44402cb`](https://github.com/inspect-js/is-symbol/commit/44402cb82d4499e947b48b31b14667d1ebe7e2b4) +- [Tests] up to `node` `v8.1`, `v7.10`, `v6.11`, `v4.8`; improve matrix; old npm breaks on newer nodes [`9047c23`](https://github.com/inspect-js/is-symbol/commit/9047c232857ecb80551a21cc0b1cc4c91d28da1f) +- Update `tape`, `covert`, `jscs`, `semver` [`d57d1ce`](https://github.com/inspect-js/is-symbol/commit/d57d1ce3fc0b740885a1ed5c0738d4a27b29ab07) +- Add `npm run eslint` [`0d75a66`](https://github.com/inspect-js/is-symbol/commit/0d75a6638ad6f7ff7d5bc958531a6328fb13e3fe) +- Update `eslint` [`042fb3a`](https://github.com/inspect-js/is-symbol/commit/042fb3aec590f0c0d205b15812b285ad95cfff6b) +- [Refactor] use `has-symbols` and `object-inspect` [`129bc68`](https://github.com/inspect-js/is-symbol/commit/129bc68dd619b789b9956ac9b63b46257ee1060c) +- [Tests] up to `node` `v10.11`, `v8.12` [`c1822e8`](https://github.com/inspect-js/is-symbol/commit/c1822e84d6cc0cee9f1c2893e91b1aa999ad41db) +- Update `tape`, `jscs`, `eslint`, `@ljharb/eslint-config` [`089d2cf`](https://github.com/inspect-js/is-symbol/commit/089d2cf7cad87b75aa534769af11524ad2e79080) +- [Tests] up to `node` `v8.4`; newer npm breaks on older node [`05ce701`](https://github.com/inspect-js/is-symbol/commit/05ce701e3c1be8b3266ffac49806832e410491c1) +- All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. [`241e6a6`](https://github.com/inspect-js/is-symbol/commit/241e6a655c0e19e9dcf0ae88e7fddd4cde394c5c) +- Test on latest `node` and `io.js` versions. [`5c8d5de`](https://github.com/inspect-js/is-symbol/commit/5c8d5deb9b7c01a8cdf959082a3d619c19751b0a) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `nsp`, `semver`, `tape` [`06047bf`](https://github.com/inspect-js/is-symbol/commit/06047bf72b20a66c0b455e80856b2d00b1910391) +- [Dev Deps] update `jscs`, `nsp`, `semver`, `eslint`, `@ljharb/eslint-config` [`9d25dd7`](https://github.com/inspect-js/is-symbol/commit/9d25dd79347c89f98207a3bad39f667f1f8a410e) +- [Tests] up to `io.js` `v3.3`, `node` `v4.1` [`ce173bd`](https://github.com/inspect-js/is-symbol/commit/ce173bda6e146907e3061a0e70463107d955de35) +- Update `nsp`, `eslint` [`29e5214`](https://github.com/inspect-js/is-symbol/commit/29e52140fac2049b4a32e175787bb3b184a1dd72) +- Update `semver`, `eslint` [`53be884`](https://github.com/inspect-js/is-symbol/commit/53be884c2811f7a4452581003d9cdaf6f9bddd3c) +- [Dev Deps] update `eslint`, `nsp`, `semver`, `tape` [`3bd149c`](https://github.com/inspect-js/is-symbol/commit/3bd149c869c099b07104b06c0692755a01f8298c) +- [Dev Deps] update `jscs` [`69b4231`](https://github.com/inspect-js/is-symbol/commit/69b4231632b170e5ddb350db2f0c59e6cad6f548) +- Test up to `io.js` `v2.1` [`0b61ac7`](https://github.com/inspect-js/is-symbol/commit/0b61ac7ac4de390296aeefb9395549592ea87da4) +- [Dev Deps] update `tape` [`5e1b200`](https://github.com/inspect-js/is-symbol/commit/5e1b2008c910bcdabee299a1ac599143ea07c3f9) +- Only apps should have lockfiles. [`a191ff5`](https://github.com/inspect-js/is-symbol/commit/a191ff5f0320fc16db42fdaa40f0c21d4326255e) +- [Dev Deps] update `nsp`, `eslint`, `@ljharb/eslint-config` [`97c87ef`](https://github.com/inspect-js/is-symbol/commit/97c87ef52b966f211e231092a54ef6ed05c99a26) +- Test on `io.js` `v2.2` [`42560e4`](https://github.com/inspect-js/is-symbol/commit/42560e466e17cbbb9fa71c0121f4bbbcf266c887) +- [Dev Deps] Update `tape`, `eslint` [`149b2f2`](https://github.com/inspect-js/is-symbol/commit/149b2f20bde92b2da12ccfeb8988beb2dc95c37c) +- [Tests] fix test messages [`28bd1ed`](https://github.com/inspect-js/is-symbol/commit/28bd1eda310590e13ada19cbd718c85c25d8a0c5) +- Test up to `io.js` `v3.0` [`c0dcc98`](https://github.com/inspect-js/is-symbol/commit/c0dcc98313d17151ec043e5452df306618be865e) +- `node` now supports Symbols now. [`d1853ad`](https://github.com/inspect-js/is-symbol/commit/d1853adf6369ab9d4c4516bdb032c2e42f52f90a) +- [Dev Deps] update `tape` [`f7a6575`](https://github.com/inspect-js/is-symbol/commit/f7a6575fbdef13abcc412c63d22b56943ed85969) +- Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. [`aae9c6a`](https://github.com/inspect-js/is-symbol/commit/aae9c6a724578659976ea74e11ec9fe35608607b) +- Test on `io.js` `v2.4` [`ab8f449`](https://github.com/inspect-js/is-symbol/commit/ab8f4492115270cc00a479915b02ac1bac75dfed) +- Test on `io.js` `v2.3` [`58ce871`](https://github.com/inspect-js/is-symbol/commit/58ce871674e857955b333aa057eeecd68b40e988) + +## [v1.0.1](https://github.com/inspect-js/is-symbol/compare/v1.0.0...v1.0.1) - 2015-01-26 + +### Commits + +- Correct package description. [`f4d15b9`](https://github.com/inspect-js/is-symbol/commit/f4d15b928b4b754b097a84f7c3ceac73c486aceb) + +## v1.0.0 - 2015-01-24 + +### Commits + +- Dotfiles. [`5d9a744`](https://github.com/inspect-js/is-symbol/commit/5d9a7441f724630070e9bd74a995191cafa1064b) +- Tests. [`8af5663`](https://github.com/inspect-js/is-symbol/commit/8af56631950dcee48b36f517837273193a6ba119) +- `make release` [`6293446`](https://github.com/inspect-js/is-symbol/commit/629344654a72e7fc8059607d6a86c64b002c3e5d) +- package.json [`7d4082c`](https://github.com/inspect-js/is-symbol/commit/7d4082ca9502118e70d24f526704d45a1a7f2067) +- Initial commit [`cbb179f`](https://github.com/inspect-js/is-symbol/commit/cbb179f677bd3dcb56ac5e3f0a7a9af503fd8952) +- Read me. [`099a775`](https://github.com/inspect-js/is-symbol/commit/099a775e7e751706283ae1cab7a8635c094773a9) +- Implementation. [`cb51248`](https://github.com/inspect-js/is-symbol/commit/cb51248eedaf55e0b8ad7dacdab179db2d76e96e) diff --git a/node_modules/is-symbol/LICENSE b/node_modules/is-symbol/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b43df444e518288ceef6eaa9badd33388191b1d3 --- /dev/null +++ b/node_modules/is-symbol/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +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. + diff --git a/node_modules/is-symbol/README.md b/node_modules/is-symbol/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5432594c7b46bfed4e9f0db4ca2afd09716125e7 --- /dev/null +++ b/node_modules/is-symbol/README.md @@ -0,0 +1,45 @@ +# is-symbol [![Version Badge][2]][1] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +Is this an ES6 Symbol value? + +## Example + +```js +var isSymbol = require('is-symbol'); +assert(!isSymbol(function () {})); +assert(!isSymbol(null)); +assert(!isSymbol(function* () { yield 42; return Infinity; }); + +assert(isSymbol(Symbol.iterator)); +assert(isSymbol(Symbol('foo'))); +assert(isSymbol(Symbol.for('foo'))); +assert(isSymbol(Object(Symbol('foo')))); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/is-symbol +[2]: https://versionbadg.es/inspect-js/is-symbol.svg +[5]: https://david-dm.org/inspect-js/is-symbol.svg +[6]: https://david-dm.org/inspect-js/is-symbol +[7]: https://david-dm.org/inspect-js/is-symbol/dev-status.svg +[8]: https://david-dm.org/inspect-js/is-symbol#info=devDependencies +[11]: https://nodei.co/npm/is-symbol.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/is-symbol.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/is-symbol.svg +[downloads-url]: https://npm-stat.com/charts.html?package=is-symbol +[codecov-image]: https://codecov.io/gh/inspect-js/is-symbol/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/is-symbol/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-symbol +[actions-url]: https://github.com/inspect-js/is-symbol/actions diff --git a/node_modules/is-symbol/index.js b/node_modules/is-symbol/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3d653e27f5fc63af9e16225b31a70cc7c429f6ae --- /dev/null +++ b/node_modules/is-symbol/index.js @@ -0,0 +1,35 @@ +'use strict'; + +var toStr = Object.prototype.toString; +var hasSymbols = require('has-symbols')(); + +if (hasSymbols) { + var symToStr = Symbol.prototype.toString; + var symStringRegex = /^Symbol\(.*\)$/; + var isSymbolObject = function isRealSymbolObject(value) { + if (typeof value.valueOf() !== 'symbol') { + return false; + } + return symStringRegex.test(symToStr.call(value)); + }; + + module.exports = function isSymbol(value) { + if (typeof value === 'symbol') { + return true; + } + if (toStr.call(value) !== '[object Symbol]') { + return false; + } + try { + return isSymbolObject(value); + } catch (e) { + return false; + } + }; +} else { + + module.exports = function isSymbol(value) { + // this environment does not support Symbols. + return false && value; + }; +} diff --git a/node_modules/is-symbol/package.json b/node_modules/is-symbol/package.json new file mode 100644 index 0000000000000000000000000000000000000000..4472b176f50b834b993378cc658686afebc3f63e --- /dev/null +++ b/node_modules/is-symbol/package.json @@ -0,0 +1,77 @@ +{ + "name": "is-symbol", + "version": "1.0.4", + "description": "Determine if a value is an ES6 Symbol or not.", + "main": "index.js", + "scripts": { + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "npx aud --production", + "lint": "eslint .", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git://github.com/inspect-js/is-symbol.git" + }, + "keywords": [ + "symbol", + "es6", + "is", + "Symbol" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/is-symbol/issues" + }, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "devDependencies": { + "@ljharb/eslint-config": "^17.6.0", + "aud": "^1.1.5", + "auto-changelog": "^2.2.1", + "eslint": "^7.26.0", + "nyc": "^10.3.2", + "object-inspect": "^1.10.3", + "safe-publish-latest": "^1.1.4", + "tape": "^5.2.2" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + } +} diff --git a/node_modules/is-symbol/test/index.js b/node_modules/is-symbol/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e01f035c8ca3ab2410d07e2bbf63351a73f5d335 --- /dev/null +++ b/node_modules/is-symbol/test/index.js @@ -0,0 +1,92 @@ +'use strict'; + +var test = require('tape'); +var isSymbol = require('../index'); + +var forEach = function (arr, func) { + var i; + for (i = 0; i < arr.length; ++i) { + func(arr[i], i, arr); + } +}; + +var hasSymbols = require('has-symbols')(); +var inspect = require('object-inspect'); +var debug = function (v, m) { return inspect(v) + ' ' + m; }; + +test('non-symbol values', function (t) { + var nonSymbols = [ + true, + false, + Object(true), + Object(false), + null, + undefined, + {}, + [], + /a/g, + 'string', + 42, + new Date(), + function () {}, + NaN + ]; + t.plan(nonSymbols.length); + forEach(nonSymbols, function (nonSymbol) { + t.equal(false, isSymbol(nonSymbol), debug(nonSymbol, 'is not a symbol')); + }); + t.end(); +}); + +test('faked symbol values', function (t) { + t.test('real symbol valueOf', { skip: !hasSymbols }, function (st) { + var fakeSymbol = { valueOf: function () { return Symbol('foo'); } }; + st.equal(false, isSymbol(fakeSymbol), 'object with valueOf returning a symbol is not a symbol'); + st.end(); + }); + + t.test('faked @@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (st) { + var fakeSymbol = { valueOf: function () { return Symbol('foo'); } }; + fakeSymbol[Symbol.toStringTag] = 'Symbol'; + st.equal(false, isSymbol(fakeSymbol), 'object with fake Symbol @@toStringTag and valueOf returning a symbol is not a symbol'); + var notSoFakeSymbol = { valueOf: function () { return 42; } }; + notSoFakeSymbol[Symbol.toStringTag] = 'Symbol'; + st.equal(false, isSymbol(notSoFakeSymbol), 'object with fake Symbol @@toStringTag and valueOf not returning a symbol is not a symbol'); + st.end(); + }); + + var fakeSymbolString = { toString: function () { return 'Symbol(foo)'; } }; + t.equal(false, isSymbol(fakeSymbolString), 'object with toString returning Symbol(foo) is not a symbol'); + + t.end(); +}); + +test('Symbol support', { skip: !hasSymbols }, function (t) { + t.test('well-known Symbols', function (st) { + var isWellKnown = function filterer(name) { + return name !== 'for' && name !== 'keyFor' && !(name in filterer); + }; + var wellKnownSymbols = Object.getOwnPropertyNames(Symbol).filter(isWellKnown); + wellKnownSymbols.forEach(function (name) { + var sym = Symbol[name]; + st.equal(true, isSymbol(sym), debug(sym, ' is a symbol')); + }); + st.end(); + }); + + t.test('user-created symbols', function (st) { + var symbols = [ + Symbol(), + Symbol('foo'), + Symbol['for']('foo'), + Object(Symbol('object')) + ]; + symbols.forEach(function (sym) { + st.equal(true, isSymbol(sym), debug(sym, ' is a symbol')); + }); + st.end(); + }); + + t.end(); +}); + diff --git a/node_modules/is-typed-array/.editorconfig b/node_modules/is-typed-array/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..bc228f8269443bf772b437890dde7756a3e8a894 --- /dev/null +++ b/node_modules/is-typed-array/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 150 + +[CHANGELOG.md] +indent_style = space +indent_size = 2 + +[*.json] +max_line_length = off + +[Makefile] +max_line_length = off diff --git a/node_modules/is-typed-array/.eslintrc b/node_modules/is-typed-array/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..34a62620e3d28724ef3fc44878562231174b28c8 --- /dev/null +++ b/node_modules/is-typed-array/.eslintrc @@ -0,0 +1,13 @@ +{ + "root": true, + + "extends": "@ljharb", + + "globals": { + "globalThis": false + }, + + "rules": { + "max-statements-per-line": [2, { "max": 2 }] + }, +} diff --git a/node_modules/is-typed-array/.github/FUNDING.yml b/node_modules/is-typed-array/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..7dd24b969689c940d2d35f91381ccd813235009f --- /dev/null +++ b/node_modules/is-typed-array/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/is-typed-array +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/is-typed-array/.nycrc b/node_modules/is-typed-array/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/is-typed-array/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/is-typed-array/CHANGELOG.md b/node_modules/is-typed-array/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..b139d2db46249ac859eae935e1669b5c7ba79938 --- /dev/null +++ b/node_modules/is-typed-array/CHANGELOG.md @@ -0,0 +1,134 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.1.12](https://github.com/inspect-js/is-typed-array/compare/v1.1.11...v1.1.12) - 2023-07-17 + +### Commits + +- [Refactor] use `which-typed-array` for all internals [`7619405`](https://github.com/inspect-js/is-typed-array/commit/761940532de595f6721fed101b02814dcfa7fe4e) + +## [v1.1.11](https://github.com/inspect-js/is-typed-array/compare/v1.1.10...v1.1.11) - 2023-07-17 + +### Commits + +- [Fix] `node < v0.6` lacks proper Object toString behavior [`c94b90d`](https://github.com/inspect-js/is-typed-array/commit/c94b90dc6bc457783d6f8cc208415a49da0933b7) +- [Robustness] use `call-bind` [`573b00b`](https://github.com/inspect-js/is-typed-array/commit/573b00b8deec42ac1ac262415e442ea0b7e1c96b) +- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`c88c2d4`](https://github.com/inspect-js/is-typed-array/commit/c88c2d479976110478fa4038fe8921251c06a163) + +## [v1.1.10](https://github.com/inspect-js/is-typed-array/compare/v1.1.9...v1.1.10) - 2022-11-02 + +### Commits + +- [meta] add `auto-changelog` [`cf6d86b`](https://github.com/inspect-js/is-typed-array/commit/cf6d86bf2f693eca357439d4d12e76d641f91f92) +- [actions] update rebase action to use reusable workflow [`8da51a5`](https://github.com/inspect-js/is-typed-array/commit/8da51a5dce6d2442ae31ccbc2be136f2e04d6bef) +- [Dev Deps] update `aud`, `is-callable`, `object-inspect`, `tape` [`554e3de`](https://github.com/inspect-js/is-typed-array/commit/554e3deec59dec926d0badc628e589ab363e465b) +- [Refactor] use `gopd` instead of an `es-abstract` helper` [`cdaa465`](https://github.com/inspect-js/is-typed-array/commit/cdaa465d5f94bfc9e32475e31209e1c2458a9603) +- [Deps] update `es-abstract` [`677ae4b`](https://github.com/inspect-js/is-typed-array/commit/677ae4b3c8323b59d6650a9254ab945045c33f79) + + + +1.1.9 / 2022-05-13 +================= + * [Refactor] use `foreach` instead of `for-each` + * [readme] markdown URL cleanup + * [Deps] update `es-abstract` + * [meta] use `npmignore` to autogenerate an npmignore file + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `safe-publish-latest`, `tape` + * [actions] reuse common workflows + * [actions] update codecov uploader + +1.1.8 / 2021-08-30 +================= + * [Refactor] use `globalThis` if available (#53) + * [Deps] update `available-typed-arrays` + * [Dev Deps] update `@ljharb/eslint-config` + +1.1.7 / 2021-08-07 +================= + * [Fix] if Symbol.toStringTag exists but is not present, use Object.prototype.toString + * [Dev Deps] update `is-callable`, `tape` + +1.1.6 / 2021-08-05 +================= + * [Fix] use `has-tostringtag` to behave correctly in the presence of symbol shams + * [readme] add actions and codecov badges + * [meta] use `prepublishOnly` script for npm 7+ + * [Deps] update `available-typed-arrays`, `es-abstract` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` + * [actions] use `node/install` instead of `node/run`; use `codecov` action + +1.1.5 / 2021-02-14 +================= + * [meta] do not publish github action workflow files or nyc output + * [Deps] update `call-bind`, `es-abstract` + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `is-callable`, `tape` + +1.1.4 / 2020-12-05 +================= + * [readme] fix repo URLs, remove defunct badges + * [Deps] update `available-typed-arrays`, `es-abstract`; use `call-bind` where applicable + * [meta] gitignore nyc output + * [meta] only audit prod deps + * [actions] add "Allow Edits" workflow + * [actions] switch Automatic Rebase workflow to `pull_request_target` event + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `is-callable`, `make-arrow-function`, `make-generator-function`, `object-inspect`, `tape`; add `aud` + * [Tests] migrate tests to Github Actions + * [Tests] run `nyc` on all tests + +1.1.3 / 2020-01-24 +================= + * [Refactor] use `es-abstract`’s `callBound`, `available-typed-arrays`, `has-symbols` + +1.1.2 / 2020-01-20 +================= + * [Fix] in envs without Symbol.toStringTag, dc8a8cc made arrays return `true` + * [Tests] add `evalmd` to `prelint` + +1.1.1 / 2020-01-18 +================= + * [Robustness] don’t rely on Array.prototype.indexOf existing + * [meta] remove unused Makefile and associated utilities + * [meta] add `funding` field; create FUNDING.yml + * [actions] add automatic rebasing / merge commit blocking + * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `is-callable`, `replace`, `semver`, `tape`; add `safe-publish-latest` + * [Tests] use shared travis-ci configs + * [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops + +1.1.0 / 2019-02-16 +================= + * [New] add `BigInt64Array` and `BigUint64Array` + * [Refactor] use an array instead of an object for storing Typed Array names + * [meta] ignore `test.html` + * [Tests] up to `node` `v11.10`, `v10.15`, `v8.15`, `v7.10`, `v6.16`, `v5.10`, `v4.9` + * [Tests] remove `jscs` + * [Tests] use `npm audit` instead of `nsp` + * [Dev Deps] update `eslint`,` @ljharb/eslint-config`, `is-callable`, `tape`, `replace`, `semver` + * [Dev Deps] remove unused eccheck script + dep + +1.0.4 / 2016-03-19 +================= + * [Fix] `Symbol.toStringTag` is on the super-`[[Prototype]]` of Float32Array, not the `[[Prototype]]` (#3) + * [Tests] up to `node` `v5.9`, `v4.4` + * [Tests] use pretest/posttest for linting/security + * [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver`, `is-callable` + +1.0.3 / 2015-10-13 +================= + * [Deps] Add missing `foreach` dependency (#1) + +1.0.2 / 2015-10-05 +================= + * [Deps] Remove unneeded "isarray" dependency + * [Dev Deps] update `eslint`, `@ljharb/eslint-config` + +1.0.1 / 2015-10-02 +================= + * Rerelease: avoid instanceof and the constructor property; work cross-realm; work with Symbol.toStringTag. + +1.0.0 / 2015-05-06 +================= + * Initial release. diff --git a/node_modules/is-typed-array/LICENSE b/node_modules/is-typed-array/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..b43df444e518288ceef6eaa9badd33388191b1d3 --- /dev/null +++ b/node_modules/is-typed-array/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +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. + diff --git a/node_modules/is-typed-array/README.md b/node_modules/is-typed-array/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5075257207e2276ba02c04b8bbb8f9bd3d18b0a8 --- /dev/null +++ b/node_modules/is-typed-array/README.md @@ -0,0 +1,70 @@ +# is-typed-array [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +Is this value a JS Typed Array? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag. + +## Example + +```js +var isTypedArray = require('is-typed-array'); +var assert = require('assert'); + +assert.equal(false, isTypedArray(undefined)); +assert.equal(false, isTypedArray(null)); +assert.equal(false, isTypedArray(false)); +assert.equal(false, isTypedArray(true)); +assert.equal(false, isTypedArray([])); +assert.equal(false, isTypedArray({})); +assert.equal(false, isTypedArray(/a/g)); +assert.equal(false, isTypedArray(new RegExp('a', 'g'))); +assert.equal(false, isTypedArray(new Date())); +assert.equal(false, isTypedArray(42)); +assert.equal(false, isTypedArray(NaN)); +assert.equal(false, isTypedArray(Infinity)); +assert.equal(false, isTypedArray(new Number(42))); +assert.equal(false, isTypedArray('foo')); +assert.equal(false, isTypedArray(Object('foo'))); +assert.equal(false, isTypedArray(function () {})); +assert.equal(false, isTypedArray(function* () {})); +assert.equal(false, isTypedArray(x => x * x)); +assert.equal(false, isTypedArray([])); + +assert.ok(isTypedArray(new Int8Array())); +assert.ok(isTypedArray(new Uint8Array())); +assert.ok(isTypedArray(new Uint8ClampedArray())); +assert.ok(isTypedArray(new Int16Array())); +assert.ok(isTypedArray(new Uint16Array())); +assert.ok(isTypedArray(new Int32Array())); +assert.ok(isTypedArray(new Uint32Array())); +assert.ok(isTypedArray(new Float32Array())); +assert.ok(isTypedArray(new Float64Array())); +assert.ok(isTypedArray(new BigInt64Array())); +assert.ok(isTypedArray(new BigUint64Array())); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/is-typed-array +[npm-version-svg]: https://versionbadg.es/inspect-js/is-typed-array.svg +[deps-svg]: https://david-dm.org/inspect-js/is-typed-array.svg +[deps-url]: https://david-dm.org/inspect-js/is-typed-array +[dev-deps-svg]: https://david-dm.org/inspect-js/is-typed-array/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/is-typed-array#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/is-typed-array.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/is-typed-array.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/is-typed-array.svg +[downloads-url]: https://npm-stat.com/charts.html?package=is-typed-array +[codecov-image]: https://codecov.io/gh/inspect-js/is-typed-array/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/is-typed-array/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-typed-array +[actions-url]: https://github.com/inspect-js/is-typed-array/actions diff --git a/node_modules/is-typed-array/index.js b/node_modules/is-typed-array/index.js new file mode 100644 index 0000000000000000000000000000000000000000..08c316314ad04a641a6b77a081a2e0865e60b43f --- /dev/null +++ b/node_modules/is-typed-array/index.js @@ -0,0 +1,7 @@ +'use strict'; + +var whichTypedArray = require('which-typed-array'); + +module.exports = function isTypedArray(value) { + return !!whichTypedArray(value); +}; diff --git a/node_modules/is-typed-array/package.json b/node_modules/is-typed-array/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e2fc30213a1a4068cd730c474273e294975012d2 --- /dev/null +++ b/node_modules/is-typed-array/package.json @@ -0,0 +1,116 @@ +{ + "name": "is-typed-array", + "version": "1.1.12", + "author": { + "name": "Jordan Harband", + "email": "ljharb@gmail.com", + "url": "http://ljharb.codes" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "contributors": [ + { + "name": "Jordan Harband", + "email": "ljharb@gmail.com", + "url": "http://ljharb.codes" + } + ], + "description": "Is this value a JS Typed Array? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag.", + "license": "MIT", + "main": "index.js", + "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated", + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "prelint": "evalmd README.md", + "lint": "eslint --ext=js,mjs .", + "pretest": "npm run --silent lint", + "test": "npm run tests-only && npm run test:harmony", + "tests-only": "nyc tape test", + "test:harmony": "nyc node --harmony --es-staging test", + "posttest": "npx aud --production", + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" + }, + "repository": { + "type": "git", + "url": "git://github.com/inspect-js/is-typed-array.git" + }, + "keywords": [ + "array", + "TypedArray", + "typed array", + "is", + "typed", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "ES6", + "toStringTag", + "Symbol.toStringTag", + "@@toStringTag" + ], + "dependencies": { + "which-typed-array": "^1.1.11" + }, + "devDependencies": { + "@ljharb/eslint-config": "^21.1.0", + "aud": "^2.0.3", + "auto-changelog": "^2.4.0", + "eslint": "=8.8.0", + "evalmd": "^0.0.19", + "for-each": "^0.3.3", + "has-tostringtag": "^1.0.0", + "in-publish": "^2.0.1", + "is-callable": "^1.2.7", + "make-arrow-function": "^1.2.0", + "make-generator-function": "^2.0.0", + "npmignore": "^0.3.0", + "nyc": "^10.3.2", + "object-inspect": "^1.12.3", + "safe-publish-latest": "^2.0.0", + "tape": "^5.6.5" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true, + "startingVersion": "1.1.10" + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] + } +} diff --git a/node_modules/is-typed-array/test/index.js b/node_modules/is-typed-array/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8e7a16b08d80bc77c84046e6f9e726f584db9f0e --- /dev/null +++ b/node_modules/is-typed-array/test/index.js @@ -0,0 +1,103 @@ +'use strict'; + +var test = require('tape'); +var isTypedArray = require('../'); +var isCallable = require('is-callable'); +var hasToStringTag = require('has-tostringtag/shams')(); +var generators = require('make-generator-function')(); +var arrowFn = require('make-arrow-function')(); +var forEach = require('for-each'); +var inspect = require('object-inspect'); + +var typedArrayNames = [ + 'Int8Array', + 'Uint8Array', + 'Uint8ClampedArray', + 'Int16Array', + 'Uint16Array', + 'Int32Array', + 'Uint32Array', + 'Float32Array', + 'Float64Array', + 'BigInt64Array', + 'BigUint64Array' +]; + +test('not arrays', function (t) { + t.test('non-number/string primitives', function (st) { + st.notOk(isTypedArray(), 'undefined is not typed array'); + st.notOk(isTypedArray(null), 'null is not typed array'); + st.notOk(isTypedArray(false), 'false is not typed array'); + st.notOk(isTypedArray(true), 'true is not typed array'); + st.end(); + }); + + t.notOk(isTypedArray({}), 'object is not typed array'); + t.notOk(isTypedArray(/a/g), 'regex literal is not typed array'); + t.notOk(isTypedArray(new RegExp('a', 'g')), 'regex object is not typed array'); + t.notOk(isTypedArray(new Date()), 'new Date() is not typed array'); + + t.test('numbers', function (st) { + st.notOk(isTypedArray(42), 'number is not typed array'); + st.notOk(isTypedArray(Object(42)), 'number object is not typed array'); + st.notOk(isTypedArray(NaN), 'NaN is not typed array'); + st.notOk(isTypedArray(Infinity), 'Infinity is not typed array'); + st.end(); + }); + + t.test('strings', function (st) { + st.notOk(isTypedArray('foo'), 'string primitive is not typed array'); + st.notOk(isTypedArray(Object('foo')), 'string object is not typed array'); + st.end(); + }); + + t.end(); +}); + +test('Functions', function (t) { + t.notOk(isTypedArray(function () {}), 'function is not typed array'); + t.end(); +}); + +test('Generators', { skip: generators.length === 0 }, function (t) { + forEach(generators, function (genFn) { + t.notOk(isTypedArray(genFn), 'generator function ' + inspect(genFn) + ' is not typed array'); + }); + t.end(); +}); + +test('Arrow functions', { skip: !arrowFn }, function (t) { + t.notOk(isTypedArray(arrowFn), 'arrow function is not typed array'); + t.end(); +}); + +test('@@toStringTag', { skip: !hasToStringTag }, function (t) { + forEach(typedArrayNames, function (typedArray) { + if (typeof global[typedArray] === 'function') { + var fakeTypedArray = []; + fakeTypedArray[Symbol.toStringTag] = typedArray; + t.notOk(isTypedArray(fakeTypedArray), 'faked ' + typedArray + ' is not typed array'); + } else { + t.comment('# SKIP ' + typedArray + ' is not supported'); + } + }); + t.end(); +}); + +test('non-Typed Arrays', function (t) { + t.notOk(isTypedArray([]), '[] is not typed array'); + t.end(); +}); + +test('Typed Arrays', function (t) { + forEach(typedArrayNames, function (typedArray) { + var TypedArray = global[typedArray]; + if (isCallable(TypedArray)) { + var arr = new TypedArray(10); + t.ok(isTypedArray(arr), 'new ' + typedArray + '(10) is typed array'); + } else { + t.comment('# SKIP ' + typedArray + ' is not supported'); + } + }); + t.end(); +}); diff --git a/node_modules/is-typedarray/LICENSE.md b/node_modules/is-typedarray/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..ee27ba4b4412b0e4a05af5e3d8a005bc6681fdf3 --- /dev/null +++ b/node_modules/is-typedarray/LICENSE.md @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +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. diff --git a/node_modules/is-typedarray/README.md b/node_modules/is-typedarray/README.md new file mode 100644 index 0000000000000000000000000000000000000000..275286391935842285d869d8a18949e04ca20fdf --- /dev/null +++ b/node_modules/is-typedarray/README.md @@ -0,0 +1,16 @@ +# is-typedarray [![locked](http://badges.github.io/stability-badges/dist/locked.svg)](http://github.com/badges/stability-badges) + +Detect whether or not an object is a +[Typed Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays). + +## Usage + +[![NPM](https://nodei.co/npm/is-typedarray.png)](https://nodei.co/npm/is-typedarray/) + +### isTypedArray(array) + +Returns `true` when array is a Typed Array, and `false` when it is not. + +## License + +MIT. See [LICENSE.md](http://github.com/hughsk/is-typedarray/blob/master/LICENSE.md) for details. diff --git a/node_modules/is-typedarray/index.js b/node_modules/is-typedarray/index.js new file mode 100644 index 0000000000000000000000000000000000000000..58596036cdf15908a729e6547936eef72b2d2e60 --- /dev/null +++ b/node_modules/is-typedarray/index.js @@ -0,0 +1,41 @@ +module.exports = isTypedArray +isTypedArray.strict = isStrictTypedArray +isTypedArray.loose = isLooseTypedArray + +var toString = Object.prototype.toString +var names = { + '[object Int8Array]': true + , '[object Int16Array]': true + , '[object Int32Array]': true + , '[object Uint8Array]': true + , '[object Uint8ClampedArray]': true + , '[object Uint16Array]': true + , '[object Uint32Array]': true + , '[object Float32Array]': true + , '[object Float64Array]': true +} + +function isTypedArray(arr) { + return ( + isStrictTypedArray(arr) + || isLooseTypedArray(arr) + ) +} + +function isStrictTypedArray(arr) { + return ( + arr instanceof Int8Array + || arr instanceof Int16Array + || arr instanceof Int32Array + || arr instanceof Uint8Array + || arr instanceof Uint8ClampedArray + || arr instanceof Uint16Array + || arr instanceof Uint32Array + || arr instanceof Float32Array + || arr instanceof Float64Array + ) +} + +function isLooseTypedArray(arr) { + return names[toString.call(arr)] +} diff --git a/node_modules/is-typedarray/package.json b/node_modules/is-typedarray/package.json new file mode 100644 index 0000000000000000000000000000000000000000..37f7ae31c1111a58b30e3ba32355381f8ecf8bf1 --- /dev/null +++ b/node_modules/is-typedarray/package.json @@ -0,0 +1,30 @@ +{ + "name": "is-typedarray", + "version": "1.0.0", + "description": "Detect whether or not an object is a Typed Array", + "main": "index.js", + "scripts": { + "test": "node test" + }, + "author": "Hugh Kennedy (http://hughsk.io/)", + "license": "MIT", + "dependencies": {}, + "devDependencies": { + "tape": "^2.13.1" + }, + "repository": { + "type": "git", + "url": "git://github.com/hughsk/is-typedarray.git" + }, + "keywords": [ + "typed", + "array", + "detect", + "is", + "util" + ], + "bugs": { + "url": "https://github.com/hughsk/is-typedarray/issues" + }, + "homepage": "https://github.com/hughsk/is-typedarray" +} diff --git a/node_modules/is-typedarray/test.js b/node_modules/is-typedarray/test.js new file mode 100644 index 0000000000000000000000000000000000000000..b0c176fa302aa0c3aacab1287893ee5c1f8b07d6 --- /dev/null +++ b/node_modules/is-typedarray/test.js @@ -0,0 +1,34 @@ +var test = require('tape') +var ista = require('./') + +test('strict', function(t) { + t.ok(ista.strict(new Int8Array), 'Int8Array') + t.ok(ista.strict(new Int16Array), 'Int16Array') + t.ok(ista.strict(new Int32Array), 'Int32Array') + t.ok(ista.strict(new Uint8Array), 'Uint8Array') + t.ok(ista.strict(new Uint16Array), 'Uint16Array') + t.ok(ista.strict(new Uint32Array), 'Uint32Array') + t.ok(ista.strict(new Float32Array), 'Float32Array') + t.ok(ista.strict(new Float64Array), 'Float64Array') + + t.ok(!ista.strict(new Array), 'Array') + t.ok(!ista.strict([]), '[]') + + t.end() +}) + +test('loose', function(t) { + t.ok(ista.loose(new Int8Array), 'Int8Array') + t.ok(ista.loose(new Int16Array), 'Int16Array') + t.ok(ista.loose(new Int32Array), 'Int32Array') + t.ok(ista.loose(new Uint8Array), 'Uint8Array') + t.ok(ista.loose(new Uint16Array), 'Uint16Array') + t.ok(ista.loose(new Uint32Array), 'Uint32Array') + t.ok(ista.loose(new Float32Array), 'Float32Array') + t.ok(ista.loose(new Float64Array), 'Float64Array') + + t.ok(!ista.loose(new Array), 'Array') + t.ok(!ista.loose([]), '[]') + + t.end() +}) diff --git a/node_modules/is-weakref/.eslintignore b/node_modules/is-weakref/.eslintignore new file mode 100644 index 0000000000000000000000000000000000000000..404abb22121cdcbb710c56f4ba2684789cb2868c --- /dev/null +++ b/node_modules/is-weakref/.eslintignore @@ -0,0 +1 @@ +coverage/ diff --git a/node_modules/is-weakref/.eslintrc b/node_modules/is-weakref/.eslintrc new file mode 100644 index 0000000000000000000000000000000000000000..3b5d9e90ec405f85dd7f9066656efccc51193697 --- /dev/null +++ b/node_modules/is-weakref/.eslintrc @@ -0,0 +1,5 @@ +{ + "root": true, + + "extends": "@ljharb", +} diff --git a/node_modules/is-weakref/.github/FUNDING.yml b/node_modules/is-weakref/.github/FUNDING.yml new file mode 100644 index 0000000000000000000000000000000000000000..a9ccddf2a7550f55f37d951fb6b273237d609f9f --- /dev/null +++ b/node_modules/is-weakref/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [ljharb] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: npm/is-weakref +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/node_modules/is-weakref/.nycrc b/node_modules/is-weakref/.nycrc new file mode 100644 index 0000000000000000000000000000000000000000..bdd626ce91477abbdd489b79988baebadbd3c897 --- /dev/null +++ b/node_modules/is-weakref/.nycrc @@ -0,0 +1,9 @@ +{ + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json"], + "exclude": [ + "coverage", + "test" + ] +} diff --git a/node_modules/is-weakref/CHANGELOG.md b/node_modules/is-weakref/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..573938d10ee3b2e97449c2c5cd99fb5c045efef2 --- /dev/null +++ b/node_modules/is-weakref/CHANGELOG.md @@ -0,0 +1,54 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.2](https://github.com/inspect-js/is-weakref/compare/v1.0.1...v1.0.2) - 2021-12-10 + +### Commits + +- [actions] reuse common workflows [`2375b1f`](https://github.com/inspect-js/is-weakref/commit/2375b1f9798b08c7af98481bbb38b4105835dacf) +- [meta] do not publish workflow files [`4c1be42`](https://github.com/inspect-js/is-weakref/commit/4c1be423afacabf2f3aa9e8bf02f668bdeaf3a20) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`7ec78ce`](https://github.com/inspect-js/is-weakref/commit/7ec78ce58c7553469eee97ae82fe147dfccde611) +- [readme] update URLs [`6306f09`](https://github.com/inspect-js/is-weakref/commit/6306f09a7df388150fb1d0b855b6f9e60165a457) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `safe-publish-latest`, `tape` [`7a1601e`](https://github.com/inspect-js/is-weakref/commit/7a1601e93ae50a791751a96d33073f5e65f3d3c9) +- [readme] add actions and codecov badges [`67ecd14`](https://github.com/inspect-js/is-weakref/commit/67ecd14b8b0192456932d1d54838accbf90ff5c0) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `object-inspect`, `safe-publish-latest`, `tape` [`1a5013b`](https://github.com/inspect-js/is-weakref/commit/1a5013bddcb9edc23025571810f9a2eebda53683) +- [actions] update codecov uploader [`b57b037`](https://github.com/inspect-js/is-weakref/commit/b57b037a547f3ecfa3d3f079a8015ec005c7181b) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`da49017`](https://github.com/inspect-js/is-weakref/commit/da49017800d628c9bcd2f094d49783d6ee649c50) +- [meta] simplify "exports" [`9b88835`](https://github.com/inspect-js/is-weakref/commit/9b8883585506c135a3fcb9f55d0944a13b4eb3e6) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`c7e77f4`](https://github.com/inspect-js/is-weakref/commit/c7e77f495308f3385adfaa1f4ac78a2632e0bcde) +- [Dev Deps] update `eslint` [`417b29e`](https://github.com/inspect-js/is-weakref/commit/417b29e7ceacebe24aef15422544443f4b59e181) +- [meta] add `safe-publish-latest`; use `prepublishOnly` script for npm 7+ [`b1b99f4`](https://github.com/inspect-js/is-weakref/commit/b1b99f45e0977d10f8472e9272e48a696145c2b1) +- [Deps] update `call-bind` [`aea342e`](https://github.com/inspect-js/is-weakref/commit/aea342e9e301deeb938e62b92a37cf991c5f7dbc) +- [actions] update workflows [`786c2d3`](https://github.com/inspect-js/is-weakref/commit/786c2d3dd4486acec09786220d3dd9fd48e70e93) + +## [v1.0.1](https://github.com/inspect-js/is-weakref/compare/v1.0.0...v1.0.1) - 2020-12-04 + +### Commits + +- [Tests] migrate tests to Github Actions [`05b4faa`](https://github.com/inspect-js/is-weakref/commit/05b4faa167c67f42c792e35c07adcb6b87e7dea0) +- [Tests] run `nyc` on all tests [`8df2e4b`](https://github.com/inspect-js/is-weakref/commit/8df2e4bd66bb6b7d55f389f28e6bb167fe1deb5a) +- [actions] add "Allow Edits" workflow [`4a716b8`](https://github.com/inspect-js/is-weakref/commit/4a716b8fcc025fe889a0f09ccaee7a9f748b1c66) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect` [`be23cf3`](https://github.com/inspect-js/is-weakref/commit/be23cf305f46db8b1c8a26d1c74b096fdba00056) +- [Refactor] use `call-bind` instead of `es-abstract` [`a933a96`](https://github.com/inspect-js/is-weakref/commit/a933a9643ddf7cddfd9f9f3cf44d675cc4c86ce5) +- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`4473ed2`](https://github.com/inspect-js/is-weakref/commit/4473ed2e73fed47cd2fa42b8d9cac17e941d2c08) +- [readme] remove travis badge [`bd3bfcd`](https://github.com/inspect-js/is-weakref/commit/bd3bfcd2c187099d2215232a7621fb960e1e2807) + +## v1.0.0 - 2020-08-01 + +### Commits + +- Initial commit [`dd86394`](https://github.com/inspect-js/is-weakref/commit/dd86394d7da000724c6e17c79077879c381e9ea3) +- readme [`f4defca`](https://github.com/inspect-js/is-weakref/commit/f4defcac48d1d99b019b596ab26bd868de1adfe9) +- Tests [`13d8139`](https://github.com/inspect-js/is-weakref/commit/13d8139dedf424239daf357261c39d3f8c33d662) +- npm init [`55a2bb7`](https://github.com/inspect-js/is-weakref/commit/55a2bb7c53b893396a51da969e352702cafe9a0e) +- Implementation [`1ec84e3`](https://github.com/inspect-js/is-weakref/commit/1ec84e36de4315d44c8da540faa27836832bb0f3) +- [meta] add auto-changelog [`ab9ce44`](https://github.com/inspect-js/is-weakref/commit/ab9ce44be717312c5221bf3d2f3f6d2dd8c6ac88) +- [actions] add automatic rebasing / merge commit blocking [`3d3f4d5`](https://github.com/inspect-js/is-weakref/commit/3d3f4d54bed6e455b2a0d0f20c87d454bf78af26) +- [meta] add "funding"; create `FUNDING.yml` [`f35ef3d`](https://github.com/inspect-js/is-weakref/commit/f35ef3de16eb06447acf3c39bdc164ba0e7bdf45) +- [Tests] add `npm run lint` [`af2123d`](https://github.com/inspect-js/is-weakref/commit/af2123d4754c14f7befa66ba01e1d72858723651) +- [Tests] use shared travis-ci configs [`042b4de`](https://github.com/inspect-js/is-weakref/commit/042b4dec08d882ae9137f4ad05ae24a1457da0f8) +- Only apps should have lockfiles [`fcae604`](https://github.com/inspect-js/is-weakref/commit/fcae604cb1422faae9311dd4219032895c0a9a2e) diff --git a/node_modules/is-weakref/LICENSE b/node_modules/is-weakref/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..707437b5750a24d0ed2dd693ce221283ff4508a0 --- /dev/null +++ b/node_modules/is-weakref/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Inspect JS + +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. diff --git a/node_modules/is-weakref/README.md b/node_modules/is-weakref/README.md new file mode 100644 index 0000000000000000000000000000000000000000..abbb978bf32cf48d6bbbd546fe77dcb46bd34ce7 --- /dev/null +++ b/node_modules/is-weakref/README.md @@ -0,0 +1,52 @@ +# is-weakref [![Version Badge][npm-version-svg]][package-url] + +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +Is this value a JS WeakRef? This module works cross-realm/iframe, and despite ES6 @@toStringTag. + +## Example + +```js +var isWeakRef = require('is-weakref'); +assert(!isWeakRef(function () {})); +assert(!isWeakRef(null)); +assert(!isWeakRef(function* () { yield 42; return Infinity; }); +assert(!isWeakRef(Symbol('foo'))); +assert(!isWeakRef(1n)); +assert(!isWeakRef(Object(1n))); + +assert(!isWeakRef(new Set())); +assert(!isWeakRef(new WeakSet())); +assert(!isWeakRef(new Map())); +assert(!isWeakRef(new WeakMap())); + +assert(isWeakRef(new WeakRef({}))); + +class MyWeakRef extends WeakRef {} +assert(isWeakRef(new MyWeakRef({}))); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/is-weakref +[npm-version-svg]: https://versionbadg.es/inspect-js/is-weakref.svg +[deps-svg]: https://david-dm.org/inspect-js/is-weakref.svg +[deps-url]: https://david-dm.org/inspect-js/is-weakref +[dev-deps-svg]: https://david-dm.org/inspect-js/is-weakref/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/is-weakref#info=devDependencies +[license-image]: https://img.shields.io/npm/l/is-weakref.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/is-weakref.svg +[downloads-url]: https://npm-stat.com/charts.html?package=is-weakref +[codecov-image]: https://codecov.io/gh/inspect-js/is-weakref/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/is-weakref/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-weakref +[actions-url]: https://github.com/inspect-js/is-weakref/actions diff --git a/node_modules/is-weakref/index.js b/node_modules/is-weakref/index.js new file mode 100644 index 0000000000000000000000000000000000000000..90769f8ac425ef23175e2d387a3c168232e0c947 --- /dev/null +++ b/node_modules/is-weakref/index.js @@ -0,0 +1,21 @@ +'use strict'; + +var callBound = require('call-bind/callBound'); + +var $deref = callBound('WeakRef.prototype.deref', true); + +module.exports = typeof WeakRef === 'undefined' + ? function isWeakRef(value) { // eslint-disable-line no-unused-vars + return false; + } + : function isWeakRef(value) { + if (!value || typeof value !== 'object') { + return false; + } + try { + $deref(value); + return true; + } catch (e) { + return false; + } + }; diff --git a/node_modules/is-weakref/package.json b/node_modules/is-weakref/package.json new file mode 100644 index 0000000000000000000000000000000000000000..2d2a6e2a16a33b310519ddda4001588dab1c9ea8 --- /dev/null +++ b/node_modules/is-weakref/package.json @@ -0,0 +1,63 @@ +{ + "name": "is-weakref", + "version": "1.0.2", + "description": "Is this value a JS WeakRef? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", + "main": "index.js", + "exports": { + ".": "./index.js", + "./package.json": "./package.json" + }, + "scripts": { + "version": "auto-changelog && git add CHANGELOG.md", + "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"", + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", + "lint": "eslint --ext=js,mjs .", + "pretest": "npm run lint", + "tests-only": "nyc tape 'test/**/*.js'", + "test": "npm run tests-only", + "posttest": "aud --production" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/inspect-js/is-weakref.git" + }, + "keywords": [ + "weakref", + "weak", + "ref", + "finalization", + "finalization registry" + ], + "author": "Jordan Harband ", + "funding": { + "url": "https://github.com/sponsors/ljharb" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/inspect-js/is-weakref/issues" + }, + "homepage": "https://github.com/inspect-js/is-weakref#readme", + "devDependencies": { + "@ljharb/eslint-config": "^20.0.0", + "aud": "^1.1.5", + "auto-changelog": "^2.3.0", + "eslint": "^8.4.1", + "for-each": "^0.3.3", + "nyc": "^10.3.2", + "object-inspect": "^1.11.1", + "safe-publish-latest": "^2.0.0", + "tape": "^5.3.2" + }, + "dependencies": { + "call-bind": "^1.0.2" + }, + "auto-changelog": { + "output": "CHANGELOG.md", + "template": "keepachangelog", + "unreleased": false, + "commitLimit": false, + "backfillLimit": false, + "hideCredit": true + } +} diff --git a/node_modules/is-weakref/test/index.js b/node_modules/is-weakref/test/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c1c5b6f966a20a5c1fe812222b3a7b9e43c9b4aa --- /dev/null +++ b/node_modules/is-weakref/test/index.js @@ -0,0 +1,26 @@ +'use strict'; + +var test = require('tape'); +var inspect = require('object-inspect'); +var forEach = require('for-each'); + +var isWeakRef = require('..'); + +test('isWeakRef', function (t) { + t.equal(typeof isWeakRef, 'function', 'is a function'); + + var nonWeakRefs = [undefined, null, true, false, 42, 0, Infinity, NaN, /a/g, function () {}, {}, []]; + forEach(nonWeakRefs, function (nonWeakRef) { + t.equal(isWeakRef(nonWeakRef), false, inspect(nonWeakRef) + ' is not a WeakRef'); + }); + + t.test('actual WeakRefs', { skip: typeof WeakRef === 'undefined' }, function (st) { + var ref = new WeakRef({}); + + st.equal(isWeakRef(ref), true, inspect(ref) + ' is a WeakRef'); + + st.end(); + }); + + t.end(); +}); diff --git a/node_modules/json-schema-traverse/.eslintrc.yml b/node_modules/json-schema-traverse/.eslintrc.yml new file mode 100644 index 0000000000000000000000000000000000000000..ab1762da9c119e9136ea914209716dd949648d8b --- /dev/null +++ b/node_modules/json-schema-traverse/.eslintrc.yml @@ -0,0 +1,27 @@ +extends: eslint:recommended +env: + node: true + browser: true +rules: + block-scoped-var: 2 + complexity: [2, 13] + curly: [2, multi-or-nest, consistent] + dot-location: [2, property] + dot-notation: 2 + indent: [2, 2, SwitchCase: 1] + linebreak-style: [2, unix] + new-cap: 2 + no-console: [2, allow: [warn, error]] + no-else-return: 2 + no-eq-null: 2 + no-fallthrough: 2 + no-invalid-this: 2 + no-return-assign: 2 + no-shadow: 1 + no-trailing-spaces: 2 + no-use-before-define: [2, nofunc] + quotes: [2, single, avoid-escape] + semi: [2, always] + strict: [2, global] + valid-jsdoc: [2, requireReturn: false] + no-control-regex: 0 diff --git a/node_modules/json-schema-traverse/.travis.yml b/node_modules/json-schema-traverse/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..7ddce74b841994f44f2b986f6ffd6f676c141469 --- /dev/null +++ b/node_modules/json-schema-traverse/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - "4" + - "6" + - "7" + - "8" +after_script: + - coveralls < coverage/lcov.info diff --git a/node_modules/json-schema-traverse/LICENSE b/node_modules/json-schema-traverse/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..7f1543566f6abbbf75914db32651cf89919cabed --- /dev/null +++ b/node_modules/json-schema-traverse/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Evgeny Poberezkin + +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. diff --git a/node_modules/json-schema-traverse/README.md b/node_modules/json-schema-traverse/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d5ccaf450a2a2bb88e5ae0778ce05712ef25c763 --- /dev/null +++ b/node_modules/json-schema-traverse/README.md @@ -0,0 +1,83 @@ +# json-schema-traverse +Traverse JSON Schema passing each schema object to callback + +[![Build Status](https://travis-ci.org/epoberezkin/json-schema-traverse.svg?branch=master)](https://travis-ci.org/epoberezkin/json-schema-traverse) +[![npm version](https://badge.fury.io/js/json-schema-traverse.svg)](https://www.npmjs.com/package/json-schema-traverse) +[![Coverage Status](https://coveralls.io/repos/github/epoberezkin/json-schema-traverse/badge.svg?branch=master)](https://coveralls.io/github/epoberezkin/json-schema-traverse?branch=master) + + +## Install + +``` +npm install json-schema-traverse +``` + + +## Usage + +```javascript +const traverse = require('json-schema-traverse'); +const schema = { + properties: { + foo: {type: 'string'}, + bar: {type: 'integer'} + } +}; + +traverse(schema, {cb}); +// cb is called 3 times with: +// 1. root schema +// 2. {type: 'string'} +// 3. {type: 'integer'} + +// Or: + +traverse(schema, {cb: {pre, post}}); +// pre is called 3 times with: +// 1. root schema +// 2. {type: 'string'} +// 3. {type: 'integer'} +// +// post is called 3 times with: +// 1. {type: 'string'} +// 2. {type: 'integer'} +// 3. root schema + +``` + +Callback function `cb` is called for each schema object (not including draft-06 boolean schemas), including the root schema, in pre-order traversal. Schema references ($ref) are not resolved, they are passed as is. Alternatively, you can pass a `{pre, post}` object as `cb`, and then `pre` will be called before traversing child elements, and `post` will be called after all child elements have been traversed. + +Callback is passed these parameters: + +- _schema_: the current schema object +- _JSON pointer_: from the root schema to the current schema object +- _root schema_: the schema passed to `traverse` object +- _parent JSON pointer_: from the root schema to the parent schema object (see below) +- _parent keyword_: the keyword inside which this schema appears (e.g. `properties`, `anyOf`, etc.) +- _parent schema_: not necessarily parent object/array; in the example above the parent schema for `{type: 'string'}` is the root schema +- _index/property_: index or property name in the array/object containing multiple schemas; in the example above for `{type: 'string'}` the property name is `'foo'` + + +## Traverse objects in all unknown keywords + +```javascript +const traverse = require('json-schema-traverse'); +const schema = { + mySchema: { + minimum: 1, + maximum: 2 + } +}; + +traverse(schema, {allKeys: true, cb}); +// cb is called 2 times with: +// 1. root schema +// 2. mySchema +``` + +Without option `allKeys: true` callback will be called only with root schema. + + +## License + +[MIT](https://github.com/epoberezkin/json-schema-traverse/blob/master/LICENSE) diff --git a/node_modules/json-schema-traverse/index.js b/node_modules/json-schema-traverse/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d4a18dfc7b1c5381b32f62db6aa54ba9251d604a --- /dev/null +++ b/node_modules/json-schema-traverse/index.js @@ -0,0 +1,89 @@ +'use strict'; + +var traverse = module.exports = function (schema, opts, cb) { + // Legacy support for v0.3.1 and earlier. + if (typeof opts == 'function') { + cb = opts; + opts = {}; + } + + cb = opts.cb || cb; + var pre = (typeof cb == 'function') ? cb : cb.pre || function() {}; + var post = cb.post || function() {}; + + _traverse(opts, pre, post, schema, '', schema); +}; + + +traverse.keywords = { + additionalItems: true, + items: true, + contains: true, + additionalProperties: true, + propertyNames: true, + not: true +}; + +traverse.arrayKeywords = { + items: true, + allOf: true, + anyOf: true, + oneOf: true +}; + +traverse.propsKeywords = { + definitions: true, + properties: true, + patternProperties: true, + dependencies: true +}; + +traverse.skipKeywords = { + default: true, + enum: true, + const: true, + required: true, + maximum: true, + minimum: true, + exclusiveMaximum: true, + exclusiveMinimum: true, + multipleOf: true, + maxLength: true, + minLength: true, + pattern: true, + format: true, + maxItems: true, + minItems: true, + uniqueItems: true, + maxProperties: true, + minProperties: true +}; + + +function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) { + if (schema && typeof schema == 'object' && !Array.isArray(schema)) { + pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex); + for (var key in schema) { + var sch = schema[key]; + if (Array.isArray(sch)) { + if (key in traverse.arrayKeywords) { + for (var i=0; i= lower ? number : lower; + } + } + return number; +} + +module.exports = baseClamp; diff --git a/node_modules/lodash/_baseEach.js b/node_modules/lodash/_baseEach.js new file mode 100644 index 0000000000000000000000000000000000000000..512c0676827c9aaf8c689216d64859ef8c7e839a --- /dev/null +++ b/node_modules/lodash/_baseEach.js @@ -0,0 +1,14 @@ +var baseForOwn = require('./_baseForOwn'), + createBaseEach = require('./_createBaseEach'); + +/** + * The base implementation of `_.forEach` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ +var baseEach = createBaseEach(baseForOwn); + +module.exports = baseEach; diff --git a/node_modules/lodash/_baseFilter.js b/node_modules/lodash/_baseFilter.js new file mode 100644 index 0000000000000000000000000000000000000000..467847736a6fb2e8644f7cb6e087d27f54694613 --- /dev/null +++ b/node_modules/lodash/_baseFilter.js @@ -0,0 +1,21 @@ +var baseEach = require('./_baseEach'); + +/** + * The base implementation of `_.filter` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; +} + +module.exports = baseFilter; diff --git a/node_modules/lodash/_baseInverter.js b/node_modules/lodash/_baseInverter.js new file mode 100644 index 0000000000000000000000000000000000000000..fbc337f01e77d7a14f8683c9a81fdb71f40298b0 --- /dev/null +++ b/node_modules/lodash/_baseInverter.js @@ -0,0 +1,21 @@ +var baseForOwn = require('./_baseForOwn'); + +/** + * The base implementation of `_.invert` and `_.invertBy` which inverts + * `object` with values transformed by `iteratee` and set by `setter`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform values. + * @param {Object} accumulator The initial inverted object. + * @returns {Function} Returns `accumulator`. + */ +function baseInverter(object, setter, iteratee, accumulator) { + baseForOwn(object, function(value, key, object) { + setter(accumulator, iteratee(value), key, object); + }); + return accumulator; +} + +module.exports = baseInverter; diff --git a/node_modules/lodash/_baseIsArguments.js b/node_modules/lodash/_baseIsArguments.js new file mode 100644 index 0000000000000000000000000000000000000000..b3562cca2c61ebff0c077b193d0711c3b0f620ff --- /dev/null +++ b/node_modules/lodash/_baseIsArguments.js @@ -0,0 +1,18 @@ +var baseGetTag = require('./_baseGetTag'), + isObjectLike = require('./isObjectLike'); + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]'; + +/** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; +} + +module.exports = baseIsArguments; diff --git a/node_modules/lodash/_baseIsArrayBuffer.js b/node_modules/lodash/_baseIsArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..a2c4f30a82850fdf4bbe8822dd68ba8f33e2a076 --- /dev/null +++ b/node_modules/lodash/_baseIsArrayBuffer.js @@ -0,0 +1,17 @@ +var baseGetTag = require('./_baseGetTag'), + isObjectLike = require('./isObjectLike'); + +var arrayBufferTag = '[object ArrayBuffer]'; + +/** + * The base implementation of `_.isArrayBuffer` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + */ +function baseIsArrayBuffer(value) { + return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; +} + +module.exports = baseIsArrayBuffer; diff --git a/node_modules/lodash/_baseIsDate.js b/node_modules/lodash/_baseIsDate.js new file mode 100644 index 0000000000000000000000000000000000000000..ba67c7857fa75264bacb44652be30931fc188f16 --- /dev/null +++ b/node_modules/lodash/_baseIsDate.js @@ -0,0 +1,18 @@ +var baseGetTag = require('./_baseGetTag'), + isObjectLike = require('./isObjectLike'); + +/** `Object#toString` result references. */ +var dateTag = '[object Date]'; + +/** + * The base implementation of `_.isDate` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + */ +function baseIsDate(value) { + return isObjectLike(value) && baseGetTag(value) == dateTag; +} + +module.exports = baseIsDate; diff --git a/node_modules/lodash/_baseIsMatch.js b/node_modules/lodash/_baseIsMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..72494bed40833bbe29ef834d070570d3bc2eb84d --- /dev/null +++ b/node_modules/lodash/_baseIsMatch.js @@ -0,0 +1,62 @@ +var Stack = require('./_Stack'), + baseIsEqual = require('./_baseIsEqual'); + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + +/** + * The base implementation of `_.isMatch` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ +function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; + + if (object == null) { + return !length; + } + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack; + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) + : result + )) { + return false; + } + } + } + return true; +} + +module.exports = baseIsMatch; diff --git a/node_modules/lodash/_baseLodash.js b/node_modules/lodash/_baseLodash.js new file mode 100644 index 0000000000000000000000000000000000000000..f76c790e2e119626bb0a2f97cab526ade36c6fe8 --- /dev/null +++ b/node_modules/lodash/_baseLodash.js @@ -0,0 +1,10 @@ +/** + * The function whose prototype chain sequence wrappers inherit from. + * + * @private + */ +function baseLodash() { + // No operation performed. +} + +module.exports = baseLodash; diff --git a/node_modules/lodash/_baseLt.js b/node_modules/lodash/_baseLt.js new file mode 100644 index 0000000000000000000000000000000000000000..8674d2946a5054a0cc1144fa7213bcc7c85ce46e --- /dev/null +++ b/node_modules/lodash/_baseLt.js @@ -0,0 +1,14 @@ +/** + * The base implementation of `_.lt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + */ +function baseLt(value, other) { + return value < other; +} + +module.exports = baseLt; diff --git a/node_modules/lodash/_baseMap.js b/node_modules/lodash/_baseMap.js new file mode 100644 index 0000000000000000000000000000000000000000..0bf5cead5c60bf3c72d38be894b098785b83ecd9 --- /dev/null +++ b/node_modules/lodash/_baseMap.js @@ -0,0 +1,22 @@ +var baseEach = require('./_baseEach'), + isArrayLike = require('./isArrayLike'); + +/** + * The base implementation of `_.map` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; +} + +module.exports = baseMap; diff --git a/node_modules/lodash/_basePullAll.js b/node_modules/lodash/_basePullAll.js new file mode 100644 index 0000000000000000000000000000000000000000..305720edea31ab7172b6aed7cfec6700c8d3093f --- /dev/null +++ b/node_modules/lodash/_basePullAll.js @@ -0,0 +1,51 @@ +var arrayMap = require('./_arrayMap'), + baseIndexOf = require('./_baseIndexOf'), + baseIndexOfWith = require('./_baseIndexOfWith'), + baseUnary = require('./_baseUnary'), + copyArray = require('./_copyArray'); + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * The base implementation of `_.pullAllBy` without support for iteratee + * shorthands. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns `array`. + */ +function basePullAll(array, values, iteratee, comparator) { + var indexOf = comparator ? baseIndexOfWith : baseIndexOf, + index = -1, + length = values.length, + seen = array; + + if (array === values) { + values = copyArray(values); + } + if (iteratee) { + seen = arrayMap(array, baseUnary(iteratee)); + } + while (++index < length) { + var fromIndex = 0, + value = values[index], + computed = iteratee ? iteratee(value) : value; + + while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { + if (seen !== array) { + splice.call(seen, fromIndex, 1); + } + splice.call(array, fromIndex, 1); + } + } + return array; +} + +module.exports = basePullAll; diff --git a/node_modules/lodash/_baseSample.js b/node_modules/lodash/_baseSample.js new file mode 100644 index 0000000000000000000000000000000000000000..58582b9112730b224788c1a7c79e939b636bb107 --- /dev/null +++ b/node_modules/lodash/_baseSample.js @@ -0,0 +1,15 @@ +var arraySample = require('./_arraySample'), + values = require('./values'); + +/** + * The base implementation of `_.sample`. + * + * @private + * @param {Array|Object} collection The collection to sample. + * @returns {*} Returns the random element. + */ +function baseSample(collection) { + return arraySample(values(collection)); +} + +module.exports = baseSample; diff --git a/node_modules/lodash/_baseToString.js b/node_modules/lodash/_baseToString.js new file mode 100644 index 0000000000000000000000000000000000000000..ada6ad298cc15a919b7ece45015785f493f2ae4c --- /dev/null +++ b/node_modules/lodash/_baseToString.js @@ -0,0 +1,37 @@ +var Symbol = require('./_Symbol'), + arrayMap = require('./_arrayMap'), + isArray = require('./isArray'), + isSymbol = require('./isSymbol'); + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +module.exports = baseToString; diff --git a/node_modules/lodash/_baseWhile.js b/node_modules/lodash/_baseWhile.js new file mode 100644 index 0000000000000000000000000000000000000000..07eac61b9893bd238fd931d19f9f71ec469f1fd1 --- /dev/null +++ b/node_modules/lodash/_baseWhile.js @@ -0,0 +1,26 @@ +var baseSlice = require('./_baseSlice'); + +/** + * The base implementation of methods like `_.dropWhile` and `_.takeWhile` + * without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to query. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [isDrop] Specify dropping elements instead of taking them. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the slice of `array`. + */ +function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length) && + predicate(array[index], index, array)) {} + + return isDrop + ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) + : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); +} + +module.exports = baseWhile; diff --git a/node_modules/lodash/_castFunction.js b/node_modules/lodash/_castFunction.js new file mode 100644 index 0000000000000000000000000000000000000000..98c91ae6378b98e60ce76eed1b80eeccac7eff0e --- /dev/null +++ b/node_modules/lodash/_castFunction.js @@ -0,0 +1,14 @@ +var identity = require('./identity'); + +/** + * Casts `value` to `identity` if it's not a function. + * + * @private + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. + */ +function castFunction(value) { + return typeof value == 'function' ? value : identity; +} + +module.exports = castFunction; diff --git a/node_modules/lodash/_copySymbolsIn.js b/node_modules/lodash/_copySymbolsIn.js new file mode 100644 index 0000000000000000000000000000000000000000..fdf20a73c2bf7551044589adc11ac9dfa4275944 --- /dev/null +++ b/node_modules/lodash/_copySymbolsIn.js @@ -0,0 +1,16 @@ +var copyObject = require('./_copyObject'), + getSymbolsIn = require('./_getSymbolsIn'); + +/** + * Copies own and inherited symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ +function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); +} + +module.exports = copySymbolsIn; diff --git a/node_modules/lodash/_createAggregator.js b/node_modules/lodash/_createAggregator.js new file mode 100644 index 0000000000000000000000000000000000000000..0be42c41cdeaf8cdd9e0fc076828f9275053b14c --- /dev/null +++ b/node_modules/lodash/_createAggregator.js @@ -0,0 +1,23 @@ +var arrayAggregator = require('./_arrayAggregator'), + baseAggregator = require('./_baseAggregator'), + baseIteratee = require('./_baseIteratee'), + isArray = require('./isArray'); + +/** + * Creates a function like `_.groupBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} [initializer] The accumulator object initializer. + * @returns {Function} Returns the new aggregator function. + */ +function createAggregator(setter, initializer) { + return function(collection, iteratee) { + var func = isArray(collection) ? arrayAggregator : baseAggregator, + accumulator = initializer ? initializer() : {}; + + return func(collection, setter, baseIteratee(iteratee, 2), accumulator); + }; +} + +module.exports = createAggregator; diff --git a/node_modules/lodash/_createBaseEach.js b/node_modules/lodash/_createBaseEach.js new file mode 100644 index 0000000000000000000000000000000000000000..d24fdd1bbcb6d0a1243a077118b60d32dc774598 --- /dev/null +++ b/node_modules/lodash/_createBaseEach.js @@ -0,0 +1,32 @@ +var isArrayLike = require('./isArrayLike'); + +/** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + if (collection == null) { + return collection; + } + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = fromRight ? length : -1, + iterable = Object(collection); + + while ((fromRight ? index-- : ++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; +} + +module.exports = createBaseEach; diff --git a/node_modules/lodash/_createCurry.js b/node_modules/lodash/_createCurry.js new file mode 100644 index 0000000000000000000000000000000000000000..f06c2cdd85ecfaa89ed5a65ae4dffe0f13db38f4 --- /dev/null +++ b/node_modules/lodash/_createCurry.js @@ -0,0 +1,46 @@ +var apply = require('./_apply'), + createCtor = require('./_createCtor'), + createHybrid = require('./_createHybrid'), + createRecurry = require('./_createRecurry'), + getHolder = require('./_getHolder'), + replaceHolders = require('./_replaceHolders'), + root = require('./_root'); + +/** + * Creates a function that wraps `func` to enable currying. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {number} arity The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ +function createCurry(func, bitmask, arity) { + var Ctor = createCtor(func); + + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length, + placeholder = getHolder(wrapper); + + while (index--) { + args[index] = arguments[index]; + } + var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) + ? [] + : replaceHolders(args, placeholder); + + length -= holders.length; + if (length < arity) { + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, undefined, + args, holders, undefined, undefined, arity - length); + } + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return apply(fn, this, args); + } + return wrapper; +} + +module.exports = createCurry; diff --git a/node_modules/lodash/_createInverter.js b/node_modules/lodash/_createInverter.js new file mode 100644 index 0000000000000000000000000000000000000000..6c0c56299bdf89d9d71ed08afa372c82bdbe81a2 --- /dev/null +++ b/node_modules/lodash/_createInverter.js @@ -0,0 +1,17 @@ +var baseInverter = require('./_baseInverter'); + +/** + * Creates a function like `_.invertBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} toIteratee The function to resolve iteratees. + * @returns {Function} Returns the new inverter function. + */ +function createInverter(setter, toIteratee) { + return function(object, iteratee) { + return baseInverter(object, setter, toIteratee(iteratee), {}); + }; +} + +module.exports = createInverter; diff --git a/node_modules/lodash/_createRound.js b/node_modules/lodash/_createRound.js new file mode 100644 index 0000000000000000000000000000000000000000..88be5df396b61c2911732fea60d865cccf994b7a --- /dev/null +++ b/node_modules/lodash/_createRound.js @@ -0,0 +1,35 @@ +var root = require('./_root'), + toInteger = require('./toInteger'), + toNumber = require('./toNumber'), + toString = require('./toString'); + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = root.isFinite, + nativeMin = Math.min; + +/** + * Creates a function like `_.round`. + * + * @private + * @param {string} methodName The name of the `Math` method to use when rounding. + * @returns {Function} Returns the new round function. + */ +function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + number = toNumber(number); + precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); + if (precision && nativeIsFinite(number)) { + // Shift with exponential notation to avoid floating-point issues. + // See [MDN](https://mdn.io/round#Examples) for more details. + var pair = (toString(number) + 'e').split('e'), + value = func(pair[0] + 'e' + (+pair[1] + precision)); + + pair = (toString(value) + 'e').split('e'); + return +(pair[0] + 'e' + (+pair[1] - precision)); + } + return func(number); + }; +} + +module.exports = createRound; diff --git a/node_modules/lodash/_createToPairs.js b/node_modules/lodash/_createToPairs.js new file mode 100644 index 0000000000000000000000000000000000000000..568417afda98a37c7c1e39655c2102558a417701 --- /dev/null +++ b/node_modules/lodash/_createToPairs.js @@ -0,0 +1,30 @@ +var baseToPairs = require('./_baseToPairs'), + getTag = require('./_getTag'), + mapToArray = require('./_mapToArray'), + setToPairs = require('./_setToPairs'); + +/** `Object#toString` result references. */ +var mapTag = '[object Map]', + setTag = '[object Set]'; + +/** + * Creates a `_.toPairs` or `_.toPairsIn` function. + * + * @private + * @param {Function} keysFunc The function to get the keys of a given object. + * @returns {Function} Returns the new pairs function. + */ +function createToPairs(keysFunc) { + return function(object) { + var tag = getTag(object); + if (tag == mapTag) { + return mapToArray(object); + } + if (tag == setTag) { + return setToPairs(object); + } + return baseToPairs(object, keysFunc(object)); + }; +} + +module.exports = createToPairs; diff --git a/node_modules/lodash/_equalByTag.js b/node_modules/lodash/_equalByTag.js new file mode 100644 index 0000000000000000000000000000000000000000..71919e8673bd9d314ff8025720beb886d2d4bc3c --- /dev/null +++ b/node_modules/lodash/_equalByTag.js @@ -0,0 +1,112 @@ +var Symbol = require('./_Symbol'), + Uint8Array = require('./_Uint8Array'), + eq = require('./eq'), + equalArrays = require('./_equalArrays'), + mapToArray = require('./_mapToArray'), + setToArray = require('./_setToArray'); + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + +/** `Object#toString` result references. */ +var boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + mapTag = '[object Map]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]'; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; + +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; +} + +module.exports = equalByTag; diff --git a/node_modules/lodash/_getData.js b/node_modules/lodash/_getData.js new file mode 100644 index 0000000000000000000000000000000000000000..a1fe7b7790ded66e46affdc4f35ede118c95759e --- /dev/null +++ b/node_modules/lodash/_getData.js @@ -0,0 +1,15 @@ +var metaMap = require('./_metaMap'), + noop = require('./noop'); + +/** + * Gets metadata for `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. + */ +var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); +}; + +module.exports = getData; diff --git a/node_modules/lodash/_getRawTag.js b/node_modules/lodash/_getRawTag.js new file mode 100644 index 0000000000000000000000000000000000000000..49a95c9c65a17148911124bf9e51ac8982769a45 --- /dev/null +++ b/node_modules/lodash/_getRawTag.js @@ -0,0 +1,46 @@ +var Symbol = require('./_Symbol'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; +} + +module.exports = getRawTag; diff --git a/node_modules/lodash/_hashClear.js b/node_modules/lodash/_hashClear.js new file mode 100644 index 0000000000000000000000000000000000000000..5d4b70cc46c64de744979bf4a21d71d5d4efe20d --- /dev/null +++ b/node_modules/lodash/_hashClear.js @@ -0,0 +1,15 @@ +var nativeCreate = require('./_nativeCreate'); + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; +} + +module.exports = hashClear; diff --git a/node_modules/lodash/_initCloneArray.js b/node_modules/lodash/_initCloneArray.js new file mode 100644 index 0000000000000000000000000000000000000000..078c15af98fffee3677993915b6ed12ca08c6f48 --- /dev/null +++ b/node_modules/lodash/_initCloneArray.js @@ -0,0 +1,26 @@ +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ +function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; +} + +module.exports = initCloneArray; diff --git a/node_modules/lodash/_isIndex.js b/node_modules/lodash/_isIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..061cd390c3e5559265af262783297c33705d1041 --- /dev/null +++ b/node_modules/lodash/_isIndex.js @@ -0,0 +1,25 @@ +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +module.exports = isIndex; diff --git a/node_modules/lodash/_isIterateeCall.js b/node_modules/lodash/_isIterateeCall.js new file mode 100644 index 0000000000000000000000000000000000000000..a0bb5a9cf60533df874447bf6592af04a4c7d88b --- /dev/null +++ b/node_modules/lodash/_isIterateeCall.js @@ -0,0 +1,30 @@ +var eq = require('./eq'), + isArrayLike = require('./isArrayLike'), + isIndex = require('./_isIndex'), + isObject = require('./isObject'); + +/** + * Checks if the given arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. + */ +function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq(object[index], value); + } + return false; +} + +module.exports = isIterateeCall; diff --git a/node_modules/lodash/_isMasked.js b/node_modules/lodash/_isMasked.js new file mode 100644 index 0000000000000000000000000000000000000000..4b0f21ba89813422e028c618ca9ea5881fb1f3d5 --- /dev/null +++ b/node_modules/lodash/_isMasked.js @@ -0,0 +1,20 @@ +var coreJsData = require('./_coreJsData'); + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +module.exports = isMasked; diff --git a/node_modules/lodash/_iteratorToArray.js b/node_modules/lodash/_iteratorToArray.js new file mode 100644 index 0000000000000000000000000000000000000000..476856647c66d06d0175c0c52af15a654b0c2cdf --- /dev/null +++ b/node_modules/lodash/_iteratorToArray.js @@ -0,0 +1,18 @@ +/** + * Converts `iterator` to an array. + * + * @private + * @param {Object} iterator The iterator to convert. + * @returns {Array} Returns the converted array. + */ +function iteratorToArray(iterator) { + var data, + result = []; + + while (!(data = iterator.next()).done) { + result.push(data.value); + } + return result; +} + +module.exports = iteratorToArray; diff --git a/node_modules/lodash/_lazyValue.js b/node_modules/lodash/_lazyValue.js new file mode 100644 index 0000000000000000000000000000000000000000..371ca8d22321e94d82ef7b0aab59bbf0dd1a2db4 --- /dev/null +++ b/node_modules/lodash/_lazyValue.js @@ -0,0 +1,69 @@ +var baseWrapperValue = require('./_baseWrapperValue'), + getView = require('./_getView'), + isArray = require('./isArray'); + +/** Used to indicate the type of lazy iteratees. */ +var LAZY_FILTER_FLAG = 1, + LAZY_MAP_FLAG = 2; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; + +/** + * Extracts the unwrapped value from its lazy wrapper. + * + * @private + * @name value + * @memberOf LazyWrapper + * @returns {*} Returns the unwrapped value. + */ +function lazyValue() { + var array = this.__wrapped__.value(), + dir = this.__dir__, + isArr = isArray(array), + isRight = dir < 0, + arrLength = isArr ? array.length : 0, + view = getView(0, arrLength, this.__views__), + start = view.start, + end = view.end, + length = end - start, + index = isRight ? end : (start - 1), + iteratees = this.__iteratees__, + iterLength = iteratees.length, + resIndex = 0, + takeCount = nativeMin(length, this.__takeCount__); + + if (!isArr || (!isRight && arrLength == length && takeCount == length)) { + return baseWrapperValue(array, this.__actions__); + } + var result = []; + + outer: + while (length-- && resIndex < takeCount) { + index += dir; + + var iterIndex = -1, + value = array[index]; + + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], + iteratee = data.iteratee, + type = data.type, + computed = iteratee(value); + + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } + } + result[resIndex++] = value; + } + return result; +} + +module.exports = lazyValue; diff --git a/node_modules/lodash/_matchesStrictComparable.js b/node_modules/lodash/_matchesStrictComparable.js new file mode 100644 index 0000000000000000000000000000000000000000..f608af9ec499ea7fc936924037f36927ee3d7553 --- /dev/null +++ b/node_modules/lodash/_matchesStrictComparable.js @@ -0,0 +1,20 @@ +/** + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. + * + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ +function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; +} + +module.exports = matchesStrictComparable; diff --git a/node_modules/lodash/_realNames.js b/node_modules/lodash/_realNames.js new file mode 100644 index 0000000000000000000000000000000000000000..aa0d5292612835249a036b6134f1a0884b898983 --- /dev/null +++ b/node_modules/lodash/_realNames.js @@ -0,0 +1,4 @@ +/** Used to lookup unminified function names. */ +var realNames = {}; + +module.exports = realNames; diff --git a/node_modules/lodash/_safeGet.js b/node_modules/lodash/_safeGet.js new file mode 100644 index 0000000000000000000000000000000000000000..b070897db29cacda78f26f03a97d02ccf5b2364f --- /dev/null +++ b/node_modules/lodash/_safeGet.js @@ -0,0 +1,21 @@ +/** + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } + + if (key == '__proto__') { + return; + } + + return object[key]; +} + +module.exports = safeGet; diff --git a/node_modules/lodash/_setData.js b/node_modules/lodash/_setData.js new file mode 100644 index 0000000000000000000000000000000000000000..e5cf3eb96ac8e67b4f7d8abb1014498434db2b62 --- /dev/null +++ b/node_modules/lodash/_setData.js @@ -0,0 +1,20 @@ +var baseSetData = require('./_baseSetData'), + shortOut = require('./_shortOut'); + +/** + * Sets metadata for `func`. + * + * **Note:** If this function becomes hot, i.e. is invoked a lot in a short + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses in V8. See + * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) + * for more details. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ +var setData = shortOut(baseSetData); + +module.exports = setData; diff --git a/node_modules/lodash/_stackClear.js b/node_modules/lodash/_stackClear.js new file mode 100644 index 0000000000000000000000000000000000000000..ce8e5a92ffff8dc695376f0fcfd48c25aafc2327 --- /dev/null +++ b/node_modules/lodash/_stackClear.js @@ -0,0 +1,15 @@ +var ListCache = require('./_ListCache'); + +/** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ +function stackClear() { + this.__data__ = new ListCache; + this.size = 0; +} + +module.exports = stackClear; diff --git a/node_modules/lodash/_strictLastIndexOf.js b/node_modules/lodash/_strictLastIndexOf.js new file mode 100644 index 0000000000000000000000000000000000000000..d7310dcc23629ce1550043095f6b4c54d4ab640b --- /dev/null +++ b/node_modules/lodash/_strictLastIndexOf.js @@ -0,0 +1,21 @@ +/** + * A specialized version of `_.lastIndexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function strictLastIndexOf(array, value, fromIndex) { + var index = fromIndex + 1; + while (index--) { + if (array[index] === value) { + return index; + } + } + return index; +} + +module.exports = strictLastIndexOf; diff --git a/node_modules/lodash/_stringSize.js b/node_modules/lodash/_stringSize.js new file mode 100644 index 0000000000000000000000000000000000000000..17ef462a682734bea3d352bd10780365ec0d1e17 --- /dev/null +++ b/node_modules/lodash/_stringSize.js @@ -0,0 +1,18 @@ +var asciiSize = require('./_asciiSize'), + hasUnicode = require('./_hasUnicode'), + unicodeSize = require('./_unicodeSize'); + +/** + * Gets the number of symbols in `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the string size. + */ +function stringSize(string) { + return hasUnicode(string) + ? unicodeSize(string) + : asciiSize(string); +} + +module.exports = stringSize; diff --git a/node_modules/lodash/_unicodeToArray.js b/node_modules/lodash/_unicodeToArray.js new file mode 100644 index 0000000000000000000000000000000000000000..2a725c062ec7689a22bc095fe7bfe5cb56aa872c --- /dev/null +++ b/node_modules/lodash/_unicodeToArray.js @@ -0,0 +1,40 @@ +/** Used to compose unicode character classes. */ +var rsAstralRange = '\\ud800-\\udfff', + rsComboMarksRange = '\\u0300-\\u036f', + reComboHalfMarksRange = '\\ufe20-\\ufe2f', + rsComboSymbolsRange = '\\u20d0-\\u20ff', + rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, + rsVarRange = '\\ufe0e\\ufe0f'; + +/** Used to compose unicode capture groups. */ +var rsAstral = '[' + rsAstralRange + ']', + rsCombo = '[' + rsComboRange + ']', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', + rsNonAstral = '[^' + rsAstralRange + ']', + rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', + rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', + rsZWJ = '\\u200d'; + +/** Used to compose unicode regexes. */ +var reOptMod = rsModifier + '?', + rsOptVar = '[' + rsVarRange + ']?', + rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', + rsSeq = rsOptVar + reOptMod + rsOptJoin, + rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + +/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ +var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + +/** + * Converts a Unicode `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function unicodeToArray(string) { + return string.match(reUnicode) || []; +} + +module.exports = unicodeToArray; diff --git a/node_modules/lodash/assignInWith.js b/node_modules/lodash/assignInWith.js new file mode 100644 index 0000000000000000000000000000000000000000..68fcc0b03a013f955bb94c11b60509f26c6775f1 --- /dev/null +++ b/node_modules/lodash/assignInWith.js @@ -0,0 +1,38 @@ +var copyObject = require('./_copyObject'), + createAssigner = require('./_createAssigner'), + keysIn = require('./keysIn'); + +/** + * This method is like `_.assignIn` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias extendWith + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignWith + * @example + * + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } + * + * var defaults = _.partialRight(_.assignInWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ +var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { + copyObject(source, keysIn(source), object, customizer); +}); + +module.exports = assignInWith; diff --git a/node_modules/lodash/at.js b/node_modules/lodash/at.js new file mode 100644 index 0000000000000000000000000000000000000000..781ee9e5f18d44e4f2c5350b2ff87c6579273618 --- /dev/null +++ b/node_modules/lodash/at.js @@ -0,0 +1,23 @@ +var baseAt = require('./_baseAt'), + flatRest = require('./_flatRest'); + +/** + * Creates an array of values corresponding to `paths` of `object`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Array} Returns the picked values. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * + * _.at(object, ['a[0].b.c', 'a[1]']); + * // => [3, 4] + */ +var at = flatRest(baseAt); + +module.exports = at; diff --git a/node_modules/lodash/ceil.js b/node_modules/lodash/ceil.js new file mode 100644 index 0000000000000000000000000000000000000000..56c8722cfc7cec98015667559fa8083c81a74d72 --- /dev/null +++ b/node_modules/lodash/ceil.js @@ -0,0 +1,26 @@ +var createRound = require('./_createRound'); + +/** + * Computes `number` rounded up to `precision`. + * + * @static + * @memberOf _ + * @since 3.10.0 + * @category Math + * @param {number} number The number to round up. + * @param {number} [precision=0] The precision to round up to. + * @returns {number} Returns the rounded up number. + * @example + * + * _.ceil(4.006); + * // => 5 + * + * _.ceil(6.004, 2); + * // => 6.01 + * + * _.ceil(6040, -2); + * // => 6100 + */ +var ceil = createRound('ceil'); + +module.exports = ceil; diff --git a/node_modules/lodash/chain.js b/node_modules/lodash/chain.js new file mode 100644 index 0000000000000000000000000000000000000000..f6cd6475ffdf173248012dec143605d0b60e4164 --- /dev/null +++ b/node_modules/lodash/chain.js @@ -0,0 +1,38 @@ +var lodash = require('./wrapperLodash'); + +/** + * Creates a `lodash` wrapper instance that wraps `value` with explicit method + * chain sequences enabled. The result of such sequences must be unwrapped + * with `_#value`. + * + * @static + * @memberOf _ + * @since 1.3.0 + * @category Seq + * @param {*} value The value to wrap. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'pebbles', 'age': 1 } + * ]; + * + * var youngest = _ + * .chain(users) + * .sortBy('age') + * .map(function(o) { + * return o.user + ' is ' + o.age; + * }) + * .head() + * .value(); + * // => 'pebbles is 1' + */ +function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; +} + +module.exports = chain; diff --git a/node_modules/lodash/chunk.js b/node_modules/lodash/chunk.js new file mode 100644 index 0000000000000000000000000000000000000000..5b562fef3ce0017df61c8654c66c4a3e83fe322f --- /dev/null +++ b/node_modules/lodash/chunk.js @@ -0,0 +1,50 @@ +var baseSlice = require('./_baseSlice'), + isIterateeCall = require('./_isIterateeCall'), + toInteger = require('./toInteger'); + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeCeil = Math.ceil, + nativeMax = Math.max; + +/** + * Creates an array of elements split into groups the length of `size`. + * If `array` can't be split evenly, the final chunk will be the remaining + * elements. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to process. + * @param {number} [size=1] The length of each chunk + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the new array of chunks. + * @example + * + * _.chunk(['a', 'b', 'c', 'd'], 2); + * // => [['a', 'b'], ['c', 'd']] + * + * _.chunk(['a', 'b', 'c', 'd'], 3); + * // => [['a', 'b', 'c'], ['d']] + */ +function chunk(array, size, guard) { + if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { + size = 1; + } else { + size = nativeMax(toInteger(size), 0); + } + var length = array == null ? 0 : array.length; + if (!length || size < 1) { + return []; + } + var index = 0, + resIndex = 0, + result = Array(nativeCeil(length / size)); + + while (index < length) { + result[resIndex++] = baseSlice(array, index, (index += size)); + } + return result; +} + +module.exports = chunk; diff --git a/node_modules/lodash/every.js b/node_modules/lodash/every.js new file mode 100644 index 0000000000000000000000000000000000000000..25080dac4985229bb1f0220809a746711d6ee05f --- /dev/null +++ b/node_modules/lodash/every.js @@ -0,0 +1,56 @@ +var arrayEvery = require('./_arrayEvery'), + baseEvery = require('./_baseEvery'), + baseIteratee = require('./_baseIteratee'), + isArray = require('./isArray'), + isIterateeCall = require('./_isIterateeCall'); + +/** + * Checks if `predicate` returns truthy for **all** elements of `collection`. + * Iteration is stopped once `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index|key, collection). + * + * **Note:** This method returns `true` for + * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because + * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of + * elements of empty collections. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + * @example + * + * _.every([true, 1, null, 'yes'], Boolean); + * // => false + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * // The `_.matches` iteratee shorthand. + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // The `_.matchesProperty` iteratee shorthand. + * _.every(users, ['active', false]); + * // => true + * + * // The `_.property` iteratee shorthand. + * _.every(users, 'active'); + * // => false + */ +function every(collection, predicate, guard) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (guard && isIterateeCall(collection, predicate, guard)) { + predicate = undefined; + } + return func(collection, baseIteratee(predicate, 3)); +} + +module.exports = every; diff --git a/node_modules/lodash/extend.js b/node_modules/lodash/extend.js new file mode 100644 index 0000000000000000000000000000000000000000..e00166c206c610aac78f792ec4afc7cc362b94f5 --- /dev/null +++ b/node_modules/lodash/extend.js @@ -0,0 +1 @@ +module.exports = require('./assignIn'); diff --git a/node_modules/lodash/findIndex.js b/node_modules/lodash/findIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..4689069f81e9b5d16a2d408d54c2d67ce932ab29 --- /dev/null +++ b/node_modules/lodash/findIndex.js @@ -0,0 +1,55 @@ +var baseFindIndex = require('./_baseFindIndex'), + baseIteratee = require('./_baseIteratee'), + toInteger = require('./toInteger'); + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, function(o) { return o.user == 'barney'; }); + * // => 0 + * + * // The `_.matches` iteratee shorthand. + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findIndex(users, ['active', false]); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.findIndex(users, 'active'); + * // => 2 + */ +function findIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax(length + index, 0); + } + return baseFindIndex(array, baseIteratee(predicate, 3), index); +} + +module.exports = findIndex; diff --git a/node_modules/lodash/findLast.js b/node_modules/lodash/findLast.js new file mode 100644 index 0000000000000000000000000000000000000000..70b4271dc365ff2ea2c7190252be369e8f886fb4 --- /dev/null +++ b/node_modules/lodash/findLast.js @@ -0,0 +1,25 @@ +var createFind = require('./_createFind'), + findLastIndex = require('./findLastIndex'); + +/** + * This method is like `_.find` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=collection.length-1] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); + * // => 3 + */ +var findLast = createFind(findLastIndex); + +module.exports = findLast; diff --git a/node_modules/lodash/flake.lock b/node_modules/lodash/flake.lock new file mode 100644 index 0000000000000000000000000000000000000000..dd0325218db2913361b56efa1e9da7f14800fd14 --- /dev/null +++ b/node_modules/lodash/flake.lock @@ -0,0 +1,40 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1613582597, + "narHash": "sha256-6LvipIvFuhyorHpUqK3HjySC5Y6gshXHFBhU9EJ4DoM=", + "path": "/nix/store/srvplqq673sqd9vyfhyc5w1p88y1gfm4-source", + "rev": "6b1057b452c55bb3b463f0d7055bc4ec3fd1f381", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1610051610, + "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/node_modules/lodash/flatMapDeep.js b/node_modules/lodash/flatMapDeep.js new file mode 100644 index 0000000000000000000000000000000000000000..4653d603330bafe8bd3858da638495635c8f3e92 --- /dev/null +++ b/node_modules/lodash/flatMapDeep.js @@ -0,0 +1,31 @@ +var baseFlatten = require('./_baseFlatten'), + map = require('./map'); + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDeep([1, 2], duplicate); + * // => [1, 1, 2, 2] + */ +function flatMapDeep(collection, iteratee) { + return baseFlatten(map(collection, iteratee), INFINITY); +} + +module.exports = flatMapDeep; diff --git a/node_modules/lodash/fp.js b/node_modules/lodash/fp.js new file mode 100644 index 0000000000000000000000000000000000000000..e372dbbdf6d5393fdf59fd453a5bbab63c058e6d --- /dev/null +++ b/node_modules/lodash/fp.js @@ -0,0 +1,2 @@ +var _ = require('./lodash.min').runInContext(); +module.exports = require('./fp/_baseConvert')(_, _); diff --git a/node_modules/lodash/functionsIn.js b/node_modules/lodash/functionsIn.js new file mode 100644 index 0000000000000000000000000000000000000000..f00345d0668163e5f7a3cd47701f02949e718d24 --- /dev/null +++ b/node_modules/lodash/functionsIn.js @@ -0,0 +1,31 @@ +var baseFunctions = require('./_baseFunctions'), + keysIn = require('./keysIn'); + +/** + * Creates an array of function property names from own and inherited + * enumerable properties of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functions + * @example + * + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functionsIn(new Foo); + * // => ['a', 'b', 'c'] + */ +function functionsIn(object) { + return object == null ? [] : baseFunctions(object, keysIn(object)); +} + +module.exports = functionsIn; diff --git a/node_modules/lodash/gt.js b/node_modules/lodash/gt.js new file mode 100644 index 0000000000000000000000000000000000000000..3a662828801bd87cd8943f46ee495e6c4c8e7b27 --- /dev/null +++ b/node_modules/lodash/gt.js @@ -0,0 +1,29 @@ +var baseGt = require('./_baseGt'), + createRelationalOperation = require('./_createRelationalOperation'); + +/** + * Checks if `value` is greater than `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + * @see _.lt + * @example + * + * _.gt(3, 1); + * // => true + * + * _.gt(3, 3); + * // => false + * + * _.gt(1, 3); + * // => false + */ +var gt = createRelationalOperation(baseGt); + +module.exports = gt; diff --git a/node_modules/lodash/isArrayBuffer.js b/node_modules/lodash/isArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..12904a64b4cbf3bc84a89098aaf63e5150e35706 --- /dev/null +++ b/node_modules/lodash/isArrayBuffer.js @@ -0,0 +1,27 @@ +var baseIsArrayBuffer = require('./_baseIsArrayBuffer'), + baseUnary = require('./_baseUnary'), + nodeUtil = require('./_nodeUtil'); + +/* Node.js helper references. */ +var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer; + +/** + * Checks if `value` is classified as an `ArrayBuffer` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + * @example + * + * _.isArrayBuffer(new ArrayBuffer(2)); + * // => true + * + * _.isArrayBuffer(new Array(2)); + * // => false + */ +var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; + +module.exports = isArrayBuffer; diff --git a/node_modules/lodash/isEqual.js b/node_modules/lodash/isEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..5e23e76c942aa04df6446a0d246bfd9435769235 --- /dev/null +++ b/node_modules/lodash/isEqual.js @@ -0,0 +1,35 @@ +var baseIsEqual = require('./_baseIsEqual'); + +/** + * Performs a deep comparison between two values to determine if they are + * equivalent. + * + * **Note:** This method supports comparing arrays, array buffers, booleans, + * date objects, error objects, maps, numbers, `Object` objects, regexes, + * sets, strings, symbols, and typed arrays. `Object` objects are compared + * by their own, not inherited, enumerable properties. Functions and DOM + * nodes are compared by strict equality, i.e. `===`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.isEqual(object, other); + * // => true + * + * object === other; + * // => false + */ +function isEqual(value, other) { + return baseIsEqual(value, other); +} + +module.exports = isEqual; diff --git a/node_modules/lodash/isEqualWith.js b/node_modules/lodash/isEqualWith.js new file mode 100644 index 0000000000000000000000000000000000000000..21bdc7ffe361fb44d091649479484207c43ffdc3 --- /dev/null +++ b/node_modules/lodash/isEqualWith.js @@ -0,0 +1,41 @@ +var baseIsEqual = require('./_baseIsEqual'); + +/** + * This method is like `_.isEqual` except that it accepts `customizer` which + * is invoked to compare values. If `customizer` returns `undefined`, comparisons + * are handled by the method instead. The `customizer` is invoked with up to + * six arguments: (objValue, othValue [, index|key, object, other, stack]). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, othValue) { + * if (isGreeting(objValue) && isGreeting(othValue)) { + * return true; + * } + * } + * + * var array = ['hello', 'goodbye']; + * var other = ['hi', 'goodbye']; + * + * _.isEqualWith(array, other, customizer); + * // => true + */ +function isEqualWith(value, other, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + var result = customizer ? customizer(value, other) : undefined; + return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; +} + +module.exports = isEqualWith; diff --git a/node_modules/lodash/isError.js b/node_modules/lodash/isError.js new file mode 100644 index 0000000000000000000000000000000000000000..b4f41e000dbef4b4b18a14d42ba2b1ff914419c1 --- /dev/null +++ b/node_modules/lodash/isError.js @@ -0,0 +1,36 @@ +var baseGetTag = require('./_baseGetTag'), + isObjectLike = require('./isObjectLike'), + isPlainObject = require('./isPlainObject'); + +/** `Object#toString` result references. */ +var domExcTag = '[object DOMException]', + errorTag = '[object Error]'; + +/** + * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, + * `SyntaxError`, `TypeError`, or `URIError` object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an error object, else `false`. + * @example + * + * _.isError(new Error); + * // => true + * + * _.isError(Error); + * // => false + */ +function isError(value) { + if (!isObjectLike(value)) { + return false; + } + var tag = baseGetTag(value); + return tag == errorTag || tag == domExcTag || + (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); +} + +module.exports = isError; diff --git a/node_modules/lodash/isInteger.js b/node_modules/lodash/isInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..66aa87d573d71750b7cdd5b004df389b052cbf50 --- /dev/null +++ b/node_modules/lodash/isInteger.js @@ -0,0 +1,33 @@ +var toInteger = require('./toInteger'); + +/** + * Checks if `value` is an integer. + * + * **Note:** This method is based on + * [`Number.isInteger`](https://mdn.io/Number/isInteger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an integer, else `false`. + * @example + * + * _.isInteger(3); + * // => true + * + * _.isInteger(Number.MIN_VALUE); + * // => false + * + * _.isInteger(Infinity); + * // => false + * + * _.isInteger('3'); + * // => false + */ +function isInteger(value) { + return typeof value == 'number' && value == toInteger(value); +} + +module.exports = isInteger; diff --git a/node_modules/lodash/isObjectLike.js b/node_modules/lodash/isObjectLike.js new file mode 100644 index 0000000000000000000000000000000000000000..301716b5a5540c4654eee8cad7ba836361d189a9 --- /dev/null +++ b/node_modules/lodash/isObjectLike.js @@ -0,0 +1,29 @@ +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +module.exports = isObjectLike; diff --git a/node_modules/lodash/isRegExp.js b/node_modules/lodash/isRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..76c9b6e9c3d442108dc4d3e2a6681c5a2080ecd3 --- /dev/null +++ b/node_modules/lodash/isRegExp.js @@ -0,0 +1,27 @@ +var baseIsRegExp = require('./_baseIsRegExp'), + baseUnary = require('./_baseUnary'), + nodeUtil = require('./_nodeUtil'); + +/* Node.js helper references. */ +var nodeIsRegExp = nodeUtil && nodeUtil.isRegExp; + +/** + * Checks if `value` is classified as a `RegExp` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + * @example + * + * _.isRegExp(/abc/); + * // => true + * + * _.isRegExp('/abc/'); + * // => false + */ +var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; + +module.exports = isRegExp; diff --git a/node_modules/lodash/isSet.js b/node_modules/lodash/isSet.js new file mode 100644 index 0000000000000000000000000000000000000000..ab88bdf81ad4ecfe5c55bf97165f88803c37d247 --- /dev/null +++ b/node_modules/lodash/isSet.js @@ -0,0 +1,27 @@ +var baseIsSet = require('./_baseIsSet'), + baseUnary = require('./_baseUnary'), + nodeUtil = require('./_nodeUtil'); + +/* Node.js helper references. */ +var nodeIsSet = nodeUtil && nodeUtil.isSet; + +/** + * Checks if `value` is classified as a `Set` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + * @example + * + * _.isSet(new Set); + * // => true + * + * _.isSet(new WeakSet); + * // => false + */ +var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; + +module.exports = isSet; diff --git a/node_modules/lodash/join.js b/node_modules/lodash/join.js new file mode 100644 index 0000000000000000000000000000000000000000..45de079ff27549ed81ef1a7b9fdd7fda35b4b68f --- /dev/null +++ b/node_modules/lodash/join.js @@ -0,0 +1,26 @@ +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeJoin = arrayProto.join; + +/** + * Converts all elements in `array` into a string separated by `separator`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to convert. + * @param {string} [separator=','] The element separator. + * @returns {string} Returns the joined string. + * @example + * + * _.join(['a', 'b', 'c'], '~'); + * // => 'a~b~c' + */ +function join(array, separator) { + return array == null ? '' : nativeJoin.call(array, separator); +} + +module.exports = join; diff --git a/node_modules/lodash/kebabCase.js b/node_modules/lodash/kebabCase.js new file mode 100644 index 0000000000000000000000000000000000000000..8a52be645556380fe01045cdb84782619bc640c8 --- /dev/null +++ b/node_modules/lodash/kebabCase.js @@ -0,0 +1,28 @@ +var createCompounder = require('./_createCompounder'); + +/** + * Converts `string` to + * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the kebab cased string. + * @example + * + * _.kebabCase('Foo Bar'); + * // => 'foo-bar' + * + * _.kebabCase('fooBar'); + * // => 'foo-bar' + * + * _.kebabCase('__FOO_BAR__'); + * // => 'foo-bar' + */ +var kebabCase = createCompounder(function(result, word, index) { + return result + (index ? '-' : '') + word.toLowerCase(); +}); + +module.exports = kebabCase; diff --git a/node_modules/lodash/mapKeys.js b/node_modules/lodash/mapKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..3b68797db0bb747459f51941e393e03533e94fa1 --- /dev/null +++ b/node_modules/lodash/mapKeys.js @@ -0,0 +1,36 @@ +var baseAssignValue = require('./_baseAssignValue'), + baseForOwn = require('./_baseForOwn'), + baseIteratee = require('./_baseIteratee'); + +/** + * The opposite of `_.mapValues`; this method creates an object with the + * same values as `object` and keys generated by running each own enumerable + * string keyed property of `object` thru `iteratee`. The iteratee is invoked + * with three arguments: (value, key, object). + * + * @static + * @memberOf _ + * @since 3.8.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapValues + * @example + * + * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { + * return key + value; + * }); + * // => { 'a1': 1, 'b2': 2 } + */ +function mapKeys(object, iteratee) { + var result = {}; + iteratee = baseIteratee(iteratee, 3); + + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, iteratee(value, key, object), value); + }); + return result; +} + +module.exports = mapKeys; diff --git a/node_modules/lodash/maxBy.js b/node_modules/lodash/maxBy.js new file mode 100644 index 0000000000000000000000000000000000000000..2eba9c06ff34103a5dde960e340e682a633c0799 --- /dev/null +++ b/node_modules/lodash/maxBy.js @@ -0,0 +1,34 @@ +var baseExtremum = require('./_baseExtremum'), + baseGt = require('./_baseGt'), + baseIteratee = require('./_baseIteratee'); + +/** + * This method is like `_.max` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * the value is ranked. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {*} Returns the maximum value. + * @example + * + * var objects = [{ 'n': 1 }, { 'n': 2 }]; + * + * _.maxBy(objects, function(o) { return o.n; }); + * // => { 'n': 2 } + * + * // The `_.property` iteratee shorthand. + * _.maxBy(objects, 'n'); + * // => { 'n': 2 } + */ +function maxBy(array, iteratee) { + return (array && array.length) + ? baseExtremum(array, baseIteratee(iteratee, 2), baseGt) + : undefined; +} + +module.exports = maxBy; diff --git a/node_modules/lodash/multiply.js b/node_modules/lodash/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..d7876e1391a41428f979da797bdf3c74d7c65732 --- /dev/null +++ b/node_modules/lodash/multiply.js @@ -0,0 +1,22 @@ +var createMathOperation = require('./_createMathOperation'); + +/** + * Multiply two numbers. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Math + * @param {number} multiplier The first number in a multiplication. + * @param {number} multiplicand The second number in a multiplication. + * @returns {number} Returns the product. + * @example + * + * _.multiply(6, 4); + * // => 24 + */ +var multiply = createMathOperation(function(multiplier, multiplicand) { + return multiplier * multiplicand; +}, 1); + +module.exports = multiply; diff --git a/node_modules/lodash/negate.js b/node_modules/lodash/negate.js new file mode 100644 index 0000000000000000000000000000000000000000..5a65cd1fb2f3ca2eda29b2e03ca07329872716e0 --- /dev/null +++ b/node_modules/lodash/negate.js @@ -0,0 +1,40 @@ +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that negates the result of the predicate `func`. The + * `func` predicate is invoked with the `this` binding and arguments of the + * created function. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} predicate The predicate to negate. + * @returns {Function} Returns the new negated function. + * @example + * + * function isEven(n) { + * return n % 2 == 0; + * } + * + * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); + * // => [1, 3, 5] + */ +function negate(predicate) { + if (typeof predicate != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function() { + var args = arguments; + switch (args.length) { + case 0: return !predicate.call(this); + case 1: return !predicate.call(this, args[0]); + case 2: return !predicate.call(this, args[0], args[1]); + case 3: return !predicate.call(this, args[0], args[1], args[2]); + } + return !predicate.apply(this, args); + }; +} + +module.exports = negate; diff --git a/node_modules/lodash/number.js b/node_modules/lodash/number.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b01008a67aa2a93a224e810e9e97cb3210e439 --- /dev/null +++ b/node_modules/lodash/number.js @@ -0,0 +1,5 @@ +module.exports = { + 'clamp': require('./clamp'), + 'inRange': require('./inRange'), + 'random': require('./random') +}; diff --git a/node_modules/lodash/padEnd.js b/node_modules/lodash/padEnd.js new file mode 100644 index 0000000000000000000000000000000000000000..224eb80e99e1681af20db6d8f64c48a3f510182f --- /dev/null +++ b/node_modules/lodash/padEnd.js @@ -0,0 +1,39 @@ +var createPadding = require('./_createPadding'), + stringSize = require('./_stringSize'), + toInteger = require('./toInteger'), + toString = require('./toString'); + +/** + * Pads `string` on the right side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padEnd('abc', 6); + * // => 'abc ' + * + * _.padEnd('abc', 6, '_-'); + * // => 'abc_-_' + * + * _.padEnd('abc', 3); + * // => 'abc' + */ +function padEnd(string, length, chars) { + string = toString(string); + length = toInteger(length); + + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (string + createPadding(length - strLength, chars)) + : string; +} + +module.exports = padEnd; diff --git a/node_modules/lodash/pickBy.js b/node_modules/lodash/pickBy.js new file mode 100644 index 0000000000000000000000000000000000000000..ae7c271eacb3dafbd512d8317500acc8da519b11 --- /dev/null +++ b/node_modules/lodash/pickBy.js @@ -0,0 +1,37 @@ +var arrayMap = require('./_arrayMap'), + baseIteratee = require('./_baseIteratee'), + basePickBy = require('./_basePickBy'), + getAllKeysIn = require('./_getAllKeysIn'); + +/** + * Creates an object composed of the `object` properties `predicate` returns + * truthy for. The predicate is invoked with two arguments: (value, key). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The source object. + * @param {Function} [predicate=_.identity] The function invoked per property. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pickBy(object, _.isNumber); + * // => { 'a': 1, 'c': 3 } + */ +function pickBy(object, predicate) { + if (object == null) { + return {}; + } + var props = arrayMap(getAllKeysIn(object), function(prop) { + return [prop]; + }); + predicate = baseIteratee(predicate); + return basePickBy(object, props, function(value, path) { + return predicate(value, path[0]); + }); +} + +module.exports = pickBy; diff --git a/node_modules/lodash/plant.js b/node_modules/lodash/plant.js new file mode 100644 index 0000000000000000000000000000000000000000..23776f3238bd3798f0faa9c711477895d60c88c5 --- /dev/null +++ b/node_modules/lodash/plant.js @@ -0,0 +1,48 @@ +var baseLodash = require('./_baseLodash'), + wrapperClone = require('./_wrapperClone'); + +/** + * Creates a clone of the chain sequence planting `value` as the wrapped value. + * + * @name plant + * @memberOf _ + * @since 3.2.0 + * @category Seq + * @param {*} value The value to plant. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var wrapped = _([1, 2]).map(square); + * var other = wrapped.plant([3, 4]); + * + * other.value(); + * // => [9, 16] + * + * wrapped.value(); + * // => [1, 4] + */ +function wrapperPlant(value) { + var result, + parent = this; + + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + clone.__index__ = 0; + clone.__values__ = undefined; + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; + } + var previous = clone; + parent = parent.__wrapped__; + } + previous.__wrapped__ = value; + return result; +} + +module.exports = wrapperPlant; diff --git a/node_modules/lodash/pullAt.js b/node_modules/lodash/pullAt.js new file mode 100644 index 0000000000000000000000000000000000000000..6ed84e064dd079c40211bfc0e5e4ee4b9d912237 --- /dev/null +++ b/node_modules/lodash/pullAt.js @@ -0,0 +1,43 @@ +var arrayMap = require('./_arrayMap'), + baseAt = require('./_baseAt'), + basePullAt = require('./_basePullAt'), + compareAscending = require('./_compareAscending'), + flatRest = require('./_flatRest'), + isIndex = require('./_isIndex'); + +/** + * Removes elements from `array` corresponding to `indexes` and returns an + * array of removed elements. + * + * **Note:** Unlike `_.at`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {...(number|number[])} [indexes] The indexes of elements to remove. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = ['a', 'b', 'c', 'd']; + * var pulled = _.pullAt(array, [1, 3]); + * + * console.log(array); + * // => ['a', 'c'] + * + * console.log(pulled); + * // => ['b', 'd'] + */ +var pullAt = flatRest(function(array, indexes) { + var length = array == null ? 0 : array.length, + result = baseAt(array, indexes); + + basePullAt(array, arrayMap(indexes, function(index) { + return isIndex(index, length) ? +index : index; + }).sort(compareAscending)); + + return result; +}); + +module.exports = pullAt; diff --git a/node_modules/lodash/random.js b/node_modules/lodash/random.js new file mode 100644 index 0000000000000000000000000000000000000000..8067711c2355e7c6da4b0b976be9857d8b49bf52 --- /dev/null +++ b/node_modules/lodash/random.js @@ -0,0 +1,82 @@ +var baseRandom = require('./_baseRandom'), + isIterateeCall = require('./_isIterateeCall'), + toFinite = require('./toFinite'); + +/** Built-in method references without a dependency on `root`. */ +var freeParseFloat = parseFloat; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min, + nativeRandom = Math.random; + +/** + * Produces a random number between the inclusive `lower` and `upper` bounds. + * If only one argument is provided a number between `0` and the given number + * is returned. If `floating` is `true`, or either `lower` or `upper` are + * floats, a floating-point number is returned instead of an integer. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @memberOf _ + * @since 0.7.0 + * @category Number + * @param {number} [lower=0] The lower bound. + * @param {number} [upper=1] The upper bound. + * @param {boolean} [floating] Specify returning a floating-point number. + * @returns {number} Returns the random number. + * @example + * + * _.random(0, 5); + * // => an integer between 0 and 5 + * + * _.random(5); + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 + */ +function random(lower, upper, floating) { + if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { + upper = floating = undefined; + } + if (floating === undefined) { + if (typeof upper == 'boolean') { + floating = upper; + upper = undefined; + } + else if (typeof lower == 'boolean') { + floating = lower; + lower = undefined; + } + } + if (lower === undefined && upper === undefined) { + lower = 0; + upper = 1; + } + else { + lower = toFinite(lower); + if (upper === undefined) { + upper = lower; + lower = 0; + } else { + upper = toFinite(upper); + } + } + if (lower > upper) { + var temp = lower; + lower = upper; + upper = temp; + } + if (floating || lower % 1 || upper % 1) { + var rand = nativeRandom(); + return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); + } + return baseRandom(lower, upper); +} + +module.exports = random; diff --git a/node_modules/lodash/range.js b/node_modules/lodash/range.js new file mode 100644 index 0000000000000000000000000000000000000000..fa63b091805e5446fbf1d21a18981f3f26e0467f --- /dev/null +++ b/node_modules/lodash/range.js @@ -0,0 +1,46 @@ +var createRange = require('./_createRange'); + +/** + * Creates an array of numbers (positive and/or negative) progressing from + * `start` up to, but not including, `end`. A step of `-1` is used if a negative + * `start` is specified without an `end` or `step`. If `end` is not specified, + * it's set to `start` with `start` then set to `0`. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns the range of numbers. + * @see _.inRange, _.rangeRight + * @example + * + * _.range(4); + * // => [0, 1, 2, 3] + * + * _.range(-4); + * // => [0, -1, -2, -3] + * + * _.range(1, 5); + * // => [1, 2, 3, 4] + * + * _.range(0, 20, 5); + * // => [0, 5, 10, 15] + * + * _.range(0, -4, -1); + * // => [0, -1, -2, -3] + * + * _.range(1, 4, 0); + * // => [1, 1, 1] + * + * _.range(0); + * // => [] + */ +var range = createRange(); + +module.exports = range; diff --git a/node_modules/lodash/rearg.js b/node_modules/lodash/rearg.js new file mode 100644 index 0000000000000000000000000000000000000000..a3e1970b8c30e3f4c5e1c1050039628db8907640 --- /dev/null +++ b/node_modules/lodash/rearg.js @@ -0,0 +1,33 @@ +var createWrap = require('./_createWrap'), + flatRest = require('./_flatRest'); + +/** Used to compose bitmasks for function metadata. */ +var WRAP_REARG_FLAG = 256; + +/** + * Creates a function that invokes `func` with arguments arranged according + * to the specified `indexes` where the argument value at the first index is + * provided as the first argument, the argument value at the second index is + * provided as the second argument, and so on. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to rearrange arguments for. + * @param {...(number|number[])} indexes The arranged argument indexes. + * @returns {Function} Returns the new function. + * @example + * + * var rearged = _.rearg(function(a, b, c) { + * return [a, b, c]; + * }, [2, 0, 1]); + * + * rearged('b', 'c', 'a') + * // => ['a', 'b', 'c'] + */ +var rearg = flatRest(function(func, indexes) { + return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); +}); + +module.exports = rearg; diff --git a/node_modules/lodash/remove.js b/node_modules/lodash/remove.js new file mode 100644 index 0000000000000000000000000000000000000000..87b1898e35d793df22a9c1212a8054be95a2ea72 --- /dev/null +++ b/node_modules/lodash/remove.js @@ -0,0 +1,53 @@ +var baseIteratee = require('./_baseIteratee'), + basePullAt = require('./_basePullAt'); + +/** + * Removes all elements from `array` that `predicate` returns truthy for + * and returns an array of the removed elements. The predicate is invoked + * with three arguments: (value, index, array). + * + * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` + * to pull elements from an array by value. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4]; + * var evens = _.remove(array, function(n) { + * return n % 2 == 0; + * }); + * + * console.log(array); + * // => [1, 3] + * + * console.log(evens); + * // => [2, 4] + */ +function remove(array, predicate) { + var result = []; + if (!(array && array.length)) { + return result; + } + var index = -1, + indexes = [], + length = array.length; + + predicate = baseIteratee(predicate, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); + } + } + basePullAt(array, indexes); + return result; +} + +module.exports = remove; diff --git a/node_modules/lodash/rest.js b/node_modules/lodash/rest.js new file mode 100644 index 0000000000000000000000000000000000000000..eaaad00b7bb7a4d29d033c852d4481d264ca4010 --- /dev/null +++ b/node_modules/lodash/rest.js @@ -0,0 +1,40 @@ +var baseRest = require('./_baseRest'), + toInteger = require('./toInteger'); + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that invokes `func` with the `this` binding of the + * created function and arguments from `start` and beyond provided as + * an array. + * + * **Note:** This method is based on the + * [rest parameter](https://mdn.io/rest_parameters). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.rest(function(what, names) { + * return what + ' ' + _.initial(names).join(', ') + + * (_.size(names) > 1 ? ', & ' : '') + _.last(names); + * }); + * + * say('hello', 'fred', 'barney', 'pebbles'); + * // => 'hello fred, barney, & pebbles' + */ +function rest(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = start === undefined ? start : toInteger(start); + return baseRest(func, start); +} + +module.exports = rest; diff --git a/node_modules/lodash/reverse.js b/node_modules/lodash/reverse.js new file mode 100644 index 0000000000000000000000000000000000000000..21764afd665b80816f58e525ce30846ef5578ea6 --- /dev/null +++ b/node_modules/lodash/reverse.js @@ -0,0 +1,34 @@ +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeReverse = arrayProto.reverse; + +/** + * Reverses `array` so that the first element becomes the last, the second + * element becomes the second to last, and so on. + * + * **Note:** This method mutates `array` and is based on + * [`Array#reverse`](https://mdn.io/Array/reverse). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3]; + * + * _.reverse(array); + * // => [3, 2, 1] + * + * console.log(array); + * // => [3, 2, 1] + */ +function reverse(array) { + return array == null ? array : nativeReverse.call(array); +} + +module.exports = reverse; diff --git a/node_modules/lodash/size.js b/node_modules/lodash/size.js new file mode 100644 index 0000000000000000000000000000000000000000..3561fc1010dce286306be36684cba8cd4ed70056 --- /dev/null +++ b/node_modules/lodash/size.js @@ -0,0 +1,46 @@ +var baseKeys = require('./_baseKeys'), + getTag = require('./_getTag'), + isArrayLike = require('./isArrayLike'), + isString = require('./isString'), + stringSize = require('./_stringSize'); + +/** `Object#toString` result references. */ +var mapTag = '[object Map]', + setTag = '[object Set]'; + +/** + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable string keyed properties for objects. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns the collection size. + * @example + * + * _.size([1, 2, 3]); + * // => 3 + * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * + * _.size('pebbles'); + * // => 7 + */ +function size(collection) { + if (collection == null) { + return 0; + } + if (isArrayLike(collection)) { + return isString(collection) ? stringSize(collection) : collection.length; + } + var tag = getTag(collection); + if (tag == mapTag || tag == setTag) { + return collection.size; + } + return baseKeys(collection).length; +} + +module.exports = size; diff --git a/node_modules/lodash/sortedLastIndex.js b/node_modules/lodash/sortedLastIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..9380cb9cbc6d65eed6f9d674076766a83e8435dd --- /dev/null +++ b/node_modules/lodash/sortedLastIndex.js @@ -0,0 +1,25 @@ +var baseSortedIndex = require('./_baseSortedIndex'); + +/** + * This method is like `_.sortedIndex` except that it returns the highest + * index at which `value` should be inserted into `array` in order to + * maintain its sort order. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedLastIndex([4, 5, 5, 5, 6], 5); + * // => 4 + */ +function sortedLastIndex(array, value) { + return baseSortedIndex(array, value, true); +} + +module.exports = sortedLastIndex; diff --git a/node_modules/lodash/times.js b/node_modules/lodash/times.js new file mode 100644 index 0000000000000000000000000000000000000000..266c90c68168d9965305052ae9a8adc431908730 --- /dev/null +++ b/node_modules/lodash/times.js @@ -0,0 +1,51 @@ +var baseTimes = require('./_baseTimes'), + castFunction = require('./_castFunction'), + toInteger = require('./toInteger'); + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used as references for the maximum length and index of an array. */ +var MAX_ARRAY_LENGTH = 4294967295; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; + +/** + * Invokes the iteratee `n` times, returning an array of the results of + * each invocation. The iteratee is invoked with one argument; (index). + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the array of results. + * @example + * + * _.times(3, String); + * // => ['0', '1', '2'] + * + * _.times(4, _.constant(0)); + * // => [0, 0, 0, 0] + */ +function times(n, iteratee) { + n = toInteger(n); + if (n < 1 || n > MAX_SAFE_INTEGER) { + return []; + } + var index = MAX_ARRAY_LENGTH, + length = nativeMin(n, MAX_ARRAY_LENGTH); + + iteratee = castFunction(iteratee); + n -= MAX_ARRAY_LENGTH; + + var result = baseTimes(length, iteratee); + while (++index < n) { + iteratee(index); + } + return result; +} + +module.exports = times; diff --git a/node_modules/lodash/toLower.js b/node_modules/lodash/toLower.js new file mode 100644 index 0000000000000000000000000000000000000000..b4b7858eb03992ef2d32546bf09c112e0a461838 --- /dev/null +++ b/node_modules/lodash/toLower.js @@ -0,0 +1,28 @@ +var toString = require('./toString'); + +/** + * Converts `string`, as a whole, to lower case just like + * [String#toLowerCase](https://mdn.io/toLowerCase). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the lower cased string. + * @example + * + * _.toLower('--Foo-Bar--'); + * // => '--foo-bar--' + * + * _.toLower('fooBar'); + * // => 'foobar' + * + * _.toLower('__FOO_BAR__'); + * // => '__foo_bar__' + */ +function toLower(value) { + return toString(value).toLowerCase(); +} + +module.exports = toLower; diff --git a/node_modules/lodash/unionWith.js b/node_modules/lodash/unionWith.js new file mode 100644 index 0000000000000000000000000000000000000000..78736b27cda71f3a69e847fa821e6ab4a063682f --- /dev/null +++ b/node_modules/lodash/unionWith.js @@ -0,0 +1,34 @@ +var baseFlatten = require('./_baseFlatten'), + baseRest = require('./_baseRest'), + baseUniq = require('./_baseUniq'), + isArrayLikeObject = require('./isArrayLikeObject'), + last = require('./last'); + +/** + * This method is like `_.union` except that it accepts `comparator` which + * is invoked to compare elements of `arrays`. Result values are chosen from + * the first array in which the value occurs. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of combined values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.unionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ +var unionWith = baseRest(function(arrays) { + var comparator = last(arrays); + comparator = typeof comparator == 'function' ? comparator : undefined; + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); +}); + +module.exports = unionWith; diff --git a/node_modules/lodash/uniqBy.js b/node_modules/lodash/uniqBy.js new file mode 100644 index 0000000000000000000000000000000000000000..53402a9bf8b846307eb4f3bab98bece1826412b5 --- /dev/null +++ b/node_modules/lodash/uniqBy.js @@ -0,0 +1,31 @@ +var baseIteratee = require('./_baseIteratee'), + baseUniq = require('./_baseUniq'); + +/** + * This method is like `_.uniq` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * uniqueness is computed. The order of result values is determined by the + * order they occur in the array. The iteratee is invoked with one argument: + * (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.uniqBy([2.1, 1.2, 2.3], Math.floor); + * // => [2.1, 1.2] + * + * // The `_.property` iteratee shorthand. + * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] + */ +function uniqBy(array, iteratee) { + return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : []; +} + +module.exports = uniqBy; diff --git a/node_modules/lodash/unzip.js b/node_modules/lodash/unzip.js new file mode 100644 index 0000000000000000000000000000000000000000..fce0ec78d1090f74ada6b01719806a388e494fb1 --- /dev/null +++ b/node_modules/lodash/unzip.js @@ -0,0 +1,45 @@ +var arrayFilter = require('./_arrayFilter'), + arrayMap = require('./_arrayMap'), + baseProperty = require('./_baseProperty'), + baseTimes = require('./_baseTimes'), + isArrayLikeObject = require('./isArrayLikeObject'); + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * This method is like `_.zip` except that it accepts an array of grouped + * elements and creates an array regrouping the elements to their pre-zip + * configuration. + * + * @static + * @memberOf _ + * @since 1.2.0 + * @category Array + * @param {Array} array The array of grouped elements to process. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); + * // => [['a', 1, true], ['b', 2, false]] + * + * _.unzip(zipped); + * // => [['a', 'b'], [1, 2], [true, false]] + */ +function unzip(array) { + if (!(array && array.length)) { + return []; + } + var length = 0; + array = arrayFilter(array, function(group) { + if (isArrayLikeObject(group)) { + length = nativeMax(group.length, length); + return true; + } + }); + return baseTimes(length, function(index) { + return arrayMap(array, baseProperty(index)); + }); +} + +module.exports = unzip; diff --git a/node_modules/lodash/upperFirst.js b/node_modules/lodash/upperFirst.js new file mode 100644 index 0000000000000000000000000000000000000000..1dd64e135613349b7d39538d81be82c26d419ba1 --- /dev/null +++ b/node_modules/lodash/upperFirst.js @@ -0,0 +1,22 @@ +var createCaseFirst = require('./_createCaseFirst'); + +/** + * Converts the first character of `string` to upper case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.upperFirst('fred'); + * // => 'Fred' + * + * _.upperFirst('FRED'); + * // => 'FRED' + */ +var upperFirst = createCaseFirst('toUpperCase'); + +module.exports = upperFirst; diff --git a/node_modules/lodash/util.js b/node_modules/lodash/util.js new file mode 100644 index 0000000000000000000000000000000000000000..d244dc27efe8899ec62374ba43a2f7d2893123b4 --- /dev/null +++ b/node_modules/lodash/util.js @@ -0,0 +1,34 @@ +module.exports = { + 'attempt': require('./attempt'), + 'bindAll': require('./bindAll'), + 'cond': require('./cond'), + 'conforms': require('./conforms'), + 'constant': require('./constant'), + 'defaultTo': require('./defaultTo'), + 'flow': require('./flow'), + 'flowRight': require('./flowRight'), + 'identity': require('./identity'), + 'iteratee': require('./iteratee'), + 'matches': require('./matches'), + 'matchesProperty': require('./matchesProperty'), + 'method': require('./method'), + 'methodOf': require('./methodOf'), + 'mixin': require('./mixin'), + 'noop': require('./noop'), + 'nthArg': require('./nthArg'), + 'over': require('./over'), + 'overEvery': require('./overEvery'), + 'overSome': require('./overSome'), + 'property': require('./property'), + 'propertyOf': require('./propertyOf'), + 'range': require('./range'), + 'rangeRight': require('./rangeRight'), + 'stubArray': require('./stubArray'), + 'stubFalse': require('./stubFalse'), + 'stubObject': require('./stubObject'), + 'stubString': require('./stubString'), + 'stubTrue': require('./stubTrue'), + 'times': require('./times'), + 'toPath': require('./toPath'), + 'uniqueId': require('./uniqueId') +}; diff --git a/node_modules/lodash/valuesIn.js b/node_modules/lodash/valuesIn.js new file mode 100644 index 0000000000000000000000000000000000000000..6296094207986fefd07d9cd60be6f64213f3e06a --- /dev/null +++ b/node_modules/lodash/valuesIn.js @@ -0,0 +1,32 @@ +var baseValues = require('./_baseValues'), + keysIn = require('./keysIn'); + +/** + * Creates an array of the own and inherited enumerable string keyed property + * values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.valuesIn(new Foo); + * // => [1, 2, 3] (iteration order is not guaranteed) + */ +function valuesIn(object) { + return object == null ? [] : baseValues(object, keysIn(object)); +} + +module.exports = valuesIn; diff --git a/node_modules/lodash/wrapperAt.js b/node_modules/lodash/wrapperAt.js new file mode 100644 index 0000000000000000000000000000000000000000..6f6a1d0806b1640ce905de7cca421c99186cd3b6 --- /dev/null +++ b/node_modules/lodash/wrapperAt.js @@ -0,0 +1,48 @@ +var LazyWrapper = require('./_LazyWrapper'), + LodashWrapper = require('./_LodashWrapper'), + baseAt = require('./_baseAt'), + flatRest = require('./_flatRest'), + isIndex = require('./_isIndex'), + thru = require('./thru'); + +/** + * This method is the wrapper version of `_.at`. + * + * @name at + * @memberOf _ + * @since 1.0.0 + * @category Seq + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * + * _(object).at(['a[0].b.c', 'a[1]']).value(); + * // => [3, 4] + */ +var wrapperAt = flatRest(function(paths) { + var length = paths.length, + start = length ? paths[0] : 0, + value = this.__wrapped__, + interceptor = function(object) { return baseAt(object, paths); }; + + if (length > 1 || this.__actions__.length || + !(value instanceof LazyWrapper) || !isIndex(start)) { + return this.thru(interceptor); + } + value = value.slice(start, +start + (length ? 1 : 0)); + value.__actions__.push({ + 'func': thru, + 'args': [interceptor], + 'thisArg': undefined + }); + return new LodashWrapper(value, this.__chain__).thru(function(array) { + if (length && !array.length) { + array.push(undefined); + } + return array; + }); +}); + +module.exports = wrapperAt; diff --git a/node_modules/lodash/xorBy.js b/node_modules/lodash/xorBy.js new file mode 100644 index 0000000000000000000000000000000000000000..e0478950c669d70ebe38be1bebaa17e31bc80ddb --- /dev/null +++ b/node_modules/lodash/xorBy.js @@ -0,0 +1,39 @@ +var arrayFilter = require('./_arrayFilter'), + baseIteratee = require('./_baseIteratee'), + baseRest = require('./_baseRest'), + baseXor = require('./_baseXor'), + isArrayLikeObject = require('./isArrayLikeObject'), + last = require('./last'); + +/** + * This method is like `_.xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by + * which by which they're compared. The order of result values is determined + * by the order they occur in the arrays. The iteratee is invoked with one + * argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2, 3.4] + * + * // The `_.property` iteratee shorthand. + * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] + */ +var xorBy = baseRest(function(arrays) { + var iteratee = last(arrays); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return baseXor(arrayFilter(arrays, isArrayLikeObject), baseIteratee(iteratee, 2)); +}); + +module.exports = xorBy; diff --git a/node_modules/magic-string/LICENSE b/node_modules/magic-string/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..667e8b45e4051a6f32008aafa25ecd8aefaaa1f9 --- /dev/null +++ b/node_modules/magic-string/LICENSE @@ -0,0 +1,7 @@ +Copyright 2018 Rich Harris + +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. diff --git a/node_modules/magic-string/README.md b/node_modules/magic-string/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d228709350037667511f4df3a1181214ef5bfdec --- /dev/null +++ b/node_modules/magic-string/README.md @@ -0,0 +1,252 @@ +# magic-string + + + build status + + + npm version + + + license + + +Suppose you have some source code. You want to make some light modifications to it - replacing a few characters here and there, wrapping it with a header and footer, etc - and ideally you'd like to generate a source map at the end of it. You've thought about using something like [recast](https://github.com/benjamn/recast) (which allows you to generate an AST from some JavaScript, manipulate it, and reprint it with a sourcemap without losing your comments and formatting), but it seems like overkill for your needs (or maybe the source code isn't JavaScript). + +Your requirements are, frankly, rather niche. But they're requirements that I also have, and for which I made magic-string. It's a small, fast utility for manipulating strings and generating sourcemaps. + +## Installation + +magic-string works in both node.js and browser environments. For node, install with npm: + +```bash +npm i magic-string +``` + +To use in browser, grab the [magic-string.umd.js](https://unpkg.com/magic-string/dist/magic-string.umd.js) file and add it to your page: + +```html + +``` + +(It also works with various module systems, if you prefer that sort of thing - it has a dependency on [vlq](https://github.com/Rich-Harris/vlq).) + +## Usage + +These examples assume you're in node.js, or something similar: + +```js +import MagicString from 'magic-string'; +import fs from 'fs' + +const s = new MagicString('problems = 99'); + +s.overwrite(0, 8, 'answer'); +s.toString(); // 'answer = 99' + +s.overwrite(11, 13, '42'); // character indices always refer to the original string +s.toString(); // 'answer = 42' + +s.prepend('var ').append(';'); // most methods are chainable +s.toString(); // 'var answer = 42;' + +const map = s.generateMap({ + source: 'source.js', + file: 'converted.js.map', + includeContent: true +}); // generates a v3 sourcemap + +fs.writeFileSync('converted.js', s.toString()); +fs.writeFileSync('converted.js.map', map.toString()); +``` + +You can pass an options argument: + +```js +const s = new MagicString(someCode, { + // both these options will be used if you later + // call `bundle.addSource( s )` - see below + filename: 'foo.js', + indentExclusionRanges: [/*...*/] +}); +``` + +## Methods + +### s.addSourcemapLocation( index ) + +Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is `false` (see below). + +### s.append( content ) + +Appends the specified content to the end of the string. Returns `this`. + +### s.appendLeft( index, content ) + +Appends the specified `content` at the `index` in the original string. If a range *ending* with `index` is subsequently moved, the insert will be moved with it. Returns `this`. See also `s.prependLeft(...)`. + +### s.appendRight( index, content ) + +Appends the specified `content` at the `index` in the original string. If a range *starting* with `index` is subsequently moved, the insert will be moved with it. Returns `this`. See also `s.prependRight(...)`. + +### s.clone() + +Does what you'd expect. + +### s.generateDecodedMap( options ) + +Generates a sourcemap object with raw mappings in array form, rather than encoded as a string. See `generateMap` documentation below for options details. Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead. + +### s.generateMap( options ) + +Generates a [version 3 sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit). All options are, well, optional: + +* `file` - the filename where you plan to write the sourcemap +* `source` - the filename of the file containing the original source +* `includeContent` - whether to include the original content in the map's `sourcesContent` array +* `hires` - whether the mapping should be high-resolution. Hi-res mappings map every single character, meaning (for example) your devtools will always be able to pinpoint the exact location of function calls and so on. With lo-res mappings, devtools may only be able to identify the correct line - but they're quicker to generate and less bulky. If sourcemap locations have been specified with `s.addSourceMapLocation()`, they will be used here. + +The returned sourcemap has two (non-enumerable) methods attached for convenience: + +* `toString` - returns the equivalent of `JSON.stringify(map)` +* `toUrl` - returns a DataURI containing the sourcemap. Useful for doing this sort of thing: + +```js +code += '\n//# sourceMappingURL=' + map.toUrl(); +``` + +### s.indent( prefix[, options] ) + +Prefixes each line of the string with `prefix`. If `prefix` is not supplied, the indentation will be guessed from the original content, falling back to a single tab character. Returns `this`. + +The `options` argument can have an `exclude` property, which is an array of `[start, end]` character ranges. These ranges will be excluded from the indentation - useful for (e.g.) multiline strings. + +### s.insertLeft( index, content ) + +**DEPRECATED** since 0.17 – use `s.appendLeft(...)` instead + +### s.insertRight( index, content ) + +**DEPRECATED** since 0.17 – use `s.prependRight(...)` instead + +### s.locate( index ) + +**DEPRECATED** since 0.10 – see [#30](https://github.com/Rich-Harris/magic-string/pull/30) + +### s.locateOrigin( index ) + +**DEPRECATED** since 0.10 – see [#30](https://github.com/Rich-Harris/magic-string/pull/30) + +### s.move( start, end, newIndex ) + +Moves the characters from `start` and `end` to `index`. Returns `this`. + +### s.overwrite( start, end, content[, options] ) + +Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply. Returns `this`. + +The fourth argument is optional. It can have a `storeName` property — if `true`, the original name will be stored for later inclusion in a sourcemap's `names` array — and a `contentOnly` property which determines whether only the content is overwritten, or anything that was appended/prepended to the range as well. + +### s.prepend( content ) + +Prepends the string with the specified content. Returns `this`. + +### s.prependLeft ( index, content ) + +Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at `index` + +### s.prependRight ( index, content ) + +Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index` + +### s.remove( start, end ) + +Removes the characters from `start` to `end` (of the original string, **not** the generated string). Removing the same content twice, or making removals that partially overlap, will cause an error. Returns `this`. + +### s.slice( start, end ) + +Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string. Throws error if the indices are for characters that were already removed. + +### s.snip( start, end ) + +Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed. + +### s.toString() + +Returns the generated string. + +### s.trim([ charType ]) + +Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end. Returns `this`. + +### s.trimStart([ charType ]) + +Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start. Returns `this`. + +### s.trimEnd([ charType ]) + +Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end. Returns `this`. + +### s.trimLines() + +Removes empty lines from the start and end. Returns `this`. + +### s.isEmpty() + +Returns true if the resulting source is empty (disregarding white space). + +## Bundling + +To concatenate several sources, use `MagicString.Bundle`: + +```js +const bundle = new MagicString.Bundle(); + +bundle.addSource({ + filename: 'foo.js', + content: new MagicString('var answer = 42;') +}); + +bundle.addSource({ + filename: 'bar.js', + content: new MagicString('console.log( answer )') +}); + +// Advanced: a source can include an `indentExclusionRanges` property +// alongside `filename` and `content`. This will be passed to `s.indent()` +// - see documentation above + +bundle.indent() // optionally, pass an indent string, otherwise it will be guessed + .prepend('(function () {\n') + .append('}());'); + +bundle.toString(); +// (function () { +// var answer = 42; +// console.log( answer ); +// }()); + +// options are as per `s.generateMap()` above +const map = bundle.generateMap({ + file: 'bundle.js', + includeContent: true, + hires: true +}); +``` + +As an alternative syntax, if you a) don't have `filename` or `indentExclusionRanges` options, or b) passed those in when you used `new MagicString(...)`, you can simply pass the `MagicString` instance itself: + +```js +const bundle = new MagicString.Bundle(); +const source = new MagicString(someCode, { + filename: 'foo.js' +}); + +bundle.addSource(source); +``` + +## License + +MIT diff --git a/node_modules/magic-string/dist/magic-string.cjs.js b/node_modules/magic-string/dist/magic-string.cjs.js new file mode 100644 index 0000000000000000000000000000000000000000..4be44d8eaf2fad792432dfb0a7f4cf9d675162b2 --- /dev/null +++ b/node_modules/magic-string/dist/magic-string.cjs.js @@ -0,0 +1,1311 @@ +'use strict'; + +var sourcemapCodec = require('sourcemap-codec'); + +var BitSet = function BitSet(arg) { + this.bits = arg instanceof BitSet ? arg.bits.slice() : []; +}; + +BitSet.prototype.add = function add (n) { + this.bits[n >> 5] |= 1 << (n & 31); +}; + +BitSet.prototype.has = function has (n) { + return !!(this.bits[n >> 5] & (1 << (n & 31))); +}; + +var Chunk = function Chunk(start, end, content) { + this.start = start; + this.end = end; + this.original = content; + + this.intro = ''; + this.outro = ''; + + this.content = content; + this.storeName = false; + this.edited = false; + + // we make these non-enumerable, for sanity while debugging + Object.defineProperties(this, { + previous: { writable: true, value: null }, + next: { writable: true, value: null }, + }); +}; + +Chunk.prototype.appendLeft = function appendLeft (content) { + this.outro += content; +}; + +Chunk.prototype.appendRight = function appendRight (content) { + this.intro = this.intro + content; +}; + +Chunk.prototype.clone = function clone () { + var chunk = new Chunk(this.start, this.end, this.original); + + chunk.intro = this.intro; + chunk.outro = this.outro; + chunk.content = this.content; + chunk.storeName = this.storeName; + chunk.edited = this.edited; + + return chunk; +}; + +Chunk.prototype.contains = function contains (index) { + return this.start < index && index < this.end; +}; + +Chunk.prototype.eachNext = function eachNext (fn) { + var chunk = this; + while (chunk) { + fn(chunk); + chunk = chunk.next; + } +}; + +Chunk.prototype.eachPrevious = function eachPrevious (fn) { + var chunk = this; + while (chunk) { + fn(chunk); + chunk = chunk.previous; + } +}; + +Chunk.prototype.edit = function edit (content, storeName, contentOnly) { + this.content = content; + if (!contentOnly) { + this.intro = ''; + this.outro = ''; + } + this.storeName = storeName; + + this.edited = true; + + return this; +}; + +Chunk.prototype.prependLeft = function prependLeft (content) { + this.outro = content + this.outro; +}; + +Chunk.prototype.prependRight = function prependRight (content) { + this.intro = content + this.intro; +}; + +Chunk.prototype.split = function split (index) { + var sliceIndex = index - this.start; + + var originalBefore = this.original.slice(0, sliceIndex); + var originalAfter = this.original.slice(sliceIndex); + + this.original = originalBefore; + + var newChunk = new Chunk(index, this.end, originalAfter); + newChunk.outro = this.outro; + this.outro = ''; + + this.end = index; + + if (this.edited) { + // TODO is this block necessary?... + newChunk.edit('', false); + this.content = ''; + } else { + this.content = originalBefore; + } + + newChunk.next = this.next; + if (newChunk.next) { newChunk.next.previous = newChunk; } + newChunk.previous = this; + this.next = newChunk; + + return newChunk; +}; + +Chunk.prototype.toString = function toString () { + return this.intro + this.content + this.outro; +}; + +Chunk.prototype.trimEnd = function trimEnd (rx) { + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + + var trimmed = this.content.replace(rx, ''); + + if (trimmed.length) { + if (trimmed !== this.content) { + this.split(this.start + trimmed.length).edit('', undefined, true); + } + return true; + } else { + this.edit('', undefined, true); + + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + } +}; + +Chunk.prototype.trimStart = function trimStart (rx) { + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + + var trimmed = this.content.replace(rx, ''); + + if (trimmed.length) { + if (trimmed !== this.content) { + this.split(this.end - trimmed.length); + this.edit('', undefined, true); + } + return true; + } else { + this.edit('', undefined, true); + + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + } +}; + +var btoa = function () { + throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.'); +}; +if (typeof window !== 'undefined' && typeof window.btoa === 'function') { + btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); }; +} else if (typeof Buffer === 'function') { + btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); }; +} + +var SourceMap = function SourceMap(properties) { + this.version = 3; + this.file = properties.file; + this.sources = properties.sources; + this.sourcesContent = properties.sourcesContent; + this.names = properties.names; + this.mappings = sourcemapCodec.encode(properties.mappings); +}; + +SourceMap.prototype.toString = function toString () { + return JSON.stringify(this); +}; + +SourceMap.prototype.toUrl = function toUrl () { + return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString()); +}; + +function guessIndent(code) { + var lines = code.split('\n'); + + var tabbed = lines.filter(function (line) { return /^\t+/.test(line); }); + var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); }); + + if (tabbed.length === 0 && spaced.length === 0) { + return null; + } + + // More lines tabbed than spaced? Assume tabs, and + // default to tabs in the case of a tie (or nothing + // to go on) + if (tabbed.length >= spaced.length) { + return '\t'; + } + + // Otherwise, we need to guess the multiple + var min = spaced.reduce(function (previous, current) { + var numSpaces = /^ +/.exec(current)[0].length; + return Math.min(numSpaces, previous); + }, Infinity); + + return new Array(min + 1).join(' '); +} + +function getRelativePath(from, to) { + var fromParts = from.split(/[/\\]/); + var toParts = to.split(/[/\\]/); + + fromParts.pop(); // get dirname + + while (fromParts[0] === toParts[0]) { + fromParts.shift(); + toParts.shift(); + } + + if (fromParts.length) { + var i = fromParts.length; + while (i--) { fromParts[i] = '..'; } + } + + return fromParts.concat(toParts).join('/'); +} + +var toString = Object.prototype.toString; + +function isObject(thing) { + return toString.call(thing) === '[object Object]'; +} + +function getLocator(source) { + var originalLines = source.split('\n'); + var lineOffsets = []; + + for (var i = 0, pos = 0; i < originalLines.length; i++) { + lineOffsets.push(pos); + pos += originalLines[i].length + 1; + } + + return function locate(index) { + var i = 0; + var j = lineOffsets.length; + while (i < j) { + var m = (i + j) >> 1; + if (index < lineOffsets[m]) { + j = m; + } else { + i = m + 1; + } + } + var line = i - 1; + var column = index - lineOffsets[line]; + return { line: line, column: column }; + }; +} + +var Mappings = function Mappings(hires) { + this.hires = hires; + this.generatedCodeLine = 0; + this.generatedCodeColumn = 0; + this.raw = []; + this.rawSegments = this.raw[this.generatedCodeLine] = []; + this.pending = null; +}; + +Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) { + if (content.length) { + var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column]; + if (nameIndex >= 0) { + segment.push(nameIndex); + } + this.rawSegments.push(segment); + } else if (this.pending) { + this.rawSegments.push(this.pending); + } + + this.advance(content); + this.pending = null; +}; + +Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) { + var originalCharIndex = chunk.start; + var first = true; + + while (originalCharIndex < chunk.end) { + if (this.hires || first || sourcemapLocations.has(originalCharIndex)) { + this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]); + } + + if (original[originalCharIndex] === '\n') { + loc.line += 1; + loc.column = 0; + this.generatedCodeLine += 1; + this.raw[this.generatedCodeLine] = this.rawSegments = []; + this.generatedCodeColumn = 0; + first = true; + } else { + loc.column += 1; + this.generatedCodeColumn += 1; + first = false; + } + + originalCharIndex += 1; + } + + this.pending = null; +}; + +Mappings.prototype.advance = function advance (str) { + if (!str) { return; } + + var lines = str.split('\n'); + + if (lines.length > 1) { + for (var i = 0; i < lines.length - 1; i++) { + this.generatedCodeLine++; + this.raw[this.generatedCodeLine] = this.rawSegments = []; + } + this.generatedCodeColumn = 0; + } + + this.generatedCodeColumn += lines[lines.length - 1].length; +}; + +var n = '\n'; + +var warned = { + insertLeft: false, + insertRight: false, + storeName: false, +}; + +var MagicString = function MagicString(string, options) { + if ( options === void 0 ) options = {}; + + var chunk = new Chunk(0, string.length, string); + + Object.defineProperties(this, { + original: { writable: true, value: string }, + outro: { writable: true, value: '' }, + intro: { writable: true, value: '' }, + firstChunk: { writable: true, value: chunk }, + lastChunk: { writable: true, value: chunk }, + lastSearchedChunk: { writable: true, value: chunk }, + byStart: { writable: true, value: {} }, + byEnd: { writable: true, value: {} }, + filename: { writable: true, value: options.filename }, + indentExclusionRanges: { writable: true, value: options.indentExclusionRanges }, + sourcemapLocations: { writable: true, value: new BitSet() }, + storedNames: { writable: true, value: {} }, + indentStr: { writable: true, value: guessIndent(string) }, + }); + + this.byStart[0] = chunk; + this.byEnd[string.length] = chunk; +}; + +MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) { + this.sourcemapLocations.add(char); +}; + +MagicString.prototype.append = function append (content) { + if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); } + + this.outro += content; + return this; +}; + +MagicString.prototype.appendLeft = function appendLeft (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byEnd[index]; + + if (chunk) { + chunk.appendLeft(content); + } else { + this.intro += content; + } + return this; +}; + +MagicString.prototype.appendRight = function appendRight (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byStart[index]; + + if (chunk) { + chunk.appendRight(content); + } else { + this.outro += content; + } + return this; +}; + +MagicString.prototype.clone = function clone () { + var cloned = new MagicString(this.original, { filename: this.filename }); + + var originalChunk = this.firstChunk; + var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone()); + + while (originalChunk) { + cloned.byStart[clonedChunk.start] = clonedChunk; + cloned.byEnd[clonedChunk.end] = clonedChunk; + + var nextOriginalChunk = originalChunk.next; + var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone(); + + if (nextClonedChunk) { + clonedChunk.next = nextClonedChunk; + nextClonedChunk.previous = clonedChunk; + + clonedChunk = nextClonedChunk; + } + + originalChunk = nextOriginalChunk; + } + + cloned.lastChunk = clonedChunk; + + if (this.indentExclusionRanges) { + cloned.indentExclusionRanges = this.indentExclusionRanges.slice(); + } + + cloned.sourcemapLocations = new BitSet(this.sourcemapLocations); + + cloned.intro = this.intro; + cloned.outro = this.outro; + + return cloned; +}; + +MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) { + var this$1$1 = this; + + options = options || {}; + + var sourceIndex = 0; + var names = Object.keys(this.storedNames); + var mappings = new Mappings(options.hires); + + var locate = getLocator(this.original); + + if (this.intro) { + mappings.advance(this.intro); + } + + this.firstChunk.eachNext(function (chunk) { + var loc = locate(chunk.start); + + if (chunk.intro.length) { mappings.advance(chunk.intro); } + + if (chunk.edited) { + mappings.addEdit( + sourceIndex, + chunk.content, + loc, + chunk.storeName ? names.indexOf(chunk.original) : -1 + ); + } else { + mappings.addUneditedChunk(sourceIndex, chunk, this$1$1.original, loc, this$1$1.sourcemapLocations); + } + + if (chunk.outro.length) { mappings.advance(chunk.outro); } + }); + + return { + file: options.file ? options.file.split(/[/\\]/).pop() : null, + sources: [options.source ? getRelativePath(options.file || '', options.source) : null], + sourcesContent: options.includeContent ? [this.original] : [null], + names: names, + mappings: mappings.raw, + }; +}; + +MagicString.prototype.generateMap = function generateMap (options) { + return new SourceMap(this.generateDecodedMap(options)); +}; + +MagicString.prototype.getIndentString = function getIndentString () { + return this.indentStr === null ? '\t' : this.indentStr; +}; + +MagicString.prototype.indent = function indent (indentStr, options) { + var pattern = /^[^\r\n]/gm; + + if (isObject(indentStr)) { + options = indentStr; + indentStr = undefined; + } + + indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t'; + + if (indentStr === '') { return this; } // noop + + options = options || {}; + + // Process exclusion ranges + var isExcluded = {}; + + if (options.exclude) { + var exclusions = + typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude; + exclusions.forEach(function (exclusion) { + for (var i = exclusion[0]; i < exclusion[1]; i += 1) { + isExcluded[i] = true; + } + }); + } + + var shouldIndentNextCharacter = options.indentStart !== false; + var replacer = function (match) { + if (shouldIndentNextCharacter) { return ("" + indentStr + match); } + shouldIndentNextCharacter = true; + return match; + }; + + this.intro = this.intro.replace(pattern, replacer); + + var charIndex = 0; + var chunk = this.firstChunk; + + while (chunk) { + var end = chunk.end; + + if (chunk.edited) { + if (!isExcluded[charIndex]) { + chunk.content = chunk.content.replace(pattern, replacer); + + if (chunk.content.length) { + shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n'; + } + } + } else { + charIndex = chunk.start; + + while (charIndex < end) { + if (!isExcluded[charIndex]) { + var char = this.original[charIndex]; + + if (char === '\n') { + shouldIndentNextCharacter = true; + } else if (char !== '\r' && shouldIndentNextCharacter) { + shouldIndentNextCharacter = false; + + if (charIndex === chunk.start) { + chunk.prependRight(indentStr); + } else { + this._splitChunk(chunk, charIndex); + chunk = chunk.next; + chunk.prependRight(indentStr); + } + } + } + + charIndex += 1; + } + } + + charIndex = chunk.end; + chunk = chunk.next; + } + + this.outro = this.outro.replace(pattern, replacer); + + return this; +}; + +MagicString.prototype.insert = function insert () { + throw new Error( + 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)' + ); +}; + +MagicString.prototype.insertLeft = function insertLeft (index, content) { + if (!warned.insertLeft) { + console.warn( + 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead' + ); // eslint-disable-line no-console + warned.insertLeft = true; + } + + return this.appendLeft(index, content); +}; + +MagicString.prototype.insertRight = function insertRight (index, content) { + if (!warned.insertRight) { + console.warn( + 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead' + ); // eslint-disable-line no-console + warned.insertRight = true; + } + + return this.prependRight(index, content); +}; + +MagicString.prototype.move = function move (start, end, index) { + if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); } + + this._split(start); + this._split(end); + this._split(index); + + var first = this.byStart[start]; + var last = this.byEnd[end]; + + var oldLeft = first.previous; + var oldRight = last.next; + + var newRight = this.byStart[index]; + if (!newRight && last === this.lastChunk) { return this; } + var newLeft = newRight ? newRight.previous : this.lastChunk; + + if (oldLeft) { oldLeft.next = oldRight; } + if (oldRight) { oldRight.previous = oldLeft; } + + if (newLeft) { newLeft.next = first; } + if (newRight) { newRight.previous = last; } + + if (!first.previous) { this.firstChunk = last.next; } + if (!last.next) { + this.lastChunk = first.previous; + this.lastChunk.next = null; + } + + first.previous = newLeft; + last.next = newRight || null; + + if (!newLeft) { this.firstChunk = first; } + if (!newRight) { this.lastChunk = last; } + return this; +}; + +MagicString.prototype.overwrite = function overwrite (start, end, content, options) { + if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); } + + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + if (end > this.original.length) { throw new Error('end is out of bounds'); } + if (start === end) + { throw new Error( + 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead' + ); } + + this._split(start); + this._split(end); + + if (options === true) { + if (!warned.storeName) { + console.warn( + 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string' + ); // eslint-disable-line no-console + warned.storeName = true; + } + + options = { storeName: true }; + } + var storeName = options !== undefined ? options.storeName : false; + var contentOnly = options !== undefined ? options.contentOnly : false; + + if (storeName) { + var original = this.original.slice(start, end); + Object.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true }); + } + + var first = this.byStart[start]; + var last = this.byEnd[end]; + + if (first) { + var chunk = first; + while (chunk !== last) { + if (chunk.next !== this.byStart[chunk.end]) { + throw new Error('Cannot overwrite across a split point'); + } + chunk = chunk.next; + chunk.edit('', false); + } + + first.edit(content, storeName, contentOnly); + } else { + // must be inserting at the end + var newChunk = new Chunk(start, end, '').edit(content, storeName); + + // TODO last chunk in the array may not be the last chunk, if it's moved... + last.next = newChunk; + newChunk.previous = last; + } + return this; +}; + +MagicString.prototype.prepend = function prepend (content) { + if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); } + + this.intro = content + this.intro; + return this; +}; + +MagicString.prototype.prependLeft = function prependLeft (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byEnd[index]; + + if (chunk) { + chunk.prependLeft(content); + } else { + this.intro = content + this.intro; + } + return this; +}; + +MagicString.prototype.prependRight = function prependRight (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byStart[index]; + + if (chunk) { + chunk.prependRight(content); + } else { + this.outro = content + this.outro; + } + return this; +}; + +MagicString.prototype.remove = function remove (start, end) { + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + if (start === end) { return this; } + + if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); } + if (start > end) { throw new Error('end must be greater than start'); } + + this._split(start); + this._split(end); + + var chunk = this.byStart[start]; + + while (chunk) { + chunk.intro = ''; + chunk.outro = ''; + chunk.edit(''); + + chunk = end > chunk.end ? this.byStart[chunk.end] : null; + } + return this; +}; + +MagicString.prototype.lastChar = function lastChar () { + if (this.outro.length) { return this.outro[this.outro.length - 1]; } + var chunk = this.lastChunk; + do { + if (chunk.outro.length) { return chunk.outro[chunk.outro.length - 1]; } + if (chunk.content.length) { return chunk.content[chunk.content.length - 1]; } + if (chunk.intro.length) { return chunk.intro[chunk.intro.length - 1]; } + } while ((chunk = chunk.previous)); + if (this.intro.length) { return this.intro[this.intro.length - 1]; } + return ''; +}; + +MagicString.prototype.lastLine = function lastLine () { + var lineIndex = this.outro.lastIndexOf(n); + if (lineIndex !== -1) { return this.outro.substr(lineIndex + 1); } + var lineStr = this.outro; + var chunk = this.lastChunk; + do { + if (chunk.outro.length > 0) { + lineIndex = chunk.outro.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.outro.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.outro + lineStr; + } + + if (chunk.content.length > 0) { + lineIndex = chunk.content.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.content.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.content + lineStr; + } + + if (chunk.intro.length > 0) { + lineIndex = chunk.intro.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.intro.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.intro + lineStr; + } + } while ((chunk = chunk.previous)); + lineIndex = this.intro.lastIndexOf(n); + if (lineIndex !== -1) { return this.intro.substr(lineIndex + 1) + lineStr; } + return this.intro + lineStr; +}; + +MagicString.prototype.slice = function slice (start, end) { + if ( start === void 0 ) start = 0; + if ( end === void 0 ) end = this.original.length; + + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + var result = ''; + + // find start chunk + var chunk = this.firstChunk; + while (chunk && (chunk.start > start || chunk.end <= start)) { + // found end chunk before start + if (chunk.start < end && chunk.end >= end) { + return result; + } + + chunk = chunk.next; + } + + if (chunk && chunk.edited && chunk.start !== start) + { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); } + + var startChunk = chunk; + while (chunk) { + if (chunk.intro && (startChunk !== chunk || chunk.start === start)) { + result += chunk.intro; + } + + var containsEnd = chunk.start < end && chunk.end >= end; + if (containsEnd && chunk.edited && chunk.end !== end) + { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); } + + var sliceStart = startChunk === chunk ? start - chunk.start : 0; + var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length; + + result += chunk.content.slice(sliceStart, sliceEnd); + + if (chunk.outro && (!containsEnd || chunk.end === end)) { + result += chunk.outro; + } + + if (containsEnd) { + break; + } + + chunk = chunk.next; + } + + return result; +}; + +// TODO deprecate this? not really very useful +MagicString.prototype.snip = function snip (start, end) { + var clone = this.clone(); + clone.remove(0, start); + clone.remove(end, clone.original.length); + + return clone; +}; + +MagicString.prototype._split = function _split (index) { + if (this.byStart[index] || this.byEnd[index]) { return; } + + var chunk = this.lastSearchedChunk; + var searchForward = index > chunk.end; + + while (chunk) { + if (chunk.contains(index)) { return this._splitChunk(chunk, index); } + + chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start]; + } +}; + +MagicString.prototype._splitChunk = function _splitChunk (chunk, index) { + if (chunk.edited && chunk.content.length) { + // zero-length edited chunks are a special case (overlapping replacements) + var loc = getLocator(this.original)(index); + throw new Error( + ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")") + ); + } + + var newChunk = chunk.split(index); + + this.byEnd[index] = chunk; + this.byStart[index] = newChunk; + this.byEnd[newChunk.end] = newChunk; + + if (chunk === this.lastChunk) { this.lastChunk = newChunk; } + + this.lastSearchedChunk = chunk; + return true; +}; + +MagicString.prototype.toString = function toString () { + var str = this.intro; + + var chunk = this.firstChunk; + while (chunk) { + str += chunk.toString(); + chunk = chunk.next; + } + + return str + this.outro; +}; + +MagicString.prototype.isEmpty = function isEmpty () { + var chunk = this.firstChunk; + do { + if ( + (chunk.intro.length && chunk.intro.trim()) || + (chunk.content.length && chunk.content.trim()) || + (chunk.outro.length && chunk.outro.trim()) + ) + { return false; } + } while ((chunk = chunk.next)); + return true; +}; + +MagicString.prototype.length = function length () { + var chunk = this.firstChunk; + var length = 0; + do { + length += chunk.intro.length + chunk.content.length + chunk.outro.length; + } while ((chunk = chunk.next)); + return length; +}; + +MagicString.prototype.trimLines = function trimLines () { + return this.trim('[\\r\\n]'); +}; + +MagicString.prototype.trim = function trim (charType) { + return this.trimStart(charType).trimEnd(charType); +}; + +MagicString.prototype.trimEndAborted = function trimEndAborted (charType) { + var rx = new RegExp((charType || '\\s') + '+$'); + + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + + var chunk = this.lastChunk; + + do { + var end = chunk.end; + var aborted = chunk.trimEnd(rx); + + // if chunk was trimmed, we have a new lastChunk + if (chunk.end !== end) { + if (this.lastChunk === chunk) { + this.lastChunk = chunk.next; + } + + this.byEnd[chunk.end] = chunk; + this.byStart[chunk.next.start] = chunk.next; + this.byEnd[chunk.next.end] = chunk.next; + } + + if (aborted) { return true; } + chunk = chunk.previous; + } while (chunk); + + return false; +}; + +MagicString.prototype.trimEnd = function trimEnd (charType) { + this.trimEndAborted(charType); + return this; +}; +MagicString.prototype.trimStartAborted = function trimStartAborted (charType) { + var rx = new RegExp('^' + (charType || '\\s') + '+'); + + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + + var chunk = this.firstChunk; + + do { + var end = chunk.end; + var aborted = chunk.trimStart(rx); + + if (chunk.end !== end) { + // special case... + if (chunk === this.lastChunk) { this.lastChunk = chunk.next; } + + this.byEnd[chunk.end] = chunk; + this.byStart[chunk.next.start] = chunk.next; + this.byEnd[chunk.next.end] = chunk.next; + } + + if (aborted) { return true; } + chunk = chunk.next; + } while (chunk); + + return false; +}; + +MagicString.prototype.trimStart = function trimStart (charType) { + this.trimStartAborted(charType); + return this; +}; + +var hasOwnProp = Object.prototype.hasOwnProperty; + +var Bundle = function Bundle(options) { + if ( options === void 0 ) options = {}; + + this.intro = options.intro || ''; + this.separator = options.separator !== undefined ? options.separator : '\n'; + this.sources = []; + this.uniqueSources = []; + this.uniqueSourceIndexByFilename = {}; +}; + +Bundle.prototype.addSource = function addSource (source) { + if (source instanceof MagicString) { + return this.addSource({ + content: source, + filename: source.filename, + separator: this.separator, + }); + } + + if (!isObject(source) || !source.content) { + throw new Error( + 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' + ); + } + + ['filename', 'indentExclusionRanges', 'separator'].forEach(function (option) { + if (!hasOwnProp.call(source, option)) { source[option] = source.content[option]; } + }); + + if (source.separator === undefined) { + // TODO there's a bunch of this sort of thing, needs cleaning up + source.separator = this.separator; + } + + if (source.filename) { + if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) { + this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length; + this.uniqueSources.push({ filename: source.filename, content: source.content.original }); + } else { + var uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]]; + if (source.content.original !== uniqueSource.content) { + throw new Error(("Illegal source: same filename (" + (source.filename) + "), different contents")); + } + } + } + + this.sources.push(source); + return this; +}; + +Bundle.prototype.append = function append (str, options) { + this.addSource({ + content: new MagicString(str), + separator: (options && options.separator) || '', + }); + + return this; +}; + +Bundle.prototype.clone = function clone () { + var bundle = new Bundle({ + intro: this.intro, + separator: this.separator, + }); + + this.sources.forEach(function (source) { + bundle.addSource({ + filename: source.filename, + content: source.content.clone(), + separator: source.separator, + }); + }); + + return bundle; +}; + +Bundle.prototype.generateDecodedMap = function generateDecodedMap (options) { + var this$1$1 = this; + if ( options === void 0 ) options = {}; + + var names = []; + this.sources.forEach(function (source) { + Object.keys(source.content.storedNames).forEach(function (name) { + if (!~names.indexOf(name)) { names.push(name); } + }); + }); + + var mappings = new Mappings(options.hires); + + if (this.intro) { + mappings.advance(this.intro); + } + + this.sources.forEach(function (source, i) { + if (i > 0) { + mappings.advance(this$1$1.separator); + } + + var sourceIndex = source.filename ? this$1$1.uniqueSourceIndexByFilename[source.filename] : -1; + var magicString = source.content; + var locate = getLocator(magicString.original); + + if (magicString.intro) { + mappings.advance(magicString.intro); + } + + magicString.firstChunk.eachNext(function (chunk) { + var loc = locate(chunk.start); + + if (chunk.intro.length) { mappings.advance(chunk.intro); } + + if (source.filename) { + if (chunk.edited) { + mappings.addEdit( + sourceIndex, + chunk.content, + loc, + chunk.storeName ? names.indexOf(chunk.original) : -1 + ); + } else { + mappings.addUneditedChunk( + sourceIndex, + chunk, + magicString.original, + loc, + magicString.sourcemapLocations + ); + } + } else { + mappings.advance(chunk.content); + } + + if (chunk.outro.length) { mappings.advance(chunk.outro); } + }); + + if (magicString.outro) { + mappings.advance(magicString.outro); + } + }); + + return { + file: options.file ? options.file.split(/[/\\]/).pop() : null, + sources: this.uniqueSources.map(function (source) { + return options.file ? getRelativePath(options.file, source.filename) : source.filename; + }), + sourcesContent: this.uniqueSources.map(function (source) { + return options.includeContent ? source.content : null; + }), + names: names, + mappings: mappings.raw, + }; +}; + +Bundle.prototype.generateMap = function generateMap (options) { + return new SourceMap(this.generateDecodedMap(options)); +}; + +Bundle.prototype.getIndentString = function getIndentString () { + var indentStringCounts = {}; + + this.sources.forEach(function (source) { + var indentStr = source.content.indentStr; + + if (indentStr === null) { return; } + + if (!indentStringCounts[indentStr]) { indentStringCounts[indentStr] = 0; } + indentStringCounts[indentStr] += 1; + }); + + return ( + Object.keys(indentStringCounts).sort(function (a, b) { + return indentStringCounts[a] - indentStringCounts[b]; + })[0] || '\t' + ); +}; + +Bundle.prototype.indent = function indent (indentStr) { + var this$1$1 = this; + + if (!arguments.length) { + indentStr = this.getIndentString(); + } + + if (indentStr === '') { return this; } // noop + + var trailingNewline = !this.intro || this.intro.slice(-1) === '\n'; + + this.sources.forEach(function (source, i) { + var separator = source.separator !== undefined ? source.separator : this$1$1.separator; + var indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator)); + + source.content.indent(indentStr, { + exclude: source.indentExclusionRanges, + indentStart: indentStart, //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator ) + }); + + trailingNewline = source.content.lastChar() === '\n'; + }); + + if (this.intro) { + this.intro = + indentStr + + this.intro.replace(/^[^\n]/gm, function (match, index) { + return index > 0 ? indentStr + match : match; + }); + } + + return this; +}; + +Bundle.prototype.prepend = function prepend (str) { + this.intro = str + this.intro; + return this; +}; + +Bundle.prototype.toString = function toString () { + var this$1$1 = this; + + var body = this.sources + .map(function (source, i) { + var separator = source.separator !== undefined ? source.separator : this$1$1.separator; + var str = (i > 0 ? separator : '') + source.content.toString(); + + return str; + }) + .join(''); + + return this.intro + body; +}; + +Bundle.prototype.isEmpty = function isEmpty () { + if (this.intro.length && this.intro.trim()) { return false; } + if (this.sources.some(function (source) { return !source.content.isEmpty(); })) { return false; } + return true; +}; + +Bundle.prototype.length = function length () { + return this.sources.reduce( + function (length, source) { return length + source.content.length(); }, + this.intro.length + ); +}; + +Bundle.prototype.trimLines = function trimLines () { + return this.trim('[\\r\\n]'); +}; + +Bundle.prototype.trim = function trim (charType) { + return this.trimStart(charType).trimEnd(charType); +}; + +Bundle.prototype.trimStart = function trimStart (charType) { + var rx = new RegExp('^' + (charType || '\\s') + '+'); + this.intro = this.intro.replace(rx, ''); + + if (!this.intro) { + var source; + var i = 0; + + do { + source = this.sources[i++]; + if (!source) { + break; + } + } while (!source.content.trimStartAborted(charType)); + } + + return this; +}; + +Bundle.prototype.trimEnd = function trimEnd (charType) { + var rx = new RegExp((charType || '\\s') + '+$'); + + var source; + var i = this.sources.length - 1; + + do { + source = this.sources[i--]; + if (!source) { + this.intro = this.intro.replace(rx, ''); + break; + } + } while (!source.content.trimEndAborted(charType)); + + return this; +}; + +MagicString.Bundle = Bundle; +MagicString.SourceMap = SourceMap; +MagicString.default = MagicString; // work around TypeScript bug https://github.com/Rich-Harris/magic-string/pull/121 + +module.exports = MagicString; +//# sourceMappingURL=magic-string.cjs.js.map diff --git a/node_modules/magic-string/dist/magic-string.cjs.js.map b/node_modules/magic-string/dist/magic-string.cjs.js.map new file mode 100644 index 0000000000000000000000000000000000000000..964c77e3e1bf7105c76a33a111c3a7ed4c4cd8a4 --- /dev/null +++ b/node_modules/magic-string/dist/magic-string.cjs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"magic-string.cjs.js","sources":["../src/BitSet.js","../src/Chunk.js","../src/SourceMap.js","../src/utils/guessIndent.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/getLocator.js","../src/utils/Mappings.js","../src/MagicString.js","../src/Bundle.js","../src/index-legacy.js"],"sourcesContent":["export default class BitSet {\n\tconstructor(arg) {\n\t\tthis.bits = arg instanceof BitSet ? arg.bits.slice() : [];\n\t}\n\n\tadd(n) {\n\t\tthis.bits[n >> 5] |= 1 << (n & 31);\n\t}\n\n\thas(n) {\n\t\treturn !!(this.bits[n >> 5] & (1 << (n & 31)));\n\t}\n}\n","export default class Chunk {\n\tconstructor(start, end, content) {\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t\tthis.original = content;\n\n\t\tthis.intro = '';\n\t\tthis.outro = '';\n\n\t\tthis.content = content;\n\t\tthis.storeName = false;\n\t\tthis.edited = false;\n\n\t\t// we make these non-enumerable, for sanity while debugging\n\t\tObject.defineProperties(this, {\n\t\t\tprevious: { writable: true, value: null },\n\t\t\tnext: { writable: true, value: null },\n\t\t});\n\t}\n\n\tappendLeft(content) {\n\t\tthis.outro += content;\n\t}\n\n\tappendRight(content) {\n\t\tthis.intro = this.intro + content;\n\t}\n\n\tclone() {\n\t\tconst chunk = new Chunk(this.start, this.end, this.original);\n\n\t\tchunk.intro = this.intro;\n\t\tchunk.outro = this.outro;\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t}\n\n\tcontains(index) {\n\t\treturn this.start < index && index < this.end;\n\t}\n\n\teachNext(fn) {\n\t\tlet chunk = this;\n\t\twhile (chunk) {\n\t\t\tfn(chunk);\n\t\t\tchunk = chunk.next;\n\t\t}\n\t}\n\n\teachPrevious(fn) {\n\t\tlet chunk = this;\n\t\twhile (chunk) {\n\t\t\tfn(chunk);\n\t\t\tchunk = chunk.previous;\n\t\t}\n\t}\n\n\tedit(content, storeName, contentOnly) {\n\t\tthis.content = content;\n\t\tif (!contentOnly) {\n\t\t\tthis.intro = '';\n\t\t\tthis.outro = '';\n\t\t}\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t}\n\n\tprependLeft(content) {\n\t\tthis.outro = content + this.outro;\n\t}\n\n\tprependRight(content) {\n\t\tthis.intro = content + this.intro;\n\t}\n\n\tsplit(index) {\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice(0, sliceIndex);\n\t\tconst originalAfter = this.original.slice(sliceIndex);\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk(index, this.end, originalAfter);\n\t\tnewChunk.outro = this.outro;\n\t\tthis.outro = '';\n\n\t\tthis.end = index;\n\n\t\tif (this.edited) {\n\t\t\t// TODO is this block necessary?...\n\t\t\tnewChunk.edit('', false);\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\tnewChunk.next = this.next;\n\t\tif (newChunk.next) newChunk.next.previous = newChunk;\n\t\tnewChunk.previous = this;\n\t\tthis.next = newChunk;\n\n\t\treturn newChunk;\n\t}\n\n\ttoString() {\n\t\treturn this.intro + this.content + this.outro;\n\t}\n\n\ttrimEnd(rx) {\n\t\tthis.outro = this.outro.replace(rx, '');\n\t\tif (this.outro.length) return true;\n\n\t\tconst trimmed = this.content.replace(rx, '');\n\n\t\tif (trimmed.length) {\n\t\t\tif (trimmed !== this.content) {\n\t\t\t\tthis.split(this.start + trimmed.length).edit('', undefined, true);\n\t\t\t}\n\t\t\treturn true;\n\t\t} else {\n\t\t\tthis.edit('', undefined, true);\n\n\t\t\tthis.intro = this.intro.replace(rx, '');\n\t\t\tif (this.intro.length) return true;\n\t\t}\n\t}\n\n\ttrimStart(rx) {\n\t\tthis.intro = this.intro.replace(rx, '');\n\t\tif (this.intro.length) return true;\n\n\t\tconst trimmed = this.content.replace(rx, '');\n\n\t\tif (trimmed.length) {\n\t\t\tif (trimmed !== this.content) {\n\t\t\t\tthis.split(this.end - trimmed.length);\n\t\t\t\tthis.edit('', undefined, true);\n\t\t\t}\n\t\t\treturn true;\n\t\t} else {\n\t\t\tthis.edit('', undefined, true);\n\n\t\t\tthis.outro = this.outro.replace(rx, '');\n\t\t\tif (this.outro.length) return true;\n\t\t}\n\t}\n}\n","import { encode } from 'sourcemap-codec';\n\nlet btoa = () => {\n\tthrow new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');\n};\nif (typeof window !== 'undefined' && typeof window.btoa === 'function') {\n\tbtoa = (str) => window.btoa(unescape(encodeURIComponent(str)));\n} else if (typeof Buffer === 'function') {\n\tbtoa = (str) => Buffer.from(str, 'utf-8').toString('base64');\n}\n\nexport default class SourceMap {\n\tconstructor(properties) {\n\t\tthis.version = 3;\n\t\tthis.file = properties.file;\n\t\tthis.sources = properties.sources;\n\t\tthis.sourcesContent = properties.sourcesContent;\n\t\tthis.names = properties.names;\n\t\tthis.mappings = encode(properties.mappings);\n\t}\n\n\ttoString() {\n\t\treturn JSON.stringify(this);\n\t}\n\n\ttoUrl() {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());\n\t}\n}\n","export default function guessIndent(code) {\n\tconst lines = code.split('\\n');\n\n\tconst tabbed = lines.filter((line) => /^\\t+/.test(line));\n\tconst spaced = lines.filter((line) => /^ {2,}/.test(line));\n\n\tif (tabbed.length === 0 && spaced.length === 0) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif (tabbed.length >= spaced.length) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce((previous, current) => {\n\t\tconst numSpaces = /^ +/.exec(current)[0].length;\n\t\treturn Math.min(numSpaces, previous);\n\t}, Infinity);\n\n\treturn new Array(min + 1).join(' ');\n}\n","export default function getRelativePath(from, to) {\n\tconst fromParts = from.split(/[/\\\\]/);\n\tconst toParts = to.split(/[/\\\\]/);\n\n\tfromParts.pop(); // get dirname\n\n\twhile (fromParts[0] === toParts[0]) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif (fromParts.length) {\n\t\tlet i = fromParts.length;\n\t\twhile (i--) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat(toParts).join('/');\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject(thing) {\n\treturn toString.call(thing) === '[object Object]';\n}\n","export default function getLocator(source) {\n\tconst originalLines = source.split('\\n');\n\tconst lineOffsets = [];\n\n\tfor (let i = 0, pos = 0; i < originalLines.length; i++) {\n\t\tlineOffsets.push(pos);\n\t\tpos += originalLines[i].length + 1;\n\t}\n\n\treturn function locate(index) {\n\t\tlet i = 0;\n\t\tlet j = lineOffsets.length;\n\t\twhile (i < j) {\n\t\t\tconst m = (i + j) >> 1;\n\t\t\tif (index < lineOffsets[m]) {\n\t\t\t\tj = m;\n\t\t\t} else {\n\t\t\t\ti = m + 1;\n\t\t\t}\n\t\t}\n\t\tconst line = i - 1;\n\t\tconst column = index - lineOffsets[line];\n\t\treturn { line, column };\n\t};\n}\n","export default class Mappings {\n\tconstructor(hires) {\n\t\tthis.hires = hires;\n\t\tthis.generatedCodeLine = 0;\n\t\tthis.generatedCodeColumn = 0;\n\t\tthis.raw = [];\n\t\tthis.rawSegments = this.raw[this.generatedCodeLine] = [];\n\t\tthis.pending = null;\n\t}\n\n\taddEdit(sourceIndex, content, loc, nameIndex) {\n\t\tif (content.length) {\n\t\t\tconst segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];\n\t\t\tif (nameIndex >= 0) {\n\t\t\t\tsegment.push(nameIndex);\n\t\t\t}\n\t\t\tthis.rawSegments.push(segment);\n\t\t} else if (this.pending) {\n\t\t\tthis.rawSegments.push(this.pending);\n\t\t}\n\n\t\tthis.advance(content);\n\t\tthis.pending = null;\n\t}\n\n\taddUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {\n\t\tlet originalCharIndex = chunk.start;\n\t\tlet first = true;\n\n\t\twhile (originalCharIndex < chunk.end) {\n\t\t\tif (this.hires || first || sourcemapLocations.has(originalCharIndex)) {\n\t\t\t\tthis.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);\n\t\t\t}\n\n\t\t\tif (original[originalCharIndex] === '\\n') {\n\t\t\t\tloc.line += 1;\n\t\t\t\tloc.column = 0;\n\t\t\t\tthis.generatedCodeLine += 1;\n\t\t\t\tthis.raw[this.generatedCodeLine] = this.rawSegments = [];\n\t\t\t\tthis.generatedCodeColumn = 0;\n\t\t\t\tfirst = true;\n\t\t\t} else {\n\t\t\t\tloc.column += 1;\n\t\t\t\tthis.generatedCodeColumn += 1;\n\t\t\t\tfirst = false;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t}\n\n\t\tthis.pending = null;\n\t}\n\n\tadvance(str) {\n\t\tif (!str) return;\n\n\t\tconst lines = str.split('\\n');\n\n\t\tif (lines.length > 1) {\n\t\t\tfor (let i = 0; i < lines.length - 1; i++) {\n\t\t\t\tthis.generatedCodeLine++;\n\t\t\t\tthis.raw[this.generatedCodeLine] = this.rawSegments = [];\n\t\t\t}\n\t\t\tthis.generatedCodeColumn = 0;\n\t\t}\n\n\t\tthis.generatedCodeColumn += lines[lines.length - 1].length;\n\t}\n}\n","import BitSet from './BitSet.js';\nimport Chunk from './Chunk.js';\nimport SourceMap from './SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport getLocator from './utils/getLocator.js';\nimport Mappings from './utils/Mappings.js';\nimport Stats from './utils/Stats.js';\n\nconst n = '\\n';\n\nconst warned = {\n\tinsertLeft: false,\n\tinsertRight: false,\n\tstoreName: false,\n};\n\nexport default class MagicString {\n\tconstructor(string, options = {}) {\n\t\tconst chunk = new Chunk(0, string.length, string);\n\n\t\tObject.defineProperties(this, {\n\t\t\toriginal: { writable: true, value: string },\n\t\t\toutro: { writable: true, value: '' },\n\t\t\tintro: { writable: true, value: '' },\n\t\t\tfirstChunk: { writable: true, value: chunk },\n\t\t\tlastChunk: { writable: true, value: chunk },\n\t\t\tlastSearchedChunk: { writable: true, value: chunk },\n\t\t\tbyStart: { writable: true, value: {} },\n\t\t\tbyEnd: { writable: true, value: {} },\n\t\t\tfilename: { writable: true, value: options.filename },\n\t\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\t\tsourcemapLocations: { writable: true, value: new BitSet() },\n\t\t\tstoredNames: { writable: true, value: {} },\n\t\t\tindentStr: { writable: true, value: guessIndent(string) },\n\t\t});\n\n\t\tif (DEBUG) {\n\t\t\tObject.defineProperty(this, 'stats', { value: new Stats() });\n\t\t}\n\n\t\tthis.byStart[0] = chunk;\n\t\tthis.byEnd[string.length] = chunk;\n\t}\n\n\taddSourcemapLocation(char) {\n\t\tthis.sourcemapLocations.add(char);\n\t}\n\n\tappend(content) {\n\t\tif (typeof content !== 'string') throw new TypeError('outro content must be a string');\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t}\n\n\tappendLeft(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('appendLeft');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byEnd[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.appendLeft(content);\n\t\t} else {\n\t\t\tthis.intro += content;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('appendLeft');\n\t\treturn this;\n\t}\n\n\tappendRight(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('appendRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byStart[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.appendRight(content);\n\t\t} else {\n\t\t\tthis.outro += content;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('appendRight');\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\tconst cloned = new MagicString(this.original, { filename: this.filename });\n\n\t\tlet originalChunk = this.firstChunk;\n\t\tlet clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());\n\n\t\twhile (originalChunk) {\n\t\t\tcloned.byStart[clonedChunk.start] = clonedChunk;\n\t\t\tcloned.byEnd[clonedChunk.end] = clonedChunk;\n\n\t\t\tconst nextOriginalChunk = originalChunk.next;\n\t\t\tconst nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();\n\n\t\t\tif (nextClonedChunk) {\n\t\t\t\tclonedChunk.next = nextClonedChunk;\n\t\t\t\tnextClonedChunk.previous = clonedChunk;\n\n\t\t\t\tclonedChunk = nextClonedChunk;\n\t\t\t}\n\n\t\t\toriginalChunk = nextOriginalChunk;\n\t\t}\n\n\t\tcloned.lastChunk = clonedChunk;\n\n\t\tif (this.indentExclusionRanges) {\n\t\t\tcloned.indentExclusionRanges = this.indentExclusionRanges.slice();\n\t\t}\n\n\t\tcloned.sourcemapLocations = new BitSet(this.sourcemapLocations);\n\n\t\tcloned.intro = this.intro;\n\t\tcloned.outro = this.outro;\n\n\t\treturn cloned;\n\t}\n\n\tgenerateDecodedMap(options) {\n\t\toptions = options || {};\n\n\t\tconst sourceIndex = 0;\n\t\tconst names = Object.keys(this.storedNames);\n\t\tconst mappings = new Mappings(options.hires);\n\n\t\tconst locate = getLocator(this.original);\n\n\t\tif (this.intro) {\n\t\t\tmappings.advance(this.intro);\n\t\t}\n\n\t\tthis.firstChunk.eachNext((chunk) => {\n\t\t\tconst loc = locate(chunk.start);\n\n\t\t\tif (chunk.intro.length) mappings.advance(chunk.intro);\n\n\t\t\tif (chunk.edited) {\n\t\t\t\tmappings.addEdit(\n\t\t\t\t\tsourceIndex,\n\t\t\t\t\tchunk.content,\n\t\t\t\t\tloc,\n\t\t\t\t\tchunk.storeName ? names.indexOf(chunk.original) : -1\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tmappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);\n\t\t\t}\n\n\t\t\tif (chunk.outro.length) mappings.advance(chunk.outro);\n\t\t});\n\n\t\treturn {\n\t\t\tfile: options.file ? options.file.split(/[/\\\\]/).pop() : null,\n\t\t\tsources: [options.source ? getRelativePath(options.file || '', options.source) : null],\n\t\t\tsourcesContent: options.includeContent ? [this.original] : [null],\n\t\t\tnames,\n\t\t\tmappings: mappings.raw,\n\t\t};\n\t}\n\n\tgenerateMap(options) {\n\t\treturn new SourceMap(this.generateDecodedMap(options));\n\t}\n\n\tgetIndentString() {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t}\n\n\tindent(indentStr, options) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif (isObject(indentStr)) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : this.indentStr || '\\t';\n\n\t\tif (indentStr === '') return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tconst isExcluded = {};\n\n\t\tif (options.exclude) {\n\t\t\tconst exclusions =\n\t\t\t\ttypeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;\n\t\t\texclusions.forEach((exclusion) => {\n\t\t\t\tfor (let i = exclusion[0]; i < exclusion[1]; i += 1) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = (match) => {\n\t\t\tif (shouldIndentNextCharacter) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace(pattern, replacer);\n\n\t\tlet charIndex = 0;\n\t\tlet chunk = this.firstChunk;\n\n\t\twhile (chunk) {\n\t\t\tconst end = chunk.end;\n\n\t\t\tif (chunk.edited) {\n\t\t\t\tif (!isExcluded[charIndex]) {\n\t\t\t\t\tchunk.content = chunk.content.replace(pattern, replacer);\n\n\t\t\t\t\tif (chunk.content.length) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile (charIndex < end) {\n\t\t\t\t\tif (!isExcluded[charIndex]) {\n\t\t\t\t\t\tconst char = this.original[charIndex];\n\n\t\t\t\t\t\tif (char === '\\n') {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if (char !== '\\r' && shouldIndentNextCharacter) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tif (charIndex === chunk.start) {\n\t\t\t\t\t\t\t\tchunk.prependRight(indentStr);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis._splitChunk(chunk, charIndex);\n\t\t\t\t\t\t\t\tchunk = chunk.next;\n\t\t\t\t\t\t\t\tchunk.prependRight(indentStr);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\tthis.outro = this.outro.replace(pattern, replacer);\n\n\t\treturn this;\n\t}\n\n\tinsert() {\n\t\tthrow new Error(\n\t\t\t'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'\n\t\t);\n\t}\n\n\tinsertLeft(index, content) {\n\t\tif (!warned.insertLeft) {\n\t\t\tconsole.warn(\n\t\t\t\t'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'\n\t\t\t); // eslint-disable-line no-console\n\t\t\twarned.insertLeft = true;\n\t\t}\n\n\t\treturn this.appendLeft(index, content);\n\t}\n\n\tinsertRight(index, content) {\n\t\tif (!warned.insertRight) {\n\t\t\tconsole.warn(\n\t\t\t\t'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'\n\t\t\t); // eslint-disable-line no-console\n\t\t\twarned.insertRight = true;\n\t\t}\n\n\t\treturn this.prependRight(index, content);\n\t}\n\n\tmove(start, end, index) {\n\t\tif (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');\n\n\t\tif (DEBUG) this.stats.time('move');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\t\tthis._split(index);\n\n\t\tconst first = this.byStart[start];\n\t\tconst last = this.byEnd[end];\n\n\t\tconst oldLeft = first.previous;\n\t\tconst oldRight = last.next;\n\n\t\tconst newRight = this.byStart[index];\n\t\tif (!newRight && last === this.lastChunk) return this;\n\t\tconst newLeft = newRight ? newRight.previous : this.lastChunk;\n\n\t\tif (oldLeft) oldLeft.next = oldRight;\n\t\tif (oldRight) oldRight.previous = oldLeft;\n\n\t\tif (newLeft) newLeft.next = first;\n\t\tif (newRight) newRight.previous = last;\n\n\t\tif (!first.previous) this.firstChunk = last.next;\n\t\tif (!last.next) {\n\t\t\tthis.lastChunk = first.previous;\n\t\t\tthis.lastChunk.next = null;\n\t\t}\n\n\t\tfirst.previous = newLeft;\n\t\tlast.next = newRight || null;\n\n\t\tif (!newLeft) this.firstChunk = first;\n\t\tif (!newRight) this.lastChunk = last;\n\n\t\tif (DEBUG) this.stats.timeEnd('move');\n\t\treturn this;\n\t}\n\n\toverwrite(start, end, content, options) {\n\t\tif (typeof content !== 'string') throw new TypeError('replacement content must be a string');\n\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tif (end > this.original.length) throw new Error('end is out of bounds');\n\t\tif (start === end)\n\t\t\tthrow new Error(\n\t\t\t\t'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'\n\t\t\t);\n\n\t\tif (DEBUG) this.stats.time('overwrite');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\n\t\tif (options === true) {\n\t\t\tif (!warned.storeName) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'\n\t\t\t\t); // eslint-disable-line no-console\n\t\t\t\twarned.storeName = true;\n\t\t\t}\n\n\t\t\toptions = { storeName: true };\n\t\t}\n\t\tconst storeName = options !== undefined ? options.storeName : false;\n\t\tconst contentOnly = options !== undefined ? options.contentOnly : false;\n\n\t\tif (storeName) {\n\t\t\tconst original = this.original.slice(start, end);\n\t\t\tObject.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true });\n\t\t}\n\n\t\tconst first = this.byStart[start];\n\t\tconst last = this.byEnd[end];\n\n\t\tif (first) {\n\t\t\tlet chunk = first;\n\t\t\twhile (chunk !== last) {\n\t\t\t\tif (chunk.next !== this.byStart[chunk.end]) {\n\t\t\t\t\tthrow new Error('Cannot overwrite across a split point');\n\t\t\t\t}\n\t\t\t\tchunk = chunk.next;\n\t\t\t\tchunk.edit('', false);\n\t\t\t}\n\n\t\t\tfirst.edit(content, storeName, contentOnly);\n\t\t} else {\n\t\t\t// must be inserting at the end\n\t\t\tconst newChunk = new Chunk(start, end, '').edit(content, storeName);\n\n\t\t\t// TODO last chunk in the array may not be the last chunk, if it's moved...\n\t\t\tlast.next = newChunk;\n\t\t\tnewChunk.previous = last;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('overwrite');\n\t\treturn this;\n\t}\n\n\tprepend(content) {\n\t\tif (typeof content !== 'string') throw new TypeError('outro content must be a string');\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t}\n\n\tprependLeft(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('insertRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byEnd[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.prependLeft(content);\n\t\t} else {\n\t\t\tthis.intro = content + this.intro;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('insertRight');\n\t\treturn this;\n\t}\n\n\tprependRight(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('insertRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byStart[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.prependRight(content);\n\t\t} else {\n\t\t\tthis.outro = content + this.outro;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('insertRight');\n\t\treturn this;\n\t}\n\n\tremove(start, end) {\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tif (start === end) return this;\n\n\t\tif (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');\n\t\tif (start > end) throw new Error('end must be greater than start');\n\n\t\tif (DEBUG) this.stats.time('remove');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\n\t\tlet chunk = this.byStart[start];\n\n\t\twhile (chunk) {\n\t\t\tchunk.intro = '';\n\t\t\tchunk.outro = '';\n\t\t\tchunk.edit('');\n\n\t\t\tchunk = end > chunk.end ? this.byStart[chunk.end] : null;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('remove');\n\t\treturn this;\n\t}\n\n\tlastChar() {\n\t\tif (this.outro.length) return this.outro[this.outro.length - 1];\n\t\tlet chunk = this.lastChunk;\n\t\tdo {\n\t\t\tif (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];\n\t\t\tif (chunk.content.length) return chunk.content[chunk.content.length - 1];\n\t\t\tif (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];\n\t\t} while ((chunk = chunk.previous));\n\t\tif (this.intro.length) return this.intro[this.intro.length - 1];\n\t\treturn '';\n\t}\n\n\tlastLine() {\n\t\tlet lineIndex = this.outro.lastIndexOf(n);\n\t\tif (lineIndex !== -1) return this.outro.substr(lineIndex + 1);\n\t\tlet lineStr = this.outro;\n\t\tlet chunk = this.lastChunk;\n\t\tdo {\n\t\t\tif (chunk.outro.length > 0) {\n\t\t\t\tlineIndex = chunk.outro.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.outro + lineStr;\n\t\t\t}\n\n\t\t\tif (chunk.content.length > 0) {\n\t\t\t\tlineIndex = chunk.content.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.content + lineStr;\n\t\t\t}\n\n\t\t\tif (chunk.intro.length > 0) {\n\t\t\t\tlineIndex = chunk.intro.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.intro + lineStr;\n\t\t\t}\n\t\t} while ((chunk = chunk.previous));\n\t\tlineIndex = this.intro.lastIndexOf(n);\n\t\tif (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;\n\t\treturn this.intro + lineStr;\n\t}\n\n\tslice(start = 0, end = this.original.length) {\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\t// find start chunk\n\t\tlet chunk = this.firstChunk;\n\t\twhile (chunk && (chunk.start > start || chunk.end <= start)) {\n\t\t\t// found end chunk before start\n\t\t\tif (chunk.start < end && chunk.end >= end) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\tif (chunk && chunk.edited && chunk.start !== start)\n\t\t\tthrow new Error(`Cannot use replaced character ${start} as slice start anchor.`);\n\n\t\tconst startChunk = chunk;\n\t\twhile (chunk) {\n\t\t\tif (chunk.intro && (startChunk !== chunk || chunk.start === start)) {\n\t\t\t\tresult += chunk.intro;\n\t\t\t}\n\n\t\t\tconst containsEnd = chunk.start < end && chunk.end >= end;\n\t\t\tif (containsEnd && chunk.edited && chunk.end !== end)\n\t\t\t\tthrow new Error(`Cannot use replaced character ${end} as slice end anchor.`);\n\n\t\t\tconst sliceStart = startChunk === chunk ? start - chunk.start : 0;\n\t\t\tconst sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;\n\n\t\t\tresult += chunk.content.slice(sliceStart, sliceEnd);\n\n\t\t\tif (chunk.outro && (!containsEnd || chunk.end === end)) {\n\t\t\t\tresult += chunk.outro;\n\t\t\t}\n\n\t\t\tif (containsEnd) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// TODO deprecate this? not really very useful\n\tsnip(start, end) {\n\t\tconst clone = this.clone();\n\t\tclone.remove(0, start);\n\t\tclone.remove(end, clone.original.length);\n\n\t\treturn clone;\n\t}\n\n\t_split(index) {\n\t\tif (this.byStart[index] || this.byEnd[index]) return;\n\n\t\tif (DEBUG) this.stats.time('_split');\n\n\t\tlet chunk = this.lastSearchedChunk;\n\t\tconst searchForward = index > chunk.end;\n\n\t\twhile (chunk) {\n\t\t\tif (chunk.contains(index)) return this._splitChunk(chunk, index);\n\n\t\t\tchunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];\n\t\t}\n\t}\n\n\t_splitChunk(chunk, index) {\n\t\tif (chunk.edited && chunk.content.length) {\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tconst loc = getLocator(this.original)(index);\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – \"${chunk.original}\")`\n\t\t\t);\n\t\t}\n\n\t\tconst newChunk = chunk.split(index);\n\n\t\tthis.byEnd[index] = chunk;\n\t\tthis.byStart[index] = newChunk;\n\t\tthis.byEnd[newChunk.end] = newChunk;\n\n\t\tif (chunk === this.lastChunk) this.lastChunk = newChunk;\n\n\t\tthis.lastSearchedChunk = chunk;\n\t\tif (DEBUG) this.stats.timeEnd('_split');\n\t\treturn true;\n\t}\n\n\ttoString() {\n\t\tlet str = this.intro;\n\n\t\tlet chunk = this.firstChunk;\n\t\twhile (chunk) {\n\t\t\tstr += chunk.toString();\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\treturn str + this.outro;\n\t}\n\n\tisEmpty() {\n\t\tlet chunk = this.firstChunk;\n\t\tdo {\n\t\t\tif (\n\t\t\t\t(chunk.intro.length && chunk.intro.trim()) ||\n\t\t\t\t(chunk.content.length && chunk.content.trim()) ||\n\t\t\t\t(chunk.outro.length && chunk.outro.trim())\n\t\t\t)\n\t\t\t\treturn false;\n\t\t} while ((chunk = chunk.next));\n\t\treturn true;\n\t}\n\n\tlength() {\n\t\tlet chunk = this.firstChunk;\n\t\tlet length = 0;\n\t\tdo {\n\t\t\tlength += chunk.intro.length + chunk.content.length + chunk.outro.length;\n\t\t} while ((chunk = chunk.next));\n\t\treturn length;\n\t}\n\n\ttrimLines() {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t}\n\n\ttrim(charType) {\n\t\treturn this.trimStart(charType).trimEnd(charType);\n\t}\n\n\ttrimEndAborted(charType) {\n\t\tconst rx = new RegExp((charType || '\\\\s') + '+$');\n\n\t\tthis.outro = this.outro.replace(rx, '');\n\t\tif (this.outro.length) return true;\n\n\t\tlet chunk = this.lastChunk;\n\n\t\tdo {\n\t\t\tconst end = chunk.end;\n\t\t\tconst aborted = chunk.trimEnd(rx);\n\n\t\t\t// if chunk was trimmed, we have a new lastChunk\n\t\t\tif (chunk.end !== end) {\n\t\t\t\tif (this.lastChunk === chunk) {\n\t\t\t\t\tthis.lastChunk = chunk.next;\n\t\t\t\t}\n\n\t\t\t\tthis.byEnd[chunk.end] = chunk;\n\t\t\t\tthis.byStart[chunk.next.start] = chunk.next;\n\t\t\t\tthis.byEnd[chunk.next.end] = chunk.next;\n\t\t\t}\n\n\t\t\tif (aborted) return true;\n\t\t\tchunk = chunk.previous;\n\t\t} while (chunk);\n\n\t\treturn false;\n\t}\n\n\ttrimEnd(charType) {\n\t\tthis.trimEndAborted(charType);\n\t\treturn this;\n\t}\n\ttrimStartAborted(charType) {\n\t\tconst rx = new RegExp('^' + (charType || '\\\\s') + '+');\n\n\t\tthis.intro = this.intro.replace(rx, '');\n\t\tif (this.intro.length) return true;\n\n\t\tlet chunk = this.firstChunk;\n\n\t\tdo {\n\t\t\tconst end = chunk.end;\n\t\t\tconst aborted = chunk.trimStart(rx);\n\n\t\t\tif (chunk.end !== end) {\n\t\t\t\t// special case...\n\t\t\t\tif (chunk === this.lastChunk) this.lastChunk = chunk.next;\n\n\t\t\t\tthis.byEnd[chunk.end] = chunk;\n\t\t\t\tthis.byStart[chunk.next.start] = chunk.next;\n\t\t\t\tthis.byEnd[chunk.next.end] = chunk.next;\n\t\t\t}\n\n\t\t\tif (aborted) return true;\n\t\t\tchunk = chunk.next;\n\t\t} while (chunk);\n\n\t\treturn false;\n\t}\n\n\ttrimStart(charType) {\n\t\tthis.trimStartAborted(charType);\n\t\treturn this;\n\t}\n}\n","import MagicString from './MagicString.js';\nimport SourceMap from './SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport getLocator from './utils/getLocator.js';\nimport Mappings from './utils/Mappings.js';\n\nconst hasOwnProp = Object.prototype.hasOwnProperty;\n\nexport default class Bundle {\n\tconstructor(options = {}) {\n\t\tthis.intro = options.intro || '';\n\t\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\t\tthis.sources = [];\n\t\tthis.uniqueSources = [];\n\t\tthis.uniqueSourceIndexByFilename = {};\n\t}\n\n\taddSource(source) {\n\t\tif (source instanceof MagicString) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator,\n\t\t\t});\n\t\t}\n\n\t\tif (!isObject(source) || !source.content) {\n\t\t\tthrow new Error(\n\t\t\t\t'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`'\n\t\t\t);\n\t\t}\n\n\t\t['filename', 'indentExclusionRanges', 'separator'].forEach((option) => {\n\t\t\tif (!hasOwnProp.call(source, option)) source[option] = source.content[option];\n\t\t});\n\n\t\tif (source.separator === undefined) {\n\t\t\t// TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif (source.filename) {\n\t\t\tif (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];\n\t\t\t\tif (source.content.original !== uniqueSource.content) {\n\t\t\t\t\tthrow new Error(`Illegal source: same filename (${source.filename}), different contents`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push(source);\n\t\treturn this;\n\t}\n\n\tappend(str, options) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString(str),\n\t\t\tseparator: (options && options.separator) || '',\n\t\t});\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator,\n\t\t});\n\n\t\tthis.sources.forEach((source) => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator,\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t}\n\n\tgenerateDecodedMap(options = {}) {\n\t\tconst names = [];\n\t\tthis.sources.forEach((source) => {\n\t\t\tObject.keys(source.content.storedNames).forEach((name) => {\n\t\t\t\tif (!~names.indexOf(name)) names.push(name);\n\t\t\t});\n\t\t});\n\n\t\tconst mappings = new Mappings(options.hires);\n\n\t\tif (this.intro) {\n\t\t\tmappings.advance(this.intro);\n\t\t}\n\n\t\tthis.sources.forEach((source, i) => {\n\t\t\tif (i > 0) {\n\t\t\t\tmappings.advance(this.separator);\n\t\t\t}\n\n\t\t\tconst sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;\n\t\t\tconst magicString = source.content;\n\t\t\tconst locate = getLocator(magicString.original);\n\n\t\t\tif (magicString.intro) {\n\t\t\t\tmappings.advance(magicString.intro);\n\t\t\t}\n\n\t\t\tmagicString.firstChunk.eachNext((chunk) => {\n\t\t\t\tconst loc = locate(chunk.start);\n\n\t\t\t\tif (chunk.intro.length) mappings.advance(chunk.intro);\n\n\t\t\t\tif (source.filename) {\n\t\t\t\t\tif (chunk.edited) {\n\t\t\t\t\t\tmappings.addEdit(\n\t\t\t\t\t\t\tsourceIndex,\n\t\t\t\t\t\t\tchunk.content,\n\t\t\t\t\t\t\tloc,\n\t\t\t\t\t\t\tchunk.storeName ? names.indexOf(chunk.original) : -1\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmappings.addUneditedChunk(\n\t\t\t\t\t\t\tsourceIndex,\n\t\t\t\t\t\t\tchunk,\n\t\t\t\t\t\t\tmagicString.original,\n\t\t\t\t\t\t\tloc,\n\t\t\t\t\t\t\tmagicString.sourcemapLocations\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmappings.advance(chunk.content);\n\t\t\t\t}\n\n\t\t\t\tif (chunk.outro.length) mappings.advance(chunk.outro);\n\t\t\t});\n\n\t\t\tif (magicString.outro) {\n\t\t\t\tmappings.advance(magicString.outro);\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tfile: options.file ? options.file.split(/[/\\\\]/).pop() : null,\n\t\t\tsources: this.uniqueSources.map((source) => {\n\t\t\t\treturn options.file ? getRelativePath(options.file, source.filename) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map((source) => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: mappings.raw,\n\t\t};\n\t}\n\n\tgenerateMap(options) {\n\t\treturn new SourceMap(this.generateDecodedMap(options));\n\t}\n\n\tgetIndentString() {\n\t\tconst indentStringCounts = {};\n\n\t\tthis.sources.forEach((source) => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif (indentStr === null) return;\n\n\t\t\tif (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;\n\t\t\tindentStringCounts[indentStr] += 1;\n\t\t});\n\n\t\treturn (\n\t\t\tObject.keys(indentStringCounts).sort((a, b) => {\n\t\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t\t})[0] || '\\t'\n\t\t);\n\t}\n\n\tindent(indentStr) {\n\t\tif (!arguments.length) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif (indentStr === '') return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice(-1) === '\\n';\n\n\t\tthis.sources.forEach((source, i) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || (i > 0 && /\\r?\\n$/.test(separator));\n\n\t\t\tsource.content.indent(indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart, //: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\ttrailingNewline = source.content.lastChar() === '\\n';\n\t\t});\n\n\t\tif (this.intro) {\n\t\t\tthis.intro =\n\t\t\t\tindentStr +\n\t\t\t\tthis.intro.replace(/^[^\\n]/gm, (match, index) => {\n\t\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tprepend(str) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t}\n\n\ttoString() {\n\t\tconst body = this.sources\n\t\t\t.map((source, i) => {\n\t\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\t\tconst str = (i > 0 ? separator : '') + source.content.toString();\n\n\t\t\t\treturn str;\n\t\t\t})\n\t\t\t.join('');\n\n\t\treturn this.intro + body;\n\t}\n\n\tisEmpty() {\n\t\tif (this.intro.length && this.intro.trim()) return false;\n\t\tif (this.sources.some((source) => !source.content.isEmpty())) return false;\n\t\treturn true;\n\t}\n\n\tlength() {\n\t\treturn this.sources.reduce(\n\t\t\t(length, source) => length + source.content.length(),\n\t\t\tthis.intro.length\n\t\t);\n\t}\n\n\ttrimLines() {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t}\n\n\ttrim(charType) {\n\t\treturn this.trimStart(charType).trimEnd(charType);\n\t}\n\n\ttrimStart(charType) {\n\t\tconst rx = new RegExp('^' + (charType || '\\\\s') + '+');\n\t\tthis.intro = this.intro.replace(rx, '');\n\n\t\tif (!this.intro) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i++];\n\t\t\t\tif (!source) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} while (!source.content.trimStartAborted(charType));\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttrimEnd(charType) {\n\t\tconst rx = new RegExp((charType || '\\\\s') + '+$');\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i--];\n\t\t\tif (!source) {\n\t\t\t\tthis.intro = this.intro.replace(rx, '');\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (!source.content.trimEndAborted(charType));\n\n\t\treturn this;\n\t}\n}\n","import MagicString from './MagicString.js';\nimport Bundle from './Bundle.js';\nimport SourceMap from './SourceMap.js';\n\nMagicString.Bundle = Bundle;\nMagicString.SourceMap = SourceMap;\nMagicString.default = MagicString; // work around TypeScript bug https://github.com/Rich-Harris/magic-string/pull/121\n\nexport default MagicString;\n"],"names":["const","let","encode","this"],"mappings":";;;;AAAe,IAAM,MAAM,GAC1B,eAAW,CAAC,GAAG,EAAE;AAClB,CAAE,IAAI,CAAC,IAAI,GAAG,GAAG,YAAY,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;AAC3D,EAAC;AACF;iBACC,oBAAI,CAAC,EAAE;AACR,CAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AACpC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AE,GAAG,IAAI,MAAM,CAAC,CAAC,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC;AACpD;AACA,CAAEC,IAAI,MAAM,CAAC;AACb,CAAEA,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AAClC;AACA,CAAE,GAAG;AACL,EAAG,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;AAC9B,EAAG,IAAI,CAAC,MAAM,EAAE;AAChB,GAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5C,GAAI,MAAM;AACV,GAAI;AACJ,EAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;AACrD;AACA,CAAE,OAAO,IAAI,CAAC;AACb;;AC1RD,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;AAC5B,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;AAClC,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC;;;;"} \ No newline at end of file diff --git a/node_modules/magic-string/dist/magic-string.es.js b/node_modules/magic-string/dist/magic-string.es.js new file mode 100644 index 0000000000000000000000000000000000000000..f6b409a6736a506f18ca9b4e57d98bed8b843527 --- /dev/null +++ b/node_modules/magic-string/dist/magic-string.es.js @@ -0,0 +1,1305 @@ +import { encode } from 'sourcemap-codec'; + +var BitSet = function BitSet(arg) { + this.bits = arg instanceof BitSet ? arg.bits.slice() : []; +}; + +BitSet.prototype.add = function add (n) { + this.bits[n >> 5] |= 1 << (n & 31); +}; + +BitSet.prototype.has = function has (n) { + return !!(this.bits[n >> 5] & (1 << (n & 31))); +}; + +var Chunk = function Chunk(start, end, content) { + this.start = start; + this.end = end; + this.original = content; + + this.intro = ''; + this.outro = ''; + + this.content = content; + this.storeName = false; + this.edited = false; + + // we make these non-enumerable, for sanity while debugging + Object.defineProperties(this, { + previous: { writable: true, value: null }, + next: { writable: true, value: null }, + }); +}; + +Chunk.prototype.appendLeft = function appendLeft (content) { + this.outro += content; +}; + +Chunk.prototype.appendRight = function appendRight (content) { + this.intro = this.intro + content; +}; + +Chunk.prototype.clone = function clone () { + var chunk = new Chunk(this.start, this.end, this.original); + + chunk.intro = this.intro; + chunk.outro = this.outro; + chunk.content = this.content; + chunk.storeName = this.storeName; + chunk.edited = this.edited; + + return chunk; +}; + +Chunk.prototype.contains = function contains (index) { + return this.start < index && index < this.end; +}; + +Chunk.prototype.eachNext = function eachNext (fn) { + var chunk = this; + while (chunk) { + fn(chunk); + chunk = chunk.next; + } +}; + +Chunk.prototype.eachPrevious = function eachPrevious (fn) { + var chunk = this; + while (chunk) { + fn(chunk); + chunk = chunk.previous; + } +}; + +Chunk.prototype.edit = function edit (content, storeName, contentOnly) { + this.content = content; + if (!contentOnly) { + this.intro = ''; + this.outro = ''; + } + this.storeName = storeName; + + this.edited = true; + + return this; +}; + +Chunk.prototype.prependLeft = function prependLeft (content) { + this.outro = content + this.outro; +}; + +Chunk.prototype.prependRight = function prependRight (content) { + this.intro = content + this.intro; +}; + +Chunk.prototype.split = function split (index) { + var sliceIndex = index - this.start; + + var originalBefore = this.original.slice(0, sliceIndex); + var originalAfter = this.original.slice(sliceIndex); + + this.original = originalBefore; + + var newChunk = new Chunk(index, this.end, originalAfter); + newChunk.outro = this.outro; + this.outro = ''; + + this.end = index; + + if (this.edited) { + // TODO is this block necessary?... + newChunk.edit('', false); + this.content = ''; + } else { + this.content = originalBefore; + } + + newChunk.next = this.next; + if (newChunk.next) { newChunk.next.previous = newChunk; } + newChunk.previous = this; + this.next = newChunk; + + return newChunk; +}; + +Chunk.prototype.toString = function toString () { + return this.intro + this.content + this.outro; +}; + +Chunk.prototype.trimEnd = function trimEnd (rx) { + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + + var trimmed = this.content.replace(rx, ''); + + if (trimmed.length) { + if (trimmed !== this.content) { + this.split(this.start + trimmed.length).edit('', undefined, true); + } + return true; + } else { + this.edit('', undefined, true); + + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + } +}; + +Chunk.prototype.trimStart = function trimStart (rx) { + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + + var trimmed = this.content.replace(rx, ''); + + if (trimmed.length) { + if (trimmed !== this.content) { + this.split(this.end - trimmed.length); + this.edit('', undefined, true); + } + return true; + } else { + this.edit('', undefined, true); + + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + } +}; + +var btoa = function () { + throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.'); +}; +if (typeof window !== 'undefined' && typeof window.btoa === 'function') { + btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); }; +} else if (typeof Buffer === 'function') { + btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); }; +} + +var SourceMap = function SourceMap(properties) { + this.version = 3; + this.file = properties.file; + this.sources = properties.sources; + this.sourcesContent = properties.sourcesContent; + this.names = properties.names; + this.mappings = encode(properties.mappings); +}; + +SourceMap.prototype.toString = function toString () { + return JSON.stringify(this); +}; + +SourceMap.prototype.toUrl = function toUrl () { + return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString()); +}; + +function guessIndent(code) { + var lines = code.split('\n'); + + var tabbed = lines.filter(function (line) { return /^\t+/.test(line); }); + var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); }); + + if (tabbed.length === 0 && spaced.length === 0) { + return null; + } + + // More lines tabbed than spaced? Assume tabs, and + // default to tabs in the case of a tie (or nothing + // to go on) + if (tabbed.length >= spaced.length) { + return '\t'; + } + + // Otherwise, we need to guess the multiple + var min = spaced.reduce(function (previous, current) { + var numSpaces = /^ +/.exec(current)[0].length; + return Math.min(numSpaces, previous); + }, Infinity); + + return new Array(min + 1).join(' '); +} + +function getRelativePath(from, to) { + var fromParts = from.split(/[/\\]/); + var toParts = to.split(/[/\\]/); + + fromParts.pop(); // get dirname + + while (fromParts[0] === toParts[0]) { + fromParts.shift(); + toParts.shift(); + } + + if (fromParts.length) { + var i = fromParts.length; + while (i--) { fromParts[i] = '..'; } + } + + return fromParts.concat(toParts).join('/'); +} + +var toString = Object.prototype.toString; + +function isObject(thing) { + return toString.call(thing) === '[object Object]'; +} + +function getLocator(source) { + var originalLines = source.split('\n'); + var lineOffsets = []; + + for (var i = 0, pos = 0; i < originalLines.length; i++) { + lineOffsets.push(pos); + pos += originalLines[i].length + 1; + } + + return function locate(index) { + var i = 0; + var j = lineOffsets.length; + while (i < j) { + var m = (i + j) >> 1; + if (index < lineOffsets[m]) { + j = m; + } else { + i = m + 1; + } + } + var line = i - 1; + var column = index - lineOffsets[line]; + return { line: line, column: column }; + }; +} + +var Mappings = function Mappings(hires) { + this.hires = hires; + this.generatedCodeLine = 0; + this.generatedCodeColumn = 0; + this.raw = []; + this.rawSegments = this.raw[this.generatedCodeLine] = []; + this.pending = null; +}; + +Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) { + if (content.length) { + var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column]; + if (nameIndex >= 0) { + segment.push(nameIndex); + } + this.rawSegments.push(segment); + } else if (this.pending) { + this.rawSegments.push(this.pending); + } + + this.advance(content); + this.pending = null; +}; + +Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) { + var originalCharIndex = chunk.start; + var first = true; + + while (originalCharIndex < chunk.end) { + if (this.hires || first || sourcemapLocations.has(originalCharIndex)) { + this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]); + } + + if (original[originalCharIndex] === '\n') { + loc.line += 1; + loc.column = 0; + this.generatedCodeLine += 1; + this.raw[this.generatedCodeLine] = this.rawSegments = []; + this.generatedCodeColumn = 0; + first = true; + } else { + loc.column += 1; + this.generatedCodeColumn += 1; + first = false; + } + + originalCharIndex += 1; + } + + this.pending = null; +}; + +Mappings.prototype.advance = function advance (str) { + if (!str) { return; } + + var lines = str.split('\n'); + + if (lines.length > 1) { + for (var i = 0; i < lines.length - 1; i++) { + this.generatedCodeLine++; + this.raw[this.generatedCodeLine] = this.rawSegments = []; + } + this.generatedCodeColumn = 0; + } + + this.generatedCodeColumn += lines[lines.length - 1].length; +}; + +var n = '\n'; + +var warned = { + insertLeft: false, + insertRight: false, + storeName: false, +}; + +var MagicString = function MagicString(string, options) { + if ( options === void 0 ) options = {}; + + var chunk = new Chunk(0, string.length, string); + + Object.defineProperties(this, { + original: { writable: true, value: string }, + outro: { writable: true, value: '' }, + intro: { writable: true, value: '' }, + firstChunk: { writable: true, value: chunk }, + lastChunk: { writable: true, value: chunk }, + lastSearchedChunk: { writable: true, value: chunk }, + byStart: { writable: true, value: {} }, + byEnd: { writable: true, value: {} }, + filename: { writable: true, value: options.filename }, + indentExclusionRanges: { writable: true, value: options.indentExclusionRanges }, + sourcemapLocations: { writable: true, value: new BitSet() }, + storedNames: { writable: true, value: {} }, + indentStr: { writable: true, value: guessIndent(string) }, + }); + + this.byStart[0] = chunk; + this.byEnd[string.length] = chunk; +}; + +MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) { + this.sourcemapLocations.add(char); +}; + +MagicString.prototype.append = function append (content) { + if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); } + + this.outro += content; + return this; +}; + +MagicString.prototype.appendLeft = function appendLeft (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byEnd[index]; + + if (chunk) { + chunk.appendLeft(content); + } else { + this.intro += content; + } + return this; +}; + +MagicString.prototype.appendRight = function appendRight (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byStart[index]; + + if (chunk) { + chunk.appendRight(content); + } else { + this.outro += content; + } + return this; +}; + +MagicString.prototype.clone = function clone () { + var cloned = new MagicString(this.original, { filename: this.filename }); + + var originalChunk = this.firstChunk; + var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone()); + + while (originalChunk) { + cloned.byStart[clonedChunk.start] = clonedChunk; + cloned.byEnd[clonedChunk.end] = clonedChunk; + + var nextOriginalChunk = originalChunk.next; + var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone(); + + if (nextClonedChunk) { + clonedChunk.next = nextClonedChunk; + nextClonedChunk.previous = clonedChunk; + + clonedChunk = nextClonedChunk; + } + + originalChunk = nextOriginalChunk; + } + + cloned.lastChunk = clonedChunk; + + if (this.indentExclusionRanges) { + cloned.indentExclusionRanges = this.indentExclusionRanges.slice(); + } + + cloned.sourcemapLocations = new BitSet(this.sourcemapLocations); + + cloned.intro = this.intro; + cloned.outro = this.outro; + + return cloned; +}; + +MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) { + var this$1$1 = this; + + options = options || {}; + + var sourceIndex = 0; + var names = Object.keys(this.storedNames); + var mappings = new Mappings(options.hires); + + var locate = getLocator(this.original); + + if (this.intro) { + mappings.advance(this.intro); + } + + this.firstChunk.eachNext(function (chunk) { + var loc = locate(chunk.start); + + if (chunk.intro.length) { mappings.advance(chunk.intro); } + + if (chunk.edited) { + mappings.addEdit( + sourceIndex, + chunk.content, + loc, + chunk.storeName ? names.indexOf(chunk.original) : -1 + ); + } else { + mappings.addUneditedChunk(sourceIndex, chunk, this$1$1.original, loc, this$1$1.sourcemapLocations); + } + + if (chunk.outro.length) { mappings.advance(chunk.outro); } + }); + + return { + file: options.file ? options.file.split(/[/\\]/).pop() : null, + sources: [options.source ? getRelativePath(options.file || '', options.source) : null], + sourcesContent: options.includeContent ? [this.original] : [null], + names: names, + mappings: mappings.raw, + }; +}; + +MagicString.prototype.generateMap = function generateMap (options) { + return new SourceMap(this.generateDecodedMap(options)); +}; + +MagicString.prototype.getIndentString = function getIndentString () { + return this.indentStr === null ? '\t' : this.indentStr; +}; + +MagicString.prototype.indent = function indent (indentStr, options) { + var pattern = /^[^\r\n]/gm; + + if (isObject(indentStr)) { + options = indentStr; + indentStr = undefined; + } + + indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t'; + + if (indentStr === '') { return this; } // noop + + options = options || {}; + + // Process exclusion ranges + var isExcluded = {}; + + if (options.exclude) { + var exclusions = + typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude; + exclusions.forEach(function (exclusion) { + for (var i = exclusion[0]; i < exclusion[1]; i += 1) { + isExcluded[i] = true; + } + }); + } + + var shouldIndentNextCharacter = options.indentStart !== false; + var replacer = function (match) { + if (shouldIndentNextCharacter) { return ("" + indentStr + match); } + shouldIndentNextCharacter = true; + return match; + }; + + this.intro = this.intro.replace(pattern, replacer); + + var charIndex = 0; + var chunk = this.firstChunk; + + while (chunk) { + var end = chunk.end; + + if (chunk.edited) { + if (!isExcluded[charIndex]) { + chunk.content = chunk.content.replace(pattern, replacer); + + if (chunk.content.length) { + shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n'; + } + } + } else { + charIndex = chunk.start; + + while (charIndex < end) { + if (!isExcluded[charIndex]) { + var char = this.original[charIndex]; + + if (char === '\n') { + shouldIndentNextCharacter = true; + } else if (char !== '\r' && shouldIndentNextCharacter) { + shouldIndentNextCharacter = false; + + if (charIndex === chunk.start) { + chunk.prependRight(indentStr); + } else { + this._splitChunk(chunk, charIndex); + chunk = chunk.next; + chunk.prependRight(indentStr); + } + } + } + + charIndex += 1; + } + } + + charIndex = chunk.end; + chunk = chunk.next; + } + + this.outro = this.outro.replace(pattern, replacer); + + return this; +}; + +MagicString.prototype.insert = function insert () { + throw new Error( + 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)' + ); +}; + +MagicString.prototype.insertLeft = function insertLeft (index, content) { + if (!warned.insertLeft) { + console.warn( + 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead' + ); // eslint-disable-line no-console + warned.insertLeft = true; + } + + return this.appendLeft(index, content); +}; + +MagicString.prototype.insertRight = function insertRight (index, content) { + if (!warned.insertRight) { + console.warn( + 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead' + ); // eslint-disable-line no-console + warned.insertRight = true; + } + + return this.prependRight(index, content); +}; + +MagicString.prototype.move = function move (start, end, index) { + if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); } + + this._split(start); + this._split(end); + this._split(index); + + var first = this.byStart[start]; + var last = this.byEnd[end]; + + var oldLeft = first.previous; + var oldRight = last.next; + + var newRight = this.byStart[index]; + if (!newRight && last === this.lastChunk) { return this; } + var newLeft = newRight ? newRight.previous : this.lastChunk; + + if (oldLeft) { oldLeft.next = oldRight; } + if (oldRight) { oldRight.previous = oldLeft; } + + if (newLeft) { newLeft.next = first; } + if (newRight) { newRight.previous = last; } + + if (!first.previous) { this.firstChunk = last.next; } + if (!last.next) { + this.lastChunk = first.previous; + this.lastChunk.next = null; + } + + first.previous = newLeft; + last.next = newRight || null; + + if (!newLeft) { this.firstChunk = first; } + if (!newRight) { this.lastChunk = last; } + return this; +}; + +MagicString.prototype.overwrite = function overwrite (start, end, content, options) { + if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); } + + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + if (end > this.original.length) { throw new Error('end is out of bounds'); } + if (start === end) + { throw new Error( + 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead' + ); } + + this._split(start); + this._split(end); + + if (options === true) { + if (!warned.storeName) { + console.warn( + 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string' + ); // eslint-disable-line no-console + warned.storeName = true; + } + + options = { storeName: true }; + } + var storeName = options !== undefined ? options.storeName : false; + var contentOnly = options !== undefined ? options.contentOnly : false; + + if (storeName) { + var original = this.original.slice(start, end); + Object.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true }); + } + + var first = this.byStart[start]; + var last = this.byEnd[end]; + + if (first) { + var chunk = first; + while (chunk !== last) { + if (chunk.next !== this.byStart[chunk.end]) { + throw new Error('Cannot overwrite across a split point'); + } + chunk = chunk.next; + chunk.edit('', false); + } + + first.edit(content, storeName, contentOnly); + } else { + // must be inserting at the end + var newChunk = new Chunk(start, end, '').edit(content, storeName); + + // TODO last chunk in the array may not be the last chunk, if it's moved... + last.next = newChunk; + newChunk.previous = last; + } + return this; +}; + +MagicString.prototype.prepend = function prepend (content) { + if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); } + + this.intro = content + this.intro; + return this; +}; + +MagicString.prototype.prependLeft = function prependLeft (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byEnd[index]; + + if (chunk) { + chunk.prependLeft(content); + } else { + this.intro = content + this.intro; + } + return this; +}; + +MagicString.prototype.prependRight = function prependRight (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byStart[index]; + + if (chunk) { + chunk.prependRight(content); + } else { + this.outro = content + this.outro; + } + return this; +}; + +MagicString.prototype.remove = function remove (start, end) { + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + if (start === end) { return this; } + + if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); } + if (start > end) { throw new Error('end must be greater than start'); } + + this._split(start); + this._split(end); + + var chunk = this.byStart[start]; + + while (chunk) { + chunk.intro = ''; + chunk.outro = ''; + chunk.edit(''); + + chunk = end > chunk.end ? this.byStart[chunk.end] : null; + } + return this; +}; + +MagicString.prototype.lastChar = function lastChar () { + if (this.outro.length) { return this.outro[this.outro.length - 1]; } + var chunk = this.lastChunk; + do { + if (chunk.outro.length) { return chunk.outro[chunk.outro.length - 1]; } + if (chunk.content.length) { return chunk.content[chunk.content.length - 1]; } + if (chunk.intro.length) { return chunk.intro[chunk.intro.length - 1]; } + } while ((chunk = chunk.previous)); + if (this.intro.length) { return this.intro[this.intro.length - 1]; } + return ''; +}; + +MagicString.prototype.lastLine = function lastLine () { + var lineIndex = this.outro.lastIndexOf(n); + if (lineIndex !== -1) { return this.outro.substr(lineIndex + 1); } + var lineStr = this.outro; + var chunk = this.lastChunk; + do { + if (chunk.outro.length > 0) { + lineIndex = chunk.outro.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.outro.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.outro + lineStr; + } + + if (chunk.content.length > 0) { + lineIndex = chunk.content.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.content.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.content + lineStr; + } + + if (chunk.intro.length > 0) { + lineIndex = chunk.intro.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.intro.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.intro + lineStr; + } + } while ((chunk = chunk.previous)); + lineIndex = this.intro.lastIndexOf(n); + if (lineIndex !== -1) { return this.intro.substr(lineIndex + 1) + lineStr; } + return this.intro + lineStr; +}; + +MagicString.prototype.slice = function slice (start, end) { + if ( start === void 0 ) start = 0; + if ( end === void 0 ) end = this.original.length; + + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + var result = ''; + + // find start chunk + var chunk = this.firstChunk; + while (chunk && (chunk.start > start || chunk.end <= start)) { + // found end chunk before start + if (chunk.start < end && chunk.end >= end) { + return result; + } + + chunk = chunk.next; + } + + if (chunk && chunk.edited && chunk.start !== start) + { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); } + + var startChunk = chunk; + while (chunk) { + if (chunk.intro && (startChunk !== chunk || chunk.start === start)) { + result += chunk.intro; + } + + var containsEnd = chunk.start < end && chunk.end >= end; + if (containsEnd && chunk.edited && chunk.end !== end) + { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); } + + var sliceStart = startChunk === chunk ? start - chunk.start : 0; + var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length; + + result += chunk.content.slice(sliceStart, sliceEnd); + + if (chunk.outro && (!containsEnd || chunk.end === end)) { + result += chunk.outro; + } + + if (containsEnd) { + break; + } + + chunk = chunk.next; + } + + return result; +}; + +// TODO deprecate this? not really very useful +MagicString.prototype.snip = function snip (start, end) { + var clone = this.clone(); + clone.remove(0, start); + clone.remove(end, clone.original.length); + + return clone; +}; + +MagicString.prototype._split = function _split (index) { + if (this.byStart[index] || this.byEnd[index]) { return; } + + var chunk = this.lastSearchedChunk; + var searchForward = index > chunk.end; + + while (chunk) { + if (chunk.contains(index)) { return this._splitChunk(chunk, index); } + + chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start]; + } +}; + +MagicString.prototype._splitChunk = function _splitChunk (chunk, index) { + if (chunk.edited && chunk.content.length) { + // zero-length edited chunks are a special case (overlapping replacements) + var loc = getLocator(this.original)(index); + throw new Error( + ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")") + ); + } + + var newChunk = chunk.split(index); + + this.byEnd[index] = chunk; + this.byStart[index] = newChunk; + this.byEnd[newChunk.end] = newChunk; + + if (chunk === this.lastChunk) { this.lastChunk = newChunk; } + + this.lastSearchedChunk = chunk; + return true; +}; + +MagicString.prototype.toString = function toString () { + var str = this.intro; + + var chunk = this.firstChunk; + while (chunk) { + str += chunk.toString(); + chunk = chunk.next; + } + + return str + this.outro; +}; + +MagicString.prototype.isEmpty = function isEmpty () { + var chunk = this.firstChunk; + do { + if ( + (chunk.intro.length && chunk.intro.trim()) || + (chunk.content.length && chunk.content.trim()) || + (chunk.outro.length && chunk.outro.trim()) + ) + { return false; } + } while ((chunk = chunk.next)); + return true; +}; + +MagicString.prototype.length = function length () { + var chunk = this.firstChunk; + var length = 0; + do { + length += chunk.intro.length + chunk.content.length + chunk.outro.length; + } while ((chunk = chunk.next)); + return length; +}; + +MagicString.prototype.trimLines = function trimLines () { + return this.trim('[\\r\\n]'); +}; + +MagicString.prototype.trim = function trim (charType) { + return this.trimStart(charType).trimEnd(charType); +}; + +MagicString.prototype.trimEndAborted = function trimEndAborted (charType) { + var rx = new RegExp((charType || '\\s') + '+$'); + + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + + var chunk = this.lastChunk; + + do { + var end = chunk.end; + var aborted = chunk.trimEnd(rx); + + // if chunk was trimmed, we have a new lastChunk + if (chunk.end !== end) { + if (this.lastChunk === chunk) { + this.lastChunk = chunk.next; + } + + this.byEnd[chunk.end] = chunk; + this.byStart[chunk.next.start] = chunk.next; + this.byEnd[chunk.next.end] = chunk.next; + } + + if (aborted) { return true; } + chunk = chunk.previous; + } while (chunk); + + return false; +}; + +MagicString.prototype.trimEnd = function trimEnd (charType) { + this.trimEndAborted(charType); + return this; +}; +MagicString.prototype.trimStartAborted = function trimStartAborted (charType) { + var rx = new RegExp('^' + (charType || '\\s') + '+'); + + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + + var chunk = this.firstChunk; + + do { + var end = chunk.end; + var aborted = chunk.trimStart(rx); + + if (chunk.end !== end) { + // special case... + if (chunk === this.lastChunk) { this.lastChunk = chunk.next; } + + this.byEnd[chunk.end] = chunk; + this.byStart[chunk.next.start] = chunk.next; + this.byEnd[chunk.next.end] = chunk.next; + } + + if (aborted) { return true; } + chunk = chunk.next; + } while (chunk); + + return false; +}; + +MagicString.prototype.trimStart = function trimStart (charType) { + this.trimStartAborted(charType); + return this; +}; + +var hasOwnProp = Object.prototype.hasOwnProperty; + +var Bundle = function Bundle(options) { + if ( options === void 0 ) options = {}; + + this.intro = options.intro || ''; + this.separator = options.separator !== undefined ? options.separator : '\n'; + this.sources = []; + this.uniqueSources = []; + this.uniqueSourceIndexByFilename = {}; +}; + +Bundle.prototype.addSource = function addSource (source) { + if (source instanceof MagicString) { + return this.addSource({ + content: source, + filename: source.filename, + separator: this.separator, + }); + } + + if (!isObject(source) || !source.content) { + throw new Error( + 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' + ); + } + + ['filename', 'indentExclusionRanges', 'separator'].forEach(function (option) { + if (!hasOwnProp.call(source, option)) { source[option] = source.content[option]; } + }); + + if (source.separator === undefined) { + // TODO there's a bunch of this sort of thing, needs cleaning up + source.separator = this.separator; + } + + if (source.filename) { + if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) { + this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length; + this.uniqueSources.push({ filename: source.filename, content: source.content.original }); + } else { + var uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]]; + if (source.content.original !== uniqueSource.content) { + throw new Error(("Illegal source: same filename (" + (source.filename) + "), different contents")); + } + } + } + + this.sources.push(source); + return this; +}; + +Bundle.prototype.append = function append (str, options) { + this.addSource({ + content: new MagicString(str), + separator: (options && options.separator) || '', + }); + + return this; +}; + +Bundle.prototype.clone = function clone () { + var bundle = new Bundle({ + intro: this.intro, + separator: this.separator, + }); + + this.sources.forEach(function (source) { + bundle.addSource({ + filename: source.filename, + content: source.content.clone(), + separator: source.separator, + }); + }); + + return bundle; +}; + +Bundle.prototype.generateDecodedMap = function generateDecodedMap (options) { + var this$1$1 = this; + if ( options === void 0 ) options = {}; + + var names = []; + this.sources.forEach(function (source) { + Object.keys(source.content.storedNames).forEach(function (name) { + if (!~names.indexOf(name)) { names.push(name); } + }); + }); + + var mappings = new Mappings(options.hires); + + if (this.intro) { + mappings.advance(this.intro); + } + + this.sources.forEach(function (source, i) { + if (i > 0) { + mappings.advance(this$1$1.separator); + } + + var sourceIndex = source.filename ? this$1$1.uniqueSourceIndexByFilename[source.filename] : -1; + var magicString = source.content; + var locate = getLocator(magicString.original); + + if (magicString.intro) { + mappings.advance(magicString.intro); + } + + magicString.firstChunk.eachNext(function (chunk) { + var loc = locate(chunk.start); + + if (chunk.intro.length) { mappings.advance(chunk.intro); } + + if (source.filename) { + if (chunk.edited) { + mappings.addEdit( + sourceIndex, + chunk.content, + loc, + chunk.storeName ? names.indexOf(chunk.original) : -1 + ); + } else { + mappings.addUneditedChunk( + sourceIndex, + chunk, + magicString.original, + loc, + magicString.sourcemapLocations + ); + } + } else { + mappings.advance(chunk.content); + } + + if (chunk.outro.length) { mappings.advance(chunk.outro); } + }); + + if (magicString.outro) { + mappings.advance(magicString.outro); + } + }); + + return { + file: options.file ? options.file.split(/[/\\]/).pop() : null, + sources: this.uniqueSources.map(function (source) { + return options.file ? getRelativePath(options.file, source.filename) : source.filename; + }), + sourcesContent: this.uniqueSources.map(function (source) { + return options.includeContent ? source.content : null; + }), + names: names, + mappings: mappings.raw, + }; +}; + +Bundle.prototype.generateMap = function generateMap (options) { + return new SourceMap(this.generateDecodedMap(options)); +}; + +Bundle.prototype.getIndentString = function getIndentString () { + var indentStringCounts = {}; + + this.sources.forEach(function (source) { + var indentStr = source.content.indentStr; + + if (indentStr === null) { return; } + + if (!indentStringCounts[indentStr]) { indentStringCounts[indentStr] = 0; } + indentStringCounts[indentStr] += 1; + }); + + return ( + Object.keys(indentStringCounts).sort(function (a, b) { + return indentStringCounts[a] - indentStringCounts[b]; + })[0] || '\t' + ); +}; + +Bundle.prototype.indent = function indent (indentStr) { + var this$1$1 = this; + + if (!arguments.length) { + indentStr = this.getIndentString(); + } + + if (indentStr === '') { return this; } // noop + + var trailingNewline = !this.intro || this.intro.slice(-1) === '\n'; + + this.sources.forEach(function (source, i) { + var separator = source.separator !== undefined ? source.separator : this$1$1.separator; + var indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator)); + + source.content.indent(indentStr, { + exclude: source.indentExclusionRanges, + indentStart: indentStart, //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator ) + }); + + trailingNewline = source.content.lastChar() === '\n'; + }); + + if (this.intro) { + this.intro = + indentStr + + this.intro.replace(/^[^\n]/gm, function (match, index) { + return index > 0 ? indentStr + match : match; + }); + } + + return this; +}; + +Bundle.prototype.prepend = function prepend (str) { + this.intro = str + this.intro; + return this; +}; + +Bundle.prototype.toString = function toString () { + var this$1$1 = this; + + var body = this.sources + .map(function (source, i) { + var separator = source.separator !== undefined ? source.separator : this$1$1.separator; + var str = (i > 0 ? separator : '') + source.content.toString(); + + return str; + }) + .join(''); + + return this.intro + body; +}; + +Bundle.prototype.isEmpty = function isEmpty () { + if (this.intro.length && this.intro.trim()) { return false; } + if (this.sources.some(function (source) { return !source.content.isEmpty(); })) { return false; } + return true; +}; + +Bundle.prototype.length = function length () { + return this.sources.reduce( + function (length, source) { return length + source.content.length(); }, + this.intro.length + ); +}; + +Bundle.prototype.trimLines = function trimLines () { + return this.trim('[\\r\\n]'); +}; + +Bundle.prototype.trim = function trim (charType) { + return this.trimStart(charType).trimEnd(charType); +}; + +Bundle.prototype.trimStart = function trimStart (charType) { + var rx = new RegExp('^' + (charType || '\\s') + '+'); + this.intro = this.intro.replace(rx, ''); + + if (!this.intro) { + var source; + var i = 0; + + do { + source = this.sources[i++]; + if (!source) { + break; + } + } while (!source.content.trimStartAborted(charType)); + } + + return this; +}; + +Bundle.prototype.trimEnd = function trimEnd (charType) { + var rx = new RegExp((charType || '\\s') + '+$'); + + var source; + var i = this.sources.length - 1; + + do { + source = this.sources[i--]; + if (!source) { + this.intro = this.intro.replace(rx, ''); + break; + } + } while (!source.content.trimEndAborted(charType)); + + return this; +}; + +export { Bundle, SourceMap, MagicString as default }; +//# sourceMappingURL=magic-string.es.js.map diff --git a/node_modules/magic-string/dist/magic-string.es.js.map b/node_modules/magic-string/dist/magic-string.es.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4624dd8ffc4c9ccd905505594692914b736ea827 --- /dev/null +++ b/node_modules/magic-string/dist/magic-string.es.js.map @@ -0,0 +1 @@ +{"version":3,"file":"magic-string.es.js","sources":["../src/BitSet.js","../src/Chunk.js","../src/SourceMap.js","../src/utils/guessIndent.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/getLocator.js","../src/utils/Mappings.js","../src/MagicString.js","../src/Bundle.js"],"sourcesContent":["export default class BitSet {\n\tconstructor(arg) {\n\t\tthis.bits = arg instanceof BitSet ? arg.bits.slice() : [];\n\t}\n\n\tadd(n) {\n\t\tthis.bits[n >> 5] |= 1 << (n & 31);\n\t}\n\n\thas(n) {\n\t\treturn !!(this.bits[n >> 5] & (1 << (n & 31)));\n\t}\n}\n","export default class Chunk {\n\tconstructor(start, end, content) {\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t\tthis.original = content;\n\n\t\tthis.intro = '';\n\t\tthis.outro = '';\n\n\t\tthis.content = content;\n\t\tthis.storeName = false;\n\t\tthis.edited = false;\n\n\t\t// we make these non-enumerable, for sanity while debugging\n\t\tObject.defineProperties(this, {\n\t\t\tprevious: { writable: true, value: null },\n\t\t\tnext: { writable: true, value: null },\n\t\t});\n\t}\n\n\tappendLeft(content) {\n\t\tthis.outro += content;\n\t}\n\n\tappendRight(content) {\n\t\tthis.intro = this.intro + content;\n\t}\n\n\tclone() {\n\t\tconst chunk = new Chunk(this.start, this.end, this.original);\n\n\t\tchunk.intro = this.intro;\n\t\tchunk.outro = this.outro;\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t}\n\n\tcontains(index) {\n\t\treturn this.start < index && index < this.end;\n\t}\n\n\teachNext(fn) {\n\t\tlet chunk = this;\n\t\twhile (chunk) {\n\t\t\tfn(chunk);\n\t\t\tchunk = chunk.next;\n\t\t}\n\t}\n\n\teachPrevious(fn) {\n\t\tlet chunk = this;\n\t\twhile (chunk) {\n\t\t\tfn(chunk);\n\t\t\tchunk = chunk.previous;\n\t\t}\n\t}\n\n\tedit(content, storeName, contentOnly) {\n\t\tthis.content = content;\n\t\tif (!contentOnly) {\n\t\t\tthis.intro = '';\n\t\t\tthis.outro = '';\n\t\t}\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t}\n\n\tprependLeft(content) {\n\t\tthis.outro = content + this.outro;\n\t}\n\n\tprependRight(content) {\n\t\tthis.intro = content + this.intro;\n\t}\n\n\tsplit(index) {\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice(0, sliceIndex);\n\t\tconst originalAfter = this.original.slice(sliceIndex);\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk(index, this.end, originalAfter);\n\t\tnewChunk.outro = this.outro;\n\t\tthis.outro = '';\n\n\t\tthis.end = index;\n\n\t\tif (this.edited) {\n\t\t\t// TODO is this block necessary?...\n\t\t\tnewChunk.edit('', false);\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\tnewChunk.next = this.next;\n\t\tif (newChunk.next) newChunk.next.previous = newChunk;\n\t\tnewChunk.previous = this;\n\t\tthis.next = newChunk;\n\n\t\treturn newChunk;\n\t}\n\n\ttoString() {\n\t\treturn this.intro + this.content + this.outro;\n\t}\n\n\ttrimEnd(rx) {\n\t\tthis.outro = this.outro.replace(rx, '');\n\t\tif (this.outro.length) return true;\n\n\t\tconst trimmed = this.content.replace(rx, '');\n\n\t\tif (trimmed.length) {\n\t\t\tif (trimmed !== this.content) {\n\t\t\t\tthis.split(this.start + trimmed.length).edit('', undefined, true);\n\t\t\t}\n\t\t\treturn true;\n\t\t} else {\n\t\t\tthis.edit('', undefined, true);\n\n\t\t\tthis.intro = this.intro.replace(rx, '');\n\t\t\tif (this.intro.length) return true;\n\t\t}\n\t}\n\n\ttrimStart(rx) {\n\t\tthis.intro = this.intro.replace(rx, '');\n\t\tif (this.intro.length) return true;\n\n\t\tconst trimmed = this.content.replace(rx, '');\n\n\t\tif (trimmed.length) {\n\t\t\tif (trimmed !== this.content) {\n\t\t\t\tthis.split(this.end - trimmed.length);\n\t\t\t\tthis.edit('', undefined, true);\n\t\t\t}\n\t\t\treturn true;\n\t\t} else {\n\t\t\tthis.edit('', undefined, true);\n\n\t\t\tthis.outro = this.outro.replace(rx, '');\n\t\t\tif (this.outro.length) return true;\n\t\t}\n\t}\n}\n","import { encode } from 'sourcemap-codec';\n\nlet btoa = () => {\n\tthrow new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');\n};\nif (typeof window !== 'undefined' && typeof window.btoa === 'function') {\n\tbtoa = (str) => window.btoa(unescape(encodeURIComponent(str)));\n} else if (typeof Buffer === 'function') {\n\tbtoa = (str) => Buffer.from(str, 'utf-8').toString('base64');\n}\n\nexport default class SourceMap {\n\tconstructor(properties) {\n\t\tthis.version = 3;\n\t\tthis.file = properties.file;\n\t\tthis.sources = properties.sources;\n\t\tthis.sourcesContent = properties.sourcesContent;\n\t\tthis.names = properties.names;\n\t\tthis.mappings = encode(properties.mappings);\n\t}\n\n\ttoString() {\n\t\treturn JSON.stringify(this);\n\t}\n\n\ttoUrl() {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());\n\t}\n}\n","export default function guessIndent(code) {\n\tconst lines = code.split('\\n');\n\n\tconst tabbed = lines.filter((line) => /^\\t+/.test(line));\n\tconst spaced = lines.filter((line) => /^ {2,}/.test(line));\n\n\tif (tabbed.length === 0 && spaced.length === 0) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif (tabbed.length >= spaced.length) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce((previous, current) => {\n\t\tconst numSpaces = /^ +/.exec(current)[0].length;\n\t\treturn Math.min(numSpaces, previous);\n\t}, Infinity);\n\n\treturn new Array(min + 1).join(' ');\n}\n","export default function getRelativePath(from, to) {\n\tconst fromParts = from.split(/[/\\\\]/);\n\tconst toParts = to.split(/[/\\\\]/);\n\n\tfromParts.pop(); // get dirname\n\n\twhile (fromParts[0] === toParts[0]) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif (fromParts.length) {\n\t\tlet i = fromParts.length;\n\t\twhile (i--) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat(toParts).join('/');\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject(thing) {\n\treturn toString.call(thing) === '[object Object]';\n}\n","export default function getLocator(source) {\n\tconst originalLines = source.split('\\n');\n\tconst lineOffsets = [];\n\n\tfor (let i = 0, pos = 0; i < originalLines.length; i++) {\n\t\tlineOffsets.push(pos);\n\t\tpos += originalLines[i].length + 1;\n\t}\n\n\treturn function locate(index) {\n\t\tlet i = 0;\n\t\tlet j = lineOffsets.length;\n\t\twhile (i < j) {\n\t\t\tconst m = (i + j) >> 1;\n\t\t\tif (index < lineOffsets[m]) {\n\t\t\t\tj = m;\n\t\t\t} else {\n\t\t\t\ti = m + 1;\n\t\t\t}\n\t\t}\n\t\tconst line = i - 1;\n\t\tconst column = index - lineOffsets[line];\n\t\treturn { line, column };\n\t};\n}\n","export default class Mappings {\n\tconstructor(hires) {\n\t\tthis.hires = hires;\n\t\tthis.generatedCodeLine = 0;\n\t\tthis.generatedCodeColumn = 0;\n\t\tthis.raw = [];\n\t\tthis.rawSegments = this.raw[this.generatedCodeLine] = [];\n\t\tthis.pending = null;\n\t}\n\n\taddEdit(sourceIndex, content, loc, nameIndex) {\n\t\tif (content.length) {\n\t\t\tconst segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];\n\t\t\tif (nameIndex >= 0) {\n\t\t\t\tsegment.push(nameIndex);\n\t\t\t}\n\t\t\tthis.rawSegments.push(segment);\n\t\t} else if (this.pending) {\n\t\t\tthis.rawSegments.push(this.pending);\n\t\t}\n\n\t\tthis.advance(content);\n\t\tthis.pending = null;\n\t}\n\n\taddUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {\n\t\tlet originalCharIndex = chunk.start;\n\t\tlet first = true;\n\n\t\twhile (originalCharIndex < chunk.end) {\n\t\t\tif (this.hires || first || sourcemapLocations.has(originalCharIndex)) {\n\t\t\t\tthis.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);\n\t\t\t}\n\n\t\t\tif (original[originalCharIndex] === '\\n') {\n\t\t\t\tloc.line += 1;\n\t\t\t\tloc.column = 0;\n\t\t\t\tthis.generatedCodeLine += 1;\n\t\t\t\tthis.raw[this.generatedCodeLine] = this.rawSegments = [];\n\t\t\t\tthis.generatedCodeColumn = 0;\n\t\t\t\tfirst = true;\n\t\t\t} else {\n\t\t\t\tloc.column += 1;\n\t\t\t\tthis.generatedCodeColumn += 1;\n\t\t\t\tfirst = false;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t}\n\n\t\tthis.pending = null;\n\t}\n\n\tadvance(str) {\n\t\tif (!str) return;\n\n\t\tconst lines = str.split('\\n');\n\n\t\tif (lines.length > 1) {\n\t\t\tfor (let i = 0; i < lines.length - 1; i++) {\n\t\t\t\tthis.generatedCodeLine++;\n\t\t\t\tthis.raw[this.generatedCodeLine] = this.rawSegments = [];\n\t\t\t}\n\t\t\tthis.generatedCodeColumn = 0;\n\t\t}\n\n\t\tthis.generatedCodeColumn += lines[lines.length - 1].length;\n\t}\n}\n","import BitSet from './BitSet.js';\nimport Chunk from './Chunk.js';\nimport SourceMap from './SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport getLocator from './utils/getLocator.js';\nimport Mappings from './utils/Mappings.js';\nimport Stats from './utils/Stats.js';\n\nconst n = '\\n';\n\nconst warned = {\n\tinsertLeft: false,\n\tinsertRight: false,\n\tstoreName: false,\n};\n\nexport default class MagicString {\n\tconstructor(string, options = {}) {\n\t\tconst chunk = new Chunk(0, string.length, string);\n\n\t\tObject.defineProperties(this, {\n\t\t\toriginal: { writable: true, value: string },\n\t\t\toutro: { writable: true, value: '' },\n\t\t\tintro: { writable: true, value: '' },\n\t\t\tfirstChunk: { writable: true, value: chunk },\n\t\t\tlastChunk: { writable: true, value: chunk },\n\t\t\tlastSearchedChunk: { writable: true, value: chunk },\n\t\t\tbyStart: { writable: true, value: {} },\n\t\t\tbyEnd: { writable: true, value: {} },\n\t\t\tfilename: { writable: true, value: options.filename },\n\t\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\t\tsourcemapLocations: { writable: true, value: new BitSet() },\n\t\t\tstoredNames: { writable: true, value: {} },\n\t\t\tindentStr: { writable: true, value: guessIndent(string) },\n\t\t});\n\n\t\tif (DEBUG) {\n\t\t\tObject.defineProperty(this, 'stats', { value: new Stats() });\n\t\t}\n\n\t\tthis.byStart[0] = chunk;\n\t\tthis.byEnd[string.length] = chunk;\n\t}\n\n\taddSourcemapLocation(char) {\n\t\tthis.sourcemapLocations.add(char);\n\t}\n\n\tappend(content) {\n\t\tif (typeof content !== 'string') throw new TypeError('outro content must be a string');\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t}\n\n\tappendLeft(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('appendLeft');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byEnd[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.appendLeft(content);\n\t\t} else {\n\t\t\tthis.intro += content;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('appendLeft');\n\t\treturn this;\n\t}\n\n\tappendRight(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('appendRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byStart[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.appendRight(content);\n\t\t} else {\n\t\t\tthis.outro += content;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('appendRight');\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\tconst cloned = new MagicString(this.original, { filename: this.filename });\n\n\t\tlet originalChunk = this.firstChunk;\n\t\tlet clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());\n\n\t\twhile (originalChunk) {\n\t\t\tcloned.byStart[clonedChunk.start] = clonedChunk;\n\t\t\tcloned.byEnd[clonedChunk.end] = clonedChunk;\n\n\t\t\tconst nextOriginalChunk = originalChunk.next;\n\t\t\tconst nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();\n\n\t\t\tif (nextClonedChunk) {\n\t\t\t\tclonedChunk.next = nextClonedChunk;\n\t\t\t\tnextClonedChunk.previous = clonedChunk;\n\n\t\t\t\tclonedChunk = nextClonedChunk;\n\t\t\t}\n\n\t\t\toriginalChunk = nextOriginalChunk;\n\t\t}\n\n\t\tcloned.lastChunk = clonedChunk;\n\n\t\tif (this.indentExclusionRanges) {\n\t\t\tcloned.indentExclusionRanges = this.indentExclusionRanges.slice();\n\t\t}\n\n\t\tcloned.sourcemapLocations = new BitSet(this.sourcemapLocations);\n\n\t\tcloned.intro = this.intro;\n\t\tcloned.outro = this.outro;\n\n\t\treturn cloned;\n\t}\n\n\tgenerateDecodedMap(options) {\n\t\toptions = options || {};\n\n\t\tconst sourceIndex = 0;\n\t\tconst names = Object.keys(this.storedNames);\n\t\tconst mappings = new Mappings(options.hires);\n\n\t\tconst locate = getLocator(this.original);\n\n\t\tif (this.intro) {\n\t\t\tmappings.advance(this.intro);\n\t\t}\n\n\t\tthis.firstChunk.eachNext((chunk) => {\n\t\t\tconst loc = locate(chunk.start);\n\n\t\t\tif (chunk.intro.length) mappings.advance(chunk.intro);\n\n\t\t\tif (chunk.edited) {\n\t\t\t\tmappings.addEdit(\n\t\t\t\t\tsourceIndex,\n\t\t\t\t\tchunk.content,\n\t\t\t\t\tloc,\n\t\t\t\t\tchunk.storeName ? names.indexOf(chunk.original) : -1\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tmappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);\n\t\t\t}\n\n\t\t\tif (chunk.outro.length) mappings.advance(chunk.outro);\n\t\t});\n\n\t\treturn {\n\t\t\tfile: options.file ? options.file.split(/[/\\\\]/).pop() : null,\n\t\t\tsources: [options.source ? getRelativePath(options.file || '', options.source) : null],\n\t\t\tsourcesContent: options.includeContent ? [this.original] : [null],\n\t\t\tnames,\n\t\t\tmappings: mappings.raw,\n\t\t};\n\t}\n\n\tgenerateMap(options) {\n\t\treturn new SourceMap(this.generateDecodedMap(options));\n\t}\n\n\tgetIndentString() {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t}\n\n\tindent(indentStr, options) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif (isObject(indentStr)) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : this.indentStr || '\\t';\n\n\t\tif (indentStr === '') return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tconst isExcluded = {};\n\n\t\tif (options.exclude) {\n\t\t\tconst exclusions =\n\t\t\t\ttypeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;\n\t\t\texclusions.forEach((exclusion) => {\n\t\t\t\tfor (let i = exclusion[0]; i < exclusion[1]; i += 1) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = (match) => {\n\t\t\tif (shouldIndentNextCharacter) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace(pattern, replacer);\n\n\t\tlet charIndex = 0;\n\t\tlet chunk = this.firstChunk;\n\n\t\twhile (chunk) {\n\t\t\tconst end = chunk.end;\n\n\t\t\tif (chunk.edited) {\n\t\t\t\tif (!isExcluded[charIndex]) {\n\t\t\t\t\tchunk.content = chunk.content.replace(pattern, replacer);\n\n\t\t\t\t\tif (chunk.content.length) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile (charIndex < end) {\n\t\t\t\t\tif (!isExcluded[charIndex]) {\n\t\t\t\t\t\tconst char = this.original[charIndex];\n\n\t\t\t\t\t\tif (char === '\\n') {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if (char !== '\\r' && shouldIndentNextCharacter) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tif (charIndex === chunk.start) {\n\t\t\t\t\t\t\t\tchunk.prependRight(indentStr);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis._splitChunk(chunk, charIndex);\n\t\t\t\t\t\t\t\tchunk = chunk.next;\n\t\t\t\t\t\t\t\tchunk.prependRight(indentStr);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\tthis.outro = this.outro.replace(pattern, replacer);\n\n\t\treturn this;\n\t}\n\n\tinsert() {\n\t\tthrow new Error(\n\t\t\t'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'\n\t\t);\n\t}\n\n\tinsertLeft(index, content) {\n\t\tif (!warned.insertLeft) {\n\t\t\tconsole.warn(\n\t\t\t\t'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'\n\t\t\t); // eslint-disable-line no-console\n\t\t\twarned.insertLeft = true;\n\t\t}\n\n\t\treturn this.appendLeft(index, content);\n\t}\n\n\tinsertRight(index, content) {\n\t\tif (!warned.insertRight) {\n\t\t\tconsole.warn(\n\t\t\t\t'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'\n\t\t\t); // eslint-disable-line no-console\n\t\t\twarned.insertRight = true;\n\t\t}\n\n\t\treturn this.prependRight(index, content);\n\t}\n\n\tmove(start, end, index) {\n\t\tif (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');\n\n\t\tif (DEBUG) this.stats.time('move');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\t\tthis._split(index);\n\n\t\tconst first = this.byStart[start];\n\t\tconst last = this.byEnd[end];\n\n\t\tconst oldLeft = first.previous;\n\t\tconst oldRight = last.next;\n\n\t\tconst newRight = this.byStart[index];\n\t\tif (!newRight && last === this.lastChunk) return this;\n\t\tconst newLeft = newRight ? newRight.previous : this.lastChunk;\n\n\t\tif (oldLeft) oldLeft.next = oldRight;\n\t\tif (oldRight) oldRight.previous = oldLeft;\n\n\t\tif (newLeft) newLeft.next = first;\n\t\tif (newRight) newRight.previous = last;\n\n\t\tif (!first.previous) this.firstChunk = last.next;\n\t\tif (!last.next) {\n\t\t\tthis.lastChunk = first.previous;\n\t\t\tthis.lastChunk.next = null;\n\t\t}\n\n\t\tfirst.previous = newLeft;\n\t\tlast.next = newRight || null;\n\n\t\tif (!newLeft) this.firstChunk = first;\n\t\tif (!newRight) this.lastChunk = last;\n\n\t\tif (DEBUG) this.stats.timeEnd('move');\n\t\treturn this;\n\t}\n\n\toverwrite(start, end, content, options) {\n\t\tif (typeof content !== 'string') throw new TypeError('replacement content must be a string');\n\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tif (end > this.original.length) throw new Error('end is out of bounds');\n\t\tif (start === end)\n\t\t\tthrow new Error(\n\t\t\t\t'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'\n\t\t\t);\n\n\t\tif (DEBUG) this.stats.time('overwrite');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\n\t\tif (options === true) {\n\t\t\tif (!warned.storeName) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'\n\t\t\t\t); // eslint-disable-line no-console\n\t\t\t\twarned.storeName = true;\n\t\t\t}\n\n\t\t\toptions = { storeName: true };\n\t\t}\n\t\tconst storeName = options !== undefined ? options.storeName : false;\n\t\tconst contentOnly = options !== undefined ? options.contentOnly : false;\n\n\t\tif (storeName) {\n\t\t\tconst original = this.original.slice(start, end);\n\t\t\tObject.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true });\n\t\t}\n\n\t\tconst first = this.byStart[start];\n\t\tconst last = this.byEnd[end];\n\n\t\tif (first) {\n\t\t\tlet chunk = first;\n\t\t\twhile (chunk !== last) {\n\t\t\t\tif (chunk.next !== this.byStart[chunk.end]) {\n\t\t\t\t\tthrow new Error('Cannot overwrite across a split point');\n\t\t\t\t}\n\t\t\t\tchunk = chunk.next;\n\t\t\t\tchunk.edit('', false);\n\t\t\t}\n\n\t\t\tfirst.edit(content, storeName, contentOnly);\n\t\t} else {\n\t\t\t// must be inserting at the end\n\t\t\tconst newChunk = new Chunk(start, end, '').edit(content, storeName);\n\n\t\t\t// TODO last chunk in the array may not be the last chunk, if it's moved...\n\t\t\tlast.next = newChunk;\n\t\t\tnewChunk.previous = last;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('overwrite');\n\t\treturn this;\n\t}\n\n\tprepend(content) {\n\t\tif (typeof content !== 'string') throw new TypeError('outro content must be a string');\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t}\n\n\tprependLeft(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('insertRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byEnd[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.prependLeft(content);\n\t\t} else {\n\t\t\tthis.intro = content + this.intro;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('insertRight');\n\t\treturn this;\n\t}\n\n\tprependRight(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('insertRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byStart[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.prependRight(content);\n\t\t} else {\n\t\t\tthis.outro = content + this.outro;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('insertRight');\n\t\treturn this;\n\t}\n\n\tremove(start, end) {\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tif (start === end) return this;\n\n\t\tif (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');\n\t\tif (start > end) throw new Error('end must be greater than start');\n\n\t\tif (DEBUG) this.stats.time('remove');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\n\t\tlet chunk = this.byStart[start];\n\n\t\twhile (chunk) {\n\t\t\tchunk.intro = '';\n\t\t\tchunk.outro = '';\n\t\t\tchunk.edit('');\n\n\t\t\tchunk = end > chunk.end ? this.byStart[chunk.end] : null;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('remove');\n\t\treturn this;\n\t}\n\n\tlastChar() {\n\t\tif (this.outro.length) return this.outro[this.outro.length - 1];\n\t\tlet chunk = this.lastChunk;\n\t\tdo {\n\t\t\tif (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];\n\t\t\tif (chunk.content.length) return chunk.content[chunk.content.length - 1];\n\t\t\tif (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];\n\t\t} while ((chunk = chunk.previous));\n\t\tif (this.intro.length) return this.intro[this.intro.length - 1];\n\t\treturn '';\n\t}\n\n\tlastLine() {\n\t\tlet lineIndex = this.outro.lastIndexOf(n);\n\t\tif (lineIndex !== -1) return this.outro.substr(lineIndex + 1);\n\t\tlet lineStr = this.outro;\n\t\tlet chunk = this.lastChunk;\n\t\tdo {\n\t\t\tif (chunk.outro.length > 0) {\n\t\t\t\tlineIndex = chunk.outro.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.outro + lineStr;\n\t\t\t}\n\n\t\t\tif (chunk.content.length > 0) {\n\t\t\t\tlineIndex = chunk.content.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.content + lineStr;\n\t\t\t}\n\n\t\t\tif (chunk.intro.length > 0) {\n\t\t\t\tlineIndex = chunk.intro.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.intro + lineStr;\n\t\t\t}\n\t\t} while ((chunk = chunk.previous));\n\t\tlineIndex = this.intro.lastIndexOf(n);\n\t\tif (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;\n\t\treturn this.intro + lineStr;\n\t}\n\n\tslice(start = 0, end = this.original.length) {\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\t// find start chunk\n\t\tlet chunk = this.firstChunk;\n\t\twhile (chunk && (chunk.start > start || chunk.end <= start)) {\n\t\t\t// found end chunk before start\n\t\t\tif (chunk.start < end && chunk.end >= end) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\tif (chunk && chunk.edited && chunk.start !== start)\n\t\t\tthrow new Error(`Cannot use replaced character ${start} as slice start anchor.`);\n\n\t\tconst startChunk = chunk;\n\t\twhile (chunk) {\n\t\t\tif (chunk.intro && (startChunk !== chunk || chunk.start === start)) {\n\t\t\t\tresult += chunk.intro;\n\t\t\t}\n\n\t\t\tconst containsEnd = chunk.start < end && chunk.end >= end;\n\t\t\tif (containsEnd && chunk.edited && chunk.end !== end)\n\t\t\t\tthrow new Error(`Cannot use replaced character ${end} as slice end anchor.`);\n\n\t\t\tconst sliceStart = startChunk === chunk ? start - chunk.start : 0;\n\t\t\tconst sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;\n\n\t\t\tresult += chunk.content.slice(sliceStart, sliceEnd);\n\n\t\t\tif (chunk.outro && (!containsEnd || chunk.end === end)) {\n\t\t\t\tresult += chunk.outro;\n\t\t\t}\n\n\t\t\tif (containsEnd) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// TODO deprecate this? not really very useful\n\tsnip(start, end) {\n\t\tconst clone = this.clone();\n\t\tclone.remove(0, start);\n\t\tclone.remove(end, clone.original.length);\n\n\t\treturn clone;\n\t}\n\n\t_split(index) {\n\t\tif (this.byStart[index] || this.byEnd[index]) return;\n\n\t\tif (DEBUG) this.stats.time('_split');\n\n\t\tlet chunk = this.lastSearchedChunk;\n\t\tconst searchForward = index > chunk.end;\n\n\t\twhile (chunk) {\n\t\t\tif (chunk.contains(index)) return this._splitChunk(chunk, index);\n\n\t\t\tchunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];\n\t\t}\n\t}\n\n\t_splitChunk(chunk, index) {\n\t\tif (chunk.edited && chunk.content.length) {\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tconst loc = getLocator(this.original)(index);\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – \"${chunk.original}\")`\n\t\t\t);\n\t\t}\n\n\t\tconst newChunk = chunk.split(index);\n\n\t\tthis.byEnd[index] = chunk;\n\t\tthis.byStart[index] = newChunk;\n\t\tthis.byEnd[newChunk.end] = newChunk;\n\n\t\tif (chunk === this.lastChunk) this.lastChunk = newChunk;\n\n\t\tthis.lastSearchedChunk = chunk;\n\t\tif (DEBUG) this.stats.timeEnd('_split');\n\t\treturn true;\n\t}\n\n\ttoString() {\n\t\tlet str = this.intro;\n\n\t\tlet chunk = this.firstChunk;\n\t\twhile (chunk) {\n\t\t\tstr += chunk.toString();\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\treturn str + this.outro;\n\t}\n\n\tisEmpty() {\n\t\tlet chunk = this.firstChunk;\n\t\tdo {\n\t\t\tif (\n\t\t\t\t(chunk.intro.length && chunk.intro.trim()) ||\n\t\t\t\t(chunk.content.length && chunk.content.trim()) ||\n\t\t\t\t(chunk.outro.length && chunk.outro.trim())\n\t\t\t)\n\t\t\t\treturn false;\n\t\t} while ((chunk = chunk.next));\n\t\treturn true;\n\t}\n\n\tlength() {\n\t\tlet chunk = this.firstChunk;\n\t\tlet length = 0;\n\t\tdo {\n\t\t\tlength += chunk.intro.length + chunk.content.length + chunk.outro.length;\n\t\t} while ((chunk = chunk.next));\n\t\treturn length;\n\t}\n\n\ttrimLines() {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t}\n\n\ttrim(charType) {\n\t\treturn this.trimStart(charType).trimEnd(charType);\n\t}\n\n\ttrimEndAborted(charType) {\n\t\tconst rx = new RegExp((charType || '\\\\s') + '+$');\n\n\t\tthis.outro = this.outro.replace(rx, '');\n\t\tif (this.outro.length) return true;\n\n\t\tlet chunk = this.lastChunk;\n\n\t\tdo {\n\t\t\tconst end = chunk.end;\n\t\t\tconst aborted = chunk.trimEnd(rx);\n\n\t\t\t// if chunk was trimmed, we have a new lastChunk\n\t\t\tif (chunk.end !== end) {\n\t\t\t\tif (this.lastChunk === chunk) {\n\t\t\t\t\tthis.lastChunk = chunk.next;\n\t\t\t\t}\n\n\t\t\t\tthis.byEnd[chunk.end] = chunk;\n\t\t\t\tthis.byStart[chunk.next.start] = chunk.next;\n\t\t\t\tthis.byEnd[chunk.next.end] = chunk.next;\n\t\t\t}\n\n\t\t\tif (aborted) return true;\n\t\t\tchunk = chunk.previous;\n\t\t} while (chunk);\n\n\t\treturn false;\n\t}\n\n\ttrimEnd(charType) {\n\t\tthis.trimEndAborted(charType);\n\t\treturn this;\n\t}\n\ttrimStartAborted(charType) {\n\t\tconst rx = new RegExp('^' + (charType || '\\\\s') + '+');\n\n\t\tthis.intro = this.intro.replace(rx, '');\n\t\tif (this.intro.length) return true;\n\n\t\tlet chunk = this.firstChunk;\n\n\t\tdo {\n\t\t\tconst end = chunk.end;\n\t\t\tconst aborted = chunk.trimStart(rx);\n\n\t\t\tif (chunk.end !== end) {\n\t\t\t\t// special case...\n\t\t\t\tif (chunk === this.lastChunk) this.lastChunk = chunk.next;\n\n\t\t\t\tthis.byEnd[chunk.end] = chunk;\n\t\t\t\tthis.byStart[chunk.next.start] = chunk.next;\n\t\t\t\tthis.byEnd[chunk.next.end] = chunk.next;\n\t\t\t}\n\n\t\t\tif (aborted) return true;\n\t\t\tchunk = chunk.next;\n\t\t} while (chunk);\n\n\t\treturn false;\n\t}\n\n\ttrimStart(charType) {\n\t\tthis.trimStartAborted(charType);\n\t\treturn this;\n\t}\n}\n","import MagicString from './MagicString.js';\nimport SourceMap from './SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport getLocator from './utils/getLocator.js';\nimport Mappings from './utils/Mappings.js';\n\nconst hasOwnProp = Object.prototype.hasOwnProperty;\n\nexport default class Bundle {\n\tconstructor(options = {}) {\n\t\tthis.intro = options.intro || '';\n\t\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\t\tthis.sources = [];\n\t\tthis.uniqueSources = [];\n\t\tthis.uniqueSourceIndexByFilename = {};\n\t}\n\n\taddSource(source) {\n\t\tif (source instanceof MagicString) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator,\n\t\t\t});\n\t\t}\n\n\t\tif (!isObject(source) || !source.content) {\n\t\t\tthrow new Error(\n\t\t\t\t'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`'\n\t\t\t);\n\t\t}\n\n\t\t['filename', 'indentExclusionRanges', 'separator'].forEach((option) => {\n\t\t\tif (!hasOwnProp.call(source, option)) source[option] = source.content[option];\n\t\t});\n\n\t\tif (source.separator === undefined) {\n\t\t\t// TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif (source.filename) {\n\t\t\tif (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];\n\t\t\t\tif (source.content.original !== uniqueSource.content) {\n\t\t\t\t\tthrow new Error(`Illegal source: same filename (${source.filename}), different contents`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push(source);\n\t\treturn this;\n\t}\n\n\tappend(str, options) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString(str),\n\t\t\tseparator: (options && options.separator) || '',\n\t\t});\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator,\n\t\t});\n\n\t\tthis.sources.forEach((source) => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator,\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t}\n\n\tgenerateDecodedMap(options = {}) {\n\t\tconst names = [];\n\t\tthis.sources.forEach((source) => {\n\t\t\tObject.keys(source.content.storedNames).forEach((name) => {\n\t\t\t\tif (!~names.indexOf(name)) names.push(name);\n\t\t\t});\n\t\t});\n\n\t\tconst mappings = new Mappings(options.hires);\n\n\t\tif (this.intro) {\n\t\t\tmappings.advance(this.intro);\n\t\t}\n\n\t\tthis.sources.forEach((source, i) => {\n\t\t\tif (i > 0) {\n\t\t\t\tmappings.advance(this.separator);\n\t\t\t}\n\n\t\t\tconst sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;\n\t\t\tconst magicString = source.content;\n\t\t\tconst locate = getLocator(magicString.original);\n\n\t\t\tif (magicString.intro) {\n\t\t\t\tmappings.advance(magicString.intro);\n\t\t\t}\n\n\t\t\tmagicString.firstChunk.eachNext((chunk) => {\n\t\t\t\tconst loc = locate(chunk.start);\n\n\t\t\t\tif (chunk.intro.length) mappings.advance(chunk.intro);\n\n\t\t\t\tif (source.filename) {\n\t\t\t\t\tif (chunk.edited) {\n\t\t\t\t\t\tmappings.addEdit(\n\t\t\t\t\t\t\tsourceIndex,\n\t\t\t\t\t\t\tchunk.content,\n\t\t\t\t\t\t\tloc,\n\t\t\t\t\t\t\tchunk.storeName ? names.indexOf(chunk.original) : -1\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmappings.addUneditedChunk(\n\t\t\t\t\t\t\tsourceIndex,\n\t\t\t\t\t\t\tchunk,\n\t\t\t\t\t\t\tmagicString.original,\n\t\t\t\t\t\t\tloc,\n\t\t\t\t\t\t\tmagicString.sourcemapLocations\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmappings.advance(chunk.content);\n\t\t\t\t}\n\n\t\t\t\tif (chunk.outro.length) mappings.advance(chunk.outro);\n\t\t\t});\n\n\t\t\tif (magicString.outro) {\n\t\t\t\tmappings.advance(magicString.outro);\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tfile: options.file ? options.file.split(/[/\\\\]/).pop() : null,\n\t\t\tsources: this.uniqueSources.map((source) => {\n\t\t\t\treturn options.file ? getRelativePath(options.file, source.filename) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map((source) => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: mappings.raw,\n\t\t};\n\t}\n\n\tgenerateMap(options) {\n\t\treturn new SourceMap(this.generateDecodedMap(options));\n\t}\n\n\tgetIndentString() {\n\t\tconst indentStringCounts = {};\n\n\t\tthis.sources.forEach((source) => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif (indentStr === null) return;\n\n\t\t\tif (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;\n\t\t\tindentStringCounts[indentStr] += 1;\n\t\t});\n\n\t\treturn (\n\t\t\tObject.keys(indentStringCounts).sort((a, b) => {\n\t\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t\t})[0] || '\\t'\n\t\t);\n\t}\n\n\tindent(indentStr) {\n\t\tif (!arguments.length) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif (indentStr === '') return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice(-1) === '\\n';\n\n\t\tthis.sources.forEach((source, i) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || (i > 0 && /\\r?\\n$/.test(separator));\n\n\t\t\tsource.content.indent(indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart, //: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\ttrailingNewline = source.content.lastChar() === '\\n';\n\t\t});\n\n\t\tif (this.intro) {\n\t\t\tthis.intro =\n\t\t\t\tindentStr +\n\t\t\t\tthis.intro.replace(/^[^\\n]/gm, (match, index) => {\n\t\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tprepend(str) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t}\n\n\ttoString() {\n\t\tconst body = this.sources\n\t\t\t.map((source, i) => {\n\t\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\t\tconst str = (i > 0 ? separator : '') + source.content.toString();\n\n\t\t\t\treturn str;\n\t\t\t})\n\t\t\t.join('');\n\n\t\treturn this.intro + body;\n\t}\n\n\tisEmpty() {\n\t\tif (this.intro.length && this.intro.trim()) return false;\n\t\tif (this.sources.some((source) => !source.content.isEmpty())) return false;\n\t\treturn true;\n\t}\n\n\tlength() {\n\t\treturn this.sources.reduce(\n\t\t\t(length, source) => length + source.content.length(),\n\t\t\tthis.intro.length\n\t\t);\n\t}\n\n\ttrimLines() {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t}\n\n\ttrim(charType) {\n\t\treturn this.trimStart(charType).trimEnd(charType);\n\t}\n\n\ttrimStart(charType) {\n\t\tconst rx = new RegExp('^' + (charType || '\\\\s') + '+');\n\t\tthis.intro = this.intro.replace(rx, '');\n\n\t\tif (!this.intro) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i++];\n\t\t\t\tif (!source) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} while (!source.content.trimStartAborted(charType));\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttrimEnd(charType) {\n\t\tconst rx = new RegExp((charType || '\\\\s') + '+$');\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i--];\n\t\t\tif (!source) {\n\t\t\t\tthis.intro = this.intro.replace(rx, '');\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (!source.content.trimEndAborted(charType));\n\n\t\treturn this;\n\t}\n}\n"],"names":["const","let","this"],"mappings":";;AAAe,IAAM,MAAM,GAC1B,eAAW,CAAC,GAAG,EAAE;AAClB,CAAE,IAAI,CAAC,IAAI,GAAG,GAAG,YAAY,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;AAC3D,EAAC;AACF;iBACC,oBAAI,CAAC,EAAE;AACR,CAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AACpC,EAAC;AACF;iBACC,oBAAI,CAAC,EAAE;AACR,CAAE,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAChD;;ACXc,IAAM,KAAK,GACzB,cAAW,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE;AAClC,CAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC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EAAE;AAChB,GAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5C,GAAI,MAAM;AACV,GAAI;AACJ,EAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;AACrD;AACA,CAAE,OAAO,IAAI,CAAC;AACb;;;;"} \ No newline at end of file diff --git a/node_modules/magic-string/dist/magic-string.umd.js b/node_modules/magic-string/dist/magic-string.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..573a4e1b651137ebcee4d87975d31d8c10afc5b8 --- /dev/null +++ b/node_modules/magic-string/dist/magic-string.umd.js @@ -0,0 +1,1371 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.MagicString = factory()); +})(this, (function () { 'use strict'; + + var BitSet = function BitSet(arg) { + this.bits = arg instanceof BitSet ? arg.bits.slice() : []; + }; + + BitSet.prototype.add = function add (n) { + this.bits[n >> 5] |= 1 << (n & 31); + }; + + BitSet.prototype.has = function has (n) { + return !!(this.bits[n >> 5] & (1 << (n & 31))); + }; + + var Chunk = function Chunk(start, end, content) { + this.start = start; + this.end = end; + this.original = content; + + this.intro = ''; + this.outro = ''; + + this.content = content; + this.storeName = false; + this.edited = false; + + // we make these non-enumerable, for sanity while debugging + Object.defineProperties(this, { + previous: { writable: true, value: null }, + next: { writable: true, value: null }, + }); + }; + + Chunk.prototype.appendLeft = function appendLeft (content) { + this.outro += content; + }; + + Chunk.prototype.appendRight = function appendRight (content) { + this.intro = this.intro + content; + }; + + Chunk.prototype.clone = function clone () { + var chunk = new Chunk(this.start, this.end, this.original); + + chunk.intro = this.intro; + chunk.outro = this.outro; + chunk.content = this.content; + chunk.storeName = this.storeName; + chunk.edited = this.edited; + + return chunk; + }; + + Chunk.prototype.contains = function contains (index) { + return this.start < index && index < this.end; + }; + + Chunk.prototype.eachNext = function eachNext (fn) { + var chunk = this; + while (chunk) { + fn(chunk); + chunk = chunk.next; + } + }; + + Chunk.prototype.eachPrevious = function eachPrevious (fn) { + var chunk = this; + while (chunk) { + fn(chunk); + chunk = chunk.previous; + } + }; + + Chunk.prototype.edit = function edit (content, storeName, contentOnly) { + this.content = content; + if (!contentOnly) { + this.intro = ''; + this.outro = ''; + } + this.storeName = storeName; + + this.edited = true; + + return this; + }; + + Chunk.prototype.prependLeft = function prependLeft (content) { + this.outro = content + this.outro; + }; + + Chunk.prototype.prependRight = function prependRight (content) { + this.intro = content + this.intro; + }; + + Chunk.prototype.split = function split (index) { + var sliceIndex = index - this.start; + + var originalBefore = this.original.slice(0, sliceIndex); + var originalAfter = this.original.slice(sliceIndex); + + this.original = originalBefore; + + var newChunk = new Chunk(index, this.end, originalAfter); + newChunk.outro = this.outro; + this.outro = ''; + + this.end = index; + + if (this.edited) { + // TODO is this block necessary?... + newChunk.edit('', false); + this.content = ''; + } else { + this.content = originalBefore; + } + + newChunk.next = this.next; + if (newChunk.next) { newChunk.next.previous = newChunk; } + newChunk.previous = this; + this.next = newChunk; + + return newChunk; + }; + + Chunk.prototype.toString = function toString () { + return this.intro + this.content + this.outro; + }; + + Chunk.prototype.trimEnd = function trimEnd (rx) { + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + + var trimmed = this.content.replace(rx, ''); + + if (trimmed.length) { + if (trimmed !== this.content) { + this.split(this.start + trimmed.length).edit('', undefined, true); + } + return true; + } else { + this.edit('', undefined, true); + + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + } + }; + + Chunk.prototype.trimStart = function trimStart (rx) { + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + + var trimmed = this.content.replace(rx, ''); + + if (trimmed.length) { + if (trimmed !== this.content) { + this.split(this.end - trimmed.length); + this.edit('', undefined, true); + } + return true; + } else { + this.edit('', undefined, true); + + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + } + }; + + var charToInteger = {}; + var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + for (var i = 0; i < chars.length; i++) { + charToInteger[chars.charCodeAt(i)] = i; + } + function encode(decoded) { + var sourceFileIndex = 0; // second field + var sourceCodeLine = 0; // third field + var sourceCodeColumn = 0; // fourth field + var nameIndex = 0; // fifth field + var mappings = ''; + for (var i = 0; i < decoded.length; i++) { + var line = decoded[i]; + if (i > 0) + mappings += ';'; + if (line.length === 0) + continue; + var generatedCodeColumn = 0; // first field + var lineMappings = []; + for (var _i = 0, line_1 = line; _i < line_1.length; _i++) { + var segment = line_1[_i]; + var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn); + generatedCodeColumn = segment[0]; + if (segment.length > 1) { + segmentMappings += + encodeInteger(segment[1] - sourceFileIndex) + + encodeInteger(segment[2] - sourceCodeLine) + + encodeInteger(segment[3] - sourceCodeColumn); + sourceFileIndex = segment[1]; + sourceCodeLine = segment[2]; + sourceCodeColumn = segment[3]; + } + if (segment.length === 5) { + segmentMappings += encodeInteger(segment[4] - nameIndex); + nameIndex = segment[4]; + } + lineMappings.push(segmentMappings); + } + mappings += lineMappings.join(','); + } + return mappings; + } + function encodeInteger(num) { + var result = ''; + num = num < 0 ? (-num << 1) | 1 : num << 1; + do { + var clamped = num & 31; + num >>>= 5; + if (num > 0) { + clamped |= 32; + } + result += chars[clamped]; + } while (num > 0); + return result; + } + + var btoa = function () { + throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.'); + }; + if (typeof window !== 'undefined' && typeof window.btoa === 'function') { + btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); }; + } else if (typeof Buffer === 'function') { + btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); }; + } + + var SourceMap = function SourceMap(properties) { + this.version = 3; + this.file = properties.file; + this.sources = properties.sources; + this.sourcesContent = properties.sourcesContent; + this.names = properties.names; + this.mappings = encode(properties.mappings); + }; + + SourceMap.prototype.toString = function toString () { + return JSON.stringify(this); + }; + + SourceMap.prototype.toUrl = function toUrl () { + return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString()); + }; + + function guessIndent(code) { + var lines = code.split('\n'); + + var tabbed = lines.filter(function (line) { return /^\t+/.test(line); }); + var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); }); + + if (tabbed.length === 0 && spaced.length === 0) { + return null; + } + + // More lines tabbed than spaced? Assume tabs, and + // default to tabs in the case of a tie (or nothing + // to go on) + if (tabbed.length >= spaced.length) { + return '\t'; + } + + // Otherwise, we need to guess the multiple + var min = spaced.reduce(function (previous, current) { + var numSpaces = /^ +/.exec(current)[0].length; + return Math.min(numSpaces, previous); + }, Infinity); + + return new Array(min + 1).join(' '); + } + + function getRelativePath(from, to) { + var fromParts = from.split(/[/\\]/); + var toParts = to.split(/[/\\]/); + + fromParts.pop(); // get dirname + + while (fromParts[0] === toParts[0]) { + fromParts.shift(); + toParts.shift(); + } + + if (fromParts.length) { + var i = fromParts.length; + while (i--) { fromParts[i] = '..'; } + } + + return fromParts.concat(toParts).join('/'); + } + + var toString = Object.prototype.toString; + + function isObject(thing) { + return toString.call(thing) === '[object Object]'; + } + + function getLocator(source) { + var originalLines = source.split('\n'); + var lineOffsets = []; + + for (var i = 0, pos = 0; i < originalLines.length; i++) { + lineOffsets.push(pos); + pos += originalLines[i].length + 1; + } + + return function locate(index) { + var i = 0; + var j = lineOffsets.length; + while (i < j) { + var m = (i + j) >> 1; + if (index < lineOffsets[m]) { + j = m; + } else { + i = m + 1; + } + } + var line = i - 1; + var column = index - lineOffsets[line]; + return { line: line, column: column }; + }; + } + + var Mappings = function Mappings(hires) { + this.hires = hires; + this.generatedCodeLine = 0; + this.generatedCodeColumn = 0; + this.raw = []; + this.rawSegments = this.raw[this.generatedCodeLine] = []; + this.pending = null; + }; + + Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) { + if (content.length) { + var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column]; + if (nameIndex >= 0) { + segment.push(nameIndex); + } + this.rawSegments.push(segment); + } else if (this.pending) { + this.rawSegments.push(this.pending); + } + + this.advance(content); + this.pending = null; + }; + + Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) { + var originalCharIndex = chunk.start; + var first = true; + + while (originalCharIndex < chunk.end) { + if (this.hires || first || sourcemapLocations.has(originalCharIndex)) { + this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]); + } + + if (original[originalCharIndex] === '\n') { + loc.line += 1; + loc.column = 0; + this.generatedCodeLine += 1; + this.raw[this.generatedCodeLine] = this.rawSegments = []; + this.generatedCodeColumn = 0; + first = true; + } else { + loc.column += 1; + this.generatedCodeColumn += 1; + first = false; + } + + originalCharIndex += 1; + } + + this.pending = null; + }; + + Mappings.prototype.advance = function advance (str) { + if (!str) { return; } + + var lines = str.split('\n'); + + if (lines.length > 1) { + for (var i = 0; i < lines.length - 1; i++) { + this.generatedCodeLine++; + this.raw[this.generatedCodeLine] = this.rawSegments = []; + } + this.generatedCodeColumn = 0; + } + + this.generatedCodeColumn += lines[lines.length - 1].length; + }; + + var n = '\n'; + + var warned = { + insertLeft: false, + insertRight: false, + storeName: false, + }; + + var MagicString = function MagicString(string, options) { + if ( options === void 0 ) options = {}; + + var chunk = new Chunk(0, string.length, string); + + Object.defineProperties(this, { + original: { writable: true, value: string }, + outro: { writable: true, value: '' }, + intro: { writable: true, value: '' }, + firstChunk: { writable: true, value: chunk }, + lastChunk: { writable: true, value: chunk }, + lastSearchedChunk: { writable: true, value: chunk }, + byStart: { writable: true, value: {} }, + byEnd: { writable: true, value: {} }, + filename: { writable: true, value: options.filename }, + indentExclusionRanges: { writable: true, value: options.indentExclusionRanges }, + sourcemapLocations: { writable: true, value: new BitSet() }, + storedNames: { writable: true, value: {} }, + indentStr: { writable: true, value: guessIndent(string) }, + }); + + this.byStart[0] = chunk; + this.byEnd[string.length] = chunk; + }; + + MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) { + this.sourcemapLocations.add(char); + }; + + MagicString.prototype.append = function append (content) { + if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); } + + this.outro += content; + return this; + }; + + MagicString.prototype.appendLeft = function appendLeft (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byEnd[index]; + + if (chunk) { + chunk.appendLeft(content); + } else { + this.intro += content; + } + return this; + }; + + MagicString.prototype.appendRight = function appendRight (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byStart[index]; + + if (chunk) { + chunk.appendRight(content); + } else { + this.outro += content; + } + return this; + }; + + MagicString.prototype.clone = function clone () { + var cloned = new MagicString(this.original, { filename: this.filename }); + + var originalChunk = this.firstChunk; + var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone()); + + while (originalChunk) { + cloned.byStart[clonedChunk.start] = clonedChunk; + cloned.byEnd[clonedChunk.end] = clonedChunk; + + var nextOriginalChunk = originalChunk.next; + var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone(); + + if (nextClonedChunk) { + clonedChunk.next = nextClonedChunk; + nextClonedChunk.previous = clonedChunk; + + clonedChunk = nextClonedChunk; + } + + originalChunk = nextOriginalChunk; + } + + cloned.lastChunk = clonedChunk; + + if (this.indentExclusionRanges) { + cloned.indentExclusionRanges = this.indentExclusionRanges.slice(); + } + + cloned.sourcemapLocations = new BitSet(this.sourcemapLocations); + + cloned.intro = this.intro; + cloned.outro = this.outro; + + return cloned; + }; + + MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) { + var this$1$1 = this; + + options = options || {}; + + var sourceIndex = 0; + var names = Object.keys(this.storedNames); + var mappings = new Mappings(options.hires); + + var locate = getLocator(this.original); + + if (this.intro) { + mappings.advance(this.intro); + } + + this.firstChunk.eachNext(function (chunk) { + var loc = locate(chunk.start); + + if (chunk.intro.length) { mappings.advance(chunk.intro); } + + if (chunk.edited) { + mappings.addEdit( + sourceIndex, + chunk.content, + loc, + chunk.storeName ? names.indexOf(chunk.original) : -1 + ); + } else { + mappings.addUneditedChunk(sourceIndex, chunk, this$1$1.original, loc, this$1$1.sourcemapLocations); + } + + if (chunk.outro.length) { mappings.advance(chunk.outro); } + }); + + return { + file: options.file ? options.file.split(/[/\\]/).pop() : null, + sources: [options.source ? getRelativePath(options.file || '', options.source) : null], + sourcesContent: options.includeContent ? [this.original] : [null], + names: names, + mappings: mappings.raw, + }; + }; + + MagicString.prototype.generateMap = function generateMap (options) { + return new SourceMap(this.generateDecodedMap(options)); + }; + + MagicString.prototype.getIndentString = function getIndentString () { + return this.indentStr === null ? '\t' : this.indentStr; + }; + + MagicString.prototype.indent = function indent (indentStr, options) { + var pattern = /^[^\r\n]/gm; + + if (isObject(indentStr)) { + options = indentStr; + indentStr = undefined; + } + + indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t'; + + if (indentStr === '') { return this; } // noop + + options = options || {}; + + // Process exclusion ranges + var isExcluded = {}; + + if (options.exclude) { + var exclusions = + typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude; + exclusions.forEach(function (exclusion) { + for (var i = exclusion[0]; i < exclusion[1]; i += 1) { + isExcluded[i] = true; + } + }); + } + + var shouldIndentNextCharacter = options.indentStart !== false; + var replacer = function (match) { + if (shouldIndentNextCharacter) { return ("" + indentStr + match); } + shouldIndentNextCharacter = true; + return match; + }; + + this.intro = this.intro.replace(pattern, replacer); + + var charIndex = 0; + var chunk = this.firstChunk; + + while (chunk) { + var end = chunk.end; + + if (chunk.edited) { + if (!isExcluded[charIndex]) { + chunk.content = chunk.content.replace(pattern, replacer); + + if (chunk.content.length) { + shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n'; + } + } + } else { + charIndex = chunk.start; + + while (charIndex < end) { + if (!isExcluded[charIndex]) { + var char = this.original[charIndex]; + + if (char === '\n') { + shouldIndentNextCharacter = true; + } else if (char !== '\r' && shouldIndentNextCharacter) { + shouldIndentNextCharacter = false; + + if (charIndex === chunk.start) { + chunk.prependRight(indentStr); + } else { + this._splitChunk(chunk, charIndex); + chunk = chunk.next; + chunk.prependRight(indentStr); + } + } + } + + charIndex += 1; + } + } + + charIndex = chunk.end; + chunk = chunk.next; + } + + this.outro = this.outro.replace(pattern, replacer); + + return this; + }; + + MagicString.prototype.insert = function insert () { + throw new Error( + 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)' + ); + }; + + MagicString.prototype.insertLeft = function insertLeft (index, content) { + if (!warned.insertLeft) { + console.warn( + 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead' + ); // eslint-disable-line no-console + warned.insertLeft = true; + } + + return this.appendLeft(index, content); + }; + + MagicString.prototype.insertRight = function insertRight (index, content) { + if (!warned.insertRight) { + console.warn( + 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead' + ); // eslint-disable-line no-console + warned.insertRight = true; + } + + return this.prependRight(index, content); + }; + + MagicString.prototype.move = function move (start, end, index) { + if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); } + + this._split(start); + this._split(end); + this._split(index); + + var first = this.byStart[start]; + var last = this.byEnd[end]; + + var oldLeft = first.previous; + var oldRight = last.next; + + var newRight = this.byStart[index]; + if (!newRight && last === this.lastChunk) { return this; } + var newLeft = newRight ? newRight.previous : this.lastChunk; + + if (oldLeft) { oldLeft.next = oldRight; } + if (oldRight) { oldRight.previous = oldLeft; } + + if (newLeft) { newLeft.next = first; } + if (newRight) { newRight.previous = last; } + + if (!first.previous) { this.firstChunk = last.next; } + if (!last.next) { + this.lastChunk = first.previous; + this.lastChunk.next = null; + } + + first.previous = newLeft; + last.next = newRight || null; + + if (!newLeft) { this.firstChunk = first; } + if (!newRight) { this.lastChunk = last; } + return this; + }; + + MagicString.prototype.overwrite = function overwrite (start, end, content, options) { + if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); } + + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + if (end > this.original.length) { throw new Error('end is out of bounds'); } + if (start === end) + { throw new Error( + 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead' + ); } + + this._split(start); + this._split(end); + + if (options === true) { + if (!warned.storeName) { + console.warn( + 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string' + ); // eslint-disable-line no-console + warned.storeName = true; + } + + options = { storeName: true }; + } + var storeName = options !== undefined ? options.storeName : false; + var contentOnly = options !== undefined ? options.contentOnly : false; + + if (storeName) { + var original = this.original.slice(start, end); + Object.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true }); + } + + var first = this.byStart[start]; + var last = this.byEnd[end]; + + if (first) { + var chunk = first; + while (chunk !== last) { + if (chunk.next !== this.byStart[chunk.end]) { + throw new Error('Cannot overwrite across a split point'); + } + chunk = chunk.next; + chunk.edit('', false); + } + + first.edit(content, storeName, contentOnly); + } else { + // must be inserting at the end + var newChunk = new Chunk(start, end, '').edit(content, storeName); + + // TODO last chunk in the array may not be the last chunk, if it's moved... + last.next = newChunk; + newChunk.previous = last; + } + return this; + }; + + MagicString.prototype.prepend = function prepend (content) { + if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); } + + this.intro = content + this.intro; + return this; + }; + + MagicString.prototype.prependLeft = function prependLeft (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byEnd[index]; + + if (chunk) { + chunk.prependLeft(content); + } else { + this.intro = content + this.intro; + } + return this; + }; + + MagicString.prototype.prependRight = function prependRight (index, content) { + if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); } + + this._split(index); + + var chunk = this.byStart[index]; + + if (chunk) { + chunk.prependRight(content); + } else { + this.outro = content + this.outro; + } + return this; + }; + + MagicString.prototype.remove = function remove (start, end) { + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + if (start === end) { return this; } + + if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); } + if (start > end) { throw new Error('end must be greater than start'); } + + this._split(start); + this._split(end); + + var chunk = this.byStart[start]; + + while (chunk) { + chunk.intro = ''; + chunk.outro = ''; + chunk.edit(''); + + chunk = end > chunk.end ? this.byStart[chunk.end] : null; + } + return this; + }; + + MagicString.prototype.lastChar = function lastChar () { + if (this.outro.length) { return this.outro[this.outro.length - 1]; } + var chunk = this.lastChunk; + do { + if (chunk.outro.length) { return chunk.outro[chunk.outro.length - 1]; } + if (chunk.content.length) { return chunk.content[chunk.content.length - 1]; } + if (chunk.intro.length) { return chunk.intro[chunk.intro.length - 1]; } + } while ((chunk = chunk.previous)); + if (this.intro.length) { return this.intro[this.intro.length - 1]; } + return ''; + }; + + MagicString.prototype.lastLine = function lastLine () { + var lineIndex = this.outro.lastIndexOf(n); + if (lineIndex !== -1) { return this.outro.substr(lineIndex + 1); } + var lineStr = this.outro; + var chunk = this.lastChunk; + do { + if (chunk.outro.length > 0) { + lineIndex = chunk.outro.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.outro.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.outro + lineStr; + } + + if (chunk.content.length > 0) { + lineIndex = chunk.content.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.content.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.content + lineStr; + } + + if (chunk.intro.length > 0) { + lineIndex = chunk.intro.lastIndexOf(n); + if (lineIndex !== -1) { return chunk.intro.substr(lineIndex + 1) + lineStr; } + lineStr = chunk.intro + lineStr; + } + } while ((chunk = chunk.previous)); + lineIndex = this.intro.lastIndexOf(n); + if (lineIndex !== -1) { return this.intro.substr(lineIndex + 1) + lineStr; } + return this.intro + lineStr; + }; + + MagicString.prototype.slice = function slice (start, end) { + if ( start === void 0 ) start = 0; + if ( end === void 0 ) end = this.original.length; + + while (start < 0) { start += this.original.length; } + while (end < 0) { end += this.original.length; } + + var result = ''; + + // find start chunk + var chunk = this.firstChunk; + while (chunk && (chunk.start > start || chunk.end <= start)) { + // found end chunk before start + if (chunk.start < end && chunk.end >= end) { + return result; + } + + chunk = chunk.next; + } + + if (chunk && chunk.edited && chunk.start !== start) + { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); } + + var startChunk = chunk; + while (chunk) { + if (chunk.intro && (startChunk !== chunk || chunk.start === start)) { + result += chunk.intro; + } + + var containsEnd = chunk.start < end && chunk.end >= end; + if (containsEnd && chunk.edited && chunk.end !== end) + { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); } + + var sliceStart = startChunk === chunk ? start - chunk.start : 0; + var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length; + + result += chunk.content.slice(sliceStart, sliceEnd); + + if (chunk.outro && (!containsEnd || chunk.end === end)) { + result += chunk.outro; + } + + if (containsEnd) { + break; + } + + chunk = chunk.next; + } + + return result; + }; + + // TODO deprecate this? not really very useful + MagicString.prototype.snip = function snip (start, end) { + var clone = this.clone(); + clone.remove(0, start); + clone.remove(end, clone.original.length); + + return clone; + }; + + MagicString.prototype._split = function _split (index) { + if (this.byStart[index] || this.byEnd[index]) { return; } + + var chunk = this.lastSearchedChunk; + var searchForward = index > chunk.end; + + while (chunk) { + if (chunk.contains(index)) { return this._splitChunk(chunk, index); } + + chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start]; + } + }; + + MagicString.prototype._splitChunk = function _splitChunk (chunk, index) { + if (chunk.edited && chunk.content.length) { + // zero-length edited chunks are a special case (overlapping replacements) + var loc = getLocator(this.original)(index); + throw new Error( + ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")") + ); + } + + var newChunk = chunk.split(index); + + this.byEnd[index] = chunk; + this.byStart[index] = newChunk; + this.byEnd[newChunk.end] = newChunk; + + if (chunk === this.lastChunk) { this.lastChunk = newChunk; } + + this.lastSearchedChunk = chunk; + return true; + }; + + MagicString.prototype.toString = function toString () { + var str = this.intro; + + var chunk = this.firstChunk; + while (chunk) { + str += chunk.toString(); + chunk = chunk.next; + } + + return str + this.outro; + }; + + MagicString.prototype.isEmpty = function isEmpty () { + var chunk = this.firstChunk; + do { + if ( + (chunk.intro.length && chunk.intro.trim()) || + (chunk.content.length && chunk.content.trim()) || + (chunk.outro.length && chunk.outro.trim()) + ) + { return false; } + } while ((chunk = chunk.next)); + return true; + }; + + MagicString.prototype.length = function length () { + var chunk = this.firstChunk; + var length = 0; + do { + length += chunk.intro.length + chunk.content.length + chunk.outro.length; + } while ((chunk = chunk.next)); + return length; + }; + + MagicString.prototype.trimLines = function trimLines () { + return this.trim('[\\r\\n]'); + }; + + MagicString.prototype.trim = function trim (charType) { + return this.trimStart(charType).trimEnd(charType); + }; + + MagicString.prototype.trimEndAborted = function trimEndAborted (charType) { + var rx = new RegExp((charType || '\\s') + '+$'); + + this.outro = this.outro.replace(rx, ''); + if (this.outro.length) { return true; } + + var chunk = this.lastChunk; + + do { + var end = chunk.end; + var aborted = chunk.trimEnd(rx); + + // if chunk was trimmed, we have a new lastChunk + if (chunk.end !== end) { + if (this.lastChunk === chunk) { + this.lastChunk = chunk.next; + } + + this.byEnd[chunk.end] = chunk; + this.byStart[chunk.next.start] = chunk.next; + this.byEnd[chunk.next.end] = chunk.next; + } + + if (aborted) { return true; } + chunk = chunk.previous; + } while (chunk); + + return false; + }; + + MagicString.prototype.trimEnd = function trimEnd (charType) { + this.trimEndAborted(charType); + return this; + }; + MagicString.prototype.trimStartAborted = function trimStartAborted (charType) { + var rx = new RegExp('^' + (charType || '\\s') + '+'); + + this.intro = this.intro.replace(rx, ''); + if (this.intro.length) { return true; } + + var chunk = this.firstChunk; + + do { + var end = chunk.end; + var aborted = chunk.trimStart(rx); + + if (chunk.end !== end) { + // special case... + if (chunk === this.lastChunk) { this.lastChunk = chunk.next; } + + this.byEnd[chunk.end] = chunk; + this.byStart[chunk.next.start] = chunk.next; + this.byEnd[chunk.next.end] = chunk.next; + } + + if (aborted) { return true; } + chunk = chunk.next; + } while (chunk); + + return false; + }; + + MagicString.prototype.trimStart = function trimStart (charType) { + this.trimStartAborted(charType); + return this; + }; + + var hasOwnProp = Object.prototype.hasOwnProperty; + + var Bundle = function Bundle(options) { + if ( options === void 0 ) options = {}; + + this.intro = options.intro || ''; + this.separator = options.separator !== undefined ? options.separator : '\n'; + this.sources = []; + this.uniqueSources = []; + this.uniqueSourceIndexByFilename = {}; + }; + + Bundle.prototype.addSource = function addSource (source) { + if (source instanceof MagicString) { + return this.addSource({ + content: source, + filename: source.filename, + separator: this.separator, + }); + } + + if (!isObject(source) || !source.content) { + throw new Error( + 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' + ); + } + + ['filename', 'indentExclusionRanges', 'separator'].forEach(function (option) { + if (!hasOwnProp.call(source, option)) { source[option] = source.content[option]; } + }); + + if (source.separator === undefined) { + // TODO there's a bunch of this sort of thing, needs cleaning up + source.separator = this.separator; + } + + if (source.filename) { + if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) { + this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length; + this.uniqueSources.push({ filename: source.filename, content: source.content.original }); + } else { + var uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]]; + if (source.content.original !== uniqueSource.content) { + throw new Error(("Illegal source: same filename (" + (source.filename) + "), different contents")); + } + } + } + + this.sources.push(source); + return this; + }; + + Bundle.prototype.append = function append (str, options) { + this.addSource({ + content: new MagicString(str), + separator: (options && options.separator) || '', + }); + + return this; + }; + + Bundle.prototype.clone = function clone () { + var bundle = new Bundle({ + intro: this.intro, + separator: this.separator, + }); + + this.sources.forEach(function (source) { + bundle.addSource({ + filename: source.filename, + content: source.content.clone(), + separator: source.separator, + }); + }); + + return bundle; + }; + + Bundle.prototype.generateDecodedMap = function generateDecodedMap (options) { + var this$1$1 = this; + if ( options === void 0 ) options = {}; + + var names = []; + this.sources.forEach(function (source) { + Object.keys(source.content.storedNames).forEach(function (name) { + if (!~names.indexOf(name)) { names.push(name); } + }); + }); + + var mappings = new Mappings(options.hires); + + if (this.intro) { + mappings.advance(this.intro); + } + + this.sources.forEach(function (source, i) { + if (i > 0) { + mappings.advance(this$1$1.separator); + } + + var sourceIndex = source.filename ? this$1$1.uniqueSourceIndexByFilename[source.filename] : -1; + var magicString = source.content; + var locate = getLocator(magicString.original); + + if (magicString.intro) { + mappings.advance(magicString.intro); + } + + magicString.firstChunk.eachNext(function (chunk) { + var loc = locate(chunk.start); + + if (chunk.intro.length) { mappings.advance(chunk.intro); } + + if (source.filename) { + if (chunk.edited) { + mappings.addEdit( + sourceIndex, + chunk.content, + loc, + chunk.storeName ? names.indexOf(chunk.original) : -1 + ); + } else { + mappings.addUneditedChunk( + sourceIndex, + chunk, + magicString.original, + loc, + magicString.sourcemapLocations + ); + } + } else { + mappings.advance(chunk.content); + } + + if (chunk.outro.length) { mappings.advance(chunk.outro); } + }); + + if (magicString.outro) { + mappings.advance(magicString.outro); + } + }); + + return { + file: options.file ? options.file.split(/[/\\]/).pop() : null, + sources: this.uniqueSources.map(function (source) { + return options.file ? getRelativePath(options.file, source.filename) : source.filename; + }), + sourcesContent: this.uniqueSources.map(function (source) { + return options.includeContent ? source.content : null; + }), + names: names, + mappings: mappings.raw, + }; + }; + + Bundle.prototype.generateMap = function generateMap (options) { + return new SourceMap(this.generateDecodedMap(options)); + }; + + Bundle.prototype.getIndentString = function getIndentString () { + var indentStringCounts = {}; + + this.sources.forEach(function (source) { + var indentStr = source.content.indentStr; + + if (indentStr === null) { return; } + + if (!indentStringCounts[indentStr]) { indentStringCounts[indentStr] = 0; } + indentStringCounts[indentStr] += 1; + }); + + return ( + Object.keys(indentStringCounts).sort(function (a, b) { + return indentStringCounts[a] - indentStringCounts[b]; + })[0] || '\t' + ); + }; + + Bundle.prototype.indent = function indent (indentStr) { + var this$1$1 = this; + + if (!arguments.length) { + indentStr = this.getIndentString(); + } + + if (indentStr === '') { return this; } // noop + + var trailingNewline = !this.intro || this.intro.slice(-1) === '\n'; + + this.sources.forEach(function (source, i) { + var separator = source.separator !== undefined ? source.separator : this$1$1.separator; + var indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator)); + + source.content.indent(indentStr, { + exclude: source.indentExclusionRanges, + indentStart: indentStart, //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator ) + }); + + trailingNewline = source.content.lastChar() === '\n'; + }); + + if (this.intro) { + this.intro = + indentStr + + this.intro.replace(/^[^\n]/gm, function (match, index) { + return index > 0 ? indentStr + match : match; + }); + } + + return this; + }; + + Bundle.prototype.prepend = function prepend (str) { + this.intro = str + this.intro; + return this; + }; + + Bundle.prototype.toString = function toString () { + var this$1$1 = this; + + var body = this.sources + .map(function (source, i) { + var separator = source.separator !== undefined ? source.separator : this$1$1.separator; + var str = (i > 0 ? separator : '') + source.content.toString(); + + return str; + }) + .join(''); + + return this.intro + body; + }; + + Bundle.prototype.isEmpty = function isEmpty () { + if (this.intro.length && this.intro.trim()) { return false; } + if (this.sources.some(function (source) { return !source.content.isEmpty(); })) { return false; } + return true; + }; + + Bundle.prototype.length = function length () { + return this.sources.reduce( + function (length, source) { return length + source.content.length(); }, + this.intro.length + ); + }; + + Bundle.prototype.trimLines = function trimLines () { + return this.trim('[\\r\\n]'); + }; + + Bundle.prototype.trim = function trim (charType) { + return this.trimStart(charType).trimEnd(charType); + }; + + Bundle.prototype.trimStart = function trimStart (charType) { + var rx = new RegExp('^' + (charType || '\\s') + '+'); + this.intro = this.intro.replace(rx, ''); + + if (!this.intro) { + var source; + var i = 0; + + do { + source = this.sources[i++]; + if (!source) { + break; + } + } while (!source.content.trimStartAborted(charType)); + } + + return this; + }; + + Bundle.prototype.trimEnd = function trimEnd (charType) { + var rx = new RegExp((charType || '\\s') + '+$'); + + var source; + var i = this.sources.length - 1; + + do { + source = this.sources[i--]; + if (!source) { + this.intro = this.intro.replace(rx, ''); + break; + } + } while (!source.content.trimEndAborted(charType)); + + return this; + }; + + MagicString.Bundle = Bundle; + MagicString.SourceMap = SourceMap; + MagicString.default = MagicString; // work around TypeScript bug https://github.com/Rich-Harris/magic-string/pull/121 + + return MagicString; + +})); +//# sourceMappingURL=magic-string.umd.js.map diff --git a/node_modules/magic-string/dist/magic-string.umd.js.map b/node_modules/magic-string/dist/magic-string.umd.js.map new file mode 100644 index 0000000000000000000000000000000000000000..70607d0221f34f8013d692b500cb92f1c149d3f0 --- /dev/null +++ b/node_modules/magic-string/dist/magic-string.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"magic-string.umd.js","sources":["../src/BitSet.js","../src/Chunk.js","../node_modules/sourcemap-codec/dist/sourcemap-codec.es.js","../src/SourceMap.js","../src/utils/guessIndent.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/getLocator.js","../src/utils/Mappings.js","../src/MagicString.js","../src/Bundle.js","../src/index-legacy.js"],"sourcesContent":["export default class BitSet {\n\tconstructor(arg) {\n\t\tthis.bits = arg instanceof BitSet ? arg.bits.slice() : [];\n\t}\n\n\tadd(n) {\n\t\tthis.bits[n >> 5] |= 1 << (n & 31);\n\t}\n\n\thas(n) {\n\t\treturn !!(this.bits[n >> 5] & (1 << (n & 31)));\n\t}\n}\n","export default class Chunk {\n\tconstructor(start, end, content) {\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t\tthis.original = content;\n\n\t\tthis.intro = '';\n\t\tthis.outro = '';\n\n\t\tthis.content = content;\n\t\tthis.storeName = false;\n\t\tthis.edited = false;\n\n\t\t// we make these non-enumerable, for sanity while debugging\n\t\tObject.defineProperties(this, {\n\t\t\tprevious: { writable: true, value: null },\n\t\t\tnext: { writable: true, value: null },\n\t\t});\n\t}\n\n\tappendLeft(content) {\n\t\tthis.outro += content;\n\t}\n\n\tappendRight(content) {\n\t\tthis.intro = this.intro + content;\n\t}\n\n\tclone() {\n\t\tconst chunk = new Chunk(this.start, this.end, this.original);\n\n\t\tchunk.intro = this.intro;\n\t\tchunk.outro = this.outro;\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t}\n\n\tcontains(index) {\n\t\treturn this.start < index && index < this.end;\n\t}\n\n\teachNext(fn) {\n\t\tlet chunk = this;\n\t\twhile (chunk) {\n\t\t\tfn(chunk);\n\t\t\tchunk = chunk.next;\n\t\t}\n\t}\n\n\teachPrevious(fn) {\n\t\tlet chunk = this;\n\t\twhile (chunk) {\n\t\t\tfn(chunk);\n\t\t\tchunk = chunk.previous;\n\t\t}\n\t}\n\n\tedit(content, storeName, contentOnly) {\n\t\tthis.content = content;\n\t\tif (!contentOnly) {\n\t\t\tthis.intro = '';\n\t\t\tthis.outro = '';\n\t\t}\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t}\n\n\tprependLeft(content) {\n\t\tthis.outro = content + this.outro;\n\t}\n\n\tprependRight(content) {\n\t\tthis.intro = content + this.intro;\n\t}\n\n\tsplit(index) {\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice(0, sliceIndex);\n\t\tconst originalAfter = this.original.slice(sliceIndex);\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk(index, this.end, originalAfter);\n\t\tnewChunk.outro = this.outro;\n\t\tthis.outro = '';\n\n\t\tthis.end = index;\n\n\t\tif (this.edited) {\n\t\t\t// TODO is this block necessary?...\n\t\t\tnewChunk.edit('', false);\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\tnewChunk.next = this.next;\n\t\tif (newChunk.next) newChunk.next.previous = newChunk;\n\t\tnewChunk.previous = this;\n\t\tthis.next = newChunk;\n\n\t\treturn newChunk;\n\t}\n\n\ttoString() {\n\t\treturn this.intro + this.content + this.outro;\n\t}\n\n\ttrimEnd(rx) {\n\t\tthis.outro = this.outro.replace(rx, '');\n\t\tif (this.outro.length) return true;\n\n\t\tconst trimmed = this.content.replace(rx, '');\n\n\t\tif (trimmed.length) {\n\t\t\tif (trimmed !== this.content) {\n\t\t\t\tthis.split(this.start + trimmed.length).edit('', undefined, true);\n\t\t\t}\n\t\t\treturn true;\n\t\t} else {\n\t\t\tthis.edit('', undefined, true);\n\n\t\t\tthis.intro = this.intro.replace(rx, '');\n\t\t\tif (this.intro.length) return true;\n\t\t}\n\t}\n\n\ttrimStart(rx) {\n\t\tthis.intro = this.intro.replace(rx, '');\n\t\tif (this.intro.length) return true;\n\n\t\tconst trimmed = this.content.replace(rx, '');\n\n\t\tif (trimmed.length) {\n\t\t\tif (trimmed !== this.content) {\n\t\t\t\tthis.split(this.end - trimmed.length);\n\t\t\t\tthis.edit('', undefined, true);\n\t\t\t}\n\t\t\treturn true;\n\t\t} else {\n\t\t\tthis.edit('', undefined, true);\n\n\t\t\tthis.outro = this.outro.replace(rx, '');\n\t\t\tif (this.outro.length) return true;\n\t\t}\n\t}\n}\n","var charToInteger = {};\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\nfor (var i = 0; i < chars.length; i++) {\n charToInteger[chars.charCodeAt(i)] = i;\n}\nfunction decode(mappings) {\n var decoded = [];\n var line = [];\n var segment = [\n 0,\n 0,\n 0,\n 0,\n 0,\n ];\n var j = 0;\n for (var i = 0, shift = 0, value = 0; i < mappings.length; i++) {\n var c = mappings.charCodeAt(i);\n if (c === 44) { // \",\"\n segmentify(line, segment, j);\n j = 0;\n }\n else if (c === 59) { // \";\"\n segmentify(line, segment, j);\n j = 0;\n decoded.push(line);\n line = [];\n segment[0] = 0;\n }\n else {\n var integer = charToInteger[c];\n if (integer === undefined) {\n throw new Error('Invalid character (' + String.fromCharCode(c) + ')');\n }\n var hasContinuationBit = integer & 32;\n integer &= 31;\n value += integer << shift;\n if (hasContinuationBit) {\n shift += 5;\n }\n else {\n var shouldNegate = value & 1;\n value >>>= 1;\n if (shouldNegate) {\n value = value === 0 ? -0x80000000 : -value;\n }\n segment[j] += value;\n j++;\n value = shift = 0; // reset\n }\n }\n }\n segmentify(line, segment, j);\n decoded.push(line);\n return decoded;\n}\nfunction segmentify(line, segment, j) {\n // This looks ugly, but we're creating specialized arrays with a specific\n // length. This is much faster than creating a new array (which v8 expands to\n // a capacity of 17 after pushing the first item), or slicing out a subarray\n // (which is slow). Length 4 is assumed to be the most frequent, followed by\n // length 5 (since not everything will have an associated name), followed by\n // length 1 (it's probably rare for a source substring to not have an\n // associated segment data).\n if (j === 4)\n line.push([segment[0], segment[1], segment[2], segment[3]]);\n else if (j === 5)\n line.push([segment[0], segment[1], segment[2], segment[3], segment[4]]);\n else if (j === 1)\n line.push([segment[0]]);\n}\nfunction encode(decoded) {\n var sourceFileIndex = 0; // second field\n var sourceCodeLine = 0; // third field\n var sourceCodeColumn = 0; // fourth field\n var nameIndex = 0; // fifth field\n var mappings = '';\n for (var i = 0; i < decoded.length; i++) {\n var line = decoded[i];\n if (i > 0)\n mappings += ';';\n if (line.length === 0)\n continue;\n var generatedCodeColumn = 0; // first field\n var lineMappings = [];\n for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {\n var segment = line_1[_i];\n var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);\n generatedCodeColumn = segment[0];\n if (segment.length > 1) {\n segmentMappings +=\n encodeInteger(segment[1] - sourceFileIndex) +\n encodeInteger(segment[2] - sourceCodeLine) +\n encodeInteger(segment[3] - sourceCodeColumn);\n sourceFileIndex = segment[1];\n sourceCodeLine = segment[2];\n sourceCodeColumn = segment[3];\n }\n if (segment.length === 5) {\n segmentMappings += encodeInteger(segment[4] - nameIndex);\n nameIndex = segment[4];\n }\n lineMappings.push(segmentMappings);\n }\n mappings += lineMappings.join(',');\n }\n return mappings;\n}\nfunction encodeInteger(num) {\n var result = '';\n num = num < 0 ? (-num << 1) | 1 : num << 1;\n do {\n var clamped = num & 31;\n num >>>= 5;\n if (num > 0) {\n clamped |= 32;\n }\n result += chars[clamped];\n } while (num > 0);\n return result;\n}\n\nexport { decode, encode };\n//# sourceMappingURL=sourcemap-codec.es.js.map\n","import { encode } from 'sourcemap-codec';\n\nlet btoa = () => {\n\tthrow new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');\n};\nif (typeof window !== 'undefined' && typeof window.btoa === 'function') {\n\tbtoa = (str) => window.btoa(unescape(encodeURIComponent(str)));\n} else if (typeof Buffer === 'function') {\n\tbtoa = (str) => Buffer.from(str, 'utf-8').toString('base64');\n}\n\nexport default class SourceMap {\n\tconstructor(properties) {\n\t\tthis.version = 3;\n\t\tthis.file = properties.file;\n\t\tthis.sources = properties.sources;\n\t\tthis.sourcesContent = properties.sourcesContent;\n\t\tthis.names = properties.names;\n\t\tthis.mappings = encode(properties.mappings);\n\t}\n\n\ttoString() {\n\t\treturn JSON.stringify(this);\n\t}\n\n\ttoUrl() {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());\n\t}\n}\n","export default function guessIndent(code) {\n\tconst lines = code.split('\\n');\n\n\tconst tabbed = lines.filter((line) => /^\\t+/.test(line));\n\tconst spaced = lines.filter((line) => /^ {2,}/.test(line));\n\n\tif (tabbed.length === 0 && spaced.length === 0) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif (tabbed.length >= spaced.length) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce((previous, current) => {\n\t\tconst numSpaces = /^ +/.exec(current)[0].length;\n\t\treturn Math.min(numSpaces, previous);\n\t}, Infinity);\n\n\treturn new Array(min + 1).join(' ');\n}\n","export default function getRelativePath(from, to) {\n\tconst fromParts = from.split(/[/\\\\]/);\n\tconst toParts = to.split(/[/\\\\]/);\n\n\tfromParts.pop(); // get dirname\n\n\twhile (fromParts[0] === toParts[0]) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif (fromParts.length) {\n\t\tlet i = fromParts.length;\n\t\twhile (i--) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat(toParts).join('/');\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject(thing) {\n\treturn toString.call(thing) === '[object Object]';\n}\n","export default function getLocator(source) {\n\tconst originalLines = source.split('\\n');\n\tconst lineOffsets = [];\n\n\tfor (let i = 0, pos = 0; i < originalLines.length; i++) {\n\t\tlineOffsets.push(pos);\n\t\tpos += originalLines[i].length + 1;\n\t}\n\n\treturn function locate(index) {\n\t\tlet i = 0;\n\t\tlet j = lineOffsets.length;\n\t\twhile (i < j) {\n\t\t\tconst m = (i + j) >> 1;\n\t\t\tif (index < lineOffsets[m]) {\n\t\t\t\tj = m;\n\t\t\t} else {\n\t\t\t\ti = m + 1;\n\t\t\t}\n\t\t}\n\t\tconst line = i - 1;\n\t\tconst column = index - lineOffsets[line];\n\t\treturn { line, column };\n\t};\n}\n","export default class Mappings {\n\tconstructor(hires) {\n\t\tthis.hires = hires;\n\t\tthis.generatedCodeLine = 0;\n\t\tthis.generatedCodeColumn = 0;\n\t\tthis.raw = [];\n\t\tthis.rawSegments = this.raw[this.generatedCodeLine] = [];\n\t\tthis.pending = null;\n\t}\n\n\taddEdit(sourceIndex, content, loc, nameIndex) {\n\t\tif (content.length) {\n\t\t\tconst segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];\n\t\t\tif (nameIndex >= 0) {\n\t\t\t\tsegment.push(nameIndex);\n\t\t\t}\n\t\t\tthis.rawSegments.push(segment);\n\t\t} else if (this.pending) {\n\t\t\tthis.rawSegments.push(this.pending);\n\t\t}\n\n\t\tthis.advance(content);\n\t\tthis.pending = null;\n\t}\n\n\taddUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {\n\t\tlet originalCharIndex = chunk.start;\n\t\tlet first = true;\n\n\t\twhile (originalCharIndex < chunk.end) {\n\t\t\tif (this.hires || first || sourcemapLocations.has(originalCharIndex)) {\n\t\t\t\tthis.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);\n\t\t\t}\n\n\t\t\tif (original[originalCharIndex] === '\\n') {\n\t\t\t\tloc.line += 1;\n\t\t\t\tloc.column = 0;\n\t\t\t\tthis.generatedCodeLine += 1;\n\t\t\t\tthis.raw[this.generatedCodeLine] = this.rawSegments = [];\n\t\t\t\tthis.generatedCodeColumn = 0;\n\t\t\t\tfirst = true;\n\t\t\t} else {\n\t\t\t\tloc.column += 1;\n\t\t\t\tthis.generatedCodeColumn += 1;\n\t\t\t\tfirst = false;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t}\n\n\t\tthis.pending = null;\n\t}\n\n\tadvance(str) {\n\t\tif (!str) return;\n\n\t\tconst lines = str.split('\\n');\n\n\t\tif (lines.length > 1) {\n\t\t\tfor (let i = 0; i < lines.length - 1; i++) {\n\t\t\t\tthis.generatedCodeLine++;\n\t\t\t\tthis.raw[this.generatedCodeLine] = this.rawSegments = [];\n\t\t\t}\n\t\t\tthis.generatedCodeColumn = 0;\n\t\t}\n\n\t\tthis.generatedCodeColumn += lines[lines.length - 1].length;\n\t}\n}\n","import BitSet from './BitSet.js';\nimport Chunk from './Chunk.js';\nimport SourceMap from './SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport getLocator from './utils/getLocator.js';\nimport Mappings from './utils/Mappings.js';\nimport Stats from './utils/Stats.js';\n\nconst n = '\\n';\n\nconst warned = {\n\tinsertLeft: false,\n\tinsertRight: false,\n\tstoreName: false,\n};\n\nexport default class MagicString {\n\tconstructor(string, options = {}) {\n\t\tconst chunk = new Chunk(0, string.length, string);\n\n\t\tObject.defineProperties(this, {\n\t\t\toriginal: { writable: true, value: string },\n\t\t\toutro: { writable: true, value: '' },\n\t\t\tintro: { writable: true, value: '' },\n\t\t\tfirstChunk: { writable: true, value: chunk },\n\t\t\tlastChunk: { writable: true, value: chunk },\n\t\t\tlastSearchedChunk: { writable: true, value: chunk },\n\t\t\tbyStart: { writable: true, value: {} },\n\t\t\tbyEnd: { writable: true, value: {} },\n\t\t\tfilename: { writable: true, value: options.filename },\n\t\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\t\tsourcemapLocations: { writable: true, value: new BitSet() },\n\t\t\tstoredNames: { writable: true, value: {} },\n\t\t\tindentStr: { writable: true, value: guessIndent(string) },\n\t\t});\n\n\t\tif (DEBUG) {\n\t\t\tObject.defineProperty(this, 'stats', { value: new Stats() });\n\t\t}\n\n\t\tthis.byStart[0] = chunk;\n\t\tthis.byEnd[string.length] = chunk;\n\t}\n\n\taddSourcemapLocation(char) {\n\t\tthis.sourcemapLocations.add(char);\n\t}\n\n\tappend(content) {\n\t\tif (typeof content !== 'string') throw new TypeError('outro content must be a string');\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t}\n\n\tappendLeft(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('appendLeft');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byEnd[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.appendLeft(content);\n\t\t} else {\n\t\t\tthis.intro += content;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('appendLeft');\n\t\treturn this;\n\t}\n\n\tappendRight(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('appendRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byStart[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.appendRight(content);\n\t\t} else {\n\t\t\tthis.outro += content;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('appendRight');\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\tconst cloned = new MagicString(this.original, { filename: this.filename });\n\n\t\tlet originalChunk = this.firstChunk;\n\t\tlet clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());\n\n\t\twhile (originalChunk) {\n\t\t\tcloned.byStart[clonedChunk.start] = clonedChunk;\n\t\t\tcloned.byEnd[clonedChunk.end] = clonedChunk;\n\n\t\t\tconst nextOriginalChunk = originalChunk.next;\n\t\t\tconst nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();\n\n\t\t\tif (nextClonedChunk) {\n\t\t\t\tclonedChunk.next = nextClonedChunk;\n\t\t\t\tnextClonedChunk.previous = clonedChunk;\n\n\t\t\t\tclonedChunk = nextClonedChunk;\n\t\t\t}\n\n\t\t\toriginalChunk = nextOriginalChunk;\n\t\t}\n\n\t\tcloned.lastChunk = clonedChunk;\n\n\t\tif (this.indentExclusionRanges) {\n\t\t\tcloned.indentExclusionRanges = this.indentExclusionRanges.slice();\n\t\t}\n\n\t\tcloned.sourcemapLocations = new BitSet(this.sourcemapLocations);\n\n\t\tcloned.intro = this.intro;\n\t\tcloned.outro = this.outro;\n\n\t\treturn cloned;\n\t}\n\n\tgenerateDecodedMap(options) {\n\t\toptions = options || {};\n\n\t\tconst sourceIndex = 0;\n\t\tconst names = Object.keys(this.storedNames);\n\t\tconst mappings = new Mappings(options.hires);\n\n\t\tconst locate = getLocator(this.original);\n\n\t\tif (this.intro) {\n\t\t\tmappings.advance(this.intro);\n\t\t}\n\n\t\tthis.firstChunk.eachNext((chunk) => {\n\t\t\tconst loc = locate(chunk.start);\n\n\t\t\tif (chunk.intro.length) mappings.advance(chunk.intro);\n\n\t\t\tif (chunk.edited) {\n\t\t\t\tmappings.addEdit(\n\t\t\t\t\tsourceIndex,\n\t\t\t\t\tchunk.content,\n\t\t\t\t\tloc,\n\t\t\t\t\tchunk.storeName ? names.indexOf(chunk.original) : -1\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tmappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);\n\t\t\t}\n\n\t\t\tif (chunk.outro.length) mappings.advance(chunk.outro);\n\t\t});\n\n\t\treturn {\n\t\t\tfile: options.file ? options.file.split(/[/\\\\]/).pop() : null,\n\t\t\tsources: [options.source ? getRelativePath(options.file || '', options.source) : null],\n\t\t\tsourcesContent: options.includeContent ? [this.original] : [null],\n\t\t\tnames,\n\t\t\tmappings: mappings.raw,\n\t\t};\n\t}\n\n\tgenerateMap(options) {\n\t\treturn new SourceMap(this.generateDecodedMap(options));\n\t}\n\n\tgetIndentString() {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t}\n\n\tindent(indentStr, options) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif (isObject(indentStr)) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : this.indentStr || '\\t';\n\n\t\tif (indentStr === '') return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tconst isExcluded = {};\n\n\t\tif (options.exclude) {\n\t\t\tconst exclusions =\n\t\t\t\ttypeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;\n\t\t\texclusions.forEach((exclusion) => {\n\t\t\t\tfor (let i = exclusion[0]; i < exclusion[1]; i += 1) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = (match) => {\n\t\t\tif (shouldIndentNextCharacter) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace(pattern, replacer);\n\n\t\tlet charIndex = 0;\n\t\tlet chunk = this.firstChunk;\n\n\t\twhile (chunk) {\n\t\t\tconst end = chunk.end;\n\n\t\t\tif (chunk.edited) {\n\t\t\t\tif (!isExcluded[charIndex]) {\n\t\t\t\t\tchunk.content = chunk.content.replace(pattern, replacer);\n\n\t\t\t\t\tif (chunk.content.length) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile (charIndex < end) {\n\t\t\t\t\tif (!isExcluded[charIndex]) {\n\t\t\t\t\t\tconst char = this.original[charIndex];\n\n\t\t\t\t\t\tif (char === '\\n') {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if (char !== '\\r' && shouldIndentNextCharacter) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tif (charIndex === chunk.start) {\n\t\t\t\t\t\t\t\tchunk.prependRight(indentStr);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis._splitChunk(chunk, charIndex);\n\t\t\t\t\t\t\t\tchunk = chunk.next;\n\t\t\t\t\t\t\t\tchunk.prependRight(indentStr);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\tthis.outro = this.outro.replace(pattern, replacer);\n\n\t\treturn this;\n\t}\n\n\tinsert() {\n\t\tthrow new Error(\n\t\t\t'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'\n\t\t);\n\t}\n\n\tinsertLeft(index, content) {\n\t\tif (!warned.insertLeft) {\n\t\t\tconsole.warn(\n\t\t\t\t'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'\n\t\t\t); // eslint-disable-line no-console\n\t\t\twarned.insertLeft = true;\n\t\t}\n\n\t\treturn this.appendLeft(index, content);\n\t}\n\n\tinsertRight(index, content) {\n\t\tif (!warned.insertRight) {\n\t\t\tconsole.warn(\n\t\t\t\t'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'\n\t\t\t); // eslint-disable-line no-console\n\t\t\twarned.insertRight = true;\n\t\t}\n\n\t\treturn this.prependRight(index, content);\n\t}\n\n\tmove(start, end, index) {\n\t\tif (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');\n\n\t\tif (DEBUG) this.stats.time('move');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\t\tthis._split(index);\n\n\t\tconst first = this.byStart[start];\n\t\tconst last = this.byEnd[end];\n\n\t\tconst oldLeft = first.previous;\n\t\tconst oldRight = last.next;\n\n\t\tconst newRight = this.byStart[index];\n\t\tif (!newRight && last === this.lastChunk) return this;\n\t\tconst newLeft = newRight ? newRight.previous : this.lastChunk;\n\n\t\tif (oldLeft) oldLeft.next = oldRight;\n\t\tif (oldRight) oldRight.previous = oldLeft;\n\n\t\tif (newLeft) newLeft.next = first;\n\t\tif (newRight) newRight.previous = last;\n\n\t\tif (!first.previous) this.firstChunk = last.next;\n\t\tif (!last.next) {\n\t\t\tthis.lastChunk = first.previous;\n\t\t\tthis.lastChunk.next = null;\n\t\t}\n\n\t\tfirst.previous = newLeft;\n\t\tlast.next = newRight || null;\n\n\t\tif (!newLeft) this.firstChunk = first;\n\t\tif (!newRight) this.lastChunk = last;\n\n\t\tif (DEBUG) this.stats.timeEnd('move');\n\t\treturn this;\n\t}\n\n\toverwrite(start, end, content, options) {\n\t\tif (typeof content !== 'string') throw new TypeError('replacement content must be a string');\n\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tif (end > this.original.length) throw new Error('end is out of bounds');\n\t\tif (start === end)\n\t\t\tthrow new Error(\n\t\t\t\t'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'\n\t\t\t);\n\n\t\tif (DEBUG) this.stats.time('overwrite');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\n\t\tif (options === true) {\n\t\t\tif (!warned.storeName) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'\n\t\t\t\t); // eslint-disable-line no-console\n\t\t\t\twarned.storeName = true;\n\t\t\t}\n\n\t\t\toptions = { storeName: true };\n\t\t}\n\t\tconst storeName = options !== undefined ? options.storeName : false;\n\t\tconst contentOnly = options !== undefined ? options.contentOnly : false;\n\n\t\tif (storeName) {\n\t\t\tconst original = this.original.slice(start, end);\n\t\t\tObject.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true });\n\t\t}\n\n\t\tconst first = this.byStart[start];\n\t\tconst last = this.byEnd[end];\n\n\t\tif (first) {\n\t\t\tlet chunk = first;\n\t\t\twhile (chunk !== last) {\n\t\t\t\tif (chunk.next !== this.byStart[chunk.end]) {\n\t\t\t\t\tthrow new Error('Cannot overwrite across a split point');\n\t\t\t\t}\n\t\t\t\tchunk = chunk.next;\n\t\t\t\tchunk.edit('', false);\n\t\t\t}\n\n\t\t\tfirst.edit(content, storeName, contentOnly);\n\t\t} else {\n\t\t\t// must be inserting at the end\n\t\t\tconst newChunk = new Chunk(start, end, '').edit(content, storeName);\n\n\t\t\t// TODO last chunk in the array may not be the last chunk, if it's moved...\n\t\t\tlast.next = newChunk;\n\t\t\tnewChunk.previous = last;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('overwrite');\n\t\treturn this;\n\t}\n\n\tprepend(content) {\n\t\tif (typeof content !== 'string') throw new TypeError('outro content must be a string');\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t}\n\n\tprependLeft(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('insertRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byEnd[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.prependLeft(content);\n\t\t} else {\n\t\t\tthis.intro = content + this.intro;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('insertRight');\n\t\treturn this;\n\t}\n\n\tprependRight(index, content) {\n\t\tif (typeof content !== 'string') throw new TypeError('inserted content must be a string');\n\n\t\tif (DEBUG) this.stats.time('insertRight');\n\n\t\tthis._split(index);\n\n\t\tconst chunk = this.byStart[index];\n\n\t\tif (chunk) {\n\t\t\tchunk.prependRight(content);\n\t\t} else {\n\t\t\tthis.outro = content + this.outro;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('insertRight');\n\t\treturn this;\n\t}\n\n\tremove(start, end) {\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tif (start === end) return this;\n\n\t\tif (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');\n\t\tif (start > end) throw new Error('end must be greater than start');\n\n\t\tif (DEBUG) this.stats.time('remove');\n\n\t\tthis._split(start);\n\t\tthis._split(end);\n\n\t\tlet chunk = this.byStart[start];\n\n\t\twhile (chunk) {\n\t\t\tchunk.intro = '';\n\t\t\tchunk.outro = '';\n\t\t\tchunk.edit('');\n\n\t\t\tchunk = end > chunk.end ? this.byStart[chunk.end] : null;\n\t\t}\n\n\t\tif (DEBUG) this.stats.timeEnd('remove');\n\t\treturn this;\n\t}\n\n\tlastChar() {\n\t\tif (this.outro.length) return this.outro[this.outro.length - 1];\n\t\tlet chunk = this.lastChunk;\n\t\tdo {\n\t\t\tif (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];\n\t\t\tif (chunk.content.length) return chunk.content[chunk.content.length - 1];\n\t\t\tif (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];\n\t\t} while ((chunk = chunk.previous));\n\t\tif (this.intro.length) return this.intro[this.intro.length - 1];\n\t\treturn '';\n\t}\n\n\tlastLine() {\n\t\tlet lineIndex = this.outro.lastIndexOf(n);\n\t\tif (lineIndex !== -1) return this.outro.substr(lineIndex + 1);\n\t\tlet lineStr = this.outro;\n\t\tlet chunk = this.lastChunk;\n\t\tdo {\n\t\t\tif (chunk.outro.length > 0) {\n\t\t\t\tlineIndex = chunk.outro.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.outro + lineStr;\n\t\t\t}\n\n\t\t\tif (chunk.content.length > 0) {\n\t\t\t\tlineIndex = chunk.content.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.content + lineStr;\n\t\t\t}\n\n\t\t\tif (chunk.intro.length > 0) {\n\t\t\t\tlineIndex = chunk.intro.lastIndexOf(n);\n\t\t\t\tif (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;\n\t\t\t\tlineStr = chunk.intro + lineStr;\n\t\t\t}\n\t\t} while ((chunk = chunk.previous));\n\t\tlineIndex = this.intro.lastIndexOf(n);\n\t\tif (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;\n\t\treturn this.intro + lineStr;\n\t}\n\n\tslice(start = 0, end = this.original.length) {\n\t\twhile (start < 0) start += this.original.length;\n\t\twhile (end < 0) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\t// find start chunk\n\t\tlet chunk = this.firstChunk;\n\t\twhile (chunk && (chunk.start > start || chunk.end <= start)) {\n\t\t\t// found end chunk before start\n\t\t\tif (chunk.start < end && chunk.end >= end) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\tif (chunk && chunk.edited && chunk.start !== start)\n\t\t\tthrow new Error(`Cannot use replaced character ${start} as slice start anchor.`);\n\n\t\tconst startChunk = chunk;\n\t\twhile (chunk) {\n\t\t\tif (chunk.intro && (startChunk !== chunk || chunk.start === start)) {\n\t\t\t\tresult += chunk.intro;\n\t\t\t}\n\n\t\t\tconst containsEnd = chunk.start < end && chunk.end >= end;\n\t\t\tif (containsEnd && chunk.edited && chunk.end !== end)\n\t\t\t\tthrow new Error(`Cannot use replaced character ${end} as slice end anchor.`);\n\n\t\t\tconst sliceStart = startChunk === chunk ? start - chunk.start : 0;\n\t\t\tconst sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;\n\n\t\t\tresult += chunk.content.slice(sliceStart, sliceEnd);\n\n\t\t\tif (chunk.outro && (!containsEnd || chunk.end === end)) {\n\t\t\t\tresult += chunk.outro;\n\t\t\t}\n\n\t\t\tif (containsEnd) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// TODO deprecate this? not really very useful\n\tsnip(start, end) {\n\t\tconst clone = this.clone();\n\t\tclone.remove(0, start);\n\t\tclone.remove(end, clone.original.length);\n\n\t\treturn clone;\n\t}\n\n\t_split(index) {\n\t\tif (this.byStart[index] || this.byEnd[index]) return;\n\n\t\tif (DEBUG) this.stats.time('_split');\n\n\t\tlet chunk = this.lastSearchedChunk;\n\t\tconst searchForward = index > chunk.end;\n\n\t\twhile (chunk) {\n\t\t\tif (chunk.contains(index)) return this._splitChunk(chunk, index);\n\n\t\t\tchunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];\n\t\t}\n\t}\n\n\t_splitChunk(chunk, index) {\n\t\tif (chunk.edited && chunk.content.length) {\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tconst loc = getLocator(this.original)(index);\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – \"${chunk.original}\")`\n\t\t\t);\n\t\t}\n\n\t\tconst newChunk = chunk.split(index);\n\n\t\tthis.byEnd[index] = chunk;\n\t\tthis.byStart[index] = newChunk;\n\t\tthis.byEnd[newChunk.end] = newChunk;\n\n\t\tif (chunk === this.lastChunk) this.lastChunk = newChunk;\n\n\t\tthis.lastSearchedChunk = chunk;\n\t\tif (DEBUG) this.stats.timeEnd('_split');\n\t\treturn true;\n\t}\n\n\ttoString() {\n\t\tlet str = this.intro;\n\n\t\tlet chunk = this.firstChunk;\n\t\twhile (chunk) {\n\t\t\tstr += chunk.toString();\n\t\t\tchunk = chunk.next;\n\t\t}\n\n\t\treturn str + this.outro;\n\t}\n\n\tisEmpty() {\n\t\tlet chunk = this.firstChunk;\n\t\tdo {\n\t\t\tif (\n\t\t\t\t(chunk.intro.length && chunk.intro.trim()) ||\n\t\t\t\t(chunk.content.length && chunk.content.trim()) ||\n\t\t\t\t(chunk.outro.length && chunk.outro.trim())\n\t\t\t)\n\t\t\t\treturn false;\n\t\t} while ((chunk = chunk.next));\n\t\treturn true;\n\t}\n\n\tlength() {\n\t\tlet chunk = this.firstChunk;\n\t\tlet length = 0;\n\t\tdo {\n\t\t\tlength += chunk.intro.length + chunk.content.length + chunk.outro.length;\n\t\t} while ((chunk = chunk.next));\n\t\treturn length;\n\t}\n\n\ttrimLines() {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t}\n\n\ttrim(charType) {\n\t\treturn this.trimStart(charType).trimEnd(charType);\n\t}\n\n\ttrimEndAborted(charType) {\n\t\tconst rx = new RegExp((charType || '\\\\s') + '+$');\n\n\t\tthis.outro = this.outro.replace(rx, '');\n\t\tif (this.outro.length) return true;\n\n\t\tlet chunk = this.lastChunk;\n\n\t\tdo {\n\t\t\tconst end = chunk.end;\n\t\t\tconst aborted = chunk.trimEnd(rx);\n\n\t\t\t// if chunk was trimmed, we have a new lastChunk\n\t\t\tif (chunk.end !== end) {\n\t\t\t\tif (this.lastChunk === chunk) {\n\t\t\t\t\tthis.lastChunk = chunk.next;\n\t\t\t\t}\n\n\t\t\t\tthis.byEnd[chunk.end] = chunk;\n\t\t\t\tthis.byStart[chunk.next.start] = chunk.next;\n\t\t\t\tthis.byEnd[chunk.next.end] = chunk.next;\n\t\t\t}\n\n\t\t\tif (aborted) return true;\n\t\t\tchunk = chunk.previous;\n\t\t} while (chunk);\n\n\t\treturn false;\n\t}\n\n\ttrimEnd(charType) {\n\t\tthis.trimEndAborted(charType);\n\t\treturn this;\n\t}\n\ttrimStartAborted(charType) {\n\t\tconst rx = new RegExp('^' + (charType || '\\\\s') + '+');\n\n\t\tthis.intro = this.intro.replace(rx, '');\n\t\tif (this.intro.length) return true;\n\n\t\tlet chunk = this.firstChunk;\n\n\t\tdo {\n\t\t\tconst end = chunk.end;\n\t\t\tconst aborted = chunk.trimStart(rx);\n\n\t\t\tif (chunk.end !== end) {\n\t\t\t\t// special case...\n\t\t\t\tif (chunk === this.lastChunk) this.lastChunk = chunk.next;\n\n\t\t\t\tthis.byEnd[chunk.end] = chunk;\n\t\t\t\tthis.byStart[chunk.next.start] = chunk.next;\n\t\t\t\tthis.byEnd[chunk.next.end] = chunk.next;\n\t\t\t}\n\n\t\t\tif (aborted) return true;\n\t\t\tchunk = chunk.next;\n\t\t} while (chunk);\n\n\t\treturn false;\n\t}\n\n\ttrimStart(charType) {\n\t\tthis.trimStartAborted(charType);\n\t\treturn this;\n\t}\n}\n","import MagicString from './MagicString.js';\nimport SourceMap from './SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport getLocator from './utils/getLocator.js';\nimport Mappings from './utils/Mappings.js';\n\nconst hasOwnProp = Object.prototype.hasOwnProperty;\n\nexport default class Bundle {\n\tconstructor(options = {}) {\n\t\tthis.intro = options.intro || '';\n\t\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\t\tthis.sources = [];\n\t\tthis.uniqueSources = [];\n\t\tthis.uniqueSourceIndexByFilename = {};\n\t}\n\n\taddSource(source) {\n\t\tif (source instanceof MagicString) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator,\n\t\t\t});\n\t\t}\n\n\t\tif (!isObject(source) || !source.content) {\n\t\t\tthrow new Error(\n\t\t\t\t'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`'\n\t\t\t);\n\t\t}\n\n\t\t['filename', 'indentExclusionRanges', 'separator'].forEach((option) => {\n\t\t\tif (!hasOwnProp.call(source, option)) source[option] = source.content[option];\n\t\t});\n\n\t\tif (source.separator === undefined) {\n\t\t\t// TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif (source.filename) {\n\t\t\tif (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];\n\t\t\t\tif (source.content.original !== uniqueSource.content) {\n\t\t\t\t\tthrow new Error(`Illegal source: same filename (${source.filename}), different contents`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push(source);\n\t\treturn this;\n\t}\n\n\tappend(str, options) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString(str),\n\t\t\tseparator: (options && options.separator) || '',\n\t\t});\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator,\n\t\t});\n\n\t\tthis.sources.forEach((source) => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator,\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t}\n\n\tgenerateDecodedMap(options = {}) {\n\t\tconst names = [];\n\t\tthis.sources.forEach((source) => {\n\t\t\tObject.keys(source.content.storedNames).forEach((name) => {\n\t\t\t\tif (!~names.indexOf(name)) names.push(name);\n\t\t\t});\n\t\t});\n\n\t\tconst mappings = new Mappings(options.hires);\n\n\t\tif (this.intro) {\n\t\t\tmappings.advance(this.intro);\n\t\t}\n\n\t\tthis.sources.forEach((source, i) => {\n\t\t\tif (i > 0) {\n\t\t\t\tmappings.advance(this.separator);\n\t\t\t}\n\n\t\t\tconst sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;\n\t\t\tconst magicString = source.content;\n\t\t\tconst locate = getLocator(magicString.original);\n\n\t\t\tif (magicString.intro) {\n\t\t\t\tmappings.advance(magicString.intro);\n\t\t\t}\n\n\t\t\tmagicString.firstChunk.eachNext((chunk) => {\n\t\t\t\tconst loc = locate(chunk.start);\n\n\t\t\t\tif (chunk.intro.length) mappings.advance(chunk.intro);\n\n\t\t\t\tif (source.filename) {\n\t\t\t\t\tif (chunk.edited) {\n\t\t\t\t\t\tmappings.addEdit(\n\t\t\t\t\t\t\tsourceIndex,\n\t\t\t\t\t\t\tchunk.content,\n\t\t\t\t\t\t\tloc,\n\t\t\t\t\t\t\tchunk.storeName ? names.indexOf(chunk.original) : -1\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmappings.addUneditedChunk(\n\t\t\t\t\t\t\tsourceIndex,\n\t\t\t\t\t\t\tchunk,\n\t\t\t\t\t\t\tmagicString.original,\n\t\t\t\t\t\t\tloc,\n\t\t\t\t\t\t\tmagicString.sourcemapLocations\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmappings.advance(chunk.content);\n\t\t\t\t}\n\n\t\t\t\tif (chunk.outro.length) mappings.advance(chunk.outro);\n\t\t\t});\n\n\t\t\tif (magicString.outro) {\n\t\t\t\tmappings.advance(magicString.outro);\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tfile: options.file ? options.file.split(/[/\\\\]/).pop() : null,\n\t\t\tsources: this.uniqueSources.map((source) => {\n\t\t\t\treturn options.file ? getRelativePath(options.file, source.filename) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map((source) => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: mappings.raw,\n\t\t};\n\t}\n\n\tgenerateMap(options) {\n\t\treturn new SourceMap(this.generateDecodedMap(options));\n\t}\n\n\tgetIndentString() {\n\t\tconst indentStringCounts = {};\n\n\t\tthis.sources.forEach((source) => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif (indentStr === null) return;\n\n\t\t\tif (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;\n\t\t\tindentStringCounts[indentStr] += 1;\n\t\t});\n\n\t\treturn (\n\t\t\tObject.keys(indentStringCounts).sort((a, b) => {\n\t\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t\t})[0] || '\\t'\n\t\t);\n\t}\n\n\tindent(indentStr) {\n\t\tif (!arguments.length) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif (indentStr === '') return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice(-1) === '\\n';\n\n\t\tthis.sources.forEach((source, i) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || (i > 0 && /\\r?\\n$/.test(separator));\n\n\t\t\tsource.content.indent(indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart, //: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\ttrailingNewline = source.content.lastChar() === '\\n';\n\t\t});\n\n\t\tif (this.intro) {\n\t\t\tthis.intro =\n\t\t\t\tindentStr +\n\t\t\t\tthis.intro.replace(/^[^\\n]/gm, (match, index) => {\n\t\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tprepend(str) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t}\n\n\ttoString() {\n\t\tconst body = this.sources\n\t\t\t.map((source, i) => {\n\t\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\t\tconst str = (i > 0 ? separator : '') + source.content.toString();\n\n\t\t\t\treturn str;\n\t\t\t})\n\t\t\t.join('');\n\n\t\treturn this.intro + body;\n\t}\n\n\tisEmpty() {\n\t\tif (this.intro.length && this.intro.trim()) return false;\n\t\tif (this.sources.some((source) => !source.content.isEmpty())) return false;\n\t\treturn true;\n\t}\n\n\tlength() {\n\t\treturn this.sources.reduce(\n\t\t\t(length, source) => length + source.content.length(),\n\t\t\tthis.intro.length\n\t\t);\n\t}\n\n\ttrimLines() {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t}\n\n\ttrim(charType) {\n\t\treturn this.trimStart(charType).trimEnd(charType);\n\t}\n\n\ttrimStart(charType) {\n\t\tconst rx = new RegExp('^' + (charType || '\\\\s') + '+');\n\t\tthis.intro = this.intro.replace(rx, '');\n\n\t\tif (!this.intro) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i++];\n\t\t\t\tif (!source) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} while (!source.content.trimStartAborted(charType));\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttrimEnd(charType) {\n\t\tconst rx = new RegExp((charType || '\\\\s') + '+$');\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i--];\n\t\t\tif (!source) {\n\t\t\t\tthis.intro = this.intro.replace(rx, '');\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (!source.content.trimEndAborted(charType));\n\n\t\treturn this;\n\t}\n}\n","import MagicString from './MagicString.js';\nimport Bundle from './Bundle.js';\nimport SourceMap from './SourceMap.js';\n\nMagicString.Bundle = Bundle;\nMagicString.SourceMap = SourceMap;\nMagicString.default = MagicString; // work around TypeScript bug https://github.com/Rich-Harris/magic-string/pull/121\n\nexport default MagicString;\n"],"names":["const","let","this"],"mappings":";;;;;;CAAe,IAAM,MAAM,GAC1B,eAAW,CAAC,GAAG,EAAE;CAClB,CAAE,IAAI,CAAC,IAAI,GAAG,GAAG,YAAY,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;CAC3D,EAAC;AACF;kBACC,oBAAI,CAAC,EAAE;CACR,CAAE,IAAI,CAAC,IAAI,C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AO,CAAC,CAAC,EAAE,CAAC,CAAC;CAC/B,GAAI,IAAI,CAAC,MAAM,EAAE;CACjB,IAAK,MAAM;CACX,IAAK;CACL,GAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE;CACxD,EAAG;AACH;CACA,CAAE,OAAO,IAAI,CAAC;CACb,EAAC;AACF;kBACC,4BAAQ,QAAQ,EAAE;CACnB,CAAED,IAAM,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC;AACpD;CACA,CAAEC,IAAI,MAAM,CAAC;CACb,CAAEA,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AAClC;CACA,CAAE,GAAG;CACL,EAAG,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;CAC9B,EAAG,IAAI,CAAC,MAAM,EAAE;CAChB,GAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;CAC5C,GAAI,MAAM;CACV,GAAI;CACJ,EAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;AACrD;CACA,CAAE,OAAO,IAAI,CAAC;CACb;;CC1RD,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;CAC5B,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;CAClC,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/magic-string/index.d.ts b/node_modules/magic-string/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..343c49dc2d896fff1c665a2eb137db5b13a40a31 --- /dev/null +++ b/node_modules/magic-string/index.d.ts @@ -0,0 +1,221 @@ +export interface BundleOptions { + intro?: string; + separator?: string; +} + +export interface SourceMapOptions { + /** + * Whether the mapping should be high-resolution. + * Hi-res mappings map every single character, meaning (for example) your devtools will always + * be able to pinpoint the exact location of function calls and so on. + * With lo-res mappings, devtools may only be able to identify the correct + * line - but they're quicker to generate and less bulky. + * If sourcemap locations have been specified with s.addSourceMapLocation(), they will be used here. + */ + hires?: boolean; + /** + * The filename where you plan to write the sourcemap. + */ + file?: string; + /** + * The filename of the file containing the original source. + */ + source?: string; + /** + * Whether to include the original content in the map's sourcesContent array. + */ + includeContent?: boolean; +} + +export type SourceMapSegment = + | [number] + | [number, number, number, number] + | [number, number, number, number, number]; + +export interface DecodedSourceMap { + file: string; + sources: string[]; + sourcesContent: string[]; + names: string[]; + mappings: SourceMapSegment[][]; +} + +export class SourceMap { + constructor(properties: DecodedSourceMap); + + version: number; + file: string; + sources: string[]; + sourcesContent: string[]; + names: string[]; + mappings: string; + + /** + * Returns the equivalent of `JSON.stringify(map)` + */ + toString(): string; + /** + * Returns a DataURI containing the sourcemap. Useful for doing this sort of thing: + * `generateMap(options?: SourceMapOptions): SourceMap;` + */ + toUrl(): string; +} + +export class Bundle { + constructor(options?: BundleOptions); + addSource(source: MagicString | { filename?: string, content: MagicString }): Bundle; + append(str: string, options?: BundleOptions): Bundle; + clone(): Bundle; + generateMap(options?: SourceMapOptions): SourceMap; + generateDecodedMap(options?: SourceMapOptions): DecodedSourceMap; + getIndentString(): string; + indent(indentStr?: string): Bundle; + indentExclusionRanges: ExclusionRange | Array; + prepend(str: string): Bundle; + toString(): string; + trimLines(): Bundle; + trim(charType?: string): Bundle; + trimStart(charType?: string): Bundle; + trimEnd(charType?: string): Bundle; + isEmpty(): boolean; + length(): number; +} + +export type ExclusionRange = [ number, number ]; + +export interface MagicStringOptions { + filename?: string, + indentExclusionRanges?: ExclusionRange | Array; +} + +export interface IndentOptions { + exclude?: ExclusionRange | Array; + indentStart?: boolean; +} + +export interface OverwriteOptions { + storeName?: boolean; + contentOnly?: boolean; +} + +export default class MagicString { + constructor(str: string, options?: MagicStringOptions); + /** + * Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false. + */ + addSourcemapLocation(char: number): void; + /** + * Appends the specified content to the end of the string. + */ + append(content: string): MagicString; + /** + * Appends the specified content at the index in the original string. + * If a range *ending* with index is subsequently moved, the insert will be moved with it. + * See also `s.prependLeft(...)`. + */ + appendLeft(index: number, content: string): MagicString; + /** + * Appends the specified content at the index in the original string. + * If a range *starting* with index is subsequently moved, the insert will be moved with it. + * See also `s.prependRight(...)`. + */ + appendRight(index: number, content: string): MagicString; + /** + * Does what you'd expect. + */ + clone(): MagicString; + /** + * Generates a version 3 sourcemap. + */ + generateMap(options?: SourceMapOptions): SourceMap; + /** + * Generates a sourcemap object with raw mappings in array form, rather than encoded as a string. + * Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead. + */ + generateDecodedMap(options?: SourceMapOptions): DecodedSourceMap; + getIndentString(): string; + + /** + * Prefixes each line of the string with prefix. + * If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character. + */ + indent(options?: IndentOptions): MagicString; + /** + * Prefixes each line of the string with prefix. + * If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character. + * + * The options argument can have an exclude property, which is an array of [start, end] character ranges. + * These ranges will be excluded from the indentation - useful for (e.g.) multiline strings. + */ + indent(indentStr?: string, options?: IndentOptions): MagicString; + indentExclusionRanges: ExclusionRange | Array; + + /** + * Moves the characters from `start and `end` to `index`. + */ + move(start: number, end: number, index: number): MagicString; + /** + * Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply. + * + * The fourth argument is optional. It can have a storeName property — if true, the original name will be stored + * for later inclusion in a sourcemap's names array — and a contentOnly property which determines whether only + * the content is overwritten, or anything that was appended/prepended to the range as well. + */ + overwrite(start: number, end: number, content: string, options?: boolean | OverwriteOptions): MagicString; + /** + * Prepends the string with the specified content. + */ + prepend(content: string): MagicString; + /** + * Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index + */ + prependLeft(index: number, content: string): MagicString; + /** + * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index` + */ + prependRight(index: number, content: string): MagicString; + /** + * Removes the characters from `start` to `end` (of the original string, **not** the generated string). + * Removing the same content twice, or making removals that partially overlap, will cause an error. + */ + remove(start: number, end: number): MagicString; + /** + * Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string. + * Throws error if the indices are for characters that were already removed. + */ + slice(start: number, end: number): string; + /** + * Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed. + */ + snip(start: number, end: number): MagicString; + /** + * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end. + */ + trim(charType?: string): MagicString; + /** + * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start. + */ + trimStart(charType?: string): MagicString; + /** + * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end. + */ + trimEnd(charType?: string): MagicString; + /** + * Removes empty lines from the start and end. + */ + trimLines(): MagicString; + + lastChar(): string; + lastLine(): string; + /** + * Returns true if the resulting source is empty (disregarding white space). + */ + isEmpty(): boolean; + length(): number; + + original: string; + /** + * Returns the generated string. + */ + toString(): string; +} diff --git a/node_modules/magic-string/package.json b/node_modules/magic-string/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b37e177b102c073ab1a5180831f0f43853debb96 --- /dev/null +++ b/node_modules/magic-string/package.json @@ -0,0 +1,52 @@ +{ + "name": "magic-string", + "version": "0.25.9", + "description": "Modify strings, generate sourcemaps", + "keywords": [ + "string", + "string manipulation", + "sourcemap", + "templating", + "transpilation" + ], + "repository": "https://github.com/rich-harris/magic-string", + "license": "MIT", + "author": "Rich Harris", + "main": "dist/magic-string.cjs.js", + "module": "dist/magic-string.es.js", + "jsnext:main": "dist/magic-string.es.js", + "typings": "index.d.ts", + "files": [ + "dist/*", + "index.d.ts", + "README.md" + ], + "scripts": { + "build": "rollup -c", + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", + "format": "prettier --single-quote --print-width 100 --use-tabs --write src/*.js src/**/*.js", + "lint": "eslint src test", + "prepare": "npm run build", + "prepublishOnly": "rm -rf dist && npm test", + "release": "bumpp -x \"npm run changelog\" --all --commit --tag --push && npm publish", + "pretest": "npm run lint && npm run build", + "test": "mocha", + "watch": "rollup -cw" + }, + "dependencies": { + "sourcemap-codec": "^1.4.8" + }, + "devDependencies": { + "@rollup/plugin-buble": "^0.21.3", + "@rollup/plugin-node-resolve": "^13.1.3", + "@rollup/plugin-replace": "^4.0.0", + "bumpp": "^7.1.1", + "conventional-changelog-cli": "^2.2.2", + "eslint": "^7.32.0", + "mocha": "^9.2.1", + "prettier": "^2.5.1", + "rollup": "^2.69.0", + "source-map": "^0.6.1", + "source-map-support": "^0.5.21" + } +} diff --git a/node_modules/mime-types/HISTORY.md b/node_modules/mime-types/HISTORY.md new file mode 100644 index 0000000000000000000000000000000000000000..c5043b75b958766a3880805dc4f19d70a4f167dd --- /dev/null +++ b/node_modules/mime-types/HISTORY.md @@ -0,0 +1,397 @@ +2.1.35 / 2022-03-12 +=================== + + * deps: mime-db@1.52.0 + - Add extensions from IANA for more `image/*` types + - Add extension `.asc` to `application/pgp-keys` + - Add extensions to various XML types + - Add new upstream MIME types + +2.1.34 / 2021-11-08 +=================== + + * deps: mime-db@1.51.0 + - Add new upstream MIME types + +2.1.33 / 2021-10-01 +=================== + + * deps: mime-db@1.50.0 + - Add deprecated iWorks mime types and extensions + - Add new upstream MIME types + +2.1.32 / 2021-07-27 +=================== + + * deps: mime-db@1.49.0 + - Add extension `.trig` to `application/trig` + - Add new upstream MIME types + +2.1.31 / 2021-06-01 +=================== + + * deps: mime-db@1.48.0 + - Add extension `.mvt` to `application/vnd.mapbox-vector-tile` + - Add new upstream MIME types + +2.1.30 / 2021-04-02 +=================== + + * deps: mime-db@1.47.0 + - Add extension `.amr` to `audio/amr` + - Remove ambigious extensions from IANA for `application/*+xml` types + - Update primary extension to `.es` for `application/ecmascript` + +2.1.29 / 2021-02-17 +=================== + + * deps: mime-db@1.46.0 + - Add extension `.amr` to `audio/amr` + - Add extension `.m4s` to `video/iso.segment` + - Add extension `.opus` to `audio/ogg` + - Add new upstream MIME types + +2.1.28 / 2021-01-01 +=================== + + * deps: mime-db@1.45.0 + - Add `application/ubjson` with extension `.ubj` + - Add `image/avif` with extension `.avif` + - Add `image/ktx2` with extension `.ktx2` + - Add extension `.dbf` to `application/vnd.dbf` + - Add extension `.rar` to `application/vnd.rar` + - Add extension `.td` to `application/urc-targetdesc+xml` + - Add new upstream MIME types + - Fix extension of `application/vnd.apple.keynote` to be `.key` + +2.1.27 / 2020-04-23 +=================== + + * deps: mime-db@1.44.0 + - Add charsets from IANA + - Add extension `.cjs` to `application/node` + - Add new upstream MIME types + +2.1.26 / 2020-01-05 +=================== + + * deps: mime-db@1.43.0 + - Add `application/x-keepass2` with extension `.kdbx` + - Add extension `.mxmf` to `audio/mobile-xmf` + - Add extensions from IANA for `application/*+xml` types + - Add new upstream MIME types + +2.1.25 / 2019-11-12 +=================== + + * deps: mime-db@1.42.0 + - Add new upstream MIME types + - Add `application/toml` with extension `.toml` + - Add `image/vnd.ms-dds` with extension `.dds` + +2.1.24 / 2019-04-20 +=================== + + * deps: mime-db@1.40.0 + - Add extensions from IANA for `model/*` types + - Add `text/mdx` with extension `.mdx` + +2.1.23 / 2019-04-17 +=================== + + * deps: mime-db@~1.39.0 + - Add extensions `.siv` and `.sieve` to `application/sieve` + - Add new upstream MIME types + +2.1.22 / 2019-02-14 +=================== + + * deps: mime-db@~1.38.0 + - Add extension `.nq` to `application/n-quads` + - Add extension `.nt` to `application/n-triples` + - Add new upstream MIME types + +2.1.21 / 2018-10-19 +=================== + + * deps: mime-db@~1.37.0 + - Add extensions to HEIC image types + - Add new upstream MIME types + +2.1.20 / 2018-08-26 +=================== + + * deps: mime-db@~1.36.0 + - Add Apple file extensions from IANA + - Add extensions from IANA for `image/*` types + - Add new upstream MIME types + +2.1.19 / 2018-07-17 +=================== + + * deps: mime-db@~1.35.0 + - Add extension `.csl` to `application/vnd.citationstyles.style+xml` + - Add extension `.es` to `application/ecmascript` + - Add extension `.owl` to `application/rdf+xml` + - Add new upstream MIME types + - Add UTF-8 as default charset for `text/turtle` + +2.1.18 / 2018-02-16 +=================== + + * deps: mime-db@~1.33.0 + - Add `application/raml+yaml` with extension `.raml` + - Add `application/wasm` with extension `.wasm` + - Add `text/shex` with extension `.shex` + - Add extensions for JPEG-2000 images + - Add extensions from IANA for `message/*` types + - Add new upstream MIME types + - Update font MIME types + - Update `text/hjson` to registered `application/hjson` + +2.1.17 / 2017-09-01 +=================== + + * deps: mime-db@~1.30.0 + - Add `application/vnd.ms-outlook` + - Add `application/x-arj` + - Add extension `.mjs` to `application/javascript` + - Add glTF types and extensions + - Add new upstream MIME types + - Add `text/x-org` + - Add VirtualBox MIME types + - Fix `source` records for `video/*` types that are IANA + - Update `font/opentype` to registered `font/otf` + +2.1.16 / 2017-07-24 +=================== + + * deps: mime-db@~1.29.0 + - Add `application/fido.trusted-apps+json` + - Add extension `.wadl` to `application/vnd.sun.wadl+xml` + - Add extension `.gz` to `application/gzip` + - Add new upstream MIME types + - Update extensions `.md` and `.markdown` to be `text/markdown` + +2.1.15 / 2017-03-23 +=================== + + * deps: mime-db@~1.27.0 + - Add new mime types + - Add `image/apng` + +2.1.14 / 2017-01-14 +=================== + + * deps: mime-db@~1.26.0 + - Add new mime types + +2.1.13 / 2016-11-18 +=================== + + * deps: mime-db@~1.25.0 + - Add new mime types + +2.1.12 / 2016-09-18 +=================== + + * deps: mime-db@~1.24.0 + - Add new mime types + - Add `audio/mp3` + +2.1.11 / 2016-05-01 +=================== + + * deps: mime-db@~1.23.0 + - Add new mime types + +2.1.10 / 2016-02-15 +=================== + + * deps: mime-db@~1.22.0 + - Add new mime types + - Fix extension of `application/dash+xml` + - Update primary extension for `audio/mp4` + +2.1.9 / 2016-01-06 +================== + + * deps: mime-db@~1.21.0 + - Add new mime types + +2.1.8 / 2015-11-30 +================== + + * deps: mime-db@~1.20.0 + - Add new mime types + +2.1.7 / 2015-09-20 +================== + + * deps: mime-db@~1.19.0 + - Add new mime types + +2.1.6 / 2015-09-03 +================== + + * deps: mime-db@~1.18.0 + - Add new mime types + +2.1.5 / 2015-08-20 +================== + + * deps: mime-db@~1.17.0 + - Add new mime types + +2.1.4 / 2015-07-30 +================== + + * deps: mime-db@~1.16.0 + - Add new mime types + +2.1.3 / 2015-07-13 +================== + + * deps: mime-db@~1.15.0 + - Add new mime types + +2.1.2 / 2015-06-25 +================== + + * deps: mime-db@~1.14.0 + - Add new mime types + +2.1.1 / 2015-06-08 +================== + + * perf: fix deopt during mapping + +2.1.0 / 2015-06-07 +================== + + * Fix incorrectly treating extension-less file name as extension + - i.e. `'path/to/json'` will no longer return `application/json` + * Fix `.charset(type)` to accept parameters + * Fix `.charset(type)` to match case-insensitive + * Improve generation of extension to MIME mapping + * Refactor internals for readability and no argument reassignment + * Prefer `application/*` MIME types from the same source + * Prefer any type over `application/octet-stream` + * deps: mime-db@~1.13.0 + - Add nginx as a source + - Add new mime types + +2.0.14 / 2015-06-06 +=================== + + * deps: mime-db@~1.12.0 + - Add new mime types + +2.0.13 / 2015-05-31 +=================== + + * deps: mime-db@~1.11.0 + - Add new mime types + +2.0.12 / 2015-05-19 +=================== + + * deps: mime-db@~1.10.0 + - Add new mime types + +2.0.11 / 2015-05-05 +=================== + + * deps: mime-db@~1.9.1 + - Add new mime types + +2.0.10 / 2015-03-13 +=================== + + * deps: mime-db@~1.8.0 + - Add new mime types + +2.0.9 / 2015-02-09 +================== + + * deps: mime-db@~1.7.0 + - Add new mime types + - Community extensions ownership transferred from `node-mime` + +2.0.8 / 2015-01-29 +================== + + * deps: mime-db@~1.6.0 + - Add new mime types + +2.0.7 / 2014-12-30 +================== + + * deps: mime-db@~1.5.0 + - Add new mime types + - Fix various invalid MIME type entries + +2.0.6 / 2014-12-30 +================== + + * deps: mime-db@~1.4.0 + - Add new mime types + - Fix various invalid MIME type entries + - Remove example template MIME types + +2.0.5 / 2014-12-29 +================== + + * deps: mime-db@~1.3.1 + - Fix missing extensions + +2.0.4 / 2014-12-10 +================== + + * deps: mime-db@~1.3.0 + - Add new mime types + +2.0.3 / 2014-11-09 +================== + + * deps: mime-db@~1.2.0 + - Add new mime types + +2.0.2 / 2014-09-28 +================== + + * deps: mime-db@~1.1.0 + - Add new mime types + - Update charsets + +2.0.1 / 2014-09-07 +================== + + * Support Node.js 0.6 + +2.0.0 / 2014-09-02 +================== + + * Use `mime-db` + * Remove `.define()` + +1.0.2 / 2014-08-04 +================== + + * Set charset=utf-8 for `text/javascript` + +1.0.1 / 2014-06-24 +================== + + * Add `text/jsx` type + +1.0.0 / 2014-05-12 +================== + + * Return `false` for unknown types + * Set charset=utf-8 for `application/json` + +0.1.0 / 2014-05-02 +================== + + * Initial release diff --git a/node_modules/mime-types/LICENSE b/node_modules/mime-types/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..06166077be4d1f620d89b9eb33c76d89e75857da --- /dev/null +++ b/node_modules/mime-types/LICENSE @@ -0,0 +1,23 @@ +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2015 Douglas Christopher Wilson + +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. diff --git a/node_modules/mime-types/README.md b/node_modules/mime-types/README.md new file mode 100644 index 0000000000000000000000000000000000000000..48d2fb477241e837c6e8d349777aac312746029b --- /dev/null +++ b/node_modules/mime-types/README.md @@ -0,0 +1,113 @@ +# mime-types + +[![NPM Version][npm-version-image]][npm-url] +[![NPM Downloads][npm-downloads-image]][npm-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][ci-image]][ci-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +The ultimate javascript content-type utility. + +Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except: + +- __No fallbacks.__ Instead of naively returning the first available type, + `mime-types` simply returns `false`, so do + `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. +- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. +- No `.define()` functionality +- Bug fixes for `.lookup(path)` + +Otherwise, the API is compatible with `mime` 1.x. + +## Install + +This is a [Node.js](https://nodejs.org/en/) module available through the +[npm registry](https://www.npmjs.com/). Installation is done using the +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): + +```sh +$ npm install mime-types +``` + +## Adding Types + +All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db), +so open a PR there if you'd like to add mime types. + +## API + +```js +var mime = require('mime-types') +``` + +All functions return `false` if input is invalid or not found. + +### mime.lookup(path) + +Lookup the content-type associated with a file. + +```js +mime.lookup('json') // 'application/json' +mime.lookup('.md') // 'text/markdown' +mime.lookup('file.html') // 'text/html' +mime.lookup('folder/file.js') // 'application/javascript' +mime.lookup('folder/.htaccess') // false + +mime.lookup('cats') // false +``` + +### mime.contentType(type) + +Create a full content-type header given a content-type or extension. +When given an extension, `mime.lookup` is used to get the matching +content-type, otherwise the given content-type is used. Then if the +content-type does not already have a `charset` parameter, `mime.charset` +is used to get the default charset and add to the returned content-type. + +```js +mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' +mime.contentType('file.json') // 'application/json; charset=utf-8' +mime.contentType('text/html') // 'text/html; charset=utf-8' +mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1' + +// from a full path +mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' +``` + +### mime.extension(type) + +Get the default extension for a content-type. + +```js +mime.extension('application/octet-stream') // 'bin' +``` + +### mime.charset(type) + +Lookup the implied default charset of a content-type. + +```js +mime.charset('text/markdown') // 'UTF-8' +``` + +### var type = mime.types[extension] + +A map of content-types by extension. + +### [extensions...] = mime.extensions[type] + +A map of extensions by content-type. + +## License + +[MIT](LICENSE) + +[ci-image]: https://badgen.net/github/checks/jshttp/mime-types/master?label=ci +[ci-url]: https://github.com/jshttp/mime-types/actions/workflows/ci.yml +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master +[coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master +[node-version-image]: https://badgen.net/npm/node/mime-types +[node-version-url]: https://nodejs.org/en/download +[npm-downloads-image]: https://badgen.net/npm/dm/mime-types +[npm-url]: https://npmjs.org/package/mime-types +[npm-version-image]: https://badgen.net/npm/v/mime-types diff --git a/node_modules/mime-types/index.js b/node_modules/mime-types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b9f34d5991077fe9fadc7d9187a7225db7e58fca --- /dev/null +++ b/node_modules/mime-types/index.js @@ -0,0 +1,188 @@ +/*! + * mime-types + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var db = require('mime-db') +var extname = require('path').extname + +/** + * Module variables. + * @private + */ + +var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/ +var TEXT_TYPE_REGEXP = /^text\//i + +/** + * Module exports. + * @public + */ + +exports.charset = charset +exports.charsets = { lookup: charset } +exports.contentType = contentType +exports.extension = extension +exports.extensions = Object.create(null) +exports.lookup = lookup +exports.types = Object.create(null) + +// Populate the extensions/types maps +populateMaps(exports.extensions, exports.types) + +/** + * Get the default charset for a MIME type. + * + * @param {string} type + * @return {boolean|string} + */ + +function charset (type) { + if (!type || typeof type !== 'string') { + return false + } + + // TODO: use media-typer + var match = EXTRACT_TYPE_REGEXP.exec(type) + var mime = match && db[match[1].toLowerCase()] + + if (mime && mime.charset) { + return mime.charset + } + + // default text/* to utf-8 + if (match && TEXT_TYPE_REGEXP.test(match[1])) { + return 'UTF-8' + } + + return false +} + +/** + * Create a full Content-Type header given a MIME type or extension. + * + * @param {string} str + * @return {boolean|string} + */ + +function contentType (str) { + // TODO: should this even be in this module? + if (!str || typeof str !== 'string') { + return false + } + + var mime = str.indexOf('/') === -1 + ? exports.lookup(str) + : str + + if (!mime) { + return false + } + + // TODO: use content-type or other module + if (mime.indexOf('charset') === -1) { + var charset = exports.charset(mime) + if (charset) mime += '; charset=' + charset.toLowerCase() + } + + return mime +} + +/** + * Get the default extension for a MIME type. + * + * @param {string} type + * @return {boolean|string} + */ + +function extension (type) { + if (!type || typeof type !== 'string') { + return false + } + + // TODO: use media-typer + var match = EXTRACT_TYPE_REGEXP.exec(type) + + // get extensions + var exts = match && exports.extensions[match[1].toLowerCase()] + + if (!exts || !exts.length) { + return false + } + + return exts[0] +} + +/** + * Lookup the MIME type for a file path/extension. + * + * @param {string} path + * @return {boolean|string} + */ + +function lookup (path) { + if (!path || typeof path !== 'string') { + return false + } + + // get the extension ("ext" or ".ext" or full path) + var extension = extname('x.' + path) + .toLowerCase() + .substr(1) + + if (!extension) { + return false + } + + return exports.types[extension] || false +} + +/** + * Populate the extensions and types maps. + * @private + */ + +function populateMaps (extensions, types) { + // source preference (least -> most) + var preference = ['nginx', 'apache', undefined, 'iana'] + + Object.keys(db).forEach(function forEachMimeType (type) { + var mime = db[type] + var exts = mime.extensions + + if (!exts || !exts.length) { + return + } + + // mime -> extensions + extensions[type] = exts + + // extension -> mime + for (var i = 0; i < exts.length; i++) { + var extension = exts[i] + + if (types[extension]) { + var from = preference.indexOf(db[types[extension]].source) + var to = preference.indexOf(mime.source) + + if (types[extension] !== 'application/octet-stream' && + (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) { + // skip the remapping + continue + } + } + + // set the extension -> mime + types[extension] = type + } + }) +} diff --git a/node_modules/mime-types/package.json b/node_modules/mime-types/package.json new file mode 100644 index 0000000000000000000000000000000000000000..bbef6964509e73f95e5b390b3923f919c72b6528 --- /dev/null +++ b/node_modules/mime-types/package.json @@ -0,0 +1,44 @@ +{ + "name": "mime-types", + "description": "The ultimate javascript content-type utility.", + "version": "2.1.35", + "contributors": [ + "Douglas Christopher Wilson ", + "Jeremiah Senkpiel (https://searchbeam.jit.su)", + "Jonathan Ong (http://jongleberry.com)" + ], + "license": "MIT", + "keywords": [ + "mime", + "types" + ], + "repository": "jshttp/mime-types", + "dependencies": { + "mime-db": "1.52.0" + }, + "devDependencies": { + "eslint": "7.32.0", + "eslint-config-standard": "14.1.1", + "eslint-plugin-import": "2.25.4", + "eslint-plugin-markdown": "2.2.1", + "eslint-plugin-node": "11.1.0", + "eslint-plugin-promise": "5.2.0", + "eslint-plugin-standard": "4.1.0", + "mocha": "9.2.2", + "nyc": "15.1.0" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "engines": { + "node": ">= 0.6" + }, + "scripts": { + "lint": "eslint .", + "test": "mocha --reporter spec test/test.js", + "test-ci": "nyc --reporter=lcov --reporter=text npm test", + "test-cov": "nyc --reporter=html --reporter=text npm test" + } +} diff --git a/node_modules/miniflare/README.md b/node_modules/miniflare/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b23ee9ea6b7f4d7d94b7e42b431e765338e7e08e --- /dev/null +++ b/node_modules/miniflare/README.md @@ -0,0 +1,772 @@ +# 🔥 Miniflare + +**Miniflare 3** is a simulator for developing and testing +[**Cloudflare Workers**](https://workers.cloudflare.com/), powered by +[`workerd`](https://github.com/cloudflare/workerd). + +> :warning: Miniflare 3 is API-only, and does not expose a CLI. Use Wrangler +> with `wrangler dev` to develop your Workers locally with Miniflare 3. + +## Quick Start + +```shell +$ npm install miniflare --save-dev +``` + +```js +import { Miniflare } from "miniflare"; + +// Create a new Miniflare instance, starting a workerd server +const mf = new Miniflare({ + script: `addEventListener("fetch", (event) => { + event.respondWith(new Response("Hello Miniflare!")); + })`, +}); + +// Send a request to the workerd server, the host is ignored +const response = await mf.dispatchFetch("http://localhost:8787/"); +console.log(await response.text()); // Hello Miniflare! + +// Cleanup Miniflare, shutting down the workerd server +await mf.dispose(); +``` + +## API + +### `type Awaitable` + +`T | Promise` + +Represents a value that can be `await`ed. Used in callback types to allow +`Promise`s to be returned if necessary. + +### `type Json` + +`string | number | boolean | null | Record | Json[]` + +Represents a JSON-serialisable value. + +### `type ModuleRuleType` + +`"ESModule" | "CommonJS" | "Text" | "Data" | "CompiledWasm"` + +Represents how a module's contents should be interpreted. + +- `"ESModule"`: interpret as + [ECMAScript module](https://tc39.es/ecma262/#sec-modules) +- `"CommonJS"`: interpret as + [CommonJS module](https://nodejs.org/api/modules.html#modules-commonjs-modules) +- `"Text"`: interpret as UTF8-encoded data, expose in runtime with + `string`-typed `default` export +- `"Data"`: interpret as arbitrary binary data, expose in runtime with + `ArrayBuffer`-typed `default` export +- `"CompiledWasm"`: interpret as binary WebAssembly module data, expose in + runtime with `WebAssembly.Module`-typed `default` export + +### `interface ModuleDefinition` + +Represents a manually defined module. + +- `type: ModuleRuleType` + + How this module's contents should be interpreted. + +- `path: string` + + Path of this module. The module's "name" will be obtained by converting this + to a relative path. The original path will be used to read `contents` if it's + omitted. + +- `contents?: string | Uint8Array` + + Contents override for this module. Binary data should be passed as + `Uint8Array`s. If omitted, will be read from `path`. + +### `interface ModuleRule` + +Represents a rule for identifying the `ModuleRuleType` of automatically located +modules. + +- `type: ModuleRuleType` + + How to interpret modules that match the `include` patterns. + +- `include: string[]` + + Glob patterns to match located module paths against (e.g. `["**/*.txt"]`). + +- `fallthrough?: boolean` + + If `true`, ignore any further rules of this `type`. This is useful for + disabling the built-in `ESModule` and `CommonJS` rules that match `*.mjs` and + `*.js`/`*.cjs` files respectively. + +### `type Persistence` + +`boolean | string | undefined` + +Represents where data should be persisted, if anywhere. + +- If this is `undefined` or `false`, data will be stored in-memory and only + persist between `Miniflare#setOptions()` calls, not restarts nor + `new Miniflare` instances. +- If this is `true`, data will be stored on the file-system, in the `$PWD/.mf` + directory. +- If this looks like a URL, then: + - If the protocol is `memory:`, data will be stored in-memory as above. + - If the protocol is `file:`, data will be stored on the file-system, in the + specified directory (e.g. `file:///path/to/directory`). +- Otherwise, if this is just a regular `string`, data will be stored on the + file-system, using the value as the directory path. + +### `enum LogLevel` + +`NONE, ERROR, WARN, INFO, DEBUG, VERBOSE` + +Controls which messages Miniflare logs. All messages at or below the selected +level will be logged. + +### `interface LogOptions` + +- `prefix?: string` + + String to add before the level prefix when logging messages. Defaults to `mf`. + +- `suffix?: string` + + String to add after the level prefix when logging messages. + +### `class Log` + +- `constructor(level?: LogLevel, opts?: LogOptions)` + + Creates a new logger that logs all messages at or below the specified level to + the `console`. + +- `error(message: Error)` + + Logs a message at the `ERROR` level. If the constructed log `level` is less + than `ERROR`, `throw`s the `message` instead. + +- `warn(message: string)` + + Logs a message at the `WARN` level. + +- `info(message: string)` + + Logs a message at the `INFO` level. + +- `debug(message: string)` + + Logs a message at the `DEBUG` level. + +- `verbose(message: string)` + + Logs a message at the `VERBOSE` level. + +### `class NoOpLog extends Log` + +- `constructor()` + + Creates a new logger that logs nothing to the `console`, and always `throw`s + `message`s logged at the `ERROR` level. + +### `interface QueueConsumerOptions` + +- `maxBatchSize?: number` + + Maximum number of messages allowed in each batch. Defaults to `5`. + +- `maxBatchTimeout?: number` + + Maximum number of seconds to wait for a full batch. If a message is sent, and + this timeout elapses, a partial batch will be dispatched. Defaults to `1`. + +- `maxRetries?: number` + + Maximum number of times to retry dispatching a message, if handling it throws, + or it is explicitly retried. Defaults to `2`. + +- `deadLetterQueue?: string` + + Name of another Queue to send a message on if it fails processing after + `maxRetries`. If this isn't specified, failed messages will be discarded. + +### `interface WorkerOptions` + +Options for an individual Worker/"nanoservice". All bindings are accessible on +the global scope in service-worker format Workers, or via the 2nd `env` +parameter in module format Workers. + +#### Core + +- `name?: string` + + Unique name for this worker. Only required if multiple `workers` are + specified. + +- `script?: string` + + JavaScript code for this worker. If this is a service worker format Worker, it + must not have any imports. If this is a modules format Worker, it must not + have any _npm_ imports, and `modules: true` must be set. If it does have + imports, `scriptPath` must also be set so Miniflare knows where to resolve + them relative to. + +- `scriptPath?: string` + + Path of JavaScript entrypoint. If this is a service worker format Worker, it + must not have any imports. If this is a modules format Worker, it must not + have any _npm_ imports, and `modules: true` must be set. + +- `modules?: boolean | ModuleDefinition[]` + + - If `true`, Miniflare will treat `script`/`scriptPath` as an ES Module and + automatically locate transitive module dependencies according to + `modulesRules`. Note that automatic location is not perfect: if the + specifier to a dynamic `import()` or `require()` is not a string literal, an + exception will be thrown. + + - If set to an array, modules can be defined manually. Transitive dependencies + must also be defined. Note the first module must be the entrypoint and have + type `"ESModule"`. + +- `modulesRoot?: string` + + If `modules` is set to `true` or an array, modules' "name"s will be their + `path`s relative to this value. This ensures file paths in stack traces are + correct. + + + + +- `modulesRules?: ModuleRule[]` + + Rules for identifying the `ModuleRuleType` of automatically located modules + when `modules: true` is set. Note the following default rules are always + included at the end: + + ```js + [ + { type: "ESModule", include: ["**/*.mjs"] }, + { type: "CommonJS", include: ["**/*.js", "**/*.cjs"] }, + ] + ``` + + > If `script` and `scriptPath` are set, and `modules` is set to an array, + > `modules` takes priority for a Worker's code, followed by `script`, then + > `scriptPath`. + + + +- `compatibilityDate?: string` + + [Compatibility date](https://developers.cloudflare.com/workers/platform/compatibility-dates/) + to use for this Worker. Defaults to a date far in the past. + +- `compatibilityFlags?: string[]` + + [Compatibility flags](https://developers.cloudflare.com/workers/platform/compatibility-dates/) + to use for this Worker. + +- `bindings?: Record` + + Record mapping binding name to arbitrary JSON-serialisable values to inject as + bindings into this Worker. + +- `wasmBindings?: Record` + + Record mapping binding name to paths containing binary WebAssembly module data + to inject as `WebAssembly.Module` bindings into this Worker. + +- `textBlobBindings?: Record` + + Record mapping binding name to paths containing UTF8-encoded data to inject as + `string` bindings into this Worker. + +- `dataBlobBindings?: Record` + + Record mapping binding name to paths containing arbitrary binary data to + inject as `ArrayBuffer` bindings into this Worker. + +- `serviceBindings?: Record Awaitable>` + + Record mapping binding name to service designators to inject as + `{ fetch: typeof fetch }` + [service bindings](https://developers.cloudflare.com/workers/platform/bindings/about-service-bindings/) + into this Worker. + + - If the designator is a `string`, requests will be dispatched to the Worker + with that `name`. + - If the designator is an object of the form `{ network: { ... } }`, where + `network` is a + [`workerd` `Network` struct](https://github.com/cloudflare/workerd/blob/bdbd6075c7c53948050c52d22f2dfa37bf376253/src/workerd/server/workerd.capnp#L555-L598), + requests will be dispatched according to the `fetch`ed URL. + - If the designator is an object of the form `{ external: { ... } }` where + `external` is a + [`workerd` `ExternalServer` struct](https://github.com/cloudflare/workerd/blob/bdbd6075c7c53948050c52d22f2dfa37bf376253/src/workerd/server/workerd.capnp#L504-L553), + requests will be dispatched to the specified remote server. + - If the designator is an object of the form `{ disk: { ... } }` where `disk` + is a + [`workerd` `DiskDirectory` struct](https://github.com/cloudflare/workerd/blob/bdbd6075c7c53948050c52d22f2dfa37bf376253/src/workerd/server/workerd.capnp#L600-L643), + requests will be dispatched to an HTTP service backed by an on-disk + directory. + - If the designator is a function, requests will be dispatched to your custom + handler. This allows you to access data and functions defined in Node.js + from your Worker. + + + +- `wrappedBindings?: Record }>` + + Record mapping binding name to designators to inject as + [wrapped bindings](https://github.com/cloudflare/workerd/blob/bfcef2d850514c569c039cb84c43bc046af4ffb9/src/workerd/server/workerd.capnp#L469-L487) into this Worker. + Wrapped bindings allow custom bindings to be written as JavaScript functions + accepting an `env` parameter of "inner bindings" and returning the value to + bind. A `string` designator is equivalent to `{ scriptName: }`. + `scriptName`'s bindings will be used as "inner bindings". JSON `bindings` in + the `designator` also become "inner bindings" and will override any of + `scriptName` bindings with the same name. The Worker named `scriptName`... + + - Must define a single `ESModule` as its source, using + `{ modules: true, script: "..." }`, `{ modules: true, scriptPath: "..." }`, + or `{ modules: [...] }` + - Must provide the function to use for the wrapped binding as an `entrypoint` + named export or a default export if `entrypoint` is omitted + - Must not be the first/entrypoint worker + - Must not be bound to with service or Durable Object bindings + - Must not define `compatibilityDate` or `compatibilityFlags` + - Must not define `outboundService` + - Must not directly or indirectly have a wrapped binding to itself + - Must not be used as an argument to `Miniflare#getWorker()` + +
+ Wrapped Bindings Example + + ```ts + import { Miniflare } from "miniflare"; + const store = new Map(); + const mf = new Miniflare({ + workers: [ + { + wrappedBindings: { + MINI_KV: { + scriptName: "mini-kv", // Use Worker named `mini-kv` for implementation + bindings: { NAMESPACE: "ns" }, // Override `NAMESPACE` inner binding + }, + }, + modules: true, + script: `export default { + async fetch(request, env, ctx) { + // Example usage of wrapped binding + await env.MINI_KV.set("key", "value"); + return new Response(await env.MINI_KV.get("key")); + } + }`, + }, + { + name: "mini-kv", + serviceBindings: { + // Function-valued service binding for accessing Node.js state + async STORE(request) { + const { pathname } = new URL(request.url); + const key = pathname.substring(1); + if (request.method === "GET") { + const value = store.get(key); + const status = value === undefined ? 404 : 200; + return new Response(value ?? null, { status }); + } else if (request.method === "PUT") { + const value = await request.text(); + store.set(key, value); + return new Response(null, { status: 204 }); + } else if (request.method === "DELETE") { + store.delete(key); + return new Response(null, { status: 204 }); + } else { + return new Response(null, { status: 405 }); + } + }, + }, + modules: true, + script: ` + // Implementation of binding + class MiniKV { + constructor(env) { + this.STORE = env.STORE; + this.baseURL = "http://x/" + (env.NAMESPACE ?? "") + ":"; + } + async get(key) { + const res = await this.STORE.fetch(this.baseURL + key); + return res.status === 404 ? null : await res.text(); + } + async set(key, body) { + await this.STORE.fetch(this.baseURL + key, { method: "PUT", body }); + } + async delete(key) { + await this.STORE.fetch(this.baseURL + key, { method: "DELETE" }); + } + } + + // env has the type { STORE: Fetcher, NAMESPACE?: string } + export default function (env) { + return new MiniKV(env); + } + `, + }, + ], + }); + ``` + +
+ + > :warning: `wrappedBindings` are only supported in modules format Workers. + + + +- `outboundService?: string | { network: Network } | { external: ExternalServer } | { disk: DiskDirectory } | (request: Request) => Awaitable` + + Dispatch this Worker's global `fetch()` and `connect()` requests to the + configured service. Service designators follow the same rules above for + `serviceBindings`. + +- `fetchMock?: import("undici").MockAgent` + + An [`undici` `MockAgent`](https://undici.nodejs.org/#/docs/api/MockAgent) to + dispatch this Worker's global `fetch()` requests through. + + > :warning: `outboundService` and `fetchMock` are mutually exclusive options. + > At most one of them may be specified per Worker. + +- `routes?: string[]` + + Array of route patterns for this Worker. These follow the same + [routing rules](https://developers.cloudflare.com/workers/platform/triggers/routes/#matching-behavior) + as deployed Workers. If no routes match, Miniflare will fallback to the Worker + defined first. + +#### Cache + +- `cache?: boolean` + + If `false`, default and named caches will be disabled. The Cache API will + still be available, it just won't cache anything. + +- `cacheWarnUsage?: boolean` + + If `true`, the first use of the Cache API will log a warning stating that the + Cache API is unsupported on `workers.dev` subdomains. + +#### Durable Objects + +- `durableObjects?: Record` + + Record mapping binding name to Durable Object class designators to inject as + `DurableObjectNamespace` bindings into this Worker. + + - If the designator is a `string`, it should be the name of a `class` exported + by this Worker. + - If the designator is an object, and `scriptName` is `undefined`, `className` + should be the name of a `class` exported by this Worker. + - Otherwise, `className` should be the name of a `class` exported by the + Worker with a `name` of `scriptName`. + +#### KV + +- `kvNamespaces?: Record | string[]` + + Record mapping binding name to KV namespace IDs to inject as `KVNamespace` + bindings into this Worker. Different Workers may bind to the same namespace ID + with different binding names. If a `string[]` of binding names is specified, + the binding name and KV namespace ID are assumed to be the same. + +- `sitePath?: string` + + Path to serve Workers Sites files from. If set, `__STATIC_CONTENT` and + `__STATIC_CONTENT_MANIFEST` bindings will be injected into this Worker. In + modules mode, `__STATIC_CONTENT_MANIFEST` will also be exposed as a module + with a `string`-typed `default` export, containing the JSON-stringified + manifest. Note Workers Sites files are never cached in Miniflare. + +- `siteInclude?: string[]` + + If set, only files with paths matching these glob patterns will be served. + +- `siteExclude?: string[]` + + If set, only files with paths _not_ matching these glob patterns will be + served. + +#### R2 + +- `r2Buckets?: Record | string[]` + + Record mapping binding name to R2 bucket names to inject as `R2Bucket` + bindings into this Worker. Different Workers may bind to the same bucket name + with different binding names. If a `string[]` of binding names is specified, + the binding name and bucket name are assumed to be the same. + +#### D1 + +- `d1Databases?: Record | string[]` + + Record mapping binding name to D1 database IDs to inject as `Fetcher` bindings + into this Worker. Note these bindings must be wrapped with a facade to provide + the expected `D1Database` API. Different Workers may bind to the same database + ID with different binding names. If a `string[]` of binding names is + specified, the binding name and database ID are assumed to be the same. + +#### Queues + +- `queueProducers?: Record | string[]` + + Record mapping binding name to queue names to inject as `WorkerQueue` bindings + into this Worker. Different Workers may bind to the same queue name with + different binding names. If a `string[]` of binding names is specified, the + binding name and queue name are assumed to be the same. + +- `queueConsumers?: Record | string[]` + + Record mapping queue name to consumer options. Messages enqueued on the + corresponding queues will be dispatched to this Worker. Note each queue can + have at most one consumer. If a `string[]` of queue names is specified, + default consumer options will be used. + +#### Analytics Engine + +_Not yet supported_ + +### `interface SharedOptions` + +Options shared between all Workers/"nanoservices". + +#### Core + +- `host?: string` + + Hostname that the `workerd` server should listen on. Defaults to `127.0.0.1`. + +- `port?: number` + + Port that the `workerd` server should listen on. Tries to default to `8787`, + but falls back to a random free port if this is in use. Note if a manually + specified port is in use, Miniflare throws an error, rather than attempting to + find a free port. + +- `https?: boolean` + + If `true`, start an HTTPS server using a pre-generated self-signed certificate + for `localhost`. Note this certificate is not valid for any other hostnames or + IP addresses. If you need to access the HTTPS server from another device, + you'll need to generate your own certificate and use the other `https*` + options below. + + ```shell + $ openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out cert.pem + ``` + + ```js + new Miniflare({ + httpsKeyPath: "key.pem", + httpsCertPath: "cert.pem", + }); + ``` + +- `httpsKey?: string` + + When one of `httpsCert` or `httpCertPath` is also specified, starts an HTTPS + server using the value of this option as the PEM encoded private key. + +- `httpsKeyPath?: string` + + When one of `httpsCert` or `httpCertPath` is also specified, starts an HTTPS + server using the PEM encoded private key stored at this file path. + +- `httpsCert?: string` + + When one of `httpsKey` or `httpsKeyPath` is also specified, starts an HTTPS + server using the value of this option as the PEM encoded certificate chain. + +- `httpsCertPath?: string` + + When one of `httpsKey` or `httpsKeyPath` is also specified, starts an HTTPS + server using the PEM encoded certificate chain stored at this file path. + +- `inspectorPort?: number` + + Port that `workerd` should start a DevTools inspector server on. Visit + `chrome://inspect` in a Chromium-based browser to connect to this. This can be + used to see detailed `console.log`s, profile CPU usage, and will eventually + allow step-through debugging. + +- `verbose?: boolean` + + Enable `workerd`'s `--verbose` flag for verbose logging. This can be used to + see simplified `console.log`s. + +- `log?: Log` + + Logger implementation for Miniflare's errors, warnings and informative + messages. + +- `upstream?: string` + + URL to use as the origin for incoming requests. If specified, all incoming + `request.url`s will be rewritten to start with this string. This is especially + useful when testing Workers that act as a proxy, and not as origins + themselves. + +- `cf?: boolean | string | Record` + + Controls the object returned from incoming `Request`'s `cf` property. + + - If set to a falsy value, an object with default placeholder values will be + used + - If set to an object, that object will be used + - If set to `true`, a real `cf` object will be fetched from a trusted + Cloudflare endpoint and cached in `node_modules/.mf` for 30 days + - If set to a `string`, a real `cf` object will be fetched and cached at the + provided path for 30 days + +- `liveReload?: boolean` + + If `true`, Miniflare will inject a script into HTML responses that + automatically reloads the page in-browser whenever the Miniflare instance's + options are updated. + +#### Cache, Durable Objects, KV, R2 and D1 + +- `cachePersist?: Persistence` + + Where to persist data cached in default or named caches. See docs for + `Persistence`. + +- `durableObjectsPersist?: Persistence` + + Where to persist data stored in Durable Objects. See docs for `Persistence`. + +- `kvPersist?: Persistence` + + Where to persist data stored in KV namespaces. See docs for `Persistence`. + +- `r2Persist?: Persistence` + + Where to persist data stored in R2 buckets. See docs for `Persistence`. + +- `d1Persist?: Persistence` + + Where to persist data stored in D1 databases. See docs for `Persistence`. + +#### Analytics Engine + +_Not yet supported_ + +### `type MiniflareOptions` + +`SharedOptions & (WorkerOptions | { workers: WorkerOptions[] })` + +Miniflare accepts either a single Worker configuration or multiple Worker +configurations in the `workers` array. When specifying an array of Workers, the +first Worker is designated the entrypoint and will receive all incoming HTTP +requests. Some options are shared between all workers and should always be +defined at the top-level. + +### `class Miniflare` + +- `constructor(opts: MiniflareOptions)` + + Creates a Miniflare instance and starts a new `workerd` server. Note unlike + Miniflare 2, Miniflare 3 _always_ starts a HTTP server listening on the + configured `host` and `port`: there are no `createServer`/`startServer` + functions. + +- `setOptions(opts: MiniflareOptions)` + + Updates the configuration for this Miniflare instance and restarts the + `workerd` server. Note unlike Miniflare 2, this does _not_ merge the new + configuration with the old configuration. Note that calling this function will + invalidate any existing values returned by the `Miniflare#get*()` methods, + preventing them from being used. + +- `ready: Promise` + + Returns a `Promise` that resolves with a `http` `URL` to the `workerd` server + once it has started and is able to accept requests. + +- `dispatchFetch(input: RequestInfo, init?: RequestInit): Promise` + + Sends a HTTP request to the `workerd` server, dispatching a `fetch` event in + the entrypoint Worker. Returns a `Promise` that resolves with the response. + Note that this implicitly waits for the `ready` `Promise` to resolve, there's + no need to do that yourself first. Additionally, the host of the request's URL + is always ignored and replaced with the `workerd` server's. + +- `getBindings = Record>(workerName?: string): Promise` + + Returns a `Promise` that resolves with a record mapping binding names to + bindings, for all bindings in the Worker with the specified `workerName`. If + `workerName` is not specified, defaults to the entrypoint Worker. + +- `getWorker(workerName?: string): Promise` + + Returns a `Promise` that resolves with a + [`Fetcher`](https://workers-types.pages.dev/experimental/#Fetcher) pointing to + the specified `workerName`. If `workerName` is not specified, defaults to the + entrypoint Worker. Note this `Fetcher` uses the experimental + [`service_binding_extra_handlers`](https://github.com/cloudflare/workerd/blob/1d9158af7ca1389474982c76ace9e248320bec77/src/workerd/io/compatibility-date.capnp#L290-L297) + compatibility flag to expose + [`scheduled()`](https://workers-types.pages.dev/experimental/#Fetcher.scheduled) + and [`queue()`](https://workers-types.pages.dev/experimental/#Fetcher.queue) + methods for dispatching `scheduled` and `queue` events. + +- `getCaches(): Promise` + + Returns a `Promise` that resolves with the + [`CacheStorage`](https://developers.cloudflare.com/workers/runtime-apis/cache/) + instance of the entrypoint Worker. This means if `cache: false` is set on the + entrypoint, calling methods on the resolved value won't do anything. + +- `getD1Database(bindingName: string, workerName?: string): Promise` + + Returns a `Promise` that resolves with the + [`D1Database`](https://developers.cloudflare.com/d1/platform/client-api/) + instance corresponding to the specified `bindingName` of `workerName`. Note + `bindingName` must not begin with `__D1_BETA__`. If `workerName` is not + specified, defaults to the entrypoint Worker. + +- `getDurableObjectNamespace(bindingName: string, workerName?: string): Promise` + + Returns a `Promise` that resolves with the + [`DurableObjectNamespace`](https://developers.cloudflare.com/workers/runtime-apis/durable-objects/#access-a-durable-object-from-a-worker) + instance corresponding to the specified `bindingName` of `workerName`. If + `workerName` is not specified, defaults to the entrypoint Worker. + +- `getKVNamespace(bindingName: string, workerName?: string): Promise` + + Returns a `Promise` that resolves with the + [`KVNamespace`](https://developers.cloudflare.com/workers/runtime-apis/kv/) + instance corresponding to the specified `bindingName` of `workerName`. If + `workerName` is not specified, defaults to the entrypoint Worker. + +- `getQueueProducer(bindingName: string, workerName?: string): Promise>` + + Returns a `Promise` that resolves with the + [`Queue`](https://developers.cloudflare.com/queues/platform/javascript-apis/) + producer instance corresponding to the specified `bindingName` of + `workerName`. If `workerName` is not specified, defaults to the entrypoint + Worker. + +- `getR2Bucket(bindingName: string, workerName?: string): Promise` + + Returns a `Promise` that resolves with the + [`R2Bucket`](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/) + producer instance corresponding to the specified `bindingName` of + `workerName`. If `workerName` is not specified, defaults to the entrypoint + Worker. + +- `dispose(): Promise` + + Cleans up the Miniflare instance, and shuts down the `workerd` server. Note + that after this is called, `Miniflare#setOptions()` and + `Miniflare#dispatchFetch()` cannot be called. Additionally, calling this + function will invalidate any values returned by the `Miniflare#get*()` + methods, preventing them from being used. diff --git a/node_modules/miniflare/bootstrap.js b/node_modules/miniflare/bootstrap.js new file mode 100644 index 0000000000000000000000000000000000000000..a5e8826349405f08dd16a2968be15e4882df24a2 --- /dev/null +++ b/node_modules/miniflare/bootstrap.js @@ -0,0 +1,11 @@ +#!/usr/bin/env node +const { Log } = require("."); + +const log = new Log(); +log.error( + [ + "`miniflare@3` no longer includes a CLI. Please use `npx wrangler dev` instead.", + "As of `wrangler@3`, this will use Miniflare by default.", + "See https://miniflare.dev/get-started/migrating for more details.", + ].join("\n") +); diff --git a/node_modules/miniflare/dist/src/index.d.ts b/node_modules/miniflare/dist/src/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7abb40c38df04c42ae67119af3a5f491fa9d7e7 --- /dev/null +++ b/node_modules/miniflare/dist/src/index.d.ts @@ -0,0 +1,4590 @@ +/// + +import { Abortable } from 'events'; +import type { AbortSignal as AbortSignal_2 } from '@cloudflare/workers-types/experimental'; +import type { Blob as Blob_2 } from '@cloudflare/workers-types/experimental'; +import { Blob as Blob_3 } from 'buffer'; +import { BodyInit } from 'undici'; +import type { CacheStorage } from '@cloudflare/workers-types/experimental'; +import type { D1Database } from '@cloudflare/workers-types/experimental'; +import { default as default_2 } from 'undici/types/mock-agent'; +import { Dispatcher } from 'undici'; +import type { DurableObjectNamespace } from '@cloudflare/workers-types/experimental'; +import type { Fetcher } from '@cloudflare/workers-types/experimental'; +import { File } from 'undici'; +import type { File as File_2 } from '@cloudflare/workers-types/experimental'; +import { FormData } from 'undici'; +import { Headers } from 'undici'; +import type { Headers as Headers_2 } from '@cloudflare/workers-types/experimental'; +import { HeadersInit } from 'undici'; +import { IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental'; +import type { KVNamespace } from '@cloudflare/workers-types/experimental'; +import { MockAgent } from 'undici'; +import NodeWebSocket from 'ws'; +import type { Queue } from '@cloudflare/workers-types/experimental'; +import type { R2Bucket } from '@cloudflare/workers-types/experimental'; +import { Readable } from 'stream'; +import type { ReadableStream } from '@cloudflare/workers-types/experimental'; +import { ReadableStream as ReadableStream_2 } from 'stream/web'; +import { ReferrerPolicy } from 'undici'; +import { Request as Request_2 } from 'undici'; +import type { Request as Request_3 } from '@cloudflare/workers-types/experimental'; +import { RequestCache } from 'undici'; +import { RequestCredentials } from 'undici'; +import { RequestDestination } from 'undici'; +import { RequestDuplex } from 'undici'; +import { RequestInfo as RequestInfo_2 } from 'undici'; +import { RequestInit as RequestInit_2 } from 'undici'; +import type { RequestInit as RequestInit_3 } from '@cloudflare/workers-types/experimental'; +import type { RequestInitCfProperties } from '@cloudflare/workers-types/experimental'; +import { RequestMode } from 'undici'; +import { RequestRedirect } from 'undici'; +import { Response as Response_2 } from 'undici'; +import type { Response as Response_3 } from '@cloudflare/workers-types/experimental'; +import { ResponseInit as ResponseInit_2 } from 'undici'; +import { ResponseRedirectStatus } from 'undici'; +import { ResponseType } from 'undici'; +import type { ServiceWorkerGlobalScope } from '@cloudflare/workers-types/experimental'; +import { compatibilityDate as supportedCompatibilityDate } from 'workerd'; +import { Transform } from 'stream'; +import { z } from 'zod'; + +export declare type Awaitable = T | Promise; + +export declare function base64Decode(encoded: string): string; + +export declare function base64Encode(value: string): string; + +export { BodyInit } + +export declare const CACHE_PLUGIN: Plugin; + +export declare const CACHE_PLUGIN_NAME = "cache"; + +export declare const CacheBindings: { + readonly MAYBE_JSON_CACHE_WARN_USAGE: "MINIFLARE_CACHE_WARN_USAGE"; +}; + +export declare const CacheHeaders: { + readonly NAMESPACE: "cf-cache-namespace"; + readonly STATUS: "cf-cache-status"; +}; + +export declare interface CacheObjectCf { + miniflare?: { + cacheWarnUsage?: boolean; + }; +} + +export declare const CacheOptionsSchema: z.ZodObject<{ + cache: z.ZodOptional; + cacheWarnUsage: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + cache?: boolean | undefined; + cacheWarnUsage?: boolean | undefined; +}, { + cache?: boolean | undefined; + cacheWarnUsage?: boolean | undefined; +}>; + +export declare const CacheSharedOptionsSchema: z.ZodObject<{ + cachePersist: z.ZodOptional>; +}, "strip", z.ZodTypeAny, { + cachePersist?: string | boolean | undefined; +}, { + cachePersist?: string | boolean | undefined; +}>; + +export declare class CloseEvent extends Event { + readonly code: number; + readonly reason: string; + readonly wasClean: boolean; + constructor(type: "close", init?: { + code?: number; + reason?: string; + wasClean?: boolean; + }); +} + +export declare interface Config { + services?: Service[]; + sockets?: Socket[]; + v8Flags?: string[]; + extensions?: Extension[]; +} + +export declare function configureEntrySocket(coreOpts: z.infer): Promise; + +export declare const CORE_PLUGIN: Plugin; + +export declare const CORE_PLUGIN_NAME = "core"; + +export declare const CoreBindings: { + readonly SERVICE_LOOPBACK: "MINIFLARE_LOOPBACK"; + readonly SERVICE_USER_ROUTE_PREFIX: "MINIFLARE_USER_ROUTE_"; + readonly SERVICE_USER_FALLBACK: "MINIFLARE_USER_FALLBACK"; + readonly TEXT_CUSTOM_SERVICE: "MINIFLARE_CUSTOM_SERVICE"; + readonly TEXT_UPSTREAM_URL: "MINIFLARE_UPSTREAM_URL"; + readonly JSON_CF_BLOB: "CF_BLOB"; + readonly JSON_ROUTES: "MINIFLARE_ROUTES"; + readonly JSON_LOG_LEVEL: "MINIFLARE_LOG_LEVEL"; + readonly DATA_LIVE_RELOAD_SCRIPT: "MINIFLARE_LIVE_RELOAD_SCRIPT"; + readonly DURABLE_OBJECT_NAMESPACE_PROXY: "MINIFLARE_PROXY"; + readonly DATA_PROXY_SECRET: "MINIFLARE_PROXY_SECRET"; +}; + +export declare const CoreHeaders: { + readonly CUSTOM_SERVICE: "MF-Custom-Service"; + readonly ORIGINAL_URL: "MF-Original-URL"; + readonly DISABLE_PRETTY_ERROR: "MF-Disable-Pretty-Error"; + readonly ERROR_STACK: "MF-Experimental-Error-Stack"; + readonly ROUTE_OVERRIDE: "MF-Route-Override"; + readonly OP_SECRET: "MF-Op-Secret"; + readonly OP: "MF-Op"; + readonly OP_TARGET: "MF-Op-Target"; + readonly OP_KEY: "MF-Op-Key"; + readonly OP_SYNC: "MF-Op-Sync"; + readonly OP_STRINGIFIED_SIZE: "MF-Op-Stringified-Size"; + readonly OP_RESULT_TYPE: "MF-Op-Result-Type"; +}; + +export declare const CoreOptionsSchema: z.ZodEffects; + path: z.ZodString; + contents: z.ZodOptional]>>; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }>, "many">; + modulesRoot: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; +}, { + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; +}>, z.ZodObject<{ + script: z.ZodString; + scriptPath: z.ZodOptional; + modules: z.ZodOptional; + modulesRules: z.ZodOptional; + include: z.ZodArray; + fallthrough: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }>, "many">>; + modulesRoot: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}, { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}>, z.ZodObject<{ + scriptPath: z.ZodString; + modules: z.ZodOptional; + modulesRules: z.ZodOptional; + include: z.ZodArray; + fallthrough: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }>, "many">>; + modulesRoot: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}, { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}>]>, z.ZodObject<{ + name: z.ZodOptional; + compatibilityDate: z.ZodOptional; + compatibilityFlags: z.ZodOptional>; + routes: z.ZodOptional>; + bindings: z.ZodOptional>>; + wasmBindings: z.ZodOptional>; + textBlobBindings: z.ZodOptional>; + dataBlobBindings: z.ZodOptional>; + serviceBindings: z.ZodOptional>; + deny: z.ZodOptional>; + tlsOptions: z.ZodOptional; + certificateChain: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }>>; + requireClientCerts: z.ZodOptional; + trustBrowserCas: z.ZodOptional; + trustedCertificates: z.ZodOptional>; + minVersion: z.ZodOptional>; + cipherList: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }>>; + }, "strip", z.ZodTypeAny, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }>; + }, "strip", z.ZodTypeAny, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }>, z.ZodObject<{ + external: z.ZodType; + }, "strip", z.ZodTypeAny, { + external: ExternalServer & (ExternalServer | undefined); + }, { + external: ExternalServer & (ExternalServer | undefined); + }>, z.ZodObject<{ + disk: z.ZodObject<{ + path: z.ZodString; + writable: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + path: string; + writable?: boolean | undefined; + }, { + path: string; + writable?: boolean | undefined; + }>; + }, "strip", z.ZodTypeAny, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }>, z.ZodFunction, z.ZodTypeDef, Request>], z.ZodUnknown>, z.ZodUnion<[z.ZodType, z.ZodPromise>]>>]>>>; + wrappedBindings: z.ZodOptional; + bindings: z.ZodOptional>>; + }, "strip", z.ZodTypeAny, { + scriptName: string; + entrypoint?: string | undefined; + bindings?: Record | undefined; + }, { + scriptName: string; + entrypoint?: string | undefined; + bindings?: Record | undefined; + }>]>>>; + outboundService: z.ZodOptional>; + deny: z.ZodOptional>; + tlsOptions: z.ZodOptional; + certificateChain: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }>>; + requireClientCerts: z.ZodOptional; + trustBrowserCas: z.ZodOptional; + trustedCertificates: z.ZodOptional>; + minVersion: z.ZodOptional>; + cipherList: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }>>; + }, "strip", z.ZodTypeAny, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }>; + }, "strip", z.ZodTypeAny, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }>, z.ZodObject<{ + external: z.ZodType; + }, "strip", z.ZodTypeAny, { + external: ExternalServer & (ExternalServer | undefined); + }, { + external: ExternalServer & (ExternalServer | undefined); + }>, z.ZodObject<{ + disk: z.ZodObject<{ + path: z.ZodString; + writable: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + path: string; + writable?: boolean | undefined; + }, { + path: string; + writable?: boolean | undefined; + }>; + }, "strip", z.ZodTypeAny, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }>, z.ZodFunction, z.ZodTypeDef, Request>], z.ZodUnknown>, z.ZodUnion<[z.ZodType, z.ZodPromise>]>>]>>; + fetchMock: z.ZodOptional, z.ZodTypeDef, MockAgent>>; + unsafeEphemeralDurableObjects: z.ZodOptional; + unsafeDirectHost: z.ZodOptional; + unsafeDirectPort: z.ZodOptional; + unsafeEvalBinding: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: MockAgent | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; +}, { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: MockAgent | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; +}>>, ({ + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; +} & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: MockAgent | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; +}) | ({ + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +} & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: MockAgent | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; +}) | ({ + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +} & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: MockAgent | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; +}), ({ + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; +} | { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +} | { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}) & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: MockAgent | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; +}>; + +export declare const CoreSharedOptionsSchema: z.ZodObject<{ + host: z.ZodOptional; + port: z.ZodOptional; + https: z.ZodOptional; + httpsKey: z.ZodOptional; + httpsKeyPath: z.ZodOptional; + httpsCert: z.ZodOptional; + httpsCertPath: z.ZodOptional; + inspectorPort: z.ZodOptional; + verbose: z.ZodOptional; + log: z.ZodOptional>; + handleRuntimeStdio: z.ZodOptional, z.ZodType], null>, z.ZodUnknown>>; + upstream: z.ZodOptional; + cf: z.ZodOptional]>>; + liveReload: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + host?: string | undefined; + port?: number | undefined; + https?: boolean | undefined; + httpsKey?: string | undefined; + httpsKeyPath?: string | undefined; + httpsCert?: string | undefined; + httpsCertPath?: string | undefined; + inspectorPort?: number | undefined; + verbose?: boolean | undefined; + log?: Log | undefined; + handleRuntimeStdio?: ((args_0: Readable, args_1: Readable) => unknown) | undefined; + upstream?: string | undefined; + cf?: string | boolean | Record | undefined; + liveReload?: boolean | undefined; +}, { + host?: string | undefined; + port?: number | undefined; + https?: boolean | undefined; + httpsKey?: string | undefined; + httpsKeyPath?: string | undefined; + httpsCert?: string | undefined; + httpsCertPath?: string | undefined; + inspectorPort?: number | undefined; + verbose?: boolean | undefined; + log?: Log | undefined; + handleRuntimeStdio?: ((args_0: Readable, args_1: Readable) => unknown) | undefined; + upstream?: string | undefined; + cf?: string | boolean | Record | undefined; + liveReload?: boolean | undefined; +}>; + +export declare function coupleWebSocket(ws: NodeWebSocket, pair: WebSocket): Promise; + +export declare function createFetchMock(): MockAgent; + +export declare function createHTTPReducers(impl: PlatformImpl): ReducersRevivers; + +export declare function createHTTPRevivers(impl: PlatformImpl): ReducersRevivers; + +export declare const D1_PLUGIN: Plugin; + +export declare const D1_PLUGIN_NAME = "d1"; + +export declare const D1OptionsSchema: z.ZodObject<{ + d1Databases: z.ZodOptional, z.ZodArray]>>; +}, "strip", z.ZodTypeAny, { + d1Databases?: string[] | Record | undefined; +}, { + d1Databases?: string[] | Record | undefined; +}>; + +export declare const D1SharedOptionsSchema: z.ZodObject<{ + d1Persist: z.ZodOptional>; +}, "strip", z.ZodTypeAny, { + d1Persist?: string | boolean | undefined; +}, { + d1Persist?: string | boolean | undefined; +}>; + +export declare function decodeSitesKey(key: string): string; + +export declare const DEFAULT_PERSIST_ROOT = ".mf"; + +export declare class DeferredPromise extends Promise { + readonly resolve: DeferredPromiseResolve; + readonly reject: DeferredPromiseReject; + constructor(executor?: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void); +} + +export declare type DeferredPromiseReject = (reason?: any) => void; + +export declare type DeferredPromiseResolve = (value: T | PromiseLike) => void; + +export declare function deserialiseRegExps(matcher: SerialisableMatcherRegExps): MatcherRegExps; + +export declare function deserialiseSiteRegExps(siteRegExps: SerialisableSiteMatcherRegExps): SiteMatcherRegExps; + +export declare interface DiskDirectory { + path?: string; + writable?: boolean; +} + +export declare type DispatchFetch = (input: RequestInfo, init?: RequestInit>) => Promise; + +export declare const DURABLE_OBJECTS_PLUGIN: Plugin; + +export declare const DURABLE_OBJECTS_PLUGIN_NAME = "do"; + +export declare const DURABLE_OBJECTS_STORAGE_SERVICE_NAME: string; + +export declare type DurableObjectClassNames = Map>; + +export declare const DurableObjectsOptionsSchema: z.ZodObject<{ + durableObjects: z.ZodOptional; + unsafeUniqueKey: z.ZodOptional; + unsafePreventEviction: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + className: string; + scriptName?: string | undefined; + unsafeUniqueKey?: string | undefined; + unsafePreventEviction?: boolean | undefined; + }, { + className: string; + scriptName?: string | undefined; + unsafeUniqueKey?: string | undefined; + unsafePreventEviction?: boolean | undefined; + }>]>>>; +}, "strip", z.ZodTypeAny, { + durableObjects?: Record | undefined; +}, { + durableObjects?: Record | undefined; +}>; + +export declare const DurableObjectsSharedOptionsSchema: z.ZodObject<{ + durableObjectsPersist: z.ZodOptional>; +}, "strip", z.ZodTypeAny, { + durableObjectsPersist?: string | boolean | undefined; +}, { + durableObjectsPersist?: string | boolean | undefined; +}>; + +/* Excluded from this release type: _enableControlEndpoints */ + +export declare function encodeSitesKey(key: string): string; + +export declare class ErrorEvent extends Event { + readonly error: Error | null; + constructor(type: "error", init?: { + error?: Error; + }); +} + +export declare interface Extension { + modules?: Extension_Module[]; +} + +export declare interface Extension_Module { + name?: string; + internal?: boolean; + esModule?: string; +} + +export declare type ExternalServer = { + address?: string; +} & ({ + http: HttpOptions; +} | { + https: ExternalServer_Https; +} | { + tcp: ExternalServer_Tcp; +}); + +export declare interface ExternalServer_Https { + options?: HttpOptions; + tlsOptions?: TlsOptions; + certificateHost?: string; +} + +export declare interface ExternalServer_Tcp { + tlsOptions?: TlsOptions; + certificateHost?: string; +} + +export declare function fetch(input: RequestInfo, init?: RequestInit | Request): Promise; + +export { File } + +export declare function _forceColour(enabled?: boolean): void; + +/* Excluded from this release type: _formatZodError */ +export { FormData } + +export declare function getAccessibleHosts(ipv4Only?: boolean): string[]; + +export declare function getCacheServiceName(workerIndex: number): string; + +export declare function getControlEndpointBindings(): Worker_Binding[]; + +export declare function getDirectSocketName(workerIndex: number): string; + +export declare function getGlobalServices({ sharedOptions, allWorkerRoutes, fallbackWorkerName, loopbackPort, log, proxyBindings, }: GlobalServicesOptions): Service[]; + +export declare function getPersistPath(pluginName: string, tmpPath: string, persist: Persistence): string; + +export declare interface GlobalServicesOptions { + sharedOptions: z.infer; + allWorkerRoutes: Map; + fallbackWorkerName: string | undefined; + loopbackPort: number; + log: Log; + proxyBindings: Worker_Binding[]; +} + +export declare function globsToRegExps(globs?: string[]): MatcherRegExps; + +export declare const HEADER_CF_BLOB = "MF-CF-Blob"; + +export { Headers } + +export { HeadersInit } + +export declare interface HttpOptions { + style?: HttpOptions_Style; + forwardedProtoHeader?: string; + cfBlobHeader?: string; + injectRequestHeaders?: HttpOptions_Header[]; + injectResponseHeaders?: HttpOptions_Header[]; +} + +export declare interface HttpOptions_Header { + name?: string; + value?: string; +} + +export declare enum HttpOptions_Style { + HOST = 0, + PROXY = 1, +} + +export declare const HYPERDRIVE_PLUGIN: Plugin; + +export declare const HYPERDRIVE_PLUGIN_NAME = "hyperdrive"; + +export declare const HyperdriveInputOptionsSchema: z.ZodObject<{ + hyperdrives: z.ZodOptional>>; +}, "strip", z.ZodTypeAny, { + hyperdrives?: Record | undefined; +}, { + hyperdrives?: Record | undefined; +}>; + +export declare const HyperdriveSchema: z.ZodEffects; + +export declare interface InclusiveRange { + start: number; + end: number; +} + +/* Excluded from this release type: _initialiseInstanceRegistry */ + +/* Excluded from this release type: _isCyclic */ + +export declare function isFetcherFetch(targetName: string, key: string): boolean; + +export declare function isR2ObjectWriteHttpMetadata(targetName: string, key: string): boolean; + +export declare function isSitesRequest(request: { + url: string; +}): boolean; + +export declare type Json = Literal | { + [key: string]: Json; +} | Json[]; + +export declare interface JsonError { + message?: string; + name?: string; + stack?: string; + cause?: JsonError; +} + +export declare const JsonSchema: z.ZodType; + +declare const kAccepted: unique symbol; + +declare const kCf: unique symbol; + +declare const kClose: unique symbol; + +declare const kClosedIncoming: unique symbol; + +declare const kClosedOutgoing: unique symbol; + +declare const kCoupled: unique symbol; + +declare const kError: unique symbol; + +export declare const kInspectorSocket: unique symbol; + +declare const kPair: unique symbol; + +export declare const kProxyNodeBinding: unique symbol; + +declare const kSend: unique symbol; + +export declare const KV_PLUGIN: Plugin; + +export declare const KV_PLUGIN_NAME = "kv"; + +export declare const KVHeaders: { + readonly EXPIRATION: "CF-Expiration"; + readonly METADATA: "CF-KV-Metadata"; +}; + +export declare const KVLimits: { + readonly MIN_CACHE_TTL: 60; + readonly MAX_LIST_KEYS: 1000; + readonly MAX_KEY_SIZE: 512; + readonly MAX_VALUE_SIZE: number; + readonly MAX_VALUE_SIZE_TEST: 1024; + readonly MAX_METADATA_SIZE: 1024; +}; + +export declare const kVoid: unique symbol; + +export declare const KVOptionsSchema: z.ZodObject<{ + kvNamespaces: z.ZodOptional, z.ZodArray]>>; + sitePath: z.ZodOptional; + siteInclude: z.ZodOptional>; + siteExclude: z.ZodOptional>; +}, "strip", z.ZodTypeAny, { + kvNamespaces?: string[] | Record | undefined; + sitePath?: string | undefined; + siteInclude?: string[] | undefined; + siteExclude?: string[] | undefined; +}, { + kvNamespaces?: string[] | Record | undefined; + sitePath?: string | undefined; + siteInclude?: string[] | undefined; + siteExclude?: string[] | undefined; +}>; + +export declare const KVParams: { + readonly URL_ENCODED: "urlencoded"; + readonly CACHE_TTL: "cache_ttl"; + readonly EXPIRATION: "expiration"; + readonly EXPIRATION_TTL: "expiration_ttl"; + readonly LIST_LIMIT: "key_count_limit"; + readonly LIST_PREFIX: "prefix"; + readonly LIST_CURSOR: "cursor"; +}; + +export declare const KVSharedOptionsSchema: z.ZodObject<{ + kvPersist: z.ZodOptional>; +}, "strip", z.ZodTypeAny, { + kvPersist?: string | boolean | undefined; +}, { + kvPersist?: string | boolean | undefined; +}>; + +declare const kWebSocket: unique symbol; + +export declare type Literal = z.infer; + +export declare const LiteralSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>; + +export declare class Log { + #private; + readonly level: LogLevel; + constructor(level?: LogLevel, opts?: LogOptions); + protected log(message: string): void; + logWithLevel(level: LogLevel, message: string): void; + error(message: Error): void; + warn(message: string): void; + info(message: string): void; + debug(message: string): void; + verbose(message: string): void; +} + +export declare enum LogLevel { + NONE = 0, + ERROR = 1, + WARN = 2, + INFO = 3, + DEBUG = 4, + VERBOSE = 5 +} + +export declare interface LogOptions { + prefix?: string; + suffix?: string; +} + +export declare interface MatcherRegExps { + include: RegExp[]; + exclude: RegExp[]; +} + +export declare function matchRoutes(routes: WorkerRoute[], url: URL): string | null; + +export declare function maybeApply(f: (value: From) => To, maybeValue: From | undefined): To | undefined; + +export declare function maybeParseURL(url: Persistence): URL | undefined; + +export declare class MessageEvent extends Event { + readonly data: ArrayBuffer | string; + constructor(type: "message", init: { + data: ArrayBuffer | string; + }); +} + +export declare function migrateDatabase(log: Log, uniqueKey: string, persistPath: string, namespace: string): Promise; + +export declare class Miniflare { + #private; + constructor(opts: MiniflareOptions); + get ready(): Promise; + getInspectorURL(): Promise; + unsafeGetDirectURL(workerName?: string): Promise; + setOptions(opts: MiniflareOptions): Promise; + dispatchFetch: DispatchFetch; + /* Excluded from this release type: _getProxyClient */ + getBindings>(workerName?: string): Promise; + getWorker(workerName?: string): Promise>; + getCaches(): Promise>; + getD1Database(bindingName: string, workerName?: string): Promise; + getDurableObjectNamespace(bindingName: string, workerName?: string): Promise>; + getKVNamespace(bindingName: string, workerName?: string): Promise>; + getQueueProducer(bindingName: string, workerName?: string): Promise>; + getR2Bucket(bindingName: string, workerName?: string): Promise>; + /* Excluded from this release type: _getInternalDurableObjectNamespace */ + dispose(): Promise; +} + +export declare class MiniflareCoreError extends MiniflareError { +} + +export declare type MiniflareCoreErrorCode = "ERR_RUNTIME_FAILURE" | "ERR_DISPOSED" | "ERR_MODULE_PARSE" | "ERR_MODULE_STRING_SCRIPT" | "ERR_MODULE_DYNAMIC_SPEC" | "ERR_MODULE_RULE" | "ERR_PERSIST_UNSUPPORTED" | "ERR_PERSIST_REMOTE_UNAUTHENTICATED" | "ERR_PERSIST_REMOTE_UNSUPPORTED" | "ERR_FUTURE_COMPATIBILITY_DATE" | "ERR_NO_WORKERS" | "ERR_VALIDATION" | "ERR_DUPLICATE_NAME" | "ERR_DIFFERENT_UNIQUE_KEYS" | "ERR_DIFFERENT_PREVENT_EVICTION" | "ERR_MULTIPLE_OUTBOUNDS" | "ERR_INVALID_WRAPPED" | "ERR_CYCLIC"; + +export declare class MiniflareError extends Error { + readonly code: Code; + readonly cause?: Error | undefined; + constructor(code: Code, message?: string, cause?: Error | undefined); +} + +export declare type MiniflareOptions = SharedOptions & (WorkerOptions | { + workers: WorkerOptions[]; +}); + +export declare type ModuleDefinition = z.infer; + +export declare const ModuleDefinitionSchema: z.ZodObject<{ + type: z.ZodEnum<["ESModule", "CommonJS", "NodeJsCompatModule", "Text", "Data", "CompiledWasm"]>; + path: z.ZodString; + contents: z.ZodOptional]>>; +}, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; +}, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; +}>; + +export declare type ModuleRule = z.infer; + +export declare const ModuleRuleSchema: z.ZodObject<{ + type: z.ZodEnum<["ESModule", "CommonJS", "NodeJsCompatModule", "Text", "Data", "CompiledWasm"]>; + include: z.ZodArray; + fallthrough: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; +}, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; +}>; + +export declare type ModuleRuleType = z.infer; + +export declare const ModuleRuleTypeSchema: z.ZodEnum<["ESModule", "CommonJS", "NodeJsCompatModule", "Text", "Data", "CompiledWasm"]>; + +export declare class Mutex { + private locked; + private resolveQueue; + private drainQueue; + private lock; + private unlock; + get hasWaiting(): boolean; + runWith(closure: () => Awaitable): Promise; + drained(): Promise; +} + +export declare function namespaceEntries(namespaces?: Record | string[]): [bindingName: string, id: string][]; + +export declare function namespaceKeys(namespaces?: Record | string[]): string[]; + +export declare interface Network { + allow?: string[]; + deny?: string[]; + tlsOptions?: TlsOptions; +} + +export declare const NODE_PLATFORM_IMPL: PlatformImpl; + +export declare class NoOpLog extends Log { + constructor(); + protected log(): void; + error(_message: Error): void; +} + +export declare function normaliseDurableObject(designator: NonNullable["durableObjects"]>[string]): { + className: string; + serviceName?: string; + unsafeUniqueKey?: string; + unsafePreventEviction?: boolean; +}; + +export declare function objectEntryWorker(durableObjectNamespace: Worker_Binding_DurableObjectNamespaceDesignator, namespace: string): Worker; + +export declare type OptionalZodTypeOf = T extends z.ZodTypeAny ? z.TypeOf : undefined; + +export declare type OverloadReplaceWorkersTypes = T extends (...args: any[]) => any ? UnionToIntersection>> : ReplaceWorkersTypes; + +export declare type OverloadUnion any> = Parameters extends [] ? T : OverloadUnion9; + +export declare type OverloadUnion2 = T extends { + (...args: infer P1): infer R1; + (...args: infer P2): infer R2; +} ? ((...args: P1) => R1) | ((...args: P2) => R2) : T; + +export declare type OverloadUnion3 = T extends { + (...args: infer P1): infer R1; + (...args: infer P2): infer R2; + (...args: infer P3): infer R3; +} ? ((...args: P1) => R1) | ((...args: P2) => R2) | ((...args: P3) => R3) : OverloadUnion2; + +export declare type OverloadUnion4 = T extends { + (...args: infer P1): infer R1; + (...args: infer P2): infer R2; + (...args: infer P3): infer R3; + (...args: infer P4): infer R4; +} ? ((...args: P1) => R1) | ((...args: P2) => R2) | ((...args: P3) => R3) | ((...args: P4) => R4) : OverloadUnion3; + +export declare type OverloadUnion5 = T extends { + (...args: infer P1): infer R1; + (...args: infer P2): infer R2; + (...args: infer P3): infer R3; + (...args: infer P4): infer R4; + (...args: infer P5): infer R5; +} ? ((...args: P1) => R1) | ((...args: P2) => R2) | ((...args: P3) => R3) | ((...args: P4) => R4) | ((...args: P5) => R5) : OverloadUnion4; + +export declare type OverloadUnion6 = T extends { + (...args: infer P1): infer R1; + (...args: infer P2): infer R2; + (...args: infer P3): infer R3; + (...args: infer P4): infer R4; + (...args: infer P5): infer R5; + (...args: infer P6): infer R6; +} ? ((...args: P1) => R1) | ((...args: P2) => R2) | ((...args: P3) => R3) | ((...args: P4) => R4) | ((...args: P5) => R5) | ((...args: P6) => R6) : OverloadUnion5; + +export declare type OverloadUnion7 = T extends { + (...args: infer P1): infer R1; + (...args: infer P2): infer R2; + (...args: infer P3): infer R3; + (...args: infer P4): infer R4; + (...args: infer P5): infer R5; + (...args: infer P6): infer R6; + (...args: infer P7): infer R7; +} ? ((...args: P1) => R1) | ((...args: P2) => R2) | ((...args: P3) => R3) | ((...args: P4) => R4) | ((...args: P5) => R5) | ((...args: P6) => R6) | ((...args: P7) => R7) : OverloadUnion6; + +export declare type OverloadUnion8 = T extends { + (...args: infer P1): infer R1; + (...args: infer P2): infer R2; + (...args: infer P3): infer R3; + (...args: infer P4): infer R4; + (...args: infer P5): infer R5; + (...args: infer P6): infer R6; + (...args: infer P7): infer R7; + (...args: infer P8): infer R8; +} ? ((...args: P1) => R1) | ((...args: P2) => R2) | ((...args: P3) => R3) | ((...args: P4) => R4) | ((...args: P5) => R5) | ((...args: P6) => R6) | ((...args: P7) => R7) | ((...args: P8) => R8) : OverloadUnion7; + +export declare type OverloadUnion9 = T extends { + (...args: infer P1): infer R1; + (...args: infer P2): infer R2; + (...args: infer P3): infer R3; + (...args: infer P4): infer R4; + (...args: infer P5): infer R5; + (...args: infer P6): infer R6; + (...args: infer P7): infer R7; + (...args: infer P8): infer R8; + (...args: infer P9): infer R9; +} ? ((...args: P1) => R1) | ((...args: P2) => R2) | ((...args: P3) => R3) | ((...args: P4) => R4) | ((...args: P5) => R5) | ((...args: P6) => R6) | ((...args: P7) => R7) | ((...args: P8) => R8) | ((...args: P9) => R9) : OverloadUnion8; + +/** + * Parses an HTTP `Range` header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range), + * returning either: + * - `undefined` indicating the range is unsatisfiable + * - An empty array indicating the entire response should be returned + * - A non-empty array of inclusive ranges of the response to return + */ +export declare function parseRanges(rangeHeader: string, length: number): InclusiveRange[] | undefined; + +export declare function parseRoutes(allRoutes: Map): WorkerRoute[]; + +export declare function parseWithReadableStreams(impl: PlatformImpl, stringified: StringifiedWithStream, revivers: ReducersRevivers): unknown; + +export declare type Persistence = z.infer; + +export declare const PersistenceSchema: z.ZodOptional>; + +export declare interface PlatformImpl { + Blob: typeof Blob_2; + File: typeof File_2; + Headers: typeof Headers_2; + Request: typeof Request_3; + Response: typeof Response_3; + isReadableStream(value: unknown): value is RS; + bufferReadableStream(stream: RS): Promise; + unbufferReadableStream(buffer: ArrayBuffer): RS; +} + +export declare type Plugin = PluginBase & (SharedOptions extends undefined ? { + sharedOptions?: undefined; +} : { + sharedOptions: SharedOptions; +}); + +export declare const PLUGIN_ENTRIES: ["cache" | "core" | "do" | "d1" | "hyperdrive" | "kv" | "queues" | "r2", ValueOf<{ + core: Plugin; + path: z.ZodString; + contents: z.ZodOptional]>>; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }>, "many">; + modulesRoot: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; + }, { + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; + }>, z.ZodObject<{ + script: z.ZodString; + scriptPath: z.ZodOptional; + modules: z.ZodOptional; + modulesRules: z.ZodOptional; + include: z.ZodArray; + fallthrough: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }>, "many">>; + modulesRoot: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }, { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }>, z.ZodObject<{ + scriptPath: z.ZodString; + modules: z.ZodOptional; + modulesRules: z.ZodOptional; + include: z.ZodArray; + fallthrough: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }>, "many">>; + modulesRoot: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }, { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }>]>, z.ZodObject<{ + name: z.ZodOptional; + compatibilityDate: z.ZodOptional; + compatibilityFlags: z.ZodOptional>; + routes: z.ZodOptional>; + bindings: z.ZodOptional>>; + wasmBindings: z.ZodOptional>; + textBlobBindings: z.ZodOptional>; + dataBlobBindings: z.ZodOptional>; + serviceBindings: z.ZodOptional>; + deny: z.ZodOptional>; + tlsOptions: z.ZodOptional; + certificateChain: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }>>; + requireClientCerts: z.ZodOptional; + trustBrowserCas: z.ZodOptional; + trustedCertificates: z.ZodOptional>; + minVersion: z.ZodOptional>; + cipherList: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }>>; + }, "strip", z.ZodTypeAny, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }>; + }, "strip", z.ZodTypeAny, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }>, z.ZodObject<{ + external: z.ZodType; + }, "strip", z.ZodTypeAny, { + external: ExternalServer & (ExternalServer | undefined); + }, { + external: ExternalServer & (ExternalServer | undefined); + }>, z.ZodObject<{ + disk: z.ZodObject<{ + path: z.ZodString; + writable: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + path: string; + writable?: boolean | undefined; + }, { + path: string; + writable?: boolean | undefined; + }>; + }, "strip", z.ZodTypeAny, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }>, z.ZodFunction, z.ZodTypeDef, Request>], z.ZodUnknown>, z.ZodUnion<[z.ZodType, z.ZodPromise>]>>]>>>; + wrappedBindings: z.ZodOptional; + bindings: z.ZodOptional>>; + }, "strip", z.ZodTypeAny, { + scriptName: string; + entrypoint?: string | undefined; + bindings?: Record | undefined; + }, { + scriptName: string; + entrypoint?: string | undefined; + bindings?: Record | undefined; + }>]>>>; + outboundService: z.ZodOptional>; + deny: z.ZodOptional>; + tlsOptions: z.ZodOptional; + certificateChain: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }>>; + requireClientCerts: z.ZodOptional; + trustBrowserCas: z.ZodOptional; + trustedCertificates: z.ZodOptional>; + minVersion: z.ZodOptional>; + cipherList: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }>>; + }, "strip", z.ZodTypeAny, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }>; + }, "strip", z.ZodTypeAny, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }>, z.ZodObject<{ + external: z.ZodType; + }, "strip", z.ZodTypeAny, { + external: ExternalServer & (ExternalServer | undefined); + }, { + external: ExternalServer & (ExternalServer | undefined); + }>, z.ZodObject<{ + disk: z.ZodObject<{ + path: z.ZodString; + writable: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + path: string; + writable?: boolean | undefined; + }, { + path: string; + writable?: boolean | undefined; + }>; + }, "strip", z.ZodTypeAny, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }>, z.ZodFunction, z.ZodTypeDef, Request>], z.ZodUnknown>, z.ZodUnion<[z.ZodType, z.ZodPromise>]>>]>>; + fetchMock: z.ZodOptional, z.ZodTypeDef, default_2>>; + unsafeEphemeralDurableObjects: z.ZodOptional; + unsafeDirectHost: z.ZodOptional; + unsafeDirectPort: z.ZodOptional; + unsafeEvalBinding: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }, { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }>>, ({ + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; + } & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }) | ({ + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + } & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }) | ({ + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + } & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }), ({ + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; + } | { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + } | { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }) & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }>, z.ZodObject<{ + host: z.ZodOptional; + port: z.ZodOptional; + https: z.ZodOptional; + httpsKey: z.ZodOptional; + httpsKeyPath: z.ZodOptional; + httpsCert: z.ZodOptional; + httpsCertPath: z.ZodOptional; + inspectorPort: z.ZodOptional; + verbose: z.ZodOptional; + log: z.ZodOptional>; + handleRuntimeStdio: z.ZodOptional, z.ZodType], null>, z.ZodUnknown>>; + upstream: z.ZodOptional; + cf: z.ZodOptional]>>; + liveReload: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + host?: string | undefined; + port?: number | undefined; + https?: boolean | undefined; + httpsKey?: string | undefined; + httpsKeyPath?: string | undefined; + httpsCert?: string | undefined; + httpsCertPath?: string | undefined; + inspectorPort?: number | undefined; + verbose?: boolean | undefined; + log?: Log | undefined; + handleRuntimeStdio?: ((args_0: Readable, args_1: Readable) => unknown) | undefined; + upstream?: string | undefined; + cf?: string | boolean | Record | undefined; + liveReload?: boolean | undefined; + }, { + host?: string | undefined; + port?: number | undefined; + https?: boolean | undefined; + httpsKey?: string | undefined; + httpsKeyPath?: string | undefined; + httpsCert?: string | undefined; + httpsCertPath?: string | undefined; + inspectorPort?: number | undefined; + verbose?: boolean | undefined; + log?: Log | undefined; + handleRuntimeStdio?: ((args_0: Readable, args_1: Readable) => unknown) | undefined; + upstream?: string | undefined; + cf?: string | boolean | Record | undefined; + liveReload?: boolean | undefined; + }>>; + cache: Plugin; + cacheWarnUsage: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + cache?: boolean | undefined; + cacheWarnUsage?: boolean | undefined; + }, { + cache?: boolean | undefined; + cacheWarnUsage?: boolean | undefined; + }>, z.ZodObject<{ + cachePersist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + cachePersist?: string | boolean | undefined; + }, { + cachePersist?: string | boolean | undefined; + }>>; + d1: Plugin, z.ZodArray]>>; + }, "strip", z.ZodTypeAny, { + d1Databases?: string[] | Record | undefined; + }, { + d1Databases?: string[] | Record | undefined; + }>, z.ZodObject<{ + d1Persist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + d1Persist?: string | boolean | undefined; + }, { + d1Persist?: string | boolean | undefined; + }>>; + do: Plugin; + unsafeUniqueKey: z.ZodOptional; + unsafePreventEviction: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + className: string; + scriptName?: string | undefined; + unsafeUniqueKey?: string | undefined; + unsafePreventEviction?: boolean | undefined; + }, { + className: string; + scriptName?: string | undefined; + unsafeUniqueKey?: string | undefined; + unsafePreventEviction?: boolean | undefined; + }>]>>>; + }, "strip", z.ZodTypeAny, { + durableObjects?: Record | undefined; + }, { + durableObjects?: Record | undefined; + }>, z.ZodObject<{ + durableObjectsPersist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + durableObjectsPersist?: string | boolean | undefined; + }, { + durableObjectsPersist?: string | boolean | undefined; + }>>; + kv: Plugin, z.ZodArray]>>; + sitePath: z.ZodOptional; + siteInclude: z.ZodOptional>; + siteExclude: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + kvNamespaces?: string[] | Record | undefined; + sitePath?: string | undefined; + siteInclude?: string[] | undefined; + siteExclude?: string[] | undefined; + }, { + kvNamespaces?: string[] | Record | undefined; + sitePath?: string | undefined; + siteInclude?: string[] | undefined; + siteExclude?: string[] | undefined; + }>, z.ZodObject<{ + kvPersist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + kvPersist?: string | boolean | undefined; + }, { + kvPersist?: string | boolean | undefined; + }>>; + queues: Plugin, z.ZodArray]>>; + queueConsumers: z.ZodOptional; + maxBatchTimeout: z.ZodOptional; + maxRetires: z.ZodOptional; + deadLetterQueue: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; + }, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; + }>>, z.ZodArray]>>; + }, "strip", z.ZodTypeAny, { + queueProducers?: string[] | Record | undefined; + queueConsumers?: string[] | Record | undefined; + }, { + queueProducers?: string[] | Record | undefined; + queueConsumers?: string[] | Record | undefined; + }>>; + r2: Plugin, z.ZodArray]>>; + }, "strip", z.ZodTypeAny, { + r2Buckets?: string[] | Record | undefined; + }, { + r2Buckets?: string[] | Record | undefined; + }>, z.ZodObject<{ + r2Persist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + r2Persist?: string | boolean | undefined; + }, { + r2Persist?: string | boolean | undefined; + }>>; + hyperdrive: Plugin>>; + }, "strip", z.ZodTypeAny, { + hyperdrives?: Record | undefined; + }, { + hyperdrives?: Record | undefined; + }>>; +}>][]; + +export declare interface PluginBase { + options: Options; + getBindings(options: z.infer, workerIndex: number): Awaitable; + getNodeBindings(options: z.infer): Awaitable>; + getServices(options: PluginServicesOptions): Awaitable; +} + +export declare const PLUGINS: { + core: Plugin; + path: z.ZodString; + contents: z.ZodOptional]>>; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }>, "many">; + modulesRoot: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; + }, { + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; + }>, z.ZodObject<{ + script: z.ZodString; + scriptPath: z.ZodOptional; + modules: z.ZodOptional; + modulesRules: z.ZodOptional; + include: z.ZodArray; + fallthrough: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }>, "many">>; + modulesRoot: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }, { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }>, z.ZodObject<{ + scriptPath: z.ZodString; + modules: z.ZodOptional; + modulesRules: z.ZodOptional; + include: z.ZodArray; + fallthrough: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }>, "many">>; + modulesRoot: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }, { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }>]>, z.ZodObject<{ + name: z.ZodOptional; + compatibilityDate: z.ZodOptional; + compatibilityFlags: z.ZodOptional>; + routes: z.ZodOptional>; + bindings: z.ZodOptional>>; + wasmBindings: z.ZodOptional>; + textBlobBindings: z.ZodOptional>; + dataBlobBindings: z.ZodOptional>; + serviceBindings: z.ZodOptional>; + deny: z.ZodOptional>; + tlsOptions: z.ZodOptional; + certificateChain: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }>>; + requireClientCerts: z.ZodOptional; + trustBrowserCas: z.ZodOptional; + trustedCertificates: z.ZodOptional>; + minVersion: z.ZodOptional>; + cipherList: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }>>; + }, "strip", z.ZodTypeAny, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }>; + }, "strip", z.ZodTypeAny, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }>, z.ZodObject<{ + external: z.ZodType; + }, "strip", z.ZodTypeAny, { + external: ExternalServer & (ExternalServer | undefined); + }, { + external: ExternalServer & (ExternalServer | undefined); + }>, z.ZodObject<{ + disk: z.ZodObject<{ + path: z.ZodString; + writable: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + path: string; + writable?: boolean | undefined; + }, { + path: string; + writable?: boolean | undefined; + }>; + }, "strip", z.ZodTypeAny, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }>, z.ZodFunction, z.ZodTypeDef, Request>], z.ZodUnknown>, z.ZodUnion<[z.ZodType, z.ZodPromise>]>>]>>>; + wrappedBindings: z.ZodOptional; + bindings: z.ZodOptional>>; + }, "strip", z.ZodTypeAny, { + scriptName: string; + entrypoint?: string | undefined; + bindings?: Record | undefined; + }, { + scriptName: string; + entrypoint?: string | undefined; + bindings?: Record | undefined; + }>]>>>; + outboundService: z.ZodOptional>; + deny: z.ZodOptional>; + tlsOptions: z.ZodOptional; + certificateChain: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }, { + privateKey?: string | undefined; + certificateChain?: string | undefined; + }>>; + requireClientCerts: z.ZodOptional; + trustBrowserCas: z.ZodOptional; + trustedCertificates: z.ZodOptional>; + minVersion: z.ZodOptional>; + cipherList: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }, { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + }>>; + }, "strip", z.ZodTypeAny, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }, { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }>; + }, "strip", z.ZodTypeAny, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }, { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + }>, z.ZodObject<{ + external: z.ZodType; + }, "strip", z.ZodTypeAny, { + external: ExternalServer & (ExternalServer | undefined); + }, { + external: ExternalServer & (ExternalServer | undefined); + }>, z.ZodObject<{ + disk: z.ZodObject<{ + path: z.ZodString; + writable: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + path: string; + writable?: boolean | undefined; + }, { + path: string; + writable?: boolean | undefined; + }>; + }, "strip", z.ZodTypeAny, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }, { + disk: { + path: string; + writable?: boolean | undefined; + }; + }>, z.ZodFunction, z.ZodTypeDef, Request>], z.ZodUnknown>, z.ZodUnion<[z.ZodType, z.ZodPromise>]>>]>>; + fetchMock: z.ZodOptional, z.ZodTypeDef, default_2>>; + unsafeEphemeralDurableObjects: z.ZodOptional; + unsafeDirectHost: z.ZodOptional; + unsafeDirectPort: z.ZodOptional; + unsafeEvalBinding: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }, { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }>>, ({ + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; + } & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }) | ({ + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + } & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }) | ({ + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + } & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }), ({ + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; + } | { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + } | { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; + }) & { + name?: string | undefined; + compatibilityDate?: string | undefined; + compatibilityFlags?: string[] | undefined; + routes?: string[] | undefined; + bindings?: Record | undefined; + wasmBindings?: Record | undefined; + textBlobBindings?: Record | undefined; + dataBlobBindings?: Record | undefined; + serviceBindings?: Record, ...args_1: unknown[]) => Response | Promise)> | undefined; + wrappedBindings?: Record | undefined; + }> | undefined; + outboundService?: string | { + network: { + allow?: string[] | undefined; + deny?: string[] | undefined; + tlsOptions?: { + keypair?: { + privateKey?: string | undefined; + certificateChain?: string | undefined; + } | undefined; + requireClientCerts?: boolean | undefined; + trustBrowserCas?: boolean | undefined; + trustedCertificates?: string[] | undefined; + minVersion?: TlsOptions_Version | undefined; + cipherList?: string | undefined; + } | undefined; + }; + } | { + external: ExternalServer & (ExternalServer | undefined); + } | { + disk: { + path: string; + writable?: boolean | undefined; + }; + } | ((args_0: Request, ...args_1: unknown[]) => Response | Promise) | undefined; + fetchMock?: default_2 | undefined; + unsafeEphemeralDurableObjects?: boolean | undefined; + unsafeDirectHost?: string | undefined; + unsafeDirectPort?: number | undefined; + unsafeEvalBinding?: string | undefined; + }>, z.ZodObject<{ + host: z.ZodOptional; + port: z.ZodOptional; + https: z.ZodOptional; + httpsKey: z.ZodOptional; + httpsKeyPath: z.ZodOptional; + httpsCert: z.ZodOptional; + httpsCertPath: z.ZodOptional; + inspectorPort: z.ZodOptional; + verbose: z.ZodOptional; + log: z.ZodOptional>; + handleRuntimeStdio: z.ZodOptional, z.ZodType], null>, z.ZodUnknown>>; + upstream: z.ZodOptional; + cf: z.ZodOptional]>>; + liveReload: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + host?: string | undefined; + port?: number | undefined; + https?: boolean | undefined; + httpsKey?: string | undefined; + httpsKeyPath?: string | undefined; + httpsCert?: string | undefined; + httpsCertPath?: string | undefined; + inspectorPort?: number | undefined; + verbose?: boolean | undefined; + log?: Log | undefined; + handleRuntimeStdio?: ((args_0: Readable, args_1: Readable) => unknown) | undefined; + upstream?: string | undefined; + cf?: string | boolean | Record | undefined; + liveReload?: boolean | undefined; + }, { + host?: string | undefined; + port?: number | undefined; + https?: boolean | undefined; + httpsKey?: string | undefined; + httpsKeyPath?: string | undefined; + httpsCert?: string | undefined; + httpsCertPath?: string | undefined; + inspectorPort?: number | undefined; + verbose?: boolean | undefined; + log?: Log | undefined; + handleRuntimeStdio?: ((args_0: Readable, args_1: Readable) => unknown) | undefined; + upstream?: string | undefined; + cf?: string | boolean | Record | undefined; + liveReload?: boolean | undefined; + }>>; + cache: Plugin; + cacheWarnUsage: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + cache?: boolean | undefined; + cacheWarnUsage?: boolean | undefined; + }, { + cache?: boolean | undefined; + cacheWarnUsage?: boolean | undefined; + }>, z.ZodObject<{ + cachePersist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + cachePersist?: string | boolean | undefined; + }, { + cachePersist?: string | boolean | undefined; + }>>; + d1: Plugin, z.ZodArray]>>; + }, "strip", z.ZodTypeAny, { + d1Databases?: string[] | Record | undefined; + }, { + d1Databases?: string[] | Record | undefined; + }>, z.ZodObject<{ + d1Persist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + d1Persist?: string | boolean | undefined; + }, { + d1Persist?: string | boolean | undefined; + }>>; + do: Plugin; + unsafeUniqueKey: z.ZodOptional; + unsafePreventEviction: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + className: string; + scriptName?: string | undefined; + unsafeUniqueKey?: string | undefined; + unsafePreventEviction?: boolean | undefined; + }, { + className: string; + scriptName?: string | undefined; + unsafeUniqueKey?: string | undefined; + unsafePreventEviction?: boolean | undefined; + }>]>>>; + }, "strip", z.ZodTypeAny, { + durableObjects?: Record | undefined; + }, { + durableObjects?: Record | undefined; + }>, z.ZodObject<{ + durableObjectsPersist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + durableObjectsPersist?: string | boolean | undefined; + }, { + durableObjectsPersist?: string | boolean | undefined; + }>>; + kv: Plugin, z.ZodArray]>>; + sitePath: z.ZodOptional; + siteInclude: z.ZodOptional>; + siteExclude: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + kvNamespaces?: string[] | Record | undefined; + sitePath?: string | undefined; + siteInclude?: string[] | undefined; + siteExclude?: string[] | undefined; + }, { + kvNamespaces?: string[] | Record | undefined; + sitePath?: string | undefined; + siteInclude?: string[] | undefined; + siteExclude?: string[] | undefined; + }>, z.ZodObject<{ + kvPersist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + kvPersist?: string | boolean | undefined; + }, { + kvPersist?: string | boolean | undefined; + }>>; + queues: Plugin, z.ZodArray]>>; + queueConsumers: z.ZodOptional; + maxBatchTimeout: z.ZodOptional; + maxRetires: z.ZodOptional; + deadLetterQueue: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; + }, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; + }>>, z.ZodArray]>>; + }, "strip", z.ZodTypeAny, { + queueProducers?: string[] | Record | undefined; + queueConsumers?: string[] | Record | undefined; + }, { + queueProducers?: string[] | Record | undefined; + queueConsumers?: string[] | Record | undefined; + }>>; + r2: Plugin, z.ZodArray]>>; + }, "strip", z.ZodTypeAny, { + r2Buckets?: string[] | Record | undefined; + }, { + r2Buckets?: string[] | Record | undefined; + }>, z.ZodObject<{ + r2Persist: z.ZodOptional>; + }, "strip", z.ZodTypeAny, { + r2Persist?: string | boolean | undefined; + }, { + r2Persist?: string | boolean | undefined; + }>>; + hyperdrive: Plugin>>; + }, "strip", z.ZodTypeAny, { + hyperdrives?: Record | undefined; + }, { + hyperdrives?: Record | undefined; + }>>; +}; + +export declare type Plugins = typeof PLUGINS; + +export declare interface PluginServicesOptions { + log: Log; + options: z.infer; + sharedOptions: OptionalZodTypeOf; + workerBindings: Worker_Binding[]; + workerIndex: number; + additionalModules: Worker_Module[]; + tmpPath: string; + workerNames: string[]; + wrappedBindingNames: WrappedBindingNames; + durableObjectClassNames: DurableObjectClassNames; + unsafeEphemeralDurableObjects: boolean; + queueConsumers: QueueConsumers; +} + +export declare function prefixError(prefix: string, e: any): Error; + +export declare function prefixStream(prefix: Uint8Array, stream: ReadableStream_2): ReadableStream_2; + +export declare const ProxyAddresses: { + readonly GLOBAL: 0; + readonly ENV: 1; + readonly USER_START: 2; +}; + +export declare class ProxyClient { + #private; + constructor(runtimeEntryURL: URL, dispatchFetch: DispatchFetch); + get global(): ServiceWorkerGlobalScope; + get env(): Record; + poisonProxies(): void; + setRuntimeEntryURL(runtimeEntryURL: URL): void; + dispose(): Promise; +} + +export declare const ProxyOps: { + readonly GET: "GET"; + readonly GET_OWN_DESCRIPTOR: "GET_OWN_DESCRIPTOR"; + readonly GET_OWN_KEYS: "GET_OWN_KEYS"; + readonly CALL: "CALL"; + readonly FREE: "FREE"; +}; + +export declare const QueueBindings: { + readonly SERVICE_WORKER_PREFIX: "MINIFLARE_WORKER_"; + readonly MAYBE_JSON_QUEUE_CONSUMERS: "MINIFLARE_QUEUE_CONSUMERS"; +}; + +export declare type QueueConsumer = z.infer; + +export declare const QueueConsumerOptionsSchema: z.ZodObject<{ + maxBatchSize: z.ZodOptional; + maxBatchTimeout: z.ZodOptional; + maxRetires: z.ZodOptional; + deadLetterQueue: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; +}, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; +}>; + +export declare type QueueConsumers = Map>; + +export declare const QueueConsumerSchema: z.ZodIntersection; + maxBatchTimeout: z.ZodOptional; + maxRetires: z.ZodOptional; + deadLetterQueue: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; +}, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; +}>, z.ZodObject<{ + workerName: z.ZodString; +}, "strip", z.ZodTypeAny, { + workerName: string; +}, { + workerName: string; +}>>; + +export declare const QueueConsumersSchema: z.ZodRecord; + maxBatchTimeout: z.ZodOptional; + maxRetires: z.ZodOptional; + deadLetterQueue: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; +}, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; +}>, z.ZodObject<{ + workerName: z.ZodString; +}, "strip", z.ZodTypeAny, { + workerName: string; +}, { + workerName: string; +}>>>; + +export declare type QueueContentType = z.infer; + +export declare const QueueContentTypeSchema: z.ZodDefault>; + +export declare type QueueIncomingMessage = z.infer; + +export declare const QueueIncomingMessageSchema: z.ZodObject<{ + contentType: z.ZodDefault>; + body: z.ZodEffects; + id: z.ZodOptional; + timestamp: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + body: Buffer; + contentType: "text" | "json" | "bytes" | "v8"; + id?: string | undefined; + timestamp?: number | undefined; +}, { + body: string; + contentType?: "text" | "json" | "bytes" | "v8" | undefined; + id?: string | undefined; + timestamp?: number | undefined; +}>; + +export declare type QueueOutgoingMessage = z.input; + +export declare const QUEUES_PLUGIN: Plugin; + +export declare const QUEUES_PLUGIN_NAME = "queues"; + +export declare const QueuesBatchRequestSchema: z.ZodObject<{ + messages: z.ZodArray>; + body: z.ZodEffects; + id: z.ZodOptional; + timestamp: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + body: Buffer; + contentType: "text" | "json" | "bytes" | "v8"; + id?: string | undefined; + timestamp?: number | undefined; + }, { + body: string; + contentType?: "text" | "json" | "bytes" | "v8" | undefined; + id?: string | undefined; + timestamp?: number | undefined; + }>, "many">; +}, "strip", z.ZodTypeAny, { + messages: { + body: Buffer; + contentType: "text" | "json" | "bytes" | "v8"; + id?: string | undefined; + timestamp?: number | undefined; + }[]; +}, { + messages: { + body: string; + contentType?: "text" | "json" | "bytes" | "v8" | undefined; + id?: string | undefined; + timestamp?: number | undefined; + }[]; +}>; + +export declare class QueuesError extends MiniflareError { +} + +export declare type QueuesErrorCode = "ERR_MULTIPLE_CONSUMERS" | "ERR_DEAD_LETTER_QUEUE_CYCLE"; + +export declare const QueuesOptionsSchema: z.ZodObject<{ + queueProducers: z.ZodOptional, z.ZodArray]>>; + queueConsumers: z.ZodOptional; + maxBatchTimeout: z.ZodOptional; + maxRetires: z.ZodOptional; + deadLetterQueue: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; + }, { + maxBatchSize?: number | undefined; + maxBatchTimeout?: number | undefined; + maxRetires?: number | undefined; + deadLetterQueue?: string | undefined; + }>>, z.ZodArray]>>; +}, "strip", z.ZodTypeAny, { + queueProducers?: string[] | Record | undefined; + queueConsumers?: string[] | Record | undefined; +}, { + queueProducers?: string[] | Record | undefined; + queueConsumers?: string[] | Record | undefined; +}>; + +export declare type QueuesOutgoingBatchRequest = z.input; + +export declare const R2_PLUGIN: Plugin; + +export declare const R2_PLUGIN_NAME = "r2"; + +export declare const R2OptionsSchema: z.ZodObject<{ + r2Buckets: z.ZodOptional, z.ZodArray]>>; +}, "strip", z.ZodTypeAny, { + r2Buckets?: string[] | Record | undefined; +}, { + r2Buckets?: string[] | Record | undefined; +}>; + +export declare const R2SharedOptionsSchema: z.ZodObject<{ + r2Persist: z.ZodOptional>; +}, "strip", z.ZodTypeAny, { + r2Persist?: string | boolean | undefined; +}, { + r2Persist?: string | boolean | undefined; +}>; + +export declare function readPrefix(stream: ReadableStream_2, prefixLength: number): Promise<[prefix: Buffer, rest: ReadableStream_2]>; + +export declare function reduceError(e: any): JsonError; + +export declare type ReducerReviver = (value: unknown) => unknown; + +export declare type ReducersRevivers = Record; + +export { ReferrerPolicy } + +export declare function registerAllowUnauthorizedDispatcher(dispatcher: Dispatcher): void; + +export declare type ReplaceWorkersTypes = T extends Request_3 ? Request : T extends Response_3 ? Response : T extends ReadableStream ? ReadableStream_2 : Required extends Required ? RequestInit : T extends Headers_2 ? Headers : T extends Blob_2 ? Blob_3 : T extends AbortSignal_2 ? AbortSignal : T extends Promise ? Promise> : T extends (...args: infer P) => infer R ? (...args: ReplaceWorkersTypes

) => ReplaceWorkersTypes : T extends object ? { + [K in keyof T]: OverloadReplaceWorkersTypes; +} : T; + +export declare class Request extends Request_2 { + [kCf]?: CfType; + constructor(input: RequestInfo, init?: RequestInit); + get cf(): CfType | undefined; + /** @ts-expect-error `clone` is actually defined as a method internally */ + clone(): Request; +} + +export { RequestCache } + +export { RequestCredentials } + +export { RequestDestination } + +export { RequestDuplex } + +export declare type RequestInfo = RequestInfo_2 | Request; + +export declare interface RequestInit extends RequestInit_2 { + cf?: CfType; +} + +export declare type RequestInitCfType = Partial | RequestInitCfProperties; + +export { RequestMode } + +export { RequestRedirect } + +export declare class Response extends Response_2 { + readonly [kWebSocket]: WebSocket | null; + static error(): Response; + static redirect(url: string | URL, status: ResponseRedirectStatus): Response; + static json(data: any, init?: ResponseInit): Response; + constructor(body?: BodyInit, init?: ResponseInit); + /** @ts-expect-error `status` is actually defined as a getter internally */ + get status(): number; + get webSocket(): WebSocket | null; + /** @ts-expect-error `clone` is actually defined as a method internally */ + clone(): Response; +} + +export declare interface ResponseInit extends ResponseInit_2 { + webSocket?: WebSocket | null; +} + +export { ResponseRedirectStatus } + +export { ResponseType } + +export declare class RouterError extends MiniflareError { +} + +export declare type RouterErrorCode = "ERR_QUERY_STRING" | "ERR_INFIX_WILDCARD"; + +export declare class Runtime { + #private; + updateConfig(configBuffer: Buffer, options: Abortable & RuntimeOptions): Promise; + dispose(): Awaitable; +} + +export declare interface RuntimeOptions { + entryAddress: string; + loopbackPort: number; + requiredSockets: SocketIdentifier[]; + inspectorAddress?: string; + verbose?: boolean; + handleRuntimeStdio?: (stdout: Readable, stderr: Readable) => void; +} + +export declare function sanitisePath(unsafe: string): string; + +export declare interface SerialisableMatcherRegExps { + include: string[]; + exclude: string[]; +} + +export declare interface SerialisableSiteMatcherRegExps { + include?: SerialisableMatcherRegExps; + exclude?: SerialisableMatcherRegExps; +} + +export declare function serialiseRegExps(matcher: MatcherRegExps): SerialisableMatcherRegExps; + +export declare function serialiseSiteRegExps(siteRegExps: SiteMatcherRegExps): SerialisableSiteMatcherRegExps; + +export declare function serializeConfig(config: Config): Buffer; + +export declare type Service = { + name?: string; +} & ({ + worker?: Worker; +} | { + network?: Network; +} | { + external?: ExternalServer; +} | { + disk?: DiskDirectory; +}); + +export declare const SERVICE_ENTRY: string; + +export declare const SERVICE_LOOPBACK = "loopback"; + +export declare interface ServiceDesignator { + name?: string; + entrypoint?: string; +} + +export declare interface ServicesExtensions { + services: Service[]; + extensions: Extension[]; +} + +export declare const SharedBindings: { + readonly TEXT_NAMESPACE: "MINIFLARE_NAMESPACE"; + readonly DURABLE_OBJECT_NAMESPACE_OBJECT: "MINIFLARE_OBJECT"; + readonly MAYBE_SERVICE_BLOBS: "MINIFLARE_BLOBS"; + readonly MAYBE_SERVICE_LOOPBACK: "MINIFLARE_LOOPBACK"; + readonly MAYBE_JSON_ENABLE_CONTROL_ENDPOINTS: "MINIFLARE_ENABLE_CONTROL_ENDPOINTS"; +}; + +export declare const SharedHeaders: { + readonly LOG_LEVEL: "MF-Log-Level"; +}; + +export declare type SharedOptions = z.infer & z.infer & z.infer & z.infer & z.infer & z.infer; + +export declare const SiteBindings: { + readonly KV_NAMESPACE_SITE: "__STATIC_CONTENT"; + readonly JSON_SITE_MANIFEST: "__STATIC_CONTENT_MANIFEST"; + readonly JSON_SITE_FILTER: "MINIFLARE_SITE_FILTER"; +}; + +export declare interface SiteMatcherRegExps { + include?: MatcherRegExps; + exclude?: MatcherRegExps; +} + +export declare const SITES_NO_CACHE_PREFIX = "$__MINIFLARE_SITES__$/"; + +export declare type Socket = { + name?: string; + address?: string; + service?: ServiceDesignator; +} & ({ + http?: HttpOptions; +} | { + https?: Socket_Https; +}); + +export declare const SOCKET_ENTRY = "entry"; + +export declare interface Socket_Https { + options?: HttpOptions; + tlsOptions?: TlsOptions; +} + +export declare type SocketIdentifier = string | typeof kInspectorSocket; + +export declare type SocketPorts = Map; + +export declare type SourceOptions = z.infer; + +export declare const SourceOptionsSchema: z.ZodUnion<[z.ZodObject<{ + modules: z.ZodArray; + path: z.ZodString; + contents: z.ZodOptional]>>; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }>, "many">; + modulesRoot: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; +}, { + modules: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + path: string; + contents?: string | Uint8Array | undefined; + }[]; + modulesRoot?: string | undefined; +}>, z.ZodObject<{ + script: z.ZodString; + scriptPath: z.ZodOptional; + modules: z.ZodOptional; + modulesRules: z.ZodOptional; + include: z.ZodArray; + fallthrough: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }>, "many">>; + modulesRoot: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}, { + script: string; + scriptPath?: string | undefined; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}>, z.ZodObject<{ + scriptPath: z.ZodString; + modules: z.ZodOptional; + modulesRules: z.ZodOptional; + include: z.ZodArray; + fallthrough: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }, { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }>, "many">>; + modulesRoot: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}, { + scriptPath: string; + modules?: boolean | undefined; + modulesRules?: { + type: "ESModule" | "CommonJS" | "NodeJsCompatModule" | "Text" | "Data" | "CompiledWasm"; + include: string[]; + fallthrough?: boolean | undefined; + }[] | undefined; + modulesRoot?: string | undefined; +}>]>; + +export declare interface StringifiedWithStream { + value: string; + unbufferedStream?: RS; +} + +export declare function stringifyWithStreams(impl: PlatformImpl, value: unknown, reducers: ReducersRevivers, allowUnbufferedStream: boolean): StringifiedWithStream | Promise>; + +export declare function stripAnsi(value: string): string; + +export declare const structuredSerializableReducers: ReducersRevivers; + +export declare const structuredSerializableRevivers: ReducersRevivers; + +export { supportedCompatibilityDate } + +export declare function testRegExps(matcher: MatcherRegExps, value: string): boolean; + +export declare function testSiteRegExps(regExps: SiteMatcherRegExps, key: string): boolean; + +export declare interface TlsOptions { + keypair?: TlsOptions_Keypair; + requireClientCerts?: boolean; + trustBrowserCas?: boolean; + trustedCertificates?: string[]; + minVersion?: TlsOptions_Version; + cipherList?: string; +} + +export declare interface TlsOptions_Keypair { + privateKey?: string; + certificateChain?: string; +} + +export declare enum TlsOptions_Version { + GOOD_DEFAULT = 0, + SSL3 = 1, + TLS1DOT0 = 2, + TLS1DOT1 = 3, + TLS1DOT2 = 4, + TLS1DOT3 = 5, +} + +export declare function _transformsForContentEncoding(encoding?: string): Transform[]; + +export declare type TypedEventListener = ((e: E) => void) | { + handleEvent(e: E): void; +}; + +export declare class TypedEventTarget> extends EventTarget { + addEventListener(type: Type, listener: TypedEventListener | null, options?: AddEventListenerOptions | boolean): void; + removeEventListener(type: Type, listener: TypedEventListener | null, options?: EventListenerOptions | boolean): void; + dispatchEvent(event: ValueOf): boolean; +} + +export declare type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; + +export declare type ValueOf = T[keyof T]; + +export declare function viewToBuffer(view: ArrayBufferView): ArrayBuffer; + +export declare type Void = typeof kVoid; + +export declare class WaitGroup { + private counter; + private resolveQueue; + add(): void; + done(): void; + wait(): Promise; +} + +export declare class WebSocket extends TypedEventTarget { + #private; + static readonly READY_STATE_CONNECTING = 0; + static readonly READY_STATE_OPEN = 1; + static readonly READY_STATE_CLOSING = 2; + static readonly READY_STATE_CLOSED = 3; + [kPair]?: WebSocket; + [kAccepted]: boolean; + [kCoupled]: boolean; + [kClosedOutgoing]: boolean; + [kClosedIncoming]: boolean; + get readyState(): number; + accept(): void; + send(message: ArrayBuffer | string): void; + [kSend](message: ArrayBuffer | string): void; + close(code?: number, reason?: string): void; + [kClose](code?: number, reason?: string): void; + [kError](error?: Error): void; +} + +export declare type WebSocketEventMap = { + message: MessageEvent; + close: CloseEvent; + error: ErrorEvent; +}; + +export declare type WebSocketPair = { + 0: WebSocket; + 1: WebSocket; +}; + +export declare const WebSocketPair: new () => WebSocketPair; + +export declare type Worker = ({ + modules?: Worker_Module[]; +} | { + serviceWorkerScript?: string; +} | { + inherit?: string; +}) & { + compatibilityDate?: string; + compatibilityFlags?: string[]; + bindings?: Worker_Binding[]; + globalOutbound?: ServiceDesignator; + cacheApiOutbound?: ServiceDesignator; + durableObjectNamespaces?: Worker_DurableObjectNamespace[]; + durableObjectUniqueKeyModifier?: string; + durableObjectStorage?: Worker_DurableObjectStorage; +}; + +export declare type Worker_Binding = { + name?: string; +} & ({ + parameter?: Worker_Binding_Parameter; +} | { + text?: string; +} | { + data?: Uint8Array; +} | { + json?: string; +} | { + wasmModule?: Uint8Array; +} | { + cryptoKey?: Worker_Binding_CryptoKey; +} | { + service?: ServiceDesignator; +} | { + durableObjectNamespace?: Worker_Binding_DurableObjectNamespaceDesignator; +} | { + kvNamespace?: ServiceDesignator; +} | { + r2Bucket?: ServiceDesignator; +} | { + r2Admin?: ServiceDesignator; +} | { + wrapped?: Worker_Binding_WrappedBinding; +} | { + queue?: ServiceDesignator; +} | { + fromEnvironment?: string; +} | { + analyticsEngine?: ServiceDesignator; +} | { + hyperdrive?: Worker_Binding_Hyperdrive; +} | { + unsafeEval?: Void; +}); + +export declare type Worker_Binding_CryptoKey = ({ + raw?: Uint8Array; +} | { + hex?: string; +} | { + base64?: string; +} | { + pkcs8?: string; +} | { + spki?: string; +} | { + jwk?: string; +}) & { + algorithm?: Worker_Binding_CryptoKey_Algorithm; + extractable?: boolean; + usages?: Worker_Binding_CryptoKey_Usage[]; +}; + +export declare type Worker_Binding_CryptoKey_Algorithm = { + name?: string; +} | { + json?: string; +}; + +export declare enum Worker_Binding_CryptoKey_Usage { + ENCRYPT = 0, + DECRYPT = 1, + SIGN = 2, + VERIFY = 3, + DERIVE_KEY = 4, + DERIVE_BITS = 5, + WRAP_KEY = 6, + UNWRAP_KEY = 7, +} + +export declare type Worker_Binding_DurableObjectNamespaceDesignator = { + className?: string; + serviceName?: string; +}; + +export declare interface Worker_Binding_Hyperdrive { + designator?: ServiceDesignator; + database?: string; + user?: string; + password?: string; + scheme?: string; +} + +export declare interface Worker_Binding_Parameter { + type?: Worker_Binding_Type; + optional?: boolean; +} + +export declare const WORKER_BINDING_SERVICE_LOOPBACK: Worker_Binding; + +export declare type Worker_Binding_Type = { + text?: Void; +} | { + data?: Void; +} | { + json?: Void; +} | { + wasm?: Void; +} | { + cryptoKey?: Worker_Binding_CryptoKey_Usage[]; +} | { + service?: Void; +} | { + durableObjectNamespace: Void; +} | { + kvNamespace?: Void; +} | { + r2Bucket?: Void; +} | { + r2Admin?: Void; +} | { + queue?: Void; +} | { + analyticsEngine?: Void; +} | { + hyperdrive?: Void; +}; + +export declare interface Worker_Binding_WrappedBinding { + moduleName?: string; + entrypoint?: string; + innerBindings?: Worker_Binding[]; +} + +export declare type Worker_DurableObjectNamespace = { + className?: string; + preventEviction?: boolean; +} & ({ + uniqueKey?: string; +} | { + ephemeralLocal?: Void; +}); + +export declare type Worker_DurableObjectStorage = { + none?: Void; +} | { + inMemory?: Void; +} | { + localDisk?: string; +}; + +export declare type Worker_Module = { + name: string; +} & ({ + esModule?: string; +} | { + commonJsModule?: string; +} | { + text?: string; +} | { + data?: Uint8Array; +} | { + wasm?: Uint8Array; +} | { + json?: string; +} | { + nodeJsCompatModule?: string; +}); + +export declare type WorkerOptions = z.infer & z.infer & z.infer & z.infer & z.infer & z.infer & z.infer & z.input; + +export declare interface WorkerRoute { + target: string; + route: string; + specificity: number; + protocol?: string; + allowHostnamePrefix: boolean; + hostname: string; + path: string; + allowPathSuffix: boolean; +} + +export declare type WrappedBindingNames = Set; + +export declare function zAwaitable(type: T): z.ZodUnion<[T, z.ZodPromise]>; + +export { } diff --git a/node_modules/miniflare/dist/src/index.js b/node_modules/miniflare/dist/src/index.js new file mode 100644 index 0000000000000000000000000000000000000000..349cda47c64c69a1002e75ab178a2b05a1dffd29 --- /dev/null +++ b/node_modules/miniflare/dist/src/index.js @@ -0,0 +1,9363 @@ +"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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +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 +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +var __publicField = (obj, key, value) => { + __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); + return value; +}; +var __accessCheck = (obj, member, msg) => { + if (!member.has(obj)) + throw TypeError("Cannot " + msg); +}; +var __privateGet = (obj, member, getter) => { + __accessCheck(obj, member, "read from private field"); + return getter ? getter.call(obj) : member.get(obj); +}; +var __privateAdd = (obj, member, value) => { + if (member.has(obj)) + throw TypeError("Cannot add the same private member more than once"); + member instanceof WeakSet ? member.add(obj) : member.set(obj, value); +}; +var __privateSet = (obj, member, value, setter) => { + __accessCheck(obj, member, "write to private field"); + setter ? setter.call(obj, value) : member.set(obj, value); + return value; +}; +var __privateMethod = (obj, member, method) => { + __accessCheck(obj, member, "access private method"); + return method; +}; + +// src/runtime/config/workerd.capnp.js +var require_workerd_capnp = __commonJS({ + "src/runtime/config/workerd.capnp.js"(exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Extension = exports.Extension_Module = exports.TlsOptions = exports.TlsOptions_Version = exports.TlsOptions_Keypair = exports.HttpOptions = exports.HttpOptions_Header = exports.HttpOptions_Style = exports.DiskDirectory = exports.Network = exports.ExternalServer = exports.ExternalServer_Which = exports.ExternalServer_Tcp = exports.ExternalServer_Https = exports.Worker = exports.Worker_Which = exports.Worker_DurableObjectStorage = exports.Worker_DurableObjectStorage_Which = exports.Worker_DurableObjectNamespace = exports.Worker_DurableObjectNamespace_Which = exports.Worker_Binding = exports.Worker_Binding_Which = exports.Worker_Binding_Hyperdrive = exports.Worker_Binding_Parameter = exports.Worker_Binding_WrappedBinding = exports.Worker_Binding_CryptoKey = exports.Worker_Binding_CryptoKey_Which = exports.Worker_Binding_CryptoKey_Algorithm = exports.Worker_Binding_CryptoKey_Algorithm_Which = exports.Worker_Binding_CryptoKey_Usage = exports.Worker_Binding_DurableObjectNamespaceDesignator = exports.Worker_Binding_Type = exports.Worker_Binding_Type_Which = exports.Worker_Module = exports.Worker_Module_Which = exports.ServiceDesignator = exports.Service = exports.Service_Which = exports.Socket = exports.Socket_Which = exports.Socket_Https = exports.Config = exports._capnpFileId = void 0; + var capnp = require("capnp-ts"); + var capnp_ts_1 = require("capnp-ts"); + exports._capnpFileId = "e6afd26682091c01"; + var Config3 = class extends capnp_ts_1.Struct { + adoptServices(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(0, this)); + } + disownServices() { + return capnp_ts_1.Struct.disown(this.getServices()); + } + getServices() { + return capnp_ts_1.Struct.getList(0, Config3._Services, this); + } + hasServices() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(0, this)); + } + initServices(length) { + return capnp_ts_1.Struct.initList(0, Config3._Services, length, this); + } + setServices(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(0, this)); + } + adoptSockets(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownSockets() { + return capnp_ts_1.Struct.disown(this.getSockets()); + } + getSockets() { + return capnp_ts_1.Struct.getList(1, Config3._Sockets, this); + } + hasSockets() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initSockets(length) { + return capnp_ts_1.Struct.initList(1, Config3._Sockets, length, this); + } + setSockets(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptV8Flags(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownV8Flags() { + return capnp_ts_1.Struct.disown(this.getV8Flags()); + } + getV8Flags() { + return capnp_ts_1.Struct.getList(2, capnp.TextList, this); + } + hasV8Flags() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initV8Flags(length) { + return capnp_ts_1.Struct.initList(2, capnp.TextList, length, this); + } + setV8Flags(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + adoptExtensions(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(3, this)); + } + disownExtensions() { + return capnp_ts_1.Struct.disown(this.getExtensions()); + } + getExtensions() { + return capnp_ts_1.Struct.getList(3, Config3._Extensions, this); + } + hasExtensions() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(3, this)); + } + initExtensions(length) { + return capnp_ts_1.Struct.initList(3, Config3._Extensions, length, this); + } + setExtensions(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(3, this)); + } + toString() { + return "Config_" + super.toString(); + } + }; + exports.Config = Config3; + Config3._capnp = { + displayName: "Config", + id: "8794486c76aaa7d6", + size: new capnp_ts_1.ObjectSize(0, 4) + }; + var Socket_Https = class extends capnp_ts_1.Struct { + adoptOptions(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownOptions() { + return capnp_ts_1.Struct.disown(this.getOptions()); + } + getOptions() { + return capnp_ts_1.Struct.getStruct(2, HttpOptions, this); + } + hasOptions() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initOptions() { + return capnp_ts_1.Struct.initStructAt(2, HttpOptions, this); + } + setOptions(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + adoptTlsOptions(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(3, this)); + } + disownTlsOptions() { + return capnp_ts_1.Struct.disown(this.getTlsOptions()); + } + getTlsOptions() { + return capnp_ts_1.Struct.getStruct(3, TlsOptions, this); + } + hasTlsOptions() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(3, this)); + } + initTlsOptions() { + return capnp_ts_1.Struct.initStructAt(3, TlsOptions, this); + } + setTlsOptions(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(3, this)); + } + toString() { + return "Socket_Https_" + super.toString(); + } + }; + exports.Socket_Https = Socket_Https; + Socket_Https._capnp = { + displayName: "https", + id: "de123876383cbbdc", + size: new capnp_ts_1.ObjectSize(8, 5) + }; + var Socket_Which; + (function(Socket_Which2) { + Socket_Which2[Socket_Which2["HTTP"] = 0] = "HTTP"; + Socket_Which2[Socket_Which2["HTTPS"] = 1] = "HTTPS"; + })(Socket_Which = exports.Socket_Which || (exports.Socket_Which = {})); + var Socket2 = class extends capnp_ts_1.Struct { + getName() { + return capnp_ts_1.Struct.getText(0, this); + } + setName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getAddress() { + return capnp_ts_1.Struct.getText(1, this); + } + setAddress(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + adoptHttp(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownHttp() { + return capnp_ts_1.Struct.disown(this.getHttp()); + } + getHttp() { + capnp_ts_1.Struct.testWhich( + "http", + capnp_ts_1.Struct.getUint16(0, this), + 0, + this + ); + return capnp_ts_1.Struct.getStruct(2, HttpOptions, this); + } + hasHttp() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initHttp() { + capnp_ts_1.Struct.setUint16(0, 0, this); + return capnp_ts_1.Struct.initStructAt(2, HttpOptions, this); + } + isHttp() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setHttp(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + getHttps() { + capnp_ts_1.Struct.testWhich( + "https", + capnp_ts_1.Struct.getUint16(0, this), + 1, + this + ); + return capnp_ts_1.Struct.getAs(Socket_Https, this); + } + initHttps() { + capnp_ts_1.Struct.setUint16(0, 1, this); + return capnp_ts_1.Struct.getAs(Socket_Https, this); + } + isHttps() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setHttps() { + capnp_ts_1.Struct.setUint16(0, 1, this); + } + adoptService(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(4, this)); + } + disownService() { + return capnp_ts_1.Struct.disown(this.getService()); + } + getService() { + return capnp_ts_1.Struct.getStruct(4, ServiceDesignator2, this); + } + hasService() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(4, this)); + } + initService() { + return capnp_ts_1.Struct.initStructAt(4, ServiceDesignator2, this); + } + setService(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(4, this)); + } + toString() { + return "Socket_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.Socket = Socket2; + Socket2.HTTP = Socket_Which.HTTP; + Socket2.HTTPS = Socket_Which.HTTPS; + Socket2._capnp = { + displayName: "Socket", + id: "9a0eba45530ee79f", + size: new capnp_ts_1.ObjectSize(8, 5) + }; + var Service_Which; + (function(Service_Which2) { + Service_Which2[Service_Which2["UNSPECIFIED"] = 0] = "UNSPECIFIED"; + Service_Which2[Service_Which2["WORKER"] = 1] = "WORKER"; + Service_Which2[Service_Which2["NETWORK"] = 2] = "NETWORK"; + Service_Which2[Service_Which2["EXTERNAL"] = 3] = "EXTERNAL"; + Service_Which2[Service_Which2["DISK"] = 4] = "DISK"; + })(Service_Which = exports.Service_Which || (exports.Service_Which = {})); + var Service4 = class extends capnp_ts_1.Struct { + getName() { + return capnp_ts_1.Struct.getText(0, this); + } + setName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + isUnspecified() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setUnspecified() { + capnp_ts_1.Struct.setUint16(0, 0, this); + } + adoptWorker(value) { + capnp_ts_1.Struct.setUint16(0, 1, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownWorker() { + return capnp_ts_1.Struct.disown(this.getWorker()); + } + getWorker() { + capnp_ts_1.Struct.testWhich( + "worker", + capnp_ts_1.Struct.getUint16(0, this), + 1, + this + ); + return capnp_ts_1.Struct.getStruct(1, Worker2, this); + } + hasWorker() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initWorker() { + capnp_ts_1.Struct.setUint16(0, 1, this); + return capnp_ts_1.Struct.initStructAt(1, Worker2, this); + } + isWorker() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setWorker(value) { + capnp_ts_1.Struct.setUint16(0, 1, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptNetwork(value) { + capnp_ts_1.Struct.setUint16(0, 2, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownNetwork() { + return capnp_ts_1.Struct.disown(this.getNetwork()); + } + getNetwork() { + capnp_ts_1.Struct.testWhich( + "network", + capnp_ts_1.Struct.getUint16(0, this), + 2, + this + ); + return capnp_ts_1.Struct.getStruct(1, Network, this); + } + hasNetwork() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initNetwork() { + capnp_ts_1.Struct.setUint16(0, 2, this); + return capnp_ts_1.Struct.initStructAt(1, Network, this); + } + isNetwork() { + return capnp_ts_1.Struct.getUint16(0, this) === 2; + } + setNetwork(value) { + capnp_ts_1.Struct.setUint16(0, 2, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptExternal(value) { + capnp_ts_1.Struct.setUint16(0, 3, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownExternal() { + return capnp_ts_1.Struct.disown(this.getExternal()); + } + getExternal() { + capnp_ts_1.Struct.testWhich( + "external", + capnp_ts_1.Struct.getUint16(0, this), + 3, + this + ); + return capnp_ts_1.Struct.getStruct(1, ExternalServer2, this); + } + hasExternal() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initExternal() { + capnp_ts_1.Struct.setUint16(0, 3, this); + return capnp_ts_1.Struct.initStructAt(1, ExternalServer2, this); + } + isExternal() { + return capnp_ts_1.Struct.getUint16(0, this) === 3; + } + setExternal(value) { + capnp_ts_1.Struct.setUint16(0, 3, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptDisk(value) { + capnp_ts_1.Struct.setUint16(0, 4, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownDisk() { + return capnp_ts_1.Struct.disown(this.getDisk()); + } + getDisk() { + capnp_ts_1.Struct.testWhich( + "disk", + capnp_ts_1.Struct.getUint16(0, this), + 4, + this + ); + return capnp_ts_1.Struct.getStruct(1, DiskDirectory, this); + } + hasDisk() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initDisk() { + capnp_ts_1.Struct.setUint16(0, 4, this); + return capnp_ts_1.Struct.initStructAt(1, DiskDirectory, this); + } + isDisk() { + return capnp_ts_1.Struct.getUint16(0, this) === 4; + } + setDisk(value) { + capnp_ts_1.Struct.setUint16(0, 4, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + toString() { + return "Service_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.Service = Service4; + Service4.UNSPECIFIED = Service_Which.UNSPECIFIED; + Service4.WORKER = Service_Which.WORKER; + Service4.NETWORK = Service_Which.NETWORK; + Service4.EXTERNAL = Service_Which.EXTERNAL; + Service4.DISK = Service_Which.DISK; + Service4._capnp = { + displayName: "Service", + id: "e5c88e8bb7bcb6b9", + size: new capnp_ts_1.ObjectSize(8, 2) + }; + var ServiceDesignator2 = class extends capnp_ts_1.Struct { + getName() { + return capnp_ts_1.Struct.getText(0, this); + } + setName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getEntrypoint() { + return capnp_ts_1.Struct.getText(1, this); + } + setEntrypoint(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + toString() { + return "ServiceDesignator_" + super.toString(); + } + }; + exports.ServiceDesignator = ServiceDesignator2; + ServiceDesignator2._capnp = { + displayName: "ServiceDesignator", + id: "ae8ec91cee724450", + size: new capnp_ts_1.ObjectSize(0, 2) + }; + var Worker_Module_Which; + (function(Worker_Module_Which2) { + Worker_Module_Which2[Worker_Module_Which2["ES_MODULE"] = 0] = "ES_MODULE"; + Worker_Module_Which2[Worker_Module_Which2["COMMON_JS_MODULE"] = 1] = "COMMON_JS_MODULE"; + Worker_Module_Which2[Worker_Module_Which2["TEXT"] = 2] = "TEXT"; + Worker_Module_Which2[Worker_Module_Which2["DATA"] = 3] = "DATA"; + Worker_Module_Which2[Worker_Module_Which2["WASM"] = 4] = "WASM"; + Worker_Module_Which2[Worker_Module_Which2["JSON"] = 5] = "JSON"; + Worker_Module_Which2[Worker_Module_Which2["NODE_JS_COMPAT_MODULE"] = 6] = "NODE_JS_COMPAT_MODULE"; + })( + Worker_Module_Which = exports.Worker_Module_Which || (exports.Worker_Module_Which = {}) + ); + var Worker_Module3 = class extends capnp_ts_1.Struct { + getName() { + return capnp_ts_1.Struct.getText(0, this); + } + setName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getEsModule() { + capnp_ts_1.Struct.testWhich( + "esModule", + capnp_ts_1.Struct.getUint16(0, this), + 0, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isEsModule() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setEsModule(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.setText(1, value, this); + } + getCommonJsModule() { + capnp_ts_1.Struct.testWhich( + "commonJsModule", + capnp_ts_1.Struct.getUint16(0, this), + 1, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isCommonJsModule() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setCommonJsModule(value) { + capnp_ts_1.Struct.setUint16(0, 1, this); + capnp_ts_1.Struct.setText(1, value, this); + } + getText() { + capnp_ts_1.Struct.testWhich( + "text", + capnp_ts_1.Struct.getUint16(0, this), + 2, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isText() { + return capnp_ts_1.Struct.getUint16(0, this) === 2; + } + setText(value) { + capnp_ts_1.Struct.setUint16(0, 2, this); + capnp_ts_1.Struct.setText(1, value, this); + } + adoptData(value) { + capnp_ts_1.Struct.setUint16(0, 3, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownData() { + return capnp_ts_1.Struct.disown(this.getData()); + } + getData() { + capnp_ts_1.Struct.testWhich( + "data", + capnp_ts_1.Struct.getUint16(0, this), + 3, + this + ); + return capnp_ts_1.Struct.getData(1, this); + } + hasData() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initData(length) { + capnp_ts_1.Struct.setUint16(0, 3, this); + return capnp_ts_1.Struct.initData(1, length, this); + } + isData() { + return capnp_ts_1.Struct.getUint16(0, this) === 3; + } + setData(value) { + capnp_ts_1.Struct.setUint16(0, 3, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptWasm(value) { + capnp_ts_1.Struct.setUint16(0, 4, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownWasm() { + return capnp_ts_1.Struct.disown(this.getWasm()); + } + getWasm() { + capnp_ts_1.Struct.testWhich( + "wasm", + capnp_ts_1.Struct.getUint16(0, this), + 4, + this + ); + return capnp_ts_1.Struct.getData(1, this); + } + hasWasm() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initWasm(length) { + capnp_ts_1.Struct.setUint16(0, 4, this); + return capnp_ts_1.Struct.initData(1, length, this); + } + isWasm() { + return capnp_ts_1.Struct.getUint16(0, this) === 4; + } + setWasm(value) { + capnp_ts_1.Struct.setUint16(0, 4, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getJson() { + capnp_ts_1.Struct.testWhich( + "json", + capnp_ts_1.Struct.getUint16(0, this), + 5, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isJson() { + return capnp_ts_1.Struct.getUint16(0, this) === 5; + } + setJson(value) { + capnp_ts_1.Struct.setUint16(0, 5, this); + capnp_ts_1.Struct.setText(1, value, this); + } + getNodeJsCompatModule() { + capnp_ts_1.Struct.testWhich( + "nodeJsCompatModule", + capnp_ts_1.Struct.getUint16(0, this), + 6, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isNodeJsCompatModule() { + return capnp_ts_1.Struct.getUint16(0, this) === 6; + } + setNodeJsCompatModule(value) { + capnp_ts_1.Struct.setUint16(0, 6, this); + capnp_ts_1.Struct.setText(1, value, this); + } + toString() { + return "Worker_Module_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.Worker_Module = Worker_Module3; + Worker_Module3.ES_MODULE = Worker_Module_Which.ES_MODULE; + Worker_Module3.COMMON_JS_MODULE = Worker_Module_Which.COMMON_JS_MODULE; + Worker_Module3.TEXT = Worker_Module_Which.TEXT; + Worker_Module3.DATA = Worker_Module_Which.DATA; + Worker_Module3.WASM = Worker_Module_Which.WASM; + Worker_Module3.JSON = Worker_Module_Which.JSON; + Worker_Module3.NODE_JS_COMPAT_MODULE = Worker_Module_Which.NODE_JS_COMPAT_MODULE; + Worker_Module3._capnp = { + displayName: "Module", + id: "d9d87a63770a12f3", + size: new capnp_ts_1.ObjectSize(8, 2) + }; + var Worker_Binding_Type_Which; + (function(Worker_Binding_Type_Which2) { + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["UNSPECIFIED"] = 0] = "UNSPECIFIED"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["TEXT"] = 1] = "TEXT"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["DATA"] = 2] = "DATA"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["JSON"] = 3] = "JSON"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["WASM"] = 4] = "WASM"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["CRYPTO_KEY"] = 5] = "CRYPTO_KEY"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["SERVICE"] = 6] = "SERVICE"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["DURABLE_OBJECT_NAMESPACE"] = 7] = "DURABLE_OBJECT_NAMESPACE"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["KV_NAMESPACE"] = 8] = "KV_NAMESPACE"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["R2BUCKET"] = 9] = "R2BUCKET"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["R2ADMIN"] = 10] = "R2ADMIN"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["QUEUE"] = 11] = "QUEUE"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["ANALYTICS_ENGINE"] = 12] = "ANALYTICS_ENGINE"; + Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["HYPERDRIVE"] = 13] = "HYPERDRIVE"; + })( + Worker_Binding_Type_Which = exports.Worker_Binding_Type_Which || (exports.Worker_Binding_Type_Which = {}) + ); + var Worker_Binding_Type = class extends capnp_ts_1.Struct { + isUnspecified() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setUnspecified() { + capnp_ts_1.Struct.setUint16(0, 0, this); + } + isText() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setText() { + capnp_ts_1.Struct.setUint16(0, 1, this); + } + isData() { + return capnp_ts_1.Struct.getUint16(0, this) === 2; + } + setData() { + capnp_ts_1.Struct.setUint16(0, 2, this); + } + isJson() { + return capnp_ts_1.Struct.getUint16(0, this) === 3; + } + setJson() { + capnp_ts_1.Struct.setUint16(0, 3, this); + } + isWasm() { + return capnp_ts_1.Struct.getUint16(0, this) === 4; + } + setWasm() { + capnp_ts_1.Struct.setUint16(0, 4, this); + } + adoptCryptoKey(value) { + capnp_ts_1.Struct.setUint16(0, 5, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(0, this)); + } + disownCryptoKey() { + return capnp_ts_1.Struct.disown(this.getCryptoKey()); + } + getCryptoKey() { + capnp_ts_1.Struct.testWhich( + "cryptoKey", + capnp_ts_1.Struct.getUint16(0, this), + 5, + this + ); + return capnp_ts_1.Struct.getList(0, capnp.Uint16List, this); + } + hasCryptoKey() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(0, this)); + } + initCryptoKey(length) { + capnp_ts_1.Struct.setUint16(0, 5, this); + return capnp_ts_1.Struct.initList(0, capnp.Uint16List, length, this); + } + isCryptoKey() { + return capnp_ts_1.Struct.getUint16(0, this) === 5; + } + setCryptoKey(value) { + capnp_ts_1.Struct.setUint16(0, 5, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(0, this)); + } + isService() { + return capnp_ts_1.Struct.getUint16(0, this) === 6; + } + setService() { + capnp_ts_1.Struct.setUint16(0, 6, this); + } + isDurableObjectNamespace() { + return capnp_ts_1.Struct.getUint16(0, this) === 7; + } + setDurableObjectNamespace() { + capnp_ts_1.Struct.setUint16(0, 7, this); + } + isKvNamespace() { + return capnp_ts_1.Struct.getUint16(0, this) === 8; + } + setKvNamespace() { + capnp_ts_1.Struct.setUint16(0, 8, this); + } + isR2Bucket() { + return capnp_ts_1.Struct.getUint16(0, this) === 9; + } + setR2Bucket() { + capnp_ts_1.Struct.setUint16(0, 9, this); + } + isR2Admin() { + return capnp_ts_1.Struct.getUint16(0, this) === 10; + } + setR2Admin() { + capnp_ts_1.Struct.setUint16(0, 10, this); + } + isQueue() { + return capnp_ts_1.Struct.getUint16(0, this) === 11; + } + setQueue() { + capnp_ts_1.Struct.setUint16(0, 11, this); + } + isAnalyticsEngine() { + return capnp_ts_1.Struct.getUint16(0, this) === 12; + } + setAnalyticsEngine() { + capnp_ts_1.Struct.setUint16(0, 12, this); + } + isHyperdrive() { + return capnp_ts_1.Struct.getUint16(0, this) === 13; + } + setHyperdrive() { + capnp_ts_1.Struct.setUint16(0, 13, this); + } + toString() { + return "Worker_Binding_Type_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.Worker_Binding_Type = Worker_Binding_Type; + Worker_Binding_Type.UNSPECIFIED = Worker_Binding_Type_Which.UNSPECIFIED; + Worker_Binding_Type.TEXT = Worker_Binding_Type_Which.TEXT; + Worker_Binding_Type.DATA = Worker_Binding_Type_Which.DATA; + Worker_Binding_Type.JSON = Worker_Binding_Type_Which.JSON; + Worker_Binding_Type.WASM = Worker_Binding_Type_Which.WASM; + Worker_Binding_Type.CRYPTO_KEY = Worker_Binding_Type_Which.CRYPTO_KEY; + Worker_Binding_Type.SERVICE = Worker_Binding_Type_Which.SERVICE; + Worker_Binding_Type.DURABLE_OBJECT_NAMESPACE = Worker_Binding_Type_Which.DURABLE_OBJECT_NAMESPACE; + Worker_Binding_Type.KV_NAMESPACE = Worker_Binding_Type_Which.KV_NAMESPACE; + Worker_Binding_Type.R2BUCKET = Worker_Binding_Type_Which.R2BUCKET; + Worker_Binding_Type.R2ADMIN = Worker_Binding_Type_Which.R2ADMIN; + Worker_Binding_Type.QUEUE = Worker_Binding_Type_Which.QUEUE; + Worker_Binding_Type.ANALYTICS_ENGINE = Worker_Binding_Type_Which.ANALYTICS_ENGINE; + Worker_Binding_Type.HYPERDRIVE = Worker_Binding_Type_Which.HYPERDRIVE; + Worker_Binding_Type._capnp = { + displayName: "Type", + id: "8906a1296519bf8a", + size: new capnp_ts_1.ObjectSize(8, 1) + }; + var Worker_Binding_DurableObjectNamespaceDesignator2 = class extends capnp_ts_1.Struct { + getClassName() { + return capnp_ts_1.Struct.getText(0, this); + } + setClassName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getServiceName() { + return capnp_ts_1.Struct.getText(1, this); + } + setServiceName(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + toString() { + return "Worker_Binding_DurableObjectNamespaceDesignator_" + super.toString(); + } + }; + exports.Worker_Binding_DurableObjectNamespaceDesignator = Worker_Binding_DurableObjectNamespaceDesignator2; + Worker_Binding_DurableObjectNamespaceDesignator2._capnp = { + displayName: "DurableObjectNamespaceDesignator", + id: "804f144ff477aac7", + size: new capnp_ts_1.ObjectSize(0, 2) + }; + var Worker_Binding_CryptoKey_Usage2; + (function(Worker_Binding_CryptoKey_Usage3) { + Worker_Binding_CryptoKey_Usage3[Worker_Binding_CryptoKey_Usage3["ENCRYPT"] = 0] = "ENCRYPT"; + Worker_Binding_CryptoKey_Usage3[Worker_Binding_CryptoKey_Usage3["DECRYPT"] = 1] = "DECRYPT"; + Worker_Binding_CryptoKey_Usage3[Worker_Binding_CryptoKey_Usage3["SIGN"] = 2] = "SIGN"; + Worker_Binding_CryptoKey_Usage3[Worker_Binding_CryptoKey_Usage3["VERIFY"] = 3] = "VERIFY"; + Worker_Binding_CryptoKey_Usage3[Worker_Binding_CryptoKey_Usage3["DERIVE_KEY"] = 4] = "DERIVE_KEY"; + Worker_Binding_CryptoKey_Usage3[Worker_Binding_CryptoKey_Usage3["DERIVE_BITS"] = 5] = "DERIVE_BITS"; + Worker_Binding_CryptoKey_Usage3[Worker_Binding_CryptoKey_Usage3["WRAP_KEY"] = 6] = "WRAP_KEY"; + Worker_Binding_CryptoKey_Usage3[Worker_Binding_CryptoKey_Usage3["UNWRAP_KEY"] = 7] = "UNWRAP_KEY"; + })( + Worker_Binding_CryptoKey_Usage2 = exports.Worker_Binding_CryptoKey_Usage || (exports.Worker_Binding_CryptoKey_Usage = {}) + ); + var Worker_Binding_CryptoKey_Algorithm_Which; + (function(Worker_Binding_CryptoKey_Algorithm_Which2) { + Worker_Binding_CryptoKey_Algorithm_Which2[Worker_Binding_CryptoKey_Algorithm_Which2["NAME"] = 0] = "NAME"; + Worker_Binding_CryptoKey_Algorithm_Which2[Worker_Binding_CryptoKey_Algorithm_Which2["JSON"] = 1] = "JSON"; + })( + Worker_Binding_CryptoKey_Algorithm_Which = exports.Worker_Binding_CryptoKey_Algorithm_Which || (exports.Worker_Binding_CryptoKey_Algorithm_Which = {}) + ); + var Worker_Binding_CryptoKey_Algorithm = class extends capnp_ts_1.Struct { + getName() { + capnp_ts_1.Struct.testWhich( + "name", + capnp_ts_1.Struct.getUint16(2, this), + 0, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isName() { + return capnp_ts_1.Struct.getUint16(2, this) === 0; + } + setName(value) { + capnp_ts_1.Struct.setUint16(2, 0, this); + capnp_ts_1.Struct.setText(1, value, this); + } + getJson() { + capnp_ts_1.Struct.testWhich( + "json", + capnp_ts_1.Struct.getUint16(2, this), + 1, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isJson() { + return capnp_ts_1.Struct.getUint16(2, this) === 1; + } + setJson(value) { + capnp_ts_1.Struct.setUint16(2, 1, this); + capnp_ts_1.Struct.setText(1, value, this); + } + toString() { + return "Worker_Binding_CryptoKey_Algorithm_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(2, this); + } + }; + exports.Worker_Binding_CryptoKey_Algorithm = Worker_Binding_CryptoKey_Algorithm; + Worker_Binding_CryptoKey_Algorithm.NAME = Worker_Binding_CryptoKey_Algorithm_Which.NAME; + Worker_Binding_CryptoKey_Algorithm.JSON = Worker_Binding_CryptoKey_Algorithm_Which.JSON; + Worker_Binding_CryptoKey_Algorithm._capnp = { + displayName: "algorithm", + id: "a1a040c5e00d7021", + size: new capnp_ts_1.ObjectSize(8, 3) + }; + var Worker_Binding_CryptoKey_Which; + (function(Worker_Binding_CryptoKey_Which2) { + Worker_Binding_CryptoKey_Which2[Worker_Binding_CryptoKey_Which2["RAW"] = 0] = "RAW"; + Worker_Binding_CryptoKey_Which2[Worker_Binding_CryptoKey_Which2["HEX"] = 1] = "HEX"; + Worker_Binding_CryptoKey_Which2[Worker_Binding_CryptoKey_Which2["BASE64"] = 2] = "BASE64"; + Worker_Binding_CryptoKey_Which2[Worker_Binding_CryptoKey_Which2["PKCS8"] = 3] = "PKCS8"; + Worker_Binding_CryptoKey_Which2[Worker_Binding_CryptoKey_Which2["SPKI"] = 4] = "SPKI"; + Worker_Binding_CryptoKey_Which2[Worker_Binding_CryptoKey_Which2["JWK"] = 5] = "JWK"; + })( + Worker_Binding_CryptoKey_Which = exports.Worker_Binding_CryptoKey_Which || (exports.Worker_Binding_CryptoKey_Which = {}) + ); + var Worker_Binding_CryptoKey = class extends capnp_ts_1.Struct { + adoptRaw(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(0, this)); + } + disownRaw() { + return capnp_ts_1.Struct.disown(this.getRaw()); + } + getRaw() { + capnp_ts_1.Struct.testWhich( + "raw", + capnp_ts_1.Struct.getUint16(0, this), + 0, + this + ); + return capnp_ts_1.Struct.getData(0, this); + } + hasRaw() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(0, this)); + } + initRaw(length) { + capnp_ts_1.Struct.setUint16(0, 0, this); + return capnp_ts_1.Struct.initData(0, length, this); + } + isRaw() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setRaw(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(0, this)); + } + getHex() { + capnp_ts_1.Struct.testWhich( + "hex", + capnp_ts_1.Struct.getUint16(0, this), + 1, + this + ); + return capnp_ts_1.Struct.getText(0, this); + } + isHex() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setHex(value) { + capnp_ts_1.Struct.setUint16(0, 1, this); + capnp_ts_1.Struct.setText(0, value, this); + } + getBase64() { + capnp_ts_1.Struct.testWhich( + "base64", + capnp_ts_1.Struct.getUint16(0, this), + 2, + this + ); + return capnp_ts_1.Struct.getText(0, this); + } + isBase64() { + return capnp_ts_1.Struct.getUint16(0, this) === 2; + } + setBase64(value) { + capnp_ts_1.Struct.setUint16(0, 2, this); + capnp_ts_1.Struct.setText(0, value, this); + } + getPkcs8() { + capnp_ts_1.Struct.testWhich( + "pkcs8", + capnp_ts_1.Struct.getUint16(0, this), + 3, + this + ); + return capnp_ts_1.Struct.getText(0, this); + } + isPkcs8() { + return capnp_ts_1.Struct.getUint16(0, this) === 3; + } + setPkcs8(value) { + capnp_ts_1.Struct.setUint16(0, 3, this); + capnp_ts_1.Struct.setText(0, value, this); + } + getSpki() { + capnp_ts_1.Struct.testWhich( + "spki", + capnp_ts_1.Struct.getUint16(0, this), + 4, + this + ); + return capnp_ts_1.Struct.getText(0, this); + } + isSpki() { + return capnp_ts_1.Struct.getUint16(0, this) === 4; + } + setSpki(value) { + capnp_ts_1.Struct.setUint16(0, 4, this); + capnp_ts_1.Struct.setText(0, value, this); + } + getJwk() { + capnp_ts_1.Struct.testWhich( + "jwk", + capnp_ts_1.Struct.getUint16(0, this), + 5, + this + ); + return capnp_ts_1.Struct.getText(0, this); + } + isJwk() { + return capnp_ts_1.Struct.getUint16(0, this) === 5; + } + setJwk(value) { + capnp_ts_1.Struct.setUint16(0, 5, this); + capnp_ts_1.Struct.setText(0, value, this); + } + getAlgorithm() { + return capnp_ts_1.Struct.getAs(Worker_Binding_CryptoKey_Algorithm, this); + } + initAlgorithm() { + return capnp_ts_1.Struct.getAs(Worker_Binding_CryptoKey_Algorithm, this); + } + getExtractable() { + return capnp_ts_1.Struct.getBit( + 32, + this, + Worker_Binding_CryptoKey._capnp.defaultExtractable + ); + } + setExtractable(value) { + capnp_ts_1.Struct.setBit(32, value, this); + } + adoptUsages(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownUsages() { + return capnp_ts_1.Struct.disown(this.getUsages()); + } + getUsages() { + return capnp_ts_1.Struct.getList(2, capnp.Uint16List, this); + } + hasUsages() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initUsages(length) { + return capnp_ts_1.Struct.initList(2, capnp.Uint16List, length, this); + } + setUsages(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + toString() { + return "Worker_Binding_CryptoKey_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.Worker_Binding_CryptoKey = Worker_Binding_CryptoKey; + Worker_Binding_CryptoKey.RAW = Worker_Binding_CryptoKey_Which.RAW; + Worker_Binding_CryptoKey.HEX = Worker_Binding_CryptoKey_Which.HEX; + Worker_Binding_CryptoKey.BASE64 = Worker_Binding_CryptoKey_Which.BASE64; + Worker_Binding_CryptoKey.PKCS8 = Worker_Binding_CryptoKey_Which.PKCS8; + Worker_Binding_CryptoKey.SPKI = Worker_Binding_CryptoKey_Which.SPKI; + Worker_Binding_CryptoKey.JWK = Worker_Binding_CryptoKey_Which.JWK; + Worker_Binding_CryptoKey.Usage = Worker_Binding_CryptoKey_Usage2; + Worker_Binding_CryptoKey._capnp = { + displayName: "CryptoKey", + id: "b5e1bff0e57d6eb0", + size: new capnp_ts_1.ObjectSize(8, 3), + defaultExtractable: capnp.getBitMask(false, 0) + }; + var Worker_Binding_WrappedBinding = class extends capnp_ts_1.Struct { + getModuleName() { + return capnp_ts_1.Struct.getText(0, this); + } + setModuleName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getEntrypoint() { + return capnp_ts_1.Struct.getText( + 1, + this, + Worker_Binding_WrappedBinding._capnp.defaultEntrypoint + ); + } + setEntrypoint(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + adoptInnerBindings(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownInnerBindings() { + return capnp_ts_1.Struct.disown(this.getInnerBindings()); + } + getInnerBindings() { + return capnp_ts_1.Struct.getList( + 2, + Worker_Binding_WrappedBinding._InnerBindings, + this + ); + } + hasInnerBindings() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initInnerBindings(length) { + return capnp_ts_1.Struct.initList( + 2, + Worker_Binding_WrappedBinding._InnerBindings, + length, + this + ); + } + setInnerBindings(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + toString() { + return "Worker_Binding_WrappedBinding_" + super.toString(); + } + }; + exports.Worker_Binding_WrappedBinding = Worker_Binding_WrappedBinding; + Worker_Binding_WrappedBinding._capnp = { + displayName: "WrappedBinding", + id: "e6f066b75f0ea113", + size: new capnp_ts_1.ObjectSize(0, 3), + defaultEntrypoint: "default" + }; + var Worker_Binding_Parameter = class extends capnp_ts_1.Struct { + adoptType(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownType() { + return capnp_ts_1.Struct.disown(this.getType()); + } + getType() { + return capnp_ts_1.Struct.getStruct(1, Worker_Binding_Type, this); + } + hasType() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initType() { + return capnp_ts_1.Struct.initStructAt(1, Worker_Binding_Type, this); + } + setType(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getOptional() { + return capnp_ts_1.Struct.getBit(16, this); + } + setOptional(value) { + capnp_ts_1.Struct.setBit(16, value, this); + } + toString() { + return "Worker_Binding_Parameter_" + super.toString(); + } + }; + exports.Worker_Binding_Parameter = Worker_Binding_Parameter; + Worker_Binding_Parameter._capnp = { + displayName: "parameter", + id: "dc57e1258d26d152", + size: new capnp_ts_1.ObjectSize(8, 6) + }; + var Worker_Binding_Hyperdrive = class extends capnp_ts_1.Struct { + adoptDesignator(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownDesignator() { + return capnp_ts_1.Struct.disown(this.getDesignator()); + } + getDesignator() { + return capnp_ts_1.Struct.getStruct(1, ServiceDesignator2, this); + } + hasDesignator() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initDesignator() { + return capnp_ts_1.Struct.initStructAt(1, ServiceDesignator2, this); + } + setDesignator(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getDatabase() { + return capnp_ts_1.Struct.getText(2, this); + } + setDatabase(value) { + capnp_ts_1.Struct.setText(2, value, this); + } + getUser() { + return capnp_ts_1.Struct.getText(3, this); + } + setUser(value) { + capnp_ts_1.Struct.setText(3, value, this); + } + getPassword() { + return capnp_ts_1.Struct.getText(4, this); + } + setPassword(value) { + capnp_ts_1.Struct.setText(4, value, this); + } + getScheme() { + return capnp_ts_1.Struct.getText(5, this); + } + setScheme(value) { + capnp_ts_1.Struct.setText(5, value, this); + } + toString() { + return "Worker_Binding_Hyperdrive_" + super.toString(); + } + }; + exports.Worker_Binding_Hyperdrive = Worker_Binding_Hyperdrive; + Worker_Binding_Hyperdrive._capnp = { + displayName: "hyperdrive", + id: "ad6c391cd55f3134", + size: new capnp_ts_1.ObjectSize(8, 6) + }; + var Worker_Binding_Which; + (function(Worker_Binding_Which2) { + Worker_Binding_Which2[Worker_Binding_Which2["UNSPECIFIED"] = 0] = "UNSPECIFIED"; + Worker_Binding_Which2[Worker_Binding_Which2["PARAMETER"] = 1] = "PARAMETER"; + Worker_Binding_Which2[Worker_Binding_Which2["TEXT"] = 2] = "TEXT"; + Worker_Binding_Which2[Worker_Binding_Which2["DATA"] = 3] = "DATA"; + Worker_Binding_Which2[Worker_Binding_Which2["JSON"] = 4] = "JSON"; + Worker_Binding_Which2[Worker_Binding_Which2["WASM_MODULE"] = 5] = "WASM_MODULE"; + Worker_Binding_Which2[Worker_Binding_Which2["CRYPTO_KEY"] = 6] = "CRYPTO_KEY"; + Worker_Binding_Which2[Worker_Binding_Which2["SERVICE"] = 7] = "SERVICE"; + Worker_Binding_Which2[Worker_Binding_Which2["DURABLE_OBJECT_NAMESPACE"] = 8] = "DURABLE_OBJECT_NAMESPACE"; + Worker_Binding_Which2[Worker_Binding_Which2["KV_NAMESPACE"] = 9] = "KV_NAMESPACE"; + Worker_Binding_Which2[Worker_Binding_Which2["R2BUCKET"] = 10] = "R2BUCKET"; + Worker_Binding_Which2[Worker_Binding_Which2["R2ADMIN"] = 11] = "R2ADMIN"; + Worker_Binding_Which2[Worker_Binding_Which2["WRAPPED"] = 12] = "WRAPPED"; + Worker_Binding_Which2[Worker_Binding_Which2["QUEUE"] = 13] = "QUEUE"; + Worker_Binding_Which2[Worker_Binding_Which2["FROM_ENVIRONMENT"] = 14] = "FROM_ENVIRONMENT"; + Worker_Binding_Which2[Worker_Binding_Which2["ANALYTICS_ENGINE"] = 15] = "ANALYTICS_ENGINE"; + Worker_Binding_Which2[Worker_Binding_Which2["HYPERDRIVE"] = 16] = "HYPERDRIVE"; + Worker_Binding_Which2[Worker_Binding_Which2["UNSAFE_EVAL"] = 17] = "UNSAFE_EVAL"; + })( + Worker_Binding_Which = exports.Worker_Binding_Which || (exports.Worker_Binding_Which = {}) + ); + var Worker_Binding4 = class extends capnp_ts_1.Struct { + getName() { + return capnp_ts_1.Struct.getText(0, this); + } + setName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + isUnspecified() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setUnspecified() { + capnp_ts_1.Struct.setUint16(0, 0, this); + } + getParameter() { + capnp_ts_1.Struct.testWhich( + "parameter", + capnp_ts_1.Struct.getUint16(0, this), + 1, + this + ); + return capnp_ts_1.Struct.getAs(Worker_Binding_Parameter, this); + } + initParameter() { + capnp_ts_1.Struct.setUint16(0, 1, this); + return capnp_ts_1.Struct.getAs(Worker_Binding_Parameter, this); + } + isParameter() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setParameter() { + capnp_ts_1.Struct.setUint16(0, 1, this); + } + getText() { + capnp_ts_1.Struct.testWhich( + "text", + capnp_ts_1.Struct.getUint16(0, this), + 2, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isText() { + return capnp_ts_1.Struct.getUint16(0, this) === 2; + } + setText(value) { + capnp_ts_1.Struct.setUint16(0, 2, this); + capnp_ts_1.Struct.setText(1, value, this); + } + adoptData(value) { + capnp_ts_1.Struct.setUint16(0, 3, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownData() { + return capnp_ts_1.Struct.disown(this.getData()); + } + getData() { + capnp_ts_1.Struct.testWhich( + "data", + capnp_ts_1.Struct.getUint16(0, this), + 3, + this + ); + return capnp_ts_1.Struct.getData(1, this); + } + hasData() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initData(length) { + capnp_ts_1.Struct.setUint16(0, 3, this); + return capnp_ts_1.Struct.initData(1, length, this); + } + isData() { + return capnp_ts_1.Struct.getUint16(0, this) === 3; + } + setData(value) { + capnp_ts_1.Struct.setUint16(0, 3, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getJson() { + capnp_ts_1.Struct.testWhich( + "json", + capnp_ts_1.Struct.getUint16(0, this), + 4, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isJson() { + return capnp_ts_1.Struct.getUint16(0, this) === 4; + } + setJson(value) { + capnp_ts_1.Struct.setUint16(0, 4, this); + capnp_ts_1.Struct.setText(1, value, this); + } + adoptWasmModule(value) { + capnp_ts_1.Struct.setUint16(0, 5, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownWasmModule() { + return capnp_ts_1.Struct.disown(this.getWasmModule()); + } + getWasmModule() { + capnp_ts_1.Struct.testWhich( + "wasmModule", + capnp_ts_1.Struct.getUint16(0, this), + 5, + this + ); + return capnp_ts_1.Struct.getData(1, this); + } + hasWasmModule() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initWasmModule(length) { + capnp_ts_1.Struct.setUint16(0, 5, this); + return capnp_ts_1.Struct.initData(1, length, this); + } + isWasmModule() { + return capnp_ts_1.Struct.getUint16(0, this) === 5; + } + setWasmModule(value) { + capnp_ts_1.Struct.setUint16(0, 5, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptCryptoKey(value) { + capnp_ts_1.Struct.setUint16(0, 6, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownCryptoKey() { + return capnp_ts_1.Struct.disown(this.getCryptoKey()); + } + getCryptoKey() { + capnp_ts_1.Struct.testWhich( + "cryptoKey", + capnp_ts_1.Struct.getUint16(0, this), + 6, + this + ); + return capnp_ts_1.Struct.getStruct(1, Worker_Binding_CryptoKey, this); + } + hasCryptoKey() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initCryptoKey() { + capnp_ts_1.Struct.setUint16(0, 6, this); + return capnp_ts_1.Struct.initStructAt(1, Worker_Binding_CryptoKey, this); + } + isCryptoKey() { + return capnp_ts_1.Struct.getUint16(0, this) === 6; + } + setCryptoKey(value) { + capnp_ts_1.Struct.setUint16(0, 6, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptService(value) { + capnp_ts_1.Struct.setUint16(0, 7, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownService() { + return capnp_ts_1.Struct.disown(this.getService()); + } + getService() { + capnp_ts_1.Struct.testWhich( + "service", + capnp_ts_1.Struct.getUint16(0, this), + 7, + this + ); + return capnp_ts_1.Struct.getStruct(1, ServiceDesignator2, this); + } + hasService() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initService() { + capnp_ts_1.Struct.setUint16(0, 7, this); + return capnp_ts_1.Struct.initStructAt(1, ServiceDesignator2, this); + } + isService() { + return capnp_ts_1.Struct.getUint16(0, this) === 7; + } + setService(value) { + capnp_ts_1.Struct.setUint16(0, 7, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptDurableObjectNamespace(value) { + capnp_ts_1.Struct.setUint16(0, 8, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownDurableObjectNamespace() { + return capnp_ts_1.Struct.disown(this.getDurableObjectNamespace()); + } + getDurableObjectNamespace() { + capnp_ts_1.Struct.testWhich( + "durableObjectNamespace", + capnp_ts_1.Struct.getUint16(0, this), + 8, + this + ); + return capnp_ts_1.Struct.getStruct( + 1, + Worker_Binding_DurableObjectNamespaceDesignator2, + this + ); + } + hasDurableObjectNamespace() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initDurableObjectNamespace() { + capnp_ts_1.Struct.setUint16(0, 8, this); + return capnp_ts_1.Struct.initStructAt( + 1, + Worker_Binding_DurableObjectNamespaceDesignator2, + this + ); + } + isDurableObjectNamespace() { + return capnp_ts_1.Struct.getUint16(0, this) === 8; + } + setDurableObjectNamespace(value) { + capnp_ts_1.Struct.setUint16(0, 8, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptKvNamespace(value) { + capnp_ts_1.Struct.setUint16(0, 9, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownKvNamespace() { + return capnp_ts_1.Struct.disown(this.getKvNamespace()); + } + getKvNamespace() { + capnp_ts_1.Struct.testWhich( + "kvNamespace", + capnp_ts_1.Struct.getUint16(0, this), + 9, + this + ); + return capnp_ts_1.Struct.getStruct(1, ServiceDesignator2, this); + } + hasKvNamespace() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initKvNamespace() { + capnp_ts_1.Struct.setUint16(0, 9, this); + return capnp_ts_1.Struct.initStructAt(1, ServiceDesignator2, this); + } + isKvNamespace() { + return capnp_ts_1.Struct.getUint16(0, this) === 9; + } + setKvNamespace(value) { + capnp_ts_1.Struct.setUint16(0, 9, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptR2Bucket(value) { + capnp_ts_1.Struct.setUint16(0, 10, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownR2Bucket() { + return capnp_ts_1.Struct.disown(this.getR2Bucket()); + } + getR2Bucket() { + capnp_ts_1.Struct.testWhich( + "r2Bucket", + capnp_ts_1.Struct.getUint16(0, this), + 10, + this + ); + return capnp_ts_1.Struct.getStruct(1, ServiceDesignator2, this); + } + hasR2Bucket() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initR2Bucket() { + capnp_ts_1.Struct.setUint16(0, 10, this); + return capnp_ts_1.Struct.initStructAt(1, ServiceDesignator2, this); + } + isR2Bucket() { + return capnp_ts_1.Struct.getUint16(0, this) === 10; + } + setR2Bucket(value) { + capnp_ts_1.Struct.setUint16(0, 10, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptR2Admin(value) { + capnp_ts_1.Struct.setUint16(0, 11, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownR2Admin() { + return capnp_ts_1.Struct.disown(this.getR2Admin()); + } + getR2Admin() { + capnp_ts_1.Struct.testWhich( + "r2Admin", + capnp_ts_1.Struct.getUint16(0, this), + 11, + this + ); + return capnp_ts_1.Struct.getStruct(1, ServiceDesignator2, this); + } + hasR2Admin() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initR2Admin() { + capnp_ts_1.Struct.setUint16(0, 11, this); + return capnp_ts_1.Struct.initStructAt(1, ServiceDesignator2, this); + } + isR2Admin() { + return capnp_ts_1.Struct.getUint16(0, this) === 11; + } + setR2Admin(value) { + capnp_ts_1.Struct.setUint16(0, 11, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptWrapped(value) { + capnp_ts_1.Struct.setUint16(0, 12, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownWrapped() { + return capnp_ts_1.Struct.disown(this.getWrapped()); + } + getWrapped() { + capnp_ts_1.Struct.testWhich( + "wrapped", + capnp_ts_1.Struct.getUint16(0, this), + 12, + this + ); + return capnp_ts_1.Struct.getStruct(1, Worker_Binding_WrappedBinding, this); + } + hasWrapped() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initWrapped() { + capnp_ts_1.Struct.setUint16(0, 12, this); + return capnp_ts_1.Struct.initStructAt( + 1, + Worker_Binding_WrappedBinding, + this + ); + } + isWrapped() { + return capnp_ts_1.Struct.getUint16(0, this) === 12; + } + setWrapped(value) { + capnp_ts_1.Struct.setUint16(0, 12, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptQueue(value) { + capnp_ts_1.Struct.setUint16(0, 13, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownQueue() { + return capnp_ts_1.Struct.disown(this.getQueue()); + } + getQueue() { + capnp_ts_1.Struct.testWhich( + "queue", + capnp_ts_1.Struct.getUint16(0, this), + 13, + this + ); + return capnp_ts_1.Struct.getStruct(1, ServiceDesignator2, this); + } + hasQueue() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initQueue() { + capnp_ts_1.Struct.setUint16(0, 13, this); + return capnp_ts_1.Struct.initStructAt(1, ServiceDesignator2, this); + } + isQueue() { + return capnp_ts_1.Struct.getUint16(0, this) === 13; + } + setQueue(value) { + capnp_ts_1.Struct.setUint16(0, 13, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getFromEnvironment() { + capnp_ts_1.Struct.testWhich( + "fromEnvironment", + capnp_ts_1.Struct.getUint16(0, this), + 14, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isFromEnvironment() { + return capnp_ts_1.Struct.getUint16(0, this) === 14; + } + setFromEnvironment(value) { + capnp_ts_1.Struct.setUint16(0, 14, this); + capnp_ts_1.Struct.setText(1, value, this); + } + adoptAnalyticsEngine(value) { + capnp_ts_1.Struct.setUint16(0, 15, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownAnalyticsEngine() { + return capnp_ts_1.Struct.disown(this.getAnalyticsEngine()); + } + getAnalyticsEngine() { + capnp_ts_1.Struct.testWhich( + "analyticsEngine", + capnp_ts_1.Struct.getUint16(0, this), + 15, + this + ); + return capnp_ts_1.Struct.getStruct(1, ServiceDesignator2, this); + } + hasAnalyticsEngine() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initAnalyticsEngine() { + capnp_ts_1.Struct.setUint16(0, 15, this); + return capnp_ts_1.Struct.initStructAt(1, ServiceDesignator2, this); + } + isAnalyticsEngine() { + return capnp_ts_1.Struct.getUint16(0, this) === 15; + } + setAnalyticsEngine(value) { + capnp_ts_1.Struct.setUint16(0, 15, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getHyperdrive() { + capnp_ts_1.Struct.testWhich( + "hyperdrive", + capnp_ts_1.Struct.getUint16(0, this), + 16, + this + ); + return capnp_ts_1.Struct.getAs(Worker_Binding_Hyperdrive, this); + } + initHyperdrive() { + capnp_ts_1.Struct.setUint16(0, 16, this); + return capnp_ts_1.Struct.getAs(Worker_Binding_Hyperdrive, this); + } + isHyperdrive() { + return capnp_ts_1.Struct.getUint16(0, this) === 16; + } + setHyperdrive() { + capnp_ts_1.Struct.setUint16(0, 16, this); + } + isUnsafeEval() { + return capnp_ts_1.Struct.getUint16(0, this) === 17; + } + setUnsafeEval() { + capnp_ts_1.Struct.setUint16(0, 17, this); + } + toString() { + return "Worker_Binding_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.Worker_Binding = Worker_Binding4; + Worker_Binding4.UNSPECIFIED = Worker_Binding_Which.UNSPECIFIED; + Worker_Binding4.PARAMETER = Worker_Binding_Which.PARAMETER; + Worker_Binding4.TEXT = Worker_Binding_Which.TEXT; + Worker_Binding4.DATA = Worker_Binding_Which.DATA; + Worker_Binding4.JSON = Worker_Binding_Which.JSON; + Worker_Binding4.WASM_MODULE = Worker_Binding_Which.WASM_MODULE; + Worker_Binding4.CRYPTO_KEY = Worker_Binding_Which.CRYPTO_KEY; + Worker_Binding4.SERVICE = Worker_Binding_Which.SERVICE; + Worker_Binding4.DURABLE_OBJECT_NAMESPACE = Worker_Binding_Which.DURABLE_OBJECT_NAMESPACE; + Worker_Binding4.KV_NAMESPACE = Worker_Binding_Which.KV_NAMESPACE; + Worker_Binding4.R2BUCKET = Worker_Binding_Which.R2BUCKET; + Worker_Binding4.R2ADMIN = Worker_Binding_Which.R2ADMIN; + Worker_Binding4.WRAPPED = Worker_Binding_Which.WRAPPED; + Worker_Binding4.QUEUE = Worker_Binding_Which.QUEUE; + Worker_Binding4.FROM_ENVIRONMENT = Worker_Binding_Which.FROM_ENVIRONMENT; + Worker_Binding4.ANALYTICS_ENGINE = Worker_Binding_Which.ANALYTICS_ENGINE; + Worker_Binding4.HYPERDRIVE = Worker_Binding_Which.HYPERDRIVE; + Worker_Binding4.UNSAFE_EVAL = Worker_Binding_Which.UNSAFE_EVAL; + Worker_Binding4.Type = Worker_Binding_Type; + Worker_Binding4.DurableObjectNamespaceDesignator = Worker_Binding_DurableObjectNamespaceDesignator2; + Worker_Binding4.CryptoKey = Worker_Binding_CryptoKey; + Worker_Binding4.WrappedBinding = Worker_Binding_WrappedBinding; + Worker_Binding4._capnp = { + displayName: "Binding", + id: "8e7e492fd7e35f3e", + size: new capnp_ts_1.ObjectSize(8, 6) + }; + var Worker_DurableObjectNamespace_Which; + (function(Worker_DurableObjectNamespace_Which2) { + Worker_DurableObjectNamespace_Which2[Worker_DurableObjectNamespace_Which2["UNIQUE_KEY"] = 0] = "UNIQUE_KEY"; + Worker_DurableObjectNamespace_Which2[Worker_DurableObjectNamespace_Which2["EPHEMERAL_LOCAL"] = 1] = "EPHEMERAL_LOCAL"; + })( + Worker_DurableObjectNamespace_Which = exports.Worker_DurableObjectNamespace_Which || (exports.Worker_DurableObjectNamespace_Which = {}) + ); + var Worker_DurableObjectNamespace = class extends capnp_ts_1.Struct { + getClassName() { + return capnp_ts_1.Struct.getText(0, this); + } + setClassName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getUniqueKey() { + capnp_ts_1.Struct.testWhich( + "uniqueKey", + capnp_ts_1.Struct.getUint16(0, this), + 0, + this + ); + return capnp_ts_1.Struct.getText(1, this); + } + isUniqueKey() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setUniqueKey(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.setText(1, value, this); + } + isEphemeralLocal() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setEphemeralLocal() { + capnp_ts_1.Struct.setUint16(0, 1, this); + } + getPreventEviction() { + return capnp_ts_1.Struct.getBit(16, this); + } + setPreventEviction(value) { + capnp_ts_1.Struct.setBit(16, value, this); + } + toString() { + return "Worker_DurableObjectNamespace_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.Worker_DurableObjectNamespace = Worker_DurableObjectNamespace; + Worker_DurableObjectNamespace.UNIQUE_KEY = Worker_DurableObjectNamespace_Which.UNIQUE_KEY; + Worker_DurableObjectNamespace.EPHEMERAL_LOCAL = Worker_DurableObjectNamespace_Which.EPHEMERAL_LOCAL; + Worker_DurableObjectNamespace._capnp = { + displayName: "DurableObjectNamespace", + id: "b429dd547d15747d", + size: new capnp_ts_1.ObjectSize(8, 2) + }; + var Worker_DurableObjectStorage_Which; + (function(Worker_DurableObjectStorage_Which2) { + Worker_DurableObjectStorage_Which2[Worker_DurableObjectStorage_Which2["NONE"] = 0] = "NONE"; + Worker_DurableObjectStorage_Which2[Worker_DurableObjectStorage_Which2["IN_MEMORY"] = 1] = "IN_MEMORY"; + Worker_DurableObjectStorage_Which2[Worker_DurableObjectStorage_Which2["LOCAL_DISK"] = 2] = "LOCAL_DISK"; + })( + Worker_DurableObjectStorage_Which = exports.Worker_DurableObjectStorage_Which || (exports.Worker_DurableObjectStorage_Which = {}) + ); + var Worker_DurableObjectStorage = class extends capnp_ts_1.Struct { + isNone() { + return capnp_ts_1.Struct.getUint16(2, this) === 0; + } + setNone() { + capnp_ts_1.Struct.setUint16(2, 0, this); + } + isInMemory() { + return capnp_ts_1.Struct.getUint16(2, this) === 1; + } + setInMemory() { + capnp_ts_1.Struct.setUint16(2, 1, this); + } + getLocalDisk() { + capnp_ts_1.Struct.testWhich( + "localDisk", + capnp_ts_1.Struct.getUint16(2, this), + 2, + this + ); + return capnp_ts_1.Struct.getText(8, this); + } + isLocalDisk() { + return capnp_ts_1.Struct.getUint16(2, this) === 2; + } + setLocalDisk(value) { + capnp_ts_1.Struct.setUint16(2, 2, this); + capnp_ts_1.Struct.setText(8, value, this); + } + toString() { + return "Worker_DurableObjectStorage_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(2, this); + } + }; + exports.Worker_DurableObjectStorage = Worker_DurableObjectStorage; + Worker_DurableObjectStorage.NONE = Worker_DurableObjectStorage_Which.NONE; + Worker_DurableObjectStorage.IN_MEMORY = Worker_DurableObjectStorage_Which.IN_MEMORY; + Worker_DurableObjectStorage.LOCAL_DISK = Worker_DurableObjectStorage_Which.LOCAL_DISK; + Worker_DurableObjectStorage._capnp = { + displayName: "durableObjectStorage", + id: "cc72b3faa57827d4", + size: new capnp_ts_1.ObjectSize(8, 9) + }; + var Worker_Which; + (function(Worker_Which2) { + Worker_Which2[Worker_Which2["MODULES"] = 0] = "MODULES"; + Worker_Which2[Worker_Which2["SERVICE_WORKER_SCRIPT"] = 1] = "SERVICE_WORKER_SCRIPT"; + Worker_Which2[Worker_Which2["INHERIT"] = 2] = "INHERIT"; + })(Worker_Which = exports.Worker_Which || (exports.Worker_Which = {})); + var Worker2 = class extends capnp_ts_1.Struct { + adoptModules(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(0, this)); + } + disownModules() { + return capnp_ts_1.Struct.disown(this.getModules()); + } + getModules() { + capnp_ts_1.Struct.testWhich( + "modules", + capnp_ts_1.Struct.getUint16(0, this), + 0, + this + ); + return capnp_ts_1.Struct.getList(0, Worker2._Modules, this); + } + hasModules() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(0, this)); + } + initModules(length) { + capnp_ts_1.Struct.setUint16(0, 0, this); + return capnp_ts_1.Struct.initList(0, Worker2._Modules, length, this); + } + isModules() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setModules(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(0, this)); + } + getServiceWorkerScript() { + capnp_ts_1.Struct.testWhich( + "serviceWorkerScript", + capnp_ts_1.Struct.getUint16(0, this), + 1, + this + ); + return capnp_ts_1.Struct.getText(0, this); + } + isServiceWorkerScript() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setServiceWorkerScript(value) { + capnp_ts_1.Struct.setUint16(0, 1, this); + capnp_ts_1.Struct.setText(0, value, this); + } + getInherit() { + capnp_ts_1.Struct.testWhich( + "inherit", + capnp_ts_1.Struct.getUint16(0, this), + 2, + this + ); + return capnp_ts_1.Struct.getText(0, this); + } + isInherit() { + return capnp_ts_1.Struct.getUint16(0, this) === 2; + } + setInherit(value) { + capnp_ts_1.Struct.setUint16(0, 2, this); + capnp_ts_1.Struct.setText(0, value, this); + } + getCompatibilityDate() { + return capnp_ts_1.Struct.getText(1, this); + } + setCompatibilityDate(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + adoptCompatibilityFlags(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownCompatibilityFlags() { + return capnp_ts_1.Struct.disown(this.getCompatibilityFlags()); + } + getCompatibilityFlags() { + return capnp_ts_1.Struct.getList(2, capnp.TextList, this); + } + hasCompatibilityFlags() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initCompatibilityFlags(length) { + return capnp_ts_1.Struct.initList(2, capnp.TextList, length, this); + } + setCompatibilityFlags(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + adoptBindings(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(3, this)); + } + disownBindings() { + return capnp_ts_1.Struct.disown(this.getBindings()); + } + getBindings() { + return capnp_ts_1.Struct.getList(3, Worker2._Bindings, this); + } + hasBindings() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(3, this)); + } + initBindings(length) { + return capnp_ts_1.Struct.initList(3, Worker2._Bindings, length, this); + } + setBindings(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(3, this)); + } + adoptGlobalOutbound(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(4, this)); + } + disownGlobalOutbound() { + return capnp_ts_1.Struct.disown(this.getGlobalOutbound()); + } + getGlobalOutbound() { + return capnp_ts_1.Struct.getStruct( + 4, + ServiceDesignator2, + this, + Worker2._capnp.defaultGlobalOutbound + ); + } + hasGlobalOutbound() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(4, this)); + } + initGlobalOutbound() { + return capnp_ts_1.Struct.initStructAt(4, ServiceDesignator2, this); + } + setGlobalOutbound(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(4, this)); + } + adoptCacheApiOutbound(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(7, this)); + } + disownCacheApiOutbound() { + return capnp_ts_1.Struct.disown(this.getCacheApiOutbound()); + } + getCacheApiOutbound() { + return capnp_ts_1.Struct.getStruct(7, ServiceDesignator2, this); + } + hasCacheApiOutbound() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(7, this)); + } + initCacheApiOutbound() { + return capnp_ts_1.Struct.initStructAt(7, ServiceDesignator2, this); + } + setCacheApiOutbound(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(7, this)); + } + adoptDurableObjectNamespaces(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(5, this)); + } + disownDurableObjectNamespaces() { + return capnp_ts_1.Struct.disown(this.getDurableObjectNamespaces()); + } + getDurableObjectNamespaces() { + return capnp_ts_1.Struct.getList(5, Worker2._DurableObjectNamespaces, this); + } + hasDurableObjectNamespaces() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(5, this)); + } + initDurableObjectNamespaces(length) { + return capnp_ts_1.Struct.initList( + 5, + Worker2._DurableObjectNamespaces, + length, + this + ); + } + setDurableObjectNamespaces(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(5, this)); + } + getDurableObjectUniqueKeyModifier() { + return capnp_ts_1.Struct.getText(6, this); + } + setDurableObjectUniqueKeyModifier(value) { + capnp_ts_1.Struct.setText(6, value, this); + } + getDurableObjectStorage() { + return capnp_ts_1.Struct.getAs(Worker_DurableObjectStorage, this); + } + initDurableObjectStorage() { + return capnp_ts_1.Struct.getAs(Worker_DurableObjectStorage, this); + } + toString() { + return "Worker_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.Worker = Worker2; + Worker2.MODULES = Worker_Which.MODULES; + Worker2.SERVICE_WORKER_SCRIPT = Worker_Which.SERVICE_WORKER_SCRIPT; + Worker2.INHERIT = Worker_Which.INHERIT; + Worker2.Module = Worker_Module3; + Worker2.Binding = Worker_Binding4; + Worker2.DurableObjectNamespace = Worker_DurableObjectNamespace; + Worker2._capnp = { + displayName: "Worker", + id: "acfa77e88fd97d1c", + size: new capnp_ts_1.ObjectSize(8, 9), + defaultGlobalOutbound: capnp.readRawPointer( + new Uint8Array([ + 16, + 5, + 64, + 2, + 17, + 5, + 74, + 0, + 0, + 255, + 105, + 110, + 116, + 101, + 114, + 110, + 101, + 116, + 0, + 0, + 0 + ]).buffer + ) + }; + var ExternalServer_Https = class extends capnp_ts_1.Struct { + adoptOptions(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownOptions() { + return capnp_ts_1.Struct.disown(this.getOptions()); + } + getOptions() { + return capnp_ts_1.Struct.getStruct(1, HttpOptions, this); + } + hasOptions() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initOptions() { + return capnp_ts_1.Struct.initStructAt(1, HttpOptions, this); + } + setOptions(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptTlsOptions(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownTlsOptions() { + return capnp_ts_1.Struct.disown(this.getTlsOptions()); + } + getTlsOptions() { + return capnp_ts_1.Struct.getStruct(2, TlsOptions, this); + } + hasTlsOptions() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initTlsOptions() { + return capnp_ts_1.Struct.initStructAt(2, TlsOptions, this); + } + setTlsOptions(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + getCertificateHost() { + return capnp_ts_1.Struct.getText(3, this); + } + setCertificateHost(value) { + capnp_ts_1.Struct.setText(3, value, this); + } + toString() { + return "ExternalServer_Https_" + super.toString(); + } + }; + exports.ExternalServer_Https = ExternalServer_Https; + ExternalServer_Https._capnp = { + displayName: "https", + id: "ac37e02afd3dc6db", + size: new capnp_ts_1.ObjectSize(8, 4) + }; + var ExternalServer_Tcp = class extends capnp_ts_1.Struct { + adoptTlsOptions(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownTlsOptions() { + return capnp_ts_1.Struct.disown(this.getTlsOptions()); + } + getTlsOptions() { + return capnp_ts_1.Struct.getStruct(1, TlsOptions, this); + } + hasTlsOptions() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initTlsOptions() { + return capnp_ts_1.Struct.initStructAt(1, TlsOptions, this); + } + setTlsOptions(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getCertificateHost() { + return capnp_ts_1.Struct.getText(2, this); + } + setCertificateHost(value) { + capnp_ts_1.Struct.setText(2, value, this); + } + toString() { + return "ExternalServer_Tcp_" + super.toString(); + } + }; + exports.ExternalServer_Tcp = ExternalServer_Tcp; + ExternalServer_Tcp._capnp = { + displayName: "tcp", + id: "d941637df0fb39f1", + size: new capnp_ts_1.ObjectSize(8, 4) + }; + var ExternalServer_Which; + (function(ExternalServer_Which2) { + ExternalServer_Which2[ExternalServer_Which2["HTTP"] = 0] = "HTTP"; + ExternalServer_Which2[ExternalServer_Which2["HTTPS"] = 1] = "HTTPS"; + ExternalServer_Which2[ExternalServer_Which2["TCP"] = 2] = "TCP"; + })( + ExternalServer_Which = exports.ExternalServer_Which || (exports.ExternalServer_Which = {}) + ); + var ExternalServer2 = class extends capnp_ts_1.Struct { + getAddress() { + return capnp_ts_1.Struct.getText(0, this); + } + setAddress(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + adoptHttp(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownHttp() { + return capnp_ts_1.Struct.disown(this.getHttp()); + } + getHttp() { + capnp_ts_1.Struct.testWhich( + "http", + capnp_ts_1.Struct.getUint16(0, this), + 0, + this + ); + return capnp_ts_1.Struct.getStruct(1, HttpOptions, this); + } + hasHttp() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initHttp() { + capnp_ts_1.Struct.setUint16(0, 0, this); + return capnp_ts_1.Struct.initStructAt(1, HttpOptions, this); + } + isHttp() { + return capnp_ts_1.Struct.getUint16(0, this) === 0; + } + setHttp(value) { + capnp_ts_1.Struct.setUint16(0, 0, this); + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getHttps() { + capnp_ts_1.Struct.testWhich( + "https", + capnp_ts_1.Struct.getUint16(0, this), + 1, + this + ); + return capnp_ts_1.Struct.getAs(ExternalServer_Https, this); + } + initHttps() { + capnp_ts_1.Struct.setUint16(0, 1, this); + return capnp_ts_1.Struct.getAs(ExternalServer_Https, this); + } + isHttps() { + return capnp_ts_1.Struct.getUint16(0, this) === 1; + } + setHttps() { + capnp_ts_1.Struct.setUint16(0, 1, this); + } + getTcp() { + capnp_ts_1.Struct.testWhich( + "tcp", + capnp_ts_1.Struct.getUint16(0, this), + 2, + this + ); + return capnp_ts_1.Struct.getAs(ExternalServer_Tcp, this); + } + initTcp() { + capnp_ts_1.Struct.setUint16(0, 2, this); + return capnp_ts_1.Struct.getAs(ExternalServer_Tcp, this); + } + isTcp() { + return capnp_ts_1.Struct.getUint16(0, this) === 2; + } + setTcp() { + capnp_ts_1.Struct.setUint16(0, 2, this); + } + toString() { + return "ExternalServer_" + super.toString(); + } + which() { + return capnp_ts_1.Struct.getUint16(0, this); + } + }; + exports.ExternalServer = ExternalServer2; + ExternalServer2.HTTP = ExternalServer_Which.HTTP; + ExternalServer2.HTTPS = ExternalServer_Which.HTTPS; + ExternalServer2.TCP = ExternalServer_Which.TCP; + ExternalServer2._capnp = { + displayName: "ExternalServer", + id: "ff209f9aa352f5a4", + size: new capnp_ts_1.ObjectSize(8, 4) + }; + var Network = class extends capnp_ts_1.Struct { + adoptAllow(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(0, this)); + } + disownAllow() { + return capnp_ts_1.Struct.disown(this.getAllow()); + } + getAllow() { + return capnp_ts_1.Struct.getList( + 0, + capnp.TextList, + this, + Network._capnp.defaultAllow + ); + } + hasAllow() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(0, this)); + } + initAllow(length) { + return capnp_ts_1.Struct.initList(0, capnp.TextList, length, this); + } + setAllow(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(0, this)); + } + adoptDeny(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownDeny() { + return capnp_ts_1.Struct.disown(this.getDeny()); + } + getDeny() { + return capnp_ts_1.Struct.getList(1, capnp.TextList, this); + } + hasDeny() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initDeny(length) { + return capnp_ts_1.Struct.initList(1, capnp.TextList, length, this); + } + setDeny(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + adoptTlsOptions(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownTlsOptions() { + return capnp_ts_1.Struct.disown(this.getTlsOptions()); + } + getTlsOptions() { + return capnp_ts_1.Struct.getStruct(2, TlsOptions, this); + } + hasTlsOptions() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initTlsOptions() { + return capnp_ts_1.Struct.initStructAt(2, TlsOptions, this); + } + setTlsOptions(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + toString() { + return "Network_" + super.toString(); + } + }; + exports.Network = Network; + Network._capnp = { + displayName: "Network", + id: "fa42244f950c9b9c", + size: new capnp_ts_1.ObjectSize(0, 3), + defaultAllow: capnp.readRawPointer( + new Uint8Array([ + 16, + 3, + 17, + 1, + 14, + 17, + 1, + 58, + 63, + 112, + 117, + 98, + 108, + 105, + 99 + ]).buffer + ) + }; + var DiskDirectory = class extends capnp_ts_1.Struct { + getPath() { + return capnp_ts_1.Struct.getText(0, this); + } + setPath(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getWritable() { + return capnp_ts_1.Struct.getBit( + 0, + this, + DiskDirectory._capnp.defaultWritable + ); + } + setWritable(value) { + capnp_ts_1.Struct.setBit(0, value, this); + } + getAllowDotfiles() { + return capnp_ts_1.Struct.getBit( + 1, + this, + DiskDirectory._capnp.defaultAllowDotfiles + ); + } + setAllowDotfiles(value) { + capnp_ts_1.Struct.setBit(1, value, this); + } + toString() { + return "DiskDirectory_" + super.toString(); + } + }; + exports.DiskDirectory = DiskDirectory; + DiskDirectory._capnp = { + displayName: "DiskDirectory", + id: "9048ab22835f51c3", + size: new capnp_ts_1.ObjectSize(8, 1), + defaultWritable: capnp.getBitMask(false, 0), + defaultAllowDotfiles: capnp.getBitMask(false, 1) + }; + var HttpOptions_Style2; + (function(HttpOptions_Style3) { + HttpOptions_Style3[HttpOptions_Style3["HOST"] = 0] = "HOST"; + HttpOptions_Style3[HttpOptions_Style3["PROXY"] = 1] = "PROXY"; + })( + HttpOptions_Style2 = exports.HttpOptions_Style || (exports.HttpOptions_Style = {}) + ); + var HttpOptions_Header = class extends capnp_ts_1.Struct { + getName() { + return capnp_ts_1.Struct.getText(0, this); + } + setName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getValue() { + return capnp_ts_1.Struct.getText(1, this); + } + setValue(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + toString() { + return "HttpOptions_Header_" + super.toString(); + } + }; + exports.HttpOptions_Header = HttpOptions_Header; + HttpOptions_Header._capnp = { + displayName: "Header", + id: "dc0394b5a6f3417e", + size: new capnp_ts_1.ObjectSize(0, 2) + }; + var HttpOptions = class extends capnp_ts_1.Struct { + getStyle() { + return capnp_ts_1.Struct.getUint16( + 0, + this, + HttpOptions._capnp.defaultStyle + ); + } + setStyle(value) { + capnp_ts_1.Struct.setUint16(0, value, this); + } + getForwardedProtoHeader() { + return capnp_ts_1.Struct.getText(0, this); + } + setForwardedProtoHeader(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getCfBlobHeader() { + return capnp_ts_1.Struct.getText(1, this); + } + setCfBlobHeader(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + adoptInjectRequestHeaders(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this)); + } + disownInjectRequestHeaders() { + return capnp_ts_1.Struct.disown(this.getInjectRequestHeaders()); + } + getInjectRequestHeaders() { + return capnp_ts_1.Struct.getList( + 2, + HttpOptions._InjectRequestHeaders, + this + ); + } + hasInjectRequestHeaders() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this)); + } + initInjectRequestHeaders(length) { + return capnp_ts_1.Struct.initList( + 2, + HttpOptions._InjectRequestHeaders, + length, + this + ); + } + setInjectRequestHeaders(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this)); + } + adoptInjectResponseHeaders(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(3, this)); + } + disownInjectResponseHeaders() { + return capnp_ts_1.Struct.disown(this.getInjectResponseHeaders()); + } + getInjectResponseHeaders() { + return capnp_ts_1.Struct.getList( + 3, + HttpOptions._InjectResponseHeaders, + this + ); + } + hasInjectResponseHeaders() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(3, this)); + } + initInjectResponseHeaders(length) { + return capnp_ts_1.Struct.initList( + 3, + HttpOptions._InjectResponseHeaders, + length, + this + ); + } + setInjectResponseHeaders(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(3, this)); + } + toString() { + return "HttpOptions_" + super.toString(); + } + }; + exports.HttpOptions = HttpOptions; + HttpOptions.Style = HttpOptions_Style2; + HttpOptions.Header = HttpOptions_Header; + HttpOptions._capnp = { + displayName: "HttpOptions", + id: "aa8dc6885da78f19", + size: new capnp_ts_1.ObjectSize(8, 4), + defaultStyle: capnp.getUint16Mask(0) + }; + var TlsOptions_Keypair = class extends capnp_ts_1.Struct { + getPrivateKey() { + return capnp_ts_1.Struct.getText(0, this); + } + setPrivateKey(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getCertificateChain() { + return capnp_ts_1.Struct.getText(1, this); + } + setCertificateChain(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + toString() { + return "TlsOptions_Keypair_" + super.toString(); + } + }; + exports.TlsOptions_Keypair = TlsOptions_Keypair; + TlsOptions_Keypair._capnp = { + displayName: "Keypair", + id: "f546bf2d5d8bd13e", + size: new capnp_ts_1.ObjectSize(0, 2) + }; + var TlsOptions_Version2; + (function(TlsOptions_Version3) { + TlsOptions_Version3[TlsOptions_Version3["GOOD_DEFAULT"] = 0] = "GOOD_DEFAULT"; + TlsOptions_Version3[TlsOptions_Version3["SSL3"] = 1] = "SSL3"; + TlsOptions_Version3[TlsOptions_Version3["TLS1DOT0"] = 2] = "TLS1DOT0"; + TlsOptions_Version3[TlsOptions_Version3["TLS1DOT1"] = 3] = "TLS1DOT1"; + TlsOptions_Version3[TlsOptions_Version3["TLS1DOT2"] = 4] = "TLS1DOT2"; + TlsOptions_Version3[TlsOptions_Version3["TLS1DOT3"] = 5] = "TLS1DOT3"; + })( + TlsOptions_Version2 = exports.TlsOptions_Version || (exports.TlsOptions_Version = {}) + ); + var TlsOptions = class extends capnp_ts_1.Struct { + adoptKeypair(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(0, this)); + } + disownKeypair() { + return capnp_ts_1.Struct.disown(this.getKeypair()); + } + getKeypair() { + return capnp_ts_1.Struct.getStruct(0, TlsOptions_Keypair, this); + } + hasKeypair() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(0, this)); + } + initKeypair() { + return capnp_ts_1.Struct.initStructAt(0, TlsOptions_Keypair, this); + } + setKeypair(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(0, this)); + } + getRequireClientCerts() { + return capnp_ts_1.Struct.getBit( + 0, + this, + TlsOptions._capnp.defaultRequireClientCerts + ); + } + setRequireClientCerts(value) { + capnp_ts_1.Struct.setBit(0, value, this); + } + getTrustBrowserCas() { + return capnp_ts_1.Struct.getBit( + 1, + this, + TlsOptions._capnp.defaultTrustBrowserCas + ); + } + setTrustBrowserCas(value) { + capnp_ts_1.Struct.setBit(1, value, this); + } + adoptTrustedCertificates(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(1, this)); + } + disownTrustedCertificates() { + return capnp_ts_1.Struct.disown(this.getTrustedCertificates()); + } + getTrustedCertificates() { + return capnp_ts_1.Struct.getList(1, capnp.TextList, this); + } + hasTrustedCertificates() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(1, this)); + } + initTrustedCertificates(length) { + return capnp_ts_1.Struct.initList(1, capnp.TextList, length, this); + } + setTrustedCertificates(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(1, this)); + } + getMinVersion() { + return capnp_ts_1.Struct.getUint16( + 2, + this, + TlsOptions._capnp.defaultMinVersion + ); + } + setMinVersion(value) { + capnp_ts_1.Struct.setUint16(2, value, this); + } + getCipherList() { + return capnp_ts_1.Struct.getText(2, this); + } + setCipherList(value) { + capnp_ts_1.Struct.setText(2, value, this); + } + toString() { + return "TlsOptions_" + super.toString(); + } + }; + exports.TlsOptions = TlsOptions; + TlsOptions.Keypair = TlsOptions_Keypair; + TlsOptions.Version = TlsOptions_Version2; + TlsOptions._capnp = { + displayName: "TlsOptions", + id: "aabb3c3778ac4311", + size: new capnp_ts_1.ObjectSize(8, 3), + defaultRequireClientCerts: capnp.getBitMask(false, 0), + defaultTrustBrowserCas: capnp.getBitMask(false, 1), + defaultMinVersion: capnp.getUint16Mask(0) + }; + var Extension_Module = class extends capnp_ts_1.Struct { + getName() { + return capnp_ts_1.Struct.getText(0, this); + } + setName(value) { + capnp_ts_1.Struct.setText(0, value, this); + } + getInternal() { + return capnp_ts_1.Struct.getBit( + 0, + this, + Extension_Module._capnp.defaultInternal + ); + } + setInternal(value) { + capnp_ts_1.Struct.setBit(0, value, this); + } + getEsModule() { + return capnp_ts_1.Struct.getText(1, this); + } + setEsModule(value) { + capnp_ts_1.Struct.setText(1, value, this); + } + toString() { + return "Extension_Module_" + super.toString(); + } + }; + exports.Extension_Module = Extension_Module; + Extension_Module._capnp = { + displayName: "Module", + id: "d5d16e76fdedc37d", + size: new capnp_ts_1.ObjectSize(8, 2), + defaultInternal: capnp.getBitMask(false, 0) + }; + var Extension3 = class extends capnp_ts_1.Struct { + adoptModules(value) { + capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(0, this)); + } + disownModules() { + return capnp_ts_1.Struct.disown(this.getModules()); + } + getModules() { + return capnp_ts_1.Struct.getList(0, Extension3._Modules, this); + } + hasModules() { + return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(0, this)); + } + initModules(length) { + return capnp_ts_1.Struct.initList(0, Extension3._Modules, length, this); + } + setModules(value) { + capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(0, this)); + } + toString() { + return "Extension_" + super.toString(); + } + }; + exports.Extension = Extension3; + Extension3.Module = Extension_Module; + Extension3._capnp = { + displayName: "Extension", + id: "e390128a861973a6", + size: new capnp_ts_1.ObjectSize(0, 1) + }; + Config3._Services = capnp.CompositeList(Service4); + Config3._Sockets = capnp.CompositeList(Socket2); + Config3._Extensions = capnp.CompositeList(Extension3); + Worker_Binding_WrappedBinding._InnerBindings = capnp.CompositeList(Worker_Binding4); + Worker2._Modules = capnp.CompositeList(Worker_Module3); + Worker2._Bindings = capnp.CompositeList(Worker_Binding4); + Worker2._DurableObjectNamespaces = capnp.CompositeList( + Worker_DurableObjectNamespace + ); + HttpOptions._InjectRequestHeaders = capnp.CompositeList(HttpOptions_Header); + HttpOptions._InjectResponseHeaders = capnp.CompositeList(HttpOptions_Header); + Extension3._Modules = capnp.CompositeList(Extension_Module); + } +}); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + CACHE_PLUGIN: () => CACHE_PLUGIN, + CACHE_PLUGIN_NAME: () => CACHE_PLUGIN_NAME, + CORE_PLUGIN: () => CORE_PLUGIN, + CORE_PLUGIN_NAME: () => CORE_PLUGIN_NAME2, + CacheBindings: () => CacheBindings, + CacheHeaders: () => CacheHeaders, + CacheOptionsSchema: () => CacheOptionsSchema, + CacheSharedOptionsSchema: () => CacheSharedOptionsSchema, + CloseEvent: () => CloseEvent, + CoreBindings: () => CoreBindings, + CoreHeaders: () => CoreHeaders, + CoreOptionsSchema: () => CoreOptionsSchema, + CoreSharedOptionsSchema: () => CoreSharedOptionsSchema, + D1OptionsSchema: () => D1OptionsSchema, + D1SharedOptionsSchema: () => D1SharedOptionsSchema, + D1_PLUGIN: () => D1_PLUGIN, + D1_PLUGIN_NAME: () => D1_PLUGIN_NAME, + DEFAULT_PERSIST_ROOT: () => DEFAULT_PERSIST_ROOT, + DURABLE_OBJECTS_PLUGIN: () => DURABLE_OBJECTS_PLUGIN, + DURABLE_OBJECTS_PLUGIN_NAME: () => DURABLE_OBJECTS_PLUGIN_NAME, + DURABLE_OBJECTS_STORAGE_SERVICE_NAME: () => DURABLE_OBJECTS_STORAGE_SERVICE_NAME, + DeferredPromise: () => DeferredPromise, + DurableObjectsOptionsSchema: () => DurableObjectsOptionsSchema, + DurableObjectsSharedOptionsSchema: () => DurableObjectsSharedOptionsSchema, + ErrorEvent: () => ErrorEvent, + File: () => import_undici8.File, + FormData: () => import_undici8.FormData, + HEADER_CF_BLOB: () => HEADER_CF_BLOB, + HYPERDRIVE_PLUGIN: () => HYPERDRIVE_PLUGIN, + HYPERDRIVE_PLUGIN_NAME: () => HYPERDRIVE_PLUGIN_NAME, + Headers: () => import_undici8.Headers, + HttpOptions_Style: () => import_workerd_capnp.HttpOptions_Style, + HyperdriveInputOptionsSchema: () => HyperdriveInputOptionsSchema, + HyperdriveSchema: () => HyperdriveSchema, + JsonSchema: () => JsonSchema, + KVHeaders: () => KVHeaders, + KVLimits: () => KVLimits, + KVOptionsSchema: () => KVOptionsSchema, + KVParams: () => KVParams, + KVSharedOptionsSchema: () => KVSharedOptionsSchema, + KV_PLUGIN: () => KV_PLUGIN, + KV_PLUGIN_NAME: () => KV_PLUGIN_NAME, + LiteralSchema: () => LiteralSchema, + Log: () => Log, + LogLevel: () => LogLevel, + MessageEvent: () => MessageEvent, + Miniflare: () => Miniflare, + MiniflareCoreError: () => MiniflareCoreError, + MiniflareError: () => MiniflareError, + ModuleDefinitionSchema: () => ModuleDefinitionSchema, + ModuleRuleSchema: () => ModuleRuleSchema, + ModuleRuleTypeSchema: () => ModuleRuleTypeSchema, + Mutex: () => Mutex, + NoOpLog: () => NoOpLog, + PLUGINS: () => PLUGINS, + PLUGIN_ENTRIES: () => PLUGIN_ENTRIES, + PersistenceSchema: () => PersistenceSchema, + ProxyAddresses: () => ProxyAddresses, + ProxyClient: () => ProxyClient, + ProxyOps: () => ProxyOps, + QUEUES_PLUGIN: () => QUEUES_PLUGIN, + QUEUES_PLUGIN_NAME: () => QUEUES_PLUGIN_NAME, + QueueBindings: () => QueueBindings, + QueueConsumerOptionsSchema: () => QueueConsumerOptionsSchema, + QueueConsumerSchema: () => QueueConsumerSchema, + QueueConsumersSchema: () => QueueConsumersSchema, + QueueContentTypeSchema: () => QueueContentTypeSchema, + QueueIncomingMessageSchema: () => QueueIncomingMessageSchema, + QueuesBatchRequestSchema: () => QueuesBatchRequestSchema, + QueuesError: () => QueuesError, + QueuesOptionsSchema: () => QueuesOptionsSchema, + R2OptionsSchema: () => R2OptionsSchema, + R2SharedOptionsSchema: () => R2SharedOptionsSchema, + R2_PLUGIN: () => R2_PLUGIN, + R2_PLUGIN_NAME: () => R2_PLUGIN_NAME, + Request: () => Request, + Response: () => Response, + RouterError: () => RouterError, + Runtime: () => Runtime, + SERVICE_ENTRY: () => SERVICE_ENTRY, + SERVICE_LOOPBACK: () => SERVICE_LOOPBACK, + SITES_NO_CACHE_PREFIX: () => SITES_NO_CACHE_PREFIX, + SOCKET_ENTRY: () => SOCKET_ENTRY, + SharedBindings: () => SharedBindings, + SharedHeaders: () => SharedHeaders, + SiteBindings: () => SiteBindings, + SourceOptionsSchema: () => SourceOptionsSchema, + TlsOptions_Version: () => import_workerd_capnp.TlsOptions_Version, + TypedEventTarget: () => TypedEventTarget, + WORKER_BINDING_SERVICE_LOOPBACK: () => WORKER_BINDING_SERVICE_LOOPBACK, + WaitGroup: () => WaitGroup, + WebSocket: () => WebSocket, + WebSocketPair: () => WebSocketPair, + Worker_Binding_CryptoKey_Usage: () => import_workerd_capnp.Worker_Binding_CryptoKey_Usage, + _enableControlEndpoints: () => _enableControlEndpoints, + _forceColour: () => _forceColour, + _formatZodError: () => _formatZodError, + _initialiseInstanceRegistry: () => _initialiseInstanceRegistry, + _isCyclic: () => _isCyclic, + _transformsForContentEncoding: () => _transformsForContentEncoding, + base64Decode: () => base64Decode, + base64Encode: () => base64Encode, + configureEntrySocket: () => configureEntrySocket, + coupleWebSocket: () => coupleWebSocket, + createFetchMock: () => createFetchMock, + createHTTPReducers: () => createHTTPReducers, + createHTTPRevivers: () => createHTTPRevivers, + decodeSitesKey: () => decodeSitesKey, + deserialiseRegExps: () => deserialiseRegExps, + deserialiseSiteRegExps: () => deserialiseSiteRegExps, + encodeSitesKey: () => encodeSitesKey, + fetch: () => fetch2, + getAccessibleHosts: () => getAccessibleHosts, + getCacheServiceName: () => getCacheServiceName, + getControlEndpointBindings: () => getControlEndpointBindings, + getDirectSocketName: () => getDirectSocketName, + getGlobalServices: () => getGlobalServices, + getPersistPath: () => getPersistPath, + globsToRegExps: () => globsToRegExps, + isFetcherFetch: () => isFetcherFetch, + isR2ObjectWriteHttpMetadata: () => isR2ObjectWriteHttpMetadata, + isSitesRequest: () => isSitesRequest, + kInspectorSocket: () => kInspectorSocket, + kProxyNodeBinding: () => kProxyNodeBinding, + kVoid: () => kVoid, + matchRoutes: () => matchRoutes, + maybeApply: () => maybeApply, + maybeParseURL: () => maybeParseURL, + migrateDatabase: () => migrateDatabase, + namespaceEntries: () => namespaceEntries, + namespaceKeys: () => namespaceKeys, + normaliseDurableObject: () => normaliseDurableObject, + objectEntryWorker: () => objectEntryWorker, + parseRanges: () => parseRanges, + parseRoutes: () => parseRoutes, + parseWithReadableStreams: () => parseWithReadableStreams, + prefixError: () => prefixError, + prefixStream: () => prefixStream, + readPrefix: () => readPrefix, + reduceError: () => reduceError, + registerAllowUnauthorizedDispatcher: () => registerAllowUnauthorizedDispatcher, + sanitisePath: () => sanitisePath, + serialiseRegExps: () => serialiseRegExps, + serialiseSiteRegExps: () => serialiseSiteRegExps, + serializeConfig: () => serializeConfig, + stringifyWithStreams: () => stringifyWithStreams, + stripAnsi: () => stripAnsi, + structuredSerializableReducers: () => structuredSerializableReducers, + structuredSerializableRevivers: () => structuredSerializableRevivers, + supportedCompatibilityDate: () => import_workerd2.compatibilityDate, + testRegExps: () => testRegExps, + testSiteRegExps: () => testSiteRegExps, + viewToBuffer: () => viewToBuffer, + zAwaitable: () => zAwaitable +}); +module.exports = __toCommonJS(src_exports); +var import_assert11 = __toESM(require("assert")); +var import_crypto3 = __toESM(require("crypto")); +var import_fs17 = __toESM(require("fs")); +var import_http7 = __toESM(require("http")); +var import_net = __toESM(require("net")); +var import_os2 = __toESM(require("os")); +var import_path20 = __toESM(require("path")); +var import_web5 = require("stream/web"); +var import_util5 = __toESM(require("util")); +var import_zlib = __toESM(require("zlib")); +var import_exit_hook = __toESM(require("exit-hook")); + +// ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs +var FORCE_COLOR; +var NODE_DISABLE_COLORS; +var NO_COLOR; +var TERM; +var isTTY = true; +if (typeof process !== "undefined") { + ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {}); + isTTY = process.stdout && process.stdout.isTTY; +} +var $ = { + enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY) +}; +function init(x, y) { + let rgx = new RegExp(`\\x1b\\[${y}m`, "g"); + let open = `\x1B[${x}m`, close = `\x1B[${y}m`; + return function(txt) { + if (!$.enabled || txt == null) + return txt; + return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close; + }; +} +var reset = init(0, 0); +var bold = init(1, 22); +var dim = init(2, 22); +var italic = init(3, 23); +var underline = init(4, 24); +var inverse = init(7, 27); +var hidden = init(8, 28); +var strikethrough = init(9, 29); +var black = init(30, 39); +var red = init(31, 39); +var green = init(32, 39); +var yellow = init(33, 39); +var blue = init(34, 39); +var magenta = init(35, 39); +var cyan = init(36, 39); +var white = init(37, 39); +var gray = init(90, 39); +var grey = init(90, 39); +var bgBlack = init(40, 49); +var bgRed = init(41, 49); +var bgGreen = init(42, 49); +var bgYellow = init(43, 49); +var bgBlue = init(44, 49); +var bgMagenta = init(45, 49); +var bgCyan = init(46, 49); +var bgWhite = init(47, 49); + +// src/index.ts +var import_stoppable = __toESM(require("stoppable")); +var import_undici9 = require("undici"); + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/shared/index.worker.ts +var import_fs = __toESM(require("fs")); +var import_path = __toESM(require("path")); +var import_url = __toESM(require("url")); +var contents; +function index_worker_default() { + if (contents !== void 0) + return contents; + const filePath = import_path.default.join(__dirname, "workers", "shared/index.worker.js"); + contents = import_fs.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url.default.pathToFileURL(filePath); + return contents; +} + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/shared/zod.worker.ts +var import_fs2 = __toESM(require("fs")); +var import_path2 = __toESM(require("path")); +var import_url2 = __toESM(require("url")); +var contents2; +function zod_worker_default() { + if (contents2 !== void 0) + return contents2; + const filePath = import_path2.default.join(__dirname, "workers", "shared/zod.worker.js"); + contents2 = import_fs2.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url2.default.pathToFileURL(filePath); + return contents2; +} + +// src/index.ts +var import_ws3 = require("ws"); +var import_zod18 = require("zod"); + +// src/cf.ts +var import_assert = __toESM(require("assert")); +var import_promises = require("fs/promises"); +var import_path3 = __toESM(require("path")); +var import_undici = require("undici"); +var defaultCfPath = import_path3.default.resolve("node_modules", ".mf", "cf.json"); +var defaultCfFetchEndpoint = "https://workers.cloudflare.com/cf.json"; +var fallbackCf = { + asOrganization: "", + asn: 395747, + colo: "DFW", + city: "Austin", + region: "Texas", + regionCode: "TX", + metroCode: "635", + postalCode: "78701", + country: "US", + continent: "NA", + timezone: "America/Chicago", + latitude: "30.27130", + longitude: "-97.74260", + clientTcpRtt: 0, + httpProtocol: "HTTP/1.1", + requestPriority: "weight=192;exclusive=0", + tlsCipher: "AEAD-AES128-GCM-SHA256", + tlsVersion: "TLSv1.3", + tlsClientAuth: { + certPresented: "0", + certVerified: "NONE", + certRevoked: "0", + certIssuerDN: "", + certSubjectDN: "", + certIssuerDNRFC2253: "", + certSubjectDNRFC2253: "", + certIssuerDNLegacy: "", + certSubjectDNLegacy: "", + certSerial: "", + certIssuerSerial: "", + certSKI: "", + certIssuerSKI: "", + certFingerprintSHA1: "", + certFingerprintSHA256: "", + certNotBefore: "", + certNotAfter: "" + }, + edgeRequestKeepAliveStatus: 0, + hostMetadata: void 0, + clientTrustScore: 99, + botManagement: { + corporateProxy: false, + verifiedBot: false, + ja3Hash: "25b4882c2bcb50cd6b469ff28c596742", + staticResource: false, + detectionIds: [], + score: 99 + } +}; +var DAY = 864e5; +var CF_DAYS = 30; +async function setupCf(log, cf) { + if (!(cf ?? process.env.NODE_ENV !== "test")) { + return fallbackCf; + } + if (typeof cf === "object") { + return cf; + } + let cfPath = defaultCfPath; + if (typeof cf === "string") { + cfPath = cf; + } + try { + const storedCf = JSON.parse(await (0, import_promises.readFile)(cfPath, "utf8")); + const cfStat = await (0, import_promises.stat)(cfPath); + (0, import_assert.default)(Date.now() - cfStat.mtimeMs <= CF_DAYS * DAY); + return storedCf; + } catch { + } + try { + const res = await (0, import_undici.fetch)(defaultCfFetchEndpoint); + const cfText = await res.text(); + const storedCf = JSON.parse(cfText); + await (0, import_promises.mkdir)(import_path3.default.dirname(cfPath), { recursive: true }); + await (0, import_promises.writeFile)(cfPath, cfText, "utf8"); + log.debug("Updated `Request.cf` object cache!"); + return storedCf; + } catch (e) { + log.warn( + "Unable to fetch the `Request.cf` object! Falling back to a default placeholder...\n" + dim(e.cause ? e.cause.stack : e.stack) + ); + return fallbackCf; + } +} + +// src/http/fetch.ts +var import_undici4 = require("undici"); +var import_ws2 = __toESM(require("ws")); + +// src/workers/cache/constants.ts +var CacheHeaders = { + NAMESPACE: "cf-cache-namespace", + STATUS: "cf-cache-status" +}; +var CacheBindings = { + MAYBE_JSON_CACHE_WARN_USAGE: "MINIFLARE_CACHE_WARN_USAGE" +}; + +// src/workers/core/constants.ts +var CoreHeaders = { + CUSTOM_SERVICE: "MF-Custom-Service", + ORIGINAL_URL: "MF-Original-URL", + DISABLE_PRETTY_ERROR: "MF-Disable-Pretty-Error", + ERROR_STACK: "MF-Experimental-Error-Stack", + ROUTE_OVERRIDE: "MF-Route-Override", + // API Proxy + OP_SECRET: "MF-Op-Secret", + OP: "MF-Op", + OP_TARGET: "MF-Op-Target", + OP_KEY: "MF-Op-Key", + OP_SYNC: "MF-Op-Sync", + OP_STRINGIFIED_SIZE: "MF-Op-Stringified-Size", + OP_RESULT_TYPE: "MF-Op-Result-Type" +}; +var CoreBindings = { + SERVICE_LOOPBACK: "MINIFLARE_LOOPBACK", + SERVICE_USER_ROUTE_PREFIX: "MINIFLARE_USER_ROUTE_", + SERVICE_USER_FALLBACK: "MINIFLARE_USER_FALLBACK", + TEXT_CUSTOM_SERVICE: "MINIFLARE_CUSTOM_SERVICE", + TEXT_UPSTREAM_URL: "MINIFLARE_UPSTREAM_URL", + JSON_CF_BLOB: "CF_BLOB", + JSON_ROUTES: "MINIFLARE_ROUTES", + JSON_LOG_LEVEL: "MINIFLARE_LOG_LEVEL", + DATA_LIVE_RELOAD_SCRIPT: "MINIFLARE_LIVE_RELOAD_SCRIPT", + DURABLE_OBJECT_NAMESPACE_PROXY: "MINIFLARE_PROXY", + DATA_PROXY_SECRET: "MINIFLARE_PROXY_SECRET" +}; +var ProxyOps = { + // Get the target or a property of the target + GET: "GET", + // Get the descriptor for a property of the target + GET_OWN_DESCRIPTOR: "GET_OWN_DESCRIPTOR", + // Get the target's own property names + GET_OWN_KEYS: "GET_OWN_KEYS", + // Call a method on the target + CALL: "CALL", + // Remove the strong reference to the target on the "heap", allowing it to be + // garbage collected + FREE: "FREE" +}; +var ProxyAddresses = { + GLOBAL: 0, + // globalThis + ENV: 1, + // env + USER_START: 2 +}; +function isFetcherFetch(targetName, key) { + return (targetName === "Fetcher" || targetName === "DurableObject") && key === "fetch"; +} +function isR2ObjectWriteHttpMetadata(targetName, key) { + return (targetName === "HeadResult" || targetName === "GetResult") && key === "writeHttpMetadata"; +} + +// src/workers/core/devalue.ts +var import_node_assert = __toESM(require("node:assert")); +var import_node_buffer = require("node:buffer"); + +// ../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/utils.js +var DevalueError = class extends Error { + /** + * @param {string} message + * @param {string[]} keys + */ + constructor(message, keys) { + super(message); + this.name = "DevalueError"; + this.path = keys.join(""); + } +}; +function is_primitive(thing) { + return Object(thing) !== thing; +} +var object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames( + Object.prototype +).sort().join("\0"); +function is_plain_object(thing) { + const proto = Object.getPrototypeOf(thing); + return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names; +} +function get_type(thing) { + return Object.prototype.toString.call(thing).slice(8, -1); +} +function get_escaped_char(char) { + switch (char) { + case '"': + return '\\"'; + case "<": + return "\\u003C"; + case "\\": + return "\\\\"; + case "\n": + return "\\n"; + case "\r": + return "\\r"; + case " ": + return "\\t"; + case "\b": + return "\\b"; + case "\f": + return "\\f"; + case "\u2028": + return "\\u2028"; + case "\u2029": + return "\\u2029"; + default: + return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : ""; + } +} +function stringify_string(str) { + let result = ""; + let last_pos = 0; + const len = str.length; + for (let i = 0; i < len; i += 1) { + const char = str[i]; + const replacement = get_escaped_char(char); + if (replacement) { + result += str.slice(last_pos, i) + replacement; + last_pos = i + 1; + } + } + return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`; +} + +// ../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/constants.js +var UNDEFINED = -1; +var HOLE = -2; +var NAN = -3; +var POSITIVE_INFINITY = -4; +var NEGATIVE_INFINITY = -5; +var NEGATIVE_ZERO = -6; + +// ../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/parse.js +function parse(serialized, revivers2) { + return unflatten(JSON.parse(serialized), revivers2); +} +function unflatten(parsed, revivers2) { + if (typeof parsed === "number") + return hydrate(parsed, true); + if (!Array.isArray(parsed) || parsed.length === 0) { + throw new Error("Invalid input"); + } + const values = ( + /** @type {any[]} */ + parsed + ); + const hydrated = Array(values.length); + function hydrate(index, standalone = false) { + if (index === UNDEFINED) + return void 0; + if (index === NAN) + return NaN; + if (index === POSITIVE_INFINITY) + return Infinity; + if (index === NEGATIVE_INFINITY) + return -Infinity; + if (index === NEGATIVE_ZERO) + return -0; + if (standalone) + throw new Error(`Invalid input`); + if (index in hydrated) + return hydrated[index]; + const value = values[index]; + if (!value || typeof value !== "object") { + hydrated[index] = value; + } else if (Array.isArray(value)) { + if (typeof value[0] === "string") { + const type = value[0]; + const reviver = revivers2?.[type]; + if (reviver) { + return hydrated[index] = reviver(hydrate(value[1])); + } + switch (type) { + case "Date": + hydrated[index] = new Date(value[1]); + break; + case "Set": + const set = /* @__PURE__ */ new Set(); + hydrated[index] = set; + for (let i = 1; i < value.length; i += 1) { + set.add(hydrate(value[i])); + } + break; + case "Map": + const map = /* @__PURE__ */ new Map(); + hydrated[index] = map; + for (let i = 1; i < value.length; i += 2) { + map.set(hydrate(value[i]), hydrate(value[i + 1])); + } + break; + case "RegExp": + hydrated[index] = new RegExp(value[1], value[2]); + break; + case "Object": + hydrated[index] = Object(value[1]); + break; + case "BigInt": + hydrated[index] = BigInt(value[1]); + break; + case "null": + const obj = /* @__PURE__ */ Object.create(null); + hydrated[index] = obj; + for (let i = 1; i < value.length; i += 2) { + obj[value[i]] = hydrate(value[i + 1]); + } + break; + default: + throw new Error(`Unknown type ${type}`); + } + } else { + const array = new Array(value.length); + hydrated[index] = array; + for (let i = 0; i < value.length; i += 1) { + const n = value[i]; + if (n === HOLE) + continue; + array[i] = hydrate(n); + } + } + } else { + const object = {}; + hydrated[index] = object; + for (const key in value) { + const n = value[key]; + object[key] = hydrate(n); + } + } + return hydrated[index]; + } + return hydrate(0); +} + +// ../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/stringify.js +function stringify(value, reducers2) { + const stringified = []; + const indexes = /* @__PURE__ */ new Map(); + const custom = []; + for (const key in reducers2) { + custom.push({ key, fn: reducers2[key] }); + } + const keys = []; + let p = 0; + function flatten(thing) { + if (typeof thing === "function") { + throw new DevalueError(`Cannot stringify a function`, keys); + } + if (indexes.has(thing)) + return indexes.get(thing); + if (thing === void 0) + return UNDEFINED; + if (Number.isNaN(thing)) + return NAN; + if (thing === Infinity) + return POSITIVE_INFINITY; + if (thing === -Infinity) + return NEGATIVE_INFINITY; + if (thing === 0 && 1 / thing < 0) + return NEGATIVE_ZERO; + const index2 = p++; + indexes.set(thing, index2); + for (const { key, fn } of custom) { + const value2 = fn(thing); + if (value2) { + stringified[index2] = `["${key}",${flatten(value2)}]`; + return index2; + } + } + let str = ""; + if (is_primitive(thing)) { + str = stringify_primitive(thing); + } else { + const type = get_type(thing); + switch (type) { + case "Number": + case "String": + case "Boolean": + str = `["Object",${stringify_primitive(thing)}]`; + break; + case "BigInt": + str = `["BigInt",${thing}]`; + break; + case "Date": + str = `["Date","${thing.toISOString()}"]`; + break; + case "RegExp": + const { source, flags } = thing; + str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`; + break; + case "Array": + str = "["; + for (let i = 0; i < thing.length; i += 1) { + if (i > 0) + str += ","; + if (i in thing) { + keys.push(`[${i}]`); + str += flatten(thing[i]); + keys.pop(); + } else { + str += HOLE; + } + } + str += "]"; + break; + case "Set": + str = '["Set"'; + for (const value2 of thing) { + str += `,${flatten(value2)}`; + } + str += "]"; + break; + case "Map": + str = '["Map"'; + for (const [key, value2] of thing) { + keys.push( + `.get(${is_primitive(key) ? stringify_primitive(key) : "..."})` + ); + str += `,${flatten(key)},${flatten(value2)}`; + } + str += "]"; + break; + default: + if (!is_plain_object(thing)) { + throw new DevalueError( + `Cannot stringify arbitrary non-POJOs`, + keys + ); + } + if (Object.getOwnPropertySymbols(thing).length > 0) { + throw new DevalueError( + `Cannot stringify POJOs with symbolic keys`, + keys + ); + } + if (Object.getPrototypeOf(thing) === null) { + str = '["null"'; + for (const key in thing) { + keys.push(`.${key}`); + str += `,${stringify_string(key)},${flatten(thing[key])}`; + keys.pop(); + } + str += "]"; + } else { + str = "{"; + let started = false; + for (const key in thing) { + if (started) + str += ","; + started = true; + keys.push(`.${key}`); + str += `${stringify_string(key)}:${flatten(thing[key])}`; + keys.pop(); + } + str += "}"; + } + } + } + stringified[index2] = str; + return index2; + } + const index = flatten(value); + if (index < 0) + return `${index}`; + return `[${stringified.join(",")}]`; +} +function stringify_primitive(thing) { + const type = typeof thing; + if (type === "string") + return stringify_string(thing); + if (thing instanceof String) + return stringify_string(thing.toString()); + if (thing === void 0) + return UNDEFINED.toString(); + if (thing === 0 && 1 / thing < 0) + return NEGATIVE_ZERO.toString(); + if (type === "bigint") + return `["BigInt","${thing}"]`; + return String(thing); +} + +// src/workers/core/devalue.ts +var ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS = [ + DataView, + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array, + BigInt64Array, + BigUint64Array +]; +var ALLOWED_ERROR_CONSTRUCTORS = [ + EvalError, + RangeError, + ReferenceError, + SyntaxError, + TypeError, + URIError, + Error + // `Error` last so more specific error subclasses preferred +]; +var structuredSerializableReducers = { + ArrayBuffer(value) { + if (value instanceof ArrayBuffer) { + return [import_node_buffer.Buffer.from(value).toString("base64")]; + } + }, + ArrayBufferView(value) { + if (ArrayBuffer.isView(value)) { + return [ + value.constructor.name, + value.buffer, + value.byteOffset, + value.byteLength + ]; + } + }, + Error(value) { + for (const ctor of ALLOWED_ERROR_CONSTRUCTORS) { + if (value instanceof ctor && value.name === ctor.name) { + return [value.name, value.message, value.stack, value.cause]; + } + } + if (value instanceof Error) { + return ["Error", value.message, value.stack, value.cause]; + } + } +}; +var structuredSerializableRevivers = { + ArrayBuffer(value) { + (0, import_node_assert.default)(Array.isArray(value)); + const [encoded] = value; + (0, import_node_assert.default)(typeof encoded === "string"); + const view = import_node_buffer.Buffer.from(encoded, "base64"); + return view.buffer.slice( + view.byteOffset, + view.byteOffset + view.byteLength + ); + }, + ArrayBufferView(value) { + (0, import_node_assert.default)(Array.isArray(value)); + const [name, buffer, byteOffset, byteLength] = value; + (0, import_node_assert.default)(typeof name === "string"); + (0, import_node_assert.default)(buffer instanceof ArrayBuffer); + (0, import_node_assert.default)(typeof byteOffset === "number"); + (0, import_node_assert.default)(typeof byteLength === "number"); + const ctor = globalThis[name]; + (0, import_node_assert.default)(ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS.includes(ctor)); + let length = byteLength; + if ("BYTES_PER_ELEMENT" in ctor) + length /= ctor.BYTES_PER_ELEMENT; + return new ctor(buffer, byteOffset, length); + }, + Error(value) { + (0, import_node_assert.default)(Array.isArray(value)); + const [name, message, stack, cause] = value; + (0, import_node_assert.default)(typeof name === "string"); + (0, import_node_assert.default)(typeof message === "string"); + (0, import_node_assert.default)(stack === void 0 || typeof stack === "string"); + const ctor = globalThis[name]; + (0, import_node_assert.default)(ALLOWED_ERROR_CONSTRUCTORS.includes(ctor)); + const error = new ctor(message, { cause }); + error.stack = stack; + return error; + } +}; +function createHTTPReducers(impl) { + return { + Headers(val) { + if (val instanceof impl.Headers) + return Object.fromEntries(val); + }, + Request(val) { + if (val instanceof impl.Request) { + return [val.method, val.url, val.headers, val.cf, val.body]; + } + }, + Response(val) { + if (val instanceof impl.Response) { + return [val.status, val.statusText, val.headers, val.cf, val.body]; + } + } + }; +} +function createHTTPRevivers(impl) { + return { + Headers(value) { + (0, import_node_assert.default)(typeof value === "object" && value !== null); + return new impl.Headers(value); + }, + Request(value) { + (0, import_node_assert.default)(Array.isArray(value)); + const [method, url13, headers, cf, body] = value; + (0, import_node_assert.default)(typeof method === "string"); + (0, import_node_assert.default)(typeof url13 === "string"); + (0, import_node_assert.default)(headers instanceof impl.Headers); + (0, import_node_assert.default)(body === null || impl.isReadableStream(body)); + return new impl.Request(url13, { + method, + headers, + cf, + // @ts-expect-error `duplex` is not required by `workerd` yet + duplex: body === null ? void 0 : "half", + body + }); + }, + Response(value) { + (0, import_node_assert.default)(Array.isArray(value)); + const [status, statusText, headers, cf, body] = value; + (0, import_node_assert.default)(typeof status === "number"); + (0, import_node_assert.default)(typeof statusText === "string"); + (0, import_node_assert.default)(headers instanceof impl.Headers); + (0, import_node_assert.default)(body === null || impl.isReadableStream(body)); + return new impl.Response(body, { + status, + statusText, + headers, + cf + }); + } + }; +} +function stringifyWithStreams(impl, value, reducers2, allowUnbufferedStream) { + let unbufferedStream; + const bufferPromises = []; + const streamReducers = { + ReadableStream(value2) { + if (impl.isReadableStream(value2)) { + if (allowUnbufferedStream && unbufferedStream === void 0) { + unbufferedStream = value2; + } else { + bufferPromises.push(impl.bufferReadableStream(value2)); + } + return true; + } + }, + Blob(value2) { + if (value2 instanceof impl.Blob) { + bufferPromises.push(value2.arrayBuffer()); + return true; + } + }, + ...reducers2 + }; + const stringifiedValue = stringify(value, streamReducers); + if (bufferPromises.length === 0) { + return { value: stringifiedValue, unbufferedStream }; + } + return Promise.all(bufferPromises).then((streamBuffers) => { + streamReducers.ReadableStream = function(value2) { + if (impl.isReadableStream(value2)) { + if (value2 === unbufferedStream) { + return true; + } else { + return streamBuffers.shift(); + } + } + }; + streamReducers.Blob = function(value2) { + if (value2 instanceof impl.Blob) { + const array = [streamBuffers.shift(), value2.type]; + if (value2 instanceof impl.File) { + array.push(value2.name, value2.lastModified); + } + return array; + } + }; + const stringifiedValue2 = stringify(value, streamReducers); + return { value: stringifiedValue2, unbufferedStream }; + }); +} +function parseWithReadableStreams(impl, stringified, revivers2) { + const streamRevivers = { + ReadableStream(value) { + if (value === true) { + (0, import_node_assert.default)(stringified.unbufferedStream !== void 0); + return stringified.unbufferedStream; + } + (0, import_node_assert.default)(value instanceof ArrayBuffer); + return impl.unbufferReadableStream(value); + }, + Blob(value) { + (0, import_node_assert.default)(Array.isArray(value)); + if (value.length === 2) { + const [buffer, type] = value; + (0, import_node_assert.default)(buffer instanceof ArrayBuffer); + (0, import_node_assert.default)(typeof type === "string"); + const opts = {}; + if (type !== "") + opts.type = type; + return new impl.Blob([buffer], opts); + } else { + (0, import_node_assert.default)(value.length === 4); + const [buffer, type, name, lastModified] = value; + (0, import_node_assert.default)(buffer instanceof ArrayBuffer); + (0, import_node_assert.default)(typeof type === "string"); + (0, import_node_assert.default)(typeof name === "string"); + (0, import_node_assert.default)(typeof lastModified === "number"); + const opts = { lastModified }; + if (type !== "") + opts.type = type; + return new impl.File([buffer], name, opts); + } + }, + ...revivers2 + }; + return parse(stringified.value, streamRevivers); +} + +// src/workers/core/routing.ts +function matchRoutes(routes, url13) { + for (const route of routes) { + if (route.protocol && route.protocol !== url13.protocol) + continue; + if (route.allowHostnamePrefix) { + if (!url13.hostname.endsWith(route.hostname)) + continue; + } else { + if (url13.hostname !== route.hostname) + continue; + } + const path21 = url13.pathname + url13.search; + if (route.allowPathSuffix) { + if (!path21.startsWith(route.path)) + continue; + } else { + if (path21 !== route.path) + continue; + } + return route.target; + } + return null; +} + +// src/workers/shared/constants.ts +var SharedHeaders = { + LOG_LEVEL: "MF-Log-Level" +}; +var SharedBindings = { + TEXT_NAMESPACE: "MINIFLARE_NAMESPACE", + DURABLE_OBJECT_NAMESPACE_OBJECT: "MINIFLARE_OBJECT", + MAYBE_SERVICE_BLOBS: "MINIFLARE_BLOBS", + MAYBE_SERVICE_LOOPBACK: "MINIFLARE_LOOPBACK", + MAYBE_JSON_ENABLE_CONTROL_ENDPOINTS: "MINIFLARE_ENABLE_CONTROL_ENDPOINTS" +}; +var LogLevel = /* @__PURE__ */ ((LogLevel2) => { + LogLevel2[LogLevel2["NONE"] = 0] = "NONE"; + LogLevel2[LogLevel2["ERROR"] = 1] = "ERROR"; + LogLevel2[LogLevel2["WARN"] = 2] = "WARN"; + LogLevel2[LogLevel2["INFO"] = 3] = "INFO"; + LogLevel2[LogLevel2["DEBUG"] = 4] = "DEBUG"; + LogLevel2[LogLevel2["VERBOSE"] = 5] = "VERBOSE"; + return LogLevel2; +})(LogLevel || {}); + +// src/workers/shared/data.ts +var import_node_buffer2 = require("node:buffer"); +function viewToBuffer(view) { + return view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength); +} +function base64Encode(value) { + return import_node_buffer2.Buffer.from(value, "utf8").toString("base64"); +} +function base64Decode(encoded) { + return import_node_buffer2.Buffer.from(encoded, "base64").toString("utf8"); +} +var dotRegexp = /(^|\/|\\)(\.+)(\/|\\|$)/g; +var illegalRegexp = /[?<>*"'^/\\:|\x00-\x1f\x80-\x9f]/g; +var windowsReservedRegexp = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i; +var leadingRegexp = /^[ /\\]+/; +var trailingRegexp = /[ /\\]+$/; +function dotReplacement(match, g1, g2, g3) { + return `${g1}${"".padStart(g2.length, "_")}${g3}`; +} +function underscoreReplacement(match) { + return "".padStart(match.length, "_"); +} +function sanitisePath(unsafe) { + return unsafe.replace(dotRegexp, dotReplacement).replace(dotRegexp, dotReplacement).replace(illegalRegexp, "_").replace(windowsReservedRegexp, "_").replace(leadingRegexp, underscoreReplacement).replace(trailingRegexp, underscoreReplacement).substring(0, 255); +} + +// src/workers/shared/matcher.ts +function testRegExps(matcher, value) { + for (const exclude of matcher.exclude) + if (exclude.test(value)) + return false; + for (const include of matcher.include) + if (include.test(value)) + return true; + return false; +} + +// src/workers/shared/range.ts +var rangePrefixRegexp = /^ *bytes *=/i; +var rangeRegexp = /^ *(?\d+)? *- *(?\d+)? *$/; +function parseRanges(rangeHeader, length) { + const prefixMatch = rangePrefixRegexp.exec(rangeHeader); + if (prefixMatch === null) + return; + rangeHeader = rangeHeader.substring(prefixMatch[0].length); + if (rangeHeader.trimStart() === "") + return []; + const ranges = rangeHeader.split(","); + const result = []; + for (const range of ranges) { + const match = rangeRegexp.exec(range); + if (match === null) + return; + const { start, end } = match.groups; + if (start !== void 0 && end !== void 0) { + const rangeStart = parseInt(start); + let rangeEnd = parseInt(end); + if (rangeStart > rangeEnd) + return; + if (rangeStart >= length) + return; + if (rangeEnd >= length) + rangeEnd = length - 1; + result.push({ start: rangeStart, end: rangeEnd }); + } else if (start !== void 0 && end === void 0) { + const rangeStart = parseInt(start); + if (rangeStart >= length) + return; + result.push({ start: rangeStart, end: length - 1 }); + } else if (start === void 0 && end !== void 0) { + const suffix = parseInt(end); + if (suffix >= length) + return []; + if (suffix === 0) + continue; + result.push({ start: length - suffix, end: length - 1 }); + } else { + return; + } + } + return result; +} + +// src/workers/shared/sync.ts +var import_node_assert2 = __toESM(require("node:assert")); +var DeferredPromise = class extends Promise { + resolve; + reject; + constructor(executor = () => { + }) { + let promiseResolve; + let promiseReject; + super((resolve, reject) => { + promiseResolve = resolve; + promiseReject = reject; + return executor(resolve, reject); + }); + this.resolve = promiseResolve; + this.reject = promiseReject; + } +}; +var Mutex = class { + locked = false; + resolveQueue = []; + drainQueue = []; + lock() { + if (!this.locked) { + this.locked = true; + return; + } + return new Promise((resolve) => this.resolveQueue.push(resolve)); + } + unlock() { + (0, import_node_assert2.default)(this.locked); + if (this.resolveQueue.length > 0) { + this.resolveQueue.shift()?.(); + } else { + this.locked = false; + let resolve; + while ((resolve = this.drainQueue.shift()) !== void 0) + resolve(); + } + } + get hasWaiting() { + return this.resolveQueue.length > 0; + } + async runWith(closure) { + const acquireAwaitable = this.lock(); + if (acquireAwaitable instanceof Promise) + await acquireAwaitable; + try { + const awaitable = closure(); + if (awaitable instanceof Promise) + return await awaitable; + return awaitable; + } finally { + this.unlock(); + } + } + async drained() { + if (this.resolveQueue.length === 0 && !this.locked) + return; + return new Promise((resolve) => this.drainQueue.push(resolve)); + } +}; +var WaitGroup = class { + counter = 0; + resolveQueue = []; + add() { + this.counter++; + } + done() { + (0, import_node_assert2.default)(this.counter > 0); + this.counter--; + if (this.counter === 0) { + let resolve; + while ((resolve = this.resolveQueue.shift()) !== void 0) + resolve(); + } + } + wait() { + if (this.counter === 0) + return Promise.resolve(); + return new Promise((resolve) => this.resolveQueue.push(resolve)); + } +}; + +// src/workers/shared/types.ts +function reduceError(e) { + return { + name: e?.name, + message: e?.message ?? String(e), + stack: e?.stack, + cause: e?.cause === void 0 ? void 0 : reduceError(e.cause) + }; +} +function maybeApply(f, maybeValue) { + return maybeValue === void 0 ? void 0 : f(maybeValue); +} + +// src/workers/kv/constants.ts +var KVLimits = { + MIN_CACHE_TTL: 60, + MAX_LIST_KEYS: 1e3, + MAX_KEY_SIZE: 512, + MAX_VALUE_SIZE: 25 * 1024 * 1024, + MAX_VALUE_SIZE_TEST: 1024, + MAX_METADATA_SIZE: 1024 +}; +var KVParams = { + URL_ENCODED: "urlencoded", + CACHE_TTL: "cache_ttl", + EXPIRATION: "expiration", + EXPIRATION_TTL: "expiration_ttl", + LIST_LIMIT: "key_count_limit", + LIST_PREFIX: "prefix", + LIST_CURSOR: "cursor" +}; +var KVHeaders = { + EXPIRATION: "CF-Expiration", + METADATA: "CF-KV-Metadata" +}; +var SiteBindings = { + KV_NAMESPACE_SITE: "__STATIC_CONTENT", + JSON_SITE_MANIFEST: "__STATIC_CONTENT_MANIFEST", + JSON_SITE_FILTER: "MINIFLARE_SITE_FILTER" +}; +var SITES_NO_CACHE_PREFIX = "$__MINIFLARE_SITES__$/"; +function encodeSitesKey(key) { + return SITES_NO_CACHE_PREFIX + encodeURIComponent(key); +} +function decodeSitesKey(key) { + return key.startsWith(SITES_NO_CACHE_PREFIX) ? decodeURIComponent(key.substring(SITES_NO_CACHE_PREFIX.length)) : key; +} +function isSitesRequest(request) { + const url13 = new URL(request.url); + return url13.pathname.startsWith(`/${SITES_NO_CACHE_PREFIX}`); +} +function serialiseRegExp(regExp) { + const str = regExp.toString(); + return str.substring(str.indexOf("/") + 1, str.lastIndexOf("/")); +} +function serialiseRegExps(matcher) { + return { + include: matcher.include.map(serialiseRegExp), + exclude: matcher.exclude.map(serialiseRegExp) + }; +} +function deserialiseRegExps(matcher) { + return { + include: matcher.include.map((regExp) => new RegExp(regExp)), + exclude: matcher.exclude.map((regExp) => new RegExp(regExp)) + }; +} +function serialiseSiteRegExps(siteRegExps) { + return { + include: siteRegExps.include && serialiseRegExps(siteRegExps.include), + exclude: siteRegExps.exclude && serialiseRegExps(siteRegExps.exclude) + }; +} +function deserialiseSiteRegExps(siteRegExps) { + return { + include: siteRegExps.include && deserialiseRegExps(siteRegExps.include), + exclude: siteRegExps.exclude && deserialiseRegExps(siteRegExps.exclude) + }; +} +function testSiteRegExps(regExps, key) { + if (regExps.include !== void 0) + return testRegExps(regExps.include, key); + if (regExps.exclude !== void 0) + return !testRegExps(regExps.exclude, key); + return true; +} + +// src/workers/queues/constants.ts +var QueueBindings = { + SERVICE_WORKER_PREFIX: "MINIFLARE_WORKER_", + MAYBE_JSON_QUEUE_CONSUMERS: "MINIFLARE_QUEUE_CONSUMERS" +}; + +// src/workers/shared/zod.worker.ts +var import_node_buffer3 = require("node:buffer"); +var import_zod = require("zod"); +var import_zod2 = require("zod"); +var HEX_REGEXP = /^[0-9a-f]*$/i; +var BASE64_REGEXP = /^[0-9a-z+/=]*$/i; +var HexDataSchema = import_zod.z.string().regex(HEX_REGEXP).transform((hex) => import_node_buffer3.Buffer.from(hex, "hex")); +var Base64DataSchema = import_zod.z.string().regex(BASE64_REGEXP).transform((base64) => import_node_buffer3.Buffer.from(base64, "base64")); + +// src/workers/queues/schemas.ts +var QueueConsumerOptionsSchema = /* @__PURE__ */ import_zod2.z.object({ + // https://developers.cloudflare.com/queues/platform/configuration/#consumer + // https://developers.cloudflare.com/queues/platform/limits/ + maxBatchSize: import_zod2.z.number().min(0).max(100).optional(), + maxBatchTimeout: import_zod2.z.number().min(0).max(30).optional(), + // seconds + maxRetires: import_zod2.z.number().min(0).max(100).optional(), + deadLetterQueue: import_zod2.z.ostring() +}); +var QueueConsumerSchema = /* @__PURE__ */ import_zod2.z.intersection( + QueueConsumerOptionsSchema, + import_zod2.z.object({ workerName: import_zod2.z.string() }) +); +var QueueConsumersSchema = /* @__PURE__ */ import_zod2.z.record(QueueConsumerSchema); +var QueueContentTypeSchema = /* @__PURE__ */ import_zod2.z.enum(["text", "json", "bytes", "v8"]).default("v8"); +var QueueIncomingMessageSchema = /* @__PURE__ */ import_zod2.z.object({ + contentType: QueueContentTypeSchema, + body: Base64DataSchema, + // When enqueuing messages on dead-letter queues, we want to reuse the same ID + // and timestamp + id: import_zod2.z.ostring(), + timestamp: import_zod2.z.onumber() +}); +var QueuesBatchRequestSchema = /* @__PURE__ */ import_zod2.z.object({ + messages: import_zod2.z.array(QueueIncomingMessageSchema) +}); + +// src/http/request.ts +var import_undici2 = require("undici"); +var kCf = Symbol("kCf"); +var Request = class extends import_undici2.Request { + // We should be able to use a private `#cf` property here instead of a symbol + // here, but we need to set this on a clone, which would otherwise lead to a + // "Cannot write private member to an object whose class did not declare it" + // error. + [kCf]; + constructor(input, init2) { + super(input, init2); + this[kCf] = init2?.cf; + if (input instanceof Request) + this[kCf] ??= input.cf; + } + get cf() { + return this[kCf]; + } + // JSDoc comment so retained when bundling types with api-extractor + /** @ts-expect-error `clone` is actually defined as a method internally */ + clone() { + const request = super.clone(); + Object.setPrototypeOf(request, Request.prototype); + request[kCf] = this[kCf]; + return request; + } +}; + +// src/http/response.ts +var import_undici3 = require("undici"); +var kWebSocket = Symbol("kWebSocket"); +var Response = class extends import_undici3.Response { + // We should be able to use a private `#webSocket` property here instead of a + // symbol here, but `undici` calls `this.status` in its constructor, which + // causes a "Cannot read private member from an object whose class did not + // declare it" error. + [kWebSocket]; + // Override BaseResponse's static methods for building Responses to return + // our type instead. Ideally, we don't want to use `Object.setPrototypeOf`. + // Unfortunately, `error()` and `redirect()` set the internal header guard + // to "immutable". + static error() { + const response = import_undici3.Response.error(); + Object.setPrototypeOf(response, Response.prototype); + return response; + } + static redirect(url13, status) { + const response = import_undici3.Response.redirect(url13, status); + Object.setPrototypeOf(response, Response.prototype); + return response; + } + static json(data, init2) { + const body = JSON.stringify(data); + const response = new Response(body, init2); + response.headers.set("Content-Type", "application/json"); + return response; + } + constructor(body, init2) { + if (init2?.webSocket) { + if (init2.status !== 101) { + throw new RangeError( + "Responses with a WebSocket must have status code 101." + ); + } + init2 = { ...init2, status: 200 }; + } + super(body, init2); + this[kWebSocket] = init2?.webSocket ?? null; + } + // JSDoc comment so retained when bundling types with api-extractor + /** @ts-expect-error `status` is actually defined as a getter internally */ + get status() { + return this[kWebSocket] ? 101 : super.status; + } + get webSocket() { + return this[kWebSocket]; + } + // JSDoc comment so retained when bundling types with api-extractor + /** @ts-expect-error `clone` is actually defined as a method internally */ + clone() { + if (this[kWebSocket]) { + throw new TypeError("Cannot clone a response to a WebSocket handshake."); + } + const response = super.clone(); + Object.setPrototypeOf(response, Response.prototype); + return response; + } +}; + +// src/http/websocket.ts +var import_assert2 = __toESM(require("assert")); +var import_events = require("events"); +var import_ws = __toESM(require("ws")); + +// src/shared/colour.ts +var originalEnabled = $.enabled; +function _forceColour(enabled = originalEnabled) { + $.enabled = enabled; +} + +// src/shared/error.ts +var MiniflareError = class extends Error { + constructor(code, message, cause) { + super(message); + this.code = code; + this.cause = cause; + Object.setPrototypeOf(this, new.target.prototype); + this.name = `${new.target.name} [${code}]`; + } +}; +var MiniflareCoreError = class extends MiniflareError { +}; + +// src/shared/event.ts +var TypedEventTarget = class extends EventTarget { + addEventListener(type, listener, options) { + super.addEventListener( + type, + listener, + options + ); + } + removeEventListener(type, listener, options) { + super.removeEventListener( + type, + listener, + options + ); + } + dispatchEvent(event) { + return super.dispatchEvent(event); + } +}; + +// src/shared/log.ts +var import_path4 = __toESM(require("path")); +var cwd = process.cwd(); +var cwdNodeModules = import_path4.default.join(cwd, "node_modules"); +var LEVEL_PREFIX = { + [0 /* NONE */]: "", + [1 /* ERROR */]: "err", + [2 /* WARN */]: "wrn", + [3 /* INFO */]: "inf", + [4 /* DEBUG */]: "dbg", + [5 /* VERBOSE */]: "vrb" +}; +var LEVEL_COLOUR = { + [0 /* NONE */]: reset, + [1 /* ERROR */]: red, + [2 /* WARN */]: yellow, + [3 /* INFO */]: green, + [4 /* DEBUG */]: grey, + [5 /* VERBOSE */]: (input) => dim(grey(input)) +}; +function prefixError(prefix, e) { + if (e.stack) { + return new Proxy(e, { + get(target, propertyKey, receiver) { + const value = Reflect.get(target, propertyKey, receiver); + return propertyKey === "stack" ? `${prefix}: ${value}` : value; + } + }); + } + return e; +} +function dimInternalStackLine(line) { + if (line.startsWith(" at") && (!line.includes(cwd) || line.includes(cwdNodeModules))) { + return dim(line); + } + return line; +} +var Log = class { + constructor(level = 3 /* INFO */, opts = {}) { + this.level = level; + const prefix = opts.prefix ?? "mf"; + const suffix = opts.suffix ?? ""; + this.#prefix = prefix ? prefix + ":" : ""; + this.#suffix = suffix ? ":" + suffix : ""; + } + #prefix; + #suffix; + log(message) { + console.log(message); + } + logWithLevel(level, message) { + if (level <= this.level) { + const prefix = `[${this.#prefix}${LEVEL_PREFIX[level]}${this.#suffix}]`; + this.log(LEVEL_COLOUR[level](`${prefix} ${message}`)); + } + } + error(message) { + if (this.level < 1 /* ERROR */) { + } else if (message.stack) { + const lines = message.stack.split("\n").map(dimInternalStackLine); + this.logWithLevel(1 /* ERROR */, lines.join("\n")); + } else { + this.logWithLevel(1 /* ERROR */, message.toString()); + } + if (message.cause) { + this.error(prefixError("Cause", message.cause)); + } + } + warn(message) { + this.logWithLevel(2 /* WARN */, message); + } + info(message) { + this.logWithLevel(3 /* INFO */, message); + } + debug(message) { + this.logWithLevel(4 /* DEBUG */, message); + } + verbose(message) { + this.logWithLevel(5 /* VERBOSE */, message); + } +}; +var NoOpLog = class extends Log { + constructor() { + super(0 /* NONE */); + } + log() { + } + error(_message) { + } +}; +var ansiRegexpPattern = [ + "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", + "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))" +].join("|"); +var ansiRegexp = new RegExp(ansiRegexpPattern, "g"); +function stripAnsi(value) { + return value.replace(ansiRegexp, ""); +} + +// src/shared/matcher.ts +var import_glob_to_regexp = __toESM(require("glob-to-regexp")); +function globsToRegExps(globs = []) { + const include = []; + const exclude = []; + const opts = { globstar: true, flags: "g" }; + for (const glob of globs) { + if (glob.startsWith("!")) { + exclude.push(new RegExp((0, import_glob_to_regexp.default)(glob.slice(1), opts), "")); + } else { + include.push(new RegExp((0, import_glob_to_regexp.default)(glob, opts), "")); + } + } + return { include, exclude }; +} + +// src/shared/streams.ts +var import_web = require("stream/web"); +function prefixStream(prefix, stream) { + const identity = new import_web.TransformStream(); + const writer = identity.writable.getWriter(); + void writer.write(prefix).then(() => { + writer.releaseLock(); + return stream.pipeTo(identity.writable); + }).catch((error) => { + return writer.abort(error); + }); + return identity.readable; +} +async function readPrefix(stream, prefixLength) { + const chunks = []; + let chunksLength = 0; + for await (const chunk of stream.values({ preventCancel: true })) { + chunks.push(chunk); + chunksLength += chunk.byteLength; + if (chunksLength >= prefixLength) + break; + } + if (chunksLength < prefixLength) { + throw new RangeError( + `Expected ${prefixLength} byte prefix, but received ${chunksLength} byte stream` + ); + } + const atLeastPrefix = Buffer.concat(chunks, chunksLength); + const prefix = atLeastPrefix.subarray(0, prefixLength); + let rest = stream; + if (chunksLength > prefixLength) { + rest = prefixStream(atLeastPrefix.subarray(prefixLength), stream); + } + return [prefix, rest]; +} + +// src/shared/types.ts +var import_zod3 = require("zod"); +function zAwaitable(type) { + return type.or(import_zod3.z.promise(type)); +} +var LiteralSchema = import_zod3.z.union([ + import_zod3.z.string(), + import_zod3.z.number(), + import_zod3.z.boolean(), + import_zod3.z.null() +]); +var JsonSchema = import_zod3.z.lazy( + () => import_zod3.z.union([LiteralSchema, import_zod3.z.array(JsonSchema), import_zod3.z.record(JsonSchema)]) +); +function _isCyclic(value, seen = /* @__PURE__ */ new Set()) { + if (typeof value !== "object" || value === null) + return false; + for (const child of Object.values(value)) { + if (seen.has(child)) + return true; + seen.add(child); + if (_isCyclic(child, seen)) + return true; + seen.delete(child); + } + return false; +} + +// src/http/websocket.ts +var MessageEvent = class extends Event { + data; + constructor(type, init2) { + super(type); + this.data = init2.data; + } +}; +var CloseEvent = class extends Event { + code; + reason; + wasClean; + constructor(type, init2) { + super(type); + this.code = init2?.code ?? 1005; + this.reason = init2?.reason ?? ""; + this.wasClean = init2?.wasClean ?? false; + } +}; +var ErrorEvent = class extends Event { + error; + constructor(type, init2) { + super(type); + this.error = init2?.error ?? null; + } +}; +var kPair = Symbol("kPair"); +var kAccepted = Symbol("kAccepted"); +var kCoupled = Symbol("kCoupled"); +var kClosedOutgoing = Symbol("kClosedOutgoing"); +var kClosedIncoming = Symbol("kClosedIncoming"); +var kSend = Symbol("kSend"); +var kClose = Symbol("kClose"); +var kError = Symbol("kError"); +var _dispatchQueue, _a, _b, _c, _d, _e, _queuingDispatchToPair, queuingDispatchToPair_fn; +var _WebSocket = class extends TypedEventTarget { + constructor() { + super(...arguments); + __privateAdd(this, _queuingDispatchToPair); + __privateAdd(this, _dispatchQueue, []); + __publicField(this, _a); + __publicField(this, _b, false); + __publicField(this, _c, false); + __publicField(this, _d, false); + __publicField(this, _e, false); + } + get readyState() { + if (this[kClosedOutgoing] && this[kClosedIncoming]) { + return _WebSocket.READY_STATE_CLOSED; + } else if (this[kClosedOutgoing] || this[kClosedIncoming]) { + return _WebSocket.READY_STATE_CLOSING; + } + return _WebSocket.READY_STATE_OPEN; + } + accept() { + if (this[kCoupled]) { + throw new TypeError( + "Can't accept() WebSocket that was already used in a response." + ); + } + if (this[kAccepted]) + return; + this[kAccepted] = true; + if (__privateGet(this, _dispatchQueue) !== void 0) { + for (const event of __privateGet(this, _dispatchQueue)) + this.dispatchEvent(event); + __privateSet(this, _dispatchQueue, void 0); + } + } + send(message) { + if (!this[kAccepted]) { + throw new TypeError( + "You must call accept() on this WebSocket before sending messages." + ); + } + this[kSend](message); + } + [(_a = kPair, _b = kAccepted, _c = kCoupled, _d = kClosedOutgoing, _e = kClosedIncoming, kSend)](message) { + if (this[kClosedOutgoing]) { + throw new TypeError("Can't call WebSocket send() after close()."); + } + const event = new MessageEvent("message", { data: message }); + void __privateMethod(this, _queuingDispatchToPair, queuingDispatchToPair_fn).call(this, event); + } + close(code, reason) { + if (code) { + const validCode = code >= 1e3 && code < 5e3 && code !== 1004 && code !== 1005 && code !== 1006 && code !== 1015; + if (!validCode) + throw new TypeError("Invalid WebSocket close code."); + } + if (reason !== void 0 && code === void 0) { + throw new TypeError( + "If you specify a WebSocket close reason, you must also specify a code." + ); + } + if (!this[kAccepted]) { + throw new TypeError( + "You must call accept() on this WebSocket before sending messages." + ); + } + this[kClose](code, reason); + } + [kClose](code, reason) { + if (this[kClosedOutgoing]) + throw new TypeError("WebSocket already closed"); + const pair = this[kPair]; + (0, import_assert2.default)(pair !== void 0); + this[kClosedOutgoing] = true; + pair[kClosedIncoming] = true; + const event = new CloseEvent("close", { code, reason }); + void __privateMethod(this, _queuingDispatchToPair, queuingDispatchToPair_fn).call(this, event); + } + [kError](error) { + const event = new ErrorEvent("error", { error }); + void __privateMethod(this, _queuingDispatchToPair, queuingDispatchToPair_fn).call(this, event); + } +}; +var WebSocket = _WebSocket; +_dispatchQueue = new WeakMap(); +_queuingDispatchToPair = new WeakSet(); +queuingDispatchToPair_fn = async function(event) { + const pair = this[kPair]; + (0, import_assert2.default)(pair !== void 0); + if (pair[kAccepted]) { + pair.dispatchEvent(event); + } else { + (0, import_assert2.default)(__privateGet(pair, _dispatchQueue) !== void 0); + __privateGet(pair, _dispatchQueue).push(event); + } +}; +// The Workers runtime prefixes these constants with `READY_STATE_`, unlike +// those in the spec: https://websockets.spec.whatwg.org/#interface-definition +__publicField(WebSocket, "READY_STATE_CONNECTING", 0); +__publicField(WebSocket, "READY_STATE_OPEN", 1); +__publicField(WebSocket, "READY_STATE_CLOSING", 2); +__publicField(WebSocket, "READY_STATE_CLOSED", 3); +var WebSocketPair = function() { + if (!(this instanceof WebSocketPair)) { + throw new TypeError( + "Failed to construct 'WebSocketPair': Please use the 'new' operator, this object constructor cannot be called as a function." + ); + } + this[0] = new WebSocket(); + this[1] = new WebSocket(); + this[0][kPair] = this[1]; + this[1][kPair] = this[0]; +}; +async function coupleWebSocket(ws, pair) { + if (pair[kCoupled]) { + throw new TypeError( + "Can't return WebSocket that was already used in a response." + ); + } + if (pair[kAccepted]) { + throw new TypeError( + "Can't return WebSocket in a Response after calling accept()." + ); + } + ws.on("message", (message, isBinary) => { + if (!pair[kClosedOutgoing]) { + pair[kSend](isBinary ? viewToBuffer(message) : message.toString()); + } + }); + ws.on("close", (code, reason) => { + if (!pair[kClosedOutgoing]) { + pair[kClose](code, reason.toString()); + } + }); + ws.on("error", (error) => { + pair[kError](error); + }); + pair.addEventListener("message", (e) => { + ws.send(e.data); + }); + pair.addEventListener("close", (e) => { + if (e.code === 1005) { + ws.close(); + } else if (e.code === 1006) { + ws.terminate(); + } else { + ws.close(e.code, e.reason); + } + }); + if (ws.readyState === import_ws.default.CONNECTING) { + await (0, import_events.once)(ws, "open"); + } else if (ws.readyState >= import_ws.default.CLOSING) { + throw new TypeError("Incoming WebSocket connection already closed."); + } + pair.accept(); + pair[kCoupled] = true; +} + +// src/http/fetch.ts +var allowUnauthorizedDispatchers = /* @__PURE__ */ new WeakSet(); +function registerAllowUnauthorizedDispatcher(dispatcher) { + allowUnauthorizedDispatchers.add(dispatcher); +} +var ignored = ["transfer-encoding", "connection", "keep-alive", "expect"]; +function headersFromIncomingRequest(req) { + const entries = Object.entries(req.headers).filter( + (pair) => { + const [name, value] = pair; + return !ignored.includes(name) && value !== void 0; + } + ); + return new import_undici4.Headers(Object.fromEntries(entries)); +} +async function fetch2(input, init2) { + const requestInit = init2; + const request = new Request(input, requestInit); + if (request.method === "GET" && request.headers.get("upgrade") === "websocket") { + const url13 = new URL(request.url); + if (url13.protocol !== "http:" && url13.protocol !== "https:") { + throw new TypeError( + `Fetch API cannot load: ${url13.toString()}. +Make sure you're using http(s):// URLs for WebSocket requests via fetch.` + ); + } + url13.protocol = url13.protocol.replace("http", "ws"); + const headers = {}; + let protocols; + for (const [key, value] of request.headers.entries()) { + if (key.toLowerCase() === "sec-websocket-protocol") { + protocols = value.split(",").map((protocol) => protocol.trim()); + } else { + headers[key] = value; + } + } + const rejectUnauthorized = requestInit?.dispatcher !== void 0 && allowUnauthorizedDispatchers.has(requestInit?.dispatcher) ? { rejectUnauthorized: false } : {}; + const ws = new import_ws2.default(url13, protocols, { + followRedirects: request.redirect === "follow", + headers, + ...rejectUnauthorized + }); + const headersPromise = new DeferredPromise(); + ws.once("upgrade", (req) => { + headersPromise.resolve(headersFromIncomingRequest(req)); + }); + const [worker, client] = Object.values(new WebSocketPair()); + await coupleWebSocket(ws, client); + return new Response(null, { + status: 101, + webSocket: worker, + headers: await headersPromise + }); + } + const response = await (0, import_undici4.fetch)(request, { + dispatcher: requestInit?.dispatcher + }); + return new Response(response.body, response); +} + +// src/http/server.ts +var import_promises10 = __toESM(require("fs/promises")); + +// src/plugins/cache/index.ts +var import_promises3 = __toESM(require("fs/promises")); + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache.worker.ts +var import_fs3 = __toESM(require("fs")); +var import_path5 = __toESM(require("path")); +var import_url3 = __toESM(require("url")); +var contents3; +function cache_worker_default() { + if (contents3 !== void 0) + return contents3; + const filePath = import_path5.default.join(__dirname, "workers", "cache/cache.worker.js"); + contents3 = import_fs3.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url3.default.pathToFileURL(filePath); + return contents3; +} + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache-entry.worker.ts +var import_fs4 = __toESM(require("fs")); +var import_path6 = __toESM(require("path")); +var import_url4 = __toESM(require("url")); +var contents4; +function cache_entry_worker_default() { + if (contents4 !== void 0) + return contents4; + const filePath = import_path6.default.join(__dirname, "workers", "cache/cache-entry.worker.js"); + contents4 = import_fs4.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url4.default.pathToFileURL(filePath); + return contents4; +} + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache-entry-noop.worker.ts +var import_fs5 = __toESM(require("fs")); +var import_path7 = __toESM(require("path")); +var import_url5 = __toESM(require("url")); +var contents5; +function cache_entry_noop_worker_default() { + if (contents5 !== void 0) + return contents5; + const filePath = import_path7.default.join(__dirname, "workers", "cache/cache-entry-noop.worker.js"); + contents5 = import_fs5.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url5.default.pathToFileURL(filePath); + return contents5; +} + +// src/plugins/cache/index.ts +var import_zod5 = require("zod"); + +// src/plugins/shared/index.ts +var import_crypto = __toESM(require("crypto")); +var import_fs7 = require("fs"); +var import_promises2 = __toESM(require("fs/promises")); +var import_path9 = __toESM(require("path")); +var import_url8 = require("url"); +var import_zod4 = require("zod"); + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/shared/object-entry.worker.ts +var import_fs6 = __toESM(require("fs")); +var import_path8 = __toESM(require("path")); +var import_url6 = __toESM(require("url")); +var contents6; +function object_entry_worker_default() { + if (contents6 !== void 0) + return contents6; + const filePath = import_path8.default.join(__dirname, "workers", "shared/object-entry.worker.js"); + contents6 = import_fs6.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url6.default.pathToFileURL(filePath); + return contents6; +} + +// src/plugins/shared/constants.ts +var SOCKET_ENTRY = "entry"; +var SOCKET_DIRECT_PREFIX = "direct"; +function getDirectSocketName(workerIndex) { + return `${SOCKET_DIRECT_PREFIX}:${workerIndex}`; +} +var SERVICE_LOOPBACK = "loopback"; +var HEADER_CF_BLOB = "MF-CF-Blob"; +var WORKER_BINDING_SERVICE_LOOPBACK = { + name: CoreBindings.SERVICE_LOOPBACK, + service: { name: SERVICE_LOOPBACK } +}; +var WORKER_BINDING_ENABLE_CONTROL_ENDPOINT = { + name: SharedBindings.MAYBE_JSON_ENABLE_CONTROL_ENDPOINTS, + json: "true" +}; +var enableControlEndpoints = false; +function getControlEndpointBindings() { + if (enableControlEndpoints) + return [WORKER_BINDING_ENABLE_CONTROL_ENDPOINT]; + else + return []; +} +function _enableControlEndpoints() { + enableControlEndpoints = true; +} +function objectEntryWorker(durableObjectNamespace, namespace) { + return { + compatibilityDate: "2023-07-24", + modules: [ + { name: "object-entry.worker.js", esModule: object_entry_worker_default() } + ], + bindings: [ + { name: SharedBindings.TEXT_NAMESPACE, text: namespace }, + { + name: SharedBindings.DURABLE_OBJECT_NAMESPACE_OBJECT, + durableObjectNamespace + } + ] + }; +} + +// src/plugins/shared/routing.ts +var import_url7 = require("url"); +var RouterError = class extends MiniflareError { +}; +function routeSpecificity(url13) { + const hostParts = url13.host.split("."); + let hostScore = hostParts.length; + if (hostParts[0] === "*") + hostScore -= 2; + const pathParts = url13.pathname.split("/"); + let pathScore = pathParts.length; + if (pathParts[pathParts.length - 1] === "*") + pathScore -= 2; + return hostScore * 26 + pathScore; +} +function parseRoutes(allRoutes) { + const routes = []; + for (const [target, targetRoutes] of allRoutes) { + for (const route of targetRoutes) { + const hasProtocol = /^[a-z0-9+\-.]+:\/\//i.test(route); + let urlInput = route; + if (!hasProtocol) + urlInput = `https://${urlInput}`; + const url13 = new import_url7.URL(urlInput); + const specificity = routeSpecificity(url13); + const protocol = hasProtocol ? url13.protocol : void 0; + const internationalisedAllowHostnamePrefix = url13.hostname.startsWith("xn--*"); + const allowHostnamePrefix = url13.hostname.startsWith("*") || internationalisedAllowHostnamePrefix; + const anyHostname = url13.hostname === "*"; + if (allowHostnamePrefix && !anyHostname) { + let hostname = url13.hostname; + if (internationalisedAllowHostnamePrefix) { + hostname = (0, import_url7.domainToUnicode)(hostname); + } + url13.hostname = hostname.substring(1); + } + const allowPathSuffix = url13.pathname.endsWith("*"); + if (allowPathSuffix) { + url13.pathname = url13.pathname.substring(0, url13.pathname.length - 1); + } + if (url13.search) { + throw new RouterError( + "ERR_QUERY_STRING", + `Route "${route}" for "${target}" contains a query string. This is not allowed.` + ); + } + if (url13.toString().includes("*") && !anyHostname) { + throw new RouterError( + "ERR_INFIX_WILDCARD", + `Route "${route}" for "${target}" contains an infix wildcard. This is not allowed.` + ); + } + routes.push({ + target, + route, + specificity, + protocol, + allowHostnamePrefix, + hostname: anyHostname ? "" : url13.hostname, + path: url13.pathname, + allowPathSuffix + }); + } + } + routes.sort((a, b) => { + if (a.specificity === b.specificity) { + return b.route.length - a.route.length; + } else { + return b.specificity - a.specificity; + } + }); + return routes; +} + +// src/plugins/shared/index.ts +var DEFAULT_PERSIST_ROOT = ".mf"; +var PersistenceSchema = import_zod4.z.boolean().or(import_zod4.z.string()).optional(); +var kProxyNodeBinding = Symbol("kProxyNodeBinding"); +function namespaceKeys(namespaces) { + if (Array.isArray(namespaces)) { + return namespaces; + } else if (namespaces !== void 0) { + return Object.keys(namespaces); + } else { + return []; + } +} +function namespaceEntries(namespaces) { + if (Array.isArray(namespaces)) { + return namespaces.map((bindingName) => [bindingName, bindingName]); + } else if (namespaces !== void 0) { + return Object.entries(namespaces); + } else { + return []; + } +} +function maybeParseURL(url13) { + if (typeof url13 !== "string" || import_path9.default.isAbsolute(url13)) + return; + try { + return new URL(url13); + } catch { + } +} +function getPersistPath(pluginName, tmpPath, persist) { + const memoryishPath = import_path9.default.join(tmpPath, pluginName); + if (persist === void 0 || persist === false) { + return memoryishPath; + } + const url13 = maybeParseURL(persist); + if (url13 !== void 0) { + if (url13.protocol === "memory:") { + return memoryishPath; + } else if (url13.protocol === "file:") { + return (0, import_url8.fileURLToPath)(url13); + } + throw new MiniflareCoreError( + "ERR_PERSIST_UNSUPPORTED", + `Unsupported "${url13.protocol}" persistence protocol for storage: ${url13.href}` + ); + } + return persist === true ? import_path9.default.join(DEFAULT_PERSIST_ROOT, pluginName) : persist; +} +function durableObjectNamespaceIdFromName(uniqueKey, name) { + const key = import_crypto.default.createHash("sha256").update(uniqueKey).digest(); + const nameHmac = import_crypto.default.createHmac("sha256", key).update(name).digest().subarray(0, 16); + const hmac = import_crypto.default.createHmac("sha256", key).update(nameHmac).digest().subarray(0, 16); + return Buffer.concat([nameHmac, hmac]).toString("hex"); +} +async function migrateDatabase(log, uniqueKey, persistPath, namespace) { + const sanitisedNamespace = sanitisePath(namespace); + const previousDir = import_path9.default.join(persistPath, sanitisedNamespace); + const previousPath = import_path9.default.join(previousDir, "db.sqlite"); + const previousWalPath = import_path9.default.join(previousDir, "db.sqlite-wal"); + if (!(0, import_fs7.existsSync)(previousPath)) + return; + const id = durableObjectNamespaceIdFromName(uniqueKey, namespace); + const newDir = import_path9.default.join(persistPath, uniqueKey); + const newPath = import_path9.default.join(newDir, `${id}.sqlite`); + const newWalPath = import_path9.default.join(newDir, `${id}.sqlite-wal`); + if ((0, import_fs7.existsSync)(newPath)) { + log.debug( + `Not migrating ${previousPath} to ${newPath} as it already exists` + ); + return; + } + log.debug(`Migrating ${previousPath} to ${newPath}...`); + await import_promises2.default.mkdir(newDir, { recursive: true }); + try { + await import_promises2.default.copyFile(previousPath, newPath); + if ((0, import_fs7.existsSync)(previousWalPath)) { + await import_promises2.default.copyFile(previousWalPath, newWalPath); + } + await import_promises2.default.unlink(previousPath); + await import_promises2.default.unlink(previousWalPath); + } catch (e) { + log.warn(`Error migrating ${previousPath} to ${newPath}: ${e}`); + } +} + +// src/plugins/cache/index.ts +var CacheOptionsSchema = import_zod5.z.object({ + cache: import_zod5.z.boolean().optional(), + cacheWarnUsage: import_zod5.z.boolean().optional() +}); +var CacheSharedOptionsSchema = import_zod5.z.object({ + cachePersist: PersistenceSchema +}); +var CACHE_PLUGIN_NAME = "cache"; +var CACHE_STORAGE_SERVICE_NAME = `${CACHE_PLUGIN_NAME}:storage`; +var CACHE_SERVICE_PREFIX = `${CACHE_PLUGIN_NAME}:cache`; +var CACHE_OBJECT_CLASS_NAME = "CacheObject"; +var CACHE_OBJECT = { + serviceName: CACHE_SERVICE_PREFIX, + className: CACHE_OBJECT_CLASS_NAME +}; +function getCacheServiceName(workerIndex) { + return `${CACHE_PLUGIN_NAME}:${workerIndex}`; +} +var CACHE_PLUGIN = { + options: CacheOptionsSchema, + sharedOptions: CacheSharedOptionsSchema, + getBindings() { + return []; + }, + getNodeBindings() { + return {}; + }, + async getServices({ sharedOptions, options, workerIndex, tmpPath }) { + const cache = options.cache ?? true; + const cacheWarnUsage = options.cacheWarnUsage ?? false; + let entryWorker; + if (cache) { + entryWorker = { + compatibilityDate: "2023-07-24", + compatibilityFlags: ["nodejs_compat", "experimental"], + modules: [ + { name: "cache-entry.worker.js", esModule: cache_entry_worker_default() } + ], + bindings: [ + { + name: SharedBindings.DURABLE_OBJECT_NAMESPACE_OBJECT, + durableObjectNamespace: CACHE_OBJECT + }, + { + name: CacheBindings.MAYBE_JSON_CACHE_WARN_USAGE, + json: JSON.stringify(cacheWarnUsage) + } + ] + }; + } else { + entryWorker = { + compatibilityDate: "2023-07-24", + compatibilityFlags: ["nodejs_compat", "experimental"], + modules: [ + { + name: "cache-entry-noop.worker.js", + esModule: cache_entry_noop_worker_default() + } + ] + }; + } + const services = [ + { name: getCacheServiceName(workerIndex), worker: entryWorker } + ]; + if (cache) { + const uniqueKey = `miniflare-${CACHE_OBJECT_CLASS_NAME}`; + const persist = sharedOptions.cachePersist; + const persistPath = getPersistPath(CACHE_PLUGIN_NAME, tmpPath, persist); + await import_promises3.default.mkdir(persistPath, { recursive: true }); + const storageService = { + name: CACHE_STORAGE_SERVICE_NAME, + disk: { path: persistPath, writable: true } + }; + const objectService = { + name: CACHE_SERVICE_PREFIX, + worker: { + compatibilityDate: "2023-07-24", + compatibilityFlags: ["nodejs_compat", "experimental"], + modules: [ + { + name: "cache.worker.js", + esModule: cache_worker_default() + } + ], + durableObjectNamespaces: [ + { + className: CACHE_OBJECT_CLASS_NAME, + uniqueKey + } + ], + // Store Durable Object SQL databases in persist path + durableObjectStorage: { localDisk: CACHE_STORAGE_SERVICE_NAME }, + // Bind blob disk directory service to object + bindings: [ + { + name: SharedBindings.MAYBE_SERVICE_BLOBS, + service: { name: CACHE_STORAGE_SERVICE_NAME } + }, + { + name: SharedBindings.MAYBE_SERVICE_LOOPBACK, + service: { name: SERVICE_LOOPBACK } + }, + ...getControlEndpointBindings() + ] + } + }; + services.push(storageService, objectService); + } + return services; + } +}; + +// src/plugins/core/index.ts +var import_assert8 = __toESM(require("assert")); +var import_fs11 = require("fs"); +var import_promises5 = __toESM(require("fs/promises")); +var import_path13 = __toESM(require("path")); +var import_stream2 = require("stream"); +var import_tls = __toESM(require("tls")); +var import_util3 = require("util"); +var import_undici7 = require("undici"); + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/core/entry.worker.ts +var import_fs8 = __toESM(require("fs")); +var import_path10 = __toESM(require("path")); +var import_url9 = __toESM(require("url")); +var contents7; +function entry_worker_default() { + if (contents7 !== void 0) + return contents7; + const filePath = import_path10.default.join(__dirname, "workers", "core/entry.worker.js"); + contents7 = import_fs8.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url9.default.pathToFileURL(filePath); + return contents7; +} + +// src/plugins/core/index.ts +var import_zod11 = require("zod"); + +// src/runtime/index.ts +var import_assert3 = __toESM(require("assert")); +var import_child_process = __toESM(require("child_process")); +var import_events2 = require("events"); +var import_readline = __toESM(require("readline")); +var import_stream = require("stream"); +var import_workerd2 = __toESM(require("workerd")); +var import_zod6 = require("zod"); + +// src/runtime/config/index.ts +var import_capnp_ts = require("capnp-ts"); + +// src/runtime/config/workerd.ts +var import_workerd_capnp = __toESM(require_workerd_capnp()); +var kVoid = Symbol("kVoid"); + +// src/runtime/config/index.ts +var import_workerd_capnp2 = __toESM(require_workerd_capnp()); +function capitalize(str) { + return str.length > 0 ? str[0].toUpperCase() + str.substring(1) : str; +} +function encodeCapnpStruct(obj, struct) { + const anyStruct = struct; + for (const [key, value] of Object.entries(obj)) { + const capitalized = capitalize(key); + if (value instanceof Uint8Array) { + const newData = anyStruct[`init${capitalized}`](value.byteLength); + newData.copyBuffer(value); + } else if (Array.isArray(value)) { + const newList = anyStruct[`init${capitalized}`](value.length); + for (let i = 0; i < value.length; i++) { + if (typeof value[i] === "object") { + encodeCapnpStruct(value[i], newList.get(i)); + } else { + newList.set(i, value[i]); + } + } + } else if (typeof value === "object") { + const newStruct = anyStruct[`init${capitalized}`](); + encodeCapnpStruct(value, newStruct); + } else if (value === kVoid) { + anyStruct[`set${capitalized}`](); + } else if (value !== void 0) { + anyStruct[`set${capitalized}`](value); + } + } +} +function serializeConfig(config) { + const message = new import_capnp_ts.Message(); + const struct = message.initRoot(import_workerd_capnp2.Config); + encodeCapnpStruct(config, struct); + return Buffer.from(message.toArrayBuffer()); +} + +// src/runtime/index.ts +var ControlMessageSchema = import_zod6.z.discriminatedUnion("event", [ + import_zod6.z.object({ + event: import_zod6.z.literal("listen"), + socket: import_zod6.z.string(), + port: import_zod6.z.number() + }), + import_zod6.z.object({ + event: import_zod6.z.literal("listen-inspector"), + port: import_zod6.z.number() + }) +]); +var kInspectorSocket = Symbol("kInspectorSocket"); +async function waitForPorts(stream, options) { + if (options?.signal?.aborted) + return; + const lines = import_readline.default.createInterface(stream); + const abortListener = () => lines.close(); + options?.signal?.addEventListener("abort", abortListener, { once: true }); + const requiredSockets = Array.from(options.requiredSockets); + const socketPorts = /* @__PURE__ */ new Map(); + try { + for await (const line of lines) { + const message = ControlMessageSchema.safeParse(JSON.parse(line)); + if (!message.success) + continue; + const data = message.data; + const socket = data.event === "listen-inspector" ? kInspectorSocket : data.socket; + const index = requiredSockets.indexOf(socket); + if (index === -1) + continue; + socketPorts.set(socket, data.port); + requiredSockets.splice(index, 1); + if (requiredSockets.length === 0) + return socketPorts; + } + } finally { + options?.signal?.removeEventListener("abort", abortListener); + } +} +function waitForExit(process2) { + return new Promise((resolve) => { + process2.once("exit", () => resolve()); + }); +} +function pipeOutput(stdout, stderr) { + import_readline.default.createInterface(stdout).on("line", (data) => console.log(data)); + import_readline.default.createInterface(stderr).on("line", (data) => console.error(red(data))); +} +function getRuntimeCommand() { + return process.env.MINIFLARE_WORKERD_PATH ?? import_workerd2.default; +} +function getRuntimeArgs(options) { + const args = [ + "serve", + // Required to use binary capnp config + "--binary", + // Required to use compatibility flags without a default-on date, + // (e.g. "streams_enable_constructors"), see https://github.com/cloudflare/workerd/pull/21 + "--experimental", + `--socket-addr=${SOCKET_ENTRY}=${options.entryAddress}`, + `--external-addr=${SERVICE_LOOPBACK}=localhost:${options.loopbackPort}`, + // Configure extra pipe for receiving control messages (e.g. when ready) + "--control-fd=3", + // Read config from stdin + "-" + ]; + if (options.inspectorAddress !== void 0) { + args.push(`--inspector-addr=${options.inspectorAddress}`); + } + if (options.verbose) { + args.push("--verbose"); + } + return args; +} +var Runtime = class { + #process; + #processExitPromise; + async updateConfig(configBuffer, options) { + await this.dispose(); + const command = getRuntimeCommand(); + const args = getRuntimeArgs(options); + const FORCE_COLOR2 = $.enabled ? "1" : "0"; + const runtimeProcess = import_child_process.default.spawn(command, args, { + stdio: ["pipe", "pipe", "pipe", "pipe"], + env: { ...process.env, FORCE_COLOR: FORCE_COLOR2 } + }); + this.#process = runtimeProcess; + this.#processExitPromise = waitForExit(runtimeProcess); + const handleRuntimeStdio = options.handleRuntimeStdio ?? pipeOutput; + handleRuntimeStdio(runtimeProcess.stdout, runtimeProcess.stderr); + const controlPipe = runtimeProcess.stdio[3]; + (0, import_assert3.default)(controlPipe instanceof import_stream.Readable); + runtimeProcess.stdin.write(configBuffer); + runtimeProcess.stdin.end(); + await (0, import_events2.once)(runtimeProcess.stdin, "finish"); + return waitForPorts(controlPipe, options); + } + dispose() { + this.#process?.kill("SIGKILL"); + return this.#processExitPromise; + } +}; + +// src/plugins/do/index.ts +var import_promises4 = __toESM(require("fs/promises")); +var import_zod7 = require("zod"); +var DurableObjectsOptionsSchema = import_zod7.z.object({ + durableObjects: import_zod7.z.record( + import_zod7.z.union([ + import_zod7.z.string(), + import_zod7.z.object({ + className: import_zod7.z.string(), + scriptName: import_zod7.z.string().optional(), + // Allow `uniqueKey` to be customised. We use in Wrangler when setting + // up stub Durable Objects that proxy requests to Durable Objects in + // another `workerd` process, to ensure the IDs created by the stub + // object can be used by the real object too. + unsafeUniqueKey: import_zod7.z.string().optional(), + // Prevents the Durable Object being evicted. + unsafePreventEviction: import_zod7.z.boolean().optional() + }) + ]) + ).optional() +}); +var DurableObjectsSharedOptionsSchema = import_zod7.z.object({ + durableObjectsPersist: PersistenceSchema +}); +function normaliseDurableObject(designator) { + const isObject = typeof designator === "object"; + const className = isObject ? designator.className : designator; + const serviceName = isObject && designator.scriptName !== void 0 ? getUserServiceName(designator.scriptName) : void 0; + const unsafeUniqueKey = isObject ? designator.unsafeUniqueKey : void 0; + const unsafePreventEviction = isObject ? designator.unsafePreventEviction : void 0; + return { className, serviceName, unsafeUniqueKey, unsafePreventEviction }; +} +var DURABLE_OBJECTS_PLUGIN_NAME = "do"; +var DURABLE_OBJECTS_STORAGE_SERVICE_NAME = `${DURABLE_OBJECTS_PLUGIN_NAME}:storage`; +var DURABLE_OBJECTS_PLUGIN = { + options: DurableObjectsOptionsSchema, + sharedOptions: DurableObjectsSharedOptionsSchema, + getBindings(options) { + return Object.entries(options.durableObjects ?? {}).map( + ([name, klass]) => { + const { className, serviceName } = normaliseDurableObject(klass); + return { + name, + durableObjectNamespace: { className, serviceName } + }; + } + ); + }, + getNodeBindings(options) { + const objects = Object.keys(options.durableObjects ?? {}); + return Object.fromEntries(objects.map((name) => [name, kProxyNodeBinding])); + }, + async getServices({ + sharedOptions, + tmpPath, + durableObjectClassNames, + unsafeEphemeralDurableObjects + }) { + let hasDurableObjects = false; + for (const classNames of durableObjectClassNames.values()) { + if (classNames.size > 0) { + hasDurableObjects = true; + break; + } + } + if (!hasDurableObjects) + return; + if (unsafeEphemeralDurableObjects) + return; + const storagePath = getPersistPath( + DURABLE_OBJECTS_PLUGIN_NAME, + tmpPath, + sharedOptions.durableObjectsPersist + ); + await import_promises4.default.mkdir(storagePath, { recursive: true }); + return [ + { + // Note this service will be de-duped by name if multiple Workers create + // it. Each Worker will have the same `sharedOptions` though, so this + // isn't a problem. + name: DURABLE_OBJECTS_STORAGE_SERVICE_NAME, + disk: { path: storagePath, writable: true } + } + ]; + } +}; + +// src/plugins/core/constants.ts +var CORE_PLUGIN_NAME = "core"; +var SERVICE_ENTRY = `${CORE_PLUGIN_NAME}:entry`; +var SERVICE_USER_PREFIX = `${CORE_PLUGIN_NAME}:user`; +var SERVICE_BUILTIN_PREFIX = `${CORE_PLUGIN_NAME}:builtin`; +var SERVICE_CUSTOM_PREFIX = `${CORE_PLUGIN_NAME}:custom`; +function getUserServiceName(workerName = "") { + return `${SERVICE_USER_PREFIX}:${workerName}`; +} +var CUSTOM_SERVICE_KNOWN_OUTBOUND = "outbound"; +function getBuiltinServiceName(workerIndex, kind, bindingName) { + return `${SERVICE_BUILTIN_PREFIX}:${workerIndex}:${kind}${bindingName}`; +} +function getCustomServiceName(workerIndex, kind, bindingName) { + return `${SERVICE_CUSTOM_PREFIX}:${workerIndex}:${kind}${bindingName}`; +} + +// src/plugins/core/modules.ts +var import_assert4 = __toESM(require("assert")); +var import_fs9 = require("fs"); +var import_module = require("module"); +var import_path11 = __toESM(require("path")); +var import_url10 = require("url"); +var import_util = require("util"); +var import_acorn = require("acorn"); +var import_acorn_walk = require("acorn-walk"); +var import_zod8 = require("zod"); +var SUGGEST_BUNDLE = "If you're trying to import an npm package, you'll need to bundle your Worker first."; +var SUGGEST_NODE = "If you're trying to import a Node.js built-in module, or an npm package that uses Node.js built-ins, you'll either need to:\n- Bundle your Worker, configuring your bundler to polyfill Node.js built-ins\n- Configure your bundler to load Workers-compatible builds by changing the main fields/conditions\n- Enable the `nodejs_compat` compatibility flag and use the `NodeJsCompatModule` module type\n- Find an alternative package that doesn't require Node.js built-ins"; +var builtinModulesWithPrefix = import_module.builtinModules.concat( + import_module.builtinModules.map((module2) => `node:${module2}`) +); +function buildStringScriptPath(workerIndex) { + return `script:${workerIndex}`; +} +var stringScriptRegexp = /^script:(\d+)$/; +function maybeGetStringScriptPathIndex(scriptPath) { + const match = stringScriptRegexp.exec(scriptPath); + return match === null ? void 0 : parseInt(match[1]); +} +var ModuleRuleTypeSchema = import_zod8.z.enum([ + "ESModule", + "CommonJS", + "NodeJsCompatModule", + "Text", + "Data", + "CompiledWasm" +]); +var ModuleRuleSchema = import_zod8.z.object({ + type: ModuleRuleTypeSchema, + include: import_zod8.z.string().array(), + fallthrough: import_zod8.z.boolean().optional() +}); +var ModuleDefinitionSchema = import_zod8.z.object({ + type: ModuleRuleTypeSchema, + path: import_zod8.z.string(), + contents: import_zod8.z.string().or(import_zod8.z.instanceof(Uint8Array)).optional() +}); +var SourceOptionsSchema = import_zod8.z.union([ + import_zod8.z.object({ + // Manually defined modules + // (used by Wrangler which has its own module collection code) + modules: import_zod8.z.array(ModuleDefinitionSchema), + // `modules` "name"s will be their paths relative to this value. + // This ensures file paths in stack traces are correct. + modulesRoot: import_zod8.z.string().optional() + }), + import_zod8.z.object({ + script: import_zod8.z.string(), + // Optional script path for resolving modules, and stack traces file names + scriptPath: import_zod8.z.string().optional(), + // Automatically collect modules by parsing `script` if `true`, or treat as + // service-worker if `false` + modules: import_zod8.z.boolean().optional(), + // How to interpret automatically collected modules + modulesRules: import_zod8.z.array(ModuleRuleSchema).optional(), + // `modules` "name"s will be their paths relative to this value. + // This ensures file paths in stack traces are correct. + modulesRoot: import_zod8.z.string().optional() + }), + import_zod8.z.object({ + scriptPath: import_zod8.z.string(), + // Automatically collect modules by parsing `scriptPath` if `true`, or treat + // as service-worker if `false` + modules: import_zod8.z.boolean().optional(), + // How to interpret automatically collected modules + modulesRules: import_zod8.z.array(ModuleRuleSchema).optional(), + // `modules` "name"s will be their paths relative to this value. + // This ensures file paths in stack traces are correct. + modulesRoot: import_zod8.z.string().optional() + }) +]); +var DEFAULT_MODULE_RULES = [ + { type: "ESModule", include: ["**/*.mjs"] }, + { type: "CommonJS", include: ["**/*.js", "**/*.cjs"] } +]; +function compileModuleRules(rules) { + const compiledRules = []; + const finalisedTypes = /* @__PURE__ */ new Set(); + for (const rule of [...rules ?? [], ...DEFAULT_MODULE_RULES]) { + if (finalisedTypes.has(rule.type)) + continue; + compiledRules.push({ + type: rule.type, + include: globsToRegExps(rule.include) + }); + if (!rule.fallthrough) + finalisedTypes.add(rule.type); + } + return compiledRules; +} +function moduleName(modulesRoot, modulePath) { + const name = import_path11.default.relative(modulesRoot, modulePath); + return import_path11.default.sep === "\\" ? name.replaceAll("\\", "/") : name; +} +function withSourceURL(script, scriptPath) { + if (script.lastIndexOf("//# sourceURL=") !== -1) + return script; + let scriptURL = scriptPath; + if (maybeGetStringScriptPathIndex(scriptPath) === void 0) { + scriptURL = (0, import_url10.pathToFileURL)(scriptPath); + } + const sourceURL = ` +//# sourceURL=${scriptURL} +`; + return script + sourceURL; +} +function getResolveErrorPrefix(referencingPath) { + const relative = import_path11.default.relative("", referencingPath); + return `Unable to resolve "${relative}" dependency`; +} +var ModuleLocator = class { + constructor(modulesRoot, additionalModuleNames, rules, compatibilityFlags) { + this.modulesRoot = modulesRoot; + this.additionalModuleNames = additionalModuleNames; + this.#compiledRules = compileModuleRules(rules); + this.#nodejsCompat = compatibilityFlags?.includes("nodejs_compat") ?? false; + } + #compiledRules; + #nodejsCompat; + #visitedPaths = /* @__PURE__ */ new Set(); + modules = []; + visitEntrypoint(code, modulePath) { + modulePath = import_path11.default.resolve(this.modulesRoot, modulePath); + if (this.#visitedPaths.has(modulePath)) + return; + this.#visitedPaths.add(modulePath); + this.#visitJavaScriptModule(code, modulePath, "ESModule"); + } + #visitJavaScriptModule(code, modulePath, type) { + const name = moduleName(this.modulesRoot, modulePath); + const module2 = createJavaScriptModule(code, name, modulePath, type); + this.modules.push(module2); + const isESM = type === "ESModule"; + let root; + try { + root = (0, import_acorn.parse)(code, { + ecmaVersion: "latest", + sourceType: isESM ? "module" : "script", + locations: true + }); + } catch (e) { + let loc = ""; + if (e.loc?.line !== void 0) { + loc += `:${e.loc.line}`; + if (e.loc.column !== void 0) + loc += `:${e.loc.column}`; + } + throw new MiniflareCoreError( + "ERR_MODULE_PARSE", + `Unable to parse "${name}": ${e.message ?? e} + at ${modulePath}${loc}` + ); + } + const visitors = { + ImportDeclaration: (node) => { + this.#visitModule(modulePath, name, type, node.source); + }, + ExportNamedDeclaration: (node) => { + if (node.source != null) { + this.#visitModule(modulePath, name, type, node.source); + } + }, + ExportAllDeclaration: (node) => { + this.#visitModule(modulePath, name, type, node.source); + }, + ImportExpression: (node) => { + this.#visitModule(modulePath, name, type, node.source); + }, + CallExpression: isESM ? void 0 : (node) => { + const argument = node.arguments[0]; + if (node.callee.type === "Identifier" && node.callee.name === "require" && argument !== void 0) { + this.#visitModule(modulePath, name, type, argument); + } + } + }; + (0, import_acorn_walk.simple)(root, visitors); + } + #visitModule(referencingPath, referencingName, referencingType, specExpression) { + if (maybeGetStringScriptPathIndex(referencingName) !== void 0) { + const prefix = getResolveErrorPrefix(referencingPath); + throw new MiniflareCoreError( + "ERR_MODULE_STRING_SCRIPT", + `${prefix}: imports are unsupported in string \`script\` without defined \`scriptPath\`` + ); + } + if (specExpression.type !== "Literal" || typeof specExpression.value !== "string") { + const modules = this.modules.map((mod) => { + const def = convertWorkerModule(mod); + return ` { type: "${def.type}", path: "${def.path}" }`; + }); + const modulesConfig = ` new Miniflare({ + ..., + modules: [ +${modules.join(",\n")}, + ... + ] + })`; + const prefix = getResolveErrorPrefix(referencingPath); + let message = `${prefix}: dynamic module specifiers are unsupported. +You must manually define your modules when constructing Miniflare: +${dim(modulesConfig)}`; + if (specExpression.loc != null) { + const { line, column } = specExpression.loc.start; + message += ` + at ${referencingPath}:${line}:${column}`; + } + throw new MiniflareCoreError("ERR_MODULE_DYNAMIC_SPEC", message); + } + const spec = specExpression.value; + const isNodeJsCompatModule = referencingType === "NodeJsCompatModule"; + if (this.#nodejsCompat && spec.startsWith("node:") || spec.startsWith("cloudflare:") || spec.startsWith("workerd:") || isNodeJsCompatModule && builtinModulesWithPrefix.includes(spec) || this.additionalModuleNames.includes(spec)) { + return; + } + const identifier = import_path11.default.resolve(import_path11.default.dirname(referencingPath), spec); + const name = moduleName(this.modulesRoot, identifier); + if (this.#visitedPaths.has(identifier)) + return; + this.#visitedPaths.add(identifier); + const rule = this.#compiledRules.find( + (rule2) => testRegExps(rule2.include, identifier) + ); + if (rule === void 0) { + const prefix = getResolveErrorPrefix(referencingPath); + const isBuiltin = builtinModulesWithPrefix.includes(spec); + const suggestion = isBuiltin ? SUGGEST_NODE : SUGGEST_BUNDLE; + throw new MiniflareCoreError( + "ERR_MODULE_RULE", + `${prefix} "${spec}": no matching module rules. +${suggestion}` + ); + } + const data = (0, import_fs9.readFileSync)(identifier); + switch (rule.type) { + case "ESModule": + case "CommonJS": + case "NodeJsCompatModule": + const code = data.toString("utf8"); + this.#visitJavaScriptModule(code, identifier, rule.type); + break; + case "Text": + this.modules.push({ name, text: data.toString("utf8") }); + break; + case "Data": + this.modules.push({ name, data }); + break; + case "CompiledWasm": + this.modules.push({ name, wasm: data }); + break; + default: + const exhaustive = rule.type; + import_assert4.default.fail(`Unreachable: ${exhaustive} modules are unsupported`); + } + } +}; +function createJavaScriptModule(code, name, modulePath, type) { + code = withSourceURL(code, modulePath); + if (type === "ESModule") { + return { name, esModule: code }; + } else if (type === "CommonJS") { + return { name, commonJsModule: code }; + } else if (type === "NodeJsCompatModule") { + return { name, nodeJsCompatModule: code }; + } + const exhaustive = type; + import_assert4.default.fail(`Unreachable: ${exhaustive} JavaScript modules are unsupported`); +} +var encoder = new import_util.TextEncoder(); +var decoder = new import_util.TextDecoder(); +function contentsToString(contents13) { + return typeof contents13 === "string" ? contents13 : decoder.decode(contents13); +} +function contentsToArray(contents13) { + return typeof contents13 === "string" ? encoder.encode(contents13) : contents13; +} +function convertModuleDefinition(modulesRoot, def) { + const name = moduleName(modulesRoot, def.path); + const contents13 = def.contents ?? (0, import_fs9.readFileSync)(def.path); + switch (def.type) { + case "ESModule": + case "CommonJS": + case "NodeJsCompatModule": + return createJavaScriptModule( + contentsToString(contents13), + name, + import_path11.default.resolve(modulesRoot, def.path), + def.type + ); + case "Text": + return { name, text: contentsToString(contents13) }; + case "Data": + return { name, data: contentsToArray(contents13) }; + case "CompiledWasm": + return { name, wasm: contentsToArray(contents13) }; + default: + const exhaustive = def.type; + import_assert4.default.fail(`Unreachable: ${exhaustive} modules are unsupported`); + } +} +function convertWorkerModule(mod) { + const path21 = mod.name; + (0, import_assert4.default)(path21 !== void 0); + const m = mod; + if ("esModule" in m) + return { path: path21, type: "ESModule" }; + else if ("commonJsModule" in m) + return { path: path21, type: "CommonJS" }; + else if ("nodeJsCompatModule" in m) + return { path: path21, type: "NodeJsCompatModule" }; + else if ("text" in m) + return { path: path21, type: "Text" }; + else if ("data" in m) + return { path: path21, type: "Data" }; + else if ("wasm" in m) + return { path: path21, type: "CompiledWasm" }; + (0, import_assert4.default)(!("json" in m), "Unreachable: json modules aren't generated"); + const exhaustive = m; + import_assert4.default.fail( + `Unreachable: [${Object.keys(exhaustive).join( + ", " + )}] modules are unsupported` + ); +} + +// src/plugins/core/proxy/client.ts +var import_assert7 = __toESM(require("assert")); +var import_crypto2 = __toESM(require("crypto")); +var import_web4 = require("stream/web"); +var import_util2 = __toESM(require("util")); +var import_undici6 = require("undici"); + +// src/plugins/core/proxy/fetch-sync.ts +var import_assert6 = __toESM(require("assert")); +var import_web2 = require("stream/web"); +var import_worker_threads = require("worker_threads"); + +// src/plugins/core/errors/index.ts +var import_fs10 = __toESM(require("fs")); +var import_path12 = __toESM(require("path")); +var import_url11 = require("url"); +var import_zod9 = require("zod"); + +// src/plugins/core/errors/sourcemap.ts +var import_assert5 = __toESM(require("assert")); + +// src/plugins/core/errors/callsite.ts +function parseStack(stack) { + return stack.split("\n").slice(1).map(parseCallSite).filter((site) => site !== void 0); +} +function parseCallSite(line) { + const lineMatch = line.match( + /at (?:(.+?)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/ + ); + if (!lineMatch) { + return; + } + let object = null; + let method = null; + let functionName = null; + let typeName = null; + let methodName = null; + const isNative = lineMatch[5] === "native"; + if (lineMatch[1]) { + functionName = lineMatch[1]; + let methodStart = functionName.lastIndexOf("."); + if (functionName[methodStart - 1] == ".") + methodStart--; + if (methodStart > 0) { + object = functionName.substring(0, methodStart); + method = functionName.substring(methodStart + 1); + const objectEnd = object.indexOf(".Module"); + if (objectEnd > 0) { + functionName = functionName.substring(objectEnd + 1); + object = object.substring(0, objectEnd); + } + } + } + if (method) { + typeName = object; + methodName = method; + } + if (method === "") { + methodName = null; + functionName = null; + } + return new CallSite({ + typeName, + functionName, + methodName, + fileName: lineMatch[2] || null, + lineNumber: parseInt(lineMatch[3]) || null, + columnNumber: parseInt(lineMatch[4]) || null, + native: isNative + }); +} +var CallSite = class { + constructor(opts) { + this.opts = opts; + } + getThis() { + return null; + } + getTypeName() { + return this.opts.typeName; + } + // eslint-disable-next-line @typescript-eslint/ban-types + getFunction() { + return void 0; + } + getFunctionName() { + return this.opts.functionName; + } + getMethodName() { + return this.opts.methodName; + } + getFileName() { + return this.opts.fileName ?? void 0; + } + getScriptNameOrSourceURL() { + return this.opts.fileName; + } + getLineNumber() { + return this.opts.lineNumber; + } + getColumnNumber() { + return this.opts.columnNumber; + } + getEvalOrigin() { + return void 0; + } + isToplevel() { + return false; + } + isEval() { + return false; + } + isNative() { + return this.opts.native; + } + isConstructor() { + return false; + } + isAsync() { + return false; + } + isPromiseAll() { + return false; + } + isPromiseAny() { + return false; + } + getPromiseIndex() { + return null; + } +}; + +// src/plugins/core/errors/sourcemap.ts +var sourceMapInstallBaseOptions = { + environment: "node", + // Don't add Node `uncaughtException` handler + handleUncaughtExceptions: false, + // Don't hook Node `require` function + hookRequire: false, + // Make sure we're using fresh copies of files (i.e. between `setOptions()`) + emptyCacheBetweenOperations: true, + // Always remove existing retrievers when calling `install()`, we should be + // specifying them each time we want to source map + overrideRetrieveFile: true, + overrideRetrieveSourceMap: true +}; +var sourceMapper; +function getSourceMapper() { + if (sourceMapper !== void 0) + return sourceMapper; + const originalSupport = require.cache["source-map-support"]; + delete require.cache["source-map-support"]; + const support = require("source-map-support"); + require.cache["source-map-support"] = originalSupport; + const originalPrepareStackTrace = Error.prepareStackTrace; + support.install(sourceMapInstallBaseOptions); + const prepareStackTrace = Error.prepareStackTrace; + (0, import_assert5.default)(prepareStackTrace !== void 0); + Error.prepareStackTrace = originalPrepareStackTrace; + sourceMapper = (retrieveSourceMap, error) => { + support.install({ + ...sourceMapInstallBaseOptions, + retrieveFile(file) { + import_assert5.default.fail(`Unexpected retrieveFile(${JSON.stringify(file)}) call`); + }, + retrieveSourceMap + }); + const callSites = parseStack(error.stack ?? ""); + return prepareStackTrace(error, callSites); + }; + return sourceMapper; +} + +// src/plugins/core/errors/index.ts +function maybeGetDiskFile(filePath) { + try { + const contents13 = import_fs10.default.readFileSync(filePath, "utf8"); + return { path: filePath, contents: contents13 }; + } catch (e) { + if (e.code !== "ENOENT") + throw e; + } +} +function maybeGetFile(workerSrcOpts, fileSpecifier) { + const maybeUrl = maybeParseURL(fileSpecifier); + if (maybeUrl !== void 0 && maybeUrl.protocol === "file:") { + const filePath = (0, import_url11.fileURLToPath)(maybeUrl); + for (const srcOpts of workerSrcOpts) { + if (Array.isArray(srcOpts.modules)) { + const modulesRoot = srcOpts.modulesRoot ?? ""; + for (const module2 of srcOpts.modules) { + if (module2.contents !== void 0 && import_path12.default.resolve(modulesRoot, module2.path) === filePath) { + const contents13 = contentsToString(module2.contents); + return { path: filePath, contents: contents13 }; + } + } + } else if ("script" in srcOpts && "scriptPath" in srcOpts && srcOpts.script !== void 0 && srcOpts.scriptPath !== void 0) { + const modulesRoot = srcOpts.modules && srcOpts.modulesRoot || ""; + if (import_path12.default.resolve(modulesRoot, srcOpts.scriptPath) === filePath) { + return { path: filePath, contents: srcOpts.script }; + } + } + } + return maybeGetDiskFile(filePath); + } + const workerIndex = maybeGetStringScriptPathIndex(fileSpecifier); + if (workerIndex !== void 0) { + const srcOpts = workerSrcOpts[workerIndex]; + if ("script" in srcOpts && srcOpts.script !== void 0) { + return { contents: srcOpts.script }; + } + } +} +function getSourceMappedStack(workerSrcOpts, error) { + function retrieveSourceMap(fileSpecifier) { + const sourceFile = maybeGetFile(workerSrcOpts, fileSpecifier); + if (sourceFile?.path === void 0) + return null; + const sourceMapRegexp = /# sourceMappingURL=(.+)/g; + const matches = [...sourceFile.contents.matchAll(sourceMapRegexp)]; + if (matches.length === 0) + return null; + const sourceMapMatch = matches[matches.length - 1]; + const root = import_path12.default.dirname(sourceFile.path); + const sourceMapPath = import_path12.default.resolve(root, sourceMapMatch[1]); + const sourceMapFile = maybeGetDiskFile(sourceMapPath); + if (sourceMapFile === void 0) + return null; + return { map: sourceMapFile.contents, url: sourceMapFile.path }; + } + return getSourceMapper()(retrieveSourceMap, error); +} +var JsonErrorSchema = import_zod9.z.lazy( + () => import_zod9.z.object({ + message: import_zod9.z.string().optional(), + name: import_zod9.z.string().optional(), + stack: import_zod9.z.string().optional(), + cause: JsonErrorSchema.optional() + }) +); +var ALLOWED_ERROR_SUBCLASS_CONSTRUCTORS = [ + EvalError, + RangeError, + ReferenceError, + SyntaxError, + TypeError, + URIError +]; +function reviveError(workerSrcOpts, jsonError) { + let cause; + if (jsonError.cause !== void 0) { + cause = reviveError(workerSrcOpts, jsonError.cause); + } + let ctor = Error; + if (jsonError.name !== void 0 && jsonError.name in globalThis) { + const maybeCtor = globalThis[jsonError.name]; + if (ALLOWED_ERROR_SUBCLASS_CONSTRUCTORS.includes(maybeCtor)) { + ctor = maybeCtor; + } + } + const error = new ctor(jsonError.message, { cause }); + if (jsonError.name !== void 0) + error.name = jsonError.name; + error.stack = jsonError.stack; + error.stack = getSourceMappedStack(workerSrcOpts, error); + return error; +} +async function handlePrettyErrorRequest(log, workerSrcOpts, request) { + const caught = JsonErrorSchema.parse(await request.json()); + const error = reviveError(workerSrcOpts, caught); + log.error(error); + const accept = request.headers.get("Accept")?.toLowerCase() ?? ""; + const userAgent = request.headers.get("User-Agent")?.toLowerCase() ?? ""; + const acceptsPrettyError = !userAgent.includes("curl/") && (accept.includes("text/html") || accept.includes("*/*") || accept.includes("text/*")); + if (!acceptsPrettyError) { + return new Response(error.stack, { status: 500 }); + } + const Youch = require("youch"); + const youch = new Youch(error.cause ?? error, { + url: request.url, + method: request.method, + headers: Object.fromEntries(request.headers) + }); + youch.addLink(() => { + return [ + '\u{1F4DA} Workers Docs', + '\u{1F4AC} Workers Discord' + ].join(""); + }); + return new Response(await youch.toHTML(), { + status: 500, + headers: { "Content-Type": "text/html;charset=utf-8" } + }); +} + +// src/plugins/core/proxy/fetch-sync.ts +var DECODER = new TextDecoder(); +var WORKER_SCRIPT = ( + /* javascript */ + ` +const { createRequire } = require("module"); +const { workerData } = require("worker_threads"); + +// Not using parentPort here so we can call receiveMessageOnPort() in host +const { notifyHandle, port, filename } = workerData; + +// When running Miniflare from Jest, regular 'require("undici")' will fail here +// with "Error: Cannot find module 'undici'". Instead we need to create a +// 'require' using the '__filename' of the host... :( +const actualRequire = createRequire(filename); +const { Client, fetch } = actualRequire("undici"); + +let clientUrl; +let client; + +port.addEventListener("message", async (event) => { + const { id, method, url, headers, body } = event.data; + if (clientUrl !== url) { + clientUrl = url; + client = new Client(url, { + connect: { rejectUnauthorized: false }, + }); + } + headers["${CoreHeaders.OP_SYNC}"] = "true"; + try { + // body cannot be a ReadableStream, so no need to specify duplex + const response = await fetch(url, { method, headers, body, dispatcher: client }); + const responseBody = response.headers.get("${CoreHeaders.OP_RESULT_TYPE}") === "ReadableStream" + ? response.body + : await response.arrayBuffer(); + const transferList = responseBody === null ? undefined : [responseBody]; + port.postMessage( + { + id, + response: { + status: response.status, + headers: Object.fromEntries(response.headers), + body: responseBody, + } + }, + transferList + ); + } catch (error) { + try { + port.postMessage({ id, error }); + } catch { + // If error failed to serialise, post simplified version + port.postMessage({ id, error: new Error(String(error)) }); + } + } + Atomics.store(notifyHandle, /* index */ 0, /* value */ 1); + Atomics.notify(notifyHandle, /* index */ 0); +}); +` +); +var SynchronousFetcher = class { + #channel; + #notifyHandle; + #worker; + #nextId = 0; + constructor() { + this.#channel = new import_worker_threads.MessageChannel(); + this.#notifyHandle = new Int32Array(new SharedArrayBuffer(4)); + } + #ensureWorker() { + if (this.#worker !== void 0) + return; + this.#worker = new import_worker_threads.Worker(WORKER_SCRIPT, { + eval: true, + workerData: { + notifyHandle: this.#notifyHandle, + port: this.#channel.port2, + filename: __filename + }, + transferList: [this.#channel.port2] + }); + } + fetch(url13, init2) { + this.#ensureWorker(); + Atomics.store( + this.#notifyHandle, + /* index */ + 0, + /* value */ + 0 + ); + const id = this.#nextId++; + this.#channel.port1.postMessage({ + id, + method: init2.method, + url: url13.toString(), + headers: init2.headers, + body: init2.body + }); + Atomics.wait( + this.#notifyHandle, + /* index */ + 0, + /* value */ + 0 + ); + const message = (0, import_worker_threads.receiveMessageOnPort)( + this.#channel.port1 + )?.message; + (0, import_assert6.default)(message?.id === id); + if ("response" in message) { + const { status, headers: rawHeaders, body } = message.response; + const headers = new import_undici8.Headers(rawHeaders); + const stack = headers.get(CoreHeaders.ERROR_STACK); + if (status === 500 && stack !== null && body !== null) { + (0, import_assert6.default)(!(body instanceof import_web2.ReadableStream)); + const caught = JsonErrorSchema.parse(JSON.parse(DECODER.decode(body))); + throw reviveError([], caught); + } + return { status, headers, body }; + } else { + throw message.error; + } + } + async dispose() { + await this.#worker?.terminate(); + } +}; + +// src/plugins/core/proxy/types.ts +var import_buffer = require("buffer"); +var import_consumers = require("stream/consumers"); +var import_web3 = require("stream/web"); +var import_undici5 = require("undici"); +var NODE_PLATFORM_IMPL = { + // Node's implementation of these classes don't quite match Workers', + // but they're close enough for us + Blob: import_buffer.Blob, + File: import_undici5.File, + Headers: import_undici5.Headers, + Request, + Response, + isReadableStream(value) { + return value instanceof import_web3.ReadableStream; + }, + bufferReadableStream(stream) { + return (0, import_consumers.arrayBuffer)(stream); + }, + unbufferReadableStream(buffer) { + return new import_buffer.Blob([new Uint8Array(buffer)]).stream(); + } +}; + +// src/plugins/core/proxy/client.ts +var kAddress = Symbol("kAddress"); +var kName = Symbol("kName"); +function isNativeTarget(value) { + return typeof value === "object" && value !== null && kAddress in value; +} +var TARGET_GLOBAL = { + [kAddress]: ProxyAddresses.GLOBAL, + [kName]: "global" +}; +var TARGET_ENV = { + [kAddress]: ProxyAddresses.ENV, + [kName]: "env" +}; +var reducers = { + ...structuredSerializableReducers, + ...createHTTPReducers(NODE_PLATFORM_IMPL), + Native(value) { + if (isNativeTarget(value)) + return [value[kAddress], value[kName]]; + } +}; +var revivers = { + ...structuredSerializableRevivers, + ...createHTTPRevivers(NODE_PLATFORM_IMPL) + // `Native` reviver depends on `ProxyStubHandler` methods +}; +var PROXY_SECRET = import_crypto2.default.randomBytes(16); +var PROXY_SECRET_HEX = PROXY_SECRET.toString("hex"); +var ProxyClient = class { + #bridge; + constructor(runtimeEntryURL, dispatchFetch) { + this.#bridge = new ProxyClientBridge(runtimeEntryURL, dispatchFetch); + } + // Lazily initialise proxies as required + #globalProxy; + #envProxy; + get global() { + return this.#globalProxy ??= this.#bridge.getProxy(TARGET_GLOBAL); + } + get env() { + return this.#envProxy ??= this.#bridge.getProxy(TARGET_ENV); + } + poisonProxies() { + this.#bridge.poisonProxies(); + this.#globalProxy = void 0; + this.#envProxy = void 0; + } + setRuntimeEntryURL(runtimeEntryURL) { + this.#bridge.url = runtimeEntryURL; + } + dispose() { + return this.#bridge.dispose(); + } +}; +var ProxyClientBridge = class { + constructor(url13, dispatchFetch) { + this.url = url13; + this.dispatchFetch = dispatchFetch; + this.#finalizationRegistry = new FinalizationRegistry(this.#finalizeProxy); + } + // Each proxy stub is initialised with the version stored here. Whenever + // `poisonProxies()` is called, this version is incremented. Before the + // proxy makes any request to `workerd`, it checks the version number here + // matches its own internal version, and throws if not. + #version = 0; + // Whenever the `ProxyServer` returns a native target, it adds a strong + // reference to the "heap" in the singleton object. This prevents the object + // being garbage collected. To solve this, we register the native target + // proxies on the client in a `FinalizationRegistry`. When the proxies get + // garbage collected, we let the `ProxyServer` know it can release the strong + // "heap" reference, as we'll never be able to access it again. Importantly, + // we need to unregister all proxies from the registry when we poison them, + // as the references will be invalid, and a new object with the same address + // may be added to the "heap". + #finalizationRegistry; + // Garbage collection passes will free lots of objects at once. Rather than + // sending a `DELETE` request for each address, we batch finalisations within + // 100ms of each other into one request. This ensures we don't create *lots* + // of TCP connections to `workerd` in `dispatchFetch()` for all the concurrent + // requests. + #finalizeBatch = []; + #finalizeBatchTimeout; + sync = new SynchronousFetcher(); + get version() { + return this.#version; + } + #finalizeProxy = (held) => { + this.#finalizeBatch.push(held); + clearTimeout(this.#finalizeBatchTimeout); + this.#finalizeBatchTimeout = setTimeout(this.#finalizeProxyBatch, 100); + }; + #finalizeProxyBatch = async () => { + const addresses = []; + for (const held of this.#finalizeBatch.splice(0)) { + if (held.version === this.#version) + addresses.push(held.address); + } + if (addresses.length === 0) + return; + try { + await this.dispatchFetch(this.url, { + method: "DELETE", + headers: { + [CoreHeaders.OP_SECRET]: PROXY_SECRET_HEX, + [CoreHeaders.OP]: ProxyOps.FREE, + [CoreHeaders.OP_TARGET]: addresses.join(",") + } + }); + } catch { + } + }; + getProxy(target) { + const handler = new ProxyStubHandler(this, target); + const proxy = new Proxy( + { [import_util2.default.inspect.custom]: handler.inspect }, + handler + ); + const held = { + address: target[kAddress], + version: this.#version + }; + this.#finalizationRegistry.register(proxy, held, this); + return proxy; + } + poisonProxies() { + this.#version++; + this.#finalizationRegistry.unregister(this); + } + dispose() { + this.poisonProxies(); + return this.sync.dispose(); + } +}; +var ProxyStubHandler = class { + constructor(bridge, target) { + this.bridge = bridge; + this.target = target; + this.#version = bridge.version; + this.#stringifiedTarget = stringify(this.target, reducers); + } + #version; + #stringifiedTarget; + #knownValues = /* @__PURE__ */ new Map(); + #knownDescriptors = /* @__PURE__ */ new Map(); + #knownOwnKeys; + revivers = { + ...revivers, + Native: (value) => { + (0, import_assert7.default)(Array.isArray(value)); + const [address, name] = value; + (0, import_assert7.default)(typeof address === "number"); + (0, import_assert7.default)(typeof name === "string"); + const target = { [kAddress]: address, [kName]: name }; + if (name === "Promise") { + const resPromise = this.bridge.dispatchFetch(this.bridge.url, { + method: "POST", + headers: { + [CoreHeaders.OP_SECRET]: PROXY_SECRET_HEX, + [CoreHeaders.OP]: ProxyOps.GET, + // GET without key just gets target + [CoreHeaders.OP_TARGET]: stringify(target, reducers) + } + }); + return this.#parseAsyncResponse(resPromise); + } else { + return this.bridge.getProxy(target); + } + } + }; + get #poisoned() { + return this.#version !== this.bridge.version; + } + #assertSafe() { + if (this.#poisoned) { + throw new Error( + "Attempted to use poisoned stub. Stubs to runtime objects must be re-created after calling `Miniflare#setOptions()` or `Miniflare#dispose()`." + ); + } + } + inspect = (depth, options) => { + const details = { name: this.target[kName], poisoned: this.#poisoned }; + return `ProxyStub ${import_util2.default.inspect(details, options)}`; + }; + #maybeThrow(res, result, caller) { + if (res.status === 500) { + if (typeof result === "object" && result !== null) { + Error.captureStackTrace(result, caller); + } + throw result; + } else { + (0, import_assert7.default)(res.status === 200); + return result; + } + } + async #parseAsyncResponse(resPromise) { + const res = await resPromise; + const typeHeader = res.headers.get(CoreHeaders.OP_RESULT_TYPE); + if (typeHeader === "Promise, ReadableStream") + return res.body; + (0, import_assert7.default)(typeHeader === "Promise"); + let stringifiedResult; + let unbufferedStream; + const stringifiedSizeHeader = res.headers.get( + CoreHeaders.OP_STRINGIFIED_SIZE + ); + if (stringifiedSizeHeader === null) { + stringifiedResult = await res.text(); + } else { + const stringifiedSize = parseInt(stringifiedSizeHeader); + (0, import_assert7.default)(!Number.isNaN(stringifiedSize)); + (0, import_assert7.default)(res.body !== null); + const [buffer, rest] = await readPrefix(res.body, stringifiedSize); + stringifiedResult = buffer.toString(); + unbufferedStream = rest.pipeThrough(new import_web4.TransformStream()); + } + const result = parseWithReadableStreams( + NODE_PLATFORM_IMPL, + { value: stringifiedResult, unbufferedStream }, + this.revivers + ); + return this.#maybeThrow(res, result, this.#parseAsyncResponse); + } + #parseSyncResponse(syncRes, caller) { + (0, import_assert7.default)(syncRes.body !== null); + (0, import_assert7.default)(syncRes.headers.get(CoreHeaders.OP_STRINGIFIED_SIZE) === null); + if (syncRes.body instanceof import_web4.ReadableStream) + return syncRes.body; + const stringifiedResult = DECODER.decode(syncRes.body); + const result = parseWithReadableStreams( + NODE_PLATFORM_IMPL, + { value: stringifiedResult }, + this.revivers + ); + return this.#maybeThrow(syncRes, result, caller); + } + get(_target, key, _receiver) { + this.#assertSafe(); + if (key === kAddress) + return this.target[kAddress]; + if (key === kName) + return this.target[kName]; + if (typeof key === "symbol" || key === "then") + return void 0; + const maybeKnown = this.#knownValues.get(key); + if (maybeKnown !== void 0) + return maybeKnown; + const syncRes = this.bridge.sync.fetch(this.bridge.url, { + method: "POST", + headers: { + [CoreHeaders.OP_SECRET]: PROXY_SECRET_HEX, + [CoreHeaders.OP]: ProxyOps.GET, + [CoreHeaders.OP_TARGET]: this.#stringifiedTarget, + [CoreHeaders.OP_KEY]: key + } + }); + let result; + if (syncRes.headers.get(CoreHeaders.OP_RESULT_TYPE) === "Function") { + result = this.#createFunction(key); + } else { + result = this.#parseSyncResponse(syncRes, this.get); + } + if ( + // Optimisation: if this property is a function, we assume constant + // prototypes of proxied objects, so it's never going to change + typeof result === "function" || // Optimisation: if this property is a reference, we assume it's never + // going to change. This allows us to reuse the known cache of nested + // objects on multiple access (e.g. reusing `env["..."]` proxy if + // `getR2Bucket()` is called on the same bucket multiple times). + isNativeTarget(result) || // Once a `ReadableStream` sent across proxy, we won't be able to read it + // again in the server, so reuse the same stream for future accesses + // (e.g. accessing `R2ObjectBody#body` multiple times) + result instanceof import_web4.ReadableStream + ) { + this.#knownValues.set(key, result); + } + return result; + } + has(target, key) { + return this.get(target, key, void 0) !== void 0; + } + getOwnPropertyDescriptor(target, key) { + this.#assertSafe(); + if (typeof key === "symbol") + return void 0; + const maybeKnown = this.#knownDescriptors.get(key); + if (maybeKnown !== void 0) + return maybeKnown; + const syncRes = this.bridge.sync.fetch(this.bridge.url, { + method: "POST", + headers: { + [CoreHeaders.OP_SECRET]: PROXY_SECRET_HEX, + [CoreHeaders.OP]: ProxyOps.GET_OWN_DESCRIPTOR, + [CoreHeaders.OP_KEY]: key, + [CoreHeaders.OP_TARGET]: this.#stringifiedTarget + } + }); + const result = this.#parseSyncResponse( + syncRes, + this.getOwnPropertyDescriptor + ); + this.#knownDescriptors.set(key, result); + return result; + } + ownKeys(_target) { + this.#assertSafe(); + if (this.#knownOwnKeys !== void 0) + return this.#knownOwnKeys; + const syncRes = this.bridge.sync.fetch(this.bridge.url, { + method: "POST", + headers: { + [CoreHeaders.OP_SECRET]: PROXY_SECRET_HEX, + [CoreHeaders.OP]: ProxyOps.GET_OWN_KEYS, + [CoreHeaders.OP_TARGET]: this.#stringifiedTarget + } + }); + const result = this.#parseSyncResponse(syncRes, this.ownKeys); + this.#knownOwnKeys = result; + return result; + } + getPrototypeOf(_target) { + this.#assertSafe(); + return null; + } + #createFunction(key) { + let knownAsync = false; + const func = { + [key]: (...args) => { + const result = this.#call(key, knownAsync, args, func); + if (!knownAsync && result instanceof Promise) + knownAsync = true; + return result; + } + }[key]; + return func; + } + #call(key, knownAsync, args, caller) { + this.#assertSafe(); + const targetName = this.target[kName]; + if (isFetcherFetch(targetName, key)) + return this.#fetcherFetchCall(args); + const stringified = stringifyWithStreams( + NODE_PLATFORM_IMPL, + args, + reducers, + /* allowUnbufferedStream */ + true + ); + if (knownAsync || // We assume every call with `ReadableStream`/`Blob` arguments is async. + // Note that you can't consume `ReadableStream`/`Blob` synchronously: if + // you tried a similar trick to `SynchronousFetcher`, blocking the main + // thread with `Atomics.wait()` would prevent chunks being read. This + // assumption doesn't hold for `Blob`s and `FormData#{append,set}()`, but + // we should never expose proxies for those APIs to users. + stringified instanceof Promise || // (instanceof Promise if buffered `ReadableStream`/`Blob`s) + stringified.unbufferedStream !== void 0) { + return this.#asyncCall(key, stringified); + } else { + const result = this.#syncCall(key, stringified.value, caller); + if (isR2ObjectWriteHttpMetadata(targetName, key)) { + const arg = args[0]; + (0, import_assert7.default)(arg instanceof import_undici6.Headers); + (0, import_assert7.default)(result instanceof import_undici6.Headers); + for (const [key2, value] of result) + arg.set(key2, value); + return; + } + return result; + } + } + #syncCall(key, stringifiedValue, caller) { + const argsSize = Buffer.byteLength(stringifiedValue).toString(); + const syncRes = this.bridge.sync.fetch(this.bridge.url, { + method: "POST", + headers: { + [CoreHeaders.OP_SECRET]: PROXY_SECRET_HEX, + [CoreHeaders.OP]: ProxyOps.CALL, + [CoreHeaders.OP_TARGET]: this.#stringifiedTarget, + [CoreHeaders.OP_KEY]: key, + [CoreHeaders.OP_STRINGIFIED_SIZE]: argsSize, + "Content-Length": argsSize + }, + body: stringifiedValue + }); + return this.#parseSyncResponse(syncRes, caller); + } + async #asyncCall(key, stringifiedAwaitable) { + const stringified = await stringifiedAwaitable; + let resPromise; + if (stringified.unbufferedStream === void 0) { + const argsSize = Buffer.byteLength(stringified.value).toString(); + resPromise = this.bridge.dispatchFetch(this.bridge.url, { + method: "POST", + headers: { + [CoreHeaders.OP_SECRET]: PROXY_SECRET_HEX, + [CoreHeaders.OP]: ProxyOps.CALL, + [CoreHeaders.OP_TARGET]: this.#stringifiedTarget, + [CoreHeaders.OP_KEY]: key, + [CoreHeaders.OP_STRINGIFIED_SIZE]: argsSize, + "Content-Length": argsSize + }, + body: stringified.value + }); + } else { + const encodedArgs = Buffer.from(stringified.value); + const argsSize = encodedArgs.byteLength.toString(); + const body = prefixStream(encodedArgs, stringified.unbufferedStream); + resPromise = this.bridge.dispatchFetch(this.bridge.url, { + method: "POST", + headers: { + [CoreHeaders.OP_SECRET]: PROXY_SECRET_HEX, + [CoreHeaders.OP]: ProxyOps.CALL, + [CoreHeaders.OP_TARGET]: this.#stringifiedTarget, + [CoreHeaders.OP_KEY]: key, + [CoreHeaders.OP_STRINGIFIED_SIZE]: argsSize + }, + duplex: "half", + body + }); + } + return this.#parseAsyncResponse(resPromise); + } + #fetcherFetchCall(args) { + const request = new Request(...args); + request.headers.set(CoreHeaders.OP_SECRET, PROXY_SECRET_HEX); + request.headers.set(CoreHeaders.OP, ProxyOps.CALL); + request.headers.set(CoreHeaders.OP_TARGET, this.#stringifiedTarget); + request.headers.set(CoreHeaders.OP_KEY, "fetch"); + return this.bridge.dispatchFetch(request); + } +}; + +// src/plugins/core/services.ts +var import_zod10 = require("zod"); +var HttpOptionsHeaderSchema = import_zod10.z.object({ + name: import_zod10.z.string(), + // name should be required + value: import_zod10.z.ostring() + // If omitted, the header will be removed +}); +var HttpOptionsSchema = import_zod10.z.object({ + style: import_zod10.z.nativeEnum(import_workerd_capnp.HttpOptions_Style).optional(), + forwardedProtoHeader: import_zod10.z.ostring(), + cfBlobHeader: import_zod10.z.ostring(), + injectRequestHeaders: HttpOptionsHeaderSchema.array().optional(), + injectResponseHeaders: HttpOptionsHeaderSchema.array().optional() +}); +var TlsOptionsKeypairSchema = import_zod10.z.object({ + privateKey: import_zod10.z.ostring(), + certificateChain: import_zod10.z.ostring() +}); +var TlsOptionsSchema = import_zod10.z.object({ + keypair: TlsOptionsKeypairSchema.optional(), + requireClientCerts: import_zod10.z.oboolean(), + trustBrowserCas: import_zod10.z.oboolean(), + trustedCertificates: import_zod10.z.string().array().optional(), + minVersion: import_zod10.z.nativeEnum(import_workerd_capnp.TlsOptions_Version).optional(), + cipherList: import_zod10.z.ostring() +}); +var NetworkSchema = import_zod10.z.object({ + allow: import_zod10.z.string().array().optional(), + deny: import_zod10.z.string().array().optional(), + tlsOptions: TlsOptionsSchema.optional() +}); +var ExternalServerSchema = import_zod10.z.intersection( + import_zod10.z.object({ address: import_zod10.z.string() }), + // address should be required + import_zod10.z.union([ + import_zod10.z.object({ http: import_zod10.z.optional(HttpOptionsSchema) }), + import_zod10.z.object({ + https: import_zod10.z.optional( + import_zod10.z.object({ + options: HttpOptionsSchema.optional(), + tlsOptions: TlsOptionsSchema.optional(), + certificateHost: import_zod10.z.ostring() + }) + ) + }) + ]) +); +var DiskDirectorySchema = import_zod10.z.object({ + path: import_zod10.z.string(), + // path should be required + writable: import_zod10.z.oboolean() +}); +var ServiceFetchSchema = import_zod10.z.function().args(import_zod10.z.instanceof(Request)).returns(zAwaitable(import_zod10.z.instanceof(Response))); +var ServiceDesignatorSchema = import_zod10.z.union([ + import_zod10.z.string(), + import_zod10.z.object({ network: NetworkSchema }), + import_zod10.z.object({ external: ExternalServerSchema }), + import_zod10.z.object({ disk: DiskDirectorySchema }), + ServiceFetchSchema +]); + +// src/plugins/core/index.ts +var trustedCertificates = process.platform === "win32" ? Array.from(import_tls.default.rootCertificates) : []; +if (process.env.NODE_EXTRA_CA_CERTS !== void 0) { + try { + const extra = (0, import_fs11.readFileSync)(process.env.NODE_EXTRA_CA_CERTS, "utf8"); + const pemBegin = "-----BEGIN"; + for (const cert of extra.split(pemBegin)) { + if (cert.trim() !== "") + trustedCertificates.push(pemBegin + cert); + } + } catch { + } +} +var encoder2 = new import_util3.TextEncoder(); +var numericCompare = new Intl.Collator(void 0, { numeric: true }).compare; +function createFetchMock() { + return new import_undici7.MockAgent(); +} +var WrappedBindingSchema = import_zod11.z.object({ + scriptName: import_zod11.z.string(), + entrypoint: import_zod11.z.string().optional(), + bindings: import_zod11.z.record(JsonSchema).optional() +}); +var CoreOptionsSchemaInput = import_zod11.z.intersection( + SourceOptionsSchema, + import_zod11.z.object({ + name: import_zod11.z.string().optional(), + compatibilityDate: import_zod11.z.string().optional(), + compatibilityFlags: import_zod11.z.string().array().optional(), + routes: import_zod11.z.string().array().optional(), + bindings: import_zod11.z.record(JsonSchema).optional(), + wasmBindings: import_zod11.z.record(import_zod11.z.string()).optional(), + textBlobBindings: import_zod11.z.record(import_zod11.z.string()).optional(), + dataBlobBindings: import_zod11.z.record(import_zod11.z.string()).optional(), + serviceBindings: import_zod11.z.record(ServiceDesignatorSchema).optional(), + wrappedBindings: import_zod11.z.record(import_zod11.z.union([import_zod11.z.string(), WrappedBindingSchema])).optional(), + outboundService: ServiceDesignatorSchema.optional(), + fetchMock: import_zod11.z.instanceof(import_undici7.MockAgent).optional(), + unsafeEphemeralDurableObjects: import_zod11.z.boolean().optional(), + unsafeDirectHost: import_zod11.z.string().optional(), + unsafeDirectPort: import_zod11.z.number().optional(), + unsafeEvalBinding: import_zod11.z.string().optional() + }) +); +var CoreOptionsSchema = CoreOptionsSchemaInput.transform((value) => { + const fetchMock = value.fetchMock; + if (fetchMock !== void 0) { + if (value.outboundService !== void 0) { + throw new MiniflareCoreError( + "ERR_MULTIPLE_OUTBOUNDS", + "Only one of `outboundService` or `fetchMock` may be specified per worker" + ); + } + value.outboundService = (req) => fetch2(req, { dispatcher: fetchMock }); + } + return value; +}); +var CoreSharedOptionsSchema = import_zod11.z.object({ + host: import_zod11.z.string().optional(), + port: import_zod11.z.number().optional(), + https: import_zod11.z.boolean().optional(), + httpsKey: import_zod11.z.string().optional(), + httpsKeyPath: import_zod11.z.string().optional(), + httpsCert: import_zod11.z.string().optional(), + httpsCertPath: import_zod11.z.string().optional(), + inspectorPort: import_zod11.z.number().optional(), + verbose: import_zod11.z.boolean().optional(), + log: import_zod11.z.instanceof(Log).optional(), + handleRuntimeStdio: import_zod11.z.function(import_zod11.z.tuple([import_zod11.z.instanceof(import_stream2.Readable), import_zod11.z.instanceof(import_stream2.Readable)])).optional(), + upstream: import_zod11.z.string().optional(), + // TODO: add back validation of cf object + cf: import_zod11.z.union([import_zod11.z.boolean(), import_zod11.z.string(), import_zod11.z.record(import_zod11.z.any())]).optional(), + liveReload: import_zod11.z.boolean().optional() +}); +var CORE_PLUGIN_NAME2 = "core"; +var LIVE_RELOAD_SCRIPT_TEMPLATE = (port) => ``; +var SCRIPT_CUSTOM_SERVICE = `addEventListener("fetch", (event) => { + const request = new Request(event.request); + request.headers.set("${CoreHeaders.CUSTOM_SERVICE}", ${CoreBindings.TEXT_CUSTOM_SERVICE}); + request.headers.set("${CoreHeaders.ORIGINAL_URL}", request.url); + event.respondWith(${CoreBindings.SERVICE_LOOPBACK}.fetch(request)); +})`; +function getCustomServiceDesignator(workerIndex, kind, name, service) { + let serviceName; + if (typeof service === "function") { + serviceName = getCustomServiceName(workerIndex, kind, name); + } else if (typeof service === "object") { + serviceName = getBuiltinServiceName(workerIndex, kind, name); + } else { + serviceName = getUserServiceName(service); + } + return { name: serviceName }; +} +function maybeGetCustomServiceService(workerIndex, kind, name, service) { + if (typeof service === "function") { + return { + name: getCustomServiceName(workerIndex, kind, name), + worker: { + serviceWorkerScript: SCRIPT_CUSTOM_SERVICE, + compatibilityDate: "2022-09-01", + bindings: [ + { + name: CoreBindings.TEXT_CUSTOM_SERVICE, + text: `${workerIndex}/${kind}${name}` + }, + WORKER_BINDING_SERVICE_LOOPBACK + ] + } + }; + } else if (typeof service === "object") { + return { + name: getBuiltinServiceName(workerIndex, kind, name), + ...service + }; + } +} +var FALLBACK_COMPATIBILITY_DATE = "2000-01-01"; +function getCurrentCompatibilityDate() { + const now = new Date().toISOString(); + return now.substring(0, now.indexOf("T")); +} +function validateCompatibilityDate(log, compatibilityDate) { + if (numericCompare(compatibilityDate, getCurrentCompatibilityDate()) > 0) { + throw new MiniflareCoreError( + "ERR_FUTURE_COMPATIBILITY_DATE", + `Compatibility date "${compatibilityDate}" is in the future and unsupported` + ); + } else if (numericCompare(compatibilityDate, import_workerd2.compatibilityDate) > 0) { + log.warn( + [ + "The latest compatibility date supported by the installed Cloudflare Workers Runtime is ", + bold(`"${import_workerd2.compatibilityDate}"`), + ",\nbut you've requested ", + bold(`"${compatibilityDate}"`), + ". Falling back to ", + bold(`"${import_workerd2.compatibilityDate}"`), + "..." + ].join("") + ); + return import_workerd2.compatibilityDate; + } + return compatibilityDate; +} +function buildJsonBindings(bindings) { + return Object.entries(bindings).map(([name, value]) => ({ + name, + json: JSON.stringify(value) + })); +} +var WRAPPED_MODULE_PREFIX = "miniflare-internal:wrapped:"; +function workerNameToWrappedModule(workerName) { + return WRAPPED_MODULE_PREFIX + workerName; +} +function maybeWrappedModuleToWorkerName(name) { + if (name.startsWith(WRAPPED_MODULE_PREFIX)) { + return name.substring(WRAPPED_MODULE_PREFIX.length); + } +} +var CORE_PLUGIN = { + options: CoreOptionsSchema, + sharedOptions: CoreSharedOptionsSchema, + getBindings(options, workerIndex) { + const bindings = []; + if (options.bindings !== void 0) { + bindings.push(...buildJsonBindings(options.bindings)); + } + if (options.wasmBindings !== void 0) { + bindings.push( + ...Object.entries(options.wasmBindings).map( + ([name, path21]) => import_promises5.default.readFile(path21).then((wasmModule) => ({ name, wasmModule })) + ) + ); + } + if (options.textBlobBindings !== void 0) { + bindings.push( + ...Object.entries(options.textBlobBindings).map( + ([name, path21]) => import_promises5.default.readFile(path21, "utf8").then((text) => ({ name, text })) + ) + ); + } + if (options.dataBlobBindings !== void 0) { + bindings.push( + ...Object.entries(options.dataBlobBindings).map( + ([name, path21]) => import_promises5.default.readFile(path21).then((data) => ({ name, data })) + ) + ); + } + if (options.serviceBindings !== void 0) { + bindings.push( + ...Object.entries(options.serviceBindings).map(([name, service]) => { + return { + name, + service: getCustomServiceDesignator( + workerIndex, + "#" /* UNKNOWN */, + name, + service + ) + }; + }) + ); + } + if (options.wrappedBindings !== void 0) { + bindings.push( + ...Object.entries(options.wrappedBindings).map(([name, designator]) => { + const isObject = typeof designator === "object"; + const scriptName = isObject ? designator.scriptName : designator; + const entrypoint = isObject ? designator.entrypoint : void 0; + const bindings2 = isObject ? designator.bindings : void 0; + const moduleName2 = workerNameToWrappedModule(scriptName); + const innerBindings = bindings2 === void 0 ? [] : buildJsonBindings(bindings2); + return { + name, + wrapped: { moduleName: moduleName2, entrypoint, innerBindings } + }; + }) + ); + } + if (options.unsafeEvalBinding !== void 0) { + bindings.push({ + name: options.unsafeEvalBinding, + unsafeEval: kVoid + }); + } + return Promise.all(bindings); + }, + async getNodeBindings(options) { + const bindingEntries = []; + if (options.bindings !== void 0) { + bindingEntries.push( + ...Object.entries(options.bindings).map(([name, value]) => [ + name, + JSON.parse(JSON.stringify(value)) + ]) + ); + } + if (options.wasmBindings !== void 0) { + bindingEntries.push( + ...Object.entries(options.wasmBindings).map( + ([name, path21]) => import_promises5.default.readFile(path21).then((buffer) => [name, new WebAssembly.Module(buffer)]) + ) + ); + } + if (options.textBlobBindings !== void 0) { + bindingEntries.push( + ...Object.entries(options.textBlobBindings).map( + ([name, path21]) => import_promises5.default.readFile(path21, "utf8").then((text) => [name, text]) + ) + ); + } + if (options.dataBlobBindings !== void 0) { + bindingEntries.push( + ...Object.entries(options.dataBlobBindings).map( + ([name, path21]) => import_promises5.default.readFile(path21).then((buffer) => [name, viewToBuffer(buffer)]) + ) + ); + } + if (options.serviceBindings !== void 0) { + bindingEntries.push( + ...Object.keys(options.serviceBindings).map((name) => [ + name, + kProxyNodeBinding + ]) + ); + } + return Object.fromEntries(await Promise.all(bindingEntries)); + }, + async getServices({ + log, + options, + workerBindings, + workerIndex, + wrappedBindingNames, + durableObjectClassNames, + additionalModules + }) { + const additionalModuleNames = additionalModules.map(({ name: name2 }) => name2); + const workerScript = getWorkerScript( + options, + workerIndex, + additionalModuleNames + ); + if ("modules" in workerScript) { + const subDirs = new Set( + workerScript.modules.map(({ name: name2 }) => import_path13.default.posix.dirname(name2)) + ); + subDirs.delete("."); + for (const module2 of additionalModules) { + workerScript.modules.push(module2); + for (const subDir of subDirs) { + const relativePath = import_path13.default.posix.relative(subDir, module2.name); + const relativePathString = JSON.stringify(relativePath); + workerScript.modules.push({ + name: import_path13.default.posix.join(subDir, module2.name), + // TODO(someday): if we ever have additional modules without + // default exports, this may be a problem. For now, our only + // additional module is `__STATIC_CONTENT_MANIFEST` so it's fine. + // If needed, we could look for instances of `export default` or + // `as default` in the module's code as a heuristic. + esModule: `export * from ${relativePathString}; export { default } from ${relativePathString};` + }); + } + } + } + const name = options.name ?? ""; + const serviceName = getUserServiceName(options.name); + const classNames = durableObjectClassNames.get(serviceName); + const classNamesEntries = Array.from(classNames ?? []); + const compatibilityDate = validateCompatibilityDate( + log, + options.compatibilityDate ?? FALLBACK_COMPATIBILITY_DATE + ); + const isWrappedBinding = wrappedBindingNames.has(name); + const services = []; + const extensions = []; + if (isWrappedBinding) { + let invalidWrapped2 = function(reason) { + const message = `Cannot use ${stringName} for wrapped binding because ${reason}`; + throw new MiniflareCoreError("ERR_INVALID_WRAPPED", message); + }; + var invalidWrapped = invalidWrapped2; + const stringName = JSON.stringify(name); + if (workerIndex === 0) { + invalidWrapped2( + `it's the entrypoint. +Ensure ${stringName} isn't the first entry in the \`workers\` array.` + ); + } + if (!("modules" in workerScript)) { + invalidWrapped2( + `it's a service worker. +Ensure ${stringName} sets \`modules\` to \`true\` or an array of modules` + ); + } + if (workerScript.modules.length !== 1) { + invalidWrapped2( + `it isn't a single module. +Ensure ${stringName} doesn't include unbundled \`import\`s.` + ); + } + const firstModule = workerScript.modules[0]; + if (!("esModule" in firstModule)) { + invalidWrapped2("it isn't a single ES module"); + } + if (options.compatibilityDate !== void 0) { + invalidWrapped2( + "it defines a compatibility date.\nWrapped bindings use the compatibility date of the worker with the binding." + ); + } + if (options.compatibilityFlags?.length) { + invalidWrapped2( + "it defines compatibility flags.\nWrapped bindings use the compatibility flags of the worker with the binding." + ); + } + if (options.outboundService !== void 0) { + invalidWrapped2( + "it defines an outbound service.\nWrapped bindings use the outbound service of the worker with the binding." + ); + } + extensions.push({ + modules: [ + { + name: workerNameToWrappedModule(name), + esModule: firstModule.esModule, + internal: true + } + ] + }); + } else { + services.push({ + name: serviceName, + worker: { + ...workerScript, + compatibilityDate, + compatibilityFlags: options.compatibilityFlags, + bindings: workerBindings, + durableObjectNamespaces: classNamesEntries.map( + ([className, { unsafeUniqueKey, unsafePreventEviction }]) => { + return { + className, + // This `uniqueKey` will (among other things) be used as part of the + // path when persisting to the file-system. `-` is invalid in + // JavaScript class names, but safe on filesystems (incl. Windows). + uniqueKey: unsafeUniqueKey ?? `${options.name ?? ""}-${className}`, + preventEviction: unsafePreventEviction + }; + } + ), + durableObjectStorage: classNamesEntries.length === 0 ? void 0 : options.unsafeEphemeralDurableObjects ? { inMemory: kVoid } : { localDisk: DURABLE_OBJECTS_STORAGE_SERVICE_NAME }, + globalOutbound: options.outboundService === void 0 ? void 0 : getCustomServiceDesignator( + workerIndex, + "$" /* KNOWN */, + CUSTOM_SERVICE_KNOWN_OUTBOUND, + options.outboundService + ), + cacheApiOutbound: { name: getCacheServiceName(workerIndex) } + } + }); + } + if (options.serviceBindings !== void 0) { + for (const [name2, service] of Object.entries(options.serviceBindings)) { + const maybeService = maybeGetCustomServiceService( + workerIndex, + "#" /* UNKNOWN */, + name2, + service + ); + if (maybeService !== void 0) + services.push(maybeService); + } + } + if (options.outboundService !== void 0) { + const maybeService = maybeGetCustomServiceService( + workerIndex, + "$" /* KNOWN */, + CUSTOM_SERVICE_KNOWN_OUTBOUND, + options.outboundService + ); + if (maybeService !== void 0) + services.push(maybeService); + } + return { services, extensions }; + } +}; +function getGlobalServices({ + sharedOptions, + allWorkerRoutes, + fallbackWorkerName, + loopbackPort, + log, + proxyBindings +}) { + const workerNames = [...allWorkerRoutes.keys()]; + const routes = parseRoutes(allWorkerRoutes); + const serviceEntryBindings = [ + WORKER_BINDING_SERVICE_LOOPBACK, + // For converting stack-traces to pretty-error pages + { name: CoreBindings.JSON_ROUTES, json: JSON.stringify(routes) }, + { name: CoreBindings.JSON_CF_BLOB, json: JSON.stringify(sharedOptions.cf) }, + { name: CoreBindings.JSON_LOG_LEVEL, json: JSON.stringify(log.level) }, + { + name: CoreBindings.SERVICE_USER_FALLBACK, + service: { name: getUserServiceName(fallbackWorkerName) } + }, + ...workerNames.map((name) => ({ + name: CoreBindings.SERVICE_USER_ROUTE_PREFIX + name, + service: { name: getUserServiceName(name) } + })), + { + name: CoreBindings.DURABLE_OBJECT_NAMESPACE_PROXY, + durableObjectNamespace: { className: "ProxyServer" } + }, + { + name: CoreBindings.DATA_PROXY_SECRET, + data: PROXY_SECRET + }, + // Add `proxyBindings` here, they'll be added to the `ProxyServer` `env` + ...proxyBindings + ]; + if (sharedOptions.upstream !== void 0) { + serviceEntryBindings.push({ + name: CoreBindings.TEXT_UPSTREAM_URL, + text: sharedOptions.upstream + }); + } + if (sharedOptions.liveReload) { + const liveReloadScript = LIVE_RELOAD_SCRIPT_TEMPLATE(loopbackPort); + serviceEntryBindings.push({ + name: CoreBindings.DATA_LIVE_RELOAD_SCRIPT, + data: encoder2.encode(liveReloadScript) + }); + } + return [ + { + name: SERVICE_LOOPBACK, + external: { http: { cfBlobHeader: HEADER_CF_BLOB } } + }, + { + name: SERVICE_ENTRY, + worker: { + modules: [{ name: "entry.worker.js", esModule: entry_worker_default() }], + compatibilityDate: "2023-04-04", + compatibilityFlags: ["nodejs_compat", "service_binding_extra_handlers"], + bindings: serviceEntryBindings, + durableObjectNamespaces: [ + { + className: "ProxyServer", + uniqueKey: `${SERVICE_ENTRY}-ProxyServer`, + // `ProxyServer` relies on a singleton object containing of "heap" + // mapping addresses to native references. If the singleton object + // were evicted, addresses would be invalidated. Therefore, we + // prevent eviction to ensure heap addresses stay valid for the + // lifetime of the `workerd` process + preventEviction: true + } + ], + // `ProxyServer` doesn't make use of Durable Object storage + durableObjectStorage: { inMemory: kVoid }, + // Always use the entrypoints cache implementation for proxying. This + // means if the entrypoint disables caching, proxied cache operations + // will be no-ops. Note we always require at least one worker to be set. + cacheApiOutbound: { name: "cache:0" } + } + }, + { + name: "internet", + network: { + // Allow access to private/public addresses: + // https://github.com/cloudflare/miniflare/issues/412 + allow: ["public", "private"], + deny: [], + tlsOptions: { + trustBrowserCas: true, + trustedCertificates + } + } + } + ]; +} +function getWorkerScript(options, workerIndex, additionalModuleNames) { + const modulesRoot = ("modulesRoot" in options ? options.modulesRoot : void 0) ?? ""; + if (Array.isArray(options.modules)) { + return { + modules: options.modules.map( + (module2) => convertModuleDefinition(modulesRoot, module2) + ) + }; + } + let code; + if ("script" in options && options.script !== void 0) { + code = options.script; + } else if ("scriptPath" in options && options.scriptPath !== void 0) { + code = (0, import_fs11.readFileSync)(options.scriptPath, "utf8"); + } else { + import_assert8.default.fail("Unreachable: Workers must have code"); + } + const scriptPath = options.scriptPath ?? buildStringScriptPath(workerIndex); + if (options.modules) { + const locator = new ModuleLocator( + modulesRoot, + additionalModuleNames, + options.modulesRules, + options.compatibilityFlags + ); + locator.visitEntrypoint(code, scriptPath); + return { modules: locator.modules }; + } else { + code = withSourceURL(code, scriptPath); + return { serviceWorkerScript: code }; + } +} + +// src/plugins/d1/index.ts +var import_promises6 = __toESM(require("fs/promises")); + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/d1/database.worker.ts +var import_fs12 = __toESM(require("fs")); +var import_path14 = __toESM(require("path")); +var import_url12 = __toESM(require("url")); +var contents8; +function database_worker_default() { + if (contents8 !== void 0) + return contents8; + const filePath = import_path14.default.join(__dirname, "workers", "d1/database.worker.js"); + contents8 = import_fs12.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url12.default.pathToFileURL(filePath); + return contents8; +} + +// src/plugins/d1/index.ts +var import_zod12 = require("zod"); +var D1OptionsSchema = import_zod12.z.object({ + d1Databases: import_zod12.z.union([import_zod12.z.record(import_zod12.z.string()), import_zod12.z.string().array()]).optional() +}); +var D1SharedOptionsSchema = import_zod12.z.object({ + d1Persist: PersistenceSchema +}); +var D1_PLUGIN_NAME = "d1"; +var D1_STORAGE_SERVICE_NAME = `${D1_PLUGIN_NAME}:storage`; +var D1_DATABASE_SERVICE_PREFIX = `${D1_PLUGIN_NAME}:db`; +var D1_DATABASE_OBJECT_CLASS_NAME = "D1DatabaseObject"; +var D1_DATABASE_OBJECT = { + serviceName: D1_DATABASE_SERVICE_PREFIX, + className: D1_DATABASE_OBJECT_CLASS_NAME +}; +var D1_PLUGIN = { + options: D1OptionsSchema, + sharedOptions: D1SharedOptionsSchema, + getBindings(options) { + const databases = namespaceEntries(options.d1Databases); + return databases.map(([name, id]) => { + const binding = name.startsWith("__D1_BETA__") ? ( + // Used before Wrangler 3.3 + { + service: { name: `${D1_DATABASE_SERVICE_PREFIX}:${id}` } + } + ) : ( + // Used after Wrangler 3.3 + { + wrapped: { + moduleName: "cloudflare-internal:d1-api", + innerBindings: [ + { + name: "fetcher", + service: { name: `${D1_DATABASE_SERVICE_PREFIX}:${id}` } + } + ] + } + } + ); + return { name, ...binding }; + }); + }, + getNodeBindings(options) { + const databases = namespaceKeys(options.d1Databases); + return Object.fromEntries( + databases.map((name) => [name, kProxyNodeBinding]) + ); + }, + async getServices({ options, sharedOptions, tmpPath, log }) { + const persist = sharedOptions.d1Persist; + const databases = namespaceEntries(options.d1Databases); + const services = databases.map(([_, id]) => ({ + name: `${D1_DATABASE_SERVICE_PREFIX}:${id}`, + worker: objectEntryWorker(D1_DATABASE_OBJECT, id) + })); + if (databases.length > 0) { + const uniqueKey = `miniflare-${D1_DATABASE_OBJECT_CLASS_NAME}`; + const persistPath = getPersistPath(D1_PLUGIN_NAME, tmpPath, persist); + await import_promises6.default.mkdir(persistPath, { recursive: true }); + const storageService = { + name: D1_STORAGE_SERVICE_NAME, + disk: { path: persistPath, writable: true } + }; + const objectService = { + name: D1_DATABASE_SERVICE_PREFIX, + worker: { + compatibilityDate: "2023-07-24", + compatibilityFlags: ["nodejs_compat", "experimental"], + modules: [ + { + name: "database.worker.js", + esModule: database_worker_default() + } + ], + durableObjectNamespaces: [ + { + className: D1_DATABASE_OBJECT_CLASS_NAME, + uniqueKey + } + ], + // Store Durable Object SQL databases in persist path + durableObjectStorage: { localDisk: D1_STORAGE_SERVICE_NAME }, + // Bind blob disk directory service to object + bindings: [ + { + name: SharedBindings.MAYBE_SERVICE_BLOBS, + service: { name: D1_STORAGE_SERVICE_NAME } + }, + { + name: SharedBindings.MAYBE_SERVICE_LOOPBACK, + service: { name: SERVICE_LOOPBACK } + }, + ...getControlEndpointBindings() + ] + } + }; + services.push(storageService, objectService); + for (const database of databases) { + await migrateDatabase(log, uniqueKey, persistPath, database[1]); + } + } + return services; + } +}; + +// src/plugins/hyperdrive/index.ts +var import_zod13 = require("zod"); +var HYPERDRIVE_PLUGIN_NAME = "hyperdrive"; +var HyperdriveSchema = import_zod13.z.string().url().transform((urlString, ctx) => { + const url13 = new URL(urlString); + if (url13.protocol === "") { + ctx.addIssue({ + code: import_zod13.z.ZodIssueCode.custom, + message: "You must specify the database protocol - e.g. 'postgresql'." + }); + } else if (url13.protocol !== "postgresql:" && url13.protocol !== "postgres:" && url13.protocol !== "") { + ctx.addIssue({ + code: import_zod13.z.ZodIssueCode.custom, + message: "Only PostgreSQL or PostgreSQL compatible databases are currently supported." + }); + } + if (url13.host === "") { + ctx.addIssue({ + code: import_zod13.z.ZodIssueCode.custom, + message: "You must provide a hostname or IP address in your connection string - e.g. 'user:password@database-hostname.example.com:5432/databasename" + }); + } + let port; + if (url13.port === "" && (url13.protocol === "postgresql:" || url13.protocol == "postgres:")) { + port = "5432"; + } else if (url13.port !== "") { + port = url13.port; + } else { + ctx.addIssue({ + code: import_zod13.z.ZodIssueCode.custom, + message: "You must provide a port number - e.g. 'user:password@database.example.com:port/databasename" + }); + } + if (url13.pathname === "") { + ctx.addIssue({ + code: import_zod13.z.ZodIssueCode.custom, + message: "You must provide a database name as the path component - e.g. /postgres" + }); + } + if (url13.username === "") { + ctx.addIssue({ + code: import_zod13.z.ZodIssueCode.custom, + message: "You must provide a username - e.g. 'user:password@database.example.com:port/databasename'" + }); + } + if (url13.password === "") { + ctx.addIssue({ + code: import_zod13.z.ZodIssueCode.custom, + message: "You must provide a password - e.g. 'user:password@database.example.com:port/databasename' " + }); + } + return { + database: url13.pathname.replace("/", ""), + user: url13.username, + password: url13.password, + scheme: url13.protocol.replace(":", ""), + host: url13.hostname, + port + }; +}); +var HyperdriveInputOptionsSchema = import_zod13.z.object({ + hyperdrives: import_zod13.z.record(import_zod13.z.string(), HyperdriveSchema).optional() +}); +var HYPERDRIVE_PLUGIN = { + options: HyperdriveInputOptionsSchema, + getBindings(options) { + return Object.entries(options.hyperdrives ?? {}).map( + ([name, config]) => ({ + name, + hyperdrive: { + designator: { + name: `${HYPERDRIVE_PLUGIN_NAME}:${name}` + }, + database: config.database, + user: config.user, + password: config.password, + scheme: config.scheme + } + }) + ); + }, + getNodeBindings() { + return {}; + }, + async getServices({ options }) { + return Object.entries(options.hyperdrives ?? {}).map( + ([name, config]) => ({ + name: `${HYPERDRIVE_PLUGIN_NAME}:${name}`, + external: { + address: `${config.host}:${config.port}`, + tcp: {} + } + }) + ); + } +}; + +// src/plugins/kv/index.ts +var import_promises8 = __toESM(require("fs/promises")); + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/kv/namespace.worker.ts +var import_fs13 = __toESM(require("fs")); +var import_path15 = __toESM(require("path")); +var import_url13 = __toESM(require("url")); +var contents9; +function namespace_worker_default() { + if (contents9 !== void 0) + return contents9; + const filePath = import_path15.default.join(__dirname, "workers", "kv/namespace.worker.js"); + contents9 = import_fs13.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url13.default.pathToFileURL(filePath); + return contents9; +} + +// src/plugins/kv/index.ts +var import_zod14 = require("zod"); + +// src/plugins/kv/constants.ts +var KV_PLUGIN_NAME = "kv"; + +// src/plugins/kv/sites.ts +var import_assert9 = __toESM(require("assert")); +var import_promises7 = __toESM(require("fs/promises")); +var import_path17 = __toESM(require("path")); + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/kv/sites.worker.ts +var import_fs14 = __toESM(require("fs")); +var import_path16 = __toESM(require("path")); +var import_url14 = __toESM(require("url")); +var contents10; +function sites_worker_default() { + if (contents10 !== void 0) + return contents10; + const filePath = import_path16.default.join(__dirname, "workers", "kv/sites.worker.js"); + contents10 = import_fs14.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url14.default.pathToFileURL(filePath); + return contents10; +} + +// src/plugins/kv/sites.ts +async function* listKeysInDirectoryInner(rootPath, currentPath) { + const fileEntries = await import_promises7.default.readdir(currentPath, { withFileTypes: true }); + for (const fileEntry of fileEntries) { + const filePath = import_path17.default.posix.join(currentPath, fileEntry.name); + if (fileEntry.isDirectory()) { + yield* listKeysInDirectoryInner(rootPath, filePath); + } else { + yield filePath.substring(rootPath.length + 1); + } + } +} +function listKeysInDirectory(rootPath) { + rootPath = import_path17.default.resolve(rootPath); + return listKeysInDirectoryInner(rootPath, rootPath); +} +var sitesRegExpsCache = /* @__PURE__ */ new WeakMap(); +var SERVICE_NAMESPACE_SITE = `${KV_PLUGIN_NAME}:site`; +async function buildStaticContentManifest(sitePath, siteRegExps) { + const staticContentManifest = {}; + for await (const key of listKeysInDirectory(sitePath)) { + if (testSiteRegExps(siteRegExps, key)) { + staticContentManifest[key] = encodeSitesKey(key); + } + } + return staticContentManifest; +} +async function getSitesBindings(options) { + const siteRegExps = { + include: options.siteInclude && globsToRegExps(options.siteInclude), + exclude: options.siteExclude && globsToRegExps(options.siteExclude) + }; + sitesRegExpsCache.set(options, siteRegExps); + const __STATIC_CONTENT_MANIFEST = await buildStaticContentManifest( + options.sitePath, + siteRegExps + ); + return [ + { + name: SiteBindings.KV_NAMESPACE_SITE, + kvNamespace: { name: SERVICE_NAMESPACE_SITE } + }, + { + name: SiteBindings.JSON_SITE_MANIFEST, + json: JSON.stringify(__STATIC_CONTENT_MANIFEST) + } + ]; +} +async function getSitesNodeBindings(options) { + const siteRegExps = sitesRegExpsCache.get(options); + (0, import_assert9.default)(siteRegExps !== void 0); + const __STATIC_CONTENT_MANIFEST = await buildStaticContentManifest( + options.sitePath, + siteRegExps + ); + return { + [SiteBindings.KV_NAMESPACE_SITE]: kProxyNodeBinding, + [SiteBindings.JSON_SITE_MANIFEST]: __STATIC_CONTENT_MANIFEST + }; +} +function getSitesServices(options) { + const siteRegExps = sitesRegExpsCache.get(options); + (0, import_assert9.default)(siteRegExps !== void 0); + const serialisedSiteRegExps = serialiseSiteRegExps(siteRegExps); + const persist = import_path17.default.resolve(options.sitePath); + const storageServiceName = `${SERVICE_NAMESPACE_SITE}:storage`; + const storageService = { + name: storageServiceName, + disk: { path: persist, writable: true } + }; + const namespaceService = { + name: SERVICE_NAMESPACE_SITE, + worker: { + compatibilityDate: "2023-07-24", + compatibilityFlags: ["nodejs_compat"], + modules: [ + { + name: "site.worker.js", + esModule: sites_worker_default() + } + ], + bindings: [ + { + name: SharedBindings.MAYBE_SERVICE_BLOBS, + service: { name: storageServiceName } + }, + { + name: SiteBindings.JSON_SITE_FILTER, + json: JSON.stringify(serialisedSiteRegExps) + } + ] + } + }; + return [storageService, namespaceService]; +} + +// src/plugins/kv/index.ts +var KVOptionsSchema = import_zod14.z.object({ + kvNamespaces: import_zod14.z.union([import_zod14.z.record(import_zod14.z.string()), import_zod14.z.string().array()]).optional(), + // Workers Sites + sitePath: import_zod14.z.string().optional(), + siteInclude: import_zod14.z.string().array().optional(), + siteExclude: import_zod14.z.string().array().optional() +}); +var KVSharedOptionsSchema = import_zod14.z.object({ + kvPersist: PersistenceSchema +}); +var SERVICE_NAMESPACE_PREFIX = `${KV_PLUGIN_NAME}:ns`; +var KV_STORAGE_SERVICE_NAME = `${KV_PLUGIN_NAME}:storage`; +var KV_NAMESPACE_OBJECT_CLASS_NAME = "KVNamespaceObject"; +var KV_NAMESPACE_OBJECT = { + serviceName: SERVICE_NAMESPACE_PREFIX, + className: KV_NAMESPACE_OBJECT_CLASS_NAME +}; +function isWorkersSitesEnabled(options) { + return options.sitePath !== void 0; +} +var KV_PLUGIN = { + options: KVOptionsSchema, + sharedOptions: KVSharedOptionsSchema, + async getBindings(options) { + const namespaces = namespaceEntries(options.kvNamespaces); + const bindings = namespaces.map(([name, id]) => ({ + name, + kvNamespace: { name: `${SERVICE_NAMESPACE_PREFIX}:${id}` } + })); + if (isWorkersSitesEnabled(options)) { + bindings.push(...await getSitesBindings(options)); + } + return bindings; + }, + async getNodeBindings(options) { + const namespaces = namespaceKeys(options.kvNamespaces); + const bindings = Object.fromEntries( + namespaces.map((name) => [name, kProxyNodeBinding]) + ); + if (isWorkersSitesEnabled(options)) { + Object.assign(bindings, await getSitesNodeBindings(options)); + } + return bindings; + }, + async getServices({ options, sharedOptions, tmpPath, log }) { + const persist = sharedOptions.kvPersist; + const namespaces = namespaceEntries(options.kvNamespaces); + const services = namespaces.map(([_, id]) => ({ + name: `${SERVICE_NAMESPACE_PREFIX}:${id}`, + worker: objectEntryWorker(KV_NAMESPACE_OBJECT, id) + })); + if (services.length > 0) { + const uniqueKey = `miniflare-${KV_NAMESPACE_OBJECT_CLASS_NAME}`; + const persistPath = getPersistPath(KV_PLUGIN_NAME, tmpPath, persist); + await import_promises8.default.mkdir(persistPath, { recursive: true }); + const storageService = { + name: KV_STORAGE_SERVICE_NAME, + disk: { path: persistPath, writable: true } + }; + const objectService = { + name: SERVICE_NAMESPACE_PREFIX, + worker: { + compatibilityDate: "2023-07-24", + compatibilityFlags: ["nodejs_compat", "experimental"], + modules: [ + { + name: "namespace.worker.js", + esModule: namespace_worker_default() + } + ], + durableObjectNamespaces: [ + { className: KV_NAMESPACE_OBJECT_CLASS_NAME, uniqueKey } + ], + // Store Durable Object SQL databases in persist path + durableObjectStorage: { localDisk: KV_STORAGE_SERVICE_NAME }, + // Bind blob disk directory service to object + bindings: [ + { + name: SharedBindings.MAYBE_SERVICE_BLOBS, + service: { name: KV_STORAGE_SERVICE_NAME } + }, + { + name: SharedBindings.MAYBE_SERVICE_LOOPBACK, + service: { name: SERVICE_LOOPBACK } + }, + ...getControlEndpointBindings() + ] + } + }; + services.push(storageService, objectService); + for (const namespace of namespaces) { + await migrateDatabase(log, uniqueKey, persistPath, namespace[1]); + } + } + if (isWorkersSitesEnabled(options)) { + services.push(...getSitesServices(options)); + } + return services; + } +}; + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/queues/broker.worker.ts +var import_fs15 = __toESM(require("fs")); +var import_path18 = __toESM(require("path")); +var import_url15 = __toESM(require("url")); +var contents11; +function broker_worker_default() { + if (contents11 !== void 0) + return contents11; + const filePath = import_path18.default.join(__dirname, "workers", "queues/broker.worker.js"); + contents11 = import_fs15.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url15.default.pathToFileURL(filePath); + return contents11; +} + +// src/plugins/queues/index.ts +var import_zod15 = require("zod"); + +// src/plugins/queues/errors.ts +var QueuesError = class extends MiniflareError { +}; + +// src/plugins/queues/index.ts +var QueuesOptionsSchema = import_zod15.z.object({ + queueProducers: import_zod15.z.union([import_zod15.z.record(import_zod15.z.string()), import_zod15.z.string().array()]).optional(), + queueConsumers: import_zod15.z.union([import_zod15.z.record(QueueConsumerOptionsSchema), import_zod15.z.string().array()]).optional() +}); +var QUEUES_PLUGIN_NAME = "queues"; +var SERVICE_QUEUE_PREFIX = `${QUEUES_PLUGIN_NAME}:queue`; +var QUEUE_BROKER_OBJECT_CLASS_NAME = "QueueBrokerObject"; +var QUEUE_BROKER_OBJECT = { + serviceName: SERVICE_QUEUE_PREFIX, + className: QUEUE_BROKER_OBJECT_CLASS_NAME +}; +var QUEUES_PLUGIN = { + options: QueuesOptionsSchema, + getBindings(options) { + const queues = namespaceEntries(options.queueProducers); + return queues.map(([name, id]) => ({ + name, + queue: { name: `${SERVICE_QUEUE_PREFIX}:${id}` } + })); + }, + getNodeBindings(options) { + const queues = namespaceKeys(options.queueProducers); + return Object.fromEntries(queues.map((name) => [name, kProxyNodeBinding])); + }, + async getServices({ + options, + workerNames, + queueConsumers: allQueueConsumers + }) { + const queues = namespaceEntries(options.queueProducers); + if (queues.length === 0) + return []; + const services = queues.map(([_, id]) => ({ + name: `${SERVICE_QUEUE_PREFIX}:${id}`, + worker: objectEntryWorker(QUEUE_BROKER_OBJECT, id) + })); + const uniqueKey = `miniflare-${QUEUE_BROKER_OBJECT_CLASS_NAME}`; + const objectService = { + name: SERVICE_QUEUE_PREFIX, + worker: { + compatibilityDate: "2023-07-24", + compatibilityFlags: [ + "nodejs_compat", + "experimental", + "service_binding_extra_handlers" + ], + modules: [ + { name: "broker.worker.js", esModule: broker_worker_default() } + ], + durableObjectNamespaces: [ + { className: QUEUE_BROKER_OBJECT_CLASS_NAME, uniqueKey } + ], + // Miniflare's Queue broker is in-memory only at the moment + durableObjectStorage: { inMemory: kVoid }, + bindings: [ + { + name: SharedBindings.MAYBE_SERVICE_LOOPBACK, + service: { name: SERVICE_LOOPBACK } + }, + ...getControlEndpointBindings(), + { + name: SharedBindings.DURABLE_OBJECT_NAMESPACE_OBJECT, + durableObjectNamespace: { + className: QUEUE_BROKER_OBJECT_CLASS_NAME + } + }, + { + name: QueueBindings.MAYBE_JSON_QUEUE_CONSUMERS, + json: JSON.stringify(Object.fromEntries(allQueueConsumers)) + }, + ...workerNames.map((name) => ({ + name: QueueBindings.SERVICE_WORKER_PREFIX + name, + service: { name: getUserServiceName(name) } + })) + ] + } + }; + services.push(objectService); + return services; + } +}; + +// src/plugins/r2/index.ts +var import_promises9 = __toESM(require("fs/promises")); + +// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/r2/bucket.worker.ts +var import_fs16 = __toESM(require("fs")); +var import_path19 = __toESM(require("path")); +var import_url16 = __toESM(require("url")); +var contents12; +function bucket_worker_default() { + if (contents12 !== void 0) + return contents12; + const filePath = import_path19.default.join(__dirname, "workers", "r2/bucket.worker.js"); + contents12 = import_fs16.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url16.default.pathToFileURL(filePath); + return contents12; +} + +// src/plugins/r2/index.ts +var import_zod16 = require("zod"); +var R2OptionsSchema = import_zod16.z.object({ + r2Buckets: import_zod16.z.union([import_zod16.z.record(import_zod16.z.string()), import_zod16.z.string().array()]).optional() +}); +var R2SharedOptionsSchema = import_zod16.z.object({ + r2Persist: PersistenceSchema +}); +var R2_PLUGIN_NAME = "r2"; +var R2_STORAGE_SERVICE_NAME = `${R2_PLUGIN_NAME}:storage`; +var R2_BUCKET_SERVICE_PREFIX = `${R2_PLUGIN_NAME}:bucket`; +var R2_BUCKET_OBJECT_CLASS_NAME = "R2BucketObject"; +var R2_BUCKET_OBJECT = { + serviceName: R2_BUCKET_SERVICE_PREFIX, + className: R2_BUCKET_OBJECT_CLASS_NAME +}; +var R2_PLUGIN = { + options: R2OptionsSchema, + sharedOptions: R2SharedOptionsSchema, + getBindings(options) { + const buckets = namespaceEntries(options.r2Buckets); + return buckets.map(([name, id]) => ({ + name, + r2Bucket: { name: `${R2_BUCKET_SERVICE_PREFIX}:${id}` } + })); + }, + getNodeBindings(options) { + const buckets = namespaceKeys(options.r2Buckets); + return Object.fromEntries(buckets.map((name) => [name, kProxyNodeBinding])); + }, + async getServices({ options, sharedOptions, tmpPath, log }) { + const persist = sharedOptions.r2Persist; + const buckets = namespaceEntries(options.r2Buckets); + const services = buckets.map(([_, id]) => ({ + name: `${R2_BUCKET_SERVICE_PREFIX}:${id}`, + worker: objectEntryWorker(R2_BUCKET_OBJECT, id) + })); + if (buckets.length > 0) { + const uniqueKey = `miniflare-${R2_BUCKET_OBJECT_CLASS_NAME}`; + const persistPath = getPersistPath(R2_PLUGIN_NAME, tmpPath, persist); + await import_promises9.default.mkdir(persistPath, { recursive: true }); + const storageService = { + name: R2_STORAGE_SERVICE_NAME, + disk: { path: persistPath, writable: true } + }; + const objectService = { + name: R2_BUCKET_SERVICE_PREFIX, + worker: { + compatibilityDate: "2023-07-24", + compatibilityFlags: ["nodejs_compat", "experimental"], + modules: [ + { + name: "bucket.worker.js", + esModule: bucket_worker_default() + } + ], + durableObjectNamespaces: [ + { + className: R2_BUCKET_OBJECT_CLASS_NAME, + uniqueKey + } + ], + // Store Durable Object SQL databases in persist path + durableObjectStorage: { localDisk: R2_STORAGE_SERVICE_NAME }, + // Bind blob disk directory service to object + bindings: [ + { + name: SharedBindings.MAYBE_SERVICE_BLOBS, + service: { name: R2_STORAGE_SERVICE_NAME } + }, + { + name: SharedBindings.MAYBE_SERVICE_LOOPBACK, + service: { name: SERVICE_LOOPBACK } + }, + ...getControlEndpointBindings() + ] + } + }; + services.push(storageService, objectService); + for (const bucket of buckets) { + await migrateDatabase(log, uniqueKey, persistPath, bucket[1]); + } + } + return services; + } +}; + +// src/plugins/index.ts +var PLUGINS = { + [CORE_PLUGIN_NAME2]: CORE_PLUGIN, + [CACHE_PLUGIN_NAME]: CACHE_PLUGIN, + [D1_PLUGIN_NAME]: D1_PLUGIN, + [DURABLE_OBJECTS_PLUGIN_NAME]: DURABLE_OBJECTS_PLUGIN, + [KV_PLUGIN_NAME]: KV_PLUGIN, + [QUEUES_PLUGIN_NAME]: QUEUES_PLUGIN, + [R2_PLUGIN_NAME]: R2_PLUGIN, + [HYPERDRIVE_PLUGIN_NAME]: HYPERDRIVE_PLUGIN +}; +var PLUGIN_ENTRIES = Object.entries(PLUGINS); + +// src/http/cert.ts +var KEY = ` +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIC+umAaVUbEfPqGA9M7b5zAP7tN2eLT1bu8U8gpbaKbsoAoGCCqGSM49 +AwEHoUQDQgAEtrIEgzogjrUHIvB4qgjg/cT7blhWuLUfSUp6H62NCo21NrVWgPtC +mCWw+vbGTBwIr/9X1S4UL1/f3zDICC7YSA== +-----END EC PRIVATE KEY----- +`; +var CERT = ` +-----BEGIN CERTIFICATE----- +MIICcDCCAhegAwIBAgIUE97EcbEWw3YZMN/ucGBSzJ/5qA4wCgYIKoZIzj0EAwIw +VTELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVRleGFzMQ8wDQYDVQQHDAZBdXN0aW4x +EzARBgNVBAoMCkNsb3VkZmxhcmUxEDAOBgNVBAsMB1dvcmtlcnMwIBcNMjMwNjIy +MTg1ODQ3WhgPMjEyMzA1MjkxODU4NDdaMFUxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI +DAVUZXhhczEPMA0GA1UEBwwGQXVzdGluMRMwEQYDVQQKDApDbG91ZGZsYXJlMRAw +DgYDVQQLDAdXb3JrZXJzMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEtrIEgzog +jrUHIvB4qgjg/cT7blhWuLUfSUp6H62NCo21NrVWgPtCmCWw+vbGTBwIr/9X1S4U +L1/f3zDICC7YSKOBwjCBvzAdBgNVHQ4EFgQUSXahTksi00c6KhUECHIY4FLW7Sow +HwYDVR0jBBgwFoAUSXahTksi00c6KhUECHIY4FLW7SowDwYDVR0TAQH/BAUwAwEB +/zAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUw +CwYDVR0PBAQDAgL0MDEGA1UdJQQqMCgGCCsGAQUFBwMBBggrBgEFBQcDAgYIKwYB +BQUHAwMGCCsGAQUFBwMIMAoGCCqGSM49BAMCA0cAMEQCIE2qnXbKTHQ8wtwI+9XR +h4ivDyz7w7iGxn3+ccmj/CQqAiApdX/Iz/jGRzi04xFlE4GoPVG/zaMi64ckmIpE +ez/dHA== +-----END CERTIFICATE----- +`; + +// src/http/server.ts +async function configureEntrySocket(coreOpts) { + const httpOptions = { + // Even though we inject a `cf` object in the entry worker, allow it to + // be customised via `dispatchFetch` + cfBlobHeader: HEADER_CF_BLOB + }; + let privateKey = void 0; + let certificateChain = void 0; + if ((coreOpts.httpsKey || coreOpts.httpsKeyPath) && (coreOpts.httpsCert || coreOpts.httpsCertPath)) { + privateKey = await valueOrFile(coreOpts.httpsKey, coreOpts.httpsKeyPath); + certificateChain = await valueOrFile( + coreOpts.httpsCert, + coreOpts.httpsCertPath + ); + } else if (coreOpts.https) { + privateKey = KEY; + certificateChain = CERT; + } + let options; + if (privateKey && certificateChain) { + options = { + https: { + options: httpOptions, + tlsOptions: { + keypair: { + privateKey, + certificateChain + } + } + } + }; + } else { + options = { + http: httpOptions + }; + } + return { + name: SOCKET_ENTRY, + service: { name: SERVICE_ENTRY }, + ...options + }; +} +function valueOrFile(value, filePath) { + return value ?? (filePath && import_promises10.default.readFile(filePath, "utf8")); +} + +// src/http/helpers.ts +var import_os = require("os"); +function getAccessibleHosts(ipv4Only = false) { + const hosts = []; + Object.values((0, import_os.networkInterfaces)()).forEach((net2) => { + net2?.forEach(({ family, address }) => { + if (family === "IPv4" || family === 4) { + hosts.push(address); + } else if (!ipv4Only) { + hosts.push(address); + } + }); + }); + return hosts; +} + +// src/http/index.ts +var import_undici8 = require("undici"); + +// src/zod-format.ts +var import_assert10 = __toESM(require("assert")); +var import_util4 = __toESM(require("util")); +var kMessages = Symbol("kMessages"); +var kActual = Symbol("kActual"); +var kGroupId = Symbol("kGroupId"); +var groupColours = [ + yellow, + /* (green) */ + cyan, + blue, + magenta, + green +]; +var GroupCountsMap = Map; +function isAnnotation(value) { + return typeof value === "object" && value !== null && kMessages in value && kActual in value; +} +function isRecord(value) { + return typeof value === "object" && value !== null; +} +function arrayShallowEqual(a, b) { + if (a.length !== b.length) + return false; + for (let i = 0; i < a.length; i++) + if (a[i] !== b[i]) + return false; + return true; +} +function issueEqual(a, b) { + return a.message === b.message && arrayShallowEqual(a.path, b.path); +} +function hasMultipleDistinctMessages(issues, atDepth) { + let firstIssue; + for (const issue of issues) { + if (issue.path.length < atDepth) + continue; + if (firstIssue === void 0) + firstIssue = issue; + else if (!issueEqual(firstIssue, issue)) + return true; + } + return false; +} +function annotate(groupCounts, annotated, input, issue, path21, groupId) { + if (path21.length === 0) { + if (issue.code === "invalid_union") { + const unionIssues = issue.unionErrors.flatMap(({ issues }) => issues); + let newGroupId; + const multipleDistinct = hasMultipleDistinctMessages( + unionIssues, + // For this check, we only include messages that are deeper than our + // current level, so we don't include messages we'd ignore if we grouped + issue.path.length + 1 + ); + if (isRecord(input) && multipleDistinct) { + newGroupId = groupCounts.size; + groupCounts.set(newGroupId, 0); + } + for (const unionIssue of unionIssues) { + const unionPath = unionIssue.path.slice(issue.path.length); + if (multipleDistinct && unionPath.length === 0) + continue; + annotated = annotate( + groupCounts, + annotated, + input, + unionIssue, + unionPath, + newGroupId + ); + } + return annotated; + } + const message = issue.message; + if (annotated !== void 0) { + if (isAnnotation(annotated) && !annotated[kMessages].includes(message)) { + annotated[kMessages].push(message); + } + return annotated; + } + if (groupId !== void 0) { + const current = groupCounts.get(groupId); + (0, import_assert10.default)(current !== void 0); + groupCounts.set(groupId, current + 1); + } + return { + [kMessages]: [message], + [kActual]: input, + [kGroupId]: groupId + }; + } + const [head, ...tail] = path21; + (0, import_assert10.default)(isRecord(input), "Expected object/array input for nested issue"); + if (annotated === void 0) { + if (Array.isArray(input)) { + annotated = new Array(input.length); + } else { + const entries = Object.keys(input).map((key) => [key, void 0]); + annotated = Object.fromEntries(entries); + } + } + (0, import_assert10.default)(isRecord(annotated), "Expected object/array for nested issue"); + annotated[head] = annotate( + groupCounts, + annotated[head], + input[head], + issue, + tail, + groupId + ); + return annotated; +} +function print(inspectOptions, groupCounts, annotated, indent = "", extras) { + const prefix = extras?.prefix ?? ""; + const suffix = extras?.suffix ?? ""; + if (isAnnotation(annotated)) { + const prefixIndent = indent + " ".repeat(prefix.length); + const actual = import_util4.default.inspect(annotated[kActual], inspectOptions); + const actualIndented = actual.split("\n").map((line, i) => i > 0 ? prefixIndent + line : line).join("\n"); + let messageColour = red; + let messagePrefix = prefixIndent + "^"; + let groupOr = ""; + if (annotated[kGroupId] !== void 0) { + messageColour = groupColours[annotated[kGroupId] % groupColours.length]; + messagePrefix += annotated[kGroupId] + 1; + const remaining = groupCounts.get(annotated[kGroupId]); + (0, import_assert10.default)(remaining !== void 0); + if (remaining > 1) + groupOr = " *or*"; + groupCounts.set(annotated[kGroupId], remaining - 1); + } + messagePrefix += " "; + const messageIndent = " ".repeat(messagePrefix.length); + const messageIndented = annotated[kMessages].flatMap((m) => m.split("\n")).map((line, i) => i > 0 ? messageIndent + line : line).join("\n"); + const error = messageColour(`${messagePrefix}${messageIndented}${groupOr}`); + return `${indent}${dim(prefix)}${actualIndented}${dim(suffix)} +${error}`; + } else if (Array.isArray(annotated)) { + let result = `${indent}${dim(`${prefix}[`)} +`; + const arrayIndent = indent + " "; + for (let i = 0; i < annotated.length; i++) { + const value = annotated[i]; + if (value === void 0 && (i === 0 || annotated[i - 1] !== void 0)) { + result += `${arrayIndent}${dim("...,")} +`; + } + if (value !== void 0) { + result += print(inspectOptions, groupCounts, value, arrayIndent, { + prefix: `/* [${i}] */ `, + suffix: "," + }); + result += "\n"; + } + } + result += `${indent}${dim(`]${suffix}`)}`; + return result; + } else if (isRecord(annotated)) { + let result = `${indent}${dim(`${prefix}{`)} +`; + const objectIndent = indent + " "; + const entries = Object.entries(annotated); + for (let i = 0; i < entries.length; i++) { + const [key, value] = entries[i]; + if (value === void 0 && (i === 0 || entries[i - 1][1] !== void 0)) { + result += `${objectIndent}${dim("...,")} +`; + } + if (value !== void 0) { + result += print(inspectOptions, groupCounts, value, objectIndent, { + prefix: `${key}: `, + suffix: "," + }); + result += "\n"; + } + } + result += `${indent}${dim(`}${suffix}`)}`; + return result; + } + return ""; +} +function _formatZodError(error, input) { + const sortedIssues = Array.from(error.issues).sort((a, b) => { + if (a.code !== b.code) { + if (a.code === "invalid_union") + return -1; + if (b.code === "invalid_union") + return 1; + } + return 0; + }); + let annotated; + const groupCounts = new GroupCountsMap(); + for (const issue of sortedIssues) { + annotated = annotate(groupCounts, annotated, input, issue, issue.path); + } + const inspectOptions = { + depth: 0, + colors: $.enabled + }; + return print(inspectOptions, groupCounts, annotated); +} + +// src/index.ts +var DEFAULT_HOST = "127.0.0.1"; +function getURLSafeHost(host) { + return import_net.default.isIPv6(host) ? `[${host}]` : host; +} +function getAccessibleHost(host) { + const accessibleHost = host === "*" || host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host; + return getURLSafeHost(accessibleHost); +} +function getServerPort(server) { + const address = server.address(); + (0, import_assert11.default)(address !== null && typeof address === "object"); + return address.port; +} +function hasMultipleWorkers(opts) { + return typeof opts === "object" && opts !== null && "workers" in opts && Array.isArray(opts.workers); +} +function validateOptions(opts) { + const sharedOpts = opts; + const multipleWorkers = hasMultipleWorkers(opts); + const workerOpts = multipleWorkers ? opts.workers : [opts]; + if (workerOpts.length === 0) { + throw new MiniflareCoreError("ERR_NO_WORKERS", "No workers defined"); + } + const pluginSharedOpts = {}; + const pluginWorkerOpts = Array.from(Array(workerOpts.length)).map( + () => ({}) + ); + try { + for (const [key, plugin] of PLUGIN_ENTRIES) { + pluginSharedOpts[key] = plugin.sharedOptions?.parse(sharedOpts); + for (let i = 0; i < workerOpts.length; i++) { + const path21 = multipleWorkers ? ["workers", i] : void 0; + pluginWorkerOpts[i][key] = plugin.options.parse(workerOpts[i], { + path: path21 + }); + } + } + } catch (e) { + if (e instanceof import_zod18.z.ZodError) { + let formatted; + try { + formatted = _formatZodError(e, opts); + } catch (formatError) { + const title = "[Miniflare] Validation Error Format Failure"; + const message = [ + "### Input", + "```", + import_util5.default.inspect(opts, { depth: null }), + "```", + "", + "### Validation Error", + "```", + e.stack, + "```", + "", + "### Format Error", + "```", + typeof formatError === "object" && formatError !== null && "stack" in formatError && typeof formatError.stack === "string" ? formatError.stack : String(formatError), + "```" + ].join("\n"); + const githubIssueUrl = new URL( + "https://github.com/cloudflare/miniflare/issues/new" + ); + githubIssueUrl.searchParams.set("title", title); + githubIssueUrl.searchParams.set("body", message); + formatted = [ + "Unable to format validation error.", + "Please open the following URL in your browser to create a GitHub issue:", + githubIssueUrl, + "", + message, + "" + ].join("\n"); + } + const error = new MiniflareCoreError( + "ERR_VALIDATION", + `Unexpected options passed to \`new Miniflare()\` constructor: +${formatted}` + ); + Object.defineProperty(error, "cause", { get: () => e }); + throw error; + } + throw e; + } + const names = /* @__PURE__ */ new Set(); + for (const opts2 of pluginWorkerOpts) { + const name = opts2.core.name ?? ""; + if (names.has(name)) { + throw new MiniflareCoreError( + "ERR_DUPLICATE_NAME", + name === "" ? "Multiple workers defined without a `name`" : `Multiple workers defined with the same \`name\`: "${name}"` + ); + } + names.add(name); + } + return [pluginSharedOpts, pluginWorkerOpts]; +} +function getDurableObjectClassNames(allWorkerOpts) { + const serviceClassNames = /* @__PURE__ */ new Map(); + for (const workerOpts of allWorkerOpts) { + const workerServiceName = getUserServiceName(workerOpts.core.name); + for (const designator of Object.values( + workerOpts.do.durableObjects ?? {} + )) { + const { + className, + // Fallback to current worker service if name not defined + serviceName = workerServiceName, + unsafeUniqueKey, + unsafePreventEviction + } = normaliseDurableObject(designator); + let classNames = serviceClassNames.get(serviceName); + if (classNames === void 0) { + classNames = /* @__PURE__ */ new Map(); + serviceClassNames.set(serviceName, classNames); + } + if (classNames.has(className)) { + const existingInfo = classNames.get(className); + if (existingInfo?.unsafeUniqueKey !== unsafeUniqueKey) { + throw new MiniflareCoreError( + "ERR_DIFFERENT_UNIQUE_KEYS", + `Multiple unsafe unique keys defined for Durable Object "${className}" in "${serviceName}": ${JSON.stringify( + unsafeUniqueKey + )} and ${JSON.stringify(existingInfo?.unsafeUniqueKey)}` + ); + } + if (existingInfo?.unsafePreventEviction !== unsafePreventEviction) { + throw new MiniflareCoreError( + "ERR_DIFFERENT_PREVENT_EVICTION", + `Multiple unsafe prevent eviction values defined for Durable Object "${className}" in "${serviceName}": ${JSON.stringify( + unsafePreventEviction + )} and ${JSON.stringify(existingInfo?.unsafePreventEviction)}` + ); + } + } else { + classNames.set(className, { unsafeUniqueKey, unsafePreventEviction }); + } + } + } + return serviceClassNames; +} +function invalidWrappedAsBound(name, bindingType) { + const stringName = JSON.stringify(name); + throw new MiniflareCoreError( + "ERR_INVALID_WRAPPED", + `Cannot use ${stringName} for wrapped binding because it is bound to with ${bindingType} bindings. +Ensure other workers don't define ${bindingType} bindings to ${stringName}.` + ); +} +function getWrappedBindingNames(allWorkerOpts, durableObjectClassNames) { + const wrappedBindingWorkerNames = /* @__PURE__ */ new Set(); + for (const workerOpts of allWorkerOpts) { + for (const designator of Object.values( + workerOpts.core.wrappedBindings ?? {} + )) { + const scriptName = typeof designator === "object" ? designator.scriptName : designator; + if (durableObjectClassNames.has(getUserServiceName(scriptName))) { + invalidWrappedAsBound(scriptName, "Durable Object"); + } + wrappedBindingWorkerNames.add(scriptName); + } + } + for (const workerOpts of allWorkerOpts) { + for (const designator of Object.values( + workerOpts.core.serviceBindings ?? {} + )) { + if (typeof designator !== "string") + continue; + if (wrappedBindingWorkerNames.has(designator)) { + invalidWrappedAsBound(designator, "service"); + } + } + } + return wrappedBindingWorkerNames; +} +function getQueueConsumers(allWorkerOpts) { + const queueConsumers = /* @__PURE__ */ new Map(); + for (const workerOpts of allWorkerOpts) { + const workerName = workerOpts.core.name ?? ""; + let workerConsumers = workerOpts.queues.queueConsumers; + if (workerConsumers !== void 0) { + if (Array.isArray(workerConsumers)) { + workerConsumers = Object.fromEntries( + workerConsumers.map((queueName) => [queueName, {}]) + ); + } + for (const [queueName, opts] of Object.entries(workerConsumers)) { + const existingConsumer = queueConsumers.get(queueName); + if (existingConsumer !== void 0) { + throw new QueuesError( + "ERR_MULTIPLE_CONSUMERS", + `Multiple consumers defined for queue "${queueName}": "${existingConsumer.workerName}" and "${workerName}"` + ); + } + queueConsumers.set(queueName, { workerName, ...opts }); + } + } + } + for (const [queueName, consumer] of queueConsumers) { + if (consumer.deadLetterQueue === queueName) { + throw new QueuesError( + "ERR_DEAD_LETTER_QUEUE_CYCLE", + `Dead letter queue for queue "${queueName}" cannot be itself` + ); + } + } + return queueConsumers; +} +function getWorkerRoutes(allWorkerOpts, wrappedBindingNames) { + const allRoutes = /* @__PURE__ */ new Map(); + for (const workerOpts of allWorkerOpts) { + const name = workerOpts.core.name ?? ""; + if (wrappedBindingNames.has(name)) + continue; + (0, import_assert11.default)(!allRoutes.has(name)); + allRoutes.set(name, workerOpts.core.routes ?? []); + } + return allRoutes; +} +function getProxyBindingName(plugin, worker, binding) { + return [ + CoreBindings.DURABLE_OBJECT_NAMESPACE_PROXY, + plugin, + worker, + binding + ].join(":"); +} +function isNativeTargetBinding(binding) { + return !("json" in binding || "wasmModule" in binding || "text" in binding || "data" in binding); +} +function buildProxyBinding(plugin, worker, binding) { + (0, import_assert11.default)(binding.name !== void 0); + const name = getProxyBindingName(plugin, worker, binding.name); + const proxyBinding = { ...binding, name }; + if ("durableObjectNamespace" in proxyBinding && proxyBinding.durableObjectNamespace !== void 0) { + proxyBinding.durableObjectNamespace.serviceName ??= getUserServiceName(worker); + } + return proxyBinding; +} +function getInternalDurableObjectProxyBindings(plugin, service) { + if (!("worker" in service)) + return; + (0, import_assert11.default)(service.worker !== void 0); + const serviceName = service.name; + (0, import_assert11.default)(serviceName !== void 0); + return service.worker.durableObjectNamespaces?.map(({ className }) => { + (0, import_assert11.default)(className !== void 0); + return { + name: getProxyBindingName(`${plugin}-internal`, serviceName, className), + durableObjectNamespace: { serviceName, className } + }; + }); +} +var restrictedUndiciHeaders = [ + // From Miniflare 2: + // https://github.com/cloudflare/miniflare/blob/9c135599dc21fe69080ada17fce6153692793bf1/packages/core/src/standards/http.ts#L129-L132 + "transfer-encoding", + "connection", + "keep-alive", + "expect" +]; +var restrictedWebSocketUpgradeHeaders = [ + "upgrade", + "connection", + "sec-websocket-accept" +]; +function _transformsForContentEncoding(encoding) { + const encoders = []; + if (!encoding) + return encoders; + const codings = encoding.toLowerCase().split(",").map((x) => x.trim()); + for (const coding of codings) { + if (/(x-)?gzip/.test(coding)) { + encoders.push(import_zlib.default.createGzip()); + } else if (/(x-)?deflate/.test(coding)) { + encoders.push(import_zlib.default.createDeflate()); + } else if (coding === "br") { + encoders.push(import_zlib.default.createBrotliCompress()); + } else { + encoders.length = 0; + break; + } + } + return encoders; +} +async function writeResponse(response, res) { + const headers = {}; + for (const entry of response.headers) { + const key = entry[0].toLowerCase(); + const value = entry[1]; + if (key === "set-cookie") { + headers[key] = response.headers.getSetCookie(); + } else { + headers[key] = value; + } + } + const encoding = headers["content-encoding"]?.toString(); + const encoders = _transformsForContentEncoding(encoding); + if (encoders.length > 0) { + delete headers["content-length"]; + } + res.writeHead(response.status, response.statusText, headers); + let initialStream = res; + for (let i = encoders.length - 1; i >= 0; i--) { + encoders[i].pipe(initialStream); + initialStream = encoders[i]; + } + if (response.body) { + for await (const chunk of response.body) { + if (chunk) + initialStream.write(chunk); + } + } + initialStream.end(); +} +function safeReadableStreamFrom(iterable) { + let iterator; + return new import_web5.ReadableStream( + { + async start() { + iterator = iterable[Symbol.asyncIterator](); + }, + // @ts-expect-error `pull` may return anything + async pull(controller) { + try { + const { done, value } = await iterator.next(); + if (done) { + queueMicrotask(() => controller.close()); + } else { + const buf = Buffer.isBuffer(value) ? value : Buffer.from(value); + controller.enqueue(new Uint8Array(buf)); + } + } catch { + queueMicrotask(() => controller.close()); + } + return controller.desiredSize > 0; + }, + async cancel() { + await iterator.return?.(); + } + }, + 0 + ); +} +var maybeInstanceRegistry; +function _initialiseInstanceRegistry() { + return maybeInstanceRegistry = /* @__PURE__ */ new Map(); +} +var Miniflare = class { + #previousSharedOpts; + #sharedOpts; + #workerOpts; + #log; + #runtime; + #removeExitHook; + #runtimeEntryURL; + #socketPorts; + #runtimeDispatcher; + #proxyClient; + // Path to temporary directory for use as scratch space/"in-memory" Durable + // Object storage. Note this may not exist, it's up to the consumers to + // create this if needed. Deleted on `dispose()`. + #tmpPath; + // Mutual exclusion lock for runtime operations (i.e. initialisation and + // updating config). This essentially puts initialisation and future updates + // in a queue, ensuring they're performed in calling order. + #runtimeMutex; + // Store `#init()` `Promise`, so we can propagate initialisation errors in + // `ready`. We would have no way of catching these otherwise. + #initPromise; + // Aborted when dispose() is called + #disposeController; + #loopbackServer; + #loopbackHost; + #liveReloadServer; + #webSocketServer; + #webSocketExtraHeaders; + constructor(opts) { + const [sharedOpts, workerOpts] = validateOptions(opts); + this.#sharedOpts = sharedOpts; + this.#workerOpts = workerOpts; + if (maybeInstanceRegistry !== void 0) { + const object = { name: "Miniflare", stack: "" }; + Error.captureStackTrace(object, Miniflare); + maybeInstanceRegistry.set(this, object.stack); + } + this.#log = this.#sharedOpts.core.log ?? new NoOpLog(); + this.#liveReloadServer = new import_ws3.WebSocketServer({ noServer: true }); + this.#webSocketServer = new import_ws3.WebSocketServer({ + noServer: true, + // Disable automatic handling of `Sec-WebSocket-Protocol` header, + // Cloudflare Workers require users to include this header themselves in + // `Response`s: https://github.com/cloudflare/miniflare/issues/179 + handleProtocols: () => false + }); + this.#webSocketExtraHeaders = /* @__PURE__ */ new WeakMap(); + this.#webSocketServer.on("headers", (headers, req) => { + const extra = this.#webSocketExtraHeaders.get(req); + this.#webSocketExtraHeaders.delete(req); + if (extra) { + for (const [key, value] of extra) { + if (!restrictedWebSocketUpgradeHeaders.includes(key.toLowerCase())) { + headers.push(`${key}: ${value}`); + } + } + } + }); + this.#tmpPath = import_path20.default.join( + import_os2.default.tmpdir(), + `miniflare-${import_crypto3.default.randomBytes(16).toString("hex")}` + ); + this.#runtime = new Runtime(); + this.#removeExitHook = (0, import_exit_hook.default)(() => { + void this.#runtime?.dispose(); + try { + import_fs17.default.rmSync(this.#tmpPath, { force: true, recursive: true }); + } catch (e) { + this.#log.debug(`Unable to remove temporary directory: ${String(e)}`); + } + }); + this.#disposeController = new AbortController(); + this.#runtimeMutex = new Mutex(); + this.#initPromise = this.#runtimeMutex.runWith(() => this.#assembleAndUpdateConfig()).catch((e) => { + maybeInstanceRegistry?.delete(this); + throw e; + }); + } + #handleReload() { + for (const ws of this.#liveReloadServer.clients) { + ws.close(1012, "Service Restart"); + } + for (const ws of this.#webSocketServer.clients) { + ws.close(1012, "Service Restart"); + } + } + async #handleLoopbackCustomService(request, customService) { + const slashIndex = customService.indexOf("/"); + const workerIndex = parseInt(customService.substring(0, slashIndex)); + const serviceKind = customService[slashIndex + 1]; + const serviceName = customService.substring(slashIndex + 2); + let service; + if (serviceKind === "#" /* UNKNOWN */) { + service = this.#workerOpts[workerIndex]?.core.serviceBindings?.[serviceName]; + } else if (serviceName === CUSTOM_SERVICE_KNOWN_OUTBOUND) { + service = this.#workerOpts[workerIndex]?.core.outboundService; + } + (0, import_assert11.default)(typeof service === "function"); + try { + const response = await service(request); + return import_zod18.z.instanceof(Response).parse(response); + } catch (e) { + return new Response(e?.stack ?? e, { status: 500 }); + } + } + get #workerSrcOpts() { + return this.#workerOpts.map(({ core }) => core); + } + #handleLoopback = async (req, res) => { + const headers = new import_undici8.Headers(); + for (const [name, values] of Object.entries(req.headers)) { + if (restrictedUndiciHeaders.includes(name)) + continue; + if (Array.isArray(values)) { + for (const value of values) + headers.append(name, value); + } else if (values !== void 0) { + headers.append(name, values); + } + } + const cfBlob = headers.get(HEADER_CF_BLOB); + headers.delete(HEADER_CF_BLOB); + (0, import_assert11.default)(!Array.isArray(cfBlob)); + const cf = cfBlob ? JSON.parse(cfBlob) : void 0; + const url13 = new URL( + headers.get(CoreHeaders.ORIGINAL_URL) ?? req.url ?? "", + "http://localhost" + ); + headers.delete(CoreHeaders.ORIGINAL_URL); + const noBody = req.method === "GET" || req.method === "HEAD"; + const body = noBody ? void 0 : safeReadableStreamFrom(req); + const request = new Request(url13, { + method: req.method, + headers, + body, + duplex: "half", + cf + }); + let response; + try { + const customService = request.headers.get(CoreHeaders.CUSTOM_SERVICE); + if (customService !== null) { + request.headers.delete(CoreHeaders.CUSTOM_SERVICE); + response = await this.#handleLoopbackCustomService( + request, + customService + ); + } else if (url13.pathname === "/core/error") { + response = await handlePrettyErrorRequest( + this.#log, + this.#workerSrcOpts, + request + ); + } else if (url13.pathname === "/core/log") { + const level = parseInt(request.headers.get(SharedHeaders.LOG_LEVEL)); + (0, import_assert11.default)( + 0 /* NONE */ <= level && level <= 5 /* VERBOSE */, + `Expected ${SharedHeaders.LOG_LEVEL} header to be log level, got ${level}` + ); + const logLevel = level; + let message = await request.text(); + if (!$.enabled) + message = stripAnsi(message); + this.#log.logWithLevel(logLevel, message); + response = new Response(null, { status: 204 }); + } + } catch (e) { + this.#log.error(e); + res?.writeHead(500); + res?.end(e?.stack ?? String(e)); + return; + } + if (res !== void 0) { + if (response === void 0) { + res.writeHead(404); + res.end(); + } else { + await writeResponse(response, res); + } + } + return response; + }; + #handleLoopbackUpgrade = async (req, socket, head) => { + const { pathname } = new URL(req.url ?? "", "http://localhost"); + if (pathname === "/cdn-cgi/mf/reload") { + this.#liveReloadServer.handleUpgrade(req, socket, head, (ws) => { + this.#liveReloadServer.emit("connection", ws, req); + }); + return; + } + const response = await this.#handleLoopback(req); + const webSocket = response?.webSocket; + if (response?.status === 101 && webSocket) { + this.#webSocketExtraHeaders.set(req, response.headers); + this.#webSocketServer.handleUpgrade(req, socket, head, (ws) => { + void coupleWebSocket(ws, webSocket); + this.#webSocketServer.emit("connection", ws, req); + }); + return; + } + const res = new import_http7.default.ServerResponse(req); + (0, import_assert11.default)(socket instanceof import_net.default.Socket); + res.assignSocket(socket); + if (!response || response.ok) { + res.writeHead(500); + res.end(); + this.#log.error( + new TypeError( + "Web Socket request did not return status 101 Switching Protocols response with Web Socket" + ) + ); + return; + } + await writeResponse(response, res); + }; + async #getLoopbackPort() { + const loopbackHost = this.#sharedOpts.core.host ?? DEFAULT_HOST; + if (this.#loopbackServer !== void 0) { + if (this.#loopbackHost === loopbackHost) { + return getServerPort(this.#loopbackServer); + } + await this.#stopLoopbackServer(); + } + this.#loopbackServer = await this.#startLoopbackServer(loopbackHost); + this.#loopbackHost = loopbackHost; + return getServerPort(this.#loopbackServer); + } + #startLoopbackServer(hostname) { + if (hostname === "*") + hostname = "::"; + return new Promise((resolve) => { + const server = (0, import_stoppable.default)( + import_http7.default.createServer(this.#handleLoopback), + /* grace */ + 0 + ); + server.on("upgrade", this.#handleLoopbackUpgrade); + server.listen(0, hostname, () => resolve(server)); + }); + } + #stopLoopbackServer() { + return new Promise((resolve, reject) => { + (0, import_assert11.default)(this.#loopbackServer !== void 0); + this.#loopbackServer.stop((err) => err ? reject(err) : resolve()); + }); + } + #getSocketAddress(id, previousRequestedPort, host = DEFAULT_HOST, requestedPort) { + if (requestedPort === 0 && previousRequestedPort === 0) { + requestedPort = this.#socketPorts?.get(id); + } + return `${host}:${requestedPort ?? 0}`; + } + async #assembleConfig(loopbackPort) { + const allWorkerOpts = this.#workerOpts; + const sharedOpts = this.#sharedOpts; + sharedOpts.core.cf = await setupCf(this.#log, sharedOpts.core.cf); + const durableObjectClassNames = getDurableObjectClassNames(allWorkerOpts); + const wrappedBindingNames = getWrappedBindingNames( + allWorkerOpts, + durableObjectClassNames + ); + const queueConsumers = getQueueConsumers(allWorkerOpts); + const allWorkerRoutes = getWorkerRoutes(allWorkerOpts, wrappedBindingNames); + const workerNames = [...allWorkerRoutes.keys()]; + const services = /* @__PURE__ */ new Map(); + const extensions = [ + { + modules: [ + { name: "miniflare:shared", esModule: index_worker_default() }, + { name: "miniflare:zod", esModule: zod_worker_default() } + ] + } + ]; + const sockets = [await configureEntrySocket(sharedOpts.core)]; + const proxyBindings = []; + const allWorkerBindings = /* @__PURE__ */ new Map(); + const wrappedBindingsToPopulate = []; + for (let i = 0; i < allWorkerOpts.length; i++) { + const workerOpts = allWorkerOpts[i]; + const workerName = workerOpts.core.name ?? ""; + const isModulesWorker = Boolean(workerOpts.core.modules); + const workerBindings = []; + allWorkerBindings.set(workerName, workerBindings); + const additionalModules = []; + for (const [key, plugin] of PLUGIN_ENTRIES) { + const pluginBindings = await plugin.getBindings(workerOpts[key], i); + if (pluginBindings !== void 0) { + for (const binding of pluginBindings) { + if (key === "kv" && binding.name === SiteBindings.JSON_SITE_MANIFEST && isModulesWorker) { + (0, import_assert11.default)("json" in binding && binding.json !== void 0); + additionalModules.push({ + name: SiteBindings.JSON_SITE_MANIFEST, + text: binding.json + }); + } else { + workerBindings.push(binding); + } + if (isNativeTargetBinding(binding)) { + proxyBindings.push(buildProxyBinding(key, workerName, binding)); + } + if ("wrapped" in binding && binding.wrapped?.moduleName !== void 0 && binding.wrapped.innerBindings !== void 0) { + const workerName2 = maybeWrappedModuleToWorkerName( + binding.wrapped.moduleName + ); + if (workerName2 !== void 0) { + wrappedBindingsToPopulate.push({ + workerName: workerName2, + innerBindings: binding.wrapped.innerBindings + }); + } + } + } + } + } + const unsafeEphemeralDurableObjects = workerOpts.core.unsafeEphemeralDurableObjects ?? false; + const pluginServicesOptionsBase = { + log: this.#log, + workerBindings, + workerIndex: i, + additionalModules, + tmpPath: this.#tmpPath, + workerNames, + wrappedBindingNames, + durableObjectClassNames, + unsafeEphemeralDurableObjects, + queueConsumers + }; + for (const [key, plugin] of PLUGIN_ENTRIES) { + const pluginServicesExtensions = await plugin.getServices({ + ...pluginServicesOptionsBase, + // @ts-expect-error `CoreOptionsSchema` has required options which are + // missing in other plugins' options. + options: workerOpts[key], + // @ts-expect-error `QueuesPlugin` doesn't define shared options + sharedOptions: sharedOpts[key] + }); + if (pluginServicesExtensions !== void 0) { + let pluginServices; + if (Array.isArray(pluginServicesExtensions)) { + pluginServices = pluginServicesExtensions; + } else { + pluginServices = pluginServicesExtensions.services; + extensions.push(...pluginServicesExtensions.extensions); + } + for (const service of pluginServices) { + if (service.name !== void 0 && !services.has(service.name)) { + services.set(service.name, service); + if (key !== DURABLE_OBJECTS_PLUGIN_NAME) { + const maybeBindings = getInternalDurableObjectProxyBindings( + key, + service + ); + if (maybeBindings !== void 0) { + proxyBindings.push(...maybeBindings); + } + } + } + } + } + } + const { unsafeDirectHost, unsafeDirectPort } = workerOpts.core; + if (unsafeDirectHost !== void 0 || unsafeDirectPort !== void 0) { + const name = getDirectSocketName(i); + const address = this.#getSocketAddress( + name, + // We don't attempt to reuse allocated ports for `unsafeDirectPort: 0` + // as there's not always a clear mapping between current/previous + // worker options. We could do it by index, names, script, etc. + // This is an unsafe option primarily intended for Wrangler's + // inspector proxy, which will usually set this value to `9229`. + // We could consider changing this in the future. + /* previousRequestedPort */ + void 0, + unsafeDirectHost, + unsafeDirectPort + ); + sockets.push({ + name, + address, + service: { name: getUserServiceName(workerName) }, + http: {} + }); + } + } + const globalServices = getGlobalServices({ + sharedOptions: sharedOpts.core, + allWorkerRoutes, + fallbackWorkerName: this.#workerOpts[0].core.name, + loopbackPort, + log: this.#log, + proxyBindings + }); + for (const service of globalServices) { + (0, import_assert11.default)(service.name !== void 0 && !services.has(service.name)); + services.set(service.name, service); + } + for (const toPopulate of wrappedBindingsToPopulate) { + const bindings = allWorkerBindings.get(toPopulate.workerName); + if (bindings === void 0) + continue; + const existingBindingNames = new Set( + toPopulate.innerBindings.map(({ name }) => name) + ); + toPopulate.innerBindings.push( + ...bindings.filter(({ name }) => !existingBindingNames.has(name)) + ); + } + const servicesArray = Array.from(services.values()); + if (wrappedBindingsToPopulate.length > 0 && _isCyclic(servicesArray)) { + throw new MiniflareCoreError( + "ERR_CYCLIC", + "Generated workerd config contains cycles. Ensure wrapped bindings don't have bindings to themselves." + ); + } + return { services: servicesArray, sockets, extensions }; + } + async #assembleAndUpdateConfig() { + const initial = !this.#runtimeEntryURL; + (0, import_assert11.default)(this.#runtime !== void 0); + const loopbackPort = await this.#getLoopbackPort(); + const config = await this.#assembleConfig(loopbackPort); + const configBuffer = serializeConfig(config); + (0, import_assert11.default)(config.sockets !== void 0); + const requiredSockets = config.sockets.map( + ({ name }) => { + (0, import_assert11.default)(name !== void 0); + return name; + } + ); + if (this.#sharedOpts.core.inspectorPort !== void 0) { + requiredSockets.push(kInspectorSocket); + } + const host = this.#sharedOpts.core.host ?? DEFAULT_HOST; + const urlSafeHost = getURLSafeHost(host); + const accessibleHost = getAccessibleHost(host); + const entryAddress = this.#getSocketAddress( + SOCKET_ENTRY, + this.#previousSharedOpts?.core.port, + host, + this.#sharedOpts.core.port + ); + let inspectorAddress; + if (this.#sharedOpts.core.inspectorPort !== void 0) { + inspectorAddress = this.#getSocketAddress( + kInspectorSocket, + this.#previousSharedOpts?.core.inspectorPort, + "localhost", + this.#sharedOpts.core.inspectorPort + ); + } + const runtimeOpts = { + signal: this.#disposeController.signal, + entryAddress, + loopbackPort, + requiredSockets, + inspectorAddress, + verbose: this.#sharedOpts.core.verbose, + handleRuntimeStdio: this.#sharedOpts.core.handleRuntimeStdio + }; + const maybeSocketPorts = await this.#runtime.updateConfig( + configBuffer, + runtimeOpts + ); + if (this.#disposeController.signal.aborted) + return; + if (maybeSocketPorts === void 0) { + throw new MiniflareCoreError( + "ERR_RUNTIME_FAILURE", + "The Workers runtime failed to start. There is likely additional logging output above." + ); + } + this.#socketPorts = maybeSocketPorts; + const entrySocket = config.sockets?.[0]; + const secure = entrySocket !== void 0 && "https" in entrySocket; + const previousEntryURL = this.#runtimeEntryURL; + const entryPort = maybeSocketPorts.get(SOCKET_ENTRY); + (0, import_assert11.default)(entryPort !== void 0); + this.#runtimeEntryURL = new URL( + `${secure ? "https" : "http"}://${accessibleHost}:${entryPort}` + ); + if (previousEntryURL?.toString() !== this.#runtimeEntryURL.toString()) { + this.#runtimeDispatcher = new import_undici9.Pool(this.#runtimeEntryURL, { + connect: { rejectUnauthorized: false } + }); + registerAllowUnauthorizedDispatcher(this.#runtimeDispatcher); + } + if (this.#proxyClient === void 0) { + this.#proxyClient = new ProxyClient( + this.#runtimeEntryURL, + this.dispatchFetch + ); + } else { + this.#proxyClient.setRuntimeEntryURL(this.#runtimeEntryURL); + } + if (!this.#runtimeMutex.hasWaiting) { + const ready = initial ? "Ready" : "Updated and ready"; + this.#log.info( + `${ready} on ${secure ? "https" : "http"}://${urlSafeHost}:${entryPort}` + ); + if (initial) { + const hosts = []; + if (host === "::" || host === "*" || host === "0.0.0.0") { + hosts.push(...getAccessibleHosts(true)); + if (host !== "0.0.0.0") { + hosts.push("localhost"); + hosts.push("[::1]"); + } + } + for (const h of hosts) { + this.#log.info(`- ${secure ? "https" : "http"}://${h}:${entryPort}`); + } + } + this.#handleReload(); + } + } + async #waitForReady(disposing = false) { + await this.#initPromise; + await this.#runtimeMutex.drained(); + if (disposing) + return new URL("http://[100::]/"); + this.#checkDisposed(); + (0, import_assert11.default)(this.#runtimeEntryURL !== void 0); + return new URL(this.#runtimeEntryURL.toString()); + } + get ready() { + return this.#waitForReady(); + } + async getInspectorURL() { + this.#checkDisposed(); + await this.ready; + (0, import_assert11.default)(this.#socketPorts !== void 0); + const maybePort = this.#socketPorts.get(kInspectorSocket); + if (maybePort === void 0) { + throw new TypeError( + "Inspector not enabled in Miniflare instance. Set the `inspectorPort` option to enable it." + ); + } + return new URL(`ws://127.0.0.1:${maybePort}`); + } + async unsafeGetDirectURL(workerName) { + this.#checkDisposed(); + await this.ready; + const workerIndex = this.#findAndAssertWorkerIndex(workerName); + const workerOpts = this.#workerOpts[workerIndex]; + const socketName = getDirectSocketName(workerIndex); + (0, import_assert11.default)(this.#socketPorts !== void 0); + const maybePort = this.#socketPorts.get(socketName); + if (maybePort === void 0) { + const friendlyWorkerName = workerName === void 0 ? "entrypoint" : JSON.stringify(workerName); + throw new TypeError( + `Direct access disabled in ${friendlyWorkerName} worker` + ); + } + const host = workerOpts.core.unsafeDirectHost ?? DEFAULT_HOST; + const accessibleHost = getAccessibleHost(host); + return new URL(`http://${accessibleHost}:${maybePort}`); + } + #checkDisposed() { + if (this.#disposeController.signal.aborted) { + throw new MiniflareCoreError( + "ERR_DISPOSED", + "Cannot use disposed instance" + ); + } + } + async #setOptions(opts) { + const [sharedOpts, workerOpts] = validateOptions(opts); + this.#previousSharedOpts = this.#sharedOpts; + this.#sharedOpts = sharedOpts; + this.#workerOpts = workerOpts; + this.#log = this.#sharedOpts.core.log ?? this.#log; + await this.#assembleAndUpdateConfig(); + } + setOptions(opts) { + this.#checkDisposed(); + this.#proxyClient?.poisonProxies(); + return this.#runtimeMutex.runWith(() => this.#setOptions(opts)); + } + dispatchFetch = async (input, init2) => { + this.#checkDisposed(); + await this.ready; + (0, import_assert11.default)(this.#runtimeEntryURL !== void 0); + (0, import_assert11.default)(this.#runtimeDispatcher !== void 0); + const forward = new Request(input, init2); + const url13 = new URL(forward.url); + forward.headers.set(CoreHeaders.ORIGINAL_URL, url13.toString()); + forward.headers.set(CoreHeaders.DISABLE_PRETTY_ERROR, "true"); + url13.protocol = this.#runtimeEntryURL.protocol; + url13.host = this.#runtimeEntryURL.host; + if (forward.cf) { + const cf = { ...fallbackCf, ...forward.cf }; + forward.headers.set(HEADER_CF_BLOB, JSON.stringify(cf)); + } + if (forward.body !== null && forward.headers.get("Content-Length") === "0") { + forward.headers.delete("Content-Length"); + } + const forwardInit = forward; + forwardInit.dispatcher = this.#runtimeDispatcher; + const response = await fetch2(url13, forwardInit); + const stack = response.headers.get(CoreHeaders.ERROR_STACK); + if (response.status === 500 && stack !== null) { + const caught = JsonErrorSchema.parse(await response.json()); + throw reviveError(this.#workerSrcOpts, caught); + } + if (process.env.MINIFLARE_ASSERT_BODIES_CONSUMED === "true" && response.body !== null) { + const originalLimit = Error.stackTraceLimit; + Error.stackTraceLimit = Infinity; + const error = new Error( + "`body` returned from `Miniflare#dispatchFetch()` not consumed immediately" + ); + Error.stackTraceLimit = originalLimit; + setImmediate(() => { + if (!response.bodyUsed) + throw error; + }); + } + return response; + }; + /** @internal */ + async _getProxyClient() { + this.#checkDisposed(); + await this.ready; + (0, import_assert11.default)(this.#proxyClient !== void 0); + return this.#proxyClient; + } + #findAndAssertWorkerIndex(workerName) { + if (workerName === void 0) { + return 0; + } else { + const index = this.#workerOpts.findIndex( + ({ core }) => (core.name ?? "") === workerName + ); + if (index === -1) { + throw new TypeError(`${JSON.stringify(workerName)} worker not found`); + } + return index; + } + } + async getBindings(workerName) { + const bindings = {}; + const proxyClient = await this._getProxyClient(); + const workerIndex = this.#findAndAssertWorkerIndex(workerName); + const workerOpts = this.#workerOpts[workerIndex]; + workerName = workerOpts.core.name ?? ""; + for (const [key, plugin] of PLUGIN_ENTRIES) { + const pluginBindings = await plugin.getNodeBindings(workerOpts[key]); + for (const [name, binding] of Object.entries(pluginBindings)) { + if (binding === kProxyNodeBinding) { + const proxyBindingName = getProxyBindingName(key, workerName, name); + const proxy = proxyClient.env[proxyBindingName]; + (0, import_assert11.default)( + proxy !== void 0, + `Expected ${proxyBindingName} to be bound` + ); + bindings[name] = proxy; + } else { + bindings[name] = binding; + } + } + } + return bindings; + } + async getWorker(workerName) { + const proxyClient = await this._getProxyClient(); + const workerIndex = this.#findAndAssertWorkerIndex(workerName); + const workerOpts = this.#workerOpts[workerIndex]; + workerName = workerOpts.core.name ?? ""; + const bindingName = CoreBindings.SERVICE_USER_ROUTE_PREFIX + workerName; + const fetcher = proxyClient.env[bindingName]; + if (fetcher === void 0) { + const stringName = JSON.stringify(workerName); + throw new TypeError( + `${stringName} is being used as a wrapped binding, and cannot be accessed as a worker` + ); + } + return fetcher; + } + async #getProxy(pluginName, bindingName, workerName) { + const proxyClient = await this._getProxyClient(); + const proxyBindingName = getProxyBindingName( + pluginName, + // Default to entrypoint worker if none specified + workerName ?? this.#workerOpts[0].core.name ?? "", + bindingName + ); + const proxy = proxyClient.env[proxyBindingName]; + if (proxy === void 0) { + const friendlyWorkerName = workerName === void 0 ? "entrypoint" : JSON.stringify(workerName); + throw new TypeError( + `${JSON.stringify(bindingName)} unbound in ${friendlyWorkerName} worker` + ); + } + return proxy; + } + // TODO(someday): would be nice to define these in plugins + async getCaches() { + const proxyClient = await this._getProxyClient(); + return proxyClient.global.caches; + } + getD1Database(bindingName, workerName) { + return this.#getProxy(D1_PLUGIN_NAME, bindingName, workerName); + } + getDurableObjectNamespace(bindingName, workerName) { + return this.#getProxy(DURABLE_OBJECTS_PLUGIN_NAME, bindingName, workerName); + } + getKVNamespace(bindingName, workerName) { + return this.#getProxy(KV_PLUGIN_NAME, bindingName, workerName); + } + getQueueProducer(bindingName, workerName) { + return this.#getProxy(QUEUES_PLUGIN_NAME, bindingName, workerName); + } + getR2Bucket(bindingName, workerName) { + return this.#getProxy(R2_PLUGIN_NAME, bindingName, workerName); + } + /** @internal */ + _getInternalDurableObjectNamespace(pluginName, serviceName, className) { + return this.#getProxy(`${pluginName}-internal`, className, serviceName); + } + async dispose() { + this.#disposeController.abort(); + this.#proxyClient?.poisonProxies(); + try { + await this.#waitForReady( + /* disposing */ + true + ); + } finally { + this.#removeExitHook?.(); + await this.#proxyClient?.dispose(); + await this.#runtime?.dispose(); + await this.#stopLoopbackServer(); + await import_fs17.default.promises.rm(this.#tmpPath, { force: true, recursive: true }); + maybeInstanceRegistry?.delete(this); + } + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + CACHE_PLUGIN, + CACHE_PLUGIN_NAME, + CORE_PLUGIN, + CORE_PLUGIN_NAME, + CacheBindings, + CacheHeaders, + CacheOptionsSchema, + CacheSharedOptionsSchema, + CloseEvent, + CoreBindings, + CoreHeaders, + CoreOptionsSchema, + CoreSharedOptionsSchema, + D1OptionsSchema, + D1SharedOptionsSchema, + D1_PLUGIN, + D1_PLUGIN_NAME, + DEFAULT_PERSIST_ROOT, + DURABLE_OBJECTS_PLUGIN, + DURABLE_OBJECTS_PLUGIN_NAME, + DURABLE_OBJECTS_STORAGE_SERVICE_NAME, + DeferredPromise, + DurableObjectsOptionsSchema, + DurableObjectsSharedOptionsSchema, + ErrorEvent, + File, + FormData, + HEADER_CF_BLOB, + HYPERDRIVE_PLUGIN, + HYPERDRIVE_PLUGIN_NAME, + Headers, + HttpOptions_Style, + HyperdriveInputOptionsSchema, + HyperdriveSchema, + JsonSchema, + KVHeaders, + KVLimits, + KVOptionsSchema, + KVParams, + KVSharedOptionsSchema, + KV_PLUGIN, + KV_PLUGIN_NAME, + LiteralSchema, + Log, + LogLevel, + MessageEvent, + Miniflare, + MiniflareCoreError, + MiniflareError, + ModuleDefinitionSchema, + ModuleRuleSchema, + ModuleRuleTypeSchema, + Mutex, + NoOpLog, + PLUGINS, + PLUGIN_ENTRIES, + PersistenceSchema, + ProxyAddresses, + ProxyClient, + ProxyOps, + QUEUES_PLUGIN, + QUEUES_PLUGIN_NAME, + QueueBindings, + QueueConsumerOptionsSchema, + QueueConsumerSchema, + QueueConsumersSchema, + QueueContentTypeSchema, + QueueIncomingMessageSchema, + QueuesBatchRequestSchema, + QueuesError, + QueuesOptionsSchema, + R2OptionsSchema, + R2SharedOptionsSchema, + R2_PLUGIN, + R2_PLUGIN_NAME, + Request, + Response, + RouterError, + Runtime, + SERVICE_ENTRY, + SERVICE_LOOPBACK, + SITES_NO_CACHE_PREFIX, + SOCKET_ENTRY, + SharedBindings, + SharedHeaders, + SiteBindings, + SourceOptionsSchema, + TlsOptions_Version, + TypedEventTarget, + WORKER_BINDING_SERVICE_LOOPBACK, + WaitGroup, + WebSocket, + WebSocketPair, + Worker_Binding_CryptoKey_Usage, + _enableControlEndpoints, + _forceColour, + _formatZodError, + _initialiseInstanceRegistry, + _isCyclic, + _transformsForContentEncoding, + base64Decode, + base64Encode, + configureEntrySocket, + coupleWebSocket, + createFetchMock, + createHTTPReducers, + createHTTPRevivers, + decodeSitesKey, + deserialiseRegExps, + deserialiseSiteRegExps, + encodeSitesKey, + fetch, + getAccessibleHosts, + getCacheServiceName, + getControlEndpointBindings, + getDirectSocketName, + getGlobalServices, + getPersistPath, + globsToRegExps, + isFetcherFetch, + isR2ObjectWriteHttpMetadata, + isSitesRequest, + kInspectorSocket, + kProxyNodeBinding, + kVoid, + matchRoutes, + maybeApply, + maybeParseURL, + migrateDatabase, + namespaceEntries, + namespaceKeys, + normaliseDurableObject, + objectEntryWorker, + parseRanges, + parseRoutes, + parseWithReadableStreams, + prefixError, + prefixStream, + readPrefix, + reduceError, + registerAllowUnauthorizedDispatcher, + sanitisePath, + serialiseRegExps, + serialiseSiteRegExps, + serializeConfig, + stringifyWithStreams, + stripAnsi, + structuredSerializableReducers, + structuredSerializableRevivers, + supportedCompatibilityDate, + testRegExps, + testSiteRegExps, + viewToBuffer, + zAwaitable +}); +/*! Path sanitisation regexps adapted from node-sanitize-filename: + * https://github.com/parshap/node-sanitize-filename/blob/209c39b914c8eb48ee27bcbde64b2c7822fdf3de/index.js#L4-L37 + * + * Licensed under the ISC license: + * + * Copyright Parsha Pourkhomami + * + * 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. + */ +/*! + * MIT License + * + * Copyright (c) Sindre Sorhus (https://sindresorhus.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. + */ +/*! + * Copyright (c) 2011 Felix Geisendörfer (felix@debuggable.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. + */ +//# sourceMappingURL=index.js.map diff --git a/node_modules/miniflare/dist/src/index.js.map b/node_modules/miniflare/dist/src/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2e92c48af5deaa51e631ef51011b9e7e1922ac81 --- /dev/null +++ b/node_modules/miniflare/dist/src/index.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../src/runtime/config/workerd.capnp.js", "../../src/index.ts", "../../../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/shared/index.worker.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/shared/zod.worker.ts", "../../src/cf.ts", "../../src/http/fetch.ts", "../../src/workers/cache/constants.ts", "../../src/workers/core/constants.ts", "../../src/workers/core/devalue.ts", "../../../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/utils.js", "../../../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/constants.js", "../../../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/parse.js", "../../../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/stringify.js", "../../src/workers/core/routing.ts", "../../src/workers/shared/constants.ts", "../../src/workers/shared/data.ts", "../../src/workers/shared/matcher.ts", "../../src/workers/shared/range.ts", "../../src/workers/shared/sync.ts", "../../src/workers/shared/types.ts", "../../src/workers/kv/constants.ts", "../../src/workers/queues/constants.ts", "../../src/workers/shared/zod.worker.ts", "../../src/workers/queues/schemas.ts", "../../src/http/request.ts", "../../src/http/response.ts", "../../src/http/websocket.ts", "../../src/shared/colour.ts", "../../src/shared/error.ts", "../../src/shared/event.ts", "../../src/shared/log.ts", "../../src/shared/matcher.ts", "../../src/shared/streams.ts", "../../src/shared/types.ts", "../../src/http/server.ts", "../../src/plugins/cache/index.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache.worker.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache-entry.worker.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache-entry-noop.worker.ts", "../../src/plugins/shared/index.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/shared/object-entry.worker.ts", "../../src/plugins/shared/constants.ts", "../../src/plugins/shared/routing.ts", "../../src/plugins/core/index.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/core/entry.worker.ts", "../../src/runtime/index.ts", "../../src/runtime/config/index.ts", "../../src/runtime/config/workerd.ts", "../../src/plugins/do/index.ts", "../../src/plugins/core/constants.ts", "../../src/plugins/core/modules.ts", "../../src/plugins/core/proxy/client.ts", "../../src/plugins/core/proxy/fetch-sync.ts", "../../src/plugins/core/errors/index.ts", "../../src/plugins/core/errors/sourcemap.ts", "../../src/plugins/core/errors/callsite.ts", "../../src/plugins/core/proxy/types.ts", "../../src/plugins/core/services.ts", "../../src/plugins/d1/index.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/d1/database.worker.ts", "../../src/plugins/hyperdrive/index.ts", "../../src/plugins/kv/index.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/kv/namespace.worker.ts", "../../src/plugins/kv/constants.ts", "../../src/plugins/kv/sites.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/kv/sites.worker.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/queues/broker.worker.ts", "../../src/plugins/queues/index.ts", "../../src/plugins/queues/errors.ts", "../../src/plugins/r2/index.ts", "embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/r2/bucket.worker.ts", "../../src/plugins/index.ts", "../../src/http/cert.ts", "../../src/http/helpers.ts", "../../src/http/index.ts", "../../src/zod-format.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAEA,WAAO,eAAe,SAAS,cAAc,EAAE,OAAO,KAAK,CAAC;AAC5D,YAAQ,YACP,QAAQ,mBACR,QAAQ,aACR,QAAQ,qBACR,QAAQ,qBACR,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,QAA8B;AAAA,MAAI;AAAA,IAC9C,UAAE;AAED,WAAK,kBAAkB;AAGvB,YAAM,KAAK,cAAc,QAAQ;AACjC,YAAM,KAAK,UAAU,QAAQ;AAC7B,YAAM,KAAK,oBAAoB;AAE/B,YAAM,YAAAQ,QAAG,SAAS,GAAG,KAAK,UAAU,EAAE,OAAO,MAAM,WAAW,KAAK,CAAC;AAIpE,6BAAuB,OAAO,IAAI;AAAA,IACnC;AAAA,EACD;AACD;", + "names": ["Config", "Socket_Which", "Socket", "ServiceDesignator", "Service_Which", "Service", "Worker", "ExternalServer", "Worker_Module_Which", "Worker_Module", "Worker_Binding_Type_Which", "Worker_Binding_DurableObjectNamespaceDesignator", "Worker_Binding_CryptoKey_Usage", "Worker_Binding_CryptoKey_Algorithm_Which", "Worker_Binding_CryptoKey_Which", "Worker_Binding_Which", "Worker_Binding", "Worker_DurableObjectNamespace_Which", "Worker_DurableObjectStorage_Which", "Worker_Which", "ExternalServer_Which", "HttpOptions_Style", "TlsOptions_Version", "Extension", "CORE_PLUGIN_NAME", "fetch", "supportedCompatibilityDate", "import_assert", "import_crypto", "import_fs", "import_http", "import_os", "import_path", "import_web", "import_util", "import_undici", "path", "fs", "url", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_ws", "import_zod", "import_path", "path", "assert", "import_undici", "import_ws", "revivers", "reducers", "index", "value", "assert", "url", "reducers", "value", "stringifiedValue", "revivers", "url", "path", "LogLevel", "import_node_buffer", "import_node_assert", "assert", "url", "import_node_buffer", "import_zod", "import_undici", "BaseRequest", "init", "import_undici", "BaseResponse", "url", "init", "import_assert", "import_path", "path", "globToRegexp", "import_zod", "init", "assert", "NodeWebSocket", "fetch", "init", "url", "NodeWebSocket", "baseFetch", "import_promises", "import_promises", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_zod", "import_fs", "import_promises", "import_path", "import_url", "import_zod", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_url", "url", "url", "path", "crypto", "fs", "fs", "import_assert", "import_fs", "import_promises", "import_path", "import_stream", "import_util", "import_undici", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_zod", "import_assert", "import_events", "import_workerd", "import_zod", "import_workerd_capnp", "CapnpConfig", "rl", "process", "workerdPath", "FORCE_COLOR", "childProcess", "assert", "import_promises", "import_zod", "fs", "import_assert", "import_fs", "import_path", "import_url", "import_zod", "module", "path", "rule", "assert", "contents", "import_assert", "import_crypto", "import_web", "import_util", "import_undici", "import_assert", "import_web", "import_fs", "import_path", "import_url", "import_zod", "import_assert", "assert", "contents", "fs", "module", "path", "url", "init", "assert", "import_web", "import_undici", "crypto", "url", "util", "assert", "key", "import_zod", "tls", "encoder", "fetch", "CORE_PLUGIN_NAME", "supportedCompatibilityDate", "path", "fs", "bindings", "moduleName", "name", "module", "invalidWrapped", "assert", "import_promises", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_zod", "fs", "import_zod", "url", "import_promises", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_zod", "import_assert", "import_promises", "import_path", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "fs", "path", "assert", "fs", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_zod", "import_promises", "import_fs", "import_path", "import_url", "contents", "path", "fs", "url", "import_zod", "fs", "CORE_PLUGIN_NAME", "fs", "net", "import_undici", "import_assert", "import_util", "path", "assert", "util", "net", "assert", "path", "util", "opts", "zlib", "os", "crypto", "exitHook", "fs", "url", "http", "stoppable", "workerName", "init", "fetch"] +} diff --git a/node_modules/miniflare/dist/src/workers/cache/cache-entry-noop.worker.js b/node_modules/miniflare/dist/src/workers/cache/cache-entry-noop.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..63b0686f796d096f3629dce8e7bb407e8cf88a72 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/cache/cache-entry-noop.worker.js @@ -0,0 +1,19 @@ +// src/workers/cache/constants.ts +var CacheHeaders = { + NAMESPACE: "cf-cache-namespace", + STATUS: "cf-cache-status" +}; + +// src/workers/cache/cache-entry-noop.worker.ts +var cache_entry_noop_worker_default = { + async fetch(request) { + return request.method === "GET" ? new Response(null, { + status: 504, + headers: { [CacheHeaders.STATUS]: "MISS" } + }) : request.method === "PUT" ? (await request.body?.pipeTo(new WritableStream()), new Response(null, { status: 204 })) : request.method === "PURGE" ? new Response(null, { status: 404 }) : new Response(null, { status: 405 }); + } +}; +export { + cache_entry_noop_worker_default as default +}; +//# sourceMappingURL=cache-entry-noop.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/cache/cache-entry-noop.worker.js.map b/node_modules/miniflare/dist/src/workers/cache/cache-entry-noop.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..27d36f91ae58e4b64cd7c902083982bd97cfe171 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/cache/cache-entry-noop.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/cache/constants.ts", "../../../../src/workers/cache/cache-entry-noop.worker.ts"], + "mappings": ";AAAO,IAAM,eAAe;AAAA,EAC3B,WAAW;AAAA,EACX,QAAQ;AACT;;;ACDA,IAAO,kCAAyB;AAAA,EAC/B,MAAM,MAAM,SAAS;AACpB,WAAI,QAAQ,WAAW,QACf,IAAI,SAAS,MAAM;AAAA,MACzB,QAAQ;AAAA,MACR,SAAS,EAAE,CAAC,aAAa,MAAM,GAAG,OAAO;AAAA,IAC1C,CAAC,IACS,QAAQ,WAAW,SAE7B,MAAM,QAAQ,MAAM,OAAO,IAAI,eAAe,CAAC,GACxC,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC,KAC/B,QAAQ,WAAW,UACtB,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC,IAElC,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA,EAE3C;AACD;", + "names": [] +} diff --git a/node_modules/miniflare/dist/src/workers/cache/cache-entry.worker.js b/node_modules/miniflare/dist/src/workers/cache/cache-entry.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..de457826b9a840f21094ce33a5f84c8f1a1dae7a --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/cache/cache-entry.worker.js @@ -0,0 +1,28 @@ +// src/workers/cache/cache-entry.worker.ts +import { SharedBindings } from "miniflare:shared"; + +// src/workers/cache/constants.ts +var CacheHeaders = { + NAMESPACE: "cf-cache-namespace", + STATUS: "cf-cache-status" +}, CacheBindings = { + MAYBE_JSON_CACHE_WARN_USAGE: "MINIFLARE_CACHE_WARN_USAGE" +}; + +// src/workers/cache/cache-entry.worker.ts +var cache_entry_worker_default = { + async fetch(request, env) { + let namespace = request.headers.get(CacheHeaders.NAMESPACE), name = namespace === null ? "default" : `named:${namespace}`, objectNamespace = env[SharedBindings.DURABLE_OBJECT_NAMESPACE_OBJECT], id = objectNamespace.idFromName(name), stub = objectNamespace.get(id), cf = { + ...request.cf, + miniflare: { + name, + cacheWarnUsage: env[CacheBindings.MAYBE_JSON_CACHE_WARN_USAGE] + } + }; + return await stub.fetch(request, { cf }); + } +}; +export { + cache_entry_worker_default as default +}; +//# sourceMappingURL=cache-entry.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/cache/cache-entry.worker.js.map b/node_modules/miniflare/dist/src/workers/cache/cache-entry.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..da2724007b58fb7fb410d96653218ec03d54fe79 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/cache/cache-entry.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/cache/cache-entry.worker.ts", "../../../../src/workers/cache/constants.ts"], + "mappings": ";AAAA,SAAmC,sBAAsB;;;ACAlD,IAAM,eAAe;AAAA,EAC3B,WAAW;AAAA,EACX,QAAQ;AACT,GAEa,gBAAgB;AAAA,EAC5B,6BAA6B;AAC9B;;;ADCA,IAAO,6BAA8B;AAAA,EACpC,MAAM,MAAM,SAAS,KAAK;AACzB,QAAM,YAAY,QAAQ,QAAQ,IAAI,aAAa,SAAS,GACtD,OAAO,cAAc,OAAO,YAAY,SAAS,aAEjD,kBAAkB,IAAI,eAAe,+BAA+B,GACpE,KAAK,gBAAgB,WAAW,IAAI,GACpC,OAAO,gBAAgB,IAAI,EAAE,GAC7B,KAA+C;AAAA,MACpD,GAAG,QAAQ;AAAA,MACX,WAAW;AAAA,QACV;AAAA,QACA,gBAAgB,IAAI,cAAc,2BAA2B;AAAA,MAC9D;AAAA,IACD;AACA,WAAO,MAAM,KAAK,MAAM,SAAS,EAAE,GAAkC,CAAC;AAAA,EACvE;AACD;", + "names": [] +} diff --git a/node_modules/miniflare/dist/src/workers/cache/cache.worker.js b/node_modules/miniflare/dist/src/workers/cache/cache.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..2e2611122ba295795aba33f830d7ec45db64841c --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/cache/cache.worker.js @@ -0,0 +1,655 @@ +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from == "object" || typeof from == "function") + for (let key of __getOwnPropNames(from)) + !__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: !0 }) : target, + mod +)); +var __decorateClass = (decorators, target, key, kind) => { + for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--) + (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result); + return kind && result && __defProp(target, key, result), result; +}; + +// ../../node_modules/.pnpm/http-cache-semantics@4.1.0/node_modules/http-cache-semantics/index.js +var require_http_cache_semantics = __commonJS({ + "../../node_modules/.pnpm/http-cache-semantics@4.1.0/node_modules/http-cache-semantics/index.js"(exports, module) { + "use strict"; + var statusCodeCacheableByDefault = /* @__PURE__ */ new Set([ + 200, + 203, + 204, + 206, + 300, + 301, + 404, + 405, + 410, + 414, + 501 + ]), understoodStatuses = /* @__PURE__ */ new Set([ + 200, + 203, + 204, + 300, + 301, + 302, + 303, + 307, + 308, + 404, + 405, + 410, + 414, + 501 + ]), errorStatusCodes = /* @__PURE__ */ new Set([ + 500, + 502, + 503, + 504 + ]), hopByHopHeaders = { + date: !0, + // included, because we add Age update Date + connection: !0, + "keep-alive": !0, + "proxy-authenticate": !0, + "proxy-authorization": !0, + te: !0, + trailer: !0, + "transfer-encoding": !0, + upgrade: !0 + }, excludedFromRevalidationUpdate = { + // Since the old body is reused, it doesn't make sense to change properties of the body + "content-length": !0, + "content-encoding": !0, + "transfer-encoding": !0, + "content-range": !0 + }; + function toNumberOrZero(s) { + let n = parseInt(s, 10); + return isFinite(n) ? n : 0; + } + function isErrorResponse(response) { + return response ? errorStatusCodes.has(response.status) : !0; + } + function parseCacheControl(header) { + let cc = {}; + if (!header) + return cc; + let parts = header.trim().split(/\s*,\s*/); + for (let part of parts) { + let [k, v] = part.split(/\s*=\s*/, 2); + cc[k] = v === void 0 ? !0 : v.replace(/^"|"$/g, ""); + } + return cc; + } + function formatCacheControl(cc) { + let parts = []; + for (let k in cc) { + let v = cc[k]; + parts.push(v === !0 ? k : k + "=" + v); + } + if (parts.length) + return parts.join(", "); + } + module.exports = class { + constructor(req, res, { + shared, + cacheHeuristic, + immutableMinTimeToLive, + ignoreCargoCult, + _fromObject + } = {}) { + if (_fromObject) { + this._fromObject(_fromObject); + return; + } + if (!res || !res.headers) + throw Error("Response headers missing"); + this._assertRequestHasHeaders(req), this._responseTime = this.now(), this._isShared = shared !== !1, this._cacheHeuristic = cacheHeuristic !== void 0 ? cacheHeuristic : 0.1, this._immutableMinTtl = immutableMinTimeToLive !== void 0 ? immutableMinTimeToLive : 24 * 3600 * 1e3, this._status = "status" in res ? res.status : 200, this._resHeaders = res.headers, this._rescc = parseCacheControl(res.headers["cache-control"]), this._method = "method" in req ? req.method : "GET", this._url = req.url, this._host = req.headers.host, this._noAuthorization = !req.headers.authorization, this._reqHeaders = res.headers.vary ? req.headers : null, this._reqcc = parseCacheControl(req.headers["cache-control"]), ignoreCargoCult && "pre-check" in this._rescc && "post-check" in this._rescc && (delete this._rescc["pre-check"], delete this._rescc["post-check"], delete this._rescc["no-cache"], delete this._rescc["no-store"], delete this._rescc["must-revalidate"], this._resHeaders = Object.assign({}, this._resHeaders, { + "cache-control": formatCacheControl(this._rescc) + }), delete this._resHeaders.expires, delete this._resHeaders.pragma), res.headers["cache-control"] == null && /no-cache/.test(res.headers.pragma) && (this._rescc["no-cache"] = !0); + } + now() { + return Date.now(); + } + storable() { + return !!(!this._reqcc["no-store"] && // A cache MUST NOT store a response to any request, unless: + // The request method is understood by the cache and defined as being cacheable, and + (this._method === "GET" || this._method === "HEAD" || this._method === "POST" && this._hasExplicitExpiration()) && // the response status code is understood by the cache, and + understoodStatuses.has(this._status) && // the "no-store" cache directive does not appear in request or response header fields, and + !this._rescc["no-store"] && // the "private" response directive does not appear in the response, if the cache is shared, and + (!this._isShared || !this._rescc.private) && // the Authorization header field does not appear in the request, if the cache is shared, + (!this._isShared || this._noAuthorization || this._allowsStoringAuthenticated()) && // the response either: + // contains an Expires header field, or + (this._resHeaders.expires || // contains a max-age response directive, or + // contains a s-maxage response directive and the cache is shared, or + // contains a public response directive. + this._rescc["max-age"] || this._isShared && this._rescc["s-maxage"] || this._rescc.public || // has a status code that is defined as cacheable by default + statusCodeCacheableByDefault.has(this._status))); + } + _hasExplicitExpiration() { + return this._isShared && this._rescc["s-maxage"] || this._rescc["max-age"] || this._resHeaders.expires; + } + _assertRequestHasHeaders(req) { + if (!req || !req.headers) + throw Error("Request headers missing"); + } + satisfiesWithoutRevalidation(req) { + this._assertRequestHasHeaders(req); + let requestCC = parseCacheControl(req.headers["cache-control"]); + return requestCC["no-cache"] || /no-cache/.test(req.headers.pragma) || requestCC["max-age"] && this.age() > requestCC["max-age"] || requestCC["min-fresh"] && this.timeToLive() < 1e3 * requestCC["min-fresh"] || this.stale() && !(requestCC["max-stale"] && !this._rescc["must-revalidate"] && (requestCC["max-stale"] === !0 || requestCC["max-stale"] > this.age() - this.maxAge())) ? !1 : this._requestMatches(req, !1); + } + _requestMatches(req, allowHeadMethod) { + return (!this._url || this._url === req.url) && this._host === req.headers.host && // the request method associated with the stored response allows it to be used for the presented request, and + (!req.method || this._method === req.method || allowHeadMethod && req.method === "HEAD") && // selecting header fields nominated by the stored response (if any) match those presented, and + this._varyMatches(req); + } + _allowsStoringAuthenticated() { + return this._rescc["must-revalidate"] || this._rescc.public || this._rescc["s-maxage"]; + } + _varyMatches(req) { + if (!this._resHeaders.vary) + return !0; + if (this._resHeaders.vary === "*") + return !1; + let fields = this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/); + for (let name of fields) + if (req.headers[name] !== this._reqHeaders[name]) + return !1; + return !0; + } + _copyWithoutHopByHopHeaders(inHeaders) { + let headers = {}; + for (let name in inHeaders) + hopByHopHeaders[name] || (headers[name] = inHeaders[name]); + if (inHeaders.connection) { + let tokens = inHeaders.connection.trim().split(/\s*,\s*/); + for (let name of tokens) + delete headers[name]; + } + if (headers.warning) { + let warnings = headers.warning.split(/,/).filter((warning) => !/^\s*1[0-9][0-9]/.test(warning)); + warnings.length ? headers.warning = warnings.join(",").trim() : delete headers.warning; + } + return headers; + } + responseHeaders() { + let headers = this._copyWithoutHopByHopHeaders(this._resHeaders), age = this.age(); + return age > 3600 * 24 && !this._hasExplicitExpiration() && this.maxAge() > 3600 * 24 && (headers.warning = (headers.warning ? `${headers.warning}, ` : "") + '113 - "rfc7234 5.5.4"'), headers.age = `${Math.round(age)}`, headers.date = new Date(this.now()).toUTCString(), headers; + } + /** + * Value of the Date response header or current time if Date was invalid + * @return timestamp + */ + date() { + let serverDate = Date.parse(this._resHeaders.date); + return isFinite(serverDate) ? serverDate : this._responseTime; + } + /** + * Value of the Age header, in seconds, updated for the current time. + * May be fractional. + * + * @return Number + */ + age() { + let age = this._ageValue(), residentTime = (this.now() - this._responseTime) / 1e3; + return age + residentTime; + } + _ageValue() { + return toNumberOrZero(this._resHeaders.age); + } + /** + * Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`. + * + * For an up-to-date value, see `timeToLive()`. + * + * @return Number + */ + maxAge() { + if (!this.storable() || this._rescc["no-cache"] || this._isShared && this._resHeaders["set-cookie"] && !this._rescc.public && !this._rescc.immutable || this._resHeaders.vary === "*") + return 0; + if (this._isShared) { + if (this._rescc["proxy-revalidate"]) + return 0; + if (this._rescc["s-maxage"]) + return toNumberOrZero(this._rescc["s-maxage"]); + } + if (this._rescc["max-age"]) + return toNumberOrZero(this._rescc["max-age"]); + let defaultMinTtl = this._rescc.immutable ? this._immutableMinTtl : 0, serverDate = this.date(); + if (this._resHeaders.expires) { + let expires = Date.parse(this._resHeaders.expires); + return Number.isNaN(expires) || expires < serverDate ? 0 : Math.max(defaultMinTtl, (expires - serverDate) / 1e3); + } + if (this._resHeaders["last-modified"]) { + let lastModified = Date.parse(this._resHeaders["last-modified"]); + if (isFinite(lastModified) && serverDate > lastModified) + return Math.max( + defaultMinTtl, + (serverDate - lastModified) / 1e3 * this._cacheHeuristic + ); + } + return defaultMinTtl; + } + timeToLive() { + let age = this.maxAge() - this.age(), staleIfErrorAge = age + toNumberOrZero(this._rescc["stale-if-error"]), staleWhileRevalidateAge = age + toNumberOrZero(this._rescc["stale-while-revalidate"]); + return Math.max(0, age, staleIfErrorAge, staleWhileRevalidateAge) * 1e3; + } + stale() { + return this.maxAge() <= this.age(); + } + _useStaleIfError() { + return this.maxAge() + toNumberOrZero(this._rescc["stale-if-error"]) > this.age(); + } + useStaleWhileRevalidate() { + return this.maxAge() + toNumberOrZero(this._rescc["stale-while-revalidate"]) > this.age(); + } + static fromObject(obj) { + return new this(void 0, void 0, { _fromObject: obj }); + } + _fromObject(obj) { + if (this._responseTime) + throw Error("Reinitialized"); + if (!obj || obj.v !== 1) + throw Error("Invalid serialization"); + this._responseTime = obj.t, this._isShared = obj.sh, this._cacheHeuristic = obj.ch, this._immutableMinTtl = obj.imm !== void 0 ? obj.imm : 24 * 3600 * 1e3, this._status = obj.st, this._resHeaders = obj.resh, this._rescc = obj.rescc, this._method = obj.m, this._url = obj.u, this._host = obj.h, this._noAuthorization = obj.a, this._reqHeaders = obj.reqh, this._reqcc = obj.reqcc; + } + toObject() { + return { + v: 1, + t: this._responseTime, + sh: this._isShared, + ch: this._cacheHeuristic, + imm: this._immutableMinTtl, + st: this._status, + resh: this._resHeaders, + rescc: this._rescc, + m: this._method, + u: this._url, + h: this._host, + a: this._noAuthorization, + reqh: this._reqHeaders, + reqcc: this._reqcc + }; + } + /** + * Headers for sending to the origin server to revalidate stale response. + * Allows server to return 304 to allow reuse of the previous response. + * + * Hop by hop headers are always stripped. + * Revalidation headers may be added or removed, depending on request. + */ + revalidationHeaders(incomingReq) { + this._assertRequestHasHeaders(incomingReq); + let headers = this._copyWithoutHopByHopHeaders(incomingReq.headers); + if (delete headers["if-range"], !this._requestMatches(incomingReq, !0) || !this.storable()) + return delete headers["if-none-match"], delete headers["if-modified-since"], headers; + if (this._resHeaders.etag && (headers["if-none-match"] = headers["if-none-match"] ? `${headers["if-none-match"]}, ${this._resHeaders.etag}` : this._resHeaders.etag), headers["accept-ranges"] || headers["if-match"] || headers["if-unmodified-since"] || this._method && this._method != "GET") { + if (delete headers["if-modified-since"], headers["if-none-match"]) { + let etags = headers["if-none-match"].split(/,/).filter((etag) => !/^\s*W\//.test(etag)); + etags.length ? headers["if-none-match"] = etags.join(",").trim() : delete headers["if-none-match"]; + } + } else + this._resHeaders["last-modified"] && !headers["if-modified-since"] && (headers["if-modified-since"] = this._resHeaders["last-modified"]); + return headers; + } + /** + * Creates new CachePolicy with information combined from the previews response, + * and the new revalidation response. + * + * Returns {policy, modified} where modified is a boolean indicating + * whether the response body has been modified, and old cached body can't be used. + * + * @return {Object} {policy: CachePolicy, modified: Boolean} + */ + revalidatedPolicy(request, response) { + if (this._assertRequestHasHeaders(request), this._useStaleIfError() && isErrorResponse(response)) + return { + modified: !1, + matches: !1, + policy: this + }; + if (!response || !response.headers) + throw Error("Response headers missing"); + let matches = !1; + if (response.status !== void 0 && response.status != 304 ? matches = !1 : response.headers.etag && !/^\s*W\//.test(response.headers.etag) ? matches = this._resHeaders.etag && this._resHeaders.etag.replace(/^\s*W\//, "") === response.headers.etag : this._resHeaders.etag && response.headers.etag ? matches = this._resHeaders.etag.replace(/^\s*W\//, "") === response.headers.etag.replace(/^\s*W\//, "") : this._resHeaders["last-modified"] ? matches = this._resHeaders["last-modified"] === response.headers["last-modified"] : !this._resHeaders.etag && !this._resHeaders["last-modified"] && !response.headers.etag && !response.headers["last-modified"] && (matches = !0), !matches) + return { + policy: new this.constructor(request, response), + // Client receiving 304 without body, even if it's invalid/mismatched has no option + // but to reuse a cached body. We don't have a good way to tell clients to do + // error recovery in such case. + modified: response.status != 304, + matches: !1 + }; + let headers = {}; + for (let k in this._resHeaders) + headers[k] = k in response.headers && !excludedFromRevalidationUpdate[k] ? response.headers[k] : this._resHeaders[k]; + let newResponse = Object.assign({}, response, { + status: this._status, + method: this._method, + headers + }); + return { + policy: new this.constructor(request, newResponse, { + shared: this._isShared, + cacheHeuristic: this._cacheHeuristic, + immutableMinTimeToLive: this._immutableMinTtl + }), + modified: !1, + matches: !0 + }; + } + }; + } +}); + +// src/workers/cache/cache.worker.ts +var import_http_cache_semantics = __toESM(require_http_cache_semantics()); +import assert from "node:assert"; +import { Buffer as Buffer2 } from "node:buffer"; +import { + DeferredPromise, + GET, + KeyValueStorage, + LogLevel, + MiniflareDurableObject, + PURGE, + PUT, + parseRanges +} from "miniflare:shared"; + +// src/workers/kv/constants.ts +import { testRegExps } from "miniflare:shared"; +var KVLimits = { + MIN_CACHE_TTL: 60, + MAX_LIST_KEYS: 1e3, + MAX_KEY_SIZE: 512, + MAX_VALUE_SIZE: 25 * 1024 * 1024, + MAX_VALUE_SIZE_TEST: 1024, + MAX_METADATA_SIZE: 1024 +}; +var SITES_NO_CACHE_PREFIX = "$__MINIFLARE_SITES__$/"; +function isSitesRequest(request) { + return new URL(request.url).pathname.startsWith(`/${SITES_NO_CACHE_PREFIX}`); +} + +// src/workers/cache/errors.worker.ts +import { HttpError } from "miniflare:shared"; + +// src/workers/cache/constants.ts +var CacheHeaders = { + NAMESPACE: "cf-cache-namespace", + STATUS: "cf-cache-status" +}; + +// src/workers/cache/errors.worker.ts +var CacheError = class extends HttpError { + constructor(code, message, headers = []) { + super(code, message); + this.headers = headers; + } + toResponse() { + return new Response(null, { + status: this.code, + headers: this.headers + }); + } + context(info) { + return this.message += ` (${info})`, this; + } +}, StorageFailure = class extends CacheError { + constructor() { + super(413, "Cache storage failed"); + } +}, PurgeFailure = class extends CacheError { + constructor() { + super(404, "Couldn't find asset to purge"); + } +}, CacheMiss = class extends CacheError { + constructor() { + super( + // workerd ignores this, but it's the correct status code + 504, + "Asset not found in cache", + [[CacheHeaders.STATUS, "MISS"]] + ); + } +}, RangeNotSatisfiable = class extends CacheError { + constructor(size) { + super(416, "Range not satisfiable", [ + ["Content-Range", `bytes */${size}`], + [CacheHeaders.STATUS, "HIT"] + ]); + } +}; + +// src/workers/cache/cache.worker.ts +function getCacheKey(req) { + return req.cf?.cacheKey ? String(req.cf?.cacheKey) : req.url; +} +function getExpiration(timers, req, res) { + let reqHeaders = normaliseHeaders(req.headers); + delete reqHeaders["cache-control"]; + let resHeaders = normaliseHeaders(res.headers); + resHeaders["cache-control"]?.toLowerCase().includes("private=set-cookie") && (resHeaders["cache-control"] = resHeaders["cache-control"]?.toLowerCase().replace(/private=set-cookie;?/i, ""), delete resHeaders["set-cookie"]); + let cacheReq = { + url: req.url, + // If a request gets to the Cache service, it's method will be GET. See README.md for details + method: "GET", + headers: reqHeaders + }, cacheRes = { + status: res.status, + headers: resHeaders + }, originalNow = import_http_cache_semantics.default.prototype.now; + import_http_cache_semantics.default.prototype.now = timers.now; + try { + let policy = new import_http_cache_semantics.default(cacheReq, cacheRes, { shared: !0 }); + return { + // Check if the request & response is cacheable + storable: policy.storable() && !("set-cookie" in resHeaders), + expiration: policy.timeToLive(), + // Cache Policy Headers is typed as [header: string]: string | string[] | undefined + // It's safe to ignore the undefined here, which is what casting to HeadersInit does + headers: policy.responseHeaders() + }; + } finally { + import_http_cache_semantics.default.prototype.now = originalNow; + } +} +function normaliseHeaders(headers) { + let result = {}; + for (let [key, value] of headers) + result[key.toLowerCase()] = value; + return result; +} +var etagRegexp = /^(W\/)?"(.+)"$/; +function parseETag(value) { + return etagRegexp.exec(value.trim())?.[2] ?? void 0; +} +var utcDateRegexp = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d\d (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d\d\d \d\d:\d\d:\d\d GMT$/; +function parseUTCDate(value) { + return utcDateRegexp.test(value) ? Date.parse(value) : NaN; +} +function getMatchResponse(reqHeaders, res) { + let reqIfNoneMatchHeader = reqHeaders.get("If-None-Match"), resETagHeader = res.headers.get("ETag"); + if (reqIfNoneMatchHeader !== null && resETagHeader !== null) { + let resETag = parseETag(resETagHeader); + if (resETag !== void 0) { + if (reqIfNoneMatchHeader.trim() === "*") + return new Response(null, { status: 304, headers: res.headers }); + for (let reqIfNoneMatch of reqIfNoneMatchHeader.split(",")) + if (resETag === parseETag(reqIfNoneMatch)) + return new Response(null, { status: 304, headers: res.headers }); + } + } + let reqIfModifiedSinceHeader = reqHeaders.get("If-Modified-Since"), resLastModifiedHeader = res.headers.get("Last-Modified"); + if (reqIfModifiedSinceHeader !== null && resLastModifiedHeader !== null) { + let reqIfModifiedSince = parseUTCDate(reqIfModifiedSinceHeader); + if (parseUTCDate(resLastModifiedHeader) <= reqIfModifiedSince) + return new Response(null, { status: 304, headers: res.headers }); + } + if (res.ranges.length > 0) + if (res.status = 206, res.ranges.length > 1) + assert(!(res.body instanceof ReadableStream)), res.headers.set("Content-Type", res.body.multipartContentType); + else { + let { start, end } = res.ranges[0]; + res.headers.set( + "Content-Range", + `bytes ${start}-${end}/${res.totalSize}` + ), res.headers.set("Content-Length", `${end - start + 1}`); + } + return res.body instanceof ReadableStream || (res.body = res.body.body), new Response(res.body, { status: res.status, headers: res.headers }); +} +var CR = "\r".charCodeAt(0), LF = ` +`.charCodeAt(0), STATUS_REGEXP = /^HTTP\/\d(?:\.\d)? (?\d+) (?.*)$/; +async function parseHttpResponse(stream) { + let buffer = Buffer2.alloc(0), blankLineIndex = -1; + for await (let chunk of stream.values({ preventCancel: !0 })) + if (buffer = Buffer2.concat([buffer, chunk]), blankLineIndex = buffer.findIndex( + (_value, index) => buffer[index] === CR && buffer[index + 1] === LF && buffer[index + 2] === CR && buffer[index + 3] === LF + ), blankLineIndex !== -1) + break; + assert(blankLineIndex !== -1, "Expected to find blank line in HTTP message"); + let rawStatusHeaders = buffer.subarray(0, blankLineIndex).toString(), [rawStatus, ...rawHeaders] = rawStatusHeaders.split(`\r +`), statusMatch = rawStatus.match(STATUS_REGEXP); + assert( + statusMatch?.groups != null, + `Expected first line ${JSON.stringify(rawStatus)} to be HTTP status line` + ); + let { rawStatusCode, statusText } = statusMatch.groups, statusCode = parseInt(rawStatusCode), headers = rawHeaders.map((rawHeader) => { + let index = rawHeader.indexOf(":"); + return [ + rawHeader.substring(0, index), + rawHeader.substring(index + 1).trim() + ]; + }), prefix = buffer.subarray( + blankLineIndex + 4 + /* "\r\n\r\n" */ + ), { readable, writable } = new IdentityTransformStream(), writer = writable.getWriter(); + return writer.write(prefix).then(() => (writer.releaseLock(), stream.pipeTo(writable))).catch((e) => console.error("Error writing HTTP body:", e)), new Response(readable, { status: statusCode, statusText, headers }); +} +var SizingStream = class extends TransformStream { + size; + constructor() { + let sizePromise = new DeferredPromise(), size = 0; + super({ + transform(chunk, controller) { + size += chunk.byteLength, controller.enqueue(chunk); + }, + flush() { + sizePromise.resolve(size); + } + }), this.size = sizePromise; + } +}, CacheObject = class extends MiniflareDurableObject { + #warnedUsage = !1; + async #maybeWarnUsage(request) { + !this.#warnedUsage && request.cf?.miniflare?.cacheWarnUsage === !0 && (this.#warnedUsage = !0, await this.logWithLevel( + LogLevel.WARN, + "Cache operations will have no impact if you deploy to a workers.dev subdomain!" + )); + } + #storage; + get storage() { + return this.#storage ??= new KeyValueStorage(this); + } + match = async (req) => { + await this.#maybeWarnUsage(req); + let cacheKey = getCacheKey(req); + if (isSitesRequest(req)) + throw new CacheMiss(); + let resHeaders, resRanges, cached = await this.storage.get(cacheKey, ({ size, headers }) => { + resHeaders = new Headers(headers); + let contentType = resHeaders.get("Content-Type"), rangeHeader = req.headers.get("Range"); + if (rangeHeader !== null && (resRanges = parseRanges(rangeHeader, size), resRanges === void 0)) + throw new RangeNotSatisfiable(size); + return { + ranges: resRanges, + contentLength: size, + contentType: contentType ?? void 0 + }; + }); + if (cached?.metadata === void 0) + throw new CacheMiss(); + return assert(resHeaders !== void 0), resHeaders.set("CF-Cache-Status", "HIT"), resRanges ??= [], getMatchResponse(req.headers, { + status: cached.metadata.status, + headers: resHeaders, + ranges: resRanges, + body: cached.value, + totalSize: cached.metadata.size + }); + }; + put = async (req) => { + await this.#maybeWarnUsage(req); + let cacheKey = getCacheKey(req); + if (isSitesRequest(req)) + throw new CacheMiss(); + assert(req.body !== null); + let res = await parseHttpResponse(req.body), body = res.body; + assert(body !== null); + let { storable, expiration, headers } = getExpiration( + this.timers, + req, + res + ); + if (!storable) { + try { + await body.pipeTo(new WritableStream()); + } catch { + } + throw new StorageFailure(); + } + let contentLength = parseInt(res.headers.get("Content-Length")), sizePromise; + if (Number.isNaN(contentLength)) { + let stream = new SizingStream(); + body = body.pipeThrough(stream), sizePromise = stream.size; + } else + sizePromise = Promise.resolve(contentLength); + let metadata = sizePromise.then((size) => ({ + headers: Object.entries(headers), + status: res.status, + size + })); + return await this.storage.put({ + key: cacheKey, + value: body, + expiration: this.timers.now() + expiration, + metadata + }), new Response(null, { status: 204 }); + }; + delete = async (req) => { + await this.#maybeWarnUsage(req); + let cacheKey = getCacheKey(req); + if (!await this.storage.delete(cacheKey)) + throw new PurgeFailure(); + return new Response(null); + }; +}; +__decorateClass([ + GET() +], CacheObject.prototype, "match", 2), __decorateClass([ + PUT() +], CacheObject.prototype, "put", 2), __decorateClass([ + PURGE() +], CacheObject.prototype, "delete", 2); +export { + CacheObject, + parseHttpResponse +}; +//# sourceMappingURL=cache.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/cache/cache.worker.js.map b/node_modules/miniflare/dist/src/workers/cache/cache.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ee4c6813720b9d969d40bc9b8f84a3f11fa08020 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/cache/cache.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../../../node_modules/.pnpm/http-cache-semantics@4.1.0/node_modules/http-cache-semantics/index.js", "../../../../src/workers/cache/cache.worker.ts", "../../../../src/workers/kv/constants.ts", "../../../../src/workers/cache/errors.worker.ts", "../../../../src/workers/cache/constants.ts"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAEA,QAAM,+BAA+B,oBAAI,IAAI;AAAA,MACzC;AAAA,MACA;AAA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,SAAS,OAAO,QAAQ,OAAO;AAAA,MAC/B,QAAQ,IAAI;AAAA,MACZ;AAAA,IACD,EAAE;AAEF,iBAAM,KAAK,QAAQ,IAAI;AAAA,MACtB,KAAK;AAAA,MACL,OAAO;AAAA,MACP,YAAY,KAAK,OAAO,IAAI,IAAI;AAAA,MAChC;AAAA,IACD,CAAC,GACM,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC1C;AAAA,EAGA,SAA4B,OAAO,QAAQ;AAC1C,UAAM,KAAK,gBAAgB,GAAG;AAC9B,QAAM,WAAW,YAAY,GAAG;AAIhC,QAAI,CAFY,MAAM,KAAK,QAAQ,OAAO,QAAQ;AAEpC,YAAM,IAAI,aAAa;AACrC,WAAO,IAAI,SAAS,IAAI;AAAA,EACzB;AACD;AA/GC;AAAA,EADC,IAAI;AAAA,GAlBO,YAmBZ,wBA8CA;AAAA,EADC,IAAI;AAAA,GAhEO,YAiEZ,sBAwDA;AAAA,EADC,MAAM;AAAA,GAxHK,YAyHZ;", + "names": ["Buffer", "CachePolicy", "Buffer"] +} diff --git a/node_modules/miniflare/dist/src/workers/core/entry.worker.js b/node_modules/miniflare/dist/src/workers/core/entry.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..7372c5a0c4cc4d3ab87bf41020491d12d9b01ea0 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/core/entry.worker.js @@ -0,0 +1,875 @@ +// ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs +var FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY = !0; +typeof process < "u" && ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {}, isTTY = process.stdout && process.stdout.isTTY); +var $ = { + enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY) +}; +function init(x, y) { + let rgx = new RegExp(`\\x1b\\[${y}m`, "g"), open = `\x1B[${x}m`, close = `\x1B[${y}m`; + return function(txt) { + return !$.enabled || txt == null ? txt : open + (~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close; + }; +} +var reset = init(0, 0), bold = init(1, 22), dim = init(2, 22), italic = init(3, 23), underline = init(4, 24), inverse = init(7, 27), hidden = init(8, 28), strikethrough = init(9, 29), black = init(30, 39), red = init(31, 39), green = init(32, 39), yellow = init(33, 39), blue = init(34, 39), magenta = init(35, 39), cyan = init(36, 39), white = init(37, 39), gray = init(90, 39), grey = init(90, 39), bgBlack = init(40, 49), bgRed = init(41, 49), bgGreen = init(42, 49), bgYellow = init(43, 49), bgBlue = init(44, 49), bgMagenta = init(45, 49), bgCyan = init(46, 49), bgWhite = init(47, 49); + +// src/workers/core/entry.worker.ts +import { LogLevel, SharedHeaders } from "miniflare:shared"; + +// src/workers/core/constants.ts +var CoreHeaders = { + CUSTOM_SERVICE: "MF-Custom-Service", + ORIGINAL_URL: "MF-Original-URL", + DISABLE_PRETTY_ERROR: "MF-Disable-Pretty-Error", + ERROR_STACK: "MF-Experimental-Error-Stack", + ROUTE_OVERRIDE: "MF-Route-Override", + // API Proxy + OP_SECRET: "MF-Op-Secret", + OP: "MF-Op", + OP_TARGET: "MF-Op-Target", + OP_KEY: "MF-Op-Key", + OP_SYNC: "MF-Op-Sync", + OP_STRINGIFIED_SIZE: "MF-Op-Stringified-Size", + OP_RESULT_TYPE: "MF-Op-Result-Type" +}, CoreBindings = { + SERVICE_LOOPBACK: "MINIFLARE_LOOPBACK", + SERVICE_USER_ROUTE_PREFIX: "MINIFLARE_USER_ROUTE_", + SERVICE_USER_FALLBACK: "MINIFLARE_USER_FALLBACK", + TEXT_CUSTOM_SERVICE: "MINIFLARE_CUSTOM_SERVICE", + TEXT_UPSTREAM_URL: "MINIFLARE_UPSTREAM_URL", + JSON_CF_BLOB: "CF_BLOB", + JSON_ROUTES: "MINIFLARE_ROUTES", + JSON_LOG_LEVEL: "MINIFLARE_LOG_LEVEL", + DATA_LIVE_RELOAD_SCRIPT: "MINIFLARE_LIVE_RELOAD_SCRIPT", + DURABLE_OBJECT_NAMESPACE_PROXY: "MINIFLARE_PROXY", + DATA_PROXY_SECRET: "MINIFLARE_PROXY_SECRET" +}, ProxyOps = { + // Get the target or a property of the target + GET: "GET", + // Get the descriptor for a property of the target + GET_OWN_DESCRIPTOR: "GET_OWN_DESCRIPTOR", + // Get the target's own property names + GET_OWN_KEYS: "GET_OWN_KEYS", + // Call a method on the target + CALL: "CALL", + // Remove the strong reference to the target on the "heap", allowing it to be + // garbage collected + FREE: "FREE" +}, ProxyAddresses = { + GLOBAL: 0, + // globalThis + ENV: 1, + // env + USER_START: 2 +}; +function isFetcherFetch(targetName, key) { + return (targetName === "Fetcher" || targetName === "DurableObject") && key === "fetch"; +} +function isR2ObjectWriteHttpMetadata(targetName, key) { + return (targetName === "HeadResult" || targetName === "GetResult") && key === "writeHttpMetadata"; +} + +// src/workers/core/http.ts +var STATUS_CODES = { + 100: "Continue", + 101: "Switching Protocols", + 102: "Processing", + 103: "Early Hints", + 200: "OK", + 201: "Created", + 202: "Accepted", + 203: "Non-Authoritative Information", + 204: "No Content", + 205: "Reset Content", + 206: "Partial Content", + 207: "Multi-Status", + 208: "Already Reported", + 226: "IM Used", + 300: "Multiple Choices", + 301: "Moved Permanently", + 302: "Found", + 303: "See Other", + 304: "Not Modified", + 305: "Use Proxy", + 307: "Temporary Redirect", + 308: "Permanent Redirect", + 400: "Bad Request", + 401: "Unauthorized", + 402: "Payment Required", + 403: "Forbidden", + 404: "Not Found", + 405: "Method Not Allowed", + 406: "Not Acceptable", + 407: "Proxy Authentication Required", + 408: "Request Timeout", + 409: "Conflict", + 410: "Gone", + 411: "Length Required", + 412: "Precondition Failed", + 413: "Payload Too Large", + 414: "URI Too Long", + 415: "Unsupported Media Type", + 416: "Range Not Satisfiable", + 417: "Expectation Failed", + 418: "I'm a Teapot", + 421: "Misdirected Request", + 422: "Unprocessable Entity", + 423: "Locked", + 424: "Failed Dependency", + 425: "Too Early", + 426: "Upgrade Required", + 428: "Precondition Required", + 429: "Too Many Requests", + 431: "Request Header Fields Too Large", + 451: "Unavailable For Legal Reasons", + 500: "Internal Server Error", + 501: "Not Implemented", + 502: "Bad Gateway", + 503: "Service Unavailable", + 504: "Gateway Timeout", + 505: "HTTP Version Not Supported", + 506: "Variant Also Negotiates", + 507: "Insufficient Storage", + 508: "Loop Detected", + 509: "Bandwidth Limit Exceeded", + 510: "Not Extended", + 511: "Network Authentication Required" +}; + +// src/workers/core/routing.ts +function matchRoutes(routes, url) { + for (let route of routes) { + if (route.protocol && route.protocol !== url.protocol) + continue; + if (route.allowHostnamePrefix) { + if (!url.hostname.endsWith(route.hostname)) + continue; + } else if (url.hostname !== route.hostname) + continue; + let path = url.pathname + url.search; + if (route.allowPathSuffix) { + if (!path.startsWith(route.path)) + continue; + } else if (path !== route.path) + continue; + return route.target; + } + return null; +} + +// src/workers/core/proxy.worker.ts +import assert2 from "node:assert"; +import { Buffer as Buffer2 } from "node:buffer"; + +// ../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/utils.js +var DevalueError = class extends Error { + /** + * @param {string} message + * @param {string[]} keys + */ + constructor(message, keys) { + super(message), this.name = "DevalueError", this.path = keys.join(""); + } +}; +function is_primitive(thing) { + return Object(thing) !== thing; +} +var object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames( + Object.prototype +).sort().join("\0"); +function is_plain_object(thing) { + let proto = Object.getPrototypeOf(thing); + return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names; +} +function get_type(thing) { + return Object.prototype.toString.call(thing).slice(8, -1); +} +function get_escaped_char(char) { + switch (char) { + case '"': + return '\\"'; + case "<": + return "\\u003C"; + case "\\": + return "\\\\"; + case ` +`: + return "\\n"; + case "\r": + return "\\r"; + case " ": + return "\\t"; + case "\b": + return "\\b"; + case "\f": + return "\\f"; + case "\u2028": + return "\\u2028"; + case "\u2029": + return "\\u2029"; + default: + return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : ""; + } +} +function stringify_string(str) { + let result = "", last_pos = 0, len = str.length; + for (let i = 0; i < len; i += 1) { + let char = str[i], replacement = get_escaped_char(char); + replacement && (result += str.slice(last_pos, i) + replacement, last_pos = i + 1); + } + return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`; +} + +// ../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/parse.js +function parse(serialized, revivers) { + return unflatten(JSON.parse(serialized), revivers); +} +function unflatten(parsed, revivers) { + if (typeof parsed == "number") + return hydrate(parsed, !0); + if (!Array.isArray(parsed) || parsed.length === 0) + throw new Error("Invalid input"); + let values = ( + /** @type {any[]} */ + parsed + ), hydrated = Array(values.length); + function hydrate(index, standalone = !1) { + if (index === -1) + return; + if (index === -3) + return NaN; + if (index === -4) + return 1 / 0; + if (index === -5) + return -1 / 0; + if (index === -6) + return -0; + if (standalone) + throw new Error("Invalid input"); + if (index in hydrated) + return hydrated[index]; + let value = values[index]; + if (!value || typeof value != "object") + hydrated[index] = value; + else if (Array.isArray(value)) + if (typeof value[0] == "string") { + let type = value[0], reviver = revivers?.[type]; + if (reviver) + return hydrated[index] = reviver(hydrate(value[1])); + switch (type) { + case "Date": + hydrated[index] = new Date(value[1]); + break; + case "Set": + let set = /* @__PURE__ */ new Set(); + hydrated[index] = set; + for (let i = 1; i < value.length; i += 1) + set.add(hydrate(value[i])); + break; + case "Map": + let map = /* @__PURE__ */ new Map(); + hydrated[index] = map; + for (let i = 1; i < value.length; i += 2) + map.set(hydrate(value[i]), hydrate(value[i + 1])); + break; + case "RegExp": + hydrated[index] = new RegExp(value[1], value[2]); + break; + case "Object": + hydrated[index] = Object(value[1]); + break; + case "BigInt": + hydrated[index] = BigInt(value[1]); + break; + case "null": + let obj = /* @__PURE__ */ Object.create(null); + hydrated[index] = obj; + for (let i = 1; i < value.length; i += 2) + obj[value[i]] = hydrate(value[i + 1]); + break; + default: + throw new Error(`Unknown type ${type}`); + } + } else { + let array = new Array(value.length); + hydrated[index] = array; + for (let i = 0; i < value.length; i += 1) { + let n = value[i]; + n !== -2 && (array[i] = hydrate(n)); + } + } + else { + let object = {}; + hydrated[index] = object; + for (let key in value) { + let n = value[key]; + object[key] = hydrate(n); + } + } + return hydrated[index]; + } + return hydrate(0); +} + +// ../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/stringify.js +function stringify(value, reducers) { + let stringified = [], indexes = /* @__PURE__ */ new Map(), custom = []; + for (let key in reducers) + custom.push({ key, fn: reducers[key] }); + let keys = [], p = 0; + function flatten(thing) { + if (typeof thing == "function") + throw new DevalueError("Cannot stringify a function", keys); + if (indexes.has(thing)) + return indexes.get(thing); + if (thing === void 0) + return -1; + if (Number.isNaN(thing)) + return -3; + if (thing === 1 / 0) + return -4; + if (thing === -1 / 0) + return -5; + if (thing === 0 && 1 / thing < 0) + return -6; + let index2 = p++; + indexes.set(thing, index2); + for (let { key, fn } of custom) { + let value2 = fn(thing); + if (value2) + return stringified[index2] = `["${key}",${flatten(value2)}]`, index2; + } + let str = ""; + if (is_primitive(thing)) + str = stringify_primitive(thing); + else + switch (get_type(thing)) { + case "Number": + case "String": + case "Boolean": + str = `["Object",${stringify_primitive(thing)}]`; + break; + case "BigInt": + str = `["BigInt",${thing}]`; + break; + case "Date": + str = `["Date","${thing.toISOString()}"]`; + break; + case "RegExp": + let { source, flags } = thing; + str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`; + break; + case "Array": + str = "["; + for (let i = 0; i < thing.length; i += 1) + i > 0 && (str += ","), i in thing ? (keys.push(`[${i}]`), str += flatten(thing[i]), keys.pop()) : str += -2; + str += "]"; + break; + case "Set": + str = '["Set"'; + for (let value2 of thing) + str += `,${flatten(value2)}`; + str += "]"; + break; + case "Map": + str = '["Map"'; + for (let [key, value2] of thing) + keys.push( + `.get(${is_primitive(key) ? stringify_primitive(key) : "..."})` + ), str += `,${flatten(key)},${flatten(value2)}`; + str += "]"; + break; + default: + if (!is_plain_object(thing)) + throw new DevalueError( + "Cannot stringify arbitrary non-POJOs", + keys + ); + if (Object.getOwnPropertySymbols(thing).length > 0) + throw new DevalueError( + "Cannot stringify POJOs with symbolic keys", + keys + ); + if (Object.getPrototypeOf(thing) === null) { + str = '["null"'; + for (let key in thing) + keys.push(`.${key}`), str += `,${stringify_string(key)},${flatten(thing[key])}`, keys.pop(); + str += "]"; + } else { + str = "{"; + let started = !1; + for (let key in thing) + started && (str += ","), started = !0, keys.push(`.${key}`), str += `${stringify_string(key)}:${flatten(thing[key])}`, keys.pop(); + str += "}"; + } + } + return stringified[index2] = str, index2; + } + let index = flatten(value); + return index < 0 ? `${index}` : `[${stringified.join(",")}]`; +} +function stringify_primitive(thing) { + let type = typeof thing; + return type === "string" ? stringify_string(thing) : thing instanceof String ? stringify_string(thing.toString()) : thing === void 0 ? (-1).toString() : thing === 0 && 1 / thing < 0 ? (-6).toString() : type === "bigint" ? `["BigInt","${thing}"]` : String(thing); +} + +// src/workers/core/proxy.worker.ts +import { readPrefix, reduceError } from "miniflare:shared"; + +// src/workers/core/devalue.ts +import assert from "node:assert"; +import { Buffer } from "node:buffer"; +var ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS = [ + DataView, + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array, + BigInt64Array, + BigUint64Array +], ALLOWED_ERROR_CONSTRUCTORS = [ + EvalError, + RangeError, + ReferenceError, + SyntaxError, + TypeError, + URIError, + Error + // `Error` last so more specific error subclasses preferred +], structuredSerializableReducers = { + ArrayBuffer(value) { + if (value instanceof ArrayBuffer) + return [Buffer.from(value).toString("base64")]; + }, + ArrayBufferView(value) { + if (ArrayBuffer.isView(value)) + return [ + value.constructor.name, + value.buffer, + value.byteOffset, + value.byteLength + ]; + }, + Error(value) { + for (let ctor of ALLOWED_ERROR_CONSTRUCTORS) + if (value instanceof ctor && value.name === ctor.name) + return [value.name, value.message, value.stack, value.cause]; + if (value instanceof Error) + return ["Error", value.message, value.stack, value.cause]; + } +}, structuredSerializableRevivers = { + ArrayBuffer(value) { + assert(Array.isArray(value)); + let [encoded] = value; + assert(typeof encoded == "string"); + let view = Buffer.from(encoded, "base64"); + return view.buffer.slice( + view.byteOffset, + view.byteOffset + view.byteLength + ); + }, + ArrayBufferView(value) { + assert(Array.isArray(value)); + let [name, buffer, byteOffset, byteLength] = value; + assert(typeof name == "string"), assert(buffer instanceof ArrayBuffer), assert(typeof byteOffset == "number"), assert(typeof byteLength == "number"); + let ctor = globalThis[name]; + assert(ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS.includes(ctor)); + let length = byteLength; + return "BYTES_PER_ELEMENT" in ctor && (length /= ctor.BYTES_PER_ELEMENT), new ctor(buffer, byteOffset, length); + }, + Error(value) { + assert(Array.isArray(value)); + let [name, message, stack, cause] = value; + assert(typeof name == "string"), assert(typeof message == "string"), assert(stack === void 0 || typeof stack == "string"); + let ctor = globalThis[name]; + assert(ALLOWED_ERROR_CONSTRUCTORS.includes(ctor)); + let error = new ctor(message, { cause }); + return error.stack = stack, error; + } +}; +function createHTTPReducers(impl) { + return { + Headers(val) { + if (val instanceof impl.Headers) + return Object.fromEntries(val); + }, + Request(val) { + if (val instanceof impl.Request) + return [val.method, val.url, val.headers, val.cf, val.body]; + }, + Response(val) { + if (val instanceof impl.Response) + return [val.status, val.statusText, val.headers, val.cf, val.body]; + } + }; +} +function createHTTPRevivers(impl) { + return { + Headers(value) { + return assert(typeof value == "object" && value !== null), new impl.Headers(value); + }, + Request(value) { + assert(Array.isArray(value)); + let [method, url, headers, cf, body] = value; + return assert(typeof method == "string"), assert(typeof url == "string"), assert(headers instanceof impl.Headers), assert(body === null || impl.isReadableStream(body)), new impl.Request(url, { + method, + headers, + cf, + // @ts-expect-error `duplex` is not required by `workerd` yet + duplex: body === null ? void 0 : "half", + body + }); + }, + Response(value) { + assert(Array.isArray(value)); + let [status, statusText, headers, cf, body] = value; + return assert(typeof status == "number"), assert(typeof statusText == "string"), assert(headers instanceof impl.Headers), assert(body === null || impl.isReadableStream(body)), new impl.Response(body, { + status, + statusText, + headers, + cf + }); + } + }; +} +function stringifyWithStreams(impl, value, reducers, allowUnbufferedStream) { + let unbufferedStream, bufferPromises = [], streamReducers = { + ReadableStream(value2) { + if (impl.isReadableStream(value2)) + return allowUnbufferedStream && unbufferedStream === void 0 ? unbufferedStream = value2 : bufferPromises.push(impl.bufferReadableStream(value2)), !0; + }, + Blob(value2) { + if (value2 instanceof impl.Blob) + return bufferPromises.push(value2.arrayBuffer()), !0; + }, + ...reducers + }, stringifiedValue = stringify(value, streamReducers); + return bufferPromises.length === 0 ? { value: stringifiedValue, unbufferedStream } : Promise.all(bufferPromises).then((streamBuffers) => (streamReducers.ReadableStream = function(value2) { + if (impl.isReadableStream(value2)) + return value2 === unbufferedStream ? !0 : streamBuffers.shift(); + }, streamReducers.Blob = function(value2) { + if (value2 instanceof impl.Blob) { + let array = [streamBuffers.shift(), value2.type]; + return value2 instanceof impl.File && array.push(value2.name, value2.lastModified), array; + } + }, { value: stringify(value, streamReducers), unbufferedStream })); +} +function parseWithReadableStreams(impl, stringified, revivers) { + let streamRevivers = { + ReadableStream(value) { + return value === !0 ? (assert(stringified.unbufferedStream !== void 0), stringified.unbufferedStream) : (assert(value instanceof ArrayBuffer), impl.unbufferReadableStream(value)); + }, + Blob(value) { + if (assert(Array.isArray(value)), value.length === 2) { + let [buffer, type] = value; + assert(buffer instanceof ArrayBuffer), assert(typeof type == "string"); + let opts = {}; + return type !== "" && (opts.type = type), new impl.Blob([buffer], opts); + } else { + assert(value.length === 4); + let [buffer, type, name, lastModified] = value; + assert(buffer instanceof ArrayBuffer), assert(typeof type == "string"), assert(typeof name == "string"), assert(typeof lastModified == "number"); + let opts = { lastModified }; + return type !== "" && (opts.type = type), new impl.File([buffer], name, opts); + } + }, + ...revivers + }; + return parse(stringified.value, streamRevivers); +} + +// src/workers/core/proxy.worker.ts +var ENCODER = new TextEncoder(), DECODER = new TextDecoder(), WORKERS_PLATFORM_IMPL = { + Blob, + File, + Headers, + Request, + Response, + isReadableStream(value) { + return value instanceof ReadableStream; + }, + bufferReadableStream(stream) { + return new Response(stream).arrayBuffer(); + }, + unbufferReadableStream(buffer) { + let body = new Response(buffer).body; + return assert2(body !== null), body; + } +}, objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0"); +function isPlainObject(value) { + let proto = Object.getPrototypeOf(value); + return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames; +} +function getType(value) { + return Object.prototype.toString.call(value).slice(8, -1); +} +var ProxyServer = class { + constructor(_state, env) { + this.env = env; + this.heap.set(ProxyAddresses.GLOBAL, globalThis), this.heap.set(ProxyAddresses.ENV, env); + } + nextHeapAddress = ProxyAddresses.USER_START; + heap = /* @__PURE__ */ new Map(); + reducers = { + ...structuredSerializableReducers, + ...createHTTPReducers(WORKERS_PLATFORM_IMPL), + // Corresponding revivers in `ProxyClient` + // `Native` reducer *MUST* be applied last + Native: (value) => { + let type = getType(value); + if (type === "Object" && !isPlainObject(value) || type === "Promise") { + let address = this.nextHeapAddress++; + return this.heap.set(address, value), assert2(typeof value == "object" && value !== null), [address, value.constructor.name]; + } + } + }; + revivers = { + ...structuredSerializableRevivers, + ...createHTTPRevivers(WORKERS_PLATFORM_IMPL), + // Corresponding reducers in `ProxyClient` + Native: (value) => { + assert2(Array.isArray(value)); + let [address] = value; + assert2(typeof address == "number"); + let heapValue = this.heap.get(address); + return assert2(heapValue !== void 0), heapValue instanceof Promise && this.heap.delete(address), heapValue; + } + }; + nativeReviver = { Native: this.revivers.Native }; + async fetch(request) { + try { + return await this.#fetch(request); + } catch (e) { + let error = reduceError(e); + return Response.json(error, { + status: 500, + headers: { [CoreHeaders.ERROR_STACK]: "true" } + }); + } + } + async #fetch(request) { + let secretHex = request.headers.get(CoreHeaders.OP_SECRET); + if (secretHex == null) + return new Response(null, { status: 401 }); + let expectedSecret = this.env[CoreBindings.DATA_PROXY_SECRET], secretBuffer = Buffer2.from(secretHex, "hex"); + if (!crypto.subtle.timingSafeEqual(secretBuffer, expectedSecret)) + return new Response(null, { status: 401 }); + let opHeader = request.headers.get(CoreHeaders.OP), targetHeader = request.headers.get(CoreHeaders.OP_TARGET), keyHeader = request.headers.get(CoreHeaders.OP_KEY), allowAsync = request.headers.get(CoreHeaders.OP_SYNC) === null, argsSizeHeader = request.headers.get(CoreHeaders.OP_STRINGIFIED_SIZE), contentLengthHeader = request.headers.get("Content-Length"); + if (targetHeader === null) + return new Response(null, { status: 400 }); + if (opHeader === ProxyOps.FREE) { + for (let targetValue of targetHeader.split(",")) { + let targetAddress = parseInt(targetValue); + assert2(!Number.isNaN(targetAddress)), this.heap.delete(targetAddress); + } + return new Response(null, { status: 204 }); + } + let target = parse( + targetHeader, + this.nativeReviver + ), targetName = target.constructor.name, status = 200, result, unbufferedRest; + if (opHeader === ProxyOps.GET) { + if (result = keyHeader === null ? target : target[keyHeader], typeof result == "function") + return new Response(null, { + status: 204, + headers: { [CoreHeaders.OP_RESULT_TYPE]: "Function" } + }); + } else if (opHeader === ProxyOps.GET_OWN_DESCRIPTOR) { + if (keyHeader === null) + return new Response(null, { status: 400 }); + let descriptor = Object.getOwnPropertyDescriptor(target, keyHeader); + descriptor !== void 0 && (result = { + configurable: descriptor.configurable, + enumerable: descriptor.enumerable, + writable: descriptor.writable + }); + } else if (opHeader === ProxyOps.GET_OWN_KEYS) + result = Object.getOwnPropertyNames(target); + else if (opHeader === ProxyOps.CALL) { + if (keyHeader === null) + return new Response(null, { status: 400 }); + let func = target[keyHeader]; + if (assert2(typeof func == "function"), isFetcherFetch(targetName, keyHeader)) { + let originalUrl = request.headers.get(CoreHeaders.ORIGINAL_URL), url = new URL(originalUrl ?? request.url); + return request = new Request(url, request), request.headers.delete(CoreHeaders.OP_SECRET), request.headers.delete(CoreHeaders.OP), request.headers.delete(CoreHeaders.OP_TARGET), request.headers.delete(CoreHeaders.OP_KEY), request.headers.delete(CoreHeaders.ORIGINAL_URL), request.headers.delete(CoreHeaders.DISABLE_PRETTY_ERROR), func.call(target, request); + } + let args; + if (argsSizeHeader === null || argsSizeHeader === contentLengthHeader) + args = parseWithReadableStreams( + WORKERS_PLATFORM_IMPL, + { value: await request.text() }, + this.revivers + ); + else { + let argsSize = parseInt(argsSizeHeader); + assert2(!Number.isNaN(argsSize)), assert2(request.body !== null); + let [encodedArgs, rest] = await readPrefix(request.body, argsSize); + unbufferedRest = rest; + let stringifiedArgs = DECODER.decode(encodedArgs); + args = parseWithReadableStreams( + WORKERS_PLATFORM_IMPL, + { value: stringifiedArgs, unbufferedStream: rest }, + this.revivers + ); + } + assert2(Array.isArray(args)); + try { + result = func.apply(target, args), isR2ObjectWriteHttpMetadata(targetName, keyHeader) && (result = args[0]); + } catch (e) { + status = 500, result = e; + } + } else + return new Response(null, { status: 404 }); + let headers = new Headers(); + if (allowAsync && result instanceof Promise) { + try { + result = await result; + } catch (e) { + status = 500, result = e; + } + headers.append(CoreHeaders.OP_RESULT_TYPE, "Promise"); + } + if (unbufferedRest !== void 0 && !unbufferedRest.locked) + try { + await unbufferedRest.pipeTo(new WritableStream()); + } catch { + } + if (result instanceof ReadableStream) + return headers.append(CoreHeaders.OP_RESULT_TYPE, "ReadableStream"), new Response(result, { status, headers }); + { + let stringified = await stringifyWithStreams( + WORKERS_PLATFORM_IMPL, + result, + this.reducers, + /* allowUnbufferedStream */ + allowAsync + ); + if (stringified.unbufferedStream === void 0) + return new Response(stringified.value, { status, headers }); + { + let body = new IdentityTransformStream(), encodedValue = ENCODER.encode(stringified.value), encodedSize = encodedValue.byteLength.toString(); + return headers.set(CoreHeaders.OP_STRINGIFIED_SIZE, encodedSize), this.#writeWithUnbufferedStream( + body.writable, + encodedValue, + stringified.unbufferedStream + ), new Response(body.readable, { status, headers }); + } + } + } + async #writeWithUnbufferedStream(writable, encodedValue, unbufferedStream) { + let writer = writable.getWriter(); + await writer.write(encodedValue), writer.releaseLock(), await unbufferedStream.pipeTo(writable); + } +}; + +// src/workers/core/entry.worker.ts +function getUserRequest(request, env) { + let originalUrl = request.headers.get(CoreHeaders.ORIGINAL_URL), upstreamUrl = env[CoreBindings.TEXT_UPSTREAM_URL], url = new URL(originalUrl ?? request.url); + if (upstreamUrl !== void 0) { + let path = url.pathname + url.search; + path.startsWith("/") && (path = `./${path.substring(1)}`), url = new URL(path, upstreamUrl); + } + return request = new Request(url, request), request.cf === void 0 && (request = new Request(request, { cf: env[CoreBindings.JSON_CF_BLOB] })), request.headers.delete(CoreHeaders.ORIGINAL_URL), request.headers.delete(CoreHeaders.DISABLE_PRETTY_ERROR), request; +} +function getTargetService(request, url, env) { + let service = env[CoreBindings.SERVICE_USER_FALLBACK], override = request.headers.get(CoreHeaders.ROUTE_OVERRIDE); + request.headers.delete(CoreHeaders.ROUTE_OVERRIDE); + let route = override ?? matchRoutes(env[CoreBindings.JSON_ROUTES], url); + return route !== null && (service = env[`${CoreBindings.SERVICE_USER_ROUTE_PREFIX}${route}`]), service; +} +function maybePrettifyError(request, response, env) { + if (response.status !== 500 || response.headers.get(CoreHeaders.ERROR_STACK) === null) + return response; + let accept = request.headers.get("Accept"), userAgent = request.headers.get("User-Agent"), headers = new Headers(); + return accept !== null && headers.set("Accept", accept), userAgent !== null && headers.set("User-Agent", userAgent), env[CoreBindings.SERVICE_LOOPBACK].fetch( + "http://localhost/core/error", + { + method: "POST", + headers, + body: response.body + } + ); +} +function maybeInjectLiveReload(response, env, ctx) { + let liveReloadScript = env[CoreBindings.DATA_LIVE_RELOAD_SCRIPT]; + if (liveReloadScript === void 0 || !response.headers.get("Content-Type")?.toLowerCase().includes("text/html")) + return response; + let headers = new Headers(response.headers), contentLength = parseInt(headers.get("content-length")); + isNaN(contentLength) || headers.set( + "content-length", + String(contentLength + liveReloadScript.byteLength) + ); + let { readable, writable } = new IdentityTransformStream(); + return ctx.waitUntil( + (async () => { + await response.body?.pipeTo(writable, { preventClose: !0 }); + let writer = writable.getWriter(); + await writer.write(liveReloadScript), await writer.close(); + })() + ), new Response(readable, { + status: response.status, + statusText: response.statusText, + headers + }); +} +function colourFromHTTPStatus(status) { + return 200 <= status && status < 300 ? green : 400 <= status && status < 500 ? yellow : 500 <= status ? red : blue; +} +function maybeLogRequest(req, res, env, ctx, startTime) { + if (env[CoreBindings.JSON_LOG_LEVEL] < LogLevel.INFO) + return; + let url = new URL(req.url), statusText = (res.statusText.trim() || STATUS_CODES[res.status]) ?? "", lines = [ + `${bold(req.method)} ${url.pathname} `, + colourFromHTTPStatus(res.status)(`${bold(res.status)} ${statusText} `), + grey(`(${Date.now() - startTime}ms)`) + ], message = reset(lines.join("")); + ctx.waitUntil( + env[CoreBindings.SERVICE_LOOPBACK].fetch("http://localhost/core/log", { + method: "POST", + headers: { [SharedHeaders.LOG_LEVEL]: LogLevel.INFO.toString() }, + body: message + }) + ); +} +function handleProxy(request, env) { + let ns = env[CoreBindings.DURABLE_OBJECT_NAMESPACE_PROXY], id = ns.idFromName(""); + return ns.get(id).fetch(request); +} +async function handleScheduled(params, service) { + let time = params.get("time"), scheduledTime = time ? new Date(parseInt(time)) : void 0, cron = params.get("cron") ?? void 0, result = await service.scheduled({ + scheduledTime, + cron + }); + return new Response(result.outcome, { + status: result.outcome === "ok" ? 200 : 500 + }); +} +var entry_worker_default = { + async fetch(request, env, ctx) { + let startTime = Date.now(); + if (request.headers.get(CoreHeaders.OP) !== null) + return handleProxy(request, env); + let disablePrettyErrorPage = request.headers.get(CoreHeaders.DISABLE_PRETTY_ERROR) !== null; + request = getUserRequest(request, env); + let url = new URL(request.url), service = getTargetService(request, url, env); + if (service === void 0) + return new Response("No entrypoint worker found", { status: 404 }); + try { + if (url.pathname === "/cdn-cgi/mf/scheduled") + return await handleScheduled(url.searchParams, service); + let response = await service.fetch(request); + return disablePrettyErrorPage || (response = await maybePrettifyError(request, response, env)), response = maybeInjectLiveReload(response, env, ctx), maybeLogRequest(request, response, env, ctx, startTime), response; + } catch (e) { + return new Response(e?.stack ?? String(e), { status: 500 }); + } + } +}; +export { + ProxyServer, + entry_worker_default as default +}; +//# sourceMappingURL=entry.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/core/entry.worker.js.map b/node_modules/miniflare/dist/src/workers/core/entry.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b050e9826c0d1b3f74e1ab9f7395ab1b3d643e94 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/core/entry.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs", "../../../../src/workers/core/entry.worker.ts", "../../../../src/workers/core/constants.ts", "../../../../src/workers/core/http.ts", "../../../../src/workers/core/routing.ts", "../../../../src/workers/core/proxy.worker.ts", "../../../../../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/utils.js", "../../../../../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/parse.js", "../../../../../../node_modules/.pnpm/devalue@4.3.2/node_modules/devalue/src/stringify.js", "../../../../src/workers/core/devalue.ts"], + "mappings": ";AAAA,IAAI,aAAa,qBAAqB,UAAU,MAAM,QAAM;AACxD,OAAO,UAAY,QACrB,EAAE,aAAa,qBAAqB,UAAU,KAAK,IAAI,QAAQ,OAAO,CAAC,GACxE,QAAQ,QAAQ,UAAU,QAAQ,OAAO;AAGnC,IAAM,IAAI;AAAA,EAChB,SAAS,CAAC,uBAAuB,YAAY,QAAQ,SAAS,WAC7D,eAAe,QAAQ,gBAAgB,OAAO;AAEhD;AAEA,SAAS,KAAK,GAAG,GAAG;AACnB,MAAI,MAAM,IAAI,OAAO,WAAW,MAAM,GAAG,GACrC,OAAO,QAAQ,MAAM,QAAQ,QAAQ;AAEzC,SAAO,SAAU,KAAK;AACrB,WAAI,CAAC,EAAE,WAAW,OAAO,OAAa,MAC/B,QAAU,EAAE,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AC;AACF;AAEA,IAAO,uBAA8B;AAAA,EACpC,MAAM,MAAM,SAAS,KAAK,KAAK;AAC9B,QAAM,YAAY,KAAK,IAAI;AAI3B,QADgB,QAAQ,QAAQ,IAAI,YAAY,EAAE,MAAM;AAC3C,aAAO,YAAY,SAAS,GAAG;AAK5C,QAAM,yBACL,QAAQ,QAAQ,IAAI,YAAY,oBAAoB,MAAM;AAE3D,cAAU,eAAe,SAAS,GAAG;AACrC,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG,GACzB,UAAU,iBAAiB,SAAS,KAAK,GAAG;AAClD,QAAI,YAAY;AACf,aAAO,IAAI,SAAS,8BAA8B,EAAE,QAAQ,IAAI,CAAC;AAGlE,QAAI;AACH,UAAI,IAAI,aAAa;AACpB,eAAO,MAAM,gBAAgB,IAAI,cAAc,OAAO;AAGvD,UAAI,WAAW,MAAM,QAAQ,MAAM,OAAO;AAC1C,aAAK,2BACJ,WAAW,MAAM,mBAAmB,SAAS,UAAU,GAAG,IAE3D,WAAW,sBAAsB,UAAU,KAAK,GAAG,GACnD,gBAAgB,SAAS,UAAU,KAAK,KAAK,SAAS,GAC/C;AAAA,IACR,SAAS,GAAP;AACD,aAAO,IAAI,SAAS,GAAG,SAAS,OAAO,CAAC,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC3D;AAAA,EACD;AACD;", + "names": ["assert", "Buffer", "index", "value", "value", "assert", "Buffer"] +} diff --git a/node_modules/miniflare/dist/src/workers/d1/database.worker.js b/node_modules/miniflare/dist/src/workers/d1/database.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..2a22f14c1850af8e3201ed302d1fabe8967387ec --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/d1/database.worker.js @@ -0,0 +1,113 @@ +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __decorateClass = (decorators, target, key, kind) => { + for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--) + (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result); + return kind && result && __defProp(target, key, result), result; +}; + +// src/workers/d1/database.worker.ts +import assert from "node:assert"; +import { + HttpError, + MiniflareDurableObject, + POST, + all, + get, + viewToBuffer +} from "miniflare:shared"; +import { z } from "miniflare:zod"; +var D1ValueSchema = z.union([ + z.number(), + z.string(), + z.null(), + z.number().array() +]), D1QuerySchema = z.object({ + sql: z.string(), + params: z.array(D1ValueSchema).nullable().optional() +}), D1QueriesSchema = z.union([D1QuerySchema, z.array(D1QuerySchema)]), served_by = "miniflare.db", D1Error = class extends HttpError { + constructor(cause) { + super(500); + this.cause = cause; + } + toResponse() { + let response = { success: !1, error: typeof this.cause == "object" && this.cause !== null && "message" in this.cause && typeof this.cause.message == "string" ? this.cause.message : String(this.cause) }; + return Response.json(response); + } +}; +function convertParams(params) { + return (params ?? []).map( + (param) => ( + // If `param` is an array, assume it's a byte array + Array.isArray(param) ? viewToBuffer(new Uint8Array(param)) : param + ) + ); +} +function convertResults(rows) { + return rows.map( + (row) => Object.fromEntries( + Object.entries(row).map(([key, value]) => { + let normalised; + return value instanceof ArrayBuffer ? normalised = Array.from(new Uint8Array(value)) : normalised = value, [key, normalised]; + }) + ) + ); +} +function sqlStmts(db) { + return { + getChanges: db.prepare( + "SELECT total_changes() AS totalChanges, last_insert_rowid() AS lastRowId" + ) + }; +} +var D1DatabaseObject = class extends MiniflareDurableObject { + #stmts; + constructor(state, env) { + super(state, env), this.#stmts = sqlStmts(this.db); + } + #changes() { + let changes = get(this.#stmts.getChanges()); + return assert(changes !== void 0), changes; + } + #query = (query) => { + let beforeTime = performance.now(), beforeSize = this.state.storage.sql.databaseSize, beforeChanges = this.#changes(), params = convertParams(query.params ?? []), cursor = this.db.prepare(query.sql)(...params), results = convertResults(all(cursor)), afterTime = performance.now(), afterSize = this.state.storage.sql.databaseSize, afterChanges = this.#changes(), duration = afterTime - beforeTime, changes = afterChanges.totalChanges - beforeChanges.totalChanges, hasChanges = changes !== 0, lastRowChanged = afterChanges.lastRowId !== beforeChanges.lastRowId, changed = hasChanges || lastRowChanged || afterSize !== beforeSize; + return { + success: !0, + results, + meta: { + served_by, + duration, + changes, + last_row_id: afterChanges.lastRowId, + changed_db: changed, + size_after: afterSize + } + }; + }; + #txn(queries) { + if (queries = queries.filter( + (query) => query.sql.replace(/^\s+--.*/gm, "").trim().length > 0 + ), queries.length === 0) { + let error = new Error("No SQL statements detected."); + throw new D1Error(error); + } + try { + return this.state.storage.transactionSync(() => queries.map(this.#query)); + } catch (e) { + throw new D1Error(e); + } + } + queryExecute = async (req) => { + let queries = D1QueriesSchema.parse(await req.json()); + return Array.isArray(queries) || (queries = [queries]), Response.json(this.#txn(queries)); + }; +}; +__decorateClass([ + POST("/query"), + POST("/execute") +], D1DatabaseObject.prototype, "queryExecute", 2); +export { + D1DatabaseObject, + D1Error +}; +//# sourceMappingURL=database.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/d1/database.worker.js.map b/node_modules/miniflare/dist/src/workers/d1/database.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b1eacd8d338a2c7781cb48936b7b0989a07e321a --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/d1/database.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/d1/database.worker.ts"], + "mappings": ";;;;;;;;;AAAA,OAAO,YAAY;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EAEA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS;AAElB,IAAM,gBAAgB,EAAE,MAAM;AAAA,EAC7B,EAAE,OAAO;AAAA,EACT,EAAE,OAAO;AAAA,EACT,EAAE,KAAK;AAAA,EACP,EAAE,OAAO,EAAE,MAAM;AAClB,CAAC,GAGK,gBAAgB,EAAE,OAAO;AAAA,EAC9B,KAAK,EAAE,OAAO;AAAA,EACd,QAAQ,EAAE,MAAM,aAAa,EA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AK,CAAC;AACpD,WAAK,MAAM,QAAQ,OAAO,MAAG,UAAU,CAAC,OAAO,IACxC,SAAS,KAAK,KAAK,KAAK,OAAO,CAAC;AAAA,EACxC;AACD;AALC;AAAA,EAFC,KAAK,QAAQ;AAAA,EACb,KAAK,UAAU;AAAA,GApEJ,iBAqEZ;", + "names": [] +} diff --git a/node_modules/miniflare/dist/src/workers/kv/namespace.worker.js b/node_modules/miniflare/dist/src/workers/kv/namespace.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..2bc3a7554e2cbd012ec81e5f698ec477c0be2bef --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/kv/namespace.worker.js @@ -0,0 +1,258 @@ +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __decorateClass = (decorators, target, key, kind) => { + for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--) + (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result); + return kind && result && __defProp(target, key, result), result; +}; + +// src/workers/kv/namespace.worker.ts +import assert from "node:assert"; +import { + DELETE, + DeferredPromise, + GET, + HttpError as HttpError2, + KeyValueStorage, + MiniflareDurableObject, + PUT, + maybeApply +} from "miniflare:shared"; + +// src/workers/kv/constants.ts +import { testRegExps } from "miniflare:shared"; +var KVLimits = { + MIN_CACHE_TTL: 60, + MAX_LIST_KEYS: 1e3, + MAX_KEY_SIZE: 512, + MAX_VALUE_SIZE: 25 * 1024 * 1024, + MAX_VALUE_SIZE_TEST: 1024, + MAX_METADATA_SIZE: 1024 +}, KVParams = { + URL_ENCODED: "urlencoded", + CACHE_TTL: "cache_ttl", + EXPIRATION: "expiration", + EXPIRATION_TTL: "expiration_ttl", + LIST_LIMIT: "key_count_limit", + LIST_PREFIX: "prefix", + LIST_CURSOR: "cursor" +}, KVHeaders = { + EXPIRATION: "CF-Expiration", + METADATA: "CF-KV-Metadata" +}; + +// src/workers/kv/validator.worker.ts +import { Buffer as Buffer2 } from "node:buffer"; +import { HttpError } from "miniflare:shared"; +function decodeKey({ key }, query) { + if (query.get(KVParams.URL_ENCODED)?.toLowerCase() !== "true") + return key; + try { + return decodeURIComponent(key); + } catch (e) { + throw e instanceof URIError ? new HttpError(400, "Could not URL-decode key name") : e; + } +} +function validateKey(key) { + if (key === "") + throw new HttpError(400, "Key names must not be empty"); + if (key === "." || key === "..") + throw new HttpError( + 400, + `Illegal key name "${key}". Please use a different name.` + ); + validateKeyLength(key); +} +function validateKeyLength(key) { + let keyLength = Buffer2.byteLength(key); + if (keyLength > KVLimits.MAX_KEY_SIZE) + throw new HttpError( + 414, + `UTF-8 encoded length of ${keyLength} exceeds key length limit of ${KVLimits.MAX_KEY_SIZE}.` + ); +} +function validateGetOptions(key, options) { + validateKey(key); + let cacheTtl = options?.cacheTtl; + if (cacheTtl !== void 0 && (isNaN(cacheTtl) || cacheTtl < KVLimits.MIN_CACHE_TTL)) + throw new HttpError( + 400, + `Invalid ${KVParams.CACHE_TTL} of ${cacheTtl}. Cache TTL must be at least ${KVLimits.MIN_CACHE_TTL}.` + ); +} +function validatePutOptions(key, options) { + let { now, rawExpiration, rawExpirationTtl, rawMetadata } = options; + validateKey(key); + let expiration; + if (rawExpirationTtl !== null) { + let expirationTtl = parseInt(rawExpirationTtl); + if (Number.isNaN(expirationTtl) || expirationTtl <= 0) + throw new HttpError( + 400, + `Invalid ${KVParams.EXPIRATION_TTL} of ${rawExpirationTtl}. Please specify integer greater than 0.` + ); + if (expirationTtl < KVLimits.MIN_CACHE_TTL) + throw new HttpError( + 400, + `Invalid ${KVParams.EXPIRATION_TTL} of ${rawExpirationTtl}. Expiration TTL must be at least ${KVLimits.MIN_CACHE_TTL}.` + ); + expiration = now + expirationTtl; + } else if (rawExpiration !== null) { + if (expiration = parseInt(rawExpiration), Number.isNaN(expiration) || expiration <= now) + throw new HttpError( + 400, + `Invalid ${KVParams.EXPIRATION} of ${rawExpiration}. Please specify integer greater than the current number of seconds since the UNIX epoch.` + ); + if (expiration < now + KVLimits.MIN_CACHE_TTL) + throw new HttpError( + 400, + `Invalid ${KVParams.EXPIRATION} of ${rawExpiration}. Expiration times must be at least ${KVLimits.MIN_CACHE_TTL} seconds in the future.` + ); + } + let metadata; + if (rawMetadata !== null) { + let metadataLength = Buffer2.byteLength(rawMetadata); + if (metadataLength > KVLimits.MAX_METADATA_SIZE) + throw new HttpError( + 413, + `Metadata length of ${metadataLength} exceeds limit of ${KVLimits.MAX_METADATA_SIZE}.` + ); + metadata = JSON.parse(rawMetadata); + } + return { expiration, metadata }; +} +function decodeListOptions(url) { + let limitParam = url.searchParams.get(KVParams.LIST_LIMIT), limit = limitParam === null ? KVLimits.MAX_LIST_KEYS : parseInt(limitParam), prefix = url.searchParams.get(KVParams.LIST_PREFIX) ?? void 0, cursor = url.searchParams.get(KVParams.LIST_CURSOR) ?? void 0; + return { limit, prefix, cursor }; +} +function validateListOptions(options) { + let limit = options.limit; + if (limit !== void 0) { + if (isNaN(limit) || limit < 1) + throw new HttpError( + 400, + `Invalid ${KVParams.LIST_LIMIT} of ${limit}. Please specify an integer greater than 0.` + ); + if (limit > KVLimits.MAX_LIST_KEYS) + throw new HttpError( + 400, + `Invalid ${KVParams.LIST_LIMIT} of ${limit}. Please specify an integer less than ${KVLimits.MAX_LIST_KEYS}.` + ); + } + let prefix = options.prefix; + prefix != null && validateKeyLength(prefix); +} + +// src/workers/kv/namespace.worker.ts +function createMaxValueSizeError(length, maxValueSize) { + return new HttpError2( + 413, + `Value length of ${length} exceeds limit of ${maxValueSize}.` + ); +} +var MaxLengthStream = class extends TransformStream { + signal; + length; + constructor(maxLength) { + let abortController = new AbortController(), lengthPromise = new DeferredPromise(), length = 0; + super({ + transform(chunk, controller) { + length += chunk.byteLength, length <= maxLength ? controller.enqueue(chunk) : abortController.signal.aborted || abortController.abort(); + }, + flush() { + lengthPromise.resolve(length); + } + }), this.signal = abortController.signal, this.length = lengthPromise; + } +}; +function millisToSeconds(millis) { + return Math.floor(millis / 1e3); +} +function secondsToMillis(seconds) { + return seconds * 1e3; +} +var KVNamespaceObject = class extends MiniflareDurableObject { + #storage; + get storage() { + return this.#storage ??= new KeyValueStorage(this); + } + get = async (req, params, url) => { + let key = decodeKey(params, url.searchParams), cacheTtlParam = url.searchParams.get(KVParams.CACHE_TTL), cacheTtl = cacheTtlParam === null ? void 0 : parseInt(cacheTtlParam); + validateGetOptions(key, { cacheTtl }); + let entry = await this.storage.get(key); + if (entry === null) + throw new HttpError2(404, "Not Found"); + let headers = new Headers(); + return entry.expiration !== void 0 && headers.set( + KVHeaders.EXPIRATION, + millisToSeconds(entry.expiration).toString() + ), entry.metadata !== void 0 && headers.set(KVHeaders.METADATA, JSON.stringify(entry.metadata)), new Response(entry.value, { headers }); + }; + put = async (req, params, url) => { + let key = decodeKey(params, url.searchParams), rawExpiration = url.searchParams.get(KVParams.EXPIRATION), rawExpirationTtl = url.searchParams.get(KVParams.EXPIRATION_TTL), rawMetadata = req.headers.get(KVHeaders.METADATA), now = millisToSeconds(this.timers.now()), { expiration, metadata } = validatePutOptions(key, { + now, + rawExpiration, + rawExpirationTtl, + rawMetadata + }), value = req.body, contentLength = parseInt(req.headers.get("Content-Length")), valueLengthHint; + Number.isNaN(contentLength) ? value === null && (valueLengthHint = 0) : valueLengthHint = contentLength, value ??= new ReadableStream({ + start(controller) { + controller.close(); + } + }); + let maxValueSize = this.beingTested ? KVLimits.MAX_VALUE_SIZE_TEST : KVLimits.MAX_VALUE_SIZE, maxLengthStream; + if (valueLengthHint !== void 0 && valueLengthHint > maxValueSize) + throw createMaxValueSizeError(valueLengthHint, maxValueSize); + maxLengthStream = new MaxLengthStream(maxValueSize), value = value.pipeThrough(maxLengthStream); + try { + await this.storage.put({ + key, + value, + expiration: maybeApply(secondsToMillis, expiration), + metadata, + signal: maxLengthStream?.signal + }); + } catch (e) { + if (typeof e == "object" && e !== null && "name" in e && e.name === "AbortError") { + assert(maxLengthStream !== void 0); + let length = await maxLengthStream.length; + throw createMaxValueSizeError(length, maxValueSize); + } else + throw e; + } + return new Response(); + }; + delete = async (req, params, url) => { + let key = decodeKey(params, url.searchParams); + return validateKey(key), await this.storage.delete(key), new Response(); + }; + list = async (req, params, url) => { + let options = decodeListOptions(url); + validateListOptions(options); + let res = await this.storage.list(options), keys = res.keys.map((key) => ({ + name: key.key, + expiration: maybeApply(millisToSeconds, key.expiration), + // workerd expects metadata to be a JSON-serialised string + metadata: maybeApply(JSON.stringify, key.metadata) + })), result; + return res.cursor === void 0 ? result = { keys, list_complete: !0, cacheStatus: null } : result = { + keys, + list_complete: !1, + cursor: res.cursor, + cacheStatus: null + }, Response.json(result); + }; +}; +__decorateClass([ + GET("/:key") +], KVNamespaceObject.prototype, "get", 2), __decorateClass([ + PUT("/:key") +], KVNamespaceObject.prototype, "put", 2), __decorateClass([ + DELETE("/:key") +], KVNamespaceObject.prototype, "delete", 2), __decorateClass([ + GET("/") +], KVNamespaceObject.prototype, "list", 2); +export { + KVNamespaceObject +}; +//# sourceMappingURL=namespace.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/kv/namespace.worker.js.map b/node_modules/miniflare/dist/src/workers/kv/namespace.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..06a4d218fd9ee3470a3025e8a824ea71cdaa6fa6 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/kv/namespace.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/kv/namespace.worker.ts", "../../../../src/workers/kv/constants.ts", "../../../../src/workers/kv/validator.worker.ts"], + "mappings": ";;;;;;;;;AAAA,OAAO,YAAY;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACM;;;ACXP,SAAyB,mBAAmB;AAErC,IAAM,WAAW;AAAA,EACvB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd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;AAjJC;AAAA,EADC,IAAI,OAAO;AAAA,GAPA,kBAQZ,sBA2BA;AAAA,EADC,IAAI,OAAO;AAAA,GAlCA,kBAmCZ,sBAiFA;AAAA,EADC,OAAO,OAAO;AAAA,GAnHH,kBAoHZ,yBAWA;AAAA,EADC,IAAI,GAAG;AAAA,GA9HI,kBA+HZ;", + "names": ["HttpError", "Buffer", "Buffer", "HttpError"] +} diff --git a/node_modules/miniflare/dist/src/workers/kv/sites.worker.js b/node_modules/miniflare/dist/src/workers/kv/sites.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..a4ee8e393048abfe53795f44cbcad1b82ef80f43 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/kv/sites.worker.js @@ -0,0 +1,147 @@ +// src/workers/kv/sites.worker.ts +import { SharedBindings, base64Decode, base64Encode } from "miniflare:shared"; + +// src/workers/kv/constants.ts +import { testRegExps } from "miniflare:shared"; +var KVLimits = { + MIN_CACHE_TTL: 60, + MAX_LIST_KEYS: 1e3, + MAX_KEY_SIZE: 512, + MAX_VALUE_SIZE: 25 * 1024 * 1024, + MAX_VALUE_SIZE_TEST: 1024, + MAX_METADATA_SIZE: 1024 +}, KVParams = { + URL_ENCODED: "urlencoded", + CACHE_TTL: "cache_ttl", + EXPIRATION: "expiration", + EXPIRATION_TTL: "expiration_ttl", + LIST_LIMIT: "key_count_limit", + LIST_PREFIX: "prefix", + LIST_CURSOR: "cursor" +}; +var SiteBindings = { + KV_NAMESPACE_SITE: "__STATIC_CONTENT", + JSON_SITE_MANIFEST: "__STATIC_CONTENT_MANIFEST", + JSON_SITE_FILTER: "MINIFLARE_SITE_FILTER" +}, SITES_NO_CACHE_PREFIX = "$__MINIFLARE_SITES__$/"; +function encodeSitesKey(key) { + return SITES_NO_CACHE_PREFIX + encodeURIComponent(key); +} +function decodeSitesKey(key) { + return key.startsWith(SITES_NO_CACHE_PREFIX) ? decodeURIComponent(key.substring(SITES_NO_CACHE_PREFIX.length)) : key; +} +function deserialiseRegExps(matcher) { + return { + include: matcher.include.map((regExp) => new RegExp(regExp)), + exclude: matcher.exclude.map((regExp) => new RegExp(regExp)) + }; +} +function deserialiseSiteRegExps(siteRegExps) { + return { + include: siteRegExps.include && deserialiseRegExps(siteRegExps.include), + exclude: siteRegExps.exclude && deserialiseRegExps(siteRegExps.exclude) + }; +} +function testSiteRegExps(regExps, key) { + return regExps.include !== void 0 ? testRegExps(regExps.include, key) : regExps.exclude !== void 0 ? !testRegExps(regExps.exclude, key) : !0; +} + +// src/workers/kv/validator.worker.ts +import { Buffer } from "node:buffer"; +import { HttpError } from "miniflare:shared"; +function validateKeyLength(key) { + let keyLength = Buffer.byteLength(key); + if (keyLength > KVLimits.MAX_KEY_SIZE) + throw new HttpError( + 414, + `UTF-8 encoded length of ${keyLength} exceeds key length limit of ${KVLimits.MAX_KEY_SIZE}.` + ); +} +function decodeListOptions(url) { + let limitParam = url.searchParams.get(KVParams.LIST_LIMIT), limit = limitParam === null ? KVLimits.MAX_LIST_KEYS : parseInt(limitParam), prefix = url.searchParams.get(KVParams.LIST_PREFIX) ?? void 0, cursor = url.searchParams.get(KVParams.LIST_CURSOR) ?? void 0; + return { limit, prefix, cursor }; +} +function validateListOptions(options) { + let limit = options.limit; + if (limit !== void 0) { + if (isNaN(limit) || limit < 1) + throw new HttpError( + 400, + `Invalid ${KVParams.LIST_LIMIT} of ${limit}. Please specify an integer greater than 0.` + ); + if (limit > KVLimits.MAX_LIST_KEYS) + throw new HttpError( + 400, + `Invalid ${KVParams.LIST_LIMIT} of ${limit}. Please specify an integer less than ${KVLimits.MAX_LIST_KEYS}.` + ); + } + let prefix = options.prefix; + prefix != null && validateKeyLength(prefix); +} + +// src/workers/kv/sites.worker.ts +var siteRegExpsCache = /* @__PURE__ */ new WeakMap(); +function getSiteRegExps(env) { + let regExps = siteRegExpsCache.get(env); + return regExps !== void 0 || (regExps = deserialiseSiteRegExps(env[SiteBindings.JSON_SITE_FILTER]), siteRegExpsCache.set(env, regExps)), regExps; +} +async function* walkDirectory(blobsService, path = "") { + let res = await blobsService.fetch(`http://placeholder/${path}`); + if (!(res.headers.get("Content-Type") ?? "").toLowerCase().startsWith("application/json")) { + await res.body?.pipeTo(new WritableStream()), yield path; + return; + } + let entries = await res.json(); + for (let { name, type } of entries) { + let entryPath = `${path}${path === "" ? "" : "/"}${name}`; + type === "directory" ? yield* walkDirectory(blobsService, entryPath) : yield entryPath; + } +} +var encoder = new TextEncoder(); +function arrayCompare(a, b) { + let minLength = Math.min(a.length, b.length); + for (let i = 0; i < minLength; i++) { + let aElement = a[i], bElement = b[i]; + if (aElement < bElement) + return -1; + if (aElement > bElement) + return 1; + } + return a.length - b.length; +} +async function handleListRequest(url, blobsService, siteRegExps) { + let options = decodeListOptions(url); + validateListOptions(options); + let { limit = KVLimits.MAX_LIST_KEYS, prefix, cursor } = options, keys = []; + for await (let name of walkDirectory(blobsService)) + testSiteRegExps(siteRegExps, name) && (name = encodeSitesKey(name), !(prefix !== void 0 && !name.startsWith(prefix)) && keys.push({ name, encodedName: encoder.encode(name) })); + keys.sort((a, b) => arrayCompare(a.encodedName, b.encodedName)); + for (let key of keys) + delete key.encodedName; + let startAfter = cursor === void 0 ? "" : base64Decode(cursor), startIndex = 0; + startAfter !== "" && (startIndex = keys.findIndex(({ name }) => name === startAfter), startIndex === -1 && (startIndex = keys.length), startIndex++); + let endIndex = startIndex + limit, nextCursor = endIndex < keys.length ? base64Encode(keys[endIndex - 1].name) : void 0; + return keys = keys.slice(startIndex, endIndex), nextCursor === void 0 ? Response.json({ keys, list_complete: !0 }) : Response.json({ keys, list_complete: !1, cursor: nextCursor }); +} +var sites_worker_default = { + async fetch(request, env) { + if (request.method !== "GET") { + let message = `Cannot ${request.method.toLowerCase()}() with Workers Sites namespace`; + return new Response(message, { status: 405, statusText: message }); + } + let url = new URL(request.url), key = url.pathname.substring(1); + url.searchParams.get(KVParams.URL_ENCODED)?.toLowerCase() === "true" && (key = decodeURIComponent(key)), key = decodeSitesKey(key); + let siteRegExps = getSiteRegExps(env); + if (key !== "" && !testSiteRegExps(siteRegExps, key)) + return new Response("Not Found", { + status: 404, + statusText: "Not Found" + }); + let blobsService = env[SharedBindings.MAYBE_SERVICE_BLOBS]; + return key === "" ? handleListRequest(url, blobsService, siteRegExps) : blobsService.fetch(new URL(key, "http://placeholder")); + } +}; +export { + sites_worker_default as default +}; +//# sourceMappingURL=sites.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/kv/sites.worker.js.map b/node_modules/miniflare/dist/src/workers/kv/sites.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8573b4a3eff1dcd68a6529ea22ba61aa3ef90589 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/kv/sites.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/kv/sites.worker.ts", "../../../../src/workers/kv/constants.ts", "../../../../src/workers/kv/validator.worker.ts"], + "mappings": ";AAAA,SAAS,gBAAgB,cAAc,oBAAoB;;;ACA3D,SAAyB,mBAAmB;AAErC,IAAM,WAAW;AAAA,EACvB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,gBAAgB,KAAK,OAAO;AAAA,EAC5B,qBAAqB;AAAA,EACrB,mBAAmB;AACpB,GAEa,WAAW;AAAA,EACvB,aAAa;AAAA,EACb,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACd;AAOO,IAAM,eAAe;AAAA,EAC3B,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,kBAAkB;AACnB,GAKa,wBAAwB;AAE9B,SAAS,eAAe,KAAqB;AAGnD,SAAO,wBAAwB,mBAAmB,GAAG;AACtD;AACO,SAAS,eAAe,KAAqB;AACnD,SAAO,IAAI,WAAW,qBAAqB,IACxC,mBAAmB,IAAI,UAAU,sBAAsB,MAAM,CAAC,IAC9D;AACJ;AAmCO,SAAS,mBACf,SAC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AM,cAAc,eAAe,GAAG;AACtC,QAAI,QAAQ,MAAM,CAAC,gBAAgB,aAAa,GAAG;AAClD,aAAO,IAAI,SAAS,aAAa;AAAA,QAChC,QAAQ;AAAA,QACR,YAAY;AAAA,MACb,CAAC;AAGF,QAAM,eAAe,IAAI,eAAe,mBAAmB;AAC3D,WAAI,QAAQ,KACJ,kBAAkB,KAAK,cAAc,WAAW,IAEhD,aAAa,MAAM,IAAI,IAAI,KAAK,oBAAoB,CAAC;AAAA,EAE9D;AACD;", + "names": [] +} diff --git a/node_modules/miniflare/dist/src/workers/queues/broker.worker.js b/node_modules/miniflare/dist/src/workers/queues/broker.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..962861ffb442cbdf73be135e2873e19f51d7ca61 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/queues/broker.worker.js @@ -0,0 +1,238 @@ +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __decorateClass = (decorators, target, key, kind) => { + for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--) + (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result); + return kind && result && __defProp(target, key, result), result; +}; + +// src/workers/queues/broker.worker.ts +import assert from "node:assert"; +import { Buffer as Buffer2 } from "node:buffer"; + +// ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs +var FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY = !0; +typeof process < "u" && ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {}, isTTY = process.stdout && process.stdout.isTTY); +var $ = { + enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY) +}; +function init(x, y) { + let rgx = new RegExp(`\\x1b\\[${y}m`, "g"), open = `\x1B[${x}m`, close = `\x1B[${y}m`; + return function(txt) { + return !$.enabled || txt == null ? txt : open + (~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close; + }; +} +var reset = init(0, 0), bold = init(1, 22), dim = init(2, 22), italic = init(3, 23), underline = init(4, 24), inverse = init(7, 27), hidden = init(8, 28), strikethrough = init(9, 29), black = init(30, 39), red = init(31, 39), green = init(32, 39), yellow = init(33, 39), blue = init(34, 39), magenta = init(35, 39), cyan = init(36, 39), white = init(37, 39), gray = init(90, 39), grey = init(90, 39), bgBlack = init(40, 49), bgRed = init(41, 49), bgGreen = init(42, 49), bgYellow = init(43, 49), bgBlue = init(44, 49), bgMagenta = init(45, 49), bgCyan = init(46, 49), bgWhite = init(47, 49); + +// src/workers/queues/broker.worker.ts +import { + HttpError, + LogLevel, + MiniflareDurableObject, + POST, + SharedBindings, + viewToBuffer +} from "miniflare:shared"; + +// src/workers/queues/constants.ts +var QueueBindings = { + SERVICE_WORKER_PREFIX: "MINIFLARE_WORKER_", + MAYBE_JSON_QUEUE_CONSUMERS: "MINIFLARE_QUEUE_CONSUMERS" +}; + +// src/workers/queues/schemas.ts +import { Base64DataSchema, z } from "miniflare:zod"; +var QueueConsumerOptionsSchema = /* @__PURE__ */ z.object({ + // https://developers.cloudflare.com/queues/platform/configuration/#consumer + // https://developers.cloudflare.com/queues/platform/limits/ + maxBatchSize: z.number().min(0).max(100).optional(), + maxBatchTimeout: z.number().min(0).max(30).optional(), + // seconds + maxRetires: z.number().min(0).max(100).optional(), + deadLetterQueue: z.ostring() +}), QueueConsumerSchema = /* @__PURE__ */ z.intersection( + QueueConsumerOptionsSchema, + z.object({ workerName: z.string() }) +), QueueConsumersSchema = /* @__PURE__ */ z.record(QueueConsumerSchema), QueueContentTypeSchema = /* @__PURE__ */ z.enum(["text", "json", "bytes", "v8"]).default("v8"), QueueIncomingMessageSchema = /* @__PURE__ */ z.object({ + contentType: QueueContentTypeSchema, + body: Base64DataSchema, + // When enqueuing messages on dead-letter queues, we want to reuse the same ID + // and timestamp + id: z.ostring(), + timestamp: z.onumber() +}), QueuesBatchRequestSchema = /* @__PURE__ */ z.object({ + messages: z.array(QueueIncomingMessageSchema) +}); + +// src/workers/queues/broker.worker.ts +var MAX_MESSAGE_SIZE_BYTES = 128 * 1e3, MAX_MESSAGE_BATCH_COUNT = 100, MAX_MESSAGE_BATCH_SIZE = (256 + 32) * 1e3, DEFAULT_BATCH_SIZE = 5, DEFAULT_BATCH_TIMEOUT = 1, DEFAULT_RETRIES = 2, exceptionQueueResponse = { + outcome: "exception", + retryAll: !1, + ackAll: !1, + explicitRetries: [], + explicitAcks: [] +}, PayloadTooLargeError = class extends HttpError { + constructor(message) { + super(413, message); + } +}; +function validateMessageSize(headers) { + let size = headers.get("Content-Length"); + if (size !== null && parseInt(size) > MAX_MESSAGE_SIZE_BYTES) + throw new PayloadTooLargeError( + `message length of ${size} bytes exceeds limit of ${MAX_MESSAGE_SIZE_BYTES}` + ); +} +function validateContentType(headers) { + let format = headers.get("X-Msg-Fmt") ?? void 0, result = QueueContentTypeSchema.safeParse(format); + if (!result.success) + throw new HttpError( + 400, + `message content type ${format} is invalid; if specified, must be one of 'text', 'json', 'bytes', or 'v8'` + ); + return result.data; +} +function validateBatchSize(headers) { + let count = headers.get("CF-Queue-Batch-Count"); + if (count !== null && parseInt(count) > MAX_MESSAGE_BATCH_COUNT) + throw new PayloadTooLargeError( + `batch message count of ${count} exceeds limit of ${MAX_MESSAGE_BATCH_COUNT}` + ); + let largestSize = headers.get("CF-Queue-Largest-Msg"); + if (largestSize !== null && parseInt(largestSize) > MAX_MESSAGE_SIZE_BYTES) + throw new PayloadTooLargeError( + `message in batch has length ${largestSize} bytes which exceeds single message size limit of ${MAX_MESSAGE_SIZE_BYTES}` + ); + let batchSize = headers.get("CF-Queue-Batch-Bytes"); + if (batchSize !== null && parseInt(batchSize) > MAX_MESSAGE_BATCH_SIZE) + throw new PayloadTooLargeError( + `batch size of ${batchSize} bytes exceeds limit of 256000` + ); +} +function deserialise({ contentType, body }) { + return contentType === "text" ? { contentType, body: body.toString() } : contentType === "json" ? { contentType, body: JSON.parse(body.toString()) } : contentType === "bytes" ? { contentType, body: viewToBuffer(body) } : { contentType, body }; +} +function serialise(msg) { + let body; + return msg.body.contentType === "text" ? body = Buffer2.from(msg.body.body) : msg.body.contentType === "json" ? body = Buffer2.from(JSON.stringify(msg.body.body)) : msg.body.contentType === "bytes" ? body = Buffer2.from(msg.body.body) : body = msg.body.body, { + id: msg.id, + timestamp: msg.timestamp, + contentType: msg.body.contentType, + body: body.toString("base64") + }; +} +var QueueMessage = class { + constructor(id, timestamp, body) { + this.id = id; + this.timestamp = timestamp; + this.body = body; + } + #failedAttempts = 0; + incrementFailedAttempts() { + return ++this.#failedAttempts; + } +}; +function formatQueueResponse(queueName, acked, total, time) { + let colour; + acked === total ? colour = green : acked > 0 ? colour = yellow : colour = red; + let message = `${bold("QUEUE")} ${queueName} ${colour(`${acked}/${total}`)}`; + return time !== void 0 && (message += grey(` (${time}ms)`)), reset(message); +} +var QueueBrokerObject = class extends MiniflareDurableObject { + #consumers; + #messages = []; + #pendingFlush; + constructor(state, env) { + super(state, env); + let maybeConsumers = env[QueueBindings.MAYBE_JSON_QUEUE_CONSUMERS]; + maybeConsumers === void 0 ? this.#consumers = {} : this.#consumers = QueueConsumersSchema.parse(maybeConsumers); + } + get #maybeConsumer() { + return this.#consumers[this.name]; + } + #dispatchBatch(workerName, batch) { + let bindingName = `${QueueBindings.SERVICE_WORKER_PREFIX}${workerName}`, maybeService = this.env[bindingName]; + assert( + maybeService !== void 0, + `Expected ${bindingName} service binding` + ); + let messages = batch.map(({ id, timestamp, body }) => body.contentType === "v8" ? { id, timestamp, serializedBody: body.body } : { id, timestamp, body: body.body }); + return maybeService.queue(this.name, messages); + } + #flush = async () => { + let consumer = this.#maybeConsumer; + assert(consumer !== void 0); + let batchSize = consumer.maxBatchSize ?? DEFAULT_BATCH_SIZE, maxAttempts = (consumer.maxRetires ?? DEFAULT_RETRIES) + 1, maxAttemptsS = maxAttempts === 1 ? "" : "s", batch = this.#messages.splice(0, batchSize), startTime = Date.now(), endTime, response; + try { + response = await this.#dispatchBatch(consumer.workerName, batch), endTime = Date.now(); + } catch (e) { + endTime = Date.now(), await this.logWithLevel(LogLevel.ERROR, String(e)), response = exceptionQueueResponse; + } + let retryAll = response.retryAll || response.outcome !== "ok", explicitRetries = new Set(response.explicitRetries), failedMessages = 0, toRetry = [], toDeadLetterQueue = []; + for (let message of batch) + (retryAll || explicitRetries.has(message.id)) && (failedMessages++, message.incrementFailedAttempts() < maxAttempts ? (await this.logWithLevel( + LogLevel.DEBUG, + `Retrying message "${message.id}" on queue "${this.name}"...` + ), toRetry.push(message)) : consumer.deadLetterQueue !== void 0 ? (await this.logWithLevel( + LogLevel.WARN, + `Moving message "${message.id}" on queue "${this.name}" to dead letter queue "${consumer.deadLetterQueue}" after ${maxAttempts} failed attempt${maxAttemptsS}...` + ), toDeadLetterQueue.push(message)) : await this.logWithLevel( + LogLevel.WARN, + `Dropped message "${message.id}" on queue "${this.name}" after ${maxAttempts} failed attempt${maxAttemptsS}!` + )); + let acked = batch.length - failedMessages; + if (await this.logWithLevel( + LogLevel.INFO, + formatQueueResponse(this.name, acked, batch.length, endTime - startTime) + ), this.#messages.push(...toRetry), this.#pendingFlush = void 0, this.#messages.length > 0 && this.#ensurePendingFlush(), toDeadLetterQueue.length > 0) { + let name = consumer.deadLetterQueue; + assert(name !== void 0); + let ns = this.env[SharedBindings.DURABLE_OBJECT_NAMESPACE_OBJECT], id = ns.idFromName(name), stub = ns.get(id), cf = { miniflare: { name } }, batchRequest = { + messages: toDeadLetterQueue.map(serialise) + }, res = await stub.fetch("http://placeholder/batch", { + method: "POST", + body: JSON.stringify(batchRequest), + cf + }); + assert(res.ok); + } + }; + #ensurePendingFlush() { + let consumer = this.#maybeConsumer; + assert(consumer !== void 0); + let batchSize = consumer.maxBatchSize ?? DEFAULT_BATCH_SIZE, batchTimeout = consumer.maxBatchTimeout ?? DEFAULT_BATCH_TIMEOUT, batchHasSpace = this.#messages.length < batchSize; + if (this.#pendingFlush !== void 0) { + if (this.#pendingFlush.immediate || batchHasSpace) + return; + this.timers.clearTimeout(this.#pendingFlush.timeout), this.#pendingFlush = void 0; + } + let delay = batchHasSpace ? batchTimeout * 1e3 : 0, timeout = this.timers.setTimeout(this.#flush, delay); + this.#pendingFlush = { immediate: delay === 0, timeout }; + } + #enqueue(messages) { + for (let message of messages) { + let randomness = crypto.getRandomValues(new Uint8Array(16)), id = message.id ?? Buffer2.from(randomness).toString("hex"), timestamp = message.timestamp ?? this.timers.now(), body = deserialise(message); + this.#messages.push(new QueueMessage(id, timestamp, body)); + } + this.#ensurePendingFlush(); + } + message = async (req) => { + validateMessageSize(req.headers); + let contentType = validateContentType(req.headers), body = Buffer2.from(await req.arrayBuffer()); + return this.#maybeConsumer === void 0 ? new Response() : (this.#enqueue([{ contentType, body }]), new Response()); + }; + batch = async (req) => { + validateBatchSize(req.headers); + let body = QueuesBatchRequestSchema.parse(await req.json()); + return this.#maybeConsumer === void 0 ? new Response() : (this.#enqueue(body.messages), new Response()); + }; +}; +__decorateClass([ + POST("/message") +], QueueBrokerObject.prototype, "message", 2), __decorateClass([ + POST("/batch") +], QueueBrokerObject.prototype, "batch", 2); +export { + QueueBrokerObject +}; +//# sourceMappingURL=broker.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/queues/broker.worker.js.map b/node_modules/miniflare/dist/src/workers/queues/broker.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b130c935b7d9bde495a429e60575e239bac04da5 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/queues/broker.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/queues/broker.worker.ts", "../../../../../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs", "../../../../src/workers/queues/constants.ts", "../../../../src/workers/queues/schemas.ts"], + "mappings": ";;;;;;;;;AAAA,OAAO,YAAY;AACnB,SAAS,UAAAA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["Buffer", "Buffer"] +} diff --git a/node_modules/miniflare/dist/src/workers/r2/bucket.worker.js b/node_modules/miniflare/dist/src/workers/r2/bucket.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..7f1a7e40afdbc8f776667a8126db2697644ac398 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/r2/bucket.worker.js @@ -0,0 +1,1157 @@ +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __decorateClass = (decorators, target, key, kind) => { + for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--) + (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result); + return kind && result && __defProp(target, key, result), result; +}; + +// src/workers/r2/bucket.worker.ts +import assert2 from "node:assert"; +import { Buffer as Buffer3 } from "node:buffer"; +import { createHash } from "node:crypto"; +import { + DeferredPromise, + GET, + MiniflareDurableObject, + PUT, + WaitGroup, + all, + base64Decode, + base64Encode, + get, + maybeApply, + readPrefix +} from "miniflare:shared"; + +// src/workers/r2/constants.ts +var R2Limits = { + MAX_LIST_KEYS: 1e3, + MAX_KEY_SIZE: 1024, + // https://developers.cloudflare.com/r2/platform/limits/ + MAX_VALUE_SIZE: 5363466240, + // 5 GiB - 5 MiB + MAX_METADATA_SIZE: 2048, + // 2048 B + MIN_MULTIPART_PART_SIZE: 5242880, + MIN_MULTIPART_PART_SIZE_TEST: 50 +}, R2Headers = { + ERROR: "cf-r2-error", + REQUEST: "cf-r2-request", + METADATA_SIZE: "cf-r2-metadata-size" +}; + +// src/workers/r2/errors.worker.ts +import { HttpError } from "miniflare:shared"; +var R2ErrorCode = { + INTERNAL_ERROR: 10001, + NO_SUCH_OBJECT_KEY: 10007, + ENTITY_TOO_LARGE: 100100, + ENTITY_TOO_SMALL: 10011, + METADATA_TOO_LARGE: 10012, + INVALID_OBJECT_NAME: 10020, + INVALID_MAX_KEYS: 10022, + NO_SUCH_UPLOAD: 10024, + INVALID_PART: 10025, + INVALID_ARGUMENT: 10029, + PRECONDITION_FAILED: 10031, + BAD_DIGEST: 10037, + INVALID_RANGE: 10039, + BAD_UPLOAD: 10048 +}, R2Error = class extends HttpError { + constructor(code, message, v4Code) { + super(code, message); + this.v4Code = v4Code; + } + object; + toResponse() { + if (this.object !== void 0) { + let { metadataSize, value } = this.object.encode(); + return new Response(value, { + status: this.code, + headers: { + [R2Headers.METADATA_SIZE]: `${metadataSize}`, + "Content-Type": "application/json", + [R2Headers.ERROR]: JSON.stringify({ + message: this.message, + version: 1, + // Note the lowercase 'c', which the runtime expects + v4code: this.v4Code + }) + } + }); + } + return new Response(null, { + status: this.code, + headers: { + [R2Headers.ERROR]: JSON.stringify({ + message: this.message, + version: 1, + // Note the lowercase 'c', which the runtime expects + v4code: this.v4Code + }) + } + }); + } + context(info) { + return this.message += ` (${info})`, this; + } + attach(object) { + return this.object = object, this; + } +}, InvalidMetadata = class extends R2Error { + constructor() { + super(400, "Metadata missing or invalid", R2ErrorCode.INVALID_ARGUMENT); + } +}, InternalError = class extends R2Error { + constructor() { + super( + 500, + "We encountered an internal error. Please try again.", + R2ErrorCode.INTERNAL_ERROR + ); + } +}, NoSuchKey = class extends R2Error { + constructor() { + super( + 404, + "The specified key does not exist.", + R2ErrorCode.NO_SUCH_OBJECT_KEY + ); + } +}, EntityTooLarge = class extends R2Error { + constructor() { + super( + 400, + "Your proposed upload exceeds the maximum allowed object size.", + R2ErrorCode.ENTITY_TOO_LARGE + ); + } +}, EntityTooSmall = class extends R2Error { + constructor() { + super( + 400, + "Your proposed upload is smaller than the minimum allowed object size.", + R2ErrorCode.ENTITY_TOO_SMALL + ); + } +}, MetadataTooLarge = class extends R2Error { + constructor() { + super( + 400, + "Your metadata headers exceed the maximum allowed metadata size.", + R2ErrorCode.METADATA_TOO_LARGE + ); + } +}, BadDigest = class extends R2Error { + constructor(algorithm, provided, calculated) { + super( + 400, + [ + `The ${algorithm} checksum you specified did not match what we received.`, + `You provided a ${algorithm} checksum with value: ${provided.toString( + "hex" + )}`, + `Actual ${algorithm} was: ${calculated.toString("hex")}` + ].join(` +`), + R2ErrorCode.BAD_DIGEST + ); + } +}, InvalidObjectName = class extends R2Error { + constructor() { + super( + 400, + "The specified object name is not valid.", + R2ErrorCode.INVALID_OBJECT_NAME + ); + } +}, InvalidMaxKeys = class extends R2Error { + constructor() { + super( + 400, + "MaxKeys params must be positive integer <= 1000.", + R2ErrorCode.INVALID_MAX_KEYS + ); + } +}, NoSuchUpload = class extends R2Error { + constructor() { + super( + 400, + "The specified multipart upload does not exist.", + R2ErrorCode.NO_SUCH_UPLOAD + ); + } +}, InvalidPart = class extends R2Error { + constructor() { + super( + 400, + "One or more of the specified parts could not be found.", + R2ErrorCode.INVALID_PART + ); + } +}, PreconditionFailed = class extends R2Error { + constructor() { + super( + 412, + "At least one of the pre-conditions you specified did not hold.", + R2ErrorCode.PRECONDITION_FAILED + ); + } +}, InvalidRange = class extends R2Error { + constructor() { + super( + 416, + "The requested range is not satisfiable", + R2ErrorCode.INVALID_RANGE + ); + } +}, BadUpload = class extends R2Error { + constructor() { + super( + 500, + "There was a problem with the multipart upload.", + R2ErrorCode.BAD_UPLOAD + ); + } +}; + +// src/workers/r2/r2Object.worker.ts +import { HEX_REGEXP } from "miniflare:zod"; +var InternalR2Object = class { + key; + version; + size; + etag; + uploaded; + httpMetadata; + customMetadata; + range; + checksums; + constructor(row, range) { + this.key = row.key, this.version = row.version, this.size = row.size, this.etag = row.etag, this.uploaded = row.uploaded, this.httpMetadata = JSON.parse(row.http_metadata), this.customMetadata = JSON.parse(row.custom_metadata), this.range = range; + let checksums = JSON.parse(row.checksums); + this.etag.length === 32 && HEX_REGEXP.test(this.etag) && (checksums.md5 = row.etag), this.checksums = checksums; + } + // Format for return to the Workers Runtime + #rawProperties() { + return { + name: this.key, + version: this.version, + size: this.size, + etag: this.etag, + uploaded: this.uploaded, + httpFields: this.httpMetadata, + customFields: Object.entries(this.customMetadata).map(([k, v]) => ({ + k, + v + })), + range: this.range, + checksums: { + 0: this.checksums.md5, + 1: this.checksums.sha1, + 2: this.checksums.sha256, + 3: this.checksums.sha384, + 4: this.checksums.sha512 + } + }; + } + encode() { + let json = JSON.stringify(this.#rawProperties()), blob = new Blob([json]); + return { metadataSize: blob.size, value: blob.stream(), size: blob.size }; + } + static encodeMultiple(objects) { + let json = JSON.stringify({ + ...objects, + objects: objects.objects.map((o) => o.#rawProperties()) + }), blob = new Blob([json]); + return { metadataSize: blob.size, value: blob.stream(), size: blob.size }; + } +}, InternalR2ObjectBody = class extends InternalR2Object { + constructor(metadata, body, range) { + super(metadata, range); + this.body = body; + } + encode() { + let { metadataSize, value: metadata } = super.encode(), size = this.range?.length ?? this.size, identity2 = new FixedLengthStream(size + metadataSize); + return metadata.pipeTo(identity2.writable, { preventClose: !0 }).then(() => this.body.pipeTo(identity2.writable)), { + metadataSize, + value: identity2.readable, + size + }; + } +}; + +// src/workers/r2/schemas.worker.ts +import { Base64DataSchema, HexDataSchema, z } from "miniflare:zod"; +var MultipartUploadState = { + IN_PROGRESS: 0, + COMPLETED: 1, + ABORTED: 2 +}, SQL_SCHEMA = ` +CREATE TABLE IF NOT EXISTS _mf_objects ( + key TEXT PRIMARY KEY, + blob_id TEXT, + version TEXT NOT NULL, + size INTEGER NOT NULL, + etag TEXT NOT NULL, + uploaded INTEGER NOT NULL, + checksums TEXT NOT NULL, + http_metadata TEXT NOT NULL, + custom_metadata TEXT NOT NULL +); +CREATE TABLE IF NOT EXISTS _mf_multipart_uploads ( + upload_id TEXT PRIMARY KEY, + key TEXT NOT NULL, + http_metadata TEXT NOT NULL, + custom_metadata TEXT NOT NULL, + state TINYINT DEFAULT 0 NOT NULL +); +CREATE TABLE IF NOT EXISTS _mf_multipart_parts ( + upload_id TEXT NOT NULL REFERENCES _mf_multipart_uploads(upload_id), + part_number INTEGER NOT NULL, + blob_id TEXT NOT NULL, + size INTEGER NOT NULL, + etag TEXT NOT NULL, + checksum_md5 TEXT NOT NULL, + object_key TEXT REFERENCES _mf_objects(key) DEFERRABLE INITIALLY DEFERRED, + PRIMARY KEY (upload_id, part_number) +); +`, DateSchema = z.coerce.number().transform((value) => new Date(value)), RecordSchema = z.object({ + k: z.string(), + v: z.string() +}).array().transform( + (entries) => Object.fromEntries(entries.map(({ k, v }) => [k, v])) +), R2RangeSchema = z.object({ + offset: z.coerce.number().optional(), + length: z.coerce.number().optional(), + suffix: z.coerce.number().optional() +}), R2EtagSchema = z.discriminatedUnion("type", [ + z.object({ type: z.literal("strong"), value: z.string() }), + z.object({ type: z.literal("weak"), value: z.string() }), + z.object({ type: z.literal("wildcard") }) +]), R2EtagMatchSchema = R2EtagSchema.array().min(1).optional(), R2ConditionalSchema = z.object({ + // Performs the operation if the object's ETag matches the given string + etagMatches: R2EtagMatchSchema, + // "If-Match" + // Performs the operation if the object's ETag does NOT match the given string + etagDoesNotMatch: R2EtagMatchSchema, + // "If-None-Match" + // Performs the operation if the object was uploaded BEFORE the given date + uploadedBefore: DateSchema.optional(), + // "If-Unmodified-Since" + // Performs the operation if the object was uploaded AFTER the given date + uploadedAfter: DateSchema.optional(), + // "If-Modified-Since" + // Truncates dates to seconds before performing comparisons + secondsGranularity: z.oboolean() +}), R2ChecksumsSchema = z.object({ + 0: HexDataSchema.optional(), + 1: HexDataSchema.optional(), + 2: HexDataSchema.optional(), + 3: HexDataSchema.optional(), + 4: HexDataSchema.optional() +}).transform((checksums) => ({ + md5: checksums[0], + sha1: checksums[1], + sha256: checksums[2], + sha384: checksums[3], + sha512: checksums[4] +})), R2PublishedPartSchema = z.object({ + etag: z.string(), + part: z.number() +}), R2HttpFieldsSchema = z.object({ + contentType: z.ostring(), + contentLanguage: z.ostring(), + contentDisposition: z.ostring(), + contentEncoding: z.ostring(), + cacheControl: z.ostring(), + cacheExpiry: z.coerce.number().optional() +}), R2HeadRequestSchema = z.object({ + method: z.literal("head"), + object: z.string() +}), R2GetRequestSchema = z.object({ + method: z.literal("get"), + object: z.string(), + // Specifies that only a specific length (from an optional offset) or suffix + // of bytes from the object should be returned. Refer to + // https://developers.cloudflare.com/r2/runtime-apis/#ranged-reads. + range: R2RangeSchema.optional(), + rangeHeader: z.ostring(), + // Specifies that the object should only be returned given satisfaction of + // certain conditions in the R2Conditional. Refer to R2Conditional above. + onlyIf: R2ConditionalSchema.optional() +}), R2PutRequestSchema = z.object({ + method: z.literal("put"), + object: z.string(), + customFields: RecordSchema.optional(), + // (renamed in transform) + httpFields: R2HttpFieldsSchema.optional(), + // (renamed in transform) + onlyIf: R2ConditionalSchema.optional(), + md5: Base64DataSchema.optional(), + // (intentionally base64, not hex) + sha1: HexDataSchema.optional(), + sha256: HexDataSchema.optional(), + sha384: HexDataSchema.optional(), + sha512: HexDataSchema.optional() +}).transform((value) => ({ + method: value.method, + object: value.object, + customMetadata: value.customFields, + httpMetadata: value.httpFields, + onlyIf: value.onlyIf, + md5: value.md5, + sha1: value.sha1, + sha256: value.sha256, + sha384: value.sha384, + sha512: value.sha512 +})), R2CreateMultipartUploadRequestSchema = z.object({ + method: z.literal("createMultipartUpload"), + object: z.string(), + customFields: RecordSchema.optional(), + // (renamed in transform) + httpFields: R2HttpFieldsSchema.optional() + // (renamed in transform) +}).transform((value) => ({ + method: value.method, + object: value.object, + customMetadata: value.customFields, + httpMetadata: value.httpFields +})), R2UploadPartRequestSchema = z.object({ + method: z.literal("uploadPart"), + object: z.string(), + uploadId: z.string(), + partNumber: z.number() +}), R2CompleteMultipartUploadRequestSchema = z.object({ + method: z.literal("completeMultipartUpload"), + object: z.string(), + uploadId: z.string(), + parts: R2PublishedPartSchema.array() +}), R2AbortMultipartUploadRequestSchema = z.object({ + method: z.literal("abortMultipartUpload"), + object: z.string(), + uploadId: z.string() +}), R2ListRequestSchema = z.object({ + method: z.literal("list"), + limit: z.onumber(), + prefix: z.ostring(), + cursor: z.ostring(), + delimiter: z.ostring(), + startAfter: z.ostring(), + include: z.union([z.literal(0), z.literal(1)]).transform((value) => value === 0 ? "httpMetadata" : "customMetadata").array().optional() +}), R2DeleteRequestSchema = z.intersection( + z.object({ method: z.literal("delete") }), + z.union([ + z.object({ object: z.string() }), + z.object({ objects: z.string().array() }) + ]) +), R2BindingRequestSchema = z.union([ + R2HeadRequestSchema, + R2GetRequestSchema, + R2PutRequestSchema, + R2CreateMultipartUploadRequestSchema, + R2UploadPartRequestSchema, + R2CompleteMultipartUploadRequestSchema, + R2AbortMultipartUploadRequestSchema, + R2ListRequestSchema, + R2DeleteRequestSchema +]); + +// src/workers/r2/validator.worker.ts +import assert from "node:assert"; +import { Buffer as Buffer2 } from "node:buffer"; +import { parseRanges } from "miniflare:shared"; +function identity(ms) { + return ms; +} +function truncateToSeconds(ms) { + return Math.floor(ms / 1e3) * 1e3; +} +function includesEtag(conditions, etag, comparison) { + for (let condition of conditions) + if (condition.type === "wildcard" || condition.value === etag && (condition.type === "strong" || comparison === "weak")) + return !0; + return !1; +} +function _testR2Conditional(cond, metadata) { + if (metadata === void 0) { + let ifMatch2 = cond.etagMatches === void 0, ifModifiedSince2 = cond.uploadedAfter === void 0; + return ifMatch2 && ifModifiedSince2; + } + let { etag, uploaded: lastModifiedRaw } = metadata, ifMatch = cond.etagMatches === void 0 || includesEtag(cond.etagMatches, etag, "strong"), ifNoneMatch = cond.etagDoesNotMatch === void 0 || !includesEtag(cond.etagDoesNotMatch, etag, "weak"), maybeTruncate = cond.secondsGranularity ? truncateToSeconds : identity, lastModified = maybeTruncate(lastModifiedRaw), ifModifiedSince = cond.uploadedAfter === void 0 || maybeTruncate(cond.uploadedAfter.getTime()) < lastModified || cond.etagDoesNotMatch !== void 0 && ifNoneMatch, ifUnmodifiedSince = cond.uploadedBefore === void 0 || lastModified < maybeTruncate(cond.uploadedBefore.getTime()) || cond.etagMatches !== void 0 && ifMatch; + return ifMatch && ifNoneMatch && ifModifiedSince && ifUnmodifiedSince; +} +var R2_HASH_ALGORITHMS = [ + { name: "MD5", field: "md5" }, + { name: "SHA-1", field: "sha1" }, + { name: "SHA-256", field: "sha256" }, + { name: "SHA-384", field: "sha384" }, + { name: "SHA-512", field: "sha512" } +]; +function serialisedLength(x) { + for (let i = 0; i < x.length; i++) + if (x.charCodeAt(i) >= 256) + return x.length * 2; + return x.length; +} +var Validator = class { + hash(digests, hashes) { + let checksums = {}; + for (let { name, field } of R2_HASH_ALGORITHMS) { + let providedHash = hashes[field]; + if (providedHash !== void 0) { + let computedHash = digests.get(name); + if (assert(computedHash !== void 0), !providedHash.equals(computedHash)) + throw new BadDigest(name, providedHash, computedHash); + checksums[field] = computedHash.toString("hex"); + } + } + return checksums; + } + condition(meta, onlyIf) { + if (onlyIf !== void 0 && !_testR2Conditional(onlyIf, meta)) + throw new PreconditionFailed(); + return this; + } + range(options, size) { + if (options.rangeHeader !== void 0) { + let ranges = parseRanges(options.rangeHeader, size); + if (ranges?.length === 1) + return ranges[0]; + } else if (options.range !== void 0) { + let { offset, length, suffix } = options.range; + if (suffix !== void 0) { + if (suffix <= 0) + throw new InvalidRange(); + suffix > size && (suffix = size), offset = size - suffix, length = suffix; + } + if (offset === void 0 && (offset = 0), length === void 0 && (length = size - offset), offset < 0 || offset > size || length <= 0) + throw new InvalidRange(); + return offset + length > size && (length = size - offset), { start: offset, end: offset + length - 1 }; + } + } + size(size) { + if (size > R2Limits.MAX_VALUE_SIZE) + throw new EntityTooLarge(); + return this; + } + metadataSize(customMetadata) { + if (customMetadata === void 0) + return this; + let metadataLength = 0; + for (let [key, value] of Object.entries(customMetadata)) + metadataLength += serialisedLength(key) + serialisedLength(value); + if (metadataLength > R2Limits.MAX_METADATA_SIZE) + throw new MetadataTooLarge(); + return this; + } + key(key) { + if (Buffer2.byteLength(key) > R2Limits.MAX_KEY_SIZE) + throw new InvalidObjectName(); + return this; + } + limit(limit) { + if (limit !== void 0 && (limit < 1 || limit > R2Limits.MAX_LIST_KEYS)) + throw new InvalidMaxKeys(); + return this; + } +}; + +// src/workers/r2/bucket.worker.ts +var DigestingStream = class extends TransformStream { + digests; + constructor(algorithms) { + let digests = new DeferredPromise(), hashes = algorithms.map((alg) => { + let stream = new crypto.DigestStream(alg), writer = stream.getWriter(); + return { stream, writer }; + }); + super({ + async transform(chunk, controller) { + for (let hash of hashes) + await hash.writer.write(chunk); + controller.enqueue(chunk); + }, + async flush() { + let result = /* @__PURE__ */ new Map(); + for (let i = 0; i < hashes.length; i++) + await hashes[i].writer.close(), result.set(algorithms[i], Buffer3.from(await hashes[i].stream.digest)); + digests.resolve(result); + } + }), this.digests = digests; + } +}, validate = new Validator(), decoder = new TextDecoder(); +function generateVersion() { + return Buffer3.from(crypto.getRandomValues(new Uint8Array(16))).toString( + "hex" + ); +} +function generateId() { + return Buffer3.from(crypto.getRandomValues(new Uint8Array(128))).toString( + "base64url" + ); +} +function generateMultipartEtag(md5Hexes) { + let hash = createHash("md5"); + for (let md5Hex of md5Hexes) + hash.update(md5Hex, "hex"); + return `${hash.digest("hex")}-${md5Hexes.length}`; +} +function rangeOverlaps(a, b) { + return a.start <= b.end && b.start <= a.end; +} +async function decodeMetadata(req) { + let metadataSize = parseInt(req.headers.get(R2Headers.METADATA_SIZE)); + if (Number.isNaN(metadataSize)) + throw new InvalidMetadata(); + assert2(req.body !== null); + let body = req.body, [metadataBuffer, value] = await readPrefix(body, metadataSize), metadataJson = decoder.decode(metadataBuffer); + return { metadata: R2BindingRequestSchema.parse(JSON.parse(metadataJson)), metadataSize, value }; +} +function decodeHeaderMetadata(req) { + let header = req.headers.get(R2Headers.REQUEST); + if (header === null) + throw new InvalidMetadata(); + return R2BindingRequestSchema.parse(JSON.parse(header)); +} +function encodeResult(result) { + let encoded; + return result instanceof InternalR2Object ? encoded = result.encode() : encoded = InternalR2Object.encodeMultiple(result), new Response(encoded.value, { + headers: { + [R2Headers.METADATA_SIZE]: `${encoded.metadataSize}`, + "Content-Type": "application/json", + "Content-Length": `${encoded.size}` + } + }); +} +function encodeJSONResult(result) { + let encoded = JSON.stringify(result); + return new Response(encoded, { + headers: { + [R2Headers.METADATA_SIZE]: `${Buffer3.byteLength(encoded)}`, + "Content-Type": "application/json" + } + }); +} +function sqlStmts(db) { + let stmtGetPreviousByKey = db.stmt("SELECT blob_id, etag, uploaded FROM _mf_objects WHERE key = :key"), stmtGetByKey = db.stmt(` + SELECT key, blob_id, version, size, etag, uploaded, checksums, http_metadata, custom_metadata + FROM _mf_objects WHERE key = :key + `), stmtPut = db.stmt(` + INSERT OR REPLACE INTO _mf_objects (key, blob_id, version, size, etag, uploaded, checksums, http_metadata, custom_metadata) + VALUES (:key, :blob_id, :version, :size, :etag, :uploaded, :checksums, :http_metadata, :custom_metadata) + `), stmtDelete = db.stmt("DELETE FROM _mf_objects WHERE key = :key RETURNING blob_id"); + function stmtListWithoutDelimiter(...extraColumns) { + let columns = [ + "key", + "version", + "size", + "etag", + "uploaded", + "checksums", + ...extraColumns + ]; + return db.stmt(` + SELECT ${columns.join(", ")} + FROM _mf_objects + WHERE substr(key, 1, length(:prefix)) = :prefix + AND (:start_after IS NULL OR key > :start_after) + ORDER BY key LIMIT :limit + `); + } + let stmtGetUploadState = db.stmt( + // For checking current upload state + "SELECT state FROM _mf_multipart_uploads WHERE upload_id = :upload_id AND key = :key" + ), stmtGetUploadMetadata = db.stmt( + // For checking current upload state, and getting metadata for completion + "SELECT http_metadata, custom_metadata, state FROM _mf_multipart_uploads WHERE upload_id = :upload_id AND key = :key" + ), stmtUpdateUploadState = db.stmt( + // For completing/aborting uploads + "UPDATE _mf_multipart_uploads SET state = :state WHERE upload_id = :upload_id" + ), stmtGetPreviousPartByNumber = db.stmt( + // For getting part number's previous blob ID to garbage collect + "SELECT blob_id FROM _mf_multipart_parts WHERE upload_id = :upload_id AND part_number = :part_number" + ), stmtPutPart = db.stmt( + // For recording metadata when uploading parts + `INSERT OR REPLACE INTO _mf_multipart_parts (upload_id, part_number, blob_id, size, etag, checksum_md5) + VALUES (:upload_id, :part_number, :blob_id, :size, :etag, :checksum_md5)` + ), stmtLinkPart = db.stmt( + // For linking parts with an object when completing uploads + `UPDATE _mf_multipart_parts SET object_key = :object_key + WHERE upload_id = :upload_id AND part_number = :part_number` + ), stmtDeletePartsByUploadId = db.stmt( + // For deleting parts when aborting uploads + "DELETE FROM _mf_multipart_parts WHERE upload_id = :upload_id RETURNING blob_id" + ), stmtDeleteUnlinkedPartsByUploadId = db.stmt( + // For deleting unused parts when completing uploads + "DELETE FROM _mf_multipart_parts WHERE upload_id = :upload_id AND object_key IS NULL RETURNING blob_id" + ), stmtDeletePartsByKey = db.stmt( + // For deleting dangling parts when overwriting an existing key + "DELETE FROM _mf_multipart_parts WHERE object_key = :object_key RETURNING blob_id" + ), stmtListPartsByUploadId = db.stmt( + // For getting part metadata when completing uploads + `SELECT upload_id, part_number, blob_id, size, etag, checksum_md5, object_key + FROM _mf_multipart_parts WHERE upload_id = :upload_id` + ), stmtListPartsByKey = db.stmt( + // For getting part metadata when getting values, size included for range + // requests, so we only need to read blobs containing the required data + "SELECT blob_id, size FROM _mf_multipart_parts WHERE object_key = :object_key ORDER BY part_number" + ); + return { + getByKey: stmtGetByKey, + getPartsByKey: db.txn((key) => { + let row = get(stmtGetByKey({ key })); + if (row !== void 0) + if (row.blob_id === null) { + let partsRows = all(stmtListPartsByKey({ object_key: key })); + return { row, parts: partsRows }; + } else + return { row }; + }), + put: db.txn((newRow, onlyIf) => { + let key = newRow.key, row = get(stmtGetPreviousByKey({ key })); + onlyIf !== void 0 && validate.condition(row, onlyIf), stmtPut(newRow); + let maybeOldBlobId = row?.blob_id; + return maybeOldBlobId === void 0 ? [] : maybeOldBlobId === null ? all(stmtDeletePartsByKey({ object_key: key })).map(({ blob_id }) => blob_id) : [maybeOldBlobId]; + }), + deleteByKeys: db.txn((keys) => { + let oldBlobIds = []; + for (let key of keys) { + let maybeOldBlobId = get(stmtDelete({ key }))?.blob_id; + if (maybeOldBlobId === null) { + let partRows = stmtDeletePartsByKey({ object_key: key }); + for (let partRow of partRows) + oldBlobIds.push(partRow.blob_id); + } else + maybeOldBlobId !== void 0 && oldBlobIds.push(maybeOldBlobId); + } + return oldBlobIds; + }), + listWithoutDelimiter: stmtListWithoutDelimiter(), + listHttpMetadataWithoutDelimiter: stmtListWithoutDelimiter("http_metadata"), + listCustomMetadataWithoutDelimiter: stmtListWithoutDelimiter("custom_metadata"), + listHttpCustomMetadataWithoutDelimiter: stmtListWithoutDelimiter( + "http_metadata", + "custom_metadata" + ), + listMetadata: db.stmt(` + SELECT + -- When grouping by a delimited prefix, this will give us the last key with that prefix. + -- NOTE: we'll use this for the next cursor. If we didn't return the last key, the next page may return the + -- same delimited prefix. Essentially, we're skipping over all keys with this group's delimited prefix. + -- When grouping by a key, this will just give us the key. + max(key) AS last_key, + iif( + -- Try get 1-indexed position \`i\` of :delimiter in rest of key after :prefix... + instr(substr(key, length(:prefix) + 1), :delimiter), + -- ...if found, we have a delimited prefix of the :prefix followed by the rest of key up to and including the :delimiter + 'dlp:' || substr(key, 1, length(:prefix) + instr(substr(key, length(:prefix) + 1), :delimiter) + length(:delimiter) - 1), + -- ...otherwise, we just have a regular key + 'key:' || key + ) AS delimited_prefix_or_key, + -- NOTE: we'll ignore metadata for delimited prefix rows, so it doesn't matter which keys' we return + version, size, etag, uploaded, checksums, http_metadata, custom_metadata + FROM _mf_objects + WHERE substr(key, 1, length(:prefix)) = :prefix + AND (:start_after IS NULL OR key > :start_after) + GROUP BY delimited_prefix_or_key -- Group keys with same delimited prefix into a row, leaving others in their own rows + ORDER BY last_key LIMIT :limit; + `), + createMultipartUpload: db.stmt(` + INSERT INTO _mf_multipart_uploads (upload_id, key, http_metadata, custom_metadata) + VALUES (:upload_id, :key, :http_metadata, :custom_metadata) + `), + putPart: db.txn( + (key, newRow) => { + if (get( + stmtGetUploadState({ + key, + upload_id: newRow.upload_id + }) + )?.state !== MultipartUploadState.IN_PROGRESS) + throw new NoSuchUpload(); + let partRow = get( + stmtGetPreviousPartByNumber({ + upload_id: newRow.upload_id, + part_number: newRow.part_number + }) + ); + return stmtPutPart(newRow), partRow?.blob_id; + } + ), + completeMultipartUpload: db.txn( + (key, upload_id, selectedParts, minPartSize) => { + let uploadRow = get(stmtGetUploadMetadata({ key, upload_id })); + if (uploadRow === void 0) + throw new InternalError(); + if (uploadRow.state > MultipartUploadState.IN_PROGRESS) + throw new NoSuchUpload(); + let partNumberSet = /* @__PURE__ */ new Set(); + for (let { part } of selectedParts) { + if (partNumberSet.has(part)) + throw new InternalError(); + partNumberSet.add(part); + } + let uploadedPartRows = stmtListPartsByUploadId({ upload_id }), uploadedParts = /* @__PURE__ */ new Map(); + for (let row of uploadedPartRows) + uploadedParts.set(row.part_number, row); + let parts = selectedParts.map((selectedPart) => { + let uploadedPart = uploadedParts.get(selectedPart.part); + if (uploadedPart?.etag !== selectedPart.etag) + throw new InvalidPart(); + return uploadedPart; + }); + for (let part of parts.slice(0, -1)) + if (part.size < minPartSize) + throw new EntityTooSmall(); + parts.sort((a, b) => a.part_number - b.part_number); + let partSize; + for (let part of parts.slice(0, -1)) + if (partSize ??= part.size, part.size < minPartSize || part.size !== partSize) + throw new BadUpload(); + if (partSize !== void 0 && parts[parts.length - 1].size > partSize) + throw new BadUpload(); + let oldBlobIds = [], maybeOldBlobId = get(stmtGetPreviousByKey({ key }))?.blob_id; + if (maybeOldBlobId === null) { + let partRows2 = stmtDeletePartsByKey({ object_key: key }); + for (let partRow of partRows2) + oldBlobIds.push(partRow.blob_id); + } else + maybeOldBlobId !== void 0 && oldBlobIds.push(maybeOldBlobId); + let totalSize = parts.reduce((acc, { size }) => acc + size, 0), etag = generateMultipartEtag( + parts.map(({ checksum_md5 }) => checksum_md5) + ), newRow = { + key, + blob_id: null, + version: generateVersion(), + size: totalSize, + etag, + uploaded: Date.now(), + checksums: "{}", + http_metadata: uploadRow.http_metadata, + custom_metadata: uploadRow.custom_metadata + }; + stmtPut(newRow); + for (let part of parts) + stmtLinkPart({ + upload_id, + part_number: part.part_number, + object_key: key + }); + let partRows = stmtDeleteUnlinkedPartsByUploadId({ upload_id }); + for (let partRow of partRows) + oldBlobIds.push(partRow.blob_id); + return stmtUpdateUploadState({ + upload_id, + state: MultipartUploadState.COMPLETED + }), { newRow, oldBlobIds }; + } + ), + abortMultipartUpload: db.txn((key, upload_id) => { + let uploadRow = get(stmtGetUploadState({ key, upload_id })); + if (uploadRow === void 0) + throw new InternalError(); + if (uploadRow.state > MultipartUploadState.IN_PROGRESS) + return []; + let oldBlobIds = all(stmtDeletePartsByUploadId({ upload_id })).map(({ blob_id }) => blob_id); + return stmtUpdateUploadState({ + upload_id, + state: MultipartUploadState.ABORTED + }), oldBlobIds; + }) + }; +} +var R2BucketObject = class extends MiniflareDurableObject { + #stmts; + // Multipart uploads are stored as multiple blobs. Therefore, when reading a + // multipart upload, we'll be reading multiple blobs. When an object is + // deleted, all its blobs are deleted in the background. + // + // Normally for single part objects, this is fine, since we'd open a handle to + // a single blob, which we'd have until we closed it, at which point the blob + // may be deleted. With multipart, we don't want to open handles for all blobs + // as we could hit open file descriptor limits. Similarly, we don't want to + // read all blobs first, as we'd have to buffer them. + // + // Instead, we set up in-process locking on blobs needed for multipart reads. + // When we start a multipart read, we acquire all the blobs we need, then + // release them as we've streamed each part. Multiple multipart reads may be + // in-progress at any given time, so we use a wait group. + // + // This assumes we only ever have a single Miniflare instance operating on a + // blob store, which is always true for in-memory stores, and usually true for + // on-disk ones. If we really wanted to do this properly, we could store the + // bookkeeping for the wait group in SQLite, but then we'd have to implement + // some inter-process signalling/subscription system. + #inUseBlobs = /* @__PURE__ */ new Map(); + constructor(state, env) { + super(state, env), this.db.exec("PRAGMA case_sensitive_like = TRUE"), this.db.exec(SQL_SCHEMA), this.#stmts = sqlStmts(this.db); + } + #acquireBlob(blobId) { + let waitGroup = this.#inUseBlobs.get(blobId); + waitGroup === void 0 ? (waitGroup = new WaitGroup(), this.#inUseBlobs.set(blobId, waitGroup), waitGroup.add(), waitGroup.wait().then(() => this.#inUseBlobs.delete(blobId))) : waitGroup.add(); + } + #releaseBlob(blobId) { + this.#inUseBlobs.get(blobId)?.done(); + } + #backgroundDelete(blobId) { + this.timers.queueMicrotask(async () => (await this.#inUseBlobs.get(blobId)?.wait(), this.blob.delete(blobId).catch((e) => { + console.error("R2BucketObject##backgroundDelete():", e); + }))); + } + #assembleMultipartValue(parts, queryRange) { + let requiredParts = [], start = 0; + for (let part of parts) { + let partRange = { start, end: start + part.size - 1 }; + if (rangeOverlaps(partRange, queryRange)) { + let range = { + start: Math.max(partRange.start, queryRange.start) - partRange.start, + end: Math.min(partRange.end, queryRange.end) - partRange.start + }; + this.#acquireBlob(part.blob_id), requiredParts.push({ blobId: part.blob_id, range }); + } + start = partRange.end + 1; + } + let identity2 = new TransformStream(); + return (async () => { + let i = 0; + try { + for (; i < requiredParts.length; i++) { + let { blobId, range } = requiredParts[i], value = await this.blob.get(blobId, range), msg = `Expected to find blob "${blobId}" for multipart value`; + assert2(value !== null, msg), await value.pipeTo(identity2.writable, { preventClose: !0 }), this.#releaseBlob(blobId); + } + await identity2.writable.close(); + } catch (e) { + await identity2.writable.abort(e); + } finally { + for (; i < requiredParts.length; i++) + this.#releaseBlob(requiredParts[i].blobId); + } + })(), identity2.readable; + } + async #head(key) { + validate.key(key); + let row = get(this.#stmts.getByKey({ key })); + if (row === void 0) + throw new NoSuchKey(); + let range = { offset: 0, length: row.size }; + return new InternalR2Object(row, range); + } + async #get(key, opts) { + validate.key(key); + let result = this.#stmts.getPartsByKey(key); + if (result === void 0) + throw new NoSuchKey(); + let { row, parts } = result, defaultR2Range = { offset: 0, length: row.size }; + try { + validate.condition(row, opts.onlyIf); + } catch (e) { + throw e instanceof PreconditionFailed && e.attach(new InternalR2Object(row, defaultR2Range)), e; + } + let range = validate.range(opts, row.size), r2Range; + if (range === void 0) + r2Range = defaultR2Range; + else { + let start = range.start, end = Math.min(range.end, row.size); + r2Range = { offset: start, length: end - start + 1 }; + } + let value; + if (row.blob_id === null) { + assert2(parts !== void 0); + let defaultRange = { start: 0, end: row.size - 1 }; + value = this.#assembleMultipartValue(parts, range ?? defaultRange); + } else if (value = await this.blob.get(row.blob_id, range), value === null) + throw new NoSuchKey(); + return new InternalR2ObjectBody(row, value, r2Range); + } + async #put(key, value, valueSize, opts) { + let algorithms = []; + for (let { name, field } of R2_HASH_ALGORITHMS) + (field === "md5" || opts[field] !== void 0) && algorithms.push(name); + let digesting = new DigestingStream(algorithms), blobId = await this.blob.put(value.pipeThrough(digesting)), digests = await digesting.digests, md5Digest = digests.get("MD5"); + assert2(md5Digest !== void 0); + let md5DigestHex = md5Digest.toString("hex"), checksums = validate.key(key).size(valueSize).metadataSize(opts.customMetadata).hash(digests, opts), row = { + key, + blob_id: blobId, + version: generateVersion(), + size: valueSize, + etag: md5DigestHex, + uploaded: Date.now(), + checksums: JSON.stringify(checksums), + http_metadata: JSON.stringify(opts.httpMetadata ?? {}), + custom_metadata: JSON.stringify(opts.customMetadata ?? {}) + }, oldBlobIds; + try { + oldBlobIds = this.#stmts.put(row, opts.onlyIf); + } catch (e) { + throw this.#backgroundDelete(blobId), e; + } + if (oldBlobIds !== void 0) + for (let blobId2 of oldBlobIds) + this.#backgroundDelete(blobId2); + return new InternalR2Object(row); + } + #delete(keys) { + Array.isArray(keys) || (keys = [keys]); + for (let key of keys) + validate.key(key); + let oldBlobIds = this.#stmts.deleteByKeys(keys); + for (let blobId of oldBlobIds) + this.#backgroundDelete(blobId); + } + #listWithoutDelimiterQuery(excludeHttp, excludeCustom) { + return excludeHttp && excludeCustom ? this.#stmts.listWithoutDelimiter : excludeHttp ? this.#stmts.listCustomMetadataWithoutDelimiter : excludeCustom ? this.#stmts.listHttpMetadataWithoutDelimiter : this.#stmts.listHttpCustomMetadataWithoutDelimiter; + } + async #list(opts) { + let prefix = opts.prefix ?? "", limit = opts.limit ?? R2Limits.MAX_LIST_KEYS; + validate.limit(limit); + let include = opts.include ?? []; + include.length > 0 && (limit = Math.min(limit, 100)); + let excludeHttp = !include.includes("httpMetadata"), excludeCustom = !include.includes("customMetadata"), rowObject = (row) => ((row.http_metadata === void 0 || excludeHttp) && (row.http_metadata = "{}"), (row.custom_metadata === void 0 || excludeCustom) && (row.custom_metadata = "{}"), new InternalR2Object(row)), startAfter = opts.startAfter; + if (opts.cursor !== void 0) { + let cursorStartAfter = base64Decode(opts.cursor); + (startAfter === void 0 || cursorStartAfter > startAfter) && (startAfter = cursorStartAfter); + } + let delimiter = opts.delimiter; + delimiter === "" && (delimiter = void 0); + let params = { + prefix, + start_after: startAfter ?? null, + // Increase the queried limit by 1, if we return this many results, we + // know there are more rows. We'll truncate to the original limit before + // returning results. + limit: limit + 1 + }, objects, delimitedPrefixes = [], nextCursorStartAfter; + if (delimiter !== void 0) { + let rows = all(this.#stmts.listMetadata({ ...params, delimiter })), hasMoreRows = rows.length === limit + 1; + rows.splice(limit, 1), objects = []; + for (let row of rows) + row.delimited_prefix_or_key.startsWith("dlp:") ? delimitedPrefixes.push(row.delimited_prefix_or_key.substring(4)) : objects.push(rowObject({ ...row, key: row.last_key })); + hasMoreRows && (nextCursorStartAfter = rows[limit - 1].last_key); + } else { + let query = this.#listWithoutDelimiterQuery(excludeHttp, excludeCustom), rows = all(query(params)), hasMoreRows = rows.length === limit + 1; + rows.splice(limit, 1), objects = rows.map(rowObject), hasMoreRows && (nextCursorStartAfter = rows[limit - 1].key); + } + let nextCursor = maybeApply(base64Encode, nextCursorStartAfter); + return { + objects, + truncated: nextCursor !== void 0, + cursor: nextCursor, + delimitedPrefixes + }; + } + async #createMultipartUpload(key, opts) { + validate.key(key); + let uploadId = generateId(); + return this.#stmts.createMultipartUpload({ + key, + upload_id: uploadId, + http_metadata: JSON.stringify(opts.httpMetadata ?? {}), + custom_metadata: JSON.stringify(opts.customMetadata ?? {}) + }), { uploadId }; + } + async #uploadPart(key, uploadId, partNumber, value, valueSize) { + validate.key(key); + let digesting = new DigestingStream(["MD5"]), blobId = await this.blob.put(value.pipeThrough(digesting)), md5Digest = (await digesting.digests).get("MD5"); + assert2(md5Digest !== void 0); + let etag = generateId(), maybeOldBlobId; + try { + maybeOldBlobId = this.#stmts.putPart(key, { + upload_id: uploadId, + part_number: partNumber, + blob_id: blobId, + size: valueSize, + etag, + checksum_md5: md5Digest.toString("hex") + }); + } catch (e) { + throw this.#backgroundDelete(blobId), e; + } + return maybeOldBlobId !== void 0 && this.#backgroundDelete(maybeOldBlobId), { etag }; + } + async #completeMultipartUpload(key, uploadId, parts) { + validate.key(key); + let minPartSize = this.beingTested ? R2Limits.MIN_MULTIPART_PART_SIZE_TEST : R2Limits.MIN_MULTIPART_PART_SIZE, { newRow, oldBlobIds } = this.#stmts.completeMultipartUpload( + key, + uploadId, + parts, + minPartSize + ); + for (let blobId of oldBlobIds) + this.#backgroundDelete(blobId); + return new InternalR2Object(newRow); + } + async #abortMultipartUpload(key, uploadId) { + validate.key(key); + let oldBlobIds = this.#stmts.abortMultipartUpload(key, uploadId); + for (let blobId of oldBlobIds) + this.#backgroundDelete(blobId); + } + get = async (req) => { + let metadata = decodeHeaderMetadata(req), result; + if (metadata.method === "head") + result = await this.#head(metadata.object); + else if (metadata.method === "get") + result = await this.#get(metadata.object, metadata); + else if (metadata.method === "list") + result = await this.#list(metadata); + else + throw new InternalError(); + return encodeResult(result); + }; + put = async (req) => { + let { metadata, metadataSize, value } = await decodeMetadata(req); + if (metadata.method === "delete") + return await this.#delete( + "object" in metadata ? metadata.object : metadata.objects + ), new Response(); + if (metadata.method === "put") { + let contentLength = parseInt(req.headers.get("Content-Length")); + assert2(!isNaN(contentLength)); + let valueSize = contentLength - metadataSize, result = await this.#put( + metadata.object, + value, + valueSize, + metadata + ); + return encodeResult(result); + } else if (metadata.method === "createMultipartUpload") { + let result = await this.#createMultipartUpload( + metadata.object, + metadata + ); + return encodeJSONResult(result); + } else if (metadata.method === "uploadPart") { + let contentLength = parseInt(req.headers.get("Content-Length")); + assert2(!isNaN(contentLength)); + let valueSize = contentLength - metadataSize, result = await this.#uploadPart( + metadata.object, + metadata.uploadId, + metadata.partNumber, + value, + valueSize + ); + return encodeJSONResult(result); + } else if (metadata.method === "completeMultipartUpload") { + let result = await this.#completeMultipartUpload( + metadata.object, + metadata.uploadId, + metadata.parts + ); + return encodeResult(result); + } else { + if (metadata.method === "abortMultipartUpload") + return await this.#abortMultipartUpload(metadata.object, metadata.uploadId), new Response(); + throw new InternalError(); + } + }; +}; +__decorateClass([ + GET("/") +], R2BucketObject.prototype, "get", 2), __decorateClass([ + PUT("/") +], R2BucketObject.prototype, "put", 2); +export { + R2BucketObject +}; +//# sourceMappingURL=bucket.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/r2/bucket.worker.js.map b/node_modules/miniflare/dist/src/workers/r2/bucket.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2a72b57e227760c656aab1ee8063121bed34c353 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/r2/bucket.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/r2/bucket.worker.ts", "../../../../src/workers/r2/constants.ts", "../../../../src/workers/r2/errors.worker.ts", "../../../../src/workers/r2/r2Object.worker.ts", "../../../../src/workers/r2/schemas.worker.ts", "../../../../src/workers/r2/validator.worker.ts"], + "mappings": ";;;;;;;;;AAAA,OAAOA,aAAY;AACnB,SAAS,UAAAC,eAAc;AACvB,SAAS,kBAAkB;AAC3B;AAAA,EAEC;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;;;ACpBA,IAAM,WAAW;AAAA,EACvB,eAAe;AAAA,EACf,cAAc;AAAA;AAAA,EAEd,gBAAgB;AAAA;AAAA,EAChB,mBAAmB;AAAA;AAAA,EACnB,yBAAyB;AAAA,EACzB,8BAA8B;AAC/B,GAEa,YAAY;AAAA,EACxB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AAChB;;;ACbA,SAAS,iBAAiB;AAI1B,IAAM,cAAc;AAAA,EACnB,gBAAgB;AAAA,EAChB,oBAAo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AA,IAC/B,WAAW,SAAS,WAAW,2BAA2B;AACzD,UAAM,SAAS,MAAM,KAAK;AAAA,QACzB,SAAS;AAAA,QACT,SAAS;AAAA,QACT,SAAS;AAAA,MACV;AACA,aAAO,aAAa,MAAM;AAAA,IAC3B,OAAO;AAAA,UAAI,SAAS,WAAW;AAC9B,qBAAM,KAAK,sBAAsB,SAAS,QAAQ,SAAS,QAAQ,GAC5D,IAAI,SAAS;AAEpB,YAAM,IAAI,cAAc;AAAA;AAAA,EAE1B;AACD;AA7EC;AAAA,EADC,IAAI,GAAG;AAAA,GAvaI,eAwaZ,sBAkBA;AAAA,EADC,IAAI,GAAG;AAAA,GAzbI,eA0bZ;", + "names": ["assert", "Buffer", "identity", "Buffer", "ifMatch", "ifModifiedSince", "Buffer", "Buffer", "assert", "partRows", "identity", "blobId"] +} diff --git a/node_modules/miniflare/dist/src/workers/shared/index.worker.js b/node_modules/miniflare/dist/src/workers/shared/index.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..25ba28110b05e675cea7d9360f9c1b1a20413861 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/shared/index.worker.js @@ -0,0 +1,702 @@ +// src/workers/shared/blob.worker.ts +import assert from "node-internal:internal_assert"; +import { Buffer as Buffer2 } from "node-internal:internal_buffer"; + +// src/workers/shared/data.ts +import { Buffer } from "node-internal:internal_buffer"; +function viewToBuffer(view) { + return view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength); +} +function base64Encode(value) { + return Buffer.from(value, "utf8").toString("base64"); +} +function base64Decode(encoded) { + return Buffer.from(encoded, "base64").toString("utf8"); +} +var dotRegexp = /(^|\/|\\)(\.+)(\/|\\|$)/g, illegalRegexp = /[?<>*"'^/\\:|\x00-\x1f\x80-\x9f]/g, windowsReservedRegexp = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i, leadingRegexp = /^[ /\\]+/, trailingRegexp = /[ /\\]+$/; +function dotReplacement(match, g1, g2, g3) { + return `${g1}${"".padStart(g2.length, "_")}${g3}`; +} +function underscoreReplacement(match) { + return "".padStart(match.length, "_"); +} +function sanitisePath(unsafe) { + return unsafe.replace(dotRegexp, dotReplacement).replace(dotRegexp, dotReplacement).replace(illegalRegexp, "_").replace(windowsReservedRegexp, "_").replace(leadingRegexp, underscoreReplacement).replace(trailingRegexp, underscoreReplacement).substring(0, 255); +} + +// src/workers/shared/blob.worker.ts +var ENCODER = new TextEncoder(); +async function readPrefix(stream, prefixLength) { + let reader = await stream.getReader({ mode: "byob" }), result = await reader.readAtLeast( + prefixLength, + new Uint8Array(prefixLength) + ); + assert(result.value !== void 0), reader.releaseLock(); + let rest = stream.pipeThrough(new IdentityTransformStream()); + return [result.value, rest]; +} +function rangeHeaders(range) { + return { Range: `bytes=${range.start}-${range.end}` }; +} +function assertFullRangeRequest(range, contentLength) { + assert( + range.start === 0 && range.end === contentLength - 1, + "Received full content, but requested partial content" + ); +} +async function fetchSingleRange(fetcher, url, range) { + let headers = range === void 0 ? {} : rangeHeaders(range), res = await fetcher.fetch(url, { headers }); + if (res.status === 404) + return null; + if (assert(res.ok && res.body !== null), range !== void 0 && res.status !== 206) { + let contentLength = parseInt(res.headers.get("Content-Length")); + assert(!Number.isNaN(contentLength)), assertFullRangeRequest(range, contentLength); + } + return res.body; +} +async function writeMultipleRanges(fetcher, url, ranges, boundary, writable, contentLength, contentType) { + for (let i = 0; i < ranges.length; i++) { + let range = ranges[i], writer2 = writable.getWriter(); + i > 0 && await writer2.write(ENCODER.encode(`\r +`)), await writer2.write(ENCODER.encode(`--${boundary}\r +`)), contentType !== void 0 && await writer2.write(ENCODER.encode(`Content-Type: ${contentType}\r +`)); + let start = range.start, end = Math.min(range.end, contentLength - 1); + await writer2.write( + ENCODER.encode( + `Content-Range: bytes ${start}-${end}/${contentLength}\r +\r +` + ) + ), writer2.releaseLock(); + let res = await fetcher.fetch(url, { headers: rangeHeaders(range) }); + assert( + res.ok && res.body !== null, + `Failed to fetch ${url}[${range.start},${range.end}], received ${res.status} ${res.statusText}` + ), res.status !== 206 && assertFullRangeRequest(range, contentLength), await res.body.pipeTo(writable, { preventClose: !0 }); + } + let writer = writable.getWriter(); + ranges.length > 0 && await writer.write(ENCODER.encode(`\r +`)), await writer.write(ENCODER.encode(`--${boundary}--`)), await writer.close(); +} +async function fetchMultipleRanges(fetcher, url, ranges, opts) { + let res = await fetcher.fetch(url, { method: "HEAD" }); + if (res.status === 404) + return null; + assert(res.ok); + let contentLength = parseInt(res.headers.get("Content-Length")); + assert(!Number.isNaN(contentLength)); + let boundary = `miniflare-boundary-${crypto.randomUUID()}`, multipartContentType = `multipart/byteranges; boundary=${boundary}`, { readable, writable } = new IdentityTransformStream(); + return writeMultipleRanges( + fetcher, + url, + ranges, + boundary, + writable, + contentLength, + opts?.contentType + ).catch((e) => console.error("Error writing multipart stream:", e)), { multipartContentType, body: readable }; +} +async function fetchRange(fetcher, url, range, opts) { + return Array.isArray(range) ? fetchMultipleRanges(fetcher, url, range, opts) : fetchSingleRange(fetcher, url, range); +} +function generateBlobId() { + let idBuffer = Buffer2.alloc(40); + return crypto.getRandomValues( + new Uint8Array(idBuffer.buffer, idBuffer.byteOffset, 32) + ), idBuffer.writeBigInt64BE( + BigInt(performance.timeOrigin + performance.now()), + 32 + ), idBuffer.toString("hex"); +} +var BlobStore = class { + // Database for binary large objects. Provides single and multi-ranged + // streaming reads and writes. + // + // Blobs have unguessable identifiers, can be deleted, but are otherwise + // immutable. These properties make it possible to perform atomic updates with + // the SQLite metadata store. No other operations will be able to interact + // with the blob until it's committed to the metadata store, because they + // won't be able to guess the ID, and we don't allow listing blobs. + // + // For example, if we put a blob in the store, then fail to insert the blob ID + // into the SQLite database for some reason during a transaction (e.g. + // `onlyIf` condition failed), no other operations can read that blob because + // the ID is lost (we'll just background-delete the blob in this case). + #fetcher; + #baseURL; + constructor(fetcher, namespace) { + namespace = encodeURIComponent(sanitisePath(namespace)), this.#fetcher = fetcher, this.#baseURL = `http://placeholder/${namespace}/blobs/`; + } + idURL(id) { + let url = new URL(this.#baseURL + id); + return url.toString().startsWith(this.#baseURL) ? url : null; + } + async get(id, range, opts) { + let idURL = this.idURL(id); + return idURL === null ? null : fetchRange(this.#fetcher, idURL, range, opts); + } + async put(stream) { + let id = generateBlobId(), idURL = this.idURL(id); + return assert(idURL !== null), await this.#fetcher.fetch(idURL, { + method: "PUT", + body: stream + }), id; + } + async delete(id) { + let idURL = this.idURL(id); + if (idURL === null) + return; + let res = await this.#fetcher.fetch(idURL, { method: "DELETE" }); + assert(res.ok || res.status === 404); + } +}; + +// src/workers/shared/constants.ts +var SharedHeaders = { + LOG_LEVEL: "MF-Log-Level" +}, SharedBindings = { + TEXT_NAMESPACE: "MINIFLARE_NAMESPACE", + DURABLE_OBJECT_NAMESPACE_OBJECT: "MINIFLARE_OBJECT", + MAYBE_SERVICE_BLOBS: "MINIFLARE_BLOBS", + MAYBE_SERVICE_LOOPBACK: "MINIFLARE_LOOPBACK", + MAYBE_JSON_ENABLE_CONTROL_ENDPOINTS: "MINIFLARE_ENABLE_CONTROL_ENDPOINTS" +}, LogLevel = /* @__PURE__ */ ((LogLevel3) => (LogLevel3[LogLevel3.NONE = 0] = "NONE", LogLevel3[LogLevel3.ERROR = 1] = "ERROR", LogLevel3[LogLevel3.WARN = 2] = "WARN", LogLevel3[LogLevel3.INFO = 3] = "INFO", LogLevel3[LogLevel3.DEBUG = 4] = "DEBUG", LogLevel3[LogLevel3.VERBOSE = 5] = "VERBOSE", LogLevel3))(LogLevel || {}); + +// src/workers/shared/keyvalue.worker.ts +import assert3 from "node-internal:internal_assert"; + +// src/workers/shared/sql.worker.ts +import assert2 from "node-internal:internal_assert"; +function isTypedValue(value) { + return value === null || typeof value == "string" || typeof value == "number" || value instanceof ArrayBuffer; +} +function createStatementFactory(sql) { + return (query) => { + let keyIndices = /* @__PURE__ */ new Map(); + query = query.replace(/[:@$]([a-z0-9_]+)/gi, (_, name) => { + let index = keyIndices.get(name); + return index === void 0 && (index = keyIndices.size, keyIndices.set(name, index)), `?${index + 1}`; + }); + let stmt = sql.prepare(query); + return (argsObject) => { + let entries = Object.entries(argsObject); + assert2.strictEqual( + entries.length, + keyIndices.size, + "Expected same number of keys in bindings and query" + ); + let argsArray = new Array(entries.length); + for (let [key, value] of entries) { + let index = keyIndices.get(key); + assert2(index !== void 0, `Unexpected binding key: ${key}`), argsArray[index] = value; + } + return stmt(...argsArray); + }; + }; +} +function createTransactionFactory(storage) { + return (closure) => (...args) => storage.transactionSync(() => closure(...args)); +} +function createTypedSql(storage) { + let sql = storage.sql; + return sql.stmt = createStatementFactory(sql), sql.txn = createTransactionFactory(storage), sql; +} +function get(cursor) { + let result; + for (let row of cursor) + result ??= row; + return result; +} +function all(cursor) { + return Array.from(cursor); +} +function drain(cursor) { + for (let _ of cursor) + ; +} + +// src/workers/shared/keyvalue.worker.ts +var SQL_SCHEMA = ` +CREATE TABLE IF NOT EXISTS _mf_entries ( + key TEXT PRIMARY KEY, + blob_id TEXT NOT NULL, + expiration INTEGER, + metadata TEXT +); +CREATE INDEX IF NOT EXISTS _mf_entries_expiration_idx ON _mf_entries(expiration); +`; +function sqlStmts(db) { + let stmtGetBlobIdByKey = db.stmt( + "SELECT blob_id FROM _mf_entries WHERE :key" + ), stmtPut = db.stmt( + `INSERT OR REPLACE INTO _mf_entries (key, blob_id, expiration, metadata) + VALUES (:key, :blob_id, :expiration, :metadata)` + ); + return { + getByKey: db.prepare( + "SELECT key, blob_id, expiration, metadata FROM _mf_entries WHERE key = ?1" + ), + put: db.txn((newEntry) => { + let key = newEntry.key, previousEntry = get(stmtGetBlobIdByKey({ key })); + return stmtPut(newEntry), previousEntry?.blob_id; + }), + deleteByKey: db.stmt( + "DELETE FROM _mf_entries WHERE key = :key RETURNING blob_id, expiration" + ), + deleteExpired: db.stmt( + // `expiration` may be `NULL`, but `NULL < ...` should be falsy + "DELETE FROM _mf_entries WHERE expiration < :now RETURNING blob_id" + ), + list: db.stmt( + `SELECT key, expiration, metadata FROM _mf_entries + WHERE substr(key, 1, length(:prefix)) = :prefix + AND key > :start_after + AND (expiration IS NULL OR expiration >= :now) + ORDER BY key LIMIT :limit` + ) + }; +} +function rowEntry(entry) { + return { + key: entry.key, + expiration: entry.expiration ?? void 0, + metadata: entry.metadata === null ? void 0 : JSON.parse(entry.metadata) + }; +} +var KeyValueStorage = class { + #stmts; + #blob; + #timers; + constructor(object) { + object.db.exec("PRAGMA case_sensitive_like = TRUE"), object.db.exec(SQL_SCHEMA), this.#stmts = sqlStmts(object.db), this.#blob = object.blob, this.#timers = object.timers; + } + #hasExpired(entry) { + return entry.expiration !== null && entry.expiration <= this.#timers.now(); + } + #backgroundDelete(blobId) { + this.#timers.queueMicrotask( + () => this.#blob.delete(blobId).catch(() => { + }) + ); + } + async get(key, optsFactory) { + let row = get(this.#stmts.getByKey(key)); + if (row === void 0) + return null; + if (this.#hasExpired(row)) + return drain(this.#stmts.deleteByKey({ key })), this.#backgroundDelete(row.blob_id), null; + let entry = rowEntry(row), opts = entry.metadata && optsFactory?.(entry.metadata); + if (opts?.ranges === void 0 || opts.ranges.length <= 1) { + let value = await this.#blob.get(row.blob_id, opts?.ranges?.[0]); + return value === null ? null : { ...entry, value }; + } else { + let value = await this.#blob.get(row.blob_id, opts.ranges, opts); + return value === null ? null : { ...entry, value }; + } + } + async put(entry) { + assert3(entry.key !== ""); + let blobId = await this.#blob.put(entry.value); + entry.signal?.aborted && (this.#backgroundDelete(blobId), entry.signal.throwIfAborted()); + let maybeOldBlobId = this.#stmts.put({ + key: entry.key, + blob_id: blobId, + expiration: entry.expiration ?? null, + metadata: entry.metadata === void 0 ? null : JSON.stringify(await entry.metadata) + }); + maybeOldBlobId !== void 0 && this.#backgroundDelete(maybeOldBlobId); + } + async delete(key) { + let cursor = this.#stmts.deleteByKey({ key }), row = get(cursor); + return row === void 0 ? !1 : (this.#backgroundDelete(row.blob_id), !this.#hasExpired(row)); + } + async list(opts) { + let now = this.#timers.now(), prefix = opts.prefix ?? "", start_after = opts.cursor === void 0 ? "" : base64Decode(opts.cursor), limit = opts.limit + 1, rowsCursor = this.#stmts.list({ + now, + prefix, + start_after, + limit + }), rows = Array.from(rowsCursor), expiredRows = this.#stmts.deleteExpired({ now }); + for (let row of expiredRows) + this.#backgroundDelete(row.blob_id); + let hasMoreRows = rows.length === opts.limit + 1; + rows.splice(opts.limit, 1); + let keys = rows.map((row) => rowEntry(row)), nextCursor = hasMoreRows ? base64Encode(rows[opts.limit - 1].key) : void 0; + return { keys, cursor: nextCursor }; + } +}; + +// src/workers/shared/matcher.ts +function testRegExps(matcher, value) { + for (let exclude of matcher.exclude) + if (exclude.test(value)) + return !1; + for (let include of matcher.include) + if (include.test(value)) + return !0; + return !1; +} + +// src/workers/shared/object.worker.ts +import assert5 from "node-internal:internal_assert"; + +// src/workers/shared/router.worker.ts +var HttpError = class extends Error { + constructor(code, message) { + super(message); + this.code = code; + Object.setPrototypeOf(this, new.target.prototype), this.name = `${new.target.name} [${code}]`; + } + toResponse() { + return new Response(this.message, { + status: this.code, + // Custom statusMessage is required for runtime error messages + statusText: this.message.substring(0, 512) + }); + } +}, kRoutesTemplate = Symbol("kRoutesTemplate"), Router = class { + // Routes added by @METHOD decorators + #routes; + constructor() { + this.#routes = new.target.prototype[kRoutesTemplate]; + } + async fetch(req) { + let url = new URL(req.url), methodRoutes = this.#routes?.get(req.method); + if (methodRoutes === void 0) + return new Response(null, { status: 405 }); + let handlers = this; + try { + for (let [path, key] of methodRoutes) { + let match = path.exec(url.pathname); + if (match !== null) + return await handlers[key](req, match.groups, url); + } + return new Response(null, { status: 404 }); + } catch (e) { + if (e instanceof HttpError) + return e.toResponse(); + throw e; + } + } +}; +function pathToRegexp(path) { + return path === void 0 ? /^.*$/ : (path.endsWith("/") || (path += "/?"), path = path.replace(/\//g, "\\/"), path = path.replace(/:(\w+)/g, "(?<$1>[^\\/]+)"), new RegExp(`^${path}$`)); +} +var createRouteDecorator = (method) => (path) => (prototype, key) => { + let route = [pathToRegexp(path), key], routes = prototype[kRoutesTemplate] ??= /* @__PURE__ */ new Map(), methodRoutes = routes.get(method); + methodRoutes ? methodRoutes.push(route) : routes.set(method, [route]); +}, GET = createRouteDecorator("GET"), HEAD = createRouteDecorator("HEAD"), POST = createRouteDecorator("POST"), PUT = createRouteDecorator("PUT"), DELETE = createRouteDecorator("DELETE"), PURGE = createRouteDecorator("PURGE"), PATCH = createRouteDecorator("PATCH"); + +// src/workers/shared/timers.worker.ts +import assert4 from "node-internal:internal_assert"; +var kFakeTimerHandle = Symbol("kFakeTimerHandle"), Timers = class { + // Fake unix time in milliseconds. If defined, fake timers will be enabled. + #fakeTimestamp; + #fakeNextTimerHandle = 0; + #fakePendingTimeouts = /* @__PURE__ */ new Map(); + #fakeRunningTasks = /* @__PURE__ */ new Set(); + // Timers API + now = () => this.#fakeTimestamp ?? Date.now(); + setTimeout(closure, delay, ...args) { + if (this.#fakeTimestamp === void 0) + return setTimeout(closure, delay, ...args); + let handle = this.#fakeNextTimerHandle++, argsClosure = () => closure(...args); + if (delay === 0) + this.queueMicrotask(argsClosure); + else { + let timeout = { + triggerTimestamp: this.#fakeTimestamp + delay, + closure: argsClosure + }; + this.#fakePendingTimeouts.set(handle, timeout); + } + return { [kFakeTimerHandle]: handle }; + } + clearTimeout(handle) { + if (typeof handle == "number") + return clearTimeout(handle); + this.#fakePendingTimeouts.delete(handle[kFakeTimerHandle]); + } + queueMicrotask(closure) { + if (this.#fakeTimestamp === void 0) + return queueMicrotask(closure); + let result = closure(); + result instanceof Promise && (this.#fakeRunningTasks.add(result), result.finally(() => this.#fakeRunningTasks.delete(result))); + } + // Fake Timers Control API + #runPendingTimeouts() { + if (this.#fakeTimestamp !== void 0) + for (let [handle, timeout] of this.#fakePendingTimeouts) + timeout.triggerTimestamp <= this.#fakeTimestamp && (this.#fakePendingTimeouts.delete(handle), this.queueMicrotask(timeout.closure)); + } + enableFakeTimers(timestamp) { + this.#fakeTimestamp = timestamp, this.#runPendingTimeouts(); + } + disableFakeTimers() { + this.#fakeTimestamp = void 0, this.#fakePendingTimeouts.clear(); + } + advanceFakeTime(delta) { + assert4( + this.#fakeTimestamp !== void 0, + "Expected fake timers to be enabled before `advanceFakeTime()` call" + ), this.#fakeTimestamp += delta, this.#runPendingTimeouts(); + } + async waitForFakeTasks() { + for (; this.#fakeRunningTasks.size > 0; ) + await Promise.all(this.#fakeRunningTasks); + } +}; + +// src/workers/shared/types.ts +function reduceError(e) { + return { + name: e?.name, + message: e?.message ?? String(e), + stack: e?.stack, + cause: e?.cause === void 0 ? void 0 : reduceError(e.cause) + }; +} +function maybeApply(f, maybeValue) { + return maybeValue === void 0 ? void 0 : f(maybeValue); +} + +// src/workers/shared/object.worker.ts +var MiniflareDurableObject = class extends Router { + constructor(state, env) { + super(); + this.state = state; + this.env = env; + } + timers = new Timers(); + // If this Durable Object receives a control op, assume it's being tested. + // We use this to adjust some limits in tests. + beingTested = !1; + #db; + get db() { + return this.#db ??= createTypedSql(this.state.storage); + } + #name; + get name() { + return assert5( + this.#name !== void 0, + "Expected `MiniflareDurableObject#fetch()` call before `name` access" + ), this.#name; + } + #blob; + get blob() { + if (this.#blob !== void 0) + return this.#blob; + let maybeBlobsService = this.env[SharedBindings.MAYBE_SERVICE_BLOBS]; + return assert5( + maybeBlobsService !== void 0, + `Expected ${SharedBindings.MAYBE_SERVICE_BLOBS} service binding` + ), this.#blob = new BlobStore(maybeBlobsService, this.name), this.#blob; + } + async logWithLevel(level, message) { + await this.env[SharedBindings.MAYBE_SERVICE_LOOPBACK]?.fetch( + "http://localhost/core/log", + { + method: "POST", + headers: { [SharedHeaders.LOG_LEVEL]: level.toString() }, + body: message + } + ); + } + async #handleControlOp({ + name, + args + }) { + if (this.beingTested = !0, name === "sqlQuery") { + assert5(args !== void 0); + let [query, ...params] = args; + assert5(typeof query == "string"), assert5(params.every(isTypedValue)); + let results = all(this.db.prepare(query)(...params)); + return Response.json(results); + } else if (name === "getBlob") { + assert5(args !== void 0); + let [id] = args; + assert5(typeof id == "string"); + let stream = await this.blob.get(id); + return new Response(stream, { status: stream === null ? 404 : 200 }); + } else { + let func = this.timers[name]; + assert5(typeof func == "function"); + let result = await func.apply(this.timers, args); + return Response.json(result ?? null); + } + } + async fetch(req) { + if (this.env[SharedBindings.MAYBE_JSON_ENABLE_CONTROL_ENDPOINTS] === !0) { + let controlOp = req?.cf?.miniflare?.controlOp; + if (controlOp !== void 0) + return this.#handleControlOp(controlOp); + } + let name = req.cf?.miniflare?.name; + assert5(name !== void 0, "Expected `cf.miniflare.name`"), this.#name = name; + try { + return await super.fetch(req); + } catch (e) { + let error = reduceError(e), fallback = error.stack ?? error.message, loopbackService = this.env[SharedBindings.MAYBE_SERVICE_LOOPBACK]; + return loopbackService !== void 0 ? loopbackService.fetch("http://localhost/core/error", { + method: "POST", + body: JSON.stringify(error) + }).catch(() => { + console.error(fallback); + }) : console.error(fallback), new Response(fallback, { status: 500 }); + } finally { + req.body !== null && !req.bodyUsed && await req.body.pipeTo(new WritableStream()); + } + } +}; + +// src/workers/shared/range.ts +var rangePrefixRegexp = /^ *bytes *=/i, rangeRegexp = /^ *(?\d+)? *- *(?\d+)? *$/; +function parseRanges(rangeHeader, length) { + let prefixMatch = rangePrefixRegexp.exec(rangeHeader); + if (prefixMatch === null) + return; + if (rangeHeader = rangeHeader.substring(prefixMatch[0].length), rangeHeader.trimStart() === "") + return []; + let ranges = rangeHeader.split(","), result = []; + for (let range of ranges) { + let match = rangeRegexp.exec(range); + if (match === null) + return; + let { start, end } = match.groups; + if (start !== void 0 && end !== void 0) { + let rangeStart = parseInt(start), rangeEnd = parseInt(end); + if (rangeStart > rangeEnd || rangeStart >= length) + return; + rangeEnd >= length && (rangeEnd = length - 1), result.push({ start: rangeStart, end: rangeEnd }); + } else if (start !== void 0 && end === void 0) { + let rangeStart = parseInt(start); + if (rangeStart >= length) + return; + result.push({ start: rangeStart, end: length - 1 }); + } else if (start === void 0 && end !== void 0) { + let suffix = parseInt(end); + if (suffix >= length) + return []; + if (suffix === 0) + continue; + result.push({ start: length - suffix, end: length - 1 }); + } else + return; + } + return result; +} + +// src/workers/shared/sync.ts +import assert6 from "node-internal:internal_assert"; +var DeferredPromise = class extends Promise { + resolve; + reject; + constructor(executor = () => { + }) { + let promiseResolve, promiseReject; + super((resolve, reject) => (promiseResolve = resolve, promiseReject = reject, executor(resolve, reject))), this.resolve = promiseResolve, this.reject = promiseReject; + } +}, Mutex = class { + locked = !1; + resolveQueue = []; + drainQueue = []; + lock() { + if (!this.locked) { + this.locked = !0; + return; + } + return new Promise((resolve) => this.resolveQueue.push(resolve)); + } + unlock() { + if (assert6(this.locked), this.resolveQueue.length > 0) + this.resolveQueue.shift()?.(); + else { + this.locked = !1; + let resolve; + for (; (resolve = this.drainQueue.shift()) !== void 0; ) + resolve(); + } + } + get hasWaiting() { + return this.resolveQueue.length > 0; + } + async runWith(closure) { + let acquireAwaitable = this.lock(); + acquireAwaitable instanceof Promise && await acquireAwaitable; + try { + let awaitable = closure(); + return awaitable instanceof Promise ? await awaitable : awaitable; + } finally { + this.unlock(); + } + } + async drained() { + if (!(this.resolveQueue.length === 0 && !this.locked)) + return new Promise((resolve) => this.drainQueue.push(resolve)); + } +}, WaitGroup = class { + counter = 0; + resolveQueue = []; + add() { + this.counter++; + } + done() { + if (assert6(this.counter > 0), this.counter--, this.counter === 0) { + let resolve; + for (; (resolve = this.resolveQueue.shift()) !== void 0; ) + resolve(); + } + } + wait() { + return this.counter === 0 ? Promise.resolve() : new Promise((resolve) => this.resolveQueue.push(resolve)); + } +}; +export { + BlobStore, + DELETE, + DeferredPromise, + GET, + HEAD, + HttpError, + KeyValueStorage, + LogLevel, + MiniflareDurableObject, + Mutex, + PATCH, + POST, + PURGE, + PUT, + Router, + SharedBindings, + SharedHeaders, + Timers, + WaitGroup, + all, + base64Decode, + base64Encode, + drain, + get, + maybeApply, + parseRanges, + readPrefix, + reduceError, + testRegExps, + viewToBuffer +}; +/*! Path sanitisation regexps adapted from node-sanitize-filename: + * https://github.com/parshap/node-sanitize-filename/blob/209c39b914c8eb48ee27bcbde64b2c7822fdf3de/index.js#L4-L37 + * + * Licensed under the ISC license: + * + * Copyright Parsha Pourkhomami + * + * 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. + */ +//# sourceMappingURL=index.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/shared/index.worker.js.map b/node_modules/miniflare/dist/src/workers/shared/index.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..389882c742fc17b84491ab1c942e5a545e1d18e2 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/shared/index.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/shared/blob.worker.ts", "../../../../src/workers/shared/data.ts", "../../../../src/workers/shared/constants.ts", "../../../../src/workers/shared/keyvalue.worker.ts", "../../../../src/workers/shared/sql.worker.ts", "../../../../src/workers/shared/matcher.ts", "../../../../src/workers/shared/object.worker.ts", "../../../../src/workers/shared/router.worker.ts", "../../../../src/workers/shared/timers.worker.ts", "../../../../src/workers/shared/types.ts", "../../../../src/workers/shared/range.ts", "../../../../src/workers/shared/sync.ts"], + "mappings": ";AAAA,OAAO,YAAY;AACnB,SAAS,UAAAA,eAAc;;;ACDvB,SAAS,cAAc;AAEhB,SAAS,aAA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AEA,OAAa;AAGZ,QAFAA,QAAO,KAAK,UAAU,CAAC,GACvB,KAAK,WACD,KAAK,YAAY,GAAG;AACvB,UAAI;AACJ,cAAQ,UAAU,KAAK,aAAa,MAAM,OAAO;AAAW,gBAAQ;AAAA,IACrE;AAAA,EACD;AAAA,EAEA,OAAsB;AACrB,WAAI,KAAK,YAAY,IAAU,QAAQ,QAAQ,IACxC,IAAI,QAAQ,CAAC,YAAY,KAAK,aAAa,KAAK,OAAO,CAAC;AAAA,EAChE;AACD;", + "names": ["Buffer", "writer", "Buffer", "LogLevel", "assert", "assert", "assert", "assert", "assert", "assert", "assert"] +} diff --git a/node_modules/miniflare/dist/src/workers/shared/object-entry.worker.js b/node_modules/miniflare/dist/src/workers/shared/object-entry.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..1bd18b7146a8e8c7040823d2e796062d26454255 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/shared/object-entry.worker.js @@ -0,0 +1,20 @@ +// src/workers/shared/constants.ts +var SharedBindings = { + TEXT_NAMESPACE: "MINIFLARE_NAMESPACE", + DURABLE_OBJECT_NAMESPACE_OBJECT: "MINIFLARE_OBJECT", + MAYBE_SERVICE_BLOBS: "MINIFLARE_BLOBS", + MAYBE_SERVICE_LOOPBACK: "MINIFLARE_LOOPBACK", + MAYBE_JSON_ENABLE_CONTROL_ENDPOINTS: "MINIFLARE_ENABLE_CONTROL_ENDPOINTS" +}; + +// src/workers/shared/object-entry.worker.ts +var object_entry_worker_default = { + async fetch(request, env) { + let name = env[SharedBindings.TEXT_NAMESPACE], objectNamespace = env[SharedBindings.DURABLE_OBJECT_NAMESPACE_OBJECT], id = objectNamespace.idFromName(name), stub = objectNamespace.get(id), cf = { miniflare: { name } }; + return await stub.fetch(request, { cf }); + } +}; +export { + object_entry_worker_default as default +}; +//# sourceMappingURL=object-entry.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/shared/object-entry.worker.js.map b/node_modules/miniflare/dist/src/workers/shared/object-entry.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ba02be88f6042c0a22a026c25b3339357942c427 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/shared/object-entry.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/shared/constants.ts", "../../../../src/workers/shared/object-entry.worker.ts"], + "mappings": ";AAIO,IAAM,iBAAiB;AAAA,EAC7B,gBAAgB;AAAA,EAChB,iCAAiC;AAAA,EACjC,qBAAqB;AAAA,EACrB,wBAAwB;AAAA,EACxB,qCAAqC;AACtC;;;ACFA,IAAO,8BAA8B;AAAA,EACpC,MAAM,MAAM,SAAS,KAAK;AACzB,QAAM,OAAO,IAAI,eAAe,cAAc,GACxC,kBAAkB,IAAI,eAAe,+BAA+B,GACpE,KAAK,gBAAgB,WAAW,IAAI,GACpC,OAAO,gBAAgB,IAAI,EAAE,GAC7B,KAA+B,EAAE,WAAW,EAAE,KAAK,EAAE;AAC3D,WAAO,MAAM,KAAK,MAAM,SAAS,EAAE,GAAkC,CAAC;AAAA,EACvE;AACD;", + "names": [] +} diff --git a/node_modules/miniflare/dist/src/workers/shared/zod.worker.js b/node_modules/miniflare/dist/src/workers/shared/zod.worker.js new file mode 100644 index 0000000000000000000000000000000000000000..5f78b6c5f00292dcd5379199b48255a7f73ca851 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/shared/zod.worker.js @@ -0,0 +1,2719 @@ +// src/workers/shared/zod.worker.ts +import { Buffer } from "node-internal:internal_buffer"; + +// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs +var util; +(function(util2) { + util2.assertEqual = (val) => val; + function assertIs(_arg) { + } + util2.assertIs = assertIs; + function assertNever(_x) { + throw new Error(); + } + util2.assertNever = assertNever, util2.arrayToEnum = (items) => { + let obj = {}; + for (let item of items) + obj[item] = item; + return obj; + }, util2.getValidEnumValues = (obj) => { + let validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] != "number"), filtered = {}; + for (let k of validKeys) + filtered[k] = obj[k]; + return util2.objectValues(filtered); + }, util2.objectValues = (obj) => util2.objectKeys(obj).map(function(e) { + return obj[e]; + }), util2.objectKeys = typeof Object.keys == "function" ? (obj) => Object.keys(obj) : (object) => { + let keys = []; + for (let key in object) + Object.prototype.hasOwnProperty.call(object, key) && keys.push(key); + return keys; + }, util2.find = (arr, checker) => { + for (let item of arr) + if (checker(item)) + return item; + }, util2.isInteger = typeof Number.isInteger == "function" ? (val) => Number.isInteger(val) : (val) => typeof val == "number" && isFinite(val) && Math.floor(val) === val; + function joinValues(array, separator = " | ") { + return array.map((val) => typeof val == "string" ? `'${val}'` : val).join(separator); + } + util2.joinValues = joinValues, util2.jsonStringifyReplacer = (_, value) => typeof value == "bigint" ? value.toString() : value; +})(util || (util = {})); +var objectUtil; +(function(objectUtil2) { + objectUtil2.mergeShapes = (first, second) => ({ + ...first, + ...second + // second overwrites first + }); +})(objectUtil || (objectUtil = {})); +var ZodParsedType = util.arrayToEnum([ + "string", + "nan", + "number", + "integer", + "float", + "boolean", + "date", + "bigint", + "symbol", + "function", + "undefined", + "null", + "array", + "object", + "unknown", + "promise", + "void", + "never", + "map", + "set" +]), getParsedType = (data) => { + switch (typeof data) { + case "undefined": + return ZodParsedType.undefined; + case "string": + return ZodParsedType.string; + case "number": + return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number; + case "boolean": + return ZodParsedType.boolean; + case "function": + return ZodParsedType.function; + case "bigint": + return ZodParsedType.bigint; + case "symbol": + return ZodParsedType.symbol; + case "object": + return Array.isArray(data) ? ZodParsedType.array : data === null ? ZodParsedType.null : data.then && typeof data.then == "function" && data.catch && typeof data.catch == "function" ? ZodParsedType.promise : typeof Map < "u" && data instanceof Map ? ZodParsedType.map : typeof Set < "u" && data instanceof Set ? ZodParsedType.set : typeof Date < "u" && data instanceof Date ? ZodParsedType.date : ZodParsedType.object; + default: + return ZodParsedType.unknown; + } +}, ZodIssueCode = util.arrayToEnum([ + "invalid_type", + "invalid_literal", + "custom", + "invalid_union", + "invalid_union_discriminator", + "invalid_enum_value", + "unrecognized_keys", + "invalid_arguments", + "invalid_return_type", + "invalid_date", + "invalid_string", + "too_small", + "too_big", + "invalid_intersection_types", + "not_multiple_of", + "not_finite" +]), quotelessJson = (obj) => JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:"), ZodError = class extends Error { + constructor(issues) { + super(), this.issues = [], this.addIssue = (sub) => { + this.issues = [...this.issues, sub]; + }, this.addIssues = (subs = []) => { + this.issues = [...this.issues, ...subs]; + }; + let actualProto = new.target.prototype; + Object.setPrototypeOf ? Object.setPrototypeOf(this, actualProto) : this.__proto__ = actualProto, this.name = "ZodError", this.issues = issues; + } + get errors() { + return this.issues; + } + format(_mapper) { + let mapper = _mapper || function(issue) { + return issue.message; + }, fieldErrors = { _errors: [] }, processError = (error) => { + for (let issue of error.issues) + if (issue.code === "invalid_union") + issue.unionErrors.map(processError); + else if (issue.code === "invalid_return_type") + processError(issue.returnTypeError); + else if (issue.code === "invalid_arguments") + processError(issue.argumentsError); + else if (issue.path.length === 0) + fieldErrors._errors.push(mapper(issue)); + else { + let curr = fieldErrors, i = 0; + for (; i < issue.path.length; ) { + let el = issue.path[i]; + i === issue.path.length - 1 ? (curr[el] = curr[el] || { _errors: [] }, curr[el]._errors.push(mapper(issue))) : curr[el] = curr[el] || { _errors: [] }, curr = curr[el], i++; + } + } + }; + return processError(this), fieldErrors; + } + toString() { + return this.message; + } + get message() { + return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2); + } + get isEmpty() { + return this.issues.length === 0; + } + flatten(mapper = (issue) => issue.message) { + let fieldErrors = {}, formErrors = []; + for (let sub of this.issues) + sub.path.length > 0 ? (fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [], fieldErrors[sub.path[0]].push(mapper(sub))) : formErrors.push(mapper(sub)); + return { formErrors, fieldErrors }; + } + get formErrors() { + return this.flatten(); + } +}; +ZodError.create = (issues) => new ZodError(issues); +var errorMap = (issue, _ctx) => { + let message; + switch (issue.code) { + case ZodIssueCode.invalid_type: + issue.received === ZodParsedType.undefined ? message = "Required" : message = `Expected ${issue.expected}, received ${issue.received}`; + break; + case ZodIssueCode.invalid_literal: + message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`; + break; + case ZodIssueCode.unrecognized_keys: + message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`; + break; + case ZodIssueCode.invalid_union: + message = "Invalid input"; + break; + case ZodIssueCode.invalid_union_discriminator: + message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`; + break; + case ZodIssueCode.invalid_enum_value: + message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`; + break; + case ZodIssueCode.invalid_arguments: + message = "Invalid function arguments"; + break; + case ZodIssueCode.invalid_return_type: + message = "Invalid function return type"; + break; + case ZodIssueCode.invalid_date: + message = "Invalid date"; + break; + case ZodIssueCode.invalid_string: + typeof issue.validation == "object" ? "includes" in issue.validation ? (message = `Invalid input: must include "${issue.validation.includes}"`, typeof issue.validation.position == "number" && (message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`)) : "startsWith" in issue.validation ? message = `Invalid input: must start with "${issue.validation.startsWith}"` : "endsWith" in issue.validation ? message = `Invalid input: must end with "${issue.validation.endsWith}"` : util.assertNever(issue.validation) : issue.validation !== "regex" ? message = `Invalid ${issue.validation}` : message = "Invalid"; + break; + case ZodIssueCode.too_small: + issue.type === "array" ? message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? "at least" : "more than"} ${issue.minimum} element(s)` : issue.type === "string" ? message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? "at least" : "over"} ${issue.minimum} character(s)` : issue.type === "number" ? message = `Number must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${issue.minimum}` : issue.type === "date" ? message = `Date must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(issue.minimum))}` : message = "Invalid input"; + break; + case ZodIssueCode.too_big: + issue.type === "array" ? message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? "at most" : "less than"} ${issue.maximum} element(s)` : issue.type === "string" ? message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? "at most" : "under"} ${issue.maximum} character(s)` : issue.type === "number" ? message = `Number must be ${issue.exact ? "exactly" : issue.inclusive ? "less than or equal to" : "less than"} ${issue.maximum}` : issue.type === "bigint" ? message = `BigInt must be ${issue.exact ? "exactly" : issue.inclusive ? "less than or equal to" : "less than"} ${issue.maximum}` : issue.type === "date" ? message = `Date must be ${issue.exact ? "exactly" : issue.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(issue.maximum))}` : message = "Invalid input"; + break; + case ZodIssueCode.custom: + message = "Invalid input"; + break; + case ZodIssueCode.invalid_intersection_types: + message = "Intersection results could not be merged"; + break; + case ZodIssueCode.not_multiple_of: + message = `Number must be a multiple of ${issue.multipleOf}`; + break; + case ZodIssueCode.not_finite: + message = "Number must be finite"; + break; + default: + message = _ctx.defaultError, util.assertNever(issue); + } + return { message }; +}, overrideErrorMap = errorMap; +function setErrorMap(map) { + overrideErrorMap = map; +} +function getErrorMap() { + return overrideErrorMap; +} +var makeIssue = (params) => { + let { data, path, errorMaps, issueData } = params, fullPath = [...path, ...issueData.path || []], fullIssue = { + ...issueData, + path: fullPath + }, errorMessage = "", maps = errorMaps.filter((m) => !!m).slice().reverse(); + for (let map of maps) + errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; + return { + ...issueData, + path: fullPath, + message: issueData.message || errorMessage + }; +}, EMPTY_PATH = []; +function addIssueToContext(ctx, issueData) { + let issue = makeIssue({ + issueData, + data: ctx.data, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + // then global default map + ].filter((x) => !!x) + }); + ctx.common.issues.push(issue); +} +var ParseStatus = class { + constructor() { + this.value = "valid"; + } + dirty() { + this.value === "valid" && (this.value = "dirty"); + } + abort() { + this.value !== "aborted" && (this.value = "aborted"); + } + static mergeArray(status, results) { + let arrayValue = []; + for (let s of results) { + if (s.status === "aborted") + return INVALID; + s.status === "dirty" && status.dirty(), arrayValue.push(s.value); + } + return { status: status.value, value: arrayValue }; + } + static async mergeObjectAsync(status, pairs) { + let syncPairs = []; + for (let pair of pairs) + syncPairs.push({ + key: await pair.key, + value: await pair.value + }); + return ParseStatus.mergeObjectSync(status, syncPairs); + } + static mergeObjectSync(status, pairs) { + let finalObject = {}; + for (let pair of pairs) { + let { key, value } = pair; + if (key.status === "aborted" || value.status === "aborted") + return INVALID; + key.status === "dirty" && status.dirty(), value.status === "dirty" && status.dirty(), key.value !== "__proto__" && (typeof value.value < "u" || pair.alwaysSet) && (finalObject[key.value] = value.value); + } + return { status: status.value, value: finalObject }; + } +}, INVALID = Object.freeze({ + status: "aborted" +}), DIRTY = (value) => ({ status: "dirty", value }), OK = (value) => ({ status: "valid", value }), isAborted = (x) => x.status === "aborted", isDirty = (x) => x.status === "dirty", isValid = (x) => x.status === "valid", isAsync = (x) => typeof Promise < "u" && x instanceof Promise, errorUtil; +(function(errorUtil2) { + errorUtil2.errToObj = (message) => typeof message == "string" ? { message } : message || {}, errorUtil2.toString = (message) => typeof message == "string" ? message : message?.message; +})(errorUtil || (errorUtil = {})); +var ParseInputLazyPath = class { + constructor(parent, value, path, key) { + this._cachedPath = [], this.parent = parent, this.data = value, this._path = path, this._key = key; + } + get path() { + return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath; + } +}, handleResult = (ctx, result) => { + if (isValid(result)) + return { success: !0, data: result.value }; + if (!ctx.common.issues.length) + throw new Error("Validation failed but no issues detected."); + return { + success: !1, + get error() { + if (this._error) + return this._error; + let error = new ZodError(ctx.common.issues); + return this._error = error, this._error; + } + }; +}; +function processCreateParams(params) { + if (!params) + return {}; + let { errorMap: errorMap2, invalid_type_error, required_error, description } = params; + if (errorMap2 && (invalid_type_error || required_error)) + throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); + return errorMap2 ? { errorMap: errorMap2, description } : { errorMap: (iss, ctx) => iss.code !== "invalid_type" ? { message: ctx.defaultError } : typeof ctx.data > "u" ? { message: required_error ?? ctx.defaultError } : { message: invalid_type_error ?? ctx.defaultError }, description }; +} +var ZodType = class { + constructor(def) { + this.spa = this.safeParseAsync, this._def = def, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this); + } + get description() { + return this._def.description; + } + _getType(input) { + return getParsedType(input.data); + } + _getOrReturnCtx(input, ctx) { + return ctx || { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + }; + } + _processInputParams(input) { + return { + status: new ParseStatus(), + ctx: { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + } + }; + } + _parseSync(input) { + let result = this._parse(input); + if (isAsync(result)) + throw new Error("Synchronous parse encountered promise."); + return result; + } + _parseAsync(input) { + let result = this._parse(input); + return Promise.resolve(result); + } + parse(data, params) { + let result = this.safeParse(data, params); + if (result.success) + return result.data; + throw result.error; + } + safeParse(data, params) { + var _a; + let ctx = { + common: { + issues: [], + async: (_a = params?.async) !== null && _a !== void 0 ? _a : !1, + contextualErrorMap: params?.errorMap + }, + path: params?.path || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }, result = this._parseSync({ data, path: ctx.path, parent: ctx }); + return handleResult(ctx, result); + } + async parseAsync(data, params) { + let result = await this.safeParseAsync(data, params); + if (result.success) + return result.data; + throw result.error; + } + async safeParseAsync(data, params) { + let ctx = { + common: { + issues: [], + contextualErrorMap: params?.errorMap, + async: !0 + }, + path: params?.path || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }, maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }), result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); + return handleResult(ctx, result); + } + refine(check, message) { + let getIssueProperties = (val) => typeof message == "string" || typeof message > "u" ? { message } : typeof message == "function" ? message(val) : message; + return this._refinement((val, ctx) => { + let result = check(val), setError = () => ctx.addIssue({ + code: ZodIssueCode.custom, + ...getIssueProperties(val) + }); + return typeof Promise < "u" && result instanceof Promise ? result.then((data) => data ? !0 : (setError(), !1)) : result ? !0 : (setError(), !1); + }); + } + refinement(check, refinementData) { + return this._refinement((val, ctx) => check(val) ? !0 : (ctx.addIssue(typeof refinementData == "function" ? refinementData(val, ctx) : refinementData), !1)); + } + _refinement(refinement) { + return new ZodEffects({ + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "refinement", refinement } + }); + } + superRefine(refinement) { + return this._refinement(refinement); + } + optional() { + return ZodOptional.create(this, this._def); + } + nullable() { + return ZodNullable.create(this, this._def); + } + nullish() { + return this.nullable().optional(); + } + array() { + return ZodArray.create(this, this._def); + } + promise() { + return ZodPromise.create(this, this._def); + } + or(option) { + return ZodUnion.create([this, option], this._def); + } + and(incoming) { + return ZodIntersection.create(this, incoming, this._def); + } + transform(transform) { + return new ZodEffects({ + ...processCreateParams(this._def), + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "transform", transform } + }); + } + default(def) { + let defaultValueFunc = typeof def == "function" ? def : () => def; + return new ZodDefault({ + ...processCreateParams(this._def), + innerType: this, + defaultValue: defaultValueFunc, + typeName: ZodFirstPartyTypeKind.ZodDefault + }); + } + brand() { + return new ZodBranded({ + typeName: ZodFirstPartyTypeKind.ZodBranded, + type: this, + ...processCreateParams(this._def) + }); + } + catch(def) { + let catchValueFunc = typeof def == "function" ? def : () => def; + return new ZodCatch({ + ...processCreateParams(this._def), + innerType: this, + catchValue: catchValueFunc, + typeName: ZodFirstPartyTypeKind.ZodCatch + }); + } + describe(description) { + let This = this.constructor; + return new This({ + ...this._def, + description + }); + } + pipe(target) { + return ZodPipeline.create(this, target); + } + readonly() { + return ZodReadonly.create(this); + } + isOptional() { + return this.safeParse(void 0).success; + } + isNullable() { + return this.safeParse(null).success; + } +}, cuidRegex = /^c[^\s-]{8,}$/i, cuid2Regex = /^[a-z][a-z0-9]*$/, ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/, uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u, ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/, ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, datetimeRegex = (args) => args.precision ? args.offset ? new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`) : new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`) : args.precision === 0 ? args.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$") : args.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"); +function isValidIP(ip, version) { + return !!((version === "v4" || !version) && ipv4Regex.test(ip) || (version === "v6" || !version) && ipv6Regex.test(ip)); +} +var ZodString = class extends ZodType { + constructor() { + super(...arguments), this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), { + validation, + code: ZodIssueCode.invalid_string, + ...errorUtil.errToObj(message) + }), this.nonempty = (message) => this.min(1, errorUtil.errToObj(message)), this.trim = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "trim" }] + }), this.toLowerCase = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toLowerCase" }] + }), this.toUpperCase = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toUpperCase" }] + }); + } + _parse(input) { + if (this._def.coerce && (input.data = String(input.data)), this._getType(input) !== ZodParsedType.string) { + let ctx2 = this._getOrReturnCtx(input); + return addIssueToContext( + ctx2, + { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.string, + received: ctx2.parsedType + } + // + ), INVALID; + } + let status = new ParseStatus(), ctx; + for (let check of this._def.checks) + if (check.kind === "min") + input.data.length < check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: !0, + exact: !1, + message: check.message + }), status.dirty()); + else if (check.kind === "max") + input.data.length > check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: !0, + exact: !1, + message: check.message + }), status.dirty()); + else if (check.kind === "length") { + let tooBig = input.data.length > check.value, tooSmall = input.data.length < check.value; + (tooBig || tooSmall) && (ctx = this._getOrReturnCtx(input, ctx), tooBig ? addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: !0, + exact: !0, + message: check.message + }) : tooSmall && addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: !0, + exact: !0, + message: check.message + }), status.dirty()); + } else if (check.kind === "email") + emailRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "email", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty()); + else if (check.kind === "emoji") + emojiRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "emoji", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty()); + else if (check.kind === "uuid") + uuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "uuid", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty()); + else if (check.kind === "cuid") + cuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "cuid", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty()); + else if (check.kind === "cuid2") + cuid2Regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "cuid2", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty()); + else if (check.kind === "ulid") + ulidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "ulid", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty()); + else if (check.kind === "url") + try { + new URL(input.data); + } catch { + ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "url", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty(); + } + else + check.kind === "regex" ? (check.regex.lastIndex = 0, check.regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "regex", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty())) : check.kind === "trim" ? input.data = input.data.trim() : check.kind === "includes" ? input.data.includes(check.value, check.position) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { includes: check.value, position: check.position }, + message: check.message + }), status.dirty()) : check.kind === "toLowerCase" ? input.data = input.data.toLowerCase() : check.kind === "toUpperCase" ? input.data = input.data.toUpperCase() : check.kind === "startsWith" ? input.data.startsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { startsWith: check.value }, + message: check.message + }), status.dirty()) : check.kind === "endsWith" ? input.data.endsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { endsWith: check.value }, + message: check.message + }), status.dirty()) : check.kind === "datetime" ? datetimeRegex(check).test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: "datetime", + message: check.message + }), status.dirty()) : check.kind === "ip" ? isValidIP(input.data, check.version) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + validation: "ip", + code: ZodIssueCode.invalid_string, + message: check.message + }), status.dirty()) : util.assertNever(check); + return { status: status.value, value: input.data }; + } + _addCheck(check) { + return new ZodString({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + email(message) { + return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) }); + } + url(message) { + return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) }); + } + emoji(message) { + return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) }); + } + uuid(message) { + return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) }); + } + cuid(message) { + return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) }); + } + cuid2(message) { + return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) }); + } + ulid(message) { + return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) }); + } + ip(options) { + return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); + } + datetime(options) { + var _a; + return typeof options == "string" ? this._addCheck({ + kind: "datetime", + precision: null, + offset: !1, + message: options + }) : this._addCheck({ + kind: "datetime", + precision: typeof options?.precision > "u" ? null : options?.precision, + offset: (_a = options?.offset) !== null && _a !== void 0 ? _a : !1, + ...errorUtil.errToObj(options?.message) + }); + } + regex(regex, message) { + return this._addCheck({ + kind: "regex", + regex, + ...errorUtil.errToObj(message) + }); + } + includes(value, options) { + return this._addCheck({ + kind: "includes", + value, + position: options?.position, + ...errorUtil.errToObj(options?.message) + }); + } + startsWith(value, message) { + return this._addCheck({ + kind: "startsWith", + value, + ...errorUtil.errToObj(message) + }); + } + endsWith(value, message) { + return this._addCheck({ + kind: "endsWith", + value, + ...errorUtil.errToObj(message) + }); + } + min(minLength, message) { + return this._addCheck({ + kind: "min", + value: minLength, + ...errorUtil.errToObj(message) + }); + } + max(maxLength, message) { + return this._addCheck({ + kind: "max", + value: maxLength, + ...errorUtil.errToObj(message) + }); + } + length(len, message) { + return this._addCheck({ + kind: "length", + value: len, + ...errorUtil.errToObj(message) + }); + } + get isDatetime() { + return !!this._def.checks.find((ch) => ch.kind === "datetime"); + } + get isEmail() { + return !!this._def.checks.find((ch) => ch.kind === "email"); + } + get isURL() { + return !!this._def.checks.find((ch) => ch.kind === "url"); + } + get isEmoji() { + return !!this._def.checks.find((ch) => ch.kind === "emoji"); + } + get isUUID() { + return !!this._def.checks.find((ch) => ch.kind === "uuid"); + } + get isCUID() { + return !!this._def.checks.find((ch) => ch.kind === "cuid"); + } + get isCUID2() { + return !!this._def.checks.find((ch) => ch.kind === "cuid2"); + } + get isULID() { + return !!this._def.checks.find((ch) => ch.kind === "ulid"); + } + get isIP() { + return !!this._def.checks.find((ch) => ch.kind === "ip"); + } + get minLength() { + let min = null; + for (let ch of this._def.checks) + ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value); + return min; + } + get maxLength() { + let max = null; + for (let ch of this._def.checks) + ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value); + return max; + } +}; +ZodString.create = (params) => { + var _a; + return new ZodString({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodString, + coerce: (_a = params?.coerce) !== null && _a !== void 0 ? _a : !1, + ...processCreateParams(params) + }); +}; +function floatSafeRemainder(val, step) { + let valDecCount = (val.toString().split(".")[1] || "").length, stepDecCount = (step.toString().split(".")[1] || "").length, decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount, valInt = parseInt(val.toFixed(decCount).replace(".", "")), stepInt = parseInt(step.toFixed(decCount).replace(".", "")); + return valInt % stepInt / Math.pow(10, decCount); +} +var ZodNumber = class extends ZodType { + constructor() { + super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf; + } + _parse(input) { + if (this._def.coerce && (input.data = Number(input.data)), this._getType(input) !== ZodParsedType.number) { + let ctx2 = this._getOrReturnCtx(input); + return addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.number, + received: ctx2.parsedType + }), INVALID; + } + let ctx, status = new ParseStatus(); + for (let check of this._def.checks) + check.kind === "int" ? util.isInteger(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: "integer", + received: "float", + message: check.message + }), status.dirty()) : check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "number", + inclusive: check.inclusive, + exact: !1, + message: check.message + }), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "number", + inclusive: check.inclusive, + exact: !1, + message: check.message + }), status.dirty()) : check.kind === "multipleOf" ? floatSafeRemainder(input.data, check.value) !== 0 && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }), status.dirty()) : check.kind === "finite" ? Number.isFinite(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.not_finite, + message: check.message + }), status.dirty()) : util.assertNever(check); + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, !0, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, !1, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, !0, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, !1, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodNumber({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodNumber({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + int(message) { + return this._addCheck({ + kind: "int", + message: errorUtil.toString(message) + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: !1, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: !1, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: !0, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: !0, + message: errorUtil.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + finite(message) { + return this._addCheck({ + kind: "finite", + message: errorUtil.toString(message) + }); + } + safe(message) { + return this._addCheck({ + kind: "min", + inclusive: !0, + value: Number.MIN_SAFE_INTEGER, + message: errorUtil.toString(message) + })._addCheck({ + kind: "max", + inclusive: !0, + value: Number.MAX_SAFE_INTEGER, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (let ch of this._def.checks) + ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value); + return min; + } + get maxValue() { + let max = null; + for (let ch of this._def.checks) + ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value); + return max; + } + get isInt() { + return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); + } + get isFinite() { + let max = null, min = null; + for (let ch of this._def.checks) { + if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") + return !0; + ch.kind === "min" ? (min === null || ch.value > min) && (min = ch.value) : ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value); + } + return Number.isFinite(min) && Number.isFinite(max); + } +}; +ZodNumber.create = (params) => new ZodNumber({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodNumber, + coerce: params?.coerce || !1, + ...processCreateParams(params) +}); +var ZodBigInt = class extends ZodType { + constructor() { + super(...arguments), this.min = this.gte, this.max = this.lte; + } + _parse(input) { + if (this._def.coerce && (input.data = BigInt(input.data)), this._getType(input) !== ZodParsedType.bigint) { + let ctx2 = this._getOrReturnCtx(input); + return addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.bigint, + received: ctx2.parsedType + }), INVALID; + } + let ctx, status = new ParseStatus(); + for (let check of this._def.checks) + check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + type: "bigint", + minimum: check.value, + inclusive: check.inclusive, + message: check.message + }), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + type: "bigint", + maximum: check.value, + inclusive: check.inclusive, + message: check.message + }), status.dirty()) : check.kind === "multipleOf" ? input.data % check.value !== BigInt(0) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }), status.dirty()) : util.assertNever(check); + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, !0, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, !1, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, !0, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, !1, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodBigInt({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodBigInt({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: !1, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: !1, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: !0, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: !0, + message: errorUtil.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (let ch of this._def.checks) + ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value); + return min; + } + get maxValue() { + let max = null; + for (let ch of this._def.checks) + ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value); + return max; + } +}; +ZodBigInt.create = (params) => { + var _a; + return new ZodBigInt({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodBigInt, + coerce: (_a = params?.coerce) !== null && _a !== void 0 ? _a : !1, + ...processCreateParams(params) + }); +}; +var ZodBoolean = class extends ZodType { + _parse(input) { + if (this._def.coerce && (input.data = Boolean(input.data)), this._getType(input) !== ZodParsedType.boolean) { + let ctx = this._getOrReturnCtx(input); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.boolean, + received: ctx.parsedType + }), INVALID; + } + return OK(input.data); + } +}; +ZodBoolean.create = (params) => new ZodBoolean({ + typeName: ZodFirstPartyTypeKind.ZodBoolean, + coerce: params?.coerce || !1, + ...processCreateParams(params) +}); +var ZodDate = class extends ZodType { + _parse(input) { + if (this._def.coerce && (input.data = new Date(input.data)), this._getType(input) !== ZodParsedType.date) { + let ctx2 = this._getOrReturnCtx(input); + return addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.date, + received: ctx2.parsedType + }), INVALID; + } + if (isNaN(input.data.getTime())) { + let ctx2 = this._getOrReturnCtx(input); + return addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_date + }), INVALID; + } + let status = new ParseStatus(), ctx; + for (let check of this._def.checks) + check.kind === "min" ? input.data.getTime() < check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + message: check.message, + inclusive: !0, + exact: !1, + minimum: check.value, + type: "date" + }), status.dirty()) : check.kind === "max" ? input.data.getTime() > check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + message: check.message, + inclusive: !0, + exact: !1, + maximum: check.value, + type: "date" + }), status.dirty()) : util.assertNever(check); + return { + status: status.value, + value: new Date(input.data.getTime()) + }; + } + _addCheck(check) { + return new ZodDate({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + min(minDate, message) { + return this._addCheck({ + kind: "min", + value: minDate.getTime(), + message: errorUtil.toString(message) + }); + } + max(maxDate, message) { + return this._addCheck({ + kind: "max", + value: maxDate.getTime(), + message: errorUtil.toString(message) + }); + } + get minDate() { + let min = null; + for (let ch of this._def.checks) + ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value); + return min != null ? new Date(min) : null; + } + get maxDate() { + let max = null; + for (let ch of this._def.checks) + ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value); + return max != null ? new Date(max) : null; + } +}; +ZodDate.create = (params) => new ZodDate({ + checks: [], + coerce: params?.coerce || !1, + typeName: ZodFirstPartyTypeKind.ZodDate, + ...processCreateParams(params) +}); +var ZodSymbol = class extends ZodType { + _parse(input) { + if (this._getType(input) !== ZodParsedType.symbol) { + let ctx = this._getOrReturnCtx(input); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.symbol, + received: ctx.parsedType + }), INVALID; + } + return OK(input.data); + } +}; +ZodSymbol.create = (params) => new ZodSymbol({ + typeName: ZodFirstPartyTypeKind.ZodSymbol, + ...processCreateParams(params) +}); +var ZodUndefined = class extends ZodType { + _parse(input) { + if (this._getType(input) !== ZodParsedType.undefined) { + let ctx = this._getOrReturnCtx(input); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.undefined, + received: ctx.parsedType + }), INVALID; + } + return OK(input.data); + } +}; +ZodUndefined.create = (params) => new ZodUndefined({ + typeName: ZodFirstPartyTypeKind.ZodUndefined, + ...processCreateParams(params) +}); +var ZodNull = class extends ZodType { + _parse(input) { + if (this._getType(input) !== ZodParsedType.null) { + let ctx = this._getOrReturnCtx(input); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.null, + received: ctx.parsedType + }), INVALID; + } + return OK(input.data); + } +}; +ZodNull.create = (params) => new ZodNull({ + typeName: ZodFirstPartyTypeKind.ZodNull, + ...processCreateParams(params) +}); +var ZodAny = class extends ZodType { + constructor() { + super(...arguments), this._any = !0; + } + _parse(input) { + return OK(input.data); + } +}; +ZodAny.create = (params) => new ZodAny({ + typeName: ZodFirstPartyTypeKind.ZodAny, + ...processCreateParams(params) +}); +var ZodUnknown = class extends ZodType { + constructor() { + super(...arguments), this._unknown = !0; + } + _parse(input) { + return OK(input.data); + } +}; +ZodUnknown.create = (params) => new ZodUnknown({ + typeName: ZodFirstPartyTypeKind.ZodUnknown, + ...processCreateParams(params) +}); +var ZodNever = class extends ZodType { + _parse(input) { + let ctx = this._getOrReturnCtx(input); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.never, + received: ctx.parsedType + }), INVALID; + } +}; +ZodNever.create = (params) => new ZodNever({ + typeName: ZodFirstPartyTypeKind.ZodNever, + ...processCreateParams(params) +}); +var ZodVoid = class extends ZodType { + _parse(input) { + if (this._getType(input) !== ZodParsedType.undefined) { + let ctx = this._getOrReturnCtx(input); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.void, + received: ctx.parsedType + }), INVALID; + } + return OK(input.data); + } +}; +ZodVoid.create = (params) => new ZodVoid({ + typeName: ZodFirstPartyTypeKind.ZodVoid, + ...processCreateParams(params) +}); +var ZodArray = class extends ZodType { + _parse(input) { + let { ctx, status } = this._processInputParams(input), def = this._def; + if (ctx.parsedType !== ZodParsedType.array) + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }), INVALID; + if (def.exactLength !== null) { + let tooBig = ctx.data.length > def.exactLength.value, tooSmall = ctx.data.length < def.exactLength.value; + (tooBig || tooSmall) && (addIssueToContext(ctx, { + code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, + minimum: tooSmall ? def.exactLength.value : void 0, + maximum: tooBig ? def.exactLength.value : void 0, + type: "array", + inclusive: !0, + exact: !0, + message: def.exactLength.message + }), status.dirty()); + } + if (def.minLength !== null && ctx.data.length < def.minLength.value && (addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minLength.value, + type: "array", + inclusive: !0, + exact: !1, + message: def.minLength.message + }), status.dirty()), def.maxLength !== null && ctx.data.length > def.maxLength.value && (addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxLength.value, + type: "array", + inclusive: !0, + exact: !1, + message: def.maxLength.message + }), status.dirty()), ctx.common.async) + return Promise.all([...ctx.data].map((item, i) => def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i)))).then((result2) => ParseStatus.mergeArray(status, result2)); + let result = [...ctx.data].map((item, i) => def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i))); + return ParseStatus.mergeArray(status, result); + } + get element() { + return this._def.type; + } + min(minLength, message) { + return new ZodArray({ + ...this._def, + minLength: { value: minLength, message: errorUtil.toString(message) } + }); + } + max(maxLength, message) { + return new ZodArray({ + ...this._def, + maxLength: { value: maxLength, message: errorUtil.toString(message) } + }); + } + length(len, message) { + return new ZodArray({ + ...this._def, + exactLength: { value: len, message: errorUtil.toString(message) } + }); + } + nonempty(message) { + return this.min(1, message); + } +}; +ZodArray.create = (schema, params) => new ZodArray({ + type: schema, + minLength: null, + maxLength: null, + exactLength: null, + typeName: ZodFirstPartyTypeKind.ZodArray, + ...processCreateParams(params) +}); +function deepPartialify(schema) { + if (schema instanceof ZodObject) { + let newShape = {}; + for (let key in schema.shape) { + let fieldSchema = schema.shape[key]; + newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); + } + return new ZodObject({ + ...schema._def, + shape: () => newShape + }); + } else + return schema instanceof ZodArray ? new ZodArray({ + ...schema._def, + type: deepPartialify(schema.element) + }) : schema instanceof ZodOptional ? ZodOptional.create(deepPartialify(schema.unwrap())) : schema instanceof ZodNullable ? ZodNullable.create(deepPartialify(schema.unwrap())) : schema instanceof ZodTuple ? ZodTuple.create(schema.items.map((item) => deepPartialify(item))) : schema; +} +var ZodObject = class extends ZodType { + constructor() { + super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend; + } + _getCached() { + if (this._cached !== null) + return this._cached; + let shape = this._def.shape(), keys = util.objectKeys(shape); + return this._cached = { shape, keys }; + } + _parse(input) { + if (this._getType(input) !== ZodParsedType.object) { + let ctx2 = this._getOrReturnCtx(input); + return addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx2.parsedType + }), INVALID; + } + let { status, ctx } = this._processInputParams(input), { shape, keys: shapeKeys } = this._getCached(), extraKeys = []; + if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) + for (let key in ctx.data) + shapeKeys.includes(key) || extraKeys.push(key); + let pairs = []; + for (let key of shapeKeys) { + let keyValidator = shape[key], value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), + alwaysSet: key in ctx.data + }); + } + if (this._def.catchall instanceof ZodNever) { + let unknownKeys = this._def.unknownKeys; + if (unknownKeys === "passthrough") + for (let key of extraKeys) + pairs.push({ + key: { status: "valid", value: key }, + value: { status: "valid", value: ctx.data[key] } + }); + else if (unknownKeys === "strict") + extraKeys.length > 0 && (addIssueToContext(ctx, { + code: ZodIssueCode.unrecognized_keys, + keys: extraKeys + }), status.dirty()); + else if (unknownKeys !== "strip") + throw new Error("Internal ZodObject error: invalid unknownKeys value."); + } else { + let catchall = this._def.catchall; + for (let key of extraKeys) { + let value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: catchall._parse( + new ParseInputLazyPath(ctx, value, ctx.path, key) + //, ctx.child(key), value, getParsedType(value) + ), + alwaysSet: key in ctx.data + }); + } + } + return ctx.common.async ? Promise.resolve().then(async () => { + let syncPairs = []; + for (let pair of pairs) { + let key = await pair.key; + syncPairs.push({ + key, + value: await pair.value, + alwaysSet: pair.alwaysSet + }); + } + return syncPairs; + }).then((syncPairs) => ParseStatus.mergeObjectSync(status, syncPairs)) : ParseStatus.mergeObjectSync(status, pairs); + } + get shape() { + return this._def.shape(); + } + strict(message) { + return errorUtil.errToObj, new ZodObject({ + ...this._def, + unknownKeys: "strict", + ...message !== void 0 ? { + errorMap: (issue, ctx) => { + var _a, _b, _c, _d; + let defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + return issue.code === "unrecognized_keys" ? { + message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError + } : { + message: defaultError + }; + } + } : {} + }); + } + strip() { + return new ZodObject({ + ...this._def, + unknownKeys: "strip" + }); + } + passthrough() { + return new ZodObject({ + ...this._def, + unknownKeys: "passthrough" + }); + } + // const AugmentFactory = + // (def: Def) => + // ( + // augmentation: Augmentation + // ): ZodObject< + // extendShape, Augmentation>, + // Def["unknownKeys"], + // Def["catchall"] + // > => { + // return new ZodObject({ + // ...def, + // shape: () => ({ + // ...def.shape(), + // ...augmentation, + // }), + // }) as any; + // }; + extend(augmentation) { + return new ZodObject({ + ...this._def, + shape: () => ({ + ...this._def.shape(), + ...augmentation + }) + }); + } + /** + * Prior to zod@1.0.12 there was a bug in the + * inferred type of merged objects. Please + * upgrade if you are experiencing issues. + */ + merge(merging) { + return new ZodObject({ + unknownKeys: merging._def.unknownKeys, + catchall: merging._def.catchall, + shape: () => ({ + ...this._def.shape(), + ...merging._def.shape() + }), + typeName: ZodFirstPartyTypeKind.ZodObject + }); + } + // merge< + // Incoming extends AnyZodObject, + // Augmentation extends Incoming["shape"], + // NewOutput extends { + // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation + // ? Augmentation[k]["_output"] + // : k extends keyof Output + // ? Output[k] + // : never; + // }, + // NewInput extends { + // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation + // ? Augmentation[k]["_input"] + // : k extends keyof Input + // ? Input[k] + // : never; + // } + // >( + // merging: Incoming + // ): ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"], + // NewOutput, + // NewInput + // > { + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + setKey(key, schema) { + return this.augment({ [key]: schema }); + } + // merge( + // merging: Incoming + // ): //ZodObject = (merging) => { + // ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"] + // > { + // // const mergedShape = objectUtil.mergeShapes( + // // this._def.shape(), + // // merging._def.shape() + // // ); + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + catchall(index) { + return new ZodObject({ + ...this._def, + catchall: index + }); + } + pick(mask) { + let shape = {}; + return util.objectKeys(mask).forEach((key) => { + mask[key] && this.shape[key] && (shape[key] = this.shape[key]); + }), new ZodObject({ + ...this._def, + shape: () => shape + }); + } + omit(mask) { + let shape = {}; + return util.objectKeys(this.shape).forEach((key) => { + mask[key] || (shape[key] = this.shape[key]); + }), new ZodObject({ + ...this._def, + shape: () => shape + }); + } + /** + * @deprecated + */ + deepPartial() { + return deepPartialify(this); + } + partial(mask) { + let newShape = {}; + return util.objectKeys(this.shape).forEach((key) => { + let fieldSchema = this.shape[key]; + mask && !mask[key] ? newShape[key] = fieldSchema : newShape[key] = fieldSchema.optional(); + }), new ZodObject({ + ...this._def, + shape: () => newShape + }); + } + required(mask) { + let newShape = {}; + return util.objectKeys(this.shape).forEach((key) => { + if (mask && !mask[key]) + newShape[key] = this.shape[key]; + else { + let newField = this.shape[key]; + for (; newField instanceof ZodOptional; ) + newField = newField._def.innerType; + newShape[key] = newField; + } + }), new ZodObject({ + ...this._def, + shape: () => newShape + }); + } + keyof() { + return createZodEnum(util.objectKeys(this.shape)); + } +}; +ZodObject.create = (shape, params) => new ZodObject({ + shape: () => shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) +}); +ZodObject.strictCreate = (shape, params) => new ZodObject({ + shape: () => shape, + unknownKeys: "strict", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) +}); +ZodObject.lazycreate = (shape, params) => new ZodObject({ + shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) +}); +var ZodUnion = class extends ZodType { + _parse(input) { + let { ctx } = this._processInputParams(input), options = this._def.options; + function handleResults(results) { + for (let result of results) + if (result.result.status === "valid") + return result.result; + for (let result of results) + if (result.result.status === "dirty") + return ctx.common.issues.push(...result.ctx.common.issues), result.result; + let unionErrors = results.map((result) => new ZodError(result.ctx.common.issues)); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }), INVALID; + } + if (ctx.common.async) + return Promise.all(options.map(async (option) => { + let childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + return { + result: await option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }), + ctx: childCtx + }; + })).then(handleResults); + { + let dirty, issues = []; + for (let option of options) { + let childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }, result = option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }); + if (result.status === "valid") + return result; + result.status === "dirty" && !dirty && (dirty = { result, ctx: childCtx }), childCtx.common.issues.length && issues.push(childCtx.common.issues); + } + if (dirty) + return ctx.common.issues.push(...dirty.ctx.common.issues), dirty.result; + let unionErrors = issues.map((issues2) => new ZodError(issues2)); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }), INVALID; + } + } + get options() { + return this._def.options; + } +}; +ZodUnion.create = (types, params) => new ZodUnion({ + options: types, + typeName: ZodFirstPartyTypeKind.ZodUnion, + ...processCreateParams(params) +}); +var getDiscriminator = (type) => type instanceof ZodLazy ? getDiscriminator(type.schema) : type instanceof ZodEffects ? getDiscriminator(type.innerType()) : type instanceof ZodLiteral ? [type.value] : type instanceof ZodEnum ? type.options : type instanceof ZodNativeEnum ? Object.keys(type.enum) : type instanceof ZodDefault ? getDiscriminator(type._def.innerType) : type instanceof ZodUndefined ? [void 0] : type instanceof ZodNull ? [null] : null, ZodDiscriminatedUnion = class extends ZodType { + _parse(input) { + let { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }), INVALID; + let discriminator = this.discriminator, discriminatorValue = ctx.data[discriminator], option = this.optionsMap.get(discriminatorValue); + return option ? ctx.common.async ? option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) : option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) : (addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union_discriminator, + options: Array.from(this.optionsMap.keys()), + path: [discriminator] + }), INVALID); + } + get discriminator() { + return this._def.discriminator; + } + get options() { + return this._def.options; + } + get optionsMap() { + return this._def.optionsMap; + } + /** + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must + * have a different value for each object in the union. + * @param discriminator the name of the discriminator property + * @param types an array of object schemas + * @param params + */ + static create(discriminator, options, params) { + let optionsMap = /* @__PURE__ */ new Map(); + for (let type of options) { + let discriminatorValues = getDiscriminator(type.shape[discriminator]); + if (!discriminatorValues) + throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); + for (let value of discriminatorValues) { + if (optionsMap.has(value)) + throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); + optionsMap.set(value, type); + } + } + return new ZodDiscriminatedUnion({ + typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, + discriminator, + options, + optionsMap, + ...processCreateParams(params) + }); + } +}; +function mergeValues(a, b) { + let aType = getParsedType(a), bType = getParsedType(b); + if (a === b) + return { valid: !0, data: a }; + if (aType === ZodParsedType.object && bType === ZodParsedType.object) { + let bKeys = util.objectKeys(b), sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1), newObj = { ...a, ...b }; + for (let key of sharedKeys) { + let sharedValue = mergeValues(a[key], b[key]); + if (!sharedValue.valid) + return { valid: !1 }; + newObj[key] = sharedValue.data; + } + return { valid: !0, data: newObj }; + } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { + if (a.length !== b.length) + return { valid: !1 }; + let newArray = []; + for (let index = 0; index < a.length; index++) { + let itemA = a[index], itemB = b[index], sharedValue = mergeValues(itemA, itemB); + if (!sharedValue.valid) + return { valid: !1 }; + newArray.push(sharedValue.data); + } + return { valid: !0, data: newArray }; + } else + return aType === ZodParsedType.date && bType === ZodParsedType.date && +a == +b ? { valid: !0, data: a } : { valid: !1 }; +} +var ZodIntersection = class extends ZodType { + _parse(input) { + let { status, ctx } = this._processInputParams(input), handleParsed = (parsedLeft, parsedRight) => { + if (isAborted(parsedLeft) || isAborted(parsedRight)) + return INVALID; + let merged = mergeValues(parsedLeft.value, parsedRight.value); + return merged.valid ? ((isDirty(parsedLeft) || isDirty(parsedRight)) && status.dirty(), { status: status.value, value: merged.data }) : (addIssueToContext(ctx, { + code: ZodIssueCode.invalid_intersection_types + }), INVALID); + }; + return ctx.common.async ? Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)) : handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); + } +}; +ZodIntersection.create = (left, right, params) => new ZodIntersection({ + left, + right, + typeName: ZodFirstPartyTypeKind.ZodIntersection, + ...processCreateParams(params) +}); +var ZodTuple = class extends ZodType { + _parse(input) { + let { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.array) + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }), INVALID; + if (ctx.data.length < this._def.items.length) + return addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: this._def.items.length, + inclusive: !0, + exact: !1, + type: "array" + }), INVALID; + !this._def.rest && ctx.data.length > this._def.items.length && (addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: this._def.items.length, + inclusive: !0, + exact: !1, + type: "array" + }), status.dirty()); + let items = [...ctx.data].map((item, itemIndex) => { + let schema = this._def.items[itemIndex] || this._def.rest; + return schema ? schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)) : null; + }).filter((x) => !!x); + return ctx.common.async ? Promise.all(items).then((results) => ParseStatus.mergeArray(status, results)) : ParseStatus.mergeArray(status, items); + } + get items() { + return this._def.items; + } + rest(rest) { + return new ZodTuple({ + ...this._def, + rest + }); + } +}; +ZodTuple.create = (schemas, params) => { + if (!Array.isArray(schemas)) + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + return new ZodTuple({ + items: schemas, + typeName: ZodFirstPartyTypeKind.ZodTuple, + rest: null, + ...processCreateParams(params) + }); +}; +var ZodRecord = class extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } + _parse(input) { + let { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }), INVALID; + let pairs = [], keyType = this._def.keyType, valueType = this._def.valueType; + for (let key in ctx.data) + pairs.push({ + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) + }); + return ctx.common.async ? ParseStatus.mergeObjectAsync(status, pairs) : ParseStatus.mergeObjectSync(status, pairs); + } + get element() { + return this._def.valueType; + } + static create(first, second, third) { + return second instanceof ZodType ? new ZodRecord({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(third) + }) : new ZodRecord({ + keyType: ZodString.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(second) + }); + } +}, ZodMap = class extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } + _parse(input) { + let { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.map) + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.map, + received: ctx.parsedType + }), INVALID; + let keyType = this._def.keyType, valueType = this._def.valueType, pairs = [...ctx.data.entries()].map(([key, value], index) => ({ + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])), + value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"])) + })); + if (ctx.common.async) { + let finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (let pair of pairs) { + let key = await pair.key, value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") + return INVALID; + (key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + let finalMap = /* @__PURE__ */ new Map(); + for (let pair of pairs) { + let key = pair.key, value = pair.value; + if (key.status === "aborted" || value.status === "aborted") + return INVALID; + (key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } + } +}; +ZodMap.create = (keyType, valueType, params) => new ZodMap({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind.ZodMap, + ...processCreateParams(params) +}); +var ZodSet = class extends ZodType { + _parse(input) { + let { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.set) + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.set, + received: ctx.parsedType + }), INVALID; + let def = this._def; + def.minSize !== null && ctx.data.size < def.minSize.value && (addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minSize.value, + type: "set", + inclusive: !0, + exact: !1, + message: def.minSize.message + }), status.dirty()), def.maxSize !== null && ctx.data.size > def.maxSize.value && (addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxSize.value, + type: "set", + inclusive: !0, + exact: !1, + message: def.maxSize.message + }), status.dirty()); + let valueType = this._def.valueType; + function finalizeSet(elements2) { + let parsedSet = /* @__PURE__ */ new Set(); + for (let element of elements2) { + if (element.status === "aborted") + return INVALID; + element.status === "dirty" && status.dirty(), parsedSet.add(element.value); + } + return { status: status.value, value: parsedSet }; + } + let elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i))); + return ctx.common.async ? Promise.all(elements).then((elements2) => finalizeSet(elements2)) : finalizeSet(elements); + } + min(minSize, message) { + return new ZodSet({ + ...this._def, + minSize: { value: minSize, message: errorUtil.toString(message) } + }); + } + max(maxSize, message) { + return new ZodSet({ + ...this._def, + maxSize: { value: maxSize, message: errorUtil.toString(message) } + }); + } + size(size, message) { + return this.min(size, message).max(size, message); + } + nonempty(message) { + return this.min(1, message); + } +}; +ZodSet.create = (valueType, params) => new ZodSet({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind.ZodSet, + ...processCreateParams(params) +}); +var ZodFunction = class extends ZodType { + constructor() { + super(...arguments), this.validate = this.implement; + } + _parse(input) { + let { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.function) + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.function, + received: ctx.parsedType + }), INVALID; + function makeArgsIssue(args, error) { + return makeIssue({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x) => !!x), + issueData: { + code: ZodIssueCode.invalid_arguments, + argumentsError: error + } + }); + } + function makeReturnsIssue(returns, error) { + return makeIssue({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x) => !!x), + issueData: { + code: ZodIssueCode.invalid_return_type, + returnTypeError: error + } + }); + } + let params = { errorMap: ctx.common.contextualErrorMap }, fn = ctx.data; + if (this._def.returns instanceof ZodPromise) { + let me = this; + return OK(async function(...args) { + let error = new ZodError([]), parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => { + throw error.addIssue(makeArgsIssue(args, e)), error; + }), result = await Reflect.apply(fn, this, parsedArgs); + return await me._def.returns._def.type.parseAsync(result, params).catch((e) => { + throw error.addIssue(makeReturnsIssue(result, e)), error; + }); + }); + } else { + let me = this; + return OK(function(...args) { + let parsedArgs = me._def.args.safeParse(args, params); + if (!parsedArgs.success) + throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); + let result = Reflect.apply(fn, this, parsedArgs.data), parsedReturns = me._def.returns.safeParse(result, params); + if (!parsedReturns.success) + throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); + return parsedReturns.data; + }); + } + } + parameters() { + return this._def.args; + } + returnType() { + return this._def.returns; + } + args(...items) { + return new ZodFunction({ + ...this._def, + args: ZodTuple.create(items).rest(ZodUnknown.create()) + }); + } + returns(returnType) { + return new ZodFunction({ + ...this._def, + returns: returnType + }); + } + implement(func) { + return this.parse(func); + } + strictImplement(func) { + return this.parse(func); + } + static create(args, returns, params) { + return new ZodFunction({ + args: args || ZodTuple.create([]).rest(ZodUnknown.create()), + returns: returns || ZodUnknown.create(), + typeName: ZodFirstPartyTypeKind.ZodFunction, + ...processCreateParams(params) + }); + } +}, ZodLazy = class extends ZodType { + get schema() { + return this._def.getter(); + } + _parse(input) { + let { ctx } = this._processInputParams(input); + return this._def.getter()._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + } +}; +ZodLazy.create = (getter, params) => new ZodLazy({ + getter, + typeName: ZodFirstPartyTypeKind.ZodLazy, + ...processCreateParams(params) +}); +var ZodLiteral = class extends ZodType { + _parse(input) { + if (input.data !== this._def.value) { + let ctx = this._getOrReturnCtx(input); + return addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_literal, + expected: this._def.value + }), INVALID; + } + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } +}; +ZodLiteral.create = (value, params) => new ZodLiteral({ + value, + typeName: ZodFirstPartyTypeKind.ZodLiteral, + ...processCreateParams(params) +}); +function createZodEnum(values, params) { + return new ZodEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodEnum, + ...processCreateParams(params) + }); +} +var ZodEnum = class extends ZodType { + _parse(input) { + if (typeof input.data != "string") { + let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values; + return addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }), INVALID; + } + if (this._def.values.indexOf(input.data) === -1) { + let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values; + return addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }), INVALID; + } + return OK(input.data); + } + get options() { + return this._def.values; + } + get enum() { + let enumValues = {}; + for (let val of this._def.values) + enumValues[val] = val; + return enumValues; + } + get Values() { + let enumValues = {}; + for (let val of this._def.values) + enumValues[val] = val; + return enumValues; + } + get Enum() { + let enumValues = {}; + for (let val of this._def.values) + enumValues[val] = val; + return enumValues; + } + extract(values) { + return ZodEnum.create(values); + } + exclude(values) { + return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + } +}; +ZodEnum.create = createZodEnum; +var ZodNativeEnum = class extends ZodType { + _parse(input) { + let nativeEnumValues = util.getValidEnumValues(this._def.values), ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { + let expectedValues = util.objectValues(nativeEnumValues); + return addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }), INVALID; + } + if (nativeEnumValues.indexOf(input.data) === -1) { + let expectedValues = util.objectValues(nativeEnumValues); + return addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }), INVALID; + } + return OK(input.data); + } + get enum() { + return this._def.values; + } +}; +ZodNativeEnum.create = (values, params) => new ZodNativeEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodNativeEnum, + ...processCreateParams(params) +}); +var ZodPromise = class extends ZodType { + unwrap() { + return this._def.type; + } + _parse(input) { + let { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === !1) + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.promise, + received: ctx.parsedType + }), INVALID; + let promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); + return OK(promisified.then((data) => this._def.type.parseAsync(data, { + path: ctx.path, + errorMap: ctx.common.contextualErrorMap + }))); + } +}; +ZodPromise.create = (schema, params) => new ZodPromise({ + type: schema, + typeName: ZodFirstPartyTypeKind.ZodPromise, + ...processCreateParams(params) +}); +var ZodEffects = class extends ZodType { + innerType() { + return this._def.schema; + } + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + } + _parse(input) { + let { status, ctx } = this._processInputParams(input), effect = this._def.effect || null, checkCtx = { + addIssue: (arg) => { + addIssueToContext(ctx, arg), arg.fatal ? status.abort() : status.dirty(); + }, + get path() { + return ctx.path; + } + }; + if (checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx), effect.type === "preprocess") { + let processed = effect.transform(ctx.data, checkCtx); + return ctx.common.issues.length ? { + status: "dirty", + value: ctx.data + } : ctx.common.async ? Promise.resolve(processed).then((processed2) => this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + })) : this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx + }); + } + if (effect.type === "refinement") { + let executeRefinement = (acc) => { + let result = effect.refinement(acc, checkCtx); + if (ctx.common.async) + return Promise.resolve(result); + if (result instanceof Promise) + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + return acc; + }; + if (ctx.common.async === !1) { + let inner = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + return inner.status === "aborted" ? INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value), { status: status.value, value: inner.value }); + } else + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => inner.status === "aborted" ? INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value).then(() => ({ status: status.value, value: inner.value })))); + } + if (effect.type === "transform") + if (ctx.common.async === !1) { + let base = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (!isValid(base)) + return base; + let result = effect.transform(base.value, checkCtx); + if (result instanceof Promise) + throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead."); + return { status: status.value, value: result }; + } else + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => isValid(base) ? Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result })) : base); + util.assertNever(effect); + } +}; +ZodEffects.create = (schema, effect, params) => new ZodEffects({ + schema, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect, + ...processCreateParams(params) +}); +ZodEffects.createWithPreprocess = (preprocess, schema, params) => new ZodEffects({ + schema, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind.ZodEffects, + ...processCreateParams(params) +}); +var ZodOptional = class extends ZodType { + _parse(input) { + return this._getType(input) === ZodParsedType.undefined ? OK(void 0) : this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } +}; +ZodOptional.create = (type, params) => new ZodOptional({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodOptional, + ...processCreateParams(params) +}); +var ZodNullable = class extends ZodType { + _parse(input) { + return this._getType(input) === ZodParsedType.null ? OK(null) : this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } +}; +ZodNullable.create = (type, params) => new ZodNullable({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodNullable, + ...processCreateParams(params) +}); +var ZodDefault = class extends ZodType { + _parse(input) { + let { ctx } = this._processInputParams(input), data = ctx.data; + return ctx.parsedType === ZodParsedType.undefined && (data = this._def.defaultValue()), this._def.innerType._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + removeDefault() { + return this._def.innerType; + } +}; +ZodDefault.create = (type, params) => new ZodDefault({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodDefault, + defaultValue: typeof params.default == "function" ? params.default : () => params.default, + ...processCreateParams(params) +}); +var ZodCatch = class extends ZodType { + _parse(input) { + let { ctx } = this._processInputParams(input), newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + } + }, result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx + } + }); + return isAsync(result) ? result.then((result2) => ({ + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + }, + input: newCtx.data + }) + })) : { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + }, + input: newCtx.data + }) + }; + } + removeCatch() { + return this._def.innerType; + } +}; +ZodCatch.create = (type, params) => new ZodCatch({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodCatch, + catchValue: typeof params.catch == "function" ? params.catch : () => params.catch, + ...processCreateParams(params) +}); +var ZodNaN = class extends ZodType { + _parse(input) { + if (this._getType(input) !== ZodParsedType.nan) { + let ctx = this._getOrReturnCtx(input); + return addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.nan, + received: ctx.parsedType + }), INVALID; + } + return { status: "valid", value: input.data }; + } +}; +ZodNaN.create = (params) => new ZodNaN({ + typeName: ZodFirstPartyTypeKind.ZodNaN, + ...processCreateParams(params) +}); +var BRAND = Symbol("zod_brand"), ZodBranded = class extends ZodType { + _parse(input) { + let { ctx } = this._processInputParams(input), data = ctx.data; + return this._def.type._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + unwrap() { + return this._def.type; + } +}, ZodPipeline = class extends ZodType { + _parse(input) { + let { status, ctx } = this._processInputParams(input); + if (ctx.common.async) + return (async () => { + let inResult = await this._def.in._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + return inResult.status === "aborted" ? INVALID : inResult.status === "dirty" ? (status.dirty(), DIRTY(inResult.value)) : this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + })(); + { + let inResult = this._def.in._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + return inResult.status === "aborted" ? INVALID : inResult.status === "dirty" ? (status.dirty(), { + status: "dirty", + value: inResult.value + }) : this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + } + static create(a, b) { + return new ZodPipeline({ + in: a, + out: b, + typeName: ZodFirstPartyTypeKind.ZodPipeline + }); + } +}, ZodReadonly = class extends ZodType { + _parse(input) { + let result = this._def.innerType._parse(input); + return isValid(result) && (result.value = Object.freeze(result.value)), result; + } +}; +ZodReadonly.create = (type, params) => new ZodReadonly({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodReadonly, + ...processCreateParams(params) +}); +var custom = (check, params = {}, fatal) => check ? ZodAny.create().superRefine((data, ctx) => { + var _a, _b; + if (!check(data)) { + let p = typeof params == "function" ? params(data) : typeof params == "string" ? { message: params } : params, _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : !0, p2 = typeof p == "string" ? { message: p } : p; + ctx.addIssue({ code: "custom", ...p2, fatal: _fatal }); + } +}) : ZodAny.create(), late = { + object: ZodObject.lazycreate +}, ZodFirstPartyTypeKind; +(function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2.ZodString = "ZodString", ZodFirstPartyTypeKind2.ZodNumber = "ZodNumber", ZodFirstPartyTypeKind2.ZodNaN = "ZodNaN", ZodFirstPartyTypeKind2.ZodBigInt = "ZodBigInt", ZodFirstPartyTypeKind2.ZodBoolean = "ZodBoolean", ZodFirstPartyTypeKind2.ZodDate = "ZodDate", ZodFirstPartyTypeKind2.ZodSymbol = "ZodSymbol", ZodFirstPartyTypeKind2.ZodUndefined = "ZodUndefined", ZodFirstPartyTypeKind2.ZodNull = "ZodNull", ZodFirstPartyTypeKind2.ZodAny = "ZodAny", ZodFirstPartyTypeKind2.ZodUnknown = "ZodUnknown", ZodFirstPartyTypeKind2.ZodNever = "ZodNever", ZodFirstPartyTypeKind2.ZodVoid = "ZodVoid", ZodFirstPartyTypeKind2.ZodArray = "ZodArray", ZodFirstPartyTypeKind2.ZodObject = "ZodObject", ZodFirstPartyTypeKind2.ZodUnion = "ZodUnion", ZodFirstPartyTypeKind2.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", ZodFirstPartyTypeKind2.ZodIntersection = "ZodIntersection", ZodFirstPartyTypeKind2.ZodTuple = "ZodTuple", ZodFirstPartyTypeKind2.ZodRecord = "ZodRecord", ZodFirstPartyTypeKind2.ZodMap = "ZodMap", ZodFirstPartyTypeKind2.ZodSet = "ZodSet", ZodFirstPartyTypeKind2.ZodFunction = "ZodFunction", ZodFirstPartyTypeKind2.ZodLazy = "ZodLazy", ZodFirstPartyTypeKind2.ZodLiteral = "ZodLiteral", ZodFirstPartyTypeKind2.ZodEnum = "ZodEnum", ZodFirstPartyTypeKind2.ZodEffects = "ZodEffects", ZodFirstPartyTypeKind2.ZodNativeEnum = "ZodNativeEnum", ZodFirstPartyTypeKind2.ZodOptional = "ZodOptional", ZodFirstPartyTypeKind2.ZodNullable = "ZodNullable", ZodFirstPartyTypeKind2.ZodDefault = "ZodDefault", ZodFirstPartyTypeKind2.ZodCatch = "ZodCatch", ZodFirstPartyTypeKind2.ZodPromise = "ZodPromise", ZodFirstPartyTypeKind2.ZodBranded = "ZodBranded", ZodFirstPartyTypeKind2.ZodPipeline = "ZodPipeline", ZodFirstPartyTypeKind2.ZodReadonly = "ZodReadonly"; +})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); +var instanceOfType = (cls, params = { + message: `Input not instance of ${cls.name}` +}) => custom((data) => data instanceof cls, params), stringType = ZodString.create, numberType = ZodNumber.create, nanType = ZodNaN.create, bigIntType = ZodBigInt.create, booleanType = ZodBoolean.create, dateType = ZodDate.create, symbolType = ZodSymbol.create, undefinedType = ZodUndefined.create, nullType = ZodNull.create, anyType = ZodAny.create, unknownType = ZodUnknown.create, neverType = ZodNever.create, voidType = ZodVoid.create, arrayType = ZodArray.create, objectType = ZodObject.create, strictObjectType = ZodObject.strictCreate, unionType = ZodUnion.create, discriminatedUnionType = ZodDiscriminatedUnion.create, intersectionType = ZodIntersection.create, tupleType = ZodTuple.create, recordType = ZodRecord.create, mapType = ZodMap.create, setType = ZodSet.create, functionType = ZodFunction.create, lazyType = ZodLazy.create, literalType = ZodLiteral.create, enumType = ZodEnum.create, nativeEnumType = ZodNativeEnum.create, promiseType = ZodPromise.create, effectsType = ZodEffects.create, optionalType = ZodOptional.create, nullableType = ZodNullable.create, preprocessType = ZodEffects.createWithPreprocess, pipelineType = ZodPipeline.create, ostring = () => stringType().optional(), onumber = () => numberType().optional(), oboolean = () => booleanType().optional(), coerce = { + string: (arg) => ZodString.create({ ...arg, coerce: !0 }), + number: (arg) => ZodNumber.create({ ...arg, coerce: !0 }), + boolean: (arg) => ZodBoolean.create({ + ...arg, + coerce: !0 + }), + bigint: (arg) => ZodBigInt.create({ ...arg, coerce: !0 }), + date: (arg) => ZodDate.create({ ...arg, coerce: !0 }) +}, NEVER = INVALID, z = /* @__PURE__ */ Object.freeze({ + __proto__: null, + defaultErrorMap: errorMap, + setErrorMap, + getErrorMap, + makeIssue, + EMPTY_PATH, + addIssueToContext, + ParseStatus, + INVALID, + DIRTY, + OK, + isAborted, + isDirty, + isValid, + isAsync, + get util() { + return util; + }, + get objectUtil() { + return objectUtil; + }, + ZodParsedType, + getParsedType, + ZodType, + ZodString, + ZodNumber, + ZodBigInt, + ZodBoolean, + ZodDate, + ZodSymbol, + ZodUndefined, + ZodNull, + ZodAny, + ZodUnknown, + ZodNever, + ZodVoid, + ZodArray, + ZodObject, + ZodUnion, + ZodDiscriminatedUnion, + ZodIntersection, + ZodTuple, + ZodRecord, + ZodMap, + ZodSet, + ZodFunction, + ZodLazy, + ZodLiteral, + ZodEnum, + ZodNativeEnum, + ZodPromise, + ZodEffects, + ZodTransformer: ZodEffects, + ZodOptional, + ZodNullable, + ZodDefault, + ZodCatch, + ZodNaN, + BRAND, + ZodBranded, + ZodPipeline, + ZodReadonly, + custom, + Schema: ZodType, + ZodSchema: ZodType, + late, + get ZodFirstPartyTypeKind() { + return ZodFirstPartyTypeKind; + }, + coerce, + any: anyType, + array: arrayType, + bigint: bigIntType, + boolean: booleanType, + date: dateType, + discriminatedUnion: discriminatedUnionType, + effect: effectsType, + enum: enumType, + function: functionType, + instanceof: instanceOfType, + intersection: intersectionType, + lazy: lazyType, + literal: literalType, + map: mapType, + nan: nanType, + nativeEnum: nativeEnumType, + never: neverType, + null: nullType, + nullable: nullableType, + number: numberType, + object: objectType, + oboolean, + onumber, + optional: optionalType, + ostring, + pipeline: pipelineType, + preprocess: preprocessType, + promise: promiseType, + record: recordType, + set: setType, + strictObject: strictObjectType, + string: stringType, + symbol: symbolType, + transformer: effectsType, + tuple: tupleType, + undefined: undefinedType, + union: unionType, + unknown: unknownType, + void: voidType, + NEVER, + ZodIssueCode, + quotelessJson, + ZodError +}); + +// src/workers/shared/zod.worker.ts +var HEX_REGEXP = /^[0-9a-f]*$/i, BASE64_REGEXP = /^[0-9a-z+/=]*$/i, HexDataSchema = z.string().regex(HEX_REGEXP).transform((hex) => Buffer.from(hex, "hex")), Base64DataSchema = z.string().regex(BASE64_REGEXP).transform((base64) => Buffer.from(base64, "base64")); +export { + BASE64_REGEXP, + Base64DataSchema, + HEX_REGEXP, + HexDataSchema, + z +}; +//# sourceMappingURL=zod.worker.js.map diff --git a/node_modules/miniflare/dist/src/workers/shared/zod.worker.js.map b/node_modules/miniflare/dist/src/workers/shared/zod.worker.js.map new file mode 100644 index 0000000000000000000000000000000000000000..77ea152730c69af17c54e9d7ed184a07d0bb9c11 --- /dev/null +++ b/node_modules/miniflare/dist/src/workers/shared/zod.worker.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "sources": ["../../../../src/workers/shared/zod.worker.ts", "../../../../../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs"], + "mappings": ";AAAA,SAAS,cAAc;;;ACAvB,IAAI;AAAA,CACH,SAAUA,OAAM;AACb,EAAAA,MAAK,cAAc,CAAC,QAAQ;AAC5B,WAAS,SAAS,MAAM;AAAA,EAAE;AAC1B,EAAAA,MAAK,WAAW;AAChB,WAAS,YAAY,IAAI;AACrB,UAAM,IAAI,MAAM;AAAA,EACpB;AACA,EAAAA,M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;AAAA,EACR,WAAW;AAAA,EACX;AAAA,EACA,IAAI,wBAAyB;AAAE,WAAO;AAAA,EAAuB;AAAA,EAC7D;AAAA,EACA,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,oBAAoB;AAAA,EACpB,QAAQ;AAAA,EACR,MAAQ;AAAA,EACR,UAAY;AAAA,EACZ,YAAc;AAAA,EACd,cAAc;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AAAA,EACL,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,MAAQ;AAAA,EACR,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,OAAO;AAAA,EACP,WAAa;AAAA,EACb,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;;;ADh6HM,IAAM,aAAa,gBAEb,gBAAgB,mBAChB,gBAAgB,EAC3B,OAAO,EACP,MAAM,UAAU,EAChB,UAAU,CAAC,QAAQ,OAAO,KAAK,KAAK,KAAK,CAAC,GAC/B,mBAAmB,EAC9B,OAAO,EACP,MAAM,aAAa,EACnB,UAAU,CAAC,WAAW,OAAO,KAAK,QAAQ,QAAQ,CAAC;", + "names": ["util", "objectUtil", "errorUtil", "errorMap", "ctx", "result", "issues", "elements", "processed", "ZodFirstPartyTypeKind"] +} diff --git a/node_modules/miniflare/package.json b/node_modules/miniflare/package.json new file mode 100644 index 0000000000000000000000000000000000000000..7b09830974daaaaf3b9462c7345dff11dcb30c23 --- /dev/null +++ b/node_modules/miniflare/package.json @@ -0,0 +1,102 @@ +{ + "name": "miniflare", + "version": "3.20231030.2", + "description": "Fun, full-featured, fully-local simulator for Cloudflare Workers", + "keywords": [ + "cloudflare", + "workers", + "worker", + "local", + "cloudworker" + ], + "homepage": "https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare#readme", + "bugs": { + "url": "https://github.com/cloudflare/workers-sdk/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/cloudflare/workers-sdk.git", + "directory": "packages/miniflare" + }, + "license": "MIT", + "author": "MrBBot ", + "main": "./dist/src/index.js", + "types": "./dist/src/index.d.ts", + "files": [ + "dist/src", + "bootstrap.js" + ], + "bin": { + "miniflare": "bootstrap.js" + }, + "dependencies": { + "acorn": "^8.8.0", + "acorn-walk": "^8.2.0", + "capnp-ts": "^0.7.0", + "exit-hook": "^2.2.1", + "glob-to-regexp": "^0.4.1", + "source-map-support": "0.5.21", + "stoppable": "^1.1.0", + "undici": "^5.22.1", + "workerd": "1.20231030.0", + "ws": "^8.11.0", + "youch": "^3.2.2", + "zod": "^3.20.6" + }, + "devDependencies": { + "@ava/typescript": "^4.0.0", + "@cloudflare/kv-asset-handler": "^0.3.0", + "@cloudflare/workers-types": "^4.20231002.0", + "@microsoft/api-extractor": "^7.36.3", + "@types/debug": "^4.1.7", + "@types/estree": "^1.0.0", + "@types/glob-to-regexp": "^0.4.1", + "@types/http-cache-semantics": "^4.0.1", + "@types/node": "^18.11.9", + "@types/rimraf": "^3.0.2", + "@types/source-map-support": "^0.5.6", + "@types/stoppable": "^1.1.1", + "@types/which": "^2.0.1", + "@types/ws": "^8.5.3", + "@typescript-eslint/eslint-plugin": "^6.9.0", + "@typescript-eslint/parser": "^6.9.0", + "ava": "^5.2.0", + "capnpc-ts": "^0.7.0", + "concurrently": "^8.2.2", + "devalue": "^4.3.0", + "devtools-protocol": "^0.0.1182435", + "esbuild": "^0.16.17", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-es": "^4.1.0", + "eslint-plugin-import": "2.26.x", + "eslint-plugin-prettier": "^5.0.1", + "expect-type": "^0.15.0", + "http-cache-semantics": "^4.1.0", + "kleur": "^4.1.5", + "prettier": "^3.0.3", + "rimraf": "^3.0.2", + "source-map": "^0.6.0", + "typescript": "~5.0.4", + "which": "^2.0.2" + }, + "engines": { + "node": ">=16.13" + }, + "volta": { + "extends": "../../package.json" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "build": "node scripts/build.mjs && pnpm run types:build", + "capnp:workerd": "capnpc -o ts src/runtime/config/workerd.capnp", + "clean": "rimraf ./dist ./dist-types", + "dev": "concurrently -n esbuild,typechk,typewrk -c yellow,blue,blue.dim \"node scripts/build.mjs watch\" \"node scripts/types.mjs tsconfig.json watch\" \"node scripts/types.mjs src/workers/tsconfig.json watch\"", + "test": "node scripts/build.mjs && ava && rimraf ./.tmp", + "test:ci": "pnpm run test", + "check:lint": "eslint \"{src,test}/**/*.ts\" \"scripts/**/*.{js,mjs}\" \"types/**/*.ts\"", + "lint:fix": "pnpm run lint -- --fix", + "types:build": "node scripts/types.mjs tsconfig.json && node scripts/types.mjs src/workers/tsconfig.json" + } +} \ No newline at end of file diff --git a/node_modules/ms/index.js b/node_modules/ms/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c4498bcc212589664a5fe0d45e5908b174ab0a37 --- /dev/null +++ b/node_modules/ms/index.js @@ -0,0 +1,162 @@ +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var w = d * 7; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === 'string' && val.length > 0) { + return parse(val); + } else if (type === 'number' && isFinite(val)) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'weeks': + case 'week': + case 'w': + return n * w; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtShort(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return Math.round(ms / d) + 'd'; + } + if (msAbs >= h) { + return Math.round(ms / h) + 'h'; + } + if (msAbs >= m) { + return Math.round(ms / m) + 'm'; + } + if (msAbs >= s) { + return Math.round(ms / s) + 's'; + } + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtLong(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return plural(ms, msAbs, d, 'day'); + } + if (msAbs >= h) { + return plural(ms, msAbs, h, 'hour'); + } + if (msAbs >= m) { + return plural(ms, msAbs, m, 'minute'); + } + if (msAbs >= s) { + return plural(ms, msAbs, s, 'second'); + } + return ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, msAbs, n, name) { + var isPlural = msAbs >= n * 1.5; + return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); +} diff --git a/node_modules/ms/license.md b/node_modules/ms/license.md new file mode 100644 index 0000000000000000000000000000000000000000..69b61253a38926757b7de1d4df4880fc2105c2c9 --- /dev/null +++ b/node_modules/ms/license.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Zeit, Inc. + +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. diff --git a/node_modules/ms/package.json b/node_modules/ms/package.json new file mode 100644 index 0000000000000000000000000000000000000000..eea666e1fb03d6ef0eb9edb7b8af363db911665f --- /dev/null +++ b/node_modules/ms/package.json @@ -0,0 +1,37 @@ +{ + "name": "ms", + "version": "2.1.2", + "description": "Tiny millisecond conversion utility", + "repository": "zeit/ms", + "main": "./index", + "files": [ + "index.js" + ], + "scripts": { + "precommit": "lint-staged", + "lint": "eslint lib/* bin/*", + "test": "mocha tests.js" + }, + "eslintConfig": { + "extends": "eslint:recommended", + "env": { + "node": true, + "es6": true + } + }, + "lint-staged": { + "*.js": [ + "npm run lint", + "prettier --single-quote --write", + "git add" + ] + }, + "license": "MIT", + "devDependencies": { + "eslint": "4.12.1", + "expect.js": "0.3.1", + "husky": "0.14.3", + "lint-staged": "5.0.0", + "mocha": "4.0.1" + } +} diff --git a/node_modules/ms/readme.md b/node_modules/ms/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..9a1996b17e0de6854dd1cf10c5f2ee642e494085 --- /dev/null +++ b/node_modules/ms/readme.md @@ -0,0 +1,60 @@ +# ms + +[![Build Status](https://travis-ci.org/zeit/ms.svg?branch=master)](https://travis-ci.org/zeit/ms) +[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/zeit) + +Use this package to easily convert various time formats to milliseconds. + +## Examples + +```js +ms('2 days') // 172800000 +ms('1d') // 86400000 +ms('10h') // 36000000 +ms('2.5 hrs') // 9000000 +ms('2h') // 7200000 +ms('1m') // 60000 +ms('5s') // 5000 +ms('1y') // 31557600000 +ms('100') // 100 +ms('-3 days') // -259200000 +ms('-1h') // -3600000 +ms('-200') // -200 +``` + +### Convert from Milliseconds + +```js +ms(60000) // "1m" +ms(2 * 60000) // "2m" +ms(-3 * 60000) // "-3m" +ms(ms('10 hours')) // "10h" +``` + +### Time Format Written-Out + +```js +ms(60000, { long: true }) // "1 minute" +ms(2 * 60000, { long: true }) // "2 minutes" +ms(-3 * 60000, { long: true }) // "-3 minutes" +ms(ms('10 hours'), { long: true }) // "10 hours" +``` + +## Features + +- Works both in [Node.js](https://nodejs.org) and in the browser +- If a number is supplied to `ms`, a string with a unit is returned +- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`) +- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned + +## Related Packages + +- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time. + +## Caught a Bug? + +1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device +2. Link the package to the global module directory: `npm link` +3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms! + +As always, you can run the tests using: `npm test` diff --git a/node_modules/mustache/CHANGELOG.md b/node_modules/mustache/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..b1f72d0a37364c5a4b6d5ec394ca69a9191421ab --- /dev/null +++ b/node_modules/mustache/CHANGELOG.md @@ -0,0 +1,618 @@ +# Change Log + +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). + +## [4.2.0] / 28 March 2021 + +### Added + +* [#773]: Add package.json `exports` field, by [@manzt]. + +## [4.1.0] / 6 December 2020 + +### Added + +* [#764]: `render()` now recognizes a config object argument, by [@pineapplemachine]. + +### Fixed + +* [#764]: Ask custom `escape` functions to escape all types of values (including `number`s), by [@pineapplemachine]. + +## [4.0.1] / 15 March 2020 + +### Fixed + + * [#739]: Fix custom delimiters in nested partials, by [@aielo]. + +## [4.0.0] / 16 January 2020 + +Majority of using projects don't have to worry by this being a new major version. + +**TLDR;** if your project manipulates `Writer.prototype.parse | Writer.cache` directly or uses `.to_html()`, you probably have to change that code. + +This release allows the internal template cache to be customised, either by disabling it completely +or provide a custom strategy deciding how the cache should behave when mustache.js parses templates. + +```js +const mustache = require('mustache'); + +// disable caching +Mustache.templateCache = undefined; + +// or use a built-in Map in modern environments +Mustache.templateCache = new Map(); +``` + +Projects that wanted to customise the caching behaviour in earlier versions of mustache.js were forced to +override internal method responsible for parsing templates; `Writer.prototype.parse`. In short, that was unfortunate +because there is more than caching happening in that method. + +We've improved that now by introducing a first class API that only affects template caching. + +The default template cache behaves as before and is still compatible with older JavaScript environments. +For those who wants to provide a custom more sopisiticated caching strategy, one can do that with an object that adheres to the following requirements: + +```ts +{ + set(cacheKey: string, value: string): void + get(cacheKey: string): string | undefined + clear(): void +} +``` + +### Added + +* [#731]: Allow template caching to be customised, by [@AndrewLeedham]. + +### Removed + +* [#735]: Remove `.to_html()`, by [@phillipj]. + +## [3.2.1] / 30 December 2019 + +### Fixed + + * [#733]: Allow the CLI to use JavaScript views when the project has ES6 modules enabled, by [@eobrain]. + +## [3.2.0] / 18 December 2019 + +### Added + +* [#728]: Expose ECMAScript Module in addition to UMD (CommonJS, AMD & global scope), by [@phillipj] and [@zekth]. + +### Using mustache.js as an ES module + +To stay backwards compatible with already using projects, the default exposed module format is still UMD. +That means projects using mustache.js as an CommonJS, AMD or global scope module, from npm or directly from github.com +can keep on doing that for now. + +For those projects who would rather want to use mustache.js as an ES module, the `mustache/mustache.mjs` file has to +be `import`ed directly. + +Below are some usage scenarios for different runtimes. + +#### Modern browser with ES module support + +```html + + +``` + +#### [Node.js](https://nodejs.org) (>= v13.2.0 or using --experimental-modules flag) + +```js +// index.mjs +import mustache from 'mustache/mustache.mjs' + +console.log(mustache.render('Hello {{name}}!', { name: 'Santa' })) +// Hello Santa! +``` + +ES Module support for Node.js will be improved in the future when [Conditional Exports](https://nodejs.org/api/esm.html#esm_conditional_exports) +is enabled by default rather than being behind an experimental flag. + +More info in [Node.js ECMAScript Modules docs](https://nodejs.org/api/esm.html). + +#### [Deno](https://deno.land/) + +```js +// index.ts +import mustache from 'https://unpkg.com/mustache@3.2.0/mustache.mjs' + +console.log(mustache.render('Hello {{name}}!', { name: 'Santa' })) +// Hello Santa! +``` + +## [3.1.0] / 13 September 2019 + +### Added + + * [#717]: Added support .js files as views in command line tool, by [@JEStaubach]. + +### Fixed + + * [#716]: Bugfix for indentation of inline partials, by [@yotammadem]. + +## [3.0.3] / 27 August 2019 + +### Added + + * [#713]: Add test cases for custom functions in partials, by [@wol-soft]. + +### Fixed + + * [#714]: Bugfix for wrong function output in partials with indentation, by [@phillipj]. + +## [3.0.2] / 21 August 2019 + +### Fixed + + * [#705]: Fix indentation of partials, by [@kevindew] and [@yotammadem]. + +### Dev + + * [#701]: Fix test failure for Node 10 and above, by [@andersk]. + * [#704]: Lint all test files just like the source files, by [@phillipj]. + * Start experimenting & comparing GitHub Actions vs Travis CI, by [@phillipj]. + +## [3.0.1] / 11 November 2018 + + * [#679]: Fix partials not rendering tokens when using custom tags, by [@stackchain]. + +## [3.0.0] / 16 September 2018 + +We are very happy to announce a new major version of mustache.js. We want to be very careful not to break projects +out in the wild, and adhering to [Semantic Versioning](http://semver.org/) we have therefore cut this new major version. + +The changes introduced will likely not require any actions for most using projects. The things to look out for that +might cause unexpected rendering results are described in the migration guide below. + +A big shout out and thanks to [@raymond-lam] for this release! Without his contributions with code and issue triaging, +this release would never have happened. + +### Major + +* [#618]: Allow rendering properties of primitive types that are not objects, by [@raymond-lam]. +* [#643]: `Writer.prototype.parse` to cache by tags in addition to template string, by [@raymond-lam]. +* [#664]: Fix `Writer.prototype.parse` cache, by [@seminaoki]. + +### Minor + +* [#673]: Add `tags` parameter to `Mustache.render()`, by [@raymond-lam]. + +### Migrating from mustache.js v2.x to v3.x + +#### Rendering properties of primitive types + +We have ensured properties of primitive types can be rendered at all times. That means `Array.length`, `String.length` +and similar. A corner case where this could cause unexpected output follows: + +View: +``` +{ + stooges: [ + { name: "Moe" }, + { name: "Larry" }, + { name: "Curly" } + ] +} +``` + +Template: +``` +{{#stooges}} + {{name}}: {{name.length}} characters +{{/stooges}} +``` + +Output with v3.0: +``` + Moe: 3 characters + Larry: 5 characters + Curly: 5 characters +``` + +Output with v2.x: +``` + Moe: characters + Larry: characters + Curly: characters +``` + +#### Caching for templates with custom delimiters + +We have improved the templates cache to ensure custom delimiters are taken into consideration for the cache. +This improvement might cause unexpected rendering behaviour for using projects actively using the custom delimiters functionality. + +Previously it was possible to use `Mustache.parse()` as a means to set global custom delimiters. If custom +delimiters were provided as an argument, it would affect all following calls to `Mustache.render()`. +Consider the following: + +```js +const template = "[[item.title]] [[item.value]]"; +mustache.parse(template, ["[[", "]]"]); + +console.log( + mustache.render(template, { + item: { + title: "TEST", + value: 1 + } + }) +); + +>> TEST 1 +``` + +The above illustrates the fact that `Mustache.parse()` made mustache.js cache the template without considering +the custom delimiters provided. This is no longer true. + +We no longer encourage using `Mustache.parse()` for this purpose, but have rather added a fourth argument to +`Mustache.render()` letting you provide custom delimiters when rendering. + +If you still need the pre-parse the template and use custom delimiters at the same time, ensure to provide +the custom delimiters as argument to `Mustache.render()` as well. + +## [2.3.2] / 17 August 2018 + +This release is made to revert changes introduced in [2.3.1] that caused unexpected behaviour for several users. + +### Minor + + * [#670]: Rollback template cache causing unexpected behaviour, by [@raymond-lam]. + +## [2.3.1] / 7 August 2018 + +### Minor + + * [#643]: `Writer.prototype.parse` to cache by tags in addition to template string, by [@raymond-lam]. + * [#664]: Fix `Writer.prototype.parse` cache, by [@seminaoki]. + +### Dev + + * [#666]: Install release tools with npm rather than pre-commit hook & `Rakefile`, by [@phillipj]. + * [#667], [#668]: Stabilize browser test suite, by [@phillipj]. + +### Docs + + * [#644]: Document global Mustache.escape overriding capacity, by [@paultopia]. + * [#657]: Correct `Mustache.parse()` return type documentation, by [@bbrooks]. + +## [2.3.0] / 8 November 2016 + +### Minor + + * [#540]: Add optional `output` argument to mustache CLI, by [@wizawu]. + * [#597]: Add compatibility with amdclean, by [@mightyplow]. + +### Dev + + * [#553]: Assert `null` lookup when rendering an unescaped value, by [@dasilvacontin]. + * [#580], [#610]: Ignore eslint for greenkeeper updates, by [@phillipj]. + * [#560]: Fix CLI tests for Windows, by [@kookookchoozeus]. + * Run browser tests w/node v4, by [@phillipj]. + +### Docs + + * [#542]: Add API documentation to README, by [@tomekwi]. + * [#546]: Add missing syntax highlighting to README code blocks, by [@pra85]. + * [#569]: Update Ctemplate links in README, by [@mortonfox]. + * [#592]: Change "loadUser" to "loadUser()" in README, by [@Flaque]. + * [#593]: Adding doctype to HTML code example in README, by [@calvinf]. + +### Dependencies + + * eslint -> 2.2.0. Breaking changes fix by [@phillipj]. [#548] + * eslint -> 2.5.1. + * mocha -> 3.0.2. + * zuul -> 3.11.0. + +## [2.2.1] / 13 December 2015 + +### Fixes + + * Improve HTML escaping, by [@phillipj]. + * Fix inconsistency in defining global mustache object, by [@simast]. + * Fix switch-case indent error, by [@norfish]. + * Unpin chai and eslint versions, by [@dasilvacontin]. + * Update README.md with proper grammar, by [@EvanLovely]. + * Update mjackson username in README, by [@mjackson]. + * Remove syntax highlighting in README code sample, by [@imagentleman]. + * Fix typo in README, by [@Xcrucifier]. + * Fix link typo in README, by [@keirog]. + +## [2.2.0] / 15 October 2015 + +### Added + + * Add Partials support to CLI, by [@palkan]. + +### Changed + + * Move install instructions to README's top, by [@mateusortiz] + * Improved devhook install output, by [@ShashankaNataraj]. + * Clarifies and improves language in documentation, by [@jfmercer]. + * Linting CLI tool, by [@phillipj]. + * npm 2.x and node v4 on Travis, by [@phillipj]. + +### Fixes + + * Fix README spelling error to "aforementioned", by [@djchie]. + * Equal error message test in .render() for server and browser, by [@phillipj]. + +### Dependencies + + * chai -> 3.3.0 + * eslint -> 1.6.0 + +## [2.1.3] / 23 July 2015 + +### Added + + * Throw error when providing .render() with invalid template type, by [@phillipj]. + * Documents use of string literals containing double quotes, by [@jfmercer]. + +### Changed + + * Move mustache gif to githubusercontent, by [@Andersos]. + +### Fixed + + * Update UMD Shim to be resilient to HTMLElement global pollution, by [@mikesherov]. + +## [2.1.2] / 17 June 2015 + +### Added + + * Mustache global definition ([#466]) by [@yousefcisco]. + +## [2.1.1] / 11 June 2015 + +### Added + + * State that we use semver on the change log, by [@dasilvacontin]. + * Added version links to change log, by [@dasilvacontin]. + +### Fixed + + * Bugfix for using values from view's context prototype, by [@phillipj]. + * Improve test with undefined/null lookup hit using dot notation, by [@dasilvacontin]. + * Bugfix for null/undefined lookup hit when using dot notation, by [@phillipj]. + * Remove moot `version` property from bower.json, by [@kkirsche]. + * bower.json doesn't require a version bump via hook, by [@dasilvacontin]. + + +## [2.1.0] / 5 June 2015 + + * Added license attribute to package.json, by [@pgilad]. + * Minor changes to make mustache.js compatible with both WSH and ASP, by [@nagaozen]. + * Improve CLI view parsing error, by [@phillipj]. + * Bugfix for view context cache, by [@phillipj]. + +## [2.0.0] / 27 Mar 2015 + + * Fixed lookup not stopping upon finding `undefined` or `null` values, by [@dasilvacontin]. + * Refactored pre-commit hook, by [@dasilvacontin]. + +## [1.2.0] / 24 Mar 2015 + + * Added -v option to CLI, by [@phillipj]. + * Bugfix for rendering Number when it serves as the Context, by [@phillipj]. + * Specified files in package.json for a cleaner install, by [@phillipj]. + +## [1.1.0] / 18 Feb 2015 + + * Refactor Writer.renderTokens() for better readability, by [@phillipj]. + * Cleanup tests section in readme, by [@phillipj]. + * Added JSHint to tests/CI, by [@phillipj]. + * Added node v0.12 on travis, by [@phillipj]. + * Created command line tool, by [@phillipj]. + * Added *falsy* to Inverted Sections description in README, by [@kristijanmatic]. + +## [1.0.0] / 20 Dec 2014 + + * Inline tag compilation, by [@mjackson]. + * Fixed AMD registration, volo package.json entry, by [@jrburke]. + * Added spm support, by [@afc163]. + * Only access properties of objects on Context.lookup, by [@cmbuckley]. + +## [0.8.2] / 17 Mar 2014 + + * Supporting Bower through a bower.json file. + +## [0.8.1] / 3 Jan 2014 + + * Fix usage of partial templates. + +## [0.8.0] / 2 Dec 2013 + + * Remove compile* writer functions, use mustache.parse instead. Smaller API. + * Throw an error when rendering a template that contains higher-order sections and + the original template is not provided. + * Remove low-level Context.make function. + * Better code readability and inline documentation. + * Stop caching templates by name. + +## [0.7.3] / 5 Nov 2013 + + * Don't require the original template to be passed to the rendering function + when using compiled templates. This is still required when using higher-order + functions in order to be able to extract the portion of the template + that was contained by that section. Fixes [#262]. + * Performance improvements. + +## [0.7.2] / 27 Dec 2012 + + * Fixed a rendering bug ([#274]) when using nested higher-order sections. + * Better error reporting on failed parse. + * Converted tests to use mocha instead of vows. + +## [0.7.1] / 6 Dec 2012 + + * Handle empty templates gracefully. Fixes [#265], [#267], and [#270]. + * Cache partials by template, not by name. Fixes [#257]. + * Added Mustache.compileTokens to compile the output of Mustache.parse. Fixes + [#258]. + +## [0.7.0] / 10 Sep 2012 + + * Rename Renderer => Writer. + * Allow partials to be loaded dynamically using a callback (thanks + [@TiddoLangerak] for the suggestion). + * Fixed a bug with higher-order sections that prevented them from being + passed the raw text of the section from the original template. + * More concise token format. Tokens also include start/end indices in the + original template. + * High-level API is consistent with the Writer API. + * Allow partials to be passed to the pre-compiled function (thanks + [@fallenice]). + * Don't use eval (thanks [@cweider]). + +## [0.6.0] / 31 Aug 2012 + + * Use JavaScript's definition of falsy when determining whether to render an + inverted section or not. Issue [#186]. + * Use Mustache.escape to escape values inside {{}}. This function may be + reassigned to alter the default escaping behavior. Issue [#244]. + * Fixed a bug that clashed with QUnit (thanks [@kannix]). + * Added volo support (thanks [@guybedford]). + +[4.1.0]: https://github.com/janl/mustache.js/compare/v4.0.1...v4.1.0 +[4.0.1]: https://github.com/janl/mustache.js/compare/v4.0.0...v4.0.1 +[4.0.0]: https://github.com/janl/mustache.js/compare/v3.2.1...v4.0.0 +[3.2.1]: https://github.com/janl/mustache.js/compare/v3.2.0...v3.2.1 +[3.2.0]: https://github.com/janl/mustache.js/compare/v3.1.0...v3.2.0 +[3.1.0]: https://github.com/janl/mustache.js/compare/v3.0.3...v3.1.0 +[3.0.3]: https://github.com/janl/mustache.js/compare/v3.0.2...v3.0.3 +[3.0.2]: https://github.com/janl/mustache.js/compare/v3.0.1...v3.0.2 +[3.0.1]: https://github.com/janl/mustache.js/compare/v3.0.0...v3.0.1 +[3.0.0]: https://github.com/janl/mustache.js/compare/v2.3.2...v3.0.0 +[2.3.2]: https://github.com/janl/mustache.js/compare/v2.3.1...v2.3.2 +[2.3.1]: https://github.com/janl/mustache.js/compare/v2.3.0...v2.3.1 +[2.3.0]: https://github.com/janl/mustache.js/compare/v2.2.1...v2.3.0 +[2.2.1]: https://github.com/janl/mustache.js/compare/v2.2.0...v2.2.1 +[2.2.0]: https://github.com/janl/mustache.js/compare/v2.1.3...v2.2.0 +[2.1.3]: https://github.com/janl/mustache.js/compare/v2.1.2...v2.1.3 +[2.1.2]: https://github.com/janl/mustache.js/compare/v2.1.1...v2.1.2 +[2.1.1]: https://github.com/janl/mustache.js/compare/v2.1.0...v2.1.1 +[2.1.0]: https://github.com/janl/mustache.js/compare/v2.0.0...v2.1.0 +[2.0.0]: https://github.com/janl/mustache.js/compare/v1.2.0...v2.0.0 +[1.2.0]: https://github.com/janl/mustache.js/compare/v1.1.0...v1.2.0 +[1.1.0]: https://github.com/janl/mustache.js/compare/v1.0.0...v1.1.0 +[1.0.0]: https://github.com/janl/mustache.js/compare/0.8.2...v1.0.0 +[0.8.2]: https://github.com/janl/mustache.js/compare/0.8.1...0.8.2 +[0.8.1]: https://github.com/janl/mustache.js/compare/0.8.0...0.8.1 +[0.8.0]: https://github.com/janl/mustache.js/compare/0.7.3...0.8.0 +[0.7.3]: https://github.com/janl/mustache.js/compare/0.7.2...0.7.3 +[0.7.2]: https://github.com/janl/mustache.js/compare/0.7.1...0.7.2 +[0.7.1]: https://github.com/janl/mustache.js/compare/0.7.0...0.7.1 +[0.7.0]: https://github.com/janl/mustache.js/compare/0.6.0...0.7.0 +[0.6.0]: https://github.com/janl/mustache.js/compare/0.5.2...0.6.0 + +[#186]: https://github.com/janl/mustache.js/issues/186 +[#244]: https://github.com/janl/mustache.js/issues/244 +[#257]: https://github.com/janl/mustache.js/issues/257 +[#258]: https://github.com/janl/mustache.js/issues/258 +[#262]: https://github.com/janl/mustache.js/issues/262 +[#265]: https://github.com/janl/mustache.js/issues/265 +[#267]: https://github.com/janl/mustache.js/issues/267 +[#270]: https://github.com/janl/mustache.js/issues/270 +[#274]: https://github.com/janl/mustache.js/issues/274 +[#466]: https://github.com/janl/mustache.js/issues/466 +[#540]: https://github.com/janl/mustache.js/issues/540 +[#542]: https://github.com/janl/mustache.js/issues/542 +[#546]: https://github.com/janl/mustache.js/issues/546 +[#548]: https://github.com/janl/mustache.js/issues/548 +[#553]: https://github.com/janl/mustache.js/issues/553 +[#560]: https://github.com/janl/mustache.js/issues/560 +[#569]: https://github.com/janl/mustache.js/issues/569 +[#580]: https://github.com/janl/mustache.js/issues/580 +[#592]: https://github.com/janl/mustache.js/issues/592 +[#593]: https://github.com/janl/mustache.js/issues/593 +[#597]: https://github.com/janl/mustache.js/issues/597 +[#610]: https://github.com/janl/mustache.js/issues/610 +[#643]: https://github.com/janl/mustache.js/issues/643 +[#644]: https://github.com/janl/mustache.js/issues/644 +[#657]: https://github.com/janl/mustache.js/issues/657 +[#664]: https://github.com/janl/mustache.js/issues/664 +[#666]: https://github.com/janl/mustache.js/issues/666 +[#667]: https://github.com/janl/mustache.js/issues/667 +[#668]: https://github.com/janl/mustache.js/issues/668 +[#670]: https://github.com/janl/mustache.js/issues/670 +[#618]: https://github.com/janl/mustache.js/issues/618 +[#673]: https://github.com/janl/mustache.js/issues/673 +[#679]: https://github.com/janl/mustache.js/issues/679 +[#701]: https://github.com/janl/mustache.js/issues/701 +[#704]: https://github.com/janl/mustache.js/issues/704 +[#705]: https://github.com/janl/mustache.js/issues/705 +[#713]: https://github.com/janl/mustache.js/issues/713 +[#714]: https://github.com/janl/mustache.js/issues/714 +[#716]: https://github.com/janl/mustache.js/issues/716 +[#717]: https://github.com/janl/mustache.js/issues/717 +[#728]: https://github.com/janl/mustache.js/issues/728 +[#733]: https://github.com/janl/mustache.js/issues/733 +[#731]: https://github.com/janl/mustache.js/issues/731 +[#735]: https://github.com/janl/mustache.js/issues/735 +[#739]: https://github.com/janl/mustache.js/issues/739 +[#764]: https://github.com/janl/mustache.js/issues/764 +[#773]: https://github.com/janl/mustache.js/issues/773 + +[@afc163]: https://github.com/afc163 +[@aielo]: https://github.com/aielo +[@andersk]: https://github.com/andersk +[@Andersos]: https://github.com/Andersos +[@AndrewLeedham]: https://github.com/AndrewLeedham +[@bbrooks]: https://github.com/bbrooks +[@calvinf]: https://github.com/calvinf +[@cmbuckley]: https://github.com/cmbuckley +[@cweider]: https://github.com/cweider +[@dasilvacontin]: https://github.com/dasilvacontin +[@djchie]: https://github.com/djchie +[@eobrain]: https://github.com/eobrain +[@EvanLovely]: https://github.com/EvanLovely +[@fallenice]: https://github.com/fallenice +[@Flaque]: https://github.com/Flaque +[@guybedford]: https://github.com/guybedford +[@imagentleman]: https://github.com/imagentleman +[@JEStaubach]: https://github.com/JEStaubach +[@jfmercer]: https://github.com/jfmercer +[@jrburke]: https://github.com/jrburke +[@kannix]: https://github.com/kannix +[@keirog]: https://github.com/keirog +[@kkirsche]: https://github.com/kkirsche +[@kookookchoozeus]: https://github.com/kookookchoozeus +[@kristijanmatic]: https://github.com/kristijanmatic +[@kevindew]: https://github.com/kevindew +[@manzt]: https://github.com/manzt +[@mateusortiz]: https://github.com/mateusortiz +[@mightyplow]: https://github.com/mightyplow +[@mikesherov]: https://github.com/mikesherov +[@mjackson]: https://github.com/mjackson +[@mortonfox]: https://github.com/mortonfox +[@nagaozen]: https://github.com/nagaozen +[@norfish]: https://github.com/norfish +[@palkan]: https://github.com/palkan +[@paultopia]: https://github.com/paultopia +[@pgilad]: https://github.com/pgilad +[@phillipj]: https://github.com/phillipj +[@pineapplemachine]: https://github.com/pineapplemachine +[@pra85]: https://github.com/pra85 +[@raymond-lam]: https://github.com/raymond-lam +[@seminaoki]: https://github.com/seminaoki +[@ShashankaNataraj]: https://github.com/ShashankaNataraj +[@simast]: https://github.com/simast +[@stackchain]: https://github.com/stackchain +[@TiddoLangerak]: https://github.com/TiddoLangerak +[@tomekwi]: https://github.com/tomekwi +[@wizawu]: https://github.com/wizawu +[@wol-soft]: https://github.com/wol-soft +[@Xcrucifier]: https://github.com/Xcrucifier +[@yotammadem]: https://github.com/yotammadem +[@yousefcisco]: https://github.com/yousefcisco +[@zekth]: https://github.com/zekth diff --git a/node_modules/mustache/LICENSE b/node_modules/mustache/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..4df7d1aae6fbbdf501a9409827e88412d3030530 --- /dev/null +++ b/node_modules/mustache/LICENSE @@ -0,0 +1,11 @@ +The MIT License + +Copyright (c) 2009 Chris Wanstrath (Ruby) +Copyright (c) 2010-2014 Jan Lehnardt (JavaScript) +Copyright (c) 2010-2015 The mustache.js community + +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. diff --git a/node_modules/mustache/README.md b/node_modules/mustache/README.md new file mode 100644 index 0000000000000000000000000000000000000000..127dfe106c85ae04e1813145c81bbdca501f3e33 --- /dev/null +++ b/node_modules/mustache/README.md @@ -0,0 +1,621 @@ +# mustache.js - Logic-less {{mustache}} templates with JavaScript + +> What could be more logical awesome than no logic at all? + +[![Build Status](https://travis-ci.org/janl/mustache.js.svg?branch=master)](https://travis-ci.org/janl/mustache.js) + +[mustache.js](http://github.com/janl/mustache.js) is a zero-dependency implementation of the [mustache](http://mustache.github.com/) template system in JavaScript. + +[Mustache](http://mustache.github.com/) is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object. + +We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values. + +For a language-agnostic overview of mustache's template syntax, see the `mustache(5)` [manpage](http://mustache.github.com/mustache.5.html). + +## Where to use mustache.js? + +You can use mustache.js to render mustache templates anywhere you can use JavaScript. This includes web browsers, server-side environments such as [Node.js](http://nodejs.org/), and [CouchDB](http://couchdb.apache.org/) views. + +mustache.js ships with support for the [CommonJS](http://www.commonjs.org/) module API, the [Asynchronous Module Definition](https://github.com/amdjs/amdjs-api/wiki/AMD) API (AMD) and [ECMAScript modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). + +In addition to being a package to be used programmatically, you can use it as a [command line tool](#command-line-tool). + +And this will be your templates after you use Mustache: + +!['stache](https://cloud.githubusercontent.com/assets/288977/8779228/a3cf700e-2f02-11e5-869a-300312fb7a00.gif) + +## Install + +You can get Mustache via [npm](http://npmjs.com). + +```bash +$ npm install mustache --save +``` + +## Usage + +Below is a quick example how to use mustache.js: + +```js +var view = { + title: "Joe", + calc: function () { + return 2 + 4; + } +}; + +var output = Mustache.render("{{title}} spends {{calc}}", view); +``` + +In this example, the `Mustache.render` function takes two parameters: 1) the [mustache](http://mustache.github.com/) template and 2) a `view` object that contains the data and code needed to render the template. + +## Templates + +A [mustache](http://mustache.github.com/) template is a string that contains any number of mustache tags. Tags are indicated by the double mustaches that surround them. `{{person}}` is a tag, as is `{{#person}}`. In both examples we refer to `person` as the tag's key. There are several types of tags available in mustache.js, described below. + +There are several techniques that can be used to load templates and hand them to mustache.js, here are two of them: + +#### Include Templates + +If you need a template for a dynamic part in a static website, you can consider including the template in the static HTML file to avoid loading templates separately. Here's a small example: + +```js +// file: render.js + +function renderHello() { + var template = document.getElementById('template').innerHTML; + var rendered = Mustache.render(template, { name: 'Luke' }); + document.getElementById('target').innerHTML = rendered; +} +``` + +```html + + +

Loading...
+ + + + + + +``` + +#### Load External Templates + +If your templates reside in individual files, you can load them asynchronously and render them when they arrive. Another example using [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch): + +```js +function renderHello() { + fetch('template.mustache') + .then((response) => response.text()) + .then((template) => { + var rendered = Mustache.render(template, { name: 'Luke' }); + document.getElementById('target').innerHTML = rendered; + }); +} +``` + +### Variables + +The most basic tag type is a simple variable. A `{{name}}` tag renders the value of the `name` key in the current context. If there is no such key, nothing is rendered. + +All variables are HTML-escaped by default. If you want to render unescaped HTML, use the triple mustache: `{{{name}}}`. You can also use `&` to unescape a variable. + +If you'd like to change HTML-escaping behavior globally (for example, to template non-HTML formats), you can override Mustache's escape function. For example, to disable all escaping: `Mustache.escape = function(text) {return text;};`. + +If you want `{{name}}` _not_ to be interpreted as a mustache tag, but rather to appear exactly as `{{name}}` in the output, you must change and then restore the default delimiter. See the [Custom Delimiters](#custom-delimiters) section for more information. + +View: + +```json +{ + "name": "Chris", + "company": "GitHub" +} +``` + +Template: + +``` +* {{name}} +* {{age}} +* {{company}} +* {{{company}}} +* {{&company}} +{{=<% %>=}} +* {{company}} +<%={{ }}=%> +``` + +Output: + +```html +* Chris +* +* <b>GitHub</b> +* GitHub +* GitHub +* {{company}} +``` + +JavaScript's dot notation may be used to access keys that are properties of objects in a view. + +View: + +```json +{ + "name": { + "first": "Michael", + "last": "Jackson" + }, + "age": "RIP" +} +``` + +Template: + +```html +* {{name.first}} {{name.last}} +* {{age}} +``` + +Output: + +```html +* Michael Jackson +* RIP +``` + +### Sections + +Sections render blocks of text zero or more times, depending on the value of the key in the current context. + +A section begins with a pound and ends with a slash. That is, `{{#person}}` begins a `person` section, while `{{/person}}` ends it. The text between the two tags is referred to as that section's "block". + +The behavior of the section is determined by the value of the key. + +#### False Values or Empty Lists + +If the `person` key does not exist, or exists and has a value of `null`, `undefined`, `false`, `0`, or `NaN`, or is an empty string or an empty list, the block will not be rendered. + +View: + +```json +{ + "person": false +} +``` + +Template: + +```html +Shown. +{{#person}} +Never shown! +{{/person}} +``` + +Output: + +```html +Shown. +``` + +#### Non-Empty Lists + +If the `person` key exists and is not `null`, `undefined`, or `false`, and is not an empty list the block will be rendered one or more times. + +When the value is a list, the block is rendered once for each item in the list. The context of the block is set to the current item in the list for each iteration. In this way we can loop over collections. + +View: + +```json +{ + "stooges": [ + { "name": "Moe" }, + { "name": "Larry" }, + { "name": "Curly" } + ] +} +``` + +Template: + +```html +{{#stooges}} +{{name}} +{{/stooges}} +``` + +Output: + +```html +Moe +Larry +Curly +``` + +When looping over an array of strings, a `.` can be used to refer to the current item in the list. + +View: + +```json +{ + "musketeers": ["Athos", "Aramis", "Porthos", "D'Artagnan"] +} +``` + +Template: + +```html +{{#musketeers}} +* {{.}} +{{/musketeers}} +``` + +Output: + +```html +* Athos +* Aramis +* Porthos +* D'Artagnan +``` + +If the value of a section variable is a function, it will be called in the context of the current item in the list on each iteration. + +View: + +```js +{ + "beatles": [ + { "firstName": "John", "lastName": "Lennon" }, + { "firstName": "Paul", "lastName": "McCartney" }, + { "firstName": "George", "lastName": "Harrison" }, + { "firstName": "Ringo", "lastName": "Starr" } + ], + "name": function () { + return this.firstName + " " + this.lastName; + } +} +``` + +Template: + +```html +{{#beatles}} +* {{name}} +{{/beatles}} +``` + +Output: + +```html +* John Lennon +* Paul McCartney +* George Harrison +* Ringo Starr +``` + +#### Functions + +If the value of a section key is a function, it is called with the section's literal block of text, un-rendered, as its first argument. The second argument is a special rendering function that uses the current view as its view argument. It is called in the context of the current view object. + +View: + +```js +{ + "name": "Tater", + "bold": function () { + return function (text, render) { + return "" + render(text) + ""; + } + } +} +``` + +Template: + +```html +{{#bold}}Hi {{name}}.{{/bold}} +``` + +Output: + +```html +Hi Tater. +``` + +### Inverted Sections + +An inverted section opens with `{{^section}}` instead of `{{#section}}`. The block of an inverted section is rendered only if the value of that section's tag is `null`, `undefined`, `false`, *falsy* or an empty list. + +View: + +```json +{ + "repos": [] +} +``` + +Template: + +```html +{{#repos}}{{name}}{{/repos}} +{{^repos}}No repos :({{/repos}} +``` + +Output: + +```html +No repos :( +``` + +### Comments + +Comments begin with a bang and are ignored. The following template: + +```html +

Today{{! ignore me }}.

+``` + +Will render as follows: + +```html +

Today.

+``` + +Comments may contain newlines. + +### Partials + +Partials begin with a greater than sign, like {{> box}}. + +Partials are rendered at runtime (as opposed to compile time), so recursive partials are possible. Just avoid infinite loops. + +They also inherit the calling context. Whereas in ERB you may have this: + +```html+erb +<%= partial :next_more, :start => start, :size => size %> +``` + +Mustache requires only this: + +```html +{{> next_more}} +``` + +Why? Because the `next_more.mustache` file will inherit the `size` and `start` variables from the calling context. In this way you may want to think of partials as includes, imports, template expansion, nested templates, or subtemplates, even though those aren't literally the case here. + + +For example, this template and partial: + + base.mustache: +

Names

+ {{#names}} + {{> user}} + {{/names}} + + user.mustache: + {{name}} + +Can be thought of as a single, expanded template: + +```html +

Names

+{{#names}} + {{name}} +{{/names}} +``` + +In mustache.js an object of partials may be passed as the third argument to `Mustache.render`. The object should be keyed by the name of the partial, and its value should be the partial text. + +```js +Mustache.render(template, view, { + user: userTemplate +}); +``` + +### Custom Delimiters + +Custom delimiters can be used in place of `{{` and `}}` by setting the new values in JavaScript or in templates. + +#### Setting in JavaScript + +The `Mustache.tags` property holds an array consisting of the opening and closing tag values. Set custom values by passing a new array of tags to `render()`, which gets honored over the default values, or by overriding the `Mustache.tags` property itself: + +```js +var customTags = [ '<%', '%>' ]; +``` + +##### Pass Value into Render Method +```js +Mustache.render(template, view, {}, customTags); +``` + +##### Override Tags Property +```js +Mustache.tags = customTags; +// Subsequent parse() and render() calls will use customTags +``` + +#### Setting in Templates + +Set Delimiter tags start with an equals sign and change the tag delimiters from `{{` and `}}` to custom strings. + +Consider the following contrived example: + +```html+erb +* {{ default_tags }} +{{=<% %>=}} +* <% erb_style_tags %> +<%={{ }}=%> +* {{ default_tags_again }} +``` + +Here we have a list with three items. The first item uses the default tag style, the second uses ERB style as defined by the Set Delimiter tag, and the third returns to the default style after yet another Set Delimiter declaration. + +According to [ctemplates](https://htmlpreview.github.io/?https://raw.githubusercontent.com/OlafvdSpek/ctemplate/master/doc/howto.html), this "is useful for languages like TeX, where double-braces may occur in the text and are awkward to use for markup." + +Custom delimiters may not contain whitespace or the equals sign. + +## Pre-parsing and Caching Templates + +By default, when mustache.js first parses a template it keeps the full parsed token tree in a cache. The next time it sees that same template it skips the parsing step and renders the template much more quickly. If you'd like, you can do this ahead of time using `mustache.parse`. + +```js +Mustache.parse(template); + +// Then, sometime later. +Mustache.render(template, view); +``` + +## Command line tool + +mustache.js is shipped with a Node.js based command line tool. It might be installed as a global tool on your computer to render a mustache template of some kind + +```bash +$ npm install -g mustache + +$ mustache dataView.json myTemplate.mustache > output.html +``` + +also supports stdin. + +```bash +$ cat dataView.json | mustache - myTemplate.mustache > output.html +``` + +or as a package.json `devDependency` in a build process maybe? + +```bash +$ npm install mustache --save-dev +``` + +```json +{ + "scripts": { + "build": "mustache dataView.json myTemplate.mustache > public/output.html" + } +} +``` +```bash +$ npm run build +``` + +The command line tool is basically a wrapper around `Mustache.render` so you get all the features. + +If your templates use partials you should pass paths to partials using `-p` flag: + +```bash +$ mustache -p path/to/partial1.mustache -p path/to/partial2.mustache dataView.json myTemplate.mustache +``` + +## Plugins for JavaScript Libraries + +mustache.js may be built specifically for several different client libraries, including the following: + + - [jQuery](http://jquery.com/) + - [MooTools](http://mootools.net/) + - [Dojo](http://www.dojotoolkit.org/) + - [YUI](http://developer.yahoo.com/yui/) + - [qooxdoo](http://qooxdoo.org/) + +These may be built using [Rake](http://rake.rubyforge.org/) and one of the following commands: +```bash +$ rake jquery +$ rake mootools +$ rake dojo +$ rake yui3 +$ rake qooxdoo +``` + +## TypeScript + +Since the source code of this package is written in JavaScript, we follow the [TypeScript publishing docs](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) preferred approach +by having type definitions available via [@types/mustache](https://www.npmjs.com/package/@types/mustache). + +## Testing + +In order to run the tests you'll need to install [Node.js](http://nodejs.org/). + +You also need to install the sub module containing [Mustache specifications](http://github.com/mustache/spec) in the project root. +```bash +$ git submodule init +$ git submodule update +``` +Install dependencies. +```bash +$ npm install +``` +Then run the tests. +```bash +$ npm test +``` +The test suite consists of both unit and integration tests. If a template isn't rendering correctly for you, you can make a test for it by doing the following: + + 1. Create a template file named `mytest.mustache` in the `test/_files` + directory. Replace `mytest` with the name of your test. + 2. Create a corresponding view file named `mytest.js` in the same directory. + This file should contain a JavaScript object literal enclosed in + parentheses. See any of the other view files for an example. + 3. Create a file with the expected output in `mytest.txt` in the same + directory. + +Then, you can run the test with: +```bash +$ TEST=mytest npm run test-render +``` + +### Browser tests + +Browser tests are not included in `npm test` as they run for too long, although they are ran automatically on Travis when merged into master. Run browser tests locally in any browser: +```bash +$ npm run test-browser-local +``` +then point your browser to `http://localhost:8080/__zuul` + +## Who uses mustache.js? + +An updated list of mustache.js users is kept [on the Github wiki](https://github.com/janl/mustache.js/wiki/Beard-Competition). Add yourself or your company if you use mustache.js! + +## Contributing + +mustache.js is a mature project, but it continues to actively invite maintainers. You can help out a high-profile project that is used in a lot of places on the web. No big commitment required, if all you do is review a single [Pull Request](https://github.com/janl/mustache.js/pulls), you are a maintainer. And a hero. + +### Your First Contribution + +- review a [Pull Request](https://github.com/janl/mustache.js/pulls) +- fix an [Issue](https://github.com/janl/mustache.js/issues) +- update the [documentation](https://github.com/janl/mustache.js#usage) +- make a website +- write a tutorial + +## Thanks + +mustache.js wouldn't kick ass if it weren't for these fine souls: + + * Chris Wanstrath / defunkt + * Alexander Lang / langalex + * Sebastian Cohnen / tisba + * J Chris Anderson / jchris + * Tom Robinson / tlrobinson + * Aaron Quint / quirkey + * Douglas Crockford + * Nikita Vasilyev / NV + * Elise Wood / glytch + * Damien Mathieu / dmathieu + * Jakub Kuźma / qoobaa + * Will Leinweber / will + * dpree + * Jason Smith / jhs + * Aaron Gibralter / agibralter + * Ross Boucher / boucher + * Matt Sanford / mzsanford + * Ben Cherry / bcherry + * Michael Jackson / mjackson + * Phillip Johnsen / phillipj + * David da Silva Contín / dasilvacontin diff --git a/node_modules/mustache/bin/mustache b/node_modules/mustache/bin/mustache new file mode 100644 index 0000000000000000000000000000000000000000..6db073f5ddebf3e0bc4a390783abfe650b92e7bb --- /dev/null +++ b/node_modules/mustache/bin/mustache @@ -0,0 +1,150 @@ +#!/usr/bin/env node + +var fs = require('fs'), + path = require('path'); + +var Mustache = require('..'); +var pkg = require('../package'); +var partials = {}; + +var partialsPaths = []; +var partialArgIndex = -1; + +while ((partialArgIndex = process.argv.indexOf('-p')) > -1) { + partialsPaths.push(process.argv.splice(partialArgIndex, 2)[1]); +} + +var viewArg = process.argv[2]; +var templateArg = process.argv[3]; +var outputArg = process.argv[4]; + +if (hasVersionArg()) { + return console.log(pkg.version); +} + +if (!templateArg || !viewArg) { + console.error('Syntax: mustache