WIP: bootstrap and partial real Solana watcher implementation

This commit is contained in:
2026-08-16 09:17:45 +00:00
commit dc23412c3f
7232 changed files with 1687637 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
'use strict'
let user
try {
user = process.platform === 'win32' ? process.env.USERNAME : process.env.USER
} catch {
// ignore, e.g., Deno without --allow-env
}
module.exports = {
// database host. defaults to localhost
host: 'localhost',
// database user's name
user,
// name of database to connect
database: undefined,
// database user's password
password: null,
// a Postgres connection string to be used instead of setting individual connection items
// NOTE: Setting this value will cause it to override any other value (such as database or user) defined
// in the defaults object.
connectionString: undefined,
// database port
port: 5432,
// number of rows to return at a time from a prepared statement's
// portal. 0 will return all rows at once
rows: 0,
// binary result mode
binary: false,
// Connection pool options - see https://github.com/brianc/node-pg-pool
// number of connections to use in connection pool
// 0 will disable connection pooling
max: 10,
// max milliseconds a client can go unused before it is removed
// from the pool and destroyed
idleTimeoutMillis: 30000,
client_encoding: '',
ssl: false,
// SSL negotiation style: 'postgres' (traditional SSLRequest) or 'direct'
sslnegotiation: undefined,
application_name: undefined,
fallback_application_name: undefined,
options: undefined,
parseInputDatesAsUTC: false,
// max milliseconds any query using this connection will execute for before timing out in error.
// false=unlimited
statement_timeout: false,
// Abort any statement that waits longer than the specified duration in milliseconds while attempting to acquire a lock.
// false=unlimited
lock_timeout: false,
// Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds
// false=unlimited
idle_in_transaction_session_timeout: false,
// max milliseconds to wait for query to complete (client side)
query_timeout: false,
connect_timeout: 0,
keepalives: 1,
keepalives_idle: 0,
}
const pgTypes = require('pg-types')
// save default parsers
const parseBigInteger = pgTypes.getTypeParser(20, 'text')
const parseBigIntegerArray = pgTypes.getTypeParser(1016, 'text')
// parse int8 so you can get your count values as actual numbers
module.exports.__defineSetter__('parseInt8', function (val) {
pgTypes.setTypeParser(20, 'text', val ? pgTypes.getTypeParser(23, 'text') : parseBigInteger)
pgTypes.setTypeParser(1016, 'text', val ? pgTypes.getTypeParser(1007, 'text') : parseBigIntegerArray)
})

View File

@@ -0,0 +1,51 @@
/**
* @fileoverview Rule to enforce `default` clauses in `switch` statements to be last
* @author Milos Djermanovic
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description:
"Enforce `default` clauses in `switch` statements to be last",
recommended: false,
url: "https://eslint.org/docs/latest/rules/default-case-last",
},
schema: [],
messages: {
notLast: "Default clause should be the last clause.",
},
},
create(context) {
return {
SwitchStatement(node) {
const cases = node.cases,
indexOfDefault = cases.findIndex(c => c.test === null);
if (
indexOfDefault !== -1 &&
indexOfDefault !== cases.length - 1
) {
const defaultClause = cases[indexOfDefault];
context.report({
node: defaultClause,
messageId: "notLast",
});
}
},
};
},
};

View File

@@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,IAAkB;IAC1C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE;YAC5B,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC/B;QACD,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACrB;SAAM;QACN,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;KACf;AACF,CAAC;AAED,MAAM,iBAAiB,GAAU;IAChC,OAAO,KAAK,GAAG,GAAG,GAAG,GAAG,CAAC;AAC1B,CAAC;AAED,MAAM,iBAAiB,CAAK;IAC3B,OAAO,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AACpJ,CAAC;AAED,MAAM,sBAAsB,GAAU;IACrC,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,kBAAkB,GAAO;IAC9B,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvM,CAAC;AAGD,MAAM,iBAAiB,MAAc,EAAE,MAAW;IACjD,MAAM,GAAG,GAAG,MAAa,CAAC;IAC1B,IAAI,MAAM,EAAE;QACX,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;YACzB,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;SACvB;KACD;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}

View File

@@ -0,0 +1,62 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.inferSingleRun = inferSingleRun;
const node_path_1 = __importDefault(require("node:path"));
/**
* ESLint (and therefore typescript-eslint) is used in both "single run"/one-time contexts,
* such as an ESLint CLI invocation, and long-running sessions (such as continuous feedback
* on a file in an IDE).
*
* When typescript-eslint handles TypeScript Program management behind the scenes, this distinction
* is important because there is significant overhead to managing the so called Watch Programs
* needed for the long-running use-case. We therefore use the following logic to figure out which
* of these contexts applies to the current execution.
*
* @returns Whether this is part of a single run, rather than a long-running process.
*/
function inferSingleRun(options) {
// https://github.com/typescript-eslint/typescript-eslint/issues/9504
// There's no support (yet?) for extraFileExtensions in single-run hosts.
// Only watch program hosts and project service can support that.
if (options?.extraFileExtensions?.length && options.project) {
return false;
}
if (
// single-run implies type-aware linting - no projects means we can't be in single-run mode
(options?.project == null && !options?.projectService) ||
// programs passed via options means the user should be managing the programs, so we shouldn't
// be creating our own single-run programs accidentally
options.programs != null) {
return false;
}
// Allow users to explicitly inform us of their intent to perform a single run (or not) with TSESTREE_SINGLE_RUN
if (process.env.TSESTREE_SINGLE_RUN === 'false') {
return false;
}
if (process.env.TSESTREE_SINGLE_RUN === 'true') {
return true;
}
// Ideally, we'd like to try to auto-detect CI or CLI usage that lets us infer a single CLI run.
if (!options.disallowAutomaticSingleRunInference) {
const possibleEslintBinPaths = [
'node_modules/.bin/eslint', // npm or yarn repo
'node_modules/eslint/bin/eslint.js', // pnpm repo
];
if (
// Default to single runs for CI processes. CI=true is set by most CI providers by default.
process.env.CI === 'true' ||
// This will be true for invocations such as `npx eslint ...` and `./node_modules/.bin/eslint ...`
possibleEslintBinPaths.some(binPath => process.argv.length > 1 &&
process.argv[1].endsWith(node_path_1.default.normalize(binPath)))) {
return !process.argv.includes('--fix');
}
}
/**
* Unless we can reliably infer otherwise, we default to assuming that this run could be part
* of a long-running session (e.g. in an IDE) and watch programs will therefore be required
*/
return false;
}

View File

@@ -0,0 +1,35 @@
import type * as core from "./core.cjs";
import type { $ZodType } from "./schemas.cjs";
export declare const $output: unique symbol;
export type $output = typeof $output;
export declare const $input: unique symbol;
export type $input = typeof $input;
export type $replace<Meta, S extends $ZodType> = Meta extends $output ? core.output<S> : Meta extends $input ? core.input<S> : Meta extends (infer M)[] ? $replace<M, S>[] : Meta extends (...args: infer P) => infer R ? (...args: {
[K in keyof P]: $replace<P[K], S>;
}) => $replace<R, S> : Meta extends object ? {
[K in keyof Meta]: $replace<Meta[K], S>;
} : Meta;
type MetadataType = object | undefined;
export declare class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
_meta: Meta;
_schema: Schema;
_map: WeakMap<Schema, $replace<Meta, Schema>>;
_idmap: Map<string, Schema>;
add<S extends Schema>(schema: S, ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]): this;
clear(): this;
remove(schema: Schema): this;
get<S extends Schema>(schema: S): $replace<Meta, S> | undefined;
has(schema: Schema): boolean;
}
export interface JSONSchemaMeta {
id?: string | undefined;
title?: string | undefined;
description?: string | undefined;
deprecated?: boolean | undefined;
[k: string]: unknown;
}
export interface GlobalMeta extends JSONSchemaMeta {
}
export declare function registry<T extends MetadataType = MetadataType, S extends $ZodType = $ZodType>(): $ZodRegistry<T, S>;
export declare const globalRegistry: $ZodRegistry<GlobalMeta>;
export {};

View File

@@ -0,0 +1,36 @@
import { expect, test } from "vitest";
import * as z from "zod/mini";
import { util as zc } from "zod/v4/core";
test("min/max", () => {
const a = z.number().check(z.minimum(5), z.minimum(6), z.minimum(7), z.maximum(10), z.maximum(11), z.maximum(12));
expect(a._zod.bag.minimum).toEqual(7);
expect(a._zod.bag.maximum).toEqual(10);
});
test("multipleOf", () => {
const b = z.number().check(z.multipleOf(5));
expect(b._zod.bag.multipleOf).toEqual(5);
});
test("int64 format", () => {
const c = z.int64();
expect(c._zod.bag.format).toEqual("int64");
expect(c._zod.bag.minimum).toEqual(zc.BIGINT_FORMAT_RANGES.int64[0]);
expect(c._zod.bag.maximum).toEqual(zc.BIGINT_FORMAT_RANGES.int64[1]);
});
test("int32 format", () => {
const d = z.int32();
expect(d._zod.bag.format).toEqual("int32");
expect(d._zod.bag.minimum).toEqual(zc.NUMBER_FORMAT_RANGES.int32[0]);
expect(d._zod.bag.maximum).toEqual(zc.NUMBER_FORMAT_RANGES.int32[1]);
});
test("array size", () => {
const e = z.array(z.string()).check(z.length(5));
expect(e._zod.bag.length).toEqual(5);
expect(e._zod.bag.minimum).toEqual(5);
expect(e._zod.bag.maximum).toEqual(5);
});

View File

@@ -0,0 +1,8 @@
import type { TSESTree } from '@typescript-eslint/types';
import type { ScopeManager } from '../ScopeManager';
import type { Scope } from './Scope';
import { ScopeBase } from './ScopeBase';
import { ScopeType } from './ScopeType';
export declare class ClassFieldInitializerScope extends ScopeBase<ScopeType.classFieldInitializer, TSESTree.Expression, Scope> {
constructor(scopeManager: ScopeManager, upperScope: ClassFieldInitializerScope['upper'], block: ClassFieldInitializerScope['block']);
}

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2016 David Frank
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.

View File

@@ -0,0 +1,22 @@
'use strict'
const build = require('../..')
module.exports = async function (threadStreamOpts) {
const { port, opts = {} } = threadStreamOpts
return build(
async function (source) {
for await (const obj of source) {
port.postMessage({
data: obj,
pinoConfig: {
levels: source.levels,
messageKey: source.messageKey,
errorKey: source.errorKey
}
})
}
},
opts
)
}

View File

@@ -0,0 +1 @@
{"version":3,"file":"scriptKind.enum.d.ts","sourceRoot":"","sources":["../../src/enums/scriptKind.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IAClB,OAAO,IAAI;IACX,EAAE,IAAI;IACN,GAAG,IAAI;IACP,EAAE,IAAI;IACN,GAAG,IAAI;IACP,QAAQ,IAAI;IACZ,IAAI,IAAI;IACR,QAAQ,IAAI;CACf"}

View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2011-2012 Tedde Lundgren <mail@tedeh.net>
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.

View File

@@ -0,0 +1,41 @@
{
"name": "pgpass",
"version": "1.0.5",
"description": "Module for reading .pgpass",
"main": "lib/index",
"scripts": {
"pretest": "chmod 600 ./test/_pgpass",
"_hint": "jshint --exclude node_modules --verbose lib test",
"_test": "mocha --recursive -R list",
"_covered_test": "nyc --reporter html --reporter text \"$npm_execpath\" run _test",
"test": "\"$npm_execpath\" run _hint && \"$npm_execpath\" run _covered_test"
},
"author": "Hannes Hörl <hannes.hoerl+pgpass@snowreporter.com>",
"license": "MIT",
"dependencies": {
"split2": "^4.1.0"
},
"devDependencies": {
"jshint": "^2.12.0",
"mocha": "^8.2.0",
"nyc": "^15.1.0",
"pg": "^8.4.1",
"pg-escape": "^0.2.0",
"pg-native": "3.0.0",
"resumer": "0.0.0",
"tmp": "^0.2.1",
"which": "^2.0.2"
},
"keywords": [
"postgres",
"pg",
"pgpass",
"password",
"postgresql"
],
"bugs": "https://github.com/hoegaarden/pgpass/issues",
"repository": {
"type": "git",
"url": "https://github.com/hoegaarden/pgpass.git"
}
}

View File

@@ -0,0 +1,12 @@
import type { TSESTree } from '@typescript-eslint/types';
import { DefinitionBase } from './DefinitionBase';
import { DefinitionType } from './DefinitionType';
export declare class ParameterDefinition extends DefinitionBase<DefinitionType.Parameter, TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructorType | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunction | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignature, null, TSESTree.BindingName> {
/**
* Whether the parameter definition is a part of a rest parameter.
*/
readonly isTypeDefinition = false;
readonly isVariableDefinition = true;
readonly rest: boolean;
constructor(name: TSESTree.BindingName, node: ParameterDefinition['node'], rest: boolean);
}

View File

@@ -0,0 +1,87 @@
{
"name": "jayson",
"version": "4.3.0",
"description": "JSON-RPC 1.0/2.0 compliant server and client",
"license": "MIT",
"keywords": [
"jsonrpc",
"json-rpc",
"rpc",
"json",
"jsonrpc-2.0",
"jsonrpc-1.0",
"middleware",
"connect",
"express",
"fork",
"distributed",
"relay",
"http",
"tcp",
"https",
"tls",
"api"
],
"author": "Tedde Lundgren <mail@tedeh.net> (https://tedeh.net)",
"maintainers": [
"Tedde Lundgren <mail@tedeh.net> (https://tedeh.net)"
],
"bin": "./bin/jayson.js",
"repository": {
"type": "git",
"url": "git://github.com/tedeh/jayson.git"
},
"homepage": "https://jayson.tedeh.net",
"bugs": "https://github.com/tedeh/jayson/issues",
"contributors": [
"Tedde Lundgren <mail@tedeh.net> (https://tedeh.net)",
"Daniel Vicory <dvicory@gmail.com> (http://bzfx.net)",
"Jonathan Liu <net147@gmail.com>"
],
"scripts": {
"test": "mocha",
"test-ci": "mocha -w -R min",
"test-tsc": "tsc --strict --lib es6 --esModuleInterop typescript/test.ts",
"coverage": "nyc mocha",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"docs": "jsdoc -t node_modules/ink-docstrap/template -R README.md -c ./jsdoc.conf.json",
"lint": "jshint lib/*.js lib/**/*.js promise/*.js promise/**/*.js; exit 0"
},
"dependencies": {
"@types/connect": "^3.4.33",
"@types/node": "^12.12.54",
"@types/ws": "^7.4.4",
"commander": "^2.20.3",
"delay": "^5.0.0",
"es6-promisify": "^5.0.0",
"eyes": "^0.1.8",
"isomorphic-ws": "^4.0.1",
"json-stringify-safe": "^5.0.1",
"stream-json": "^1.9.1",
"uuid": "^8.3.2",
"ws": "^7.5.10"
},
"devDependencies": {
"@types/express-serve-static-core": "^4.17.30",
"body-parser": "^1.19.0",
"connect": "^3.7.0",
"coveralls-next": "^6.0.1",
"es6-promise": "^4.2.8",
"express": "^4.17.1",
"ink-docstrap": "github:docstrap/docstrap#pull/345/head",
"jsdoc": "^4.0.2",
"jshint": "^2.12.0",
"mocha": "^10.2.0",
"mocha-lcov-reporter": "^1.3.0",
"node-fetch": "^2.7.0",
"nyc": "^17.1.0",
"pass-stream": "^1.0.0",
"should": "^13.2.3",
"superagent": "^3.8.3",
"typescript": "^4.7.4"
},
"engines": {
"node": ">=8"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeToCurve = exports.hashToCurve = exports.secp384r1 = exports.p384 = void 0;
const nist_ts_1 = require("./nist.js");
/** @deprecated use `import { p384 } from '@noble/curves/nist.js';` */
exports.p384 = nist_ts_1.p384;
/** @deprecated use `import { p384 } from '@noble/curves/nist.js';` */
exports.secp384r1 = nist_ts_1.p384;
/** @deprecated use `import { p384_hasher } from '@noble/curves/nist.js';` */
exports.hashToCurve = (() => nist_ts_1.p384_hasher.hashToCurve)();
/** @deprecated use `import { p384_hasher } from '@noble/curves/nist.js';` */
exports.encodeToCurve = (() => nist_ts_1.p384_hasher.encodeToCurve)();
//# sourceMappingURL=p384.js.map

View File

@@ -0,0 +1,452 @@
| Linux / MacOS / Windows | Coverage | Downloads |
| ----------------------- | -------- | --------- |
| [![build][bb]][bl] | [![coverage][cb]][cl] | [![downloads][db]][dl] |
[bb]: https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml/badge.svg
[bl]: https://github.com/kaelzhang/node-ignore/actions/workflows/nodejs.yml
[cb]: https://codecov.io/gh/kaelzhang/node-ignore/branch/master/graph/badge.svg
[cl]: https://codecov.io/gh/kaelzhang/node-ignore
[db]: http://img.shields.io/npm/dm/ignore.svg
[dl]: https://www.npmjs.org/package/ignore
# ignore
`ignore` is a manager, filter and parser which implemented in pure JavaScript according to the [.gitignore spec 2.22.1](http://git-scm.com/docs/gitignore).
`ignore` is used by eslint, gitbook and [many others](https://www.npmjs.com/browse/depended/ignore).
Pay **ATTENTION** that [`minimatch`](https://www.npmjs.org/package/minimatch) (which used by `fstream-ignore`) does not follow the gitignore spec.
To filter filenames according to a .gitignore file, I recommend this npm package, `ignore`.
To parse an `.npmignore` file, you should use `minimatch`, because an `.npmignore` file is parsed by npm using `minimatch` and it does not work in the .gitignore way.
### Tested on
`ignore` is fully tested, and has more than **five hundreds** of unit tests.
- Linux + Node: `0.8` - `7.x`
- Windows + Node: `0.10` - `7.x`, node < `0.10` is not tested due to the lack of support of appveyor.
Actually, `ignore` does not rely on any versions of node specially.
Since `4.0.0`, ignore will no longer support `node < 6` by default, to use in node < 6, `require('ignore/legacy')`. For details, see [CHANGELOG](https://github.com/kaelzhang/node-ignore/blob/master/CHANGELOG.md).
## Table Of Main Contents
- [Usage](#usage)
- [`Pathname` Conventions](#pathname-conventions)
- See Also:
- [`glob-gitignore`](https://www.npmjs.com/package/glob-gitignore) matches files using patterns and filters them according to gitignore rules.
- [Upgrade Guide](#upgrade-guide)
## Install
```sh
npm i ignore
```
## Usage
```js
import ignore from 'ignore'
const ig = ignore().add(['.abc/*', '!.abc/d/'])
```
### Filter the given paths
```js
const paths = [
'.abc/a.js', // filtered out
'.abc/d/e.js' // included
]
ig.filter(paths) // ['.abc/d/e.js']
ig.ignores('.abc/a.js') // true
```
### As the filter function
```js
paths.filter(ig.createFilter()); // ['.abc/d/e.js']
```
### Win32 paths will be handled
```js
ig.filter(['.abc\\a.js', '.abc\\d\\e.js'])
// if the code above runs on windows, the result will be
// ['.abc\\d\\e.js']
```
## Why another ignore?
- `ignore` is a standalone module, and is much simpler so that it could easy work with other programs, unlike [isaacs](https://npmjs.org/~isaacs)'s [fstream-ignore](https://npmjs.org/package/fstream-ignore) which must work with the modules of the fstream family.
- `ignore` only contains utility methods to filter paths according to the specified ignore rules, so
- `ignore` never try to find out ignore rules by traversing directories or fetching from git configurations.
- `ignore` don't cares about sub-modules of git projects.
- Exactly according to [gitignore man page](http://git-scm.com/docs/gitignore), fixes some known matching issues of fstream-ignore, such as:
- '`/*.js`' should only match '`a.js`', but not '`abc/a.js`'.
- '`**/foo`' should match '`foo`' anywhere.
- Prevent re-including a file if a parent directory of that file is excluded.
- Handle trailing whitespaces:
- `'a '`(one space) should not match `'a '`(two spaces).
- `'a \ '` matches `'a '`
- All test cases are verified with the result of `git check-ignore`.
# Methods
## .add(pattern: string | Ignore): this
## .add(patterns: Array<string | Ignore>): this
## .add({pattern: string, mark?: string}): this since 7.0.0
- **pattern** `string | Ignore` An ignore pattern string, or the `Ignore` instance
- **patterns** `Array<string | Ignore>` Array of ignore patterns.
- **mark?** `string` Pattern mark, which is used to associate the pattern with a certain marker, such as the line no of the `.gitignore` file. Actually it could be an arbitrary string and is optional.
Adds a rule or several rules to the current manager.
Returns `this`
Notice that a line starting with `'#'`(hash) is treated as a comment. Put a backslash (`'\'`) in front of the first hash for patterns that begin with a hash, if you want to ignore a file with a hash at the beginning of the filename.
```js
ignore().add('#abc').ignores('#abc') // false
ignore().add('\\#abc').ignores('#abc') // true
```
`pattern` could either be a line of ignore pattern or a string of multiple ignore patterns, which means we could just `ignore().add()` the content of a ignore file:
```js
ignore()
.add(fs.readFileSync(filenameOfGitignore).toString())
.filter(filenames)
```
`pattern` could also be an `ignore` instance, so that we could easily inherit the rules of another `Ignore` instance.
## .ignores(pathname: [Pathname](#pathname-conventions)): boolean
> new in 3.2.0
Returns `Boolean` whether `pathname` should be ignored.
```js
ig.ignores('.abc/a.js') // true
```
Please **PAY ATTENTION** that `.ignores()` is **NOT** equivalent to `git check-ignore` although in most cases they return equivalent results.
However, for the purposes of imitating the behavior of `git check-ignore`, please use `.checkIgnore()` instead.
### `Pathname` Conventions:
#### 1. `Pathname` should be a `path.relative()`d pathname
`Pathname` should be a string that have been `path.join()`ed, or the return value of `path.relative()` to the current directory,
```js
// WRONG, an error will be thrown
ig.ignores('./abc')
// WRONG, for it will never happen, and an error will be thrown
// If the gitignore rule locates at the root directory,
// `'/abc'` should be changed to `'abc'`.
// ```
// path.relative('/', '/abc') -> 'abc'
// ```
ig.ignores('/abc')
// WRONG, that it is an absolute path on Windows, an error will be thrown
ig.ignores('C:\\abc')
// Right
ig.ignores('abc')
// Right
ig.ignores(path.join('./abc')) // path.join('./abc') -> 'abc'
```
In other words, each `Pathname` here should be a relative path to the directory of the gitignore rules.
Suppose the dir structure is:
```
/path/to/your/repo
|-- a
| |-- a.js
|
|-- .b
|
|-- .c
|-- .DS_store
```
Then the `paths` might be like this:
```js
[
'a/a.js'
'.b',
'.c/.DS_store'
]
```
#### 2. filenames and dirnames
`node-ignore` does NO `fs.stat` during path matching, so `node-ignore` treats
- `foo` as a file
- **`foo/` as a directory**
For the example below:
```js
// First, we add a ignore pattern to ignore a directory
ig.add('config/')
// `ig` does NOT know if 'config', in the real world,
// is a normal file, directory or something.
ig.ignores('config')
// `ig` treats `config` as a file, so it returns `false`
ig.ignores('config/')
// returns `true`
```
Specially for people who develop some library based on `node-ignore`, it is important to understand that.
Usually, you could use [`glob`](http://npmjs.org/package/glob) with `option.mark = true` to fetch the structure of the current directory:
```js
import glob from 'glob'
glob('**', {
// Adds a / character to directory matches.
mark: true
}, (err, files) => {
if (err) {
return console.error(err)
}
let filtered = ignore().add(patterns).filter(files)
console.log(filtered)
})
```
## .filter(paths: Array&lt;Pathname&gt;): Array&lt;Pathname&gt;
```ts
type Pathname = string
```
Filters the given array of pathnames, and returns the filtered array.
- **paths** `Array.<Pathname>` The array of `pathname`s to be filtered.
## .createFilter()
Creates a filter function which could filter an array of paths with `Array.prototype.filter`.
Returns `function(path)` the filter function.
## .test(pathname: Pathname): TestResult
> New in 5.0.0
Returns `TestResult`
```ts
// Since 5.0.0
interface TestResult {
ignored: boolean
// true if the `pathname` is finally unignored by some negative pattern
unignored: boolean
// The `IgnoreRule` which ignores the pathname
rule?: IgnoreRule
}
// Since 7.0.0
interface IgnoreRule {
// The original pattern
pattern: string
// Whether the pattern is a negative pattern
negative: boolean
// Which is used for other packages to build things upon `node-ignore`
mark?: string
}
```
- `{ignored: true, unignored: false}`: the `pathname` is ignored
- `{ignored: false, unignored: true}`: the `pathname` is unignored
- `{ignored: false, unignored: false}`: the `pathname` is never matched by any ignore rules.
## .checkIgnore(target: string): TestResult
> new in 7.0.0
Debugs gitignore / exclude files, which is equivalent to `git check-ignore -v`. Usually this method is used for other packages to implement the function of `git check-ignore -v` upon `node-ignore`
- **target** `string` the target to test.
Returns `TestResult`
```js
ig.add({
pattern: 'foo/*',
mark: '60'
})
const {
ignored,
rule
} = checkIgnore('foo/')
if (ignored) {
console.log(`.gitignore:${result}:${rule.mark}:${rule.pattern} foo/`)
}
// .gitignore:60:foo/* foo/
```
Please pay attention that this method does not have a strong built-in cache mechanism.
The purpose of introducing this method is to make it possible to implement the `git check-ignore` command in JavaScript based on `node-ignore`.
So do not use this method in those situations where performance is extremely important.
## static `isPathValid(pathname): boolean` since 5.0.0
Check whether the `pathname` is an valid `path.relative()`d path according to the [convention](#1-pathname-should-be-a-pathrelatived-pathname).
This method is **NOT** used to check if an ignore pattern is valid.
```js
import {isPathValid} from 'ignore'
isPathValid('./foo') // false
```
## <strike>.addIgnoreFile(path)</strike>
REMOVED in `3.x` for now.
To upgrade `ignore@2.x` up to `3.x`, use
```js
import fs from 'fs'
if (fs.existsSync(filename)) {
ignore().add(fs.readFileSync(filename).toString())
}
```
instead.
## ignore(options)
### `options.ignorecase` since 4.0.0
Similar to the `core.ignorecase` option of [git-config](https://git-scm.com/docs/git-config), `node-ignore` will be case insensitive if `options.ignorecase` is set to `true` (the default value), otherwise case sensitive.
```js
const ig = ignore({
ignorecase: false
})
ig.add('*.png')
ig.ignores('*.PNG') // false
```
### `options.ignoreCase?: boolean` since 5.2.0
Which is an alternative to `options.ignoreCase`
### `options.allowRelativePaths?: boolean` since 5.2.0
This option brings backward compatibility with projects which based on `ignore@4.x`. If `options.allowRelativePaths` is `true`, `ignore` will not check whether the given path to be tested is [`path.relative()`d](#pathname-conventions).
However, passing a relative path, such as `'./foo'` or `'../foo'`, to test if it is ignored or not is not a good practise, which might lead to unexpected behavior
```js
ignore({
allowRelativePaths: true
}).ignores('../foo/bar.js') // And it will not throw
```
****
# Upgrade Guide
## Upgrade 4.x -> 5.x
Since `5.0.0`, if an invalid `Pathname` passed into `ig.ignores()`, an error will be thrown, unless `options.allowRelative = true` is passed to the `Ignore` factory.
While `ignore < 5.0.0` did not make sure what the return value was, as well as
```ts
.ignores(pathname: Pathname): boolean
.filter(pathnames: Array<Pathname>): Array<Pathname>
.createFilter(): (pathname: Pathname) => boolean
.test(pathname: Pathname): {ignored: boolean, unignored: boolean}
```
See the convention [here](#1-pathname-should-be-a-pathrelatived-pathname) for details.
If there are invalid pathnames, the conversion and filtration should be done by users.
```js
import {isPathValid} from 'ignore' // introduced in 5.0.0
const paths = [
// invalid
//////////////////
'',
false,
'../foo',
'.',
//////////////////
// valid
'foo'
]
.filter(isPathValid)
ig.filter(paths)
```
## Upgrade 3.x -> 4.x
Since `4.0.0`, `ignore` will no longer support node < 6, to use `ignore` in node < 6:
```js
var ignore = require('ignore/legacy')
```
## Upgrade 2.x -> 3.x
- All `options` of 2.x are unnecessary and removed, so just remove them.
- `ignore()` instance is no longer an [`EventEmitter`](nodejs.org/api/events.html), and all events are unnecessary and removed.
- `.addIgnoreFile()` is removed, see the [.addIgnoreFile](#addignorefilepath) section for details.
****
# Collaborators
- [@whitecolor](https://github.com/whitecolor) *Alex*
- [@SamyPesse](https://github.com/SamyPesse) *Samy Pessé*
- [@azproduction](https://github.com/azproduction) *Mikhail Davydov*
- [@TrySound](https://github.com/TrySound) *Bogdan Chadkin*
- [@JanMattner](https://github.com/JanMattner) *Jan Mattner*
- [@ntwb](https://github.com/ntwb) *Stephen Edgar*
- [@kasperisager](https://github.com/kasperisager) *Kasper Isager*
- [@sandersn](https://github.com/sandersn) *Nathan Shively-Sanders*

View File

@@ -0,0 +1,9 @@
(function () {
require('./lib/main').config(
Object.assign(
{},
require('./lib/env-options'),
require('./lib/cli-options')(process.argv)
)
)
})()

View File

@@ -0,0 +1,46 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface SymbolConstructor {
/**
* A reference to the prototype.
*/
readonly prototype: Symbol;
/**
* Returns a new unique Symbol value.
* @param description Description of the new Symbol object.
*/
(description?: string | number): symbol;
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Otherwise, returns a new symbol with this key.
* @param key key to search for.
*/
for(key: string): symbol;
/**
* Returns a key from the global symbol registry matching the given Symbol if found.
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
keyFor(sym: symbol): string | undefined;
}
declare var Symbol: SymbolConstructor;

View File

@@ -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

View File

@@ -0,0 +1,978 @@
// Code generated by _scripts/generate-ts-ast.ts. DO NOT EDIT.
import { SyntaxKind } from "#enums/syntaxKind";
import { createNodeArray, updateArrayBindingPattern, updateArrayLiteralExpression, updateArrayTypeNode, updateArrowFunction, updateAsExpression, updateAwaitExpression, updateBinaryExpression, updateBindingElement, updateBlock, updateBreakStatement, updateCallExpression, updateCallSignatureDeclaration, updateCaseBlock, updateCaseClause, updateCatchClause, updateClassDeclaration, updateClassExpression, updateClassStaticBlockDeclaration, updateComputedPropertyName, updateConditionalExpression, updateConditionalTypeNode, updateConstructorDeclaration, updateConstructorTypeNode, updateConstructSignatureDeclaration, updateContinueStatement, updateDecorator, updateDefaultClause, updateDeleteExpression, updateDoStatement, updateElementAccessExpression, updateEnumDeclaration, updateEnumMember, updateExportAssignment, updateExportDeclaration, updateExportSpecifier, updateExpressionStatement, updateExpressionWithTypeArguments, updateExternalModuleReference, updateForInStatement, updateForOfStatement, updateForStatement, updateFunctionDeclaration, updateFunctionExpression, updateFunctionTypeNode, updateGetAccessorDeclaration, updateHeritageClause, updateIfStatement, updateImportAttribute, updateImportAttributes, updateImportClause, updateImportDeclaration, updateImportEqualsDeclaration, updateImportSpecifier, updateImportTypeNode, updateIndexedAccessTypeNode, updateIndexSignatureDeclaration, updateInferTypeNode, updateInterfaceDeclaration, updateIntersectionTypeNode, updateJSDoc, updateJSDocAugmentsTag, updateJSDocCallbackTag, updateJSDocDeprecatedTag, updateJSDocImplementsTag, updateJSDocImportTag, updateJSDocLink, updateJSDocLinkCode, updateJSDocLinkPlain, updateJSDocNameReference, updateJSDocNonNullableType, updateJSDocNullableType, updateJSDocOptionalType, updateJSDocOverloadTag, updateJSDocOverrideTag, updateJSDocPrivateTag, updateJSDocProtectedTag, updateJSDocPublicTag, updateJSDocReadonlyTag, updateJSDocReturnTag, updateJSDocSatisfiesTag, updateJSDocSeeTag, updateJSDocSignature, updateJSDocTemplateTag, updateJSDocThisTag, updateJSDocThrowsTag, updateJSDocTypedefTag, updateJSDocTypeExpression, updateJSDocTypeLiteral, updateJSDocTypeTag, updateJSDocUnknownTag, updateJSDocVariadicType, updateJsxAttribute, updateJsxAttributes, updateJsxClosingElement, updateJsxElement, updateJsxExpression, updateJsxFragment, updateJsxNamespacedName, updateJsxOpeningElement, updateJsxSelfClosingElement, updateJsxSpreadAttribute, updateLabeledStatement, updateLiteralTypeNode, updateMappedTypeNode, updateMetaProperty, updateMethodDeclaration, updateMethodSignatureDeclaration, updateMissingDeclaration, updateModuleBlock, updateModuleDeclaration, updateNamedExports, updateNamedImports, updateNamedTupleMember, updateNamespaceExport, updateNamespaceExportDeclaration, updateNamespaceImport, updateNewExpression, updateNonNullExpression, updateObjectBindingPattern, updateObjectLiteralExpression, updateOptionalTypeNode, updateParameterDeclaration, updateParenthesizedExpression, updateParenthesizedTypeNode, updatePartiallyEmittedExpression, updatePostfixUnaryExpression, updatePrefixUnaryExpression, updatePropertyAccessExpression, updatePropertyAssignment, updatePropertyDeclaration, updatePropertySignatureDeclaration, updateQualifiedName, updateRestTypeNode, updateReturnStatement, updateSatisfiesExpression, updateSetAccessorDeclaration, updateShorthandPropertyAssignment, updateSourceFile, updateSpreadAssignment, updateSpreadElement, updateSwitchStatement, updateSyntaxList, updateSyntheticExpression, updateSyntheticReferenceExpression, updateTaggedTemplateExpression, updateTemplateExpression, updateTemplateLiteralTypeNode, updateTemplateLiteralTypeSpan, updateTemplateSpan, updateThrowStatement, updateTryStatement, updateTupleTypeNode, updateTypeAliasDeclaration, updateTypeAssertion, updateTypeLiteralNode, updateTypeOfExpression, updateTypeOperatorNode, updateTypeParameterDeclaration, updateTypePredicateNode, updateTypeQueryNode, updateTypeReferenceNode, updateUnionTypeNode, updateVariableDeclaration, updateVariableDeclarationList, updateVariableStatement, updateVoidExpression, updateWhileStatement, updateWithStatement, updateYieldExpression, } from "./factory.generated.js";
import { isAssertsKeyword, isAsteriskToken, isAwaitKeyword, isBinaryOperatorToken, isBindingName, isBlock, isCaseBlock, isCatchClause, isColonToken, isConciseBody, isDotDotDotToken, isEndOfFile, isEntityName, isEqualsGreaterThanToken, isEqualsToken, isExclamationToken, isExpression, isExpressionWithTypeArguments, isForInitializer, isFunctionBody, isIdentifier, isImportAttributeName, isImportAttributes, isImportClause, isJSDocFullName, isJsxAttributeName, isJsxAttributes, isJsxAttributeValue, isJsxClosingElement, isJsxClosingFragment, isJsxOpeningElement, isJsxOpeningFragment, isJsxTagNameExpression, isLeftHandSideExpression, isMemberName, isModuleBody, isModuleExportName, isModuleName, isModuleReference, isNamedExportBindings, isNamedImportBindings, isPropertyName, isQuestionDotToken, isQuestionOrExclamationToken, isQuestionOrPlusOrMinusToken, isQuestionToken, isReadonlyKeywordOrPlusOrMinusToken, isStatement, isTemplateHead, isTemplateLiteral, isTemplateMiddleOrTail, isTypeNode, isTypeParameterDeclaration, isTypePredicateParameterName, isVariableDeclaration, isVariableDeclarationList, } from "./is.js";
import { visitEachChildOfJSDocParameterTag, visitEachChildOfJSDocPropertyTag, } from "./visitor.js";
export function visitNode(node, visitor, test) {
if (node === undefined)
return undefined;
const visited = visitor(node);
if (visited !== undefined && test !== undefined && !test(visited)) {
throw new Error("Visited node failed test assertion.");
}
return visited;
}
export function visitNodes(nodes, visitor) {
if (nodes === undefined)
return undefined;
const updated = visitNodesArray(nodes, visitor);
if (updated === nodes) {
return nodes;
}
return createNodeArray(updated, nodes.pos, nodes.end);
}
export function visitNodesArray(nodes, visitor) {
if (nodes === undefined)
return undefined;
let updated;
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
const visited = visitor(node);
if (updated) {
if (visited)
updated.push(visited);
}
else if (visited !== node) {
updated = [];
for (let j = 0; j < i; j++)
updated.push(nodes[j]);
if (visited)
updated.push(visited);
}
}
return updated ?? nodes;
}
export function visitEachChild(node, visitor) {
if (node === undefined)
return undefined;
const fn = visitEachChildTable[node.kind];
return fn ? fn(node, visitor) : node;
}
const visitEachChildTable = {
[SyntaxKind.QualifiedName]: (node, visitor) => {
const _left = visitNode(node.left, visitor, isEntityName);
const _right = visitNode(node.right, visitor, isIdentifier);
return updateQualifiedName(node, _left, _right);
},
[SyntaxKind.ComputedPropertyName]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateComputedPropertyName(node, _expression);
},
[SyntaxKind.Decorator]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isLeftHandSideExpression);
return updateDecorator(node, _expression);
},
[SyntaxKind.IfStatement]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _thenStatement = visitNode(node.thenStatement, visitor, isStatement);
const _elseStatement = visitNode(node.elseStatement, visitor, isStatement);
return updateIfStatement(node, _expression, _thenStatement, _elseStatement);
},
[SyntaxKind.DoStatement]: (node, visitor) => {
const _statement = visitNode(node.statement, visitor, isStatement);
const _expression = visitNode(node.expression, visitor, isExpression);
return updateDoStatement(node, _statement, _expression);
},
[SyntaxKind.WhileStatement]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _statement = visitNode(node.statement, visitor, isStatement);
return updateWhileStatement(node, _expression, _statement);
},
[SyntaxKind.ForStatement]: (node, visitor) => {
const _initializer = visitNode(node.initializer, visitor, isForInitializer);
const _condition = visitNode(node.condition, visitor, isExpression);
const _incrementor = visitNode(node.incrementor, visitor, isExpression);
const _statement = visitNode(node.statement, visitor, isStatement);
return updateForStatement(node, _initializer, _condition, _incrementor, _statement);
},
[SyntaxKind.BreakStatement]: (node, visitor) => {
const _label = visitNode(node.label, visitor, isIdentifier);
return updateBreakStatement(node, _label);
},
[SyntaxKind.ContinueStatement]: (node, visitor) => {
const _label = visitNode(node.label, visitor, isIdentifier);
return updateContinueStatement(node, _label);
},
[SyntaxKind.ReturnStatement]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateReturnStatement(node, _expression);
},
[SyntaxKind.WithStatement]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _statement = visitNode(node.statement, visitor, isStatement);
return updateWithStatement(node, _expression, _statement);
},
[SyntaxKind.SwitchStatement]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _caseBlock = visitNode(node.caseBlock, visitor, isCaseBlock);
return updateSwitchStatement(node, _expression, _caseBlock);
},
[SyntaxKind.CaseBlock]: (node, visitor) => {
const _clauses = visitNodes(node.clauses, visitor);
return updateCaseBlock(node, _clauses);
},
[SyntaxKind.ThrowStatement]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateThrowStatement(node, _expression);
},
[SyntaxKind.TryStatement]: (node, visitor) => {
const _tryBlock = visitNode(node.tryBlock, visitor, isBlock);
const _catchClause = visitNode(node.catchClause, visitor, isCatchClause);
const _finallyBlock = visitNode(node.finallyBlock, visitor, isBlock);
return updateTryStatement(node, _tryBlock, _catchClause, _finallyBlock);
},
[SyntaxKind.CatchClause]: (node, visitor) => {
const _variableDeclaration = visitNode(node.variableDeclaration, visitor, isVariableDeclaration);
const _block = visitNode(node.block, visitor, isBlock);
return updateCatchClause(node, _variableDeclaration, _block);
},
[SyntaxKind.LabeledStatement]: (node, visitor) => {
const _label = visitNode(node.label, visitor, isIdentifier);
const _statement = visitNode(node.statement, visitor, isStatement);
return updateLabeledStatement(node, _label, _statement);
},
[SyntaxKind.ExpressionStatement]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateExpressionStatement(node, _expression);
},
[SyntaxKind.Block]: (node, visitor) => {
const _statements = visitNodes(node.statements, visitor);
return updateBlock(node, _statements);
},
[SyntaxKind.VariableStatement]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _declarationList = visitNode(node.declarationList, visitor, isVariableDeclarationList);
return updateVariableStatement(node, _modifiers, _declarationList);
},
[SyntaxKind.VariableDeclaration]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isBindingName);
const _exclamationToken = visitNode(node.exclamationToken, visitor, isExclamationToken);
const _type = visitNode(node.type, visitor, isTypeNode);
const _initializer = visitNode(node.initializer, visitor, isExpression);
return updateVariableDeclaration(node, _name, _exclamationToken, _type, _initializer);
},
[SyntaxKind.VariableDeclarationList]: (node, visitor) => {
const _declarations = visitNodes(node.declarations, visitor);
return updateVariableDeclarationList(node, _declarations);
},
[SyntaxKind.Parameter]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _dotDotDotToken = visitNode(node.dotDotDotToken, visitor, isDotDotDotToken);
const _name = visitNode(node.name, visitor, isBindingName);
const _questionToken = visitNode(node.questionToken, visitor, isQuestionToken);
const _type = visitNode(node.type, visitor, isTypeNode);
const _initializer = visitNode(node.initializer, visitor, isExpression);
return updateParameterDeclaration(node, _modifiers, _dotDotDotToken, _name, _questionToken, _type, _initializer);
},
[SyntaxKind.BindingElement]: (node, visitor) => {
const _dotDotDotToken = visitNode(node.dotDotDotToken, visitor, isDotDotDotToken);
const _propertyName = visitNode(node.propertyName, visitor, isPropertyName);
const _name = visitNode(node.name, visitor, isBindingName);
const _initializer = visitNode(node.initializer, visitor, isExpression);
return updateBindingElement(node, _dotDotDotToken, _propertyName, _name, _initializer);
},
[SyntaxKind.MissingDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
return updateMissingDeclaration(node, _modifiers);
},
[SyntaxKind.FunctionDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _asteriskToken = visitNode(node.asteriskToken, visitor, isAsteriskToken);
const _name = visitNode(node.name, visitor, isIdentifier);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
const _body = visitNode(node.body, visitor, isFunctionBody);
return updateFunctionDeclaration(node, _modifiers, _asteriskToken, _name, _typeParameters, _parameters, _type, _body);
},
[SyntaxKind.ClassDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _heritageClauses = visitNodes(node.heritageClauses, visitor);
const _members = visitNodes(node.members, visitor);
return updateClassDeclaration(node, _modifiers, _name, _typeParameters, _heritageClauses, _members);
},
[SyntaxKind.ClassExpression]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _heritageClauses = visitNodes(node.heritageClauses, visitor);
const _members = visitNodes(node.members, visitor);
return updateClassExpression(node, _modifiers, _name, _typeParameters, _heritageClauses, _members);
},
[SyntaxKind.HeritageClause]: (node, visitor) => {
const _types = visitNodes(node.types, visitor);
return updateHeritageClause(node, _types);
},
[SyntaxKind.InterfaceDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _heritageClauses = visitNodes(node.heritageClauses, visitor);
const _members = visitNodes(node.members, visitor);
return updateInterfaceDeclaration(node, _modifiers, _name, _typeParameters, _heritageClauses, _members);
},
[SyntaxKind.TypeAliasDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateTypeAliasDeclaration(node, _modifiers, _name, _typeParameters, _type);
},
[SyntaxKind.EnumMember]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isPropertyName);
const _initializer = visitNode(node.initializer, visitor, isExpression);
return updateEnumMember(node, _name, _initializer);
},
[SyntaxKind.EnumDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
const _members = visitNodes(node.members, visitor);
return updateEnumDeclaration(node, _modifiers, _name, _members);
},
[SyntaxKind.ModuleBlock]: (node, visitor) => {
const _statements = visitNodes(node.statements, visitor);
return updateModuleBlock(node, _statements);
},
[SyntaxKind.ImportDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _importClause = visitNode(node.importClause, visitor, isImportClause);
const _moduleSpecifier = visitNode(node.moduleSpecifier, visitor, isExpression);
const _attributes = visitNode(node.attributes, visitor, isImportAttributes);
return updateImportDeclaration(node, _modifiers, _importClause, _moduleSpecifier, _attributes);
},
[SyntaxKind.ExternalModuleReference]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateExternalModuleReference(node, _expression);
},
[SyntaxKind.NamespaceImport]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isIdentifier);
return updateNamespaceImport(node, _name);
},
[SyntaxKind.NamedImports]: (node, visitor) => {
const _elements = visitNodes(node.elements, visitor);
return updateNamedImports(node, _elements);
},
[SyntaxKind.ExportAssignment]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
const _expression = visitNode(node.expression, visitor, isExpression);
return updateExportAssignment(node, _modifiers, _type, _expression);
},
[SyntaxKind.NamespaceExportDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
return updateNamespaceExportDeclaration(node, _modifiers, _name);
},
[SyntaxKind.NamespaceExport]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isModuleExportName);
return updateNamespaceExport(node, _name);
},
[SyntaxKind.NamedExports]: (node, visitor) => {
const _elements = visitNodes(node.elements, visitor);
return updateNamedExports(node, _elements);
},
[SyntaxKind.ExportSpecifier]: (node, visitor) => {
const _propertyName = visitNode(node.propertyName, visitor, isModuleExportName);
const _name = visitNode(node.name, visitor, isModuleExportName);
return updateExportSpecifier(node, _propertyName, _name);
},
[SyntaxKind.CallSignature]: (node, visitor) => {
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateCallSignatureDeclaration(node, _typeParameters, _parameters, _type);
},
[SyntaxKind.ConstructSignature]: (node, visitor) => {
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateConstructSignatureDeclaration(node, _typeParameters, _parameters, _type);
},
[SyntaxKind.Constructor]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
const _body = visitNode(node.body, visitor, isFunctionBody);
return updateConstructorDeclaration(node, _modifiers, _typeParameters, _parameters, _type, _body);
},
[SyntaxKind.GetAccessor]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isPropertyName);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
const _body = visitNode(node.body, visitor, isFunctionBody);
return updateGetAccessorDeclaration(node, _modifiers, _name, _typeParameters, _parameters, _type, _body);
},
[SyntaxKind.SetAccessor]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isPropertyName);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
const _body = visitNode(node.body, visitor, isFunctionBody);
return updateSetAccessorDeclaration(node, _modifiers, _name, _typeParameters, _parameters, _type, _body);
},
[SyntaxKind.IndexSignature]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateIndexSignatureDeclaration(node, _modifiers, _parameters, _type);
},
[SyntaxKind.MethodSignature]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isPropertyName);
const _postfixToken = visitNode(node.postfixToken, visitor, isQuestionOrExclamationToken);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateMethodSignatureDeclaration(node, _modifiers, _name, _postfixToken, _typeParameters, _parameters, _type);
},
[SyntaxKind.MethodDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _asteriskToken = visitNode(node.asteriskToken, visitor, isAsteriskToken);
const _name = visitNode(node.name, visitor, isPropertyName);
const _postfixToken = visitNode(node.postfixToken, visitor, isQuestionOrExclamationToken);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
const _body = visitNode(node.body, visitor, isFunctionBody);
return updateMethodDeclaration(node, _modifiers, _asteriskToken, _name, _postfixToken, _typeParameters, _parameters, _type, _body);
},
[SyntaxKind.PropertySignature]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isPropertyName);
const _postfixToken = visitNode(node.postfixToken, visitor, isQuestionOrExclamationToken);
const _type = visitNode(node.type, visitor, isTypeNode);
const _initializer = visitNode(node.initializer, visitor, isExpression);
return updatePropertySignatureDeclaration(node, _modifiers, _name, _postfixToken, _type, _initializer);
},
[SyntaxKind.PropertyDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isPropertyName);
const _postfixToken = visitNode(node.postfixToken, visitor, isQuestionOrExclamationToken);
const _type = visitNode(node.type, visitor, isTypeNode);
const _initializer = visitNode(node.initializer, visitor, isExpression);
return updatePropertyDeclaration(node, _modifiers, _name, _postfixToken, _type, _initializer);
},
[SyntaxKind.ClassStaticBlockDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _body = visitNode(node.body, visitor, isBlock);
return updateClassStaticBlockDeclaration(node, _modifiers, _body);
},
[SyntaxKind.BinaryExpression]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _left = visitNode(node.left, visitor, isExpression);
const _type = visitNode(node.type, visitor, isTypeNode);
const _operatorToken = visitNode(node.operatorToken, visitor, isBinaryOperatorToken);
const _right = visitNode(node.right, visitor, isExpression);
return updateBinaryExpression(node, _modifiers, _left, _type, _operatorToken, _right);
},
[SyntaxKind.PrefixUnaryExpression]: (node, visitor) => {
const _operand = visitNode(node.operand, visitor, isExpression);
return updatePrefixUnaryExpression(node, _operand);
},
[SyntaxKind.PostfixUnaryExpression]: (node, visitor) => {
const _operand = visitNode(node.operand, visitor, isExpression);
return updatePostfixUnaryExpression(node, _operand);
},
[SyntaxKind.YieldExpression]: (node, visitor) => {
const _asteriskToken = visitNode(node.asteriskToken, visitor, isAsteriskToken);
const _expression = visitNode(node.expression, visitor, isExpression);
return updateYieldExpression(node, _asteriskToken, _expression);
},
[SyntaxKind.ArrowFunction]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
const _equalsGreaterThanToken = visitNode(node.equalsGreaterThanToken, visitor, isEqualsGreaterThanToken);
const _body = visitNode(node.body, visitor, isConciseBody);
return updateArrowFunction(node, _modifiers, _typeParameters, _parameters, _type, _equalsGreaterThanToken, _body);
},
[SyntaxKind.FunctionExpression]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _asteriskToken = visitNode(node.asteriskToken, visitor, isAsteriskToken);
const _name = visitNode(node.name, visitor, isIdentifier);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
const _body = visitNode(node.body, visitor, isFunctionBody);
return updateFunctionExpression(node, _modifiers, _asteriskToken, _name, _typeParameters, _parameters, _type, _body);
},
[SyntaxKind.AsExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateAsExpression(node, _expression, _type);
},
[SyntaxKind.SatisfiesExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateSatisfiesExpression(node, _expression, _type);
},
[SyntaxKind.ConditionalExpression]: (node, visitor) => {
const _condition = visitNode(node.condition, visitor, isExpression);
const _questionToken = visitNode(node.questionToken, visitor, isQuestionToken);
const _whenTrue = visitNode(node.whenTrue, visitor, isExpression);
const _colonToken = visitNode(node.colonToken, visitor, isColonToken);
const _whenFalse = visitNode(node.whenFalse, visitor, isExpression);
return updateConditionalExpression(node, _condition, _questionToken, _whenTrue, _colonToken, _whenFalse);
},
[SyntaxKind.PropertyAccessExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _questionDotToken = visitNode(node.questionDotToken, visitor, isQuestionDotToken);
const _name = visitNode(node.name, visitor, isMemberName);
return updatePropertyAccessExpression(node, _expression, _questionDotToken, _name);
},
[SyntaxKind.ElementAccessExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _questionDotToken = visitNode(node.questionDotToken, visitor, isQuestionDotToken);
const _argumentExpression = visitNode(node.argumentExpression, visitor, isExpression);
return updateElementAccessExpression(node, _expression, _questionDotToken, _argumentExpression);
},
[SyntaxKind.CallExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _questionDotToken = visitNode(node.questionDotToken, visitor, isQuestionDotToken);
const _typeArguments = visitNodes(node.typeArguments, visitor);
const _arguments = visitNodes(node.arguments, visitor);
return updateCallExpression(node, _expression, _questionDotToken, _typeArguments, _arguments);
},
[SyntaxKind.NewExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _typeArguments = visitNodes(node.typeArguments, visitor);
const _arguments = visitNodes(node.arguments, visitor);
return updateNewExpression(node, _expression, _typeArguments, _arguments);
},
[SyntaxKind.MetaProperty]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isIdentifier);
return updateMetaProperty(node, _name);
},
[SyntaxKind.NonNullExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateNonNullExpression(node, _expression);
},
[SyntaxKind.SpreadElement]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateSpreadElement(node, _expression);
},
[SyntaxKind.TemplateExpression]: (node, visitor) => {
const _head = visitNode(node.head, visitor, isTemplateHead);
const _templateSpans = visitNodes(node.templateSpans, visitor);
return updateTemplateExpression(node, _head, _templateSpans);
},
[SyntaxKind.TemplateSpan]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _literal = visitNode(node.literal, visitor, isTemplateMiddleOrTail);
return updateTemplateSpan(node, _expression, _literal);
},
[SyntaxKind.TaggedTemplateExpression]: (node, visitor) => {
const _tag = visitNode(node.tag, visitor, isExpression);
const _questionDotToken = visitNode(node.questionDotToken, visitor, isQuestionDotToken);
const _typeArguments = visitNodes(node.typeArguments, visitor);
const _template = visitNode(node.template, visitor, isTemplateLiteral);
return updateTaggedTemplateExpression(node, _tag, _questionDotToken, _typeArguments, _template);
},
[SyntaxKind.ParenthesizedExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateParenthesizedExpression(node, _expression);
},
[SyntaxKind.ArrayLiteralExpression]: (node, visitor) => {
const _elements = visitNodes(node.elements, visitor);
return updateArrayLiteralExpression(node, _elements);
},
[SyntaxKind.ObjectLiteralExpression]: (node, visitor) => {
const _properties = visitNodes(node.properties, visitor);
return updateObjectLiteralExpression(node, _properties);
},
[SyntaxKind.SpreadAssignment]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateSpreadAssignment(node, _expression);
},
[SyntaxKind.PropertyAssignment]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isPropertyName);
const _postfixToken = visitNode(node.postfixToken, visitor, isQuestionOrExclamationToken);
const _type = visitNode(node.type, visitor, isTypeNode);
const _initializer = visitNode(node.initializer, visitor, isExpression);
return updatePropertyAssignment(node, _modifiers, _name, _postfixToken, _type, _initializer);
},
[SyntaxKind.ShorthandPropertyAssignment]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isPropertyName);
const _postfixToken = visitNode(node.postfixToken, visitor, isQuestionOrExclamationToken);
const _type = visitNode(node.type, visitor, isTypeNode);
const _equalsToken = visitNode(node.equalsToken, visitor, isEqualsToken);
const _objectAssignmentInitializer = visitNode(node.objectAssignmentInitializer, visitor, isExpression);
return updateShorthandPropertyAssignment(node, _modifiers, _name, _postfixToken, _type, _equalsToken, _objectAssignmentInitializer);
},
[SyntaxKind.DeleteExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateDeleteExpression(node, _expression);
},
[SyntaxKind.TypeOfExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateTypeOfExpression(node, _expression);
},
[SyntaxKind.VoidExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateVoidExpression(node, _expression);
},
[SyntaxKind.AwaitExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateAwaitExpression(node, _expression);
},
[SyntaxKind.TypeAssertionExpression]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
const _expression = visitNode(node.expression, visitor, isExpression);
return updateTypeAssertion(node, _type, _expression);
},
[SyntaxKind.UnionType]: (node, visitor) => {
const _types = visitNodes(node.types, visitor);
return updateUnionTypeNode(node, _types);
},
[SyntaxKind.IntersectionType]: (node, visitor) => {
const _types = visitNodes(node.types, visitor);
return updateIntersectionTypeNode(node, _types);
},
[SyntaxKind.ConditionalType]: (node, visitor) => {
const _checkType = visitNode(node.checkType, visitor, isTypeNode);
const _extendsType = visitNode(node.extendsType, visitor, isTypeNode);
const _trueType = visitNode(node.trueType, visitor, isTypeNode);
const _falseType = visitNode(node.falseType, visitor, isTypeNode);
return updateConditionalTypeNode(node, _checkType, _extendsType, _trueType, _falseType);
},
[SyntaxKind.TypeOperator]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateTypeOperatorNode(node, _type);
},
[SyntaxKind.InferType]: (node, visitor) => {
const _typeParameter = visitNode(node.typeParameter, visitor, isTypeParameterDeclaration);
return updateInferTypeNode(node, _typeParameter);
},
[SyntaxKind.ArrayType]: (node, visitor) => {
const _elementType = visitNode(node.elementType, visitor, isTypeNode);
return updateArrayTypeNode(node, _elementType);
},
[SyntaxKind.IndexedAccessType]: (node, visitor) => {
const _objectType = visitNode(node.objectType, visitor, isTypeNode);
const _indexType = visitNode(node.indexType, visitor, isTypeNode);
return updateIndexedAccessTypeNode(node, _objectType, _indexType);
},
[SyntaxKind.TypeReference]: (node, visitor) => {
const _typeName = visitNode(node.typeName, visitor, isEntityName);
const _typeArguments = visitNodes(node.typeArguments, visitor);
return updateTypeReferenceNode(node, _typeName, _typeArguments);
},
[SyntaxKind.ExpressionWithTypeArguments]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _typeArguments = visitNodes(node.typeArguments, visitor);
return updateExpressionWithTypeArguments(node, _expression, _typeArguments);
},
[SyntaxKind.LiteralType]: (node, visitor) => {
const _literal = visitNode(node.literal, visitor);
return updateLiteralTypeNode(node, _literal);
},
[SyntaxKind.TypePredicate]: (node, visitor) => {
const _assertsModifier = visitNode(node.assertsModifier, visitor, isAssertsKeyword);
const _parameterName = visitNode(node.parameterName, visitor, isTypePredicateParameterName);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateTypePredicateNode(node, _assertsModifier, _parameterName, _type);
},
[SyntaxKind.ImportAttribute]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isImportAttributeName);
const _value = visitNode(node.value, visitor, isExpression);
return updateImportAttribute(node, _name, _value);
},
[SyntaxKind.ImportAttributes]: (node, visitor) => {
const _attributes = visitNodes(node.attributes, visitor);
return updateImportAttributes(node, _attributes);
},
[SyntaxKind.TypeQuery]: (node, visitor) => {
const _exprName = visitNode(node.exprName, visitor, isEntityName);
const _typeArguments = visitNodes(node.typeArguments, visitor);
return updateTypeQueryNode(node, _exprName, _typeArguments);
},
[SyntaxKind.MappedType]: (node, visitor) => {
const _readonlyToken = visitNode(node.readonlyToken, visitor, isReadonlyKeywordOrPlusOrMinusToken);
const _typeParameter = visitNode(node.typeParameter, visitor, isTypeParameterDeclaration);
const _nameType = visitNode(node.nameType, visitor, isTypeNode);
const _questionToken = visitNode(node.questionToken, visitor, isQuestionOrPlusOrMinusToken);
const _type = visitNode(node.type, visitor, isTypeNode);
const _members = visitNodes(node.members, visitor);
return updateMappedTypeNode(node, _readonlyToken, _typeParameter, _nameType, _questionToken, _type, _members);
},
[SyntaxKind.TypeLiteral]: (node, visitor) => {
const _members = visitNodes(node.members, visitor);
return updateTypeLiteralNode(node, _members);
},
[SyntaxKind.TupleType]: (node, visitor) => {
const _elements = visitNodes(node.elements, visitor);
return updateTupleTypeNode(node, _elements);
},
[SyntaxKind.NamedTupleMember]: (node, visitor) => {
const _dotDotDotToken = visitNode(node.dotDotDotToken, visitor, isDotDotDotToken);
const _name = visitNode(node.name, visitor, isIdentifier);
const _questionToken = visitNode(node.questionToken, visitor, isQuestionToken);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateNamedTupleMember(node, _dotDotDotToken, _name, _questionToken, _type);
},
[SyntaxKind.OptionalType]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateOptionalTypeNode(node, _type);
},
[SyntaxKind.RestType]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateRestTypeNode(node, _type);
},
[SyntaxKind.ParenthesizedType]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateParenthesizedTypeNode(node, _type);
},
[SyntaxKind.FunctionType]: (node, visitor) => {
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateFunctionTypeNode(node, _typeParameters, _parameters, _type);
},
[SyntaxKind.ConstructorType]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateConstructorTypeNode(node, _modifiers, _typeParameters, _parameters, _type);
},
[SyntaxKind.TemplateLiteralType]: (node, visitor) => {
const _head = visitNode(node.head, visitor, isTemplateHead);
const _templateSpans = visitNodes(node.templateSpans, visitor);
return updateTemplateLiteralTypeNode(node, _head, _templateSpans);
},
[SyntaxKind.TemplateLiteralTypeSpan]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
const _literal = visitNode(node.literal, visitor, isTemplateMiddleOrTail);
return updateTemplateLiteralTypeSpan(node, _type, _literal);
},
[SyntaxKind.SyntheticExpression]: (node, visitor) => {
const _tupleNameSource = visitNode(node.tupleNameSource, visitor);
return updateSyntheticExpression(node, _tupleNameSource);
},
[SyntaxKind.PartiallyEmittedExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updatePartiallyEmittedExpression(node, _expression);
},
[SyntaxKind.JsxElement]: (node, visitor) => {
const _openingElement = visitNode(node.openingElement, visitor, isJsxOpeningElement);
const _children = visitNodes(node.children, visitor);
const _closingElement = visitNode(node.closingElement, visitor, isJsxClosingElement);
return updateJsxElement(node, _openingElement, _children, _closingElement);
},
[SyntaxKind.JsxAttributes]: (node, visitor) => {
const _properties = visitNodes(node.properties, visitor);
return updateJsxAttributes(node, _properties);
},
[SyntaxKind.JsxNamespacedName]: (node, visitor) => {
const _namespace = visitNode(node.namespace, visitor, isIdentifier);
const _name = visitNode(node.name, visitor, isIdentifier);
return updateJsxNamespacedName(node, _namespace, _name);
},
[SyntaxKind.JsxOpeningElement]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isJsxTagNameExpression);
const _typeArguments = visitNodes(node.typeArguments, visitor);
const _attributes = visitNode(node.attributes, visitor, isJsxAttributes);
return updateJsxOpeningElement(node, _tagName, _typeArguments, _attributes);
},
[SyntaxKind.JsxSelfClosingElement]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isJsxTagNameExpression);
const _typeArguments = visitNodes(node.typeArguments, visitor);
const _attributes = visitNode(node.attributes, visitor, isJsxAttributes);
return updateJsxSelfClosingElement(node, _tagName, _typeArguments, _attributes);
},
[SyntaxKind.JsxFragment]: (node, visitor) => {
const _openingFragment = visitNode(node.openingFragment, visitor, isJsxOpeningFragment);
const _children = visitNodes(node.children, visitor);
const _closingFragment = visitNode(node.closingFragment, visitor, isJsxClosingFragment);
return updateJsxFragment(node, _openingFragment, _children, _closingFragment);
},
[SyntaxKind.JsxAttribute]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isJsxAttributeName);
const _initializer = visitNode(node.initializer, visitor, isJsxAttributeValue);
return updateJsxAttribute(node, _name, _initializer);
},
[SyntaxKind.JsxSpreadAttribute]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
return updateJsxSpreadAttribute(node, _expression);
},
[SyntaxKind.JsxClosingElement]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isJsxTagNameExpression);
return updateJsxClosingElement(node, _tagName);
},
[SyntaxKind.JsxExpression]: (node, visitor) => {
const _dotDotDotToken = visitNode(node.dotDotDotToken, visitor, isDotDotDotToken);
const _expression = visitNode(node.expression, visitor, isExpression);
return updateJsxExpression(node, _dotDotDotToken, _expression);
},
[SyntaxKind.SyntaxList]: (node, visitor) => {
const _children = visitNodesArray(node.children, visitor);
return updateSyntaxList(node, _children);
},
[SyntaxKind.JSDoc]: (node, visitor) => {
const _comment = visitNodes(node.comment, visitor);
const _tags = visitNodes(node.tags, visitor);
return updateJSDoc(node, _comment, _tags);
},
[SyntaxKind.JSDocTypeExpression]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateJSDocTypeExpression(node, _type);
},
[SyntaxKind.JSDocNonNullableType]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateJSDocNonNullableType(node, _type);
},
[SyntaxKind.JSDocNullableType]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateJSDocNullableType(node, _type);
},
[SyntaxKind.JSDocVariadicType]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateJSDocVariadicType(node, _type);
},
[SyntaxKind.JSDocOptionalType]: (node, visitor) => {
const _type = visitNode(node.type, visitor, isTypeNode);
return updateJSDocOptionalType(node, _type);
},
[SyntaxKind.JSDocTypeTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocTypeTag(node, _tagName, _typeExpression, _comment);
},
[SyntaxKind.JSDocUnknownTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocUnknownTag(node, _tagName, _comment);
},
[SyntaxKind.JSDocTemplateTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _constraint = visitNode(node.constraint, visitor);
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocTemplateTag(node, _tagName, _constraint, _typeParameters, _comment);
},
[SyntaxKind.JSDocReturnTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor, isTypeNode);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocReturnTag(node, _tagName, _typeExpression, _comment);
},
[SyntaxKind.JSDocPublicTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocPublicTag(node, _tagName, _comment);
},
[SyntaxKind.JSDocPrivateTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocPrivateTag(node, _tagName, _comment);
},
[SyntaxKind.JSDocProtectedTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocProtectedTag(node, _tagName, _comment);
},
[SyntaxKind.JSDocReadonlyTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocReadonlyTag(node, _tagName, _comment);
},
[SyntaxKind.JSDocOverrideTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocOverrideTag(node, _tagName, _comment);
},
[SyntaxKind.JSDocDeprecatedTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocDeprecatedTag(node, _tagName, _comment);
},
[SyntaxKind.JSDocSeeTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _nameExpression = visitNode(node.nameExpression, visitor, isTypeNode);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocSeeTag(node, _tagName, _nameExpression, _comment);
},
[SyntaxKind.JSDocImplementsTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _className = visitNode(node.className, visitor, isExpressionWithTypeArguments);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocImplementsTag(node, _tagName, _className, _comment);
},
[SyntaxKind.JSDocAugmentsTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _className = visitNode(node.className, visitor, isExpressionWithTypeArguments);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocAugmentsTag(node, _tagName, _className, _comment);
},
[SyntaxKind.JSDocSatisfiesTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor, isTypeNode);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocSatisfiesTag(node, _tagName, _typeExpression, _comment);
},
[SyntaxKind.JSDocThrowsTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor, isTypeNode);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocThrowsTag(node, _tagName, _typeExpression, _comment);
},
[SyntaxKind.JSDocThisTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor, isTypeNode);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocThisTag(node, _tagName, _typeExpression, _comment);
},
[SyntaxKind.JSDocImportTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _importClause = visitNode(node.importClause, visitor, isImportClause);
const _moduleSpecifier = visitNode(node.moduleSpecifier, visitor, isExpression);
const _attributes = visitNode(node.attributes, visitor, isImportAttributes);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocImportTag(node, _tagName, _importClause, _moduleSpecifier, _attributes, _comment);
},
[SyntaxKind.JSDocCallbackTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor, isTypeNode);
const _name = visitNode(node.name, visitor, isJSDocFullName);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocCallbackTag(node, _tagName, _typeExpression, _name, _comment);
},
[SyntaxKind.JSDocOverloadTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor, isTypeNode);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocOverloadTag(node, _tagName, _typeExpression, _comment);
},
[SyntaxKind.JSDocTypedefTag]: (node, visitor) => {
const _tagName = visitNode(node.tagName, visitor, isIdentifier);
const _typeExpression = visitNode(node.typeExpression, visitor);
const _name = visitNode(node.name, visitor, isJSDocFullName);
const _comment = visitNodes(node.comment, visitor);
return updateJSDocTypedefTag(node, _tagName, _typeExpression, _name, _comment);
},
[SyntaxKind.JSDocSignature]: (node, visitor) => {
const _typeParameters = visitNodes(node.typeParameters, visitor);
const _parameters = visitNodes(node.parameters, visitor);
const _type = visitNode(node.type, visitor, isTypeNode);
return updateJSDocSignature(node, _typeParameters, _parameters, _type);
},
[SyntaxKind.JSDocNameReference]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isEntityName);
return updateJSDocNameReference(node, _name);
},
[SyntaxKind.SourceFile]: (node, visitor) => {
const _statements = visitNodes(node.statements, visitor);
const _endOfFileToken = visitNode(node.endOfFileToken, visitor, isEndOfFile);
return updateSourceFile(node, _statements, _endOfFileToken);
},
[SyntaxKind.ModuleDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isModuleName);
const _body = visitNode(node.body, visitor, isModuleBody);
return updateModuleDeclaration(node, _modifiers, _name, _body);
},
[SyntaxKind.ImportEqualsDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
const _moduleReference = visitNode(node.moduleReference, visitor, isModuleReference);
return updateImportEqualsDeclaration(node, _modifiers, _name, _moduleReference);
},
[SyntaxKind.ExportDeclaration]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _exportClause = visitNode(node.exportClause, visitor, isNamedExportBindings);
const _moduleSpecifier = visitNode(node.moduleSpecifier, visitor, isExpression);
const _attributes = visitNode(node.attributes, visitor, isImportAttributes);
return updateExportDeclaration(node, _modifiers, _exportClause, _moduleSpecifier, _attributes);
},
[SyntaxKind.ImportType]: (node, visitor) => {
const _argument = visitNode(node.argument, visitor, isTypeNode);
const _attributes = visitNode(node.attributes, visitor, isImportAttributes);
const _qualifier = visitNode(node.qualifier, visitor, isEntityName);
const _typeArguments = visitNodes(node.typeArguments, visitor);
return updateImportTypeNode(node, _argument, _attributes, _qualifier, _typeArguments);
},
[SyntaxKind.ImportClause]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isIdentifier);
const _namedBindings = visitNode(node.namedBindings, visitor, isNamedImportBindings);
return updateImportClause(node, _name, _namedBindings);
},
[SyntaxKind.ImportSpecifier]: (node, visitor) => {
const _propertyName = visitNode(node.propertyName, visitor, isModuleExportName);
const _name = visitNode(node.name, visitor, isIdentifier);
return updateImportSpecifier(node, _propertyName, _name);
},
[SyntaxKind.JSDocLink]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isEntityName);
return updateJSDocLink(node, _name);
},
[SyntaxKind.JSDocLinkPlain]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isEntityName);
return updateJSDocLinkPlain(node, _name);
},
[SyntaxKind.JSDocLinkCode]: (node, visitor) => {
const _name = visitNode(node.name, visitor, isEntityName);
return updateJSDocLinkCode(node, _name);
},
[SyntaxKind.TypeParameter]: (node, visitor) => {
const _modifiers = visitNodes(node.modifiers, visitor);
const _name = visitNode(node.name, visitor, isIdentifier);
const _constraint = visitNode(node.constraint, visitor, isTypeNode);
const _expression = visitNode(node.expression, visitor, isExpression);
const _defaultType = visitNode(node.defaultType, visitor, isTypeNode);
return updateTypeParameterDeclaration(node, _modifiers, _name, _constraint, _expression, _defaultType);
},
[SyntaxKind.SyntheticReferenceExpression]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _thisArg = visitNode(node.thisArg, visitor, isExpression);
return updateSyntheticReferenceExpression(node, _expression, _thisArg);
},
[SyntaxKind.JSDocTypeLiteral]: (node, visitor) => {
const _jsdocPropertyTags = visitNodesArray(node.jsdocPropertyTags, visitor);
return updateJSDocTypeLiteral(node, _jsdocPropertyTags);
},
[SyntaxKind.ForInStatement]: (node, visitor) => {
const _awaitModifier = visitNode(node.awaitModifier, visitor, isAwaitKeyword);
const _initializer = visitNode(node.initializer, visitor, isForInitializer);
const _expression = visitNode(node.expression, visitor, isExpression);
const _statement = visitNode(node.statement, visitor, isStatement);
return updateForInStatement(node, _awaitModifier, _initializer, _expression, _statement);
},
[SyntaxKind.ForOfStatement]: (node, visitor) => {
const _awaitModifier = visitNode(node.awaitModifier, visitor, isAwaitKeyword);
const _initializer = visitNode(node.initializer, visitor, isForInitializer);
const _expression = visitNode(node.expression, visitor, isExpression);
const _statement = visitNode(node.statement, visitor, isStatement);
return updateForOfStatement(node, _awaitModifier, _initializer, _expression, _statement);
},
[SyntaxKind.CaseClause]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _statements = visitNodes(node.statements, visitor);
return updateCaseClause(node, _expression, _statements);
},
[SyntaxKind.DefaultClause]: (node, visitor) => {
const _expression = visitNode(node.expression, visitor, isExpression);
const _statements = visitNodes(node.statements, visitor);
return updateDefaultClause(node, _expression, _statements);
},
[SyntaxKind.ObjectBindingPattern]: (node, visitor) => {
const _elements = visitNodes(node.elements, visitor);
return updateObjectBindingPattern(node, _elements);
},
[SyntaxKind.ArrayBindingPattern]: (node, visitor) => {
const _elements = visitNodes(node.elements, visitor);
return updateArrayBindingPattern(node, _elements);
},
[SyntaxKind.JSDocParameterTag]: visitEachChildOfJSDocParameterTag,
[SyntaxKind.JSDocPropertyTag]: visitEachChildOfJSDocPropertyTag,
};
//# sourceMappingURL=visitor.generated.js.map

View File

@@ -0,0 +1,24 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Symbol {
/**
* Expose the [[Description]] internal slot of a symbol directly.
*/
readonly description: string | undefined;
}

View File

@@ -0,0 +1,132 @@
'use strict';
/// <reference types="../types/index.d.ts" />
// (c) 2020-present Andrea Giammarchi
const {parse: $parse, stringify: $stringify} = JSON;
const {keys} = Object;
const Primitive = String; // it could be Number
const primitive = 'string'; // it could be 'number'
const ignore = {};
const object = 'object';
const noop = (_, value) => value;
const primitives = value => (
value instanceof Primitive ? Primitive(value) : value
);
const Primitives = (_, value) => (
typeof value === primitive ? new Primitive(value) : value
);
const resolver = (input, lazy, parsed, $) => output => {
for (let ke = keys(output), {length} = ke, y = 0; y < length; y++) {
const k = ke[y];
const value = output[k];
if (value instanceof Primitive) {
const tmp = input[+value];
if (typeof tmp === object && !parsed.has(tmp)) {
parsed.add(tmp);
output[k] = ignore;
lazy.push({ o: output, k, r: tmp });
}
else
output[k] = $.call(output, k, tmp);
}
else if (output[k] !== ignore)
output[k] = $.call(output, k, value);
}
return output;
};
const set = (known, input, value) => {
const index = Primitive(input.push(value) - 1);
known.set(value, index);
return index;
};
/**
* Converts a specialized flatted string into a JS value.
* @param {string} text
* @param {(this: any, key: string, value: any) => any} [reviver]
* @returns {any}
*/
const parse = (text, reviver) => {
const input = $parse(text, Primitives).map(primitives);
const $ = reviver || noop;
let value = input[0];
if (typeof value === object && value) {
const lazy = [];
const revive = resolver(input, lazy, new Set, $);
value = revive(value);
let i = 0;
while (i < lazy.length) {
// it could be a lazy.shift() but that's costly
const {o, k, r} = lazy[i++];
o[k] = $.call(o, k, revive(r));
}
}
return $.call({'': value}, '', value);
};
exports.parse = parse;
/**
* Converts a JS value into a specialized flatted string.
* @param {any} value
* @param {((this: any, key: string, value: any) => any) | (string | number)[] | null | undefined} [replacer]
* @param {string | number | undefined} [space]
* @returns {string}
*/
const stringify = (value, replacer, space) => {
const $ = replacer && typeof replacer === object ?
(k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
(replacer || noop);
const known = new Map;
const input = [];
const output = [];
let i = +set(known, input, $.call({'': value}, '', value));
let firstRun = !i;
while (i < input.length) {
firstRun = true;
output[i] = $stringify(input[i++], replace, space);
}
return '[' + output.join(',') + ']';
function replace(key, value) {
if (firstRun) {
firstRun = !firstRun;
return value;
}
const after = $.call(this, key, value);
switch (typeof after) {
case object:
if (after === null) return after;
case primitive:
return known.get(after) || set(known, input, after);
}
return after;
}
};
exports.stringify = stringify;
/**
* Converts a generic value into a JSON serializable object without losing recursion.
* @param {any} value
* @returns {any}
*/
const toJSON = value => $parse(stringify(value));
exports.toJSON = toJSON;
/**
* Converts a previously serialized object with recursion into a recursive one.
* @param {any} value
* @returns {any}
*/
const fromJSON = value => parse($stringify(value));
exports.fromJSON = fromJSON;

View File

@@ -0,0 +1,116 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.findTruthinessAssertedArgument = findTruthinessAssertedArgument;
exports.findTypeGuardAssertedArgument = findTypeGuardAssertedArgument;
const utils_1 = require("@typescript-eslint/utils");
const ts = __importStar(require("typescript"));
/**
* Inspect a call expression to see if it's a call to an assertion function.
* If it is, return the node of the argument that is asserted.
*/
function findTruthinessAssertedArgument(services, node) {
// If the call looks like `assert(expr1, expr2, ...c, d, e, f)`, then we can
// only care if `expr1` or `expr2` is asserted, since anything that happens
// within or after a spread argument is out of scope to reason about.
const checkableArguments = [];
for (const argument of node.arguments) {
if (argument.type === utils_1.AST_NODE_TYPES.SpreadElement) {
break;
}
checkableArguments.push(argument);
}
// nothing to do
if (checkableArguments.length === 0) {
return undefined;
}
const checker = services.program.getTypeChecker();
const signature = services.getResolvedSignature(node);
if (signature == null) {
return undefined;
}
const firstTypePredicateResult = checker.getTypePredicateOfSignature(signature);
if (firstTypePredicateResult == null) {
return undefined;
}
const { kind, parameterIndex, type } = firstTypePredicateResult;
if (!(kind === ts.TypePredicateKind.AssertsIdentifier && type == null)) {
return undefined;
}
return checkableArguments.at(parameterIndex);
}
/**
* Inspect a call expression to see if it's a call to an assertion function.
* If it is, return the node of the argument that is asserted and other useful info.
*/
function findTypeGuardAssertedArgument(services, node) {
// If the call looks like `assert(expr1, expr2, ...c, d, e, f)`, then we can
// only care if `expr1` or `expr2` is asserted, since anything that happens
// within or after a spread argument is out of scope to reason about.
const checkableArguments = [];
for (const argument of node.arguments) {
if (argument.type === utils_1.AST_NODE_TYPES.SpreadElement) {
break;
}
checkableArguments.push(argument);
}
// nothing to do
if (checkableArguments.length === 0) {
return undefined;
}
const checker = services.program.getTypeChecker();
const callSignature = services.getResolvedSignature(node);
if (callSignature == null) {
return undefined;
}
const typePredicateInfo = checker.getTypePredicateOfSignature(callSignature);
if (typePredicateInfo == null) {
return undefined;
}
const { kind, parameterIndex, type } = typePredicateInfo;
if (!((kind === ts.TypePredicateKind.AssertsIdentifier ||
kind === ts.TypePredicateKind.Identifier) &&
type != null)) {
return undefined;
}
if (parameterIndex >= checkableArguments.length) {
return undefined;
}
return {
argument: checkableArguments[parameterIndex],
asserts: kind === ts.TypePredicateKind.AssertsIdentifier,
type,
};
}

View File

@@ -0,0 +1 @@
{"version":3,"file":"sourceFileCache.js","sourceRoot":"","sources":["../../src/api/sourceFileCache.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,SAAS,MAAM,CAAC,UAAkB,EAAE,SAAiB;IACjD,OAAO,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC;AACxC,CAAC;AAgBD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,eAAe;IACxB,wDAAwD;IAChD,KAAK,GAAkC,IAAI,GAAG,EAAE,CAAC;IACzD,qFAAqF;IAC7E,oBAAoB,GAAwC,IAAI,GAAG,EAAE,CAAC;IAE9E;;;;;;;;OAQG;IACH,WAAW,CAAC,IAAU,EAAE,UAAkB,EAAE,SAAiB;QACzD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACjD,OAAO,KAAK,EAAE,IAAI,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,IAAU,EAAE,IAAgB,EAAE,eAAuB,EAAE,WAAmB,EAAE,UAAkB,EAAE,SAAiB;QACjH,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAClC,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC1C,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,KAAK,eAAe,IAAI,CAAC,CAAC,WAAW,KAAK,WAAW,CAAC,CAAC;QAC3G,IAAI,QAAQ,EAAE,CAAC;YACX,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;YAC5C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACzB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACH,iBAAiB,CAAC,aAAqB,EAAE,kBAA0B,EAAE,OAAoC;QACrG,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACzE,IAAI,CAAC,cAAc;YAAE,OAAO;QAE5B,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,eAAe,IAAI,EAAE,CAAC,CAAC;QAChE,MAAM,eAAe,GAAG,OAAO,EAAE,eAAe,IAAI,EAAE,CAAC;QAEvD,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,cAAc,EAAE,CAAC;YAC9C,IAAI,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC;gBAAE,SAAS;YAE7C,MAAM,cAAc,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;YAClD,IAAI,YAAqC,CAAC;YAC1C,IAAI,cAAc,EAAE,CAAC;gBACjB,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;gBACjC,KAAK,MAAM,CAAC,IAAI,cAAc,CAAC,YAAY,IAAI,EAAE;oBAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBACvE,KAAK,MAAM,CAAC,IAAI,cAAc,CAAC,YAAY,IAAI,EAAE;oBAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC3E,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;YACtD,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;YAEhD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACvB,IAAI,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC;oBAAE,SAAS;gBACtC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACrC,IAAI,CAAC,OAAO;oBAAE,SAAS;gBACvB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;oBAC1B,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;wBAC1B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;wBACvB,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;oBACnD,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,UAAkB;QAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,UAAU,EAAE,CAAC;YAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;YAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACvB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACrC,IAAI,CAAC,OAAO;oBAAE,SAAS;gBACvB,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC3C,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBAC5B,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;wBAC7B,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACzB,CAAC;gBACL,CAAC;gBACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC5B,CAAC;YACL,CAAC;QACL,CAAC;QACD,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAEO,SAAS,CAAC,UAAkB,EAAE,SAAiB,EAAE,IAAU;QAC/D,IAAI,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;YACvB,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;YAClB,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,KAAK;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAU;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACJ"}

View File

@@ -0,0 +1,54 @@
export const balanced = (a, b, str) => {
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
const r = ma !== null && mb != null && range(ma, mb, str);
return (r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + ma.length, r[1]),
post: str.slice(r[1] + mb.length),
});
};
const maybeMatch = (reg, str) => {
const m = str.match(reg);
return m ? m[0] : null;
};
export const range = (a, b, str) => {
let begs, beg, left, right = undefined, result;
let ai = str.indexOf(a);
let bi = str.indexOf(b, ai + 1);
let i = ai;
if (ai >= 0 && bi > 0) {
if (a === b) {
return [ai, bi];
}
begs = [];
left = str.length;
while (i >= 0 && !result) {
if (i === ai) {
begs.push(i);
ai = str.indexOf(a, i + 1);
}
else if (begs.length === 1) {
const r = begs.pop();
if (r !== undefined)
result = [r, bi];
}
else {
beg = begs.pop();
if (beg !== undefined && beg < left) {
left = beg;
right = bi;
}
bi = str.indexOf(b, i + 1);
}
i = ai < bi && ai >= 0 ? ai : bi;
}
if (begs.length && right !== undefined) {
result = [left, right];
}
}
return result;
};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1,77 @@
import RAL from './ral';
import { Event } from './events';
import { Message } from './messages';
import { ContentDecoder, ContentTypeDecoder } from './encoding';
import { Disposable } from './api';
/**
* A callback that receives each incoming JSON-RPC message.
*/
export interface DataCallback {
(data: Message): void;
}
export interface PartialMessageInfo {
readonly messageToken: number;
readonly waitingTime: number;
}
/** Reads JSON-RPC messages from some underlying transport. */
export interface MessageReader {
/** Raised whenever an error occurs while reading a message. */
readonly onError: Event<Error>;
/** An event raised when the end of the underlying transport has been reached. */
readonly onClose: Event<void>;
/**
* An event that *may* be raised to inform the owner that only part of a message has been received.
* A MessageReader implementation may choose to raise this event after a timeout elapses while waiting for more of a partially received message to be received.
*/
readonly onPartialMessage: Event<PartialMessageInfo>;
/**
* Begins listening for incoming messages. To be called at most once.
* @param callback A callback for receiving decoded messages.
*/
listen(callback: DataCallback): Disposable;
/** Releases resources incurred from reading or raising events. Does NOT close the underlying transport, if any. */
dispose(): void;
}
export declare namespace MessageReader {
function is(value: any): value is MessageReader;
}
export declare abstract class AbstractMessageReader implements MessageReader {
private errorEmitter;
private closeEmitter;
private partialMessageEmitter;
constructor();
dispose(): void;
get onError(): Event<Error>;
protected fireError(error: any): void;
get onClose(): Event<void>;
protected fireClose(): void;
get onPartialMessage(): Event<PartialMessageInfo>;
protected firePartialMessage(info: PartialMessageInfo): void;
private asError;
abstract listen(callback: DataCallback): Disposable;
}
export interface MessageReaderOptions {
charset?: RAL.MessageBufferEncoding;
contentDecoder?: ContentDecoder;
contentDecoders?: ContentDecoder[];
contentTypeDecoder?: ContentTypeDecoder;
contentTypeDecoders?: ContentTypeDecoder[];
}
export declare class ReadableStreamMessageReader extends AbstractMessageReader {
private readable;
private options;
private callback;
private nextMessageLength;
private messageToken;
private buffer;
private partialMessageTimer;
private _partialMessageTimeout;
private readSemaphore;
constructor(readable: RAL.ReadableStream, options?: RAL.MessageBufferEncoding | MessageReaderOptions);
set partialMessageTimeout(timeout: number);
get partialMessageTimeout(): number;
listen(callback: DataCallback): Disposable;
private onData;
private clearPartialMessageTimer;
private setPartialMessageTimer;
}

View File

@@ -0,0 +1,9 @@
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
export default _default;
/**
* This is a compatibility ruleset that:
* - disables rules from eslint:recommended which are already handled by TypeScript.
* - enables rules that make sense due to TS's typechecking / transpilation.
* @see {@link https://typescript-eslint.io/users/configs/#eslint-recommended}
*/
declare function _default(_plugin: FlatConfig.Plugin, _parser: FlatConfig.Parser): FlatConfig.Config;

View File

@@ -0,0 +1 @@
{"version":3,"file":"scriptTarget.enum.js","sourceRoot":"","sources":["../../src/enums/scriptTarget.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAeX;AAfD,WAAY,YAAY;IACpB,mDAAU,CAAA;IACV,mDAAU,CAAA;IACV,mDAAU,CAAA;IACV,mDAAU,CAAA;IACV,mDAAU,CAAA;IACV,mDAAU,CAAA;IACV,mDAAU,CAAA;IACV,mDAAU,CAAA;IACV,oDAAW,CAAA;IACX,oDAAW,CAAA;IACX,oDAAW,CAAA;IACX,oDAAW,CAAA;IACX,iDAAU,CAAA;IACV,oDAAe,CAAA;AACnB,CAAC,EAfW,YAAY,KAAZ,YAAY,QAevB"}

View File

@@ -0,0 +1,63 @@
var test = require('tape')
var _JSON = require('../')
function clone (o) {
return JSON.parse(JSON.stringify(o))
}
var examples = {
simple: { foo: [], bar: {}, baz: Buffer.from('some binary data') },
just_buffer: Buffer.from('JUST A BUFFER'),
all_types: {
string:'hello',
number: 3145,
null: null,
object: {},
array: [],
boolean: true,
boolean2: false
},
foo: Buffer.from('foo'),
foo2: Buffer.from('foo2'),
escape: {
buffer: Buffer.from('x'),
string: _JSON.stringify(Buffer.from('x'))
},
escape2: {
buffer: Buffer.from('x'),
string: ':base64:'+ Buffer.from('x').toString('base64')
},
undefined: {
empty: undefined, test: true
},
undefined2: {
first: 1, empty: undefined, test: true
},
undefinedArray: {
array: [undefined, 1, 'two']
},
fn: {
fn: function () {}
},
undefined: undefined
}
for(k in examples)
(function (value, k) {
test(k, function (t) {
var s = _JSON.stringify(value)
console.log('parse', s)
if(JSON.stringify(value) !== undefined) {
console.log(s)
var _value = _JSON.parse(s)
t.deepEqual(clone(_value), clone(value))
}
else
t.equal(s, undefined)
t.end()
})
})(examples[k], k)

View File

@@ -0,0 +1,278 @@
# Browser API
Pino is compatible with [`browserify`](https://npm.im/browserify) for browser-side usage:
This can be useful with isomorphic/universal JavaScript code.
By default, in the browser,
`pino` uses corresponding [Log4j](https://en.wikipedia.org/wiki/Log4j) `console` methods (`console.error`, `console.warn`, `console.info`, `console.debug`, `console.trace`) and uses `console.error` for any `fatal` level logs.
## Options
Pino can be passed a `browser` object in the options object,
which can have the following properties:
### `asObject` (Boolean)
```js
const pino = require('pino')({browser: {asObject: true}})
```
The `asObject` option will create a pino-like log object instead of
passing all arguments to a console method, for instance:
```js
pino.info('hi') // creates and logs {msg: 'hi', level: 30, time: <ts>}
```
When `write` is set, `asObject` will always be `true`.
### `asObjectBindingsOnly` (Boolean)
```js
const pino = require('pino')({browser: {asObjectBindingsOnly: true}})
```
The `asObjectBindingsOnly` option is similar to `asObject` but will keep the message
and arguments unformatted. This allows to defer formatting the message to the
actual call to `console` methods, where browsers then have richer formatting in
their devtools than when pino will format the message to a string first.
```js
pino.info('hello %s', 'world') // creates and logs {level: 30, time: <ts>}, 'hello %s', 'world'
```
### `formatters` (Object)
An object containing functions for formatting the shape of the log lines. When provided, it enables the logger to produce a pino-like log object with customized formatting. Currently, it supports formatting for the `level` object only.
##### `level`
Changes the shape of the log level. The default shape is `{ level: number }`.
The function takes two arguments, the label of the level (e.g. `'info'`)
and the numeric value (e.g. `30`).
```js
const formatters = {
level (label, number) {
return { level: number }
}
}
```
### `reportCaller` (Boolean)
Attempts to capture and include the originating callsite (file:line:column) for each log call in the browser logger.
- When used together with `asObject` (or when `formatters` are provided), the callsite is added as a `caller` string property on the emitted log object.
- In the default mode (nonobject), the callsite string is appended as the last argument passed to the corresponding `console` method. This makes the location visible in the console output even though the consoles clickable header still points to Pino internals.
```js
// Object mode: adds `caller` to the log object
const pino = require('pino')({
browser: {
asObject: true,
reportCaller: true
}
})
pino.info('hello')
// -> { level: 30, msg: 'hello', time: <ts>, caller: '/path/to/file.js:10:15' }
// Default mode: appends the caller string as the last console argument
const pino2 = require('pino')({
browser: {
reportCaller: true
}
})
pino2.info('hello')
// -> console receives: 'hello', '/path/to/file.js:10:15'
```
Notes:
- This is a besteffort feature that parses the JavaScript Error stack. Stack formats vary across engines.
- The clickable link shown by devtools for a console message is determined by where `console.*` is invoked and cannot be changed by libraries; `reportCaller` surfaces the user callsite alongside the log message.
### `write` (Function | Object)
Instead of passing log messages to `console.log` they can be passed to
a supplied function.
If `write` is set to a single function, all logging objects are passed
to this function.
```js
const pino = require('pino')({
browser: {
write: (o) => {
// do something with o
}
}
})
```
If `write` is an object, it can have methods that correspond to the
levels. When a message is logged at a given level, the corresponding
method is called. If a method isn't present, the logging falls back
to using the `console`.
```js
const pino = require('pino')({
browser: {
write: {
info: function (o) {
//process info log object
},
error: function (o) {
//process error log object
}
}
}
})
```
### `serialize`: (Boolean | Array)
The serializers provided to `pino` are ignored by default in the browser, including
the standard serializers provided with Pino. Since the default destination for log
messages is the console, values such as `Error` objects are enhanced for inspection,
which they otherwise wouldn't be if the Error serializer was enabled.
We can turn all serializers on,
```js
const pino = require('pino')({
browser: {
serialize: true
}
})
```
Or we can selectively enable them via an array:
```js
const pino = require('pino')({
serializers: {
custom: myCustomSerializer,
another: anotherSerializer
},
browser: {
serialize: ['custom']
}
})
// following will apply myCustomSerializer to the custom property,
// but will not apply anotherSerializer to another key
pino.info({custom: 'a', another: 'b'})
```
When `serialize` is `true` the standard error serializer is also enabled (see https://github.com/pinojs/pino/blob/master/docs/api.md#stdSerializers).
This is a global serializer, which will apply to any `Error` objects passed to the logger methods.
If `serialize` is an array the standard error serializer is also automatically enabled, it can
be explicitly disabled by including a string in the serialize array: `!stdSerializers.err`, like so:
```js
const pino = require('pino')({
serializers: {
custom: myCustomSerializer,
another: anotherSerializer
},
browser: {
serialize: ['!stdSerializers.err', 'custom'] //will not serialize Errors, will serialize `custom` keys
}
})
```
The `serialize` array also applies to any child logger serializers (see https://github.com/pinojs/pino/blob/master/docs/api.md#discussion-2
for how to set child-bound serializers).
Unlike server pino the serializers apply to every object passed to the logger method,
if the `asObject` option is `true`, this results in the serializers applying to the
first object (as in server pino).
For more info on serializers see https://github.com/pinojs/pino/blob/master/docs/api.md#mergingobject.
### `transmit` (Object)
An object with `send` and `level` properties.
The `transmit.level` property specifies the minimum level (inclusive) of when the `send` function
should be called, if not supplied the `send` function be called based on the main logging `level`
(set via `options.level`, defaulting to `info`).
The `transmit` object must have a `send` function which will be called after
writing the log message. The `send` function is passed the level of the log
message and a `logEvent` object.
The `logEvent` object is a data structure representing a log message, it represents
the arguments passed to a logger statement, the level
at which they were logged, and the hierarchy of child bindings.
The `logEvent` format is structured like so:
```js
{
ts = Number,
messages = Array,
bindings = Array,
level: { label = String, value = Number}
}
```
The `ts` property is a Unix epoch timestamp in milliseconds, the time is taken from the moment the
logger method is called.
The `messages` array is all arguments passed to logger method, (for instance `logger.info('a', 'b', 'c')`
would result in `messages` array `['a', 'b', 'c']`).
The `bindings` array represents each child logger (if any), and the relevant bindings.
For instance, given `logger.child({a: 1}).child({b: 2}).info({c: 3})`, the bindings array
would hold `[{a: 1}, {b: 2}]` and the `messages` array would be `[{c: 3}]`. The `bindings`
are ordered according to their position in the child logger hierarchy, with the lowest index
being the top of the hierarchy.
By default, serializers are not applied to log output in the browser, but they will *always* be
applied to `messages` and `bindings` in the `logEvent` object. This allows us to ensure a consistent
format for all values between server and client.
The `level` holds the label (for instance `info`), and the corresponding numerical value
(for instance `30`). This could be important in cases where client-side level values and
labels differ from server-side.
The point of the `send` function is to remotely record log messages:
```js
const pino = require('pino')({
browser: {
transmit: {
level: 'warn',
send: function (level, logEvent) {
if (level === 'warn') {
// maybe send the logEvent to a separate endpoint
// or maybe analyze the messages further before sending
}
// we could also use the `logEvent.level.value` property to determine
// numerical value
if (logEvent.level.value >= 50) { // covers error and fatal
// send the logEvent somewhere
}
}
}
}
})
```
### `disabled` (Boolean)
```js
const pino = require('pino')({browser: {disabled: true}})
```
The `disabled` option will disable logging in browser if set
to `true`, by default it is set to `false`.

View File

@@ -0,0 +1,266 @@
{
"name": "@noble/hashes",
"version": "1.8.0",
"description": "Audited & minimal 0-dependency JS implementation of SHA, RIPEMD, BLAKE, HMAC, HKDF, PBKDF & Scrypt",
"files": [
"/*.js",
"/*.js.map",
"/*.d.ts",
"/*.d.ts.map",
"esm",
"src/*.ts"
],
"scripts": {
"bench": "node benchmark/noble.js",
"bench:compare": "MBENCH_DIMS='algorithm,buffer,library' node benchmark/hashes.js",
"bench:compare-hkdf": "MBENCH_DIMS='algorithm,length,library' node benchmark/hkdf.js",
"bench:compare-scrypt": "MBENCH_DIMS='iters,library' MBENCH_FILTER='async' node benchmark/scrypt.js",
"bench:install": "cd benchmark; npm install; npm install .. --install-links",
"build": "npm run build:clean; tsc && tsc -p tsconfig.cjs.json",
"build:clean": "rm -f *.{js,d.ts,js.map,d.ts.map} esm/*.{js,js.map,d.ts.map}",
"build:release": "npx jsbt esbuild test/build",
"lint": "prettier --check 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",
"format": "prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",
"test": "node --import ./test/esm-register.js test/index.js",
"test:bun": "bun test/index.js",
"test:deno": "deno --allow-env --allow-read --import-map=./test/import_map.json test/index.js",
"test:dos": "node --import ./test/esm-register.js test/slow-dos.test.js",
"test:big": "node --import ./test/esm-register.js test/slow-big.test.js",
"test:kdf": "node --import ./test/esm-register.js test/slow-kdf.test.js"
},
"author": "Paul Miller (https://paulmillr.com)",
"homepage": "https://paulmillr.com/noble/",
"repository": {
"type": "git",
"url": "git+https://github.com/paulmillr/noble-hashes.git"
},
"license": "MIT",
"devDependencies": {
"@paulmillr/jsbt": "0.3.3",
"fast-check": "3.0.0",
"micro-bmark": "0.4.1",
"micro-should": "0.5.2",
"prettier": "3.5.3",
"typescript": "5.8.3"
},
"engines": {
"node": "^14.21.3 || >=16"
},
"exports": {
".": {
"import": "./esm/index.js",
"require": "./index.js"
},
"./crypto": {
"node": {
"import": "./esm/cryptoNode.js",
"default": "./cryptoNode.js"
},
"import": "./esm/crypto.js",
"default": "./crypto.js"
},
"./_assert": {
"import": "./esm/_assert.js",
"require": "./_assert.js"
},
"./_md": {
"import": "./esm/_md.js",
"require": "./_md.js"
},
"./argon2": {
"import": "./esm/argon2.js",
"require": "./argon2.js"
},
"./blake1": {
"import": "./esm/blake1.js",
"require": "./blake1.js"
},
"./blake2": {
"import": "./esm/blake2.js",
"require": "./blake2.js"
},
"./blake2b": {
"import": "./esm/blake2b.js",
"require": "./blake2b.js"
},
"./blake2s": {
"import": "./esm/blake2s.js",
"require": "./blake2s.js"
},
"./blake3": {
"import": "./esm/blake3.js",
"require": "./blake3.js"
},
"./eskdf": {
"import": "./esm/eskdf.js",
"require": "./eskdf.js"
},
"./hkdf": {
"import": "./esm/hkdf.js",
"require": "./hkdf.js"
},
"./hmac": {
"import": "./esm/hmac.js",
"require": "./hmac.js"
},
"./legacy": {
"import": "./esm/legacy.js",
"require": "./legacy.js"
},
"./pbkdf2": {
"import": "./esm/pbkdf2.js",
"require": "./pbkdf2.js"
},
"./ripemd160": {
"import": "./esm/ripemd160.js",
"require": "./ripemd160.js"
},
"./scrypt": {
"import": "./esm/scrypt.js",
"require": "./scrypt.js"
},
"./sha1": {
"import": "./esm/sha1.js",
"require": "./sha1.js"
},
"./sha2": {
"import": "./esm/sha2.js",
"require": "./sha2.js"
},
"./sha3-addons": {
"import": "./esm/sha3-addons.js",
"require": "./sha3-addons.js"
},
"./sha3": {
"import": "./esm/sha3.js",
"require": "./sha3.js"
},
"./sha256": {
"import": "./esm/sha256.js",
"require": "./sha256.js"
},
"./sha512": {
"import": "./esm/sha512.js",
"require": "./sha512.js"
},
"./utils": {
"import": "./esm/utils.js",
"require": "./utils.js"
},
"./_assert.js": {
"import": "./esm/_assert.js",
"require": "./_assert.js"
},
"./_md.js": {
"import": "./esm/_md.js",
"require": "./_md.js"
},
"./argon2.js": {
"import": "./esm/argon2.js",
"require": "./argon2.js"
},
"./blake1.js": {
"import": "./esm/blake1.js",
"require": "./blake1.js"
},
"./blake2.js": {
"import": "./esm/blake2.js",
"require": "./blake2.js"
},
"./blake2b.js": {
"import": "./esm/blake2b.js",
"require": "./blake2b.js"
},
"./blake2s.js": {
"import": "./esm/blake2s.js",
"require": "./blake2s.js"
},
"./blake3.js": {
"import": "./esm/blake3.js",
"require": "./blake3.js"
},
"./eskdf.js": {
"import": "./esm/eskdf.js",
"require": "./eskdf.js"
},
"./hkdf.js": {
"import": "./esm/hkdf.js",
"require": "./hkdf.js"
},
"./hmac.js": {
"import": "./esm/hmac.js",
"require": "./hmac.js"
},
"./legacy.js": {
"import": "./esm/legacy.js",
"require": "./legacy.js"
},
"./pbkdf2.js": {
"import": "./esm/pbkdf2.js",
"require": "./pbkdf2.js"
},
"./ripemd160.js": {
"import": "./esm/ripemd160.js",
"require": "./ripemd160.js"
},
"./scrypt.js": {
"import": "./esm/scrypt.js",
"require": "./scrypt.js"
},
"./sha1.js": {
"import": "./esm/sha1.js",
"require": "./sha1.js"
},
"./sha2.js": {
"import": "./esm/sha2.js",
"require": "./sha2.js"
},
"./sha3-addons.js": {
"import": "./esm/sha3-addons.js",
"require": "./sha3-addons.js"
},
"./sha3.js": {
"import": "./esm/sha3.js",
"require": "./sha3.js"
},
"./sha256.js": {
"import": "./esm/sha256.js",
"require": "./sha256.js"
},
"./sha512.js": {
"import": "./esm/sha512.js",
"require": "./sha512.js"
},
"./utils.js": {
"import": "./esm/utils.js",
"require": "./utils.js"
}
},
"sideEffects": false,
"browser": {
"node:crypto": false,
"./crypto": "./crypto.js"
},
"keywords": [
"sha",
"sha2",
"sha3",
"sha256",
"sha512",
"keccak",
"kangarootwelve",
"ripemd160",
"blake2",
"blake3",
"hmac",
"hkdf",
"pbkdf2",
"scrypt",
"kdf",
"hash",
"cryptography",
"security",
"noble"
],
"funding": "https://paulmillr.com/funding/"
}